---
name: glean-team-sync
description: >
  Sync team structure from Glean people directory into WALL-E's brain.
  Reads the owner's profile, their manager, peers, and direct reports,
  then recursively maps each person's contact info, location, and role.
version: 1.0.0
author: wall-e
execution: script
entry: run.js
trigger:
  type: manual
config:
  owner_name:
    type: string
    default: ""
    description: "Name of the person whose team to sync (defaults to WALLE_OWNER_NAME)"
  depth:
    type: number
    default: 2
    description: "How many levels of org tree to traverse (1=direct team, 2=skip-level reports)"
tags: [glean, team, people, directory, org, contacts]
permissions:
  - glean:read
  - brain:write
---
# Glean Team Sync

## What This Skill Does

Syncs team structure from Glean's people directory into WALL-E's brain.
Starting from the owner, it discovers the org tree (manager, peers, direct
reports) and stores each person's profile as a memory.

## How It Works

1. Search Glean for the owner by name via `employee_search` MCP tool
2. Parse the profile: name, title, department, location, email, manager, reports
3. Recursively search each team member up to configured depth
4. Dedup by `source_id` = `glean:person:{email}` — skip unchanged, update modified
5. Store as memories with `source: 'glean'`, `memory_type: 'team_member'`

## Memory Format

Each person is stored as a memory:
- **source**: `glean`
- **source_id**: `glean:person:{email}`
- **source_channel**: department or team name
- **memory_type**: `team_member`
- **subject**: person's full name
- **content**: human-readable profile with title, location, contact, org relationship
- **metadata**: JSON with structured fields (email, title, department, location, manager, reports, relationship)
- **importance**: 0.5 (team context)

## Output

Returns: `{ synced, updated, skipped, errors, people: [...names] }`
