@ekanos/cli 0.33.1 → 0.33.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,8 +4,20 @@ import type { TeamAgentAccess } from '@ekanos/integration-schema';
4
4
  * every run. Any other agent acts as itself: the person it "runs as" only
5
5
  * lends their own connection to a per-person product (one each person
6
6
  * connects for themselves), and every other product runs on the team's.
7
+ *
8
+ * `personConnections` is the host's answer to which granted products
9
+ * actually run on that person's connection: none means every call runs on
10
+ * the team's (or the Source's), so no per-person connection is named. Absent
11
+ * or null (an older host, or a grant of whatever is connected): the general
12
+ * wording.
7
13
  */
8
- export declare function identityLabel(runsAs: string | null, personal?: boolean): string;
14
+ export declare function identityLabel(runsAs: string | null, personal?: boolean, personConnections?: readonly string[] | null): string;
15
+ /**
16
+ * The products (by key, as `personConnections` names them) a confirmation's `connections` say run on the runs-as
17
+ * person's own connection; null when the host sent none (an older host, or a
18
+ * grant of whatever is connected).
19
+ */
20
+ export declare function personConnectionsOf(access: TeamAgentAccess | undefined): string[] | null;
9
21
  /**
10
22
  * Whose connection, to what, the confirmation covers: per product from the
11
23
  * host's `connections` (the team's, the Source's, or the runs-as person's own
@@ -3,13 +3,37 @@
3
3
  * every run. Any other agent acts as itself: the person it "runs as" only
4
4
  * lends their own connection to a per-person product (one each person
5
5
  * connects for themselves), and every other product runs on the team's.
6
+ *
7
+ * `personConnections` is the host's answer to which granted products
8
+ * actually run on that person's connection: none means every call runs on
9
+ * the team's (or the Source's), so no per-person connection is named. Absent
10
+ * or null (an older host, or a grant of whatever is connected): the general
11
+ * wording.
6
12
  */
7
- export function identityLabel(runsAs, personal = false) {
13
+ export function identityLabel(runsAs, personal = false, personConnections) {
8
14
  if (personal)
9
15
  return `acts for ${runsAs !== null && runsAs !== void 0 ? runsAs : 'nobody (its creator left the team)'}`;
10
- return runsAs
11
- ? `acts as itself · per-person connections: ${possessive(runsAs)} own`
12
- : 'acts as itself · paused: the person it runs as left the team';
16
+ if (!runsAs)
17
+ return 'acts as itself · paused: the person it runs as left the team';
18
+ if (!personConnections) {
19
+ return `acts as itself · per-person connections: ${possessive(runsAs)} own`;
20
+ }
21
+ if (personConnections.length === 0) {
22
+ return "acts as itself · on the team's connections";
23
+ }
24
+ return `acts as itself · per-person connections: ${possessive(runsAs)} own (${personConnections.join(', ')})`;
25
+ }
26
+ /**
27
+ * The products (by key, as `personConnections` names them) a confirmation's `connections` say run on the runs-as
28
+ * person's own connection; null when the host sent none (an older host, or a
29
+ * grant of whatever is connected).
30
+ */
31
+ export function personConnectionsOf(access) {
32
+ if (!(access === null || access === void 0 ? void 0 : access.connections))
33
+ return null;
34
+ return access.connections
35
+ .filter((entry) => entry.via === 'person')
36
+ .map((entry) => entry.key);
13
37
  }
14
38
  function possessive(person) {
15
39
  return person === 'you' ? 'your' : `${person}'s`;
@@ -1 +1 @@
1
- {"version":3,"file":"team-agent-access.js","sourceRoot":"","sources":["../../src/commands/team-agent-access.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,MAAqB,EAAE,QAAQ,GAAG,KAAK;IACnE,IAAI,QAAQ;QACV,OAAO,YAAY,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,oCAAoC,EAAE,CAAC;IACtE,OAAO,MAAM;QACX,CAAC,CAAC,4CAA4C,UAAU,CAAC,MAAM,CAAC,MAAM;QACtE,CAAC,CAAC,8DAA8D,CAAC;AACrE,CAAC;AAED,SAAS,UAAU,CAAC,MAAc;IAChC,OAAO,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,CAAC;AACnD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAAuB,EACvB,MAAqB;IAErB,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC;IAC7D,I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AC,MAAuB;IACpD,IAAI,MAAM,CAAC,KAAK,KAAK,KAAK;QAAE,OAAO,0CAA0C,CAAC;IAC9E,IAAI,MAAM,CAAC,KAAK,KAAK,WAAW;QAC9B,OAAO,sCAAsC,CAAC;IAChD,MAAM,KAAK,GAAG;QACZ,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,eAAe,CAAC;QACnE,GAAG,MAAM,CAAC,KAAK;KAChB,CAAC;IACF,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC;QACrB,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;QAClB,CAAC,CAAC,mCAAmC,CAAC;AAC1C,CAAC","sourcesContent":["import type { TeamAgentAccess } from '@ekanos/integration-schema';\n\n/**\n * Who the agent is in its runs. A personal agent acts for its creator on\n * every run. Any other agent acts as itself: the person it \"runs as\" only\n * lends their own connection to a per-person product (one each person\n * connects for themselves), and every other product runs on the team's.\n */\nexport function identityLabel(runsAs: string | null, personal = false): string {\n if (personal)\n return `acts for ${runsAs ?? 'nobody (its creator left the team)'}`;\n return runsAs\n ? `acts as itself · per-person connections: ${possessive(runsAs)} own`\n : 'acts as itself · paused: the person it runs as left the team';\n}\n\nfunction possessive(person: string): string {\n return person === 'you' ? 'your' : `${person}'s`;\n}\n\n/**\n * Whose connection, to what, the confirmation covers: per product from the\n * host's `connections` (the team's, the Source's, or the runs-as person's own\n * for a per-person product). An older host sends no `connections`: then the\n * team's connections, and the runs-as person's own only for a per-person\n * product.\n */\nexport function describeConnections(\n access: TeamAgentAccess,\n runsAs: string | null,\n): string {\n const person = runsAs ? possessive(runsAs) : \"its creator's\";\n if (!access.connections) {\n return `${describeAccess(access)} — on the team's connections, or ${person} own for a per-person product`;\n }\n const covered = new Set(access.connections.flatMap((entry) => entry.tools));\n const parts = access.connections.map((entry) => {\n const whose =\n entry.via === 'team'\n ? \"the team's\"\n : entry.via === 'source'\n ? \"the Source's\"\n : `${person} own`;\n const what = entry.everyTool ? 'every tool' : entry.tools.join(', ');\n return `${whose} ${entry.name} connection (${what})`;\n });\n const rest = access.tools.filter((tool) => !covered.has(tool));\n if (rest.length > 0) parts.push(rest.join(', '));\n return parts.length > 0\n ? parts.join('; ')\n : 'nothing yet (no products granted)';\n}\n\n/** What a confirmation covers, in words: whose connections, to what. */\nexport function describeAccess(access: TeamAgentAccess): string {\n if (access.scope === 'all') return 'every tool of every product they connect';\n if (access.scope === 'read_only')\n return 'read from every product they connect';\n const parts = [\n ...access.products.map((product) => `${product.name} (every tool)`),\n ...access.tools,\n ];\n return parts.length > 0\n ? parts.join(', ')\n : 'nothing yet (no products granted)';\n}\n"]}
1
+ {"version":3,"file":"team-agent-access.js","sourceRoot":"","sources":["../../src/commands/team-agent-access.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,aAAa,CAC3B,MAAqB,EACrB,QAAQ,GAAG,KAAK,EAChB,iBAA4C;IAE5C,IAAI,QAAQ;QACV,OAAO,YAAY,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,oCAAoC,EAAE,CAAC;IACtE,IAAI,CAAC,MAAM;QACT,OAAO,8DAA8D,CAAC;IACxE,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,OAAO,4CAA4C,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC;IAC9E,CAAC;IACD,IAAI,iBAAiB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnC,OAAO,4CAA4C,CAAC;IACtD,CAAC;IACD,OAAO,4CAA4C,UAAU,CAAC,MAAM,CAAC,SAAS,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;AAChH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAAmC;IAEnC,IAAI,EAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,WAAW,CAAA;QAAE,OAAO,IAAI,CA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KAAK,IAAI,KAAK,CAAC,IAAI,gBAAgB,IAAI,GAAG,CAAC;IACvD,CAAC,CAAC,CAAC;IACH,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/D,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACjD,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC;QACrB,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;QAClB,CAAC,CAAC,mCAAmC,CAAC;AAC1C,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,cAAc,CAAC,MAAuB;IACpD,IAAI,MAAM,CAAC,KAAK,KAAK,KAAK;QAAE,OAAO,0CAA0C,CAAC;IAC9E,IAAI,MAAM,CAAC,KAAK,KAAK,WAAW;QAC9B,OAAO,sCAAsC,CAAC;IAChD,MAAM,KAAK,GAAG;QACZ,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,eAAe,CAAC;QACnE,GAAG,MAAM,CAAC,KAAK;KAChB,CAAC;IACF,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC;QACrB,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;QAClB,CAAC,CAAC,mCAAmC,CAAC;AAC1C,CAAC","sourcesContent":["import type { TeamAgentAccess } from '@ekanos/integration-schema';\n\n/**\n * Who the agent is in its runs. A personal agent acts for its creator on\n * every run. Any other agent acts as itself: the person it \"runs as\" only\n * lends their own connection to a per-person product (one each person\n * connects for themselves), and every other product runs on the team's.\n *\n * `personConnections` is the host's answer to which granted products\n * actually run on that person's connection: none means every call runs on\n * the team's (or the Source's), so no per-person connection is named. Absent\n * or null (an older host, or a grant of whatever is connected): the general\n * wording.\n */\nexport function identityLabel(\n runsAs: string | null,\n personal = false,\n personConnections?: readonly string[] | null,\n): string {\n if (personal)\n return `acts for ${runsAs ?? 'nobody (its creator left the team)'}`;\n if (!runsAs)\n return 'acts as itself · paused: the person it runs as left the team';\n if (!personConnections) {\n return `acts as itself · per-person connections: ${possessive(runsAs)} own`;\n }\n if (personConnections.length === 0) {\n return \"acts as itself · on the team's connections\";\n }\n return `acts as itself · per-person connections: ${possessive(runsAs)} own (${personConnections.join(', ')})`;\n}\n\n/**\n * The products (by key, as `personConnections` names them) a confirmation's `connections` say run on the runs-as\n * person's own connection; null when the host sent none (an older host, or a\n * grant of whatever is connected).\n */\nexport function personConnectionsOf(\n access: TeamAgentAccess | undefined,\n): string[] | null {\n if (!access?.connections) return null;\n return access.connections\n .filter((entry) => entry.via === 'person')\n .map((entry) => entry.key);\n}\n\nfunction possessive(person: string): string {\n return person === 'you' ? 'your' : `${person}'s`;\n}\n\n/**\n * Whose connection, to what, the confirmation covers: per product from the\n * host's `connections` (the team's, the Source's, or the runs-as person's own\n * for a per-person product). An older host sends no `connections`: then the\n * team's connections, and the runs-as person's own only for a per-person\n * product.\n */\nexport function describeConnections(\n access: TeamAgentAccess,\n runsAs: string | null,\n): string {\n const person = runsAs ? possessive(runsAs) : \"its creator's\";\n if (!access.connections) {\n return `${describeAccess(access)} — on the team's connections, or ${person} own for a per-person product`;\n }\n const covered = new Set(access.connections.flatMap((entry) => entry.tools));\n const parts = access.connections.map((entry) => {\n const whose =\n entry.via === 'team'\n ? \"the team's\"\n : entry.via === 'source'\n ? \"the Source's\"\n : `${person} own`;\n const what = entry.everyTool ? 'every tool' : entry.tools.join(', ');\n return `${whose} ${entry.name} connection (${what})`;\n });\n const rest = access.tools.filter((tool) => !covered.has(tool));\n if (rest.length > 0) parts.push(rest.join(', '));\n return parts.length > 0\n ? parts.join('; ')\n : 'nothing yet (no products granted)';\n}\n\n/** What a confirmation covers, in words: whose connections, to what. */\nexport function describeAccess(access: TeamAgentAccess): string {\n if (access.scope === 'all') return 'every tool of every product they connect';\n if (access.scope === 'read_only')\n return 'read from every product they connect';\n const parts = [\n ...access.products.map((product) => `${product.name} (every tool)`),\n ...access.tools,\n ];\n return parts.length > 0\n ? parts.join(', ')\n : 'nothing yet (no products granted)';\n}\n"]}
@@ -194,7 +194,7 @@ export function describeAgentReadiness(entry, target, readiness, activity, scope
194
194
  ? `draft v${(_b = agent.version) !== null && _b !== void 0 ? _b : '?'} (testing, unpublished)`
195
195
  : `v${(_c = agent.version) !== null && _c !== void 0 ? _c : '?'} (${agent.pinned ? 'pinned' : 'following'})`,
196
196
  ...(agent.status === 'active' ? [] : [agent.status]),
197
- identityLabel(agent.runsAs),
197
+ identityLabel(agent.runsAs, false, agent.personConnections),
198
198
  agent.accessConfirmed ? '✓ access confirmed' : '✗ access not confirmed',
199
199
  ].join(' · ');
200
200
  const width = Math.max(8, ...agent.requirements.map((item) => item.key.length));
@@ -1 +1 @@
1
- {"version":3,"file":"team-agent-readiness.js","sourceRoot":"","sources":["../../src/commands/team-agent-readiness.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAmB,QAAQ,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAkCpD,MAAM,UAAU,cAAc,CAC5B,KAAqB,EACrB,MAAuB;;;IAEvB,MAAM,KAAK,GAAG,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC5C,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,MAAM,KAAK,CAAC;QACxB,KAAK;QACL,IAAI,QAAE,MAAA,KAAK,CAAC,CAAC,CAAC,0CAAE,GAAG,mCAAI,IAAI;KAC5B,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,IAAmB;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YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG;YACnC,CAAC,CAAC,EAAE,CAAC;QACT,OAAO,KAAK,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,WAAW,GAAG,MAAM,GAAG,QAAQ,EAAE,CAAC;IACvD,CAAC;IACD,MAAM,MAAM,GAAG,YAAY,OAAC,IAAI,CAAC,MAAM,mCAAI,eAAe,CAAC,CAAC;IAC5D,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;AACrF,CAAC","sourcesContent":["import type {\n AgentRunSummary,\n ChannelRequirement,\n Requirement,\n TeamAgentEntry,\n TeamAgentHold,\n TeamIntegrationEvent,\n} from '@ekanos/integration-schema';\n\nimport { cli } from '../invocation';\nimport { type ScopeFacts, scopeFix, scopeHiddenWords } from './scope-notice';\nimport { identityLabel } from './team-agent-access';\n\n/**\n * \"Is this agent live on this team, and if not, why?\" — one answer for\n * `teams agents show` and the summary line of `teams agents list`, built only\n * from what the host already reports (CLI audit 2026-10-19, §3).\n *\n * Live is: on, on a published version, every connection it needs made,\n * access confirmed by someone who sets it up (a team manager or the Source\n * admin, plan 247.2), at least one trigger on, and every trigger's events\n * able to reach it. Each gap is a step with one fix, in the order they have\n * to be done; the first step's fix is \"Next\". A publish holds no team, so\n * there is no update waiting.\n */\n\nexport interface ReadinessStep {\n /** What is missing, in words. */\n problem: string;\n /** The one command (or app step) that fixes it. */\n fix: string;\n}\n\nexport interface AgentReadiness {\n live: boolean;\n steps: ReadinessStep[];\n /** The first step's fix; null when there is none. */\n next: string | null;\n}\n\nexport interface ReadinessTarget {\n team: string;\n source: string;\n}\n\nexport function agentReadiness(\n entry: TeamAgentEntry,\n target: ReadinessTarget,\n): AgentReadiness {\n const steps = readinessSteps(entry, target);\n return {\n live: steps.length === 0,\n steps,\n next: steps[0]?.fix ?? null,\n };\n}\n\n/**\n * What a newer version adds over the one a team runs, in words (a publish's\n * report of the teams pinned to another version):\n * \"adds zendesk_update_ticket; lets zendesk_add_tag run without approval\".\n */\nexport function describeHold(hold: TeamAgentHold): string {\n const adds = [\n ...(hold.adds.scope === 'all'\n ? ['every tool of the products it can reach']\n : hold.adds.scope === 'read_only'\n ? ['every read of the products it can reach']\n : []),\n ...hold.adds.products.map((product) => `${product.name} (every tool)`),\n ...hold.adds.tools,\n ];\n const loosens = [\n ...(hold.loosens.writes ? ['writes'] : []),\n ...(hold.loosens.reads ? ['reads'] : []),\n ...hold.loosens.tools,\n ];\n const parts = [\n ...(adds.length > 0 ? [`adds ${adds.join(', ')}`] : []),\n ...(loosens.length > 0\n ? [`lets ${loosens.join(', ')} run without approval`]\n : []),\n ];\n return parts.length > 0 ? parts.join('; ') : 'reaches further';\n}\n\nfunction readinessSteps(\n entry: TeamAgentEntry,\n { team, source }: ReadinessTarget,\n): ReadinessStep[] {\n const enable = `${cli()} teams agents enable ${team} ${entry.key} --source ${source}`;\n const agent = entry.agent;\n if (!agent) return [{ problem: `off for ${team}`, fix: enable }];\n if (agent.status !== 'active') {\n return [{ problem: `${agent.status} for ${team}`, fix: enable }];\n }\n\n const steps: ReadinessStep[] = [];\n if (agent.draft) {\n // A team testing a draft runs it only when started by hand.\n steps.push({\n problem: `testing unpublished draft v${agent.version ?? '?'}: its triggers do not start it`,\n fix: `${cli()} agents publish ${entry.key} --source ${source}`,\n });\n } else if (agent.version === null) {\n steps.push({\n problem: 'no published version',\n fix: `${cli()} agents publish ${entry.key} --source ${source}`,\n });\n }\n for (const item of agent.missing) {\n steps.push({\n problem: `${item.name}: ${REASON_WORDS[item.reason ?? 'not_connected']}`,\n fix:\n requirementFix(item, team, source) ??\n `${cli()} teams mcp status ${team} ${item.key} --source ${source}`,\n });\n }\n if (!agent.accessConfirmed) {\n steps.push({\n problem: 'nobody has confirmed what it may use',\n // Whoever sets it up confirms, as themselves: the Source admin here,\n // or a team manager in the app (plan 247.2).\n fix: `${cli()} teams agents confirm ${team} ${entry.key} --source ${source} (or a team manager confirms in the app: Agents › ${entry.name} › Setup)`,\n });\n }\n if (!agent.triggers.some((trigger) => trigger.enabled)) {\n steps.push({\n problem: 'no trigger is on, so it only runs when started by hand',\n fix: `${cli()} teams triggers add ${team} ${entry.key} event <event-id> --source ${source} (event ids: ${cli()} catalog --source ${source})`,\n });\n }\n for (const channel of agent.channels ?? []) {\n if (channel.ready) continue;\n steps.push({\n problem: channel.problem ?? `${channel.name} not ready`,\n fix: channelFix(channel, team, source),\n });\n }\n return steps;\n}\n\nexport const REASON_WORDS: Record<\n NonNullable<Requirement['reason']>,\n string\n> = {\n not_connected: 'not connected',\n no_route: 'no route maps the Source connection’s events to this team',\n source_unsupported: 'the integration no longer supports a Source connection',\n source_not_entitled: 'the product is not enabled for the Source',\n source_not_connected: 'the Source connection is not made',\n};\n\n/** The one command that makes a requirement, or null when none can. */\nexport function requirementFix(\n item: Requirement,\n team: string,\n source: string,\n): string | null {\n if (item.kind === 'mcp') return null;\n switch (item.reason) {\n case 'no_route':\n return `${cli()} routes set ${item.key} <value> ${team} --source ${source} (values: ${cli()} routes options ${item.key} --source ${source})`;\n case 'source_not_connected':\n return `${cli()} apps connect ${item.key} --source ${source}`;\n case 'source_not_entitled':\n return `${cli()} sources products enable ${item.key} --source ${source} (a Source admin, for a global integration or one the Source built; Ekanos enables anything else)`;\n case 'source_unsupported':\n return `set connections.${item.key}.owner to \"team\" in agent.json, then ${cli()} agents apply`;\n default:\n if (item.connected) return null;\n // A per-person product is the runs-as person's connection, not the\n // caller's: connecting your own leaves the agent missing it.\n return item.via === 'person' && item.viaDetail\n ? `${cli()} teams connect ${team} ${item.key} --as ${item.viaDetail} --source ${source}`\n : `${cli()} teams connect ${team} ${item.key} --source ${source}`;\n }\n}\n\n/**\n * The one command that makes a channel ready. An older host sends no\n * `arrival`: the channel's key (`<product>:webhook`, `<product>:route`,\n * `<product>:<connection>`) still says which command it is.\n */\nexport function channelFix(\n channel: ChannelRequirement,\n team: string,\n source: string,\n): string {\n const suffix = channel.key.includes(':') ? channel.key.split(':')[1] : null;\n const arrival =\n channel.arrival ??\n (suffix === 'webhook'\n ? 'team-webhook'\n : suffix === 'route'\n ? 'source-route'\n : 'install');\n switch (arrival) {\n case 'team-webhook':\n return `${cli()} teams webhook ${team} ${channel.product} --source ${source}`;\n case 'source-route':\n return channel.webhook\n ? `${cli()} routes set ${channel.product} <value> ${team} --source ${source} (values: ${cli()} routes options ${channel.product} --source ${source})`\n : `${cli()} routes webhook ${channel.product} --source ${source}`;\n default: {\n if (channel.key === 'slack' || channel.key === 'linear-app') {\n return `${cli()} teams connect ${team} ${channel.key} --source ${source}`;\n }\n const connection = channel.connectionId ?? suffix;\n return `${cli()} teams connect ${team} ${channel.product}${connection ? ` --connection ${connection}` : ''} --source ${source}`;\n }\n }\n}\n\n/** How the events of a ready channel reach the agent. */\nexport function reachedVia(channel: ChannelRequirement): string {\n switch (channel.arrival) {\n case 'team-webhook':\n return 'team webhook';\n case 'source-route':\n return 'Source webhook, routed';\n default:\n return `${channel.name} installed`;\n }\n}\n\n/** A fix as a line: a command is run in the terminal; anything else is a person's step. */\nexport function fixLine(fix: string): string {\n return fix.startsWith(cli()) ? `in your terminal: ${fix}` : fix;\n}\n\n/** \"Live: yes\" or \"Live: no — N steps left\". */\nexport function liveLine(readiness: AgentReadiness): string {\n const left = readiness.steps.length;\n return readiness.live\n ? 'Live: yes'\n : `Live: no — ${left} step${left === 1 ? '' : 's'} left`;\n}\n\n/* ---------------------------------------------------------------------- */\n/* teams agents show */\n/* ---------------------------------------------------------------------- */\n\n/** What happened lately, read alongside the agent; each part optional. */\nexport interface AgentActivity {\n /** The agent's recent runs, newest first. */\n runs: AgentRunSummary[] | null;\n /** The team's recent integration events, newest first. */\n events: TeamIntegrationEvent[] | null;\n}\n\n/**\n * One line per product, per trigger, then Live and Next. A product the\n * team's product scopes hide from it in the app says so — connected or not,\n * the team cannot see it there (`scope`, the team's scopes).\n */\nexport function describeAgentReadiness(\n entry: TeamAgentEntry,\n target: ReadinessTarget,\n readiness: AgentReadiness,\n activity: AgentActivity,\n scope?: ScopeFacts,\n): string {\n const agent = entry.agent;\n if (!agent) {\n return [\n `${entry.key} on ${target.team} · off · v${entry.publishedVersion ?? '?'} published`,\n ` ${liveLine(readiness)}`,\n ` Next: ${readiness.next}`,\n ].join('\\n');\n }\n\n const head = [\n `${entry.key} on ${target.team}`,\n agent.draft\n ? `draft v${agent.version ?? '?'} (testing, unpublished)`\n : `v${agent.version ?? '?'} (${agent.pinned ? 'pinned' : 'following'})`,\n ...(agent.status === 'active' ? [] : [agent.status]),\n identityLabel(agent.runsAs),\n agent.accessConfirmed ? '✓ access confirmed' : '✗ access not confirmed',\n ].join(' · ');\n\n const width = Math.max(\n 8,\n ...agent.requirements.map((item) => item.key.length),\n );\n const pad = (label: string) => label.padEnd(width);\n const indent = ' '.repeat(width + 4);\n\n const products = agent.requirements.flatMap((item) => {\n const fix = item.connected\n ? null\n : (requirementFix(item, target.team, target.source) ??\n `${cli()} teams mcp status ${target.team} ${item.key} --source ${target.source}`);\n const hidden =\n item.hiddenByScope && scope\n ? [\n `${indent}! ${scopeHiddenWords(scope)}`,\n `${indent}→ ${fixLine(scopeFix(scope, { ...target, product: item.key }))}`,\n ]\n : [];\n return [\n ` ${pad(item.key)} ${productState(item)}`,\n ...(fix ? [`${indent}→ ${fixLine(fix)}`] : []),\n ...hidden,\n ];\n });\n\n const nameWidth = Math.max(\n 0,\n ...agent.triggers.map(\n (trigger) => (trigger.eventId ?? trigger.type).length,\n ),\n );\n const triggers = agent.triggers.flatMap((trigger, index) => {\n const label = index === 0 ? pad('triggers') : pad('');\n const name = (trigger.eventId ?? trigger.type).padEnd(nameWidth);\n if (!trigger.enabled) return [` ${label} ${name} (off)`];\n const channel = (agent.channels ?? []).find((candidate) =>\n candidate.triggers.includes(trigger.eventId ?? trigger.type),\n );\n const reach = channel\n ? channel.ready\n ? `✓ reachable (${reachedVia(channel)}${channel.lastDeliveryAt ? `, last delivery ${channel.lastDeliveryAt}` : ''})`\n : `✗ ${channel.problem ?? `${channel.name} not ready`}`\n : `✓ ${TRIGGER_REACH[trigger.type] ?? 'reachable'}`;\n // An event trigger's runs are the ones its own events started; any\n // other trigger's, the agent's latest run of that trigger type.\n const ownEvents = trigger.eventId\n ? (activity.events ?? []).filter(\n (event) => event.eventId === trigger.eventId,\n )\n : [];\n const lastEvent = ownEvents[0];\n const lastRun = trigger.eventId\n ? ownEvents.find((event) => event.runs.length > 0)?.runs[0]\n : activity.runs?.find((run) => run.trigger === trigger.type);\n const known = trigger.eventId ? activity.events : activity.runs;\n const facts = [\n reach,\n ...(trigger.eventId && activity.events\n ? [\n lastEvent\n ? `last event ${lastEvent.receivedAt} ${lastEvent.status}`\n : 'no event yet',\n ]\n : []),\n ...(known\n ? [\n lastRun\n ? `last run ${lastRun.startedAt} ${lastRun.status}`\n : 'no run yet',\n ]\n : []),\n ];\n return [\n ` ${label} ${name} ${facts.join(' · ')}`,\n ...(channel && !channel.ready\n ? [\n `${indent}→ ${fixLine(channelFix(channel, target.team, target.source))}`,\n ]\n : []),\n ];\n });\n\n return [\n head,\n ...products,\n ...(agent.triggers.length > 0 ? triggers : [` ${pad('triggers')} none`]),\n ` ${liveLine(readiness)}`,\n ...(readiness.next ? [` Next: ${readiness.next}`] : []),\n ].join('\\n');\n}\n\nconst TRIGGER_REACH: Record<string, string> = {\n manual: 'started by hand',\n schedule: 'runs on its schedule',\n webhook: 'reachable at its trigger URL',\n};\n\nfunction productState(item: Requirement): string {\n if (item.kind === 'mcp') {\n return item.connected\n ? '✓ MCP server connected'\n : '✗ MCP server not signed in';\n }\n const via =\n item.via === 'source'\n ? 'via Source connection'\n : item.via === 'person'\n ? `via ${item.viaDetail ?? 'the runs-as person'}'s personal connection`\n : item.via === 'team'\n ? 'via team connection'\n : null;\n if (item.connected) {\n const routes =\n item.via === 'source' && item.viaDetail\n ? ` · routes: ${item.viaDetail}`\n : '';\n const fallback =\n item.reason && item.reason !== 'not_connected'\n ? ` (${REASON_WORDS[item.reason]})`\n : '';\n return `✓ ${via ?? 'connected'}${routes}${fallback}`;\n }\n const reason = REASON_WORDS[item.reason ?? 'not_connected'];\n return `✗ ${via ? `${via} — ` : ''}${reason}${item.required ? '' : ' (optional)'}`;\n}\n"]}
1
+ {"version":3,"file":"team-agent-readiness.js","sourceRoot":"","sources":["../../src/commands/team-agent-readiness.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAmB,QAAQ,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAkCpD,MAAM,UAAU,cAAc,CAC5B,KAAqB,EACrB,MAAuB;;;IAEvB,MAAM,KAAK,GAAG,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC5C,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,MAAM,KAAK,CAAC;QACxB,KAAK;QACL,IAAI,QAAE,MAAA,KAAK,CAAC,CAAC,CAAC,0CAAE,GAAG,mCAAI,IAAI;KAC5B,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,IAAmB;IAC9C,MAAM,IAAI,GAAG;QACX,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,KAAK;YAC3B,CAAC,CAAC,CAAC,yCAAyC,CAAC;YAC7C,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,WAAW;gBAC/B,CAAC,CAAC,CAAC,yCAAyC,CAAC;gBAC7C,CAAC,CAAC,EAAE,CAAC;QACT,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,eAAe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AAE,GAAG,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;AACrF,CAAC","sourcesContent":["import type {\n AgentRunSummary,\n ChannelRequirement,\n Requirement,\n TeamAgentEntry,\n TeamAgentHold,\n TeamIntegrationEvent,\n} from '@ekanos/integration-schema';\n\nimport { cli } from '../invocation';\nimport { type ScopeFacts, scopeFix, scopeHiddenWords } from './scope-notice';\nimport { identityLabel } from './team-agent-access';\n\n/**\n * \"Is this agent live on this team, and if not, why?\" — one answer for\n * `teams agents show` and the summary line of `teams agents list`, built only\n * from what the host already reports (CLI audit 2026-10-19, §3).\n *\n * Live is: on, on a published version, every connection it needs made,\n * access confirmed by someone who sets it up (a team manager or the Source\n * admin, plan 247.2), at least one trigger on, and every trigger's events\n * able to reach it. Each gap is a step with one fix, in the order they have\n * to be done; the first step's fix is \"Next\". A publish holds no team, so\n * there is no update waiting.\n */\n\nexport interface ReadinessStep {\n /** What is missing, in words. */\n problem: string;\n /** The one command (or app step) that fixes it. */\n fix: string;\n}\n\nexport interface AgentReadiness {\n live: boolean;\n steps: ReadinessStep[];\n /** The first step's fix; null when there is none. */\n next: string | null;\n}\n\nexport interface ReadinessTarget {\n team: string;\n source: string;\n}\n\nexport function agentReadiness(\n entry: TeamAgentEntry,\n target: ReadinessTarget,\n): AgentReadiness {\n const steps = readinessSteps(entry, target);\n return {\n live: steps.length === 0,\n steps,\n next: steps[0]?.fix ?? null,\n };\n}\n\n/**\n * What a newer version adds over the one a team runs, in words (a publish's\n * report of the teams pinned to another version):\n * \"adds zendesk_update_ticket; lets zendesk_add_tag run without approval\".\n */\nexport function describeHold(hold: TeamAgentHold): string {\n const adds = [\n ...(hold.adds.scope === 'all'\n ? ['every tool of the products it can reach']\n : hold.adds.scope === 'read_only'\n ? ['every read of the products it can reach']\n : []),\n ...hold.adds.products.map((product) => `${product.name} (every tool)`),\n ...hold.adds.tools,\n ];\n const loosens = [\n ...(hold.loosens.writes ? ['writes'] : []),\n ...(hold.loosens.reads ? ['reads'] : []),\n ...hold.loosens.tools,\n ];\n const parts = [\n ...(adds.length > 0 ? [`adds ${adds.join(', ')}`] : []),\n ...(loosens.length > 0\n ? [`lets ${loosens.join(', ')} run without approval`]\n : []),\n ];\n return parts.length > 0 ? parts.join('; ') : 'reaches further';\n}\n\nfunction readinessSteps(\n entry: TeamAgentEntry,\n { team, source }: ReadinessTarget,\n): ReadinessStep[] {\n const enable = `${cli()} teams agents enable ${team} ${entry.key} --source ${source}`;\n const agent = entry.agent;\n if (!agent) return [{ problem: `off for ${team}`, fix: enable }];\n if (agent.status !== 'active') {\n return [{ problem: `${agent.status} for ${team}`, fix: enable }];\n }\n\n const steps: ReadinessStep[] = [];\n if (agent.draft) {\n // A team testing a draft runs it only when started by hand.\n steps.push({\n problem: `testing unpublished draft v${agent.version ?? '?'}: its triggers do not start it`,\n fix: `${cli()} agents publish ${entry.key} --source ${source}`,\n });\n } else if (agent.version === null) {\n steps.push({\n problem: 'no published version',\n fix: `${cli()} agents publish ${entry.key} --source ${source}`,\n });\n }\n for (const item of agent.missing) {\n steps.push({\n problem: `${item.name}: ${REASON_WORDS[item.reason ?? 'not_connected']}`,\n fix:\n requirementFix(item, team, source) ??\n `${cli()} teams mcp status ${team} ${item.key} --source ${source}`,\n });\n }\n if (!agent.accessConfirmed) {\n steps.push({\n problem: 'nobody has confirmed what it may use',\n // Whoever sets it up confirms, as themselves: the Source admin here,\n // or a team manager in the app (plan 247.2).\n fix: `${cli()} teams agents confirm ${team} ${entry.key} --source ${source} (or a team manager confirms in the app: Agents › ${entry.name} › Setup)`,\n });\n }\n if (!agent.triggers.some((trigger) => trigger.enabled)) {\n steps.push({\n problem: 'no trigger is on, so it only runs when started by hand',\n fix: `${cli()} teams triggers add ${team} ${entry.key} event <event-id> --source ${source} (event ids: ${cli()} catalog --source ${source})`,\n });\n }\n for (const channel of agent.channels ?? []) {\n if (channel.ready) continue;\n steps.push({\n problem: channel.problem ?? `${channel.name} not ready`,\n fix: channelFix(channel, team, source),\n });\n }\n return steps;\n}\n\nexport const REASON_WORDS: Record<\n NonNullable<Requirement['reason']>,\n string\n> = {\n not_connected: 'not connected',\n no_route: 'no route maps the Source connection’s events to this team',\n source_unsupported: 'the integration no longer supports a Source connection',\n source_not_entitled: 'the product is not enabled for the Source',\n source_not_connected: 'the Source connection is not made',\n};\n\n/** The one command that makes a requirement, or null when none can. */\nexport function requirementFix(\n item: Requirement,\n team: string,\n source: string,\n): string | null {\n if (item.kind === 'mcp') return null;\n switch (item.reason) {\n case 'no_route':\n return `${cli()} routes set ${item.key} <value> ${team} --source ${source} (values: ${cli()} routes options ${item.key} --source ${source})`;\n case 'source_not_connected':\n return `${cli()} apps connect ${item.key} --source ${source}`;\n case 'source_not_entitled':\n return `${cli()} sources products enable ${item.key} --source ${source} (a Source admin, for a global integration or one the Source built; Ekanos enables anything else)`;\n case 'source_unsupported':\n return `set connections.${item.key}.owner to \"team\" in agent.json, then ${cli()} agents apply`;\n default:\n if (item.connected) return null;\n // A per-person product is the runs-as person's connection, not the\n // caller's: connecting your own leaves the agent missing it.\n return item.via === 'person' && item.viaDetail\n ? `${cli()} teams connect ${team} ${item.key} --as ${item.viaDetail} --source ${source}`\n : `${cli()} teams connect ${team} ${item.key} --source ${source}`;\n }\n}\n\n/**\n * The one command that makes a channel ready. An older host sends no\n * `arrival`: the channel's key (`<product>:webhook`, `<product>:route`,\n * `<product>:<connection>`) still says which command it is.\n */\nexport function channelFix(\n channel: ChannelRequirement,\n team: string,\n source: string,\n): string {\n const suffix = channel.key.includes(':') ? channel.key.split(':')[1] : null;\n const arrival =\n channel.arrival ??\n (suffix === 'webhook'\n ? 'team-webhook'\n : suffix === 'route'\n ? 'source-route'\n : 'install');\n switch (arrival) {\n case 'team-webhook':\n return `${cli()} teams webhook ${team} ${channel.product} --source ${source}`;\n case 'source-route':\n return channel.webhook\n ? `${cli()} routes set ${channel.product} <value> ${team} --source ${source} (values: ${cli()} routes options ${channel.product} --source ${source})`\n : `${cli()} routes webhook ${channel.product} --source ${source}`;\n default: {\n if (channel.key === 'slack' || channel.key === 'linear-app') {\n return `${cli()} teams connect ${team} ${channel.key} --source ${source}`;\n }\n const connection = channel.connectionId ?? suffix;\n return `${cli()} teams connect ${team} ${channel.product}${connection ? ` --connection ${connection}` : ''} --source ${source}`;\n }\n }\n}\n\n/** How the events of a ready channel reach the agent. */\nexport function reachedVia(channel: ChannelRequirement): string {\n switch (channel.arrival) {\n case 'team-webhook':\n return 'team webhook';\n case 'source-route':\n return 'Source webhook, routed';\n default:\n return `${channel.name} installed`;\n }\n}\n\n/** A fix as a line: a command is run in the terminal; anything else is a person's step. */\nexport function fixLine(fix: string): string {\n return fix.startsWith(cli()) ? `in your terminal: ${fix}` : fix;\n}\n\n/** \"Live: yes\" or \"Live: no — N steps left\". */\nexport function liveLine(readiness: AgentReadiness): string {\n const left = readiness.steps.length;\n return readiness.live\n ? 'Live: yes'\n : `Live: no — ${left} step${left === 1 ? '' : 's'} left`;\n}\n\n/* ---------------------------------------------------------------------- */\n/* teams agents show */\n/* ---------------------------------------------------------------------- */\n\n/** What happened lately, read alongside the agent; each part optional. */\nexport interface AgentActivity {\n /** The agent's recent runs, newest first. */\n runs: AgentRunSummary[] | null;\n /** The team's recent integration events, newest first. */\n events: TeamIntegrationEvent[] | null;\n}\n\n/**\n * One line per product, per trigger, then Live and Next. A product the\n * team's product scopes hide from it in the app says so — connected or not,\n * the team cannot see it there (`scope`, the team's scopes).\n */\nexport function describeAgentReadiness(\n entry: TeamAgentEntry,\n target: ReadinessTarget,\n readiness: AgentReadiness,\n activity: AgentActivity,\n scope?: ScopeFacts,\n): string {\n const agent = entry.agent;\n if (!agent) {\n return [\n `${entry.key} on ${target.team} · off · v${entry.publishedVersion ?? '?'} published`,\n ` ${liveLine(readiness)}`,\n ` Next: ${readiness.next}`,\n ].join('\\n');\n }\n\n const head = [\n `${entry.key} on ${target.team}`,\n agent.draft\n ? `draft v${agent.version ?? '?'} (testing, unpublished)`\n : `v${agent.version ?? '?'} (${agent.pinned ? 'pinned' : 'following'})`,\n ...(agent.status === 'active' ? [] : [agent.status]),\n identityLabel(agent.runsAs, false, agent.personConnections),\n agent.accessConfirmed ? '✓ access confirmed' : '✗ access not confirmed',\n ].join(' · ');\n\n const width = Math.max(\n 8,\n ...agent.requirements.map((item) => item.key.length),\n );\n const pad = (label: string) => label.padEnd(width);\n const indent = ' '.repeat(width + 4);\n\n const products = agent.requirements.flatMap((item) => {\n const fix = item.connected\n ? null\n : (requirementFix(item, target.team, target.source) ??\n `${cli()} teams mcp status ${target.team} ${item.key} --source ${target.source}`);\n const hidden =\n item.hiddenByScope && scope\n ? [\n `${indent}! ${scopeHiddenWords(scope)}`,\n `${indent}→ ${fixLine(scopeFix(scope, { ...target, product: item.key }))}`,\n ]\n : [];\n return [\n ` ${pad(item.key)} ${productState(item)}`,\n ...(fix ? [`${indent}→ ${fixLine(fix)}`] : []),\n ...hidden,\n ];\n });\n\n const nameWidth = Math.max(\n 0,\n ...agent.triggers.map(\n (trigger) => (trigger.eventId ?? trigger.type).length,\n ),\n );\n const triggers = agent.triggers.flatMap((trigger, index) => {\n const label = index === 0 ? pad('triggers') : pad('');\n const name = (trigger.eventId ?? trigger.type).padEnd(nameWidth);\n if (!trigger.enabled) return [` ${label} ${name} (off)`];\n const channel = (agent.channels ?? []).find((candidate) =>\n candidate.triggers.includes(trigger.eventId ?? trigger.type),\n );\n const reach = channel\n ? channel.ready\n ? `✓ reachable (${reachedVia(channel)}${channel.lastDeliveryAt ? `, last delivery ${channel.lastDeliveryAt}` : ''})`\n : `✗ ${channel.problem ?? `${channel.name} not ready`}`\n : `✓ ${TRIGGER_REACH[trigger.type] ?? 'reachable'}`;\n // An event trigger's runs are the ones its own events started; any\n // other trigger's, the agent's latest run of that trigger type.\n const ownEvents = trigger.eventId\n ? (activity.events ?? []).filter(\n (event) => event.eventId === trigger.eventId,\n )\n : [];\n const lastEvent = ownEvents[0];\n const lastRun = trigger.eventId\n ? ownEvents.find((event) => event.runs.length > 0)?.runs[0]\n : activity.runs?.find((run) => run.trigger === trigger.type);\n const known = trigger.eventId ? activity.events : activity.runs;\n const facts = [\n reach,\n ...(trigger.eventId && activity.events\n ? [\n lastEvent\n ? `last event ${lastEvent.receivedAt} ${lastEvent.status}`\n : 'no event yet',\n ]\n : []),\n ...(known\n ? [\n lastRun\n ? `last run ${lastRun.startedAt} ${lastRun.status}`\n : 'no run yet',\n ]\n : []),\n ];\n return [\n ` ${label} ${name} ${facts.join(' · ')}`,\n ...(channel && !channel.ready\n ? [\n `${indent}→ ${fixLine(channelFix(channel, target.team, target.source))}`,\n ]\n : []),\n ];\n });\n\n return [\n head,\n ...products,\n ...(agent.triggers.length > 0 ? triggers : [` ${pad('triggers')} none`]),\n ` ${liveLine(readiness)}`,\n ...(readiness.next ? [` Next: ${readiness.next}`] : []),\n ].join('\\n');\n}\n\nconst TRIGGER_REACH: Record<string, string> = {\n manual: 'started by hand',\n schedule: 'runs on its schedule',\n webhook: 'reachable at its trigger URL',\n};\n\nfunction productState(item: Requirement): string {\n if (item.kind === 'mcp') {\n return item.connected\n ? '✓ MCP server connected'\n : '✗ MCP server not signed in';\n }\n const via =\n item.via === 'source'\n ? 'via Source connection'\n : item.via === 'person'\n ? `via ${item.viaDetail ?? 'the runs-as person'}'s personal connection`\n : item.via === 'team'\n ? 'via team connection'\n : null;\n if (item.connected) {\n const routes =\n item.via === 'source' && item.viaDetail\n ? ` · routes: ${item.viaDetail}`\n : '';\n const fallback =\n item.reason && item.reason !== 'not_connected'\n ? ` (${REASON_WORDS[item.reason]})`\n : '';\n return `✓ ${via ?? 'connected'}${routes}${fallback}`;\n }\n const reason = REASON_WORDS[item.reason ?? 'not_connected'];\n return `✗ ${via ? `${via} — ` : ''}${reason}${item.required ? '' : ' (optional)'}`;\n}\n"]}
@@ -2,7 +2,7 @@ import { AgentRunListSchema, TeamAgentChangeResultSchema, TeamAgentListSchema, T
2
2
  import { invalidStateError, notFoundError, usageError } from '../errors.js';
3
3
  import { cli } from '../invocation.js';
4
4
  import { call, listTeamEvents } from '../teams-api.js';
5
- import { describeAccess, describeConnections, identityLabel, } from './team-agent-access.js';
5
+ import { describeAccess, describeConnections, identityLabel, personConnectionsOf, } from './team-agent-access.js';
6
6
  import { REASON_WORDS, agentReadiness, channelFix, describeAgentReadiness, fixLine, liveLine, reachedVia, requirementFix, } from './team-agent-readiness.js';
7
7
  import { requireOperand, usageFor } from './team-agents.js';
8
8
  import { runTeamAgentDefine } from './team-agents-define.js';
@@ -404,13 +404,13 @@ async function shownVersion(ctx, run, base, key) {
404
404
  }));
405
405
  const own = (_a = list.ownAgents) === null || _a === void 0 ? void 0 : _a.find((entry) => entry.slug === key);
406
406
  if (own) {
407
- ctx.log(`Confirming what ${key} v${own.version} on ${list.team.slug} may use (it ${identityLabel((_c = own.createdBy) !== null && _c !== void 0 ? _c : null, own.ownership === 'personal')}).`);
407
+ ctx.log(`Confirming what ${key} v${own.version} on ${list.team.slug} may use (it ${identityLabel((_c = own.createdBy) !== null && _c !== void 0 ? _c : null, own.ownership === 'personal', own.personConnections)}).`);
408
408
  return own.version;
409
409
  }
410
410
  const agent = (_b = list.agents.find((entry) => entry.key === key)) === null || _b === void 0 ? void 0 : _b.agent;
411
411
  if (!agent || agent.version === null)
412
412
  return null;
413
- ctx.log(`Confirming what ${key} v${agent.version} on ${list.team.slug} may use (it ${identityLabel(agent.runsAs)}).`);
413
+ ctx.log(`Confirming what ${key} v${agent.version} on ${list.team.slug} may use (it ${identityLabel(agent.runsAs, false, agent.personConnections)}).`);
414
414
  return agent.version;
415
415
  }
416
416
  function change(run, path, method, body) {
@@ -431,7 +431,7 @@ function describeEntry(entry, team, source) {
431
431
  const version = versionLabel(agent);
432
432
  const lines = [
433
433
  `\n${entry.key} — ${entry.name}`,
434
- ` ${agent.status} · ${version} · ${identityLabel(agent.runsAs)}${agent.accessConfirmed ? '' : ` · access not confirmed (${confirmCommand(team, entry.key, source)})`}`,
434
+ ` ${agent.status} · ${version} · ${identityLabel(agent.runsAs, false, agent.personConnections)}${agent.accessConfirmed ? '' : ` · access not confirmed (${confirmCommand(team, entry.key, source)})`}`,
435
435
  ` triggers: ${agent.triggers.length === 0 ? 'none' : agent.triggers.map((trigger) => `${trigger.type}${trigger.enabled ? '' : ' (off)'}`).join(', ')}`,
436
436
  ` links: ${agent.links.length === 0 ? 'none' : agent.links.map((link) => `${link.kind}${link.mode ? `/${link.mode}` : ''} → ${link.to}`).join(', ')}`,
437
437
  ];
@@ -451,7 +451,7 @@ function describeOwnAgent(agent, team, source) {
451
451
  const personal = agent.ownership === 'personal';
452
452
  const whose = personal
453
453
  ? `personal agent of ${agent.yours ? 'yours' : ((_a = agent.createdBy) !== null && _a !== void 0 ? _a : 'a former member')}`
454
- : `team agent · ${identityLabel((_b = agent.createdBy) !== null && _b !== void 0 ? _b : null)}`;
454
+ : `team agent · ${identityLabel((_b = agent.createdBy) !== null && _b !== void 0 ? _b : null, false, agent.personConnections)}`;
455
455
  const lines = [
456
456
  `
457
457
  ${agent.slug} — ${agent.name}`,
@@ -541,7 +541,7 @@ function describeChange(result, title, source, options = {}) {
541
541
  var _a;
542
542
  const lines = [
543
543
  `${options.confirmRequested && !result.accessConfirmed ? '!' : '✓'} ${title}`,
544
- ` ${result.status} · ${versionLabel(result)} · ${identityLabel(result.runsAs, result.ownership === 'personal')}`,
544
+ ` ${result.status} · ${versionLabel(result)} · ${identityLabel(result.runsAs, result.ownership === 'personal', personConnectionsOf(result.access))}`,
545
545
  ];
546
546
  const uses = result.access
547
547
  ? describeConnections(result.access, result.runsAs)
@@ -1 +1 @@
1
- {"version":3,"file":"team-agents-agents.js","sourceRoot":"","sources":["../../src/commands/team-agents-agents.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAIlB,2BAA2B,EAE3B,mBAAmB,EAGnB,qBAAqB,EAGrB,qBAAqB,EAErB,mBAAmB,GAEpB,MAAM,4BAA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AAE,KAAa;IACtD,MAAM,KAAK,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,UAAU,CAAC,wBAAwB,KAAK,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CAAC,GAAiB,EAAE,IAAY;;IACjD,MAAM,KAAK,GAAG,MAAA,GAAG,CAAC,IAAI,CAAC,KAAK,0CAAG,IAAI,CAAC,CAAC;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC9E,CAAC;AAED,SAAS,aAAa,CAAC,KAAyB;IAC9C,OAAO,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAChE,CAAC;AAED,SAAS,YAAY,CACnB,GAAiB,EACjB,IAAwB;IAExB,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACpC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IAClC,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,UAAU,CAAC,KAAK,IAAI,yBAAyB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC3E,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import {\n AgentRunListSchema,\n type ChannelRequirement,\n type Requirement,\n type TeamAgentChangeResult,\n TeamAgentChangeResultSchema,\n type TeamAgentEntry,\n TeamAgentListSchema,\n type TeamAgentPolicy,\n type TeamAgentPolicyChange,\n TeamAgentPolicySchema,\n type TeamAgentSkills,\n type TeamAgentSkillsChange,\n TeamAgentSkillsSchema,\n type TeamAgentTagsChange,\n TeamAgentTagsSchema,\n type TeamOwnAgent,\n} from '@ekanos/integration-schema';\n\nimport type { CliContext } from '../context';\nimport { invalidStateError, notFoundError, usageError } from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { cli } from '../invocation';\nimport { call, listTeamEvents } from '../teams-api';\nimport {\n describeAccess,\n describeConnections,\n identityLabel,\n} from './team-agent-access';\nimport {\n REASON_WORDS,\n agentReadiness,\n channelFix,\n describeAgentReadiness,\n fixLine,\n liveLine,\n reachedVia,\n requirementFix,\n} from './team-agent-readiness';\nimport { type TeamAgentRun, requireOperand, usageFor } from './team-agents';\nimport { runTeamAgentDefine } from './team-agents-define';\nimport { confirmChange } from './teams-lifecycle';\n\nexport { describeAccess, describeConnections, identityLabel };\n\n/**\n * `ekanos teams agents list|show|create|apply|enable|confirm|disable|archive|unarchive|pin|unpin|policy|skills|tags` —\n * a team's provided agents, turned on, versioned, given an approval policy\n * and skills by the Source admin; and the team's own and personal agents,\n * made and changed from an agent.json with `create|apply`\n * (team-agents-define.ts), turned on with `enable`. A personal agent is\n * listed and shown to everyone, and changed by its creator alone. `enable|pin … --draft` puts one team on\n * the template's latest, unpublished version to test it there before\n * publishing. `confirm` (and `--confirm-access`) records the caller's own\n * confirmation that it may use its connections in runs no one watches:\n * whoever sets an agent up confirms it (plan 247.2), never a member.\n * `show` answers \"is this agent live, and if not, why?\" for one agent; `list`\n * ends each agent with the same verdict.\n */\nexport async function runTeamAgentsArea(\n ctx: CliContext,\n run: TeamAgentRun,\n): Promise<ExitCode> {\n const team = requireOperand(run.operands[0], 'team slug', 'agents');\n const base = `/api/partner/teams/${encodeURIComponent(team)}/agents`;\n\n if (run.verb === 'list') {\n expectOperands(run, 1);\n const list = await run.client.call((token) =>\n call(run.host, token, TeamAgentListSchema, {\n method: 'GET',\n path: base,\n source: run.source,\n }),\n );\n const target = { team: list.team.slug, source: run.source };\n const own = list.ownAgents ?? [];\n return ctx.succeed(\n {\n host: run.host,\n ...list,\n agents: list.agents.map((entry) => ({\n ...entry,\n readiness: agentReadiness(entry, target),\n })),\n },\n [\n ctx.ui.result({\n title:\n list.agents.length === 0 && own.length === 0\n ? `No agents are provided for ${list.team.slug}`\n : `Agents for ${list.team.slug}`,\n tone: list.agents.length === 0 && own.length === 0 ? 'warn' : 'ok',\n }),\n ...list.agents.map((entry) =>\n describeEntry(entry, list.team.slug, run.source),\n ),\n ...(own.length > 0\n ? [\n `\nThe team's own and personal agents:`,\n ...own.map((agent) =>\n describeOwnAgent(agent, list.team.slug, run.source),\n ),\n ]\n : []),\n list.mcpServers.length > 0\n ? `\\nMCP servers: ${list.mcpServers.map((server) => `${server.key} (${server.status})`).join(', ')}`\n : '',\n ]\n .filter(Boolean)\n .join('\\n'),\n );\n }\n\n if (run.verb === 'create' || run.verb === 'apply') {\n return runTeamAgentDefine(ctx, run, run.verb);\n }\n\n const key = requireOperand(run.operands[1], 'agent key', 'agents');\n const path = `${base}/${encodeURIComponent(key)}`;\n\n switch (run.verb) {\n case 'show':\n expectOperands(run, 2);\n return show(ctx, run, base, key);\n case 'enable': {\n expectOperands(run, 2);\n const as = stringFlag(run, 'as');\n const draft = run.args.flags?.draft === true;\n const confirmAccess = run.args.flags?.['confirm-access'] === true;\n const result = await change(run, `${path}/enable`, 'POST', {\n ...(as ? { as } : {}),\n ...(draft ? { draft: true } : {}),\n ...(confirmAccess ? { confirmAccess: true } : {}),\n });\n if (draft) requireDraftHost(result, 'enabled');\n return ctx.succeed(\n { host: run.host, ...result },\n describeChange(\n result,\n `${\n draft\n ? `Testing draft v${result.version ?? '?'} of ${result.slug} on ${result.team.slug}`\n : `Turned on ${result.slug} for ${result.team.slug}`\n }${confirmAccess && result.accessConfirmed ? ', and you confirmed what it may use' : ''}`,\n run.source,\n { confirmRequested: confirmAccess },\n ),\n );\n }\n case 'confirm': {\n expectOperands(run, 2);\n // Confirm what the person is shown, never a publish that lands after:\n // the host refuses if the version moved (AGENT_VERSION_CHANGED).\n const shown = await shownVersion(ctx, run, base, key);\n const result = await change(\n run,\n `${path}/confirm`,\n 'POST',\n shown === null ? {} : { expectedVersion: shown },\n );\n return ctx.succeed(\n { host: run.host, ...result },\n describeChange(\n result,\n `You confirmed what ${result.slug} on ${result.team.slug} may use`,\n run.source,\n { confirmRequested: true },\n ),\n );\n }\n case 'disable': {\n expectOperands(run, 2);\n if (!run.args.yes) {\n throw invalidStateError(\n `Turning ${key} off for ${team} pauses it: nothing starts it for that team until it is turned on again, and turning it on is refused once the person it runs as has left the team.`,\n `Re-run with --yes: ekanos teams agents disable ${team} ${key} --yes`,\n );\n }\n const result = await change(run, `${path}/disable`, 'POST', {});\n return ctx.succeed(\n { host: run.host, ...result },\n describeChange(\n result,\n `Turned off ${result.slug} for ${result.team.slug}`,\n run.source,\n ),\n );\n }\n case 'pin': {\n if (run.args.flags?.draft === true) {\n expectOperands(run, 2);\n const result = await change(run, `${path}/pin`, 'PUT', {\n version: null,\n draft: true,\n });\n requireDraftHost(result, 'pinned');\n return ctx.succeed(\n { host: run.host, ...result },\n describeChange(\n result,\n `Testing draft v${result.version ?? '?'} of ${result.slug} on ${result.team.slug}`,\n run.source,\n ),\n );\n }\n expectOperands(run, 3);\n const version = Number(run.operands[2]);\n if (!Number.isInteger(version) || version < 1) {\n throw usageError(\n run.operands[2]\n ? `\"${run.operands[2]}\" is not a version number.`\n : 'Name the version to pin.',\n `e.g. \"ekanos teams agents pin ${team} ${key} 3\", or \"--draft\" to test the unpublished draft. \"ekanos agents show ${key}\" lists its versions.`,\n );\n }\n const result = await change(run, `${path}/pin`, 'PUT', { version });\n return ctx.succeed(\n { host: run.host, ...result },\n describeChange(\n result,\n `${result.team.slug} stays on v${result.version ?? version} of ${result.slug}`,\n run.source,\n ),\n );\n }\n case 'unpin': {\n expectOperands(run, 2);\n const result = await change(run, `${path}/pin`, 'PUT', { version: null });\n return ctx.succeed(\n { host: run.host, ...result },\n describeChange(\n result,\n `${result.team.slug} follows each published version of ${result.slug}`,\n run.source,\n ),\n );\n }\n case 'archive': {\n expectOperands(run, 2);\n // Asked before any request: a script or an agent run passes --yes.\n if (!run.args.yes) {\n await confirmChange(ctx, run.args, {\n what: `Archiving ${key} on ${team} takes it off the team's list: nothing starts it until it is unarchived and turned on again. Its runs, approvals and setup are kept.`,\n command: `${cli()} teams agents archive ${team} ${key} --yes`,\n question: `Archive ${key} on ${team}? [y/N]`,\n });\n }\n const result = await change(run, `${path}/archive`, 'POST', {});\n return ctx.succeed(\n { host: run.host, ...result },\n [\n `✓ Archived ${result.slug} on ${result.team.slug}`,\n ` Bring it back, paused: ${cli()} teams agents unarchive ${result.team.slug} ${result.slug} --source ${run.source}`,\n ].join('\\n'),\n );\n }\n case 'unarchive': {\n expectOperands(run, 2);\n const result = await change(run, `${path}/unarchive`, 'POST', {});\n return ctx.succeed(\n { host: run.host, ...result },\n [\n `✓ Unarchived ${result.slug} on ${result.team.slug}: it is paused`,\n ` ${identityLabel(result.runsAs, result.ownership === 'personal')}`,\n ` Next: ${cli()} teams agents enable ${result.team.slug} ${result.slug} --source ${run.source}`,\n ].join('\\n'),\n );\n }\n case 'tags':\n return tags(ctx, run, team, key, `${path}/tags`);\n case 'policy':\n return policy(ctx, run, team, key, `${path}/policy`);\n case 'skills':\n return skills(ctx, run, team, key, `${path}/skills`);\n default:\n throw usageError(\n `Unknown teams agents subcommand \"${run.verb}\".`,\n usageFor('agents'),\n );\n }\n}\n\n/**\n * One agent on one team: each product and whose connection it acts through,\n * each trigger and how its events reach the agent (with the last event and\n * the last run), access, \"Live: yes/no\" and exactly one Next. Reads the\n * team's agents, then its recent runs and events; a host without the\n * activity reads still answers the rest.\n */\nasync function show(\n ctx: CliContext,\n run: TeamAgentRun,\n base: string,\n key: string,\n): Promise<ExitCode> {\n const list = await run.client.call((token) =>\n call(run.host, token, TeamAgentListSchema, {\n method: 'GET',\n path: base,\n source: run.source,\n }),\n );\n const entry = list.agents.find((candidate) => candidate.key === key);\n // The host finds an agent by its own slug first, as here: a team agent\n // named like a template that is not turned on is the team agent.\n const own = entry?.agent\n ? undefined\n : list.ownAgents?.find((candidate) => candidate.slug === key);\n if (own) {\n return ctx.succeed(\n { host: run.host, team: list.team, ownAgent: own },\n describeOwnAgent(own, list.team.slug, run.source).trimStart(),\n );\n }\n if (!entry) {\n throw notFoundError(\n `No agent \"${key}\" is provided for ${list.team.slug}.`,\n `\"ekanos teams agents list ${list.team.slug}\" lists the agents provided for it.`,\n );\n }\n const target = { team: list.team.slug, source: run.source };\n const readiness = agentReadiness(entry, target);\n const [runs, events] = entry.agent\n ? await Promise.all([\n activity(ctx, 'runs', () =>\n run.client.call((token) =>\n call(run.host, token, AgentRunListSchema, {\n method: 'GET',\n path: `/api/partner/teams/${encodeURIComponent(target.team)}/runs?agent=${encodeURIComponent(key)}`,\n source: run.source,\n }),\n ),\n ),\n entry.agent.triggers.some((trigger) => trigger.eventId)\n ? activity(ctx, 'events', () =>\n run.client.call((token) =>\n listTeamEvents(\n run.host,\n token,\n { source: run.source, team: target.team },\n { limit: 100 },\n ),\n ),\n )\n : Promise.resolve(null),\n ])\n : [null, null];\n\n return ctx.succeed(\n {\n host: run.host,\n team: list.team,\n agent: entry,\n readiness,\n lastRun: runs?.runs[0] ?? null,\n recentEvents: events\n ? events.events.filter((event) =>\n entry.agent?.triggers.some(\n (trigger) => trigger.eventId === event.eventId,\n ),\n )\n : null,\n },\n describeAgentReadiness(\n entry,\n target,\n readiness,\n {\n runs: runs?.runs ?? null,\n events: events?.events ?? null,\n },\n list.scope,\n ),\n );\n}\n\n/** A read `show` can do without: on failure, say so and carry on. */\nasync function activity<T>(\n ctx: CliContext,\n what: string,\n read: () => Promise<T>,\n): Promise<T | null> {\n try {\n return await read();\n } catch (error) {\n ctx.log(\n `Could not read the team's recent ${what}: ${error instanceof Error ? error.message : String(error)}`,\n );\n return null;\n }\n}\n\nasync function policy(\n ctx: CliContext,\n run: TeamAgentRun,\n team: string,\n key: string,\n path: string,\n): Promise<ExitCode> {\n const [action, tool, decision] = run.operands.slice(2);\n const change: TeamAgentPolicyChange = {};\n const reads = approvalFlag(run, 'reads');\n const writes = approvalFlag(run, 'writes');\n if (reads) change.reads = reads;\n if (writes) change.writes = writes;\n\n if (action === 'set') {\n const mode = parseApproval(decision);\n if (!tool || !mode) {\n throw usageError(\n 'policy set needs a tool and auto|approve.',\n `e.g. \"ekanos teams agents policy ${team} ${key} set zendesk_reply_to_ticket approve\".`,\n );\n }\n change.set = { [tool]: mode };\n } else if (action === 'unset') {\n if (!tool || decision) {\n throw usageError(\n 'policy unset needs exactly one tool.',\n `e.g. \"ekanos teams agents policy ${team} ${key} unset zendesk_reply_to_ticket\".`,\n );\n }\n change.unset = [tool];\n } else if (action !== undefined) {\n throw usageError(`Unknown policy action \"${action}\".`, usageFor('agents'));\n }\n\n const writing = Object.keys(change).length > 0;\n const confirmAccess = run.args.flags?.['confirm-access'] === true;\n if (confirmAccess && !writing) {\n throw usageError(\n '--confirm-access goes with a policy change.',\n `To confirm on its own: \"ekanos teams agents confirm ${team} ${key}\".`,\n );\n }\n const result = await run.client.call((token) =>\n call(run.host, token, TeamAgentPolicySchema, {\n method: writing ? 'PUT' : 'GET',\n path,\n source: run.source,\n ...(writing\n ? { body: { ...change, ...(confirmAccess ? { confirmAccess } : {}) } }\n : {}),\n }),\n );\n return ctx.succeed(\n { host: run.host, ...result },\n describePolicy(ctx, result, writing, run.source),\n );\n}\n\n/**\n * `teams agents skills <team> <key> [add|remove <skill>]` — the skills the\n * team's agent reads. A provided agent takes the team's own only where its\n * template allows (`teamCustomization.skills`); its template's stay.\n */\nasync function skills(\n ctx: CliContext,\n run: TeamAgentRun,\n team: string,\n key: string,\n path: string,\n): Promise<ExitCode> {\n const [action, slug, extra] = run.operands.slice(2);\n if (extra !== undefined) {\n throw usageError(`Unexpected argument \"${extra}\".`, usageFor('agents'));\n }\n let change: TeamAgentSkillsChange | null = null;\n if (action === 'add' || action === 'remove') {\n if (!slug) {\n throw usageError(\n `skills ${action} needs a skill slug.`,\n `e.g. \"ekanos teams agents skills ${team} ${key} ${action} refund-policy\". \"ekanos skills list --team ${team}\" lists the team's skills.`,\n );\n }\n change = { [action]: [slug.trim().toLowerCase()] };\n } else if (action !== undefined) {\n throw usageError(`Unknown skills action \"${action}\".`, usageFor('agents'));\n }\n\n const result = await run.client.call((token) =>\n call(run.host, token, TeamAgentSkillsSchema, {\n method: change ? 'PUT' : 'GET',\n path,\n source: run.source,\n ...(change ? { body: change } : {}),\n }),\n );\n return ctx.succeed(\n { host: run.host, ...result },\n describeSkills(ctx, result, change),\n );\n}\n\n/**\n * `teams agents tags <team> <key> [add|remove <tag>]` — the labels that\n * organize the team's agents; they grant nothing. A tag the team does not\n * have yet is made when it is added, as the app's New tag makes it.\n */\nasync function tags(\n ctx: CliContext,\n run: TeamAgentRun,\n team: string,\n key: string,\n path: string,\n): Promise<ExitCode> {\n const [action, tag, extra] = run.operands.slice(2);\n if (extra !== undefined) {\n throw usageError(\n `Unexpected argument \"${extra}\".`,\n 'Quote a tag name with spaces, e.g. \"Customer support\".',\n );\n }\n let change: TeamAgentTagsChange | null = null;\n if (action === 'add' || action === 'remove') {\n if (!tag?.trim()) {\n throw usageError(\n `tags ${action} needs a tag.`,\n `e.g. ${cli()} teams agents tags ${team} ${key} ${action} \"Customer support\"`,\n );\n }\n change = { [action]: tag.trim() };\n } else if (action !== undefined) {\n throw usageError(`Unknown tags action \"${action}\".`, usageFor('agents'));\n }\n\n const result = await run.client.call((token) =>\n call(run.host, token, TeamAgentTagsSchema, {\n method: change ? 'PUT' : 'GET',\n path,\n source: run.source,\n ...(change ? { body: change } : {}),\n }),\n );\n const title = change?.add\n ? `Tagged ${result.slug} on ${result.team.slug} \"${change.add}\"`\n : change?.remove\n ? `Took the tag \"${change.remove}\" off ${result.slug} on ${result.team.slug}`\n : `Tags of ${result.slug} on ${result.team.slug}`;\n const lines = [\n ctx.ui.result({\n title,\n tone: 'ok',\n rows: [\n [\n 'tags',\n result.tags.length === 0\n ? 'none'\n : result.tags.map((item) => item.name).join(', '),\n ],\n ],\n notes: result.createdTag\n ? [\n `${result.team.slug} had no tag \"${result.createdTag.name}\": it was made.`,\n ]\n : [],\n }),\n ];\n const others = result.teamTags.filter(\n (item) => !result.tags.some((on) => on.slug === item.slug),\n );\n if (!change && others.length > 0) {\n lines.push(\n `\\nThe team's other tags: ${others.map((item) => item.name).join(', ')}`,\n );\n }\n return ctx.succeed({ host: run.host, ...result }, lines.join('\\n'));\n}\n\nfunction describeSkills(\n ctx: CliContext,\n result: TeamAgentSkills,\n change: TeamAgentSkillsChange | null,\n): string {\n const [verb, slug] = change?.add\n ? ['Attached', change.add[0]]\n : change?.remove\n ? ['Detached', change.remove[0]]\n : [null, null];\n const head = ctx.ui.result({\n title: verb\n ? `${verb} ${slug} ${verb === 'Attached' ? 'to' : 'from'} ${result.slug} on ${result.team.slug}`\n : `Skills of ${result.slug} on ${result.team.slug}`,\n tone: result.editable ? 'ok' : 'warn',\n rows: [\n [\n 'team skills',\n result.editable ? 'allowed' : 'no — follows the template',\n ],\n ],\n notes: result.lockedReason ? [result.lockedReason] : [],\n });\n if (result.skills.length === 0) return `${head}\\n\\nNo skills attached.`;\n return `${head}\\n\\n${ctx.ui.table(\n ['skill', 'name', 'from'],\n result.skills.map((skill) => [\n skill.slug,\n skill.name,\n skill.fromTemplate ? 'the template' : `${skill.level} skill`,\n ]),\n )}`;\n}\n\nfunction describePolicy(\n ctx: CliContext,\n policy: TeamAgentPolicy,\n changed: boolean,\n source: string,\n): string {\n // Absent from an older host: say nothing rather than guess.\n const unconfirmed = policy.accessConfirmed === false;\n const head = ctx.ui.result({\n title: changed\n ? `Policy updated for ${policy.slug} on ${policy.team.slug}`\n : `Policy of ${policy.slug} on ${policy.team.slug}`,\n tone: policy.editable && !unconfirmed ? 'ok' : 'warn',\n rows: [\n ['reads', policy.reads],\n ['writes', policy.writes],\n ['editable', policy.editable ? 'yes' : 'no — follows the template'],\n ],\n notes: [\n ...(policy.lockedReason ? [policy.lockedReason] : []),\n ...(unconfirmed\n ? [\n `Not confirmed: until you or one of the team's agent managers confirms what it may use, it uses only what needs no confirmation (a looser policy drops a confirmation). Confirm it as yourself with --confirm-access on the change, or for a provided agent ${confirmCommand(policy.team.slug, policy.key, source)}; a team manager can also confirm on its page in the app`,\n ]\n : []),\n ],\n });\n if (policy.tools.length === 0) {\n return `${head}\\n\\nNo tools yet: connect its integrations or MCP servers.`;\n }\n return `${head}\\n\\n${ctx.ui.table(\n ['tool', 'from', 'effect', 'runs'],\n policy.tools.map((tool) => [\n tool.name,\n tool.source,\n tool.effect,\n `${tool.decision === 'auto' ? 'on its own' : 'waits for approval'}${tool.overridden ? ' (set per tool)' : ''}`,\n ]),\n )}`;\n}\n\n/**\n * The version `confirm` is about to approve — the one it runs — printed\n * before it is sent, so the person confirms what they saw. Null when the\n * team's agent has no version to name.\n */\nasync function shownVersion(\n ctx: CliContext,\n run: TeamAgentRun,\n base: string,\n key: string,\n): Promise<number | null> {\n const list = await run.client.call((token) =>\n call(run.host, token, TeamAgentListSchema, {\n method: 'GET',\n path: base,\n source: run.source,\n }),\n );\n const own = list.ownAgents?.find((entry) => entry.slug === key);\n if (own) {\n ctx.log(\n `Confirming what ${key} v${own.version} on ${list.team.slug} may use (it ${identityLabel(own.createdBy ?? null, own.ownership === 'personal')}).`,\n );\n return own.version;\n }\n const agent = list.agents.find((entry) => entry.key === key)?.agent;\n if (!agent || agent.version === null) return null;\n ctx.log(\n `Confirming what ${key} v${agent.version} on ${list.team.slug} may use (it ${identityLabel(agent.runsAs)}).`,\n );\n return agent.version;\n}\n\nfunction change(\n run: TeamAgentRun,\n path: string,\n method: 'POST' | 'PUT',\n body: unknown,\n): Promise<TeamAgentChangeResult> {\n return run.client.call((token) =>\n call(run.host, token, TeamAgentChangeResultSchema, {\n method,\n path,\n source: run.source,\n body,\n }),\n );\n}\n\nfunction describeEntry(\n entry: TeamAgentEntry,\n team: string,\n source: string,\n): string {\n const readiness = agentReadiness(entry, { team, source });\n if (!entry.agent) {\n return `\\n${entry.key} — ${entry.name}\\n off · v${entry.publishedVersion ?? '?'} published\\n ${liveLine(readiness)} · Next: ${readiness.next}`;\n }\n const agent = entry.agent;\n const version = versionLabel(agent);\n const lines = [\n `\\n${entry.key} — ${entry.name}`,\n ` ${agent.status} · ${version} · ${identityLabel(agent.runsAs)}${agent.accessConfirmed ? '' : ` · access not confirmed (${confirmCommand(team, entry.key, source)})`}`,\n ` triggers: ${agent.triggers.length === 0 ? 'none' : agent.triggers.map((trigger) => `${trigger.type}${trigger.enabled ? '' : ' (off)'}`).join(', ')}`,\n ` links: ${agent.links.length === 0 ? 'none' : agent.links.map((link) => `${link.kind}${link.mode ? `/${link.mode}` : ''} → ${link.to}`).join(', ')}`,\n ];\n lines.push(\n ...requirementLines(agent.requirements, agent.missing, team, source),\n );\n if (agent.draft) lines.push(...draftLines(team, entry.key));\n lines.push(...channelLines(agent.channels ?? [], team, source));\n lines.push(\n ` ${liveLine(readiness)}${readiness.next ? ` · Next: ${readiness.next}` : ''}`,\n );\n return lines.join('\\n');\n}\n\n/**\n * One of the team's own agents, or a personal one: whose it is, its version\n * (what `apply --base-version` names), its triggers, and the next step.\n */\nfunction describeOwnAgent(\n agent: TeamOwnAgent,\n team: string,\n source: string,\n): string {\n const personal = agent.ownership === 'personal';\n const whose = personal\n ? `personal agent of ${agent.yours ? 'yours' : (agent.createdBy ?? 'a former member')}`\n : `team agent · ${identityLabel(agent.createdBy ?? null)}`;\n const lines = [\n `\n${agent.slug} — ${agent.name}`,\n ` ${agent.status} · v${agent.version} · ${whose}${agent.accessConfirmed ? '' : ' · access not confirmed'}`,\n ` triggers: ${agent.triggers.length === 0 ? 'none' : agent.triggers.map((trigger) => `${trigger.type}${trigger.enabled ? '' : ' (off)'}`).join(', ')}`,\n ];\n if (personal && !agent.yours) {\n lines.push(\n ' Only its creator changes it, runs it, decides its approvals or reads its runs.',\n );\n } else if (agent.status !== 'active') {\n lines.push(\n ` Next: ekanos teams agents enable ${team} ${agent.slug} --source ${source}`,\n );\n } else if (!agent.accessConfirmed) {\n lines.push(` Next: ${confirmCommand(team, agent.slug, source)}`);\n }\n return lines.join('\\n');\n}\n\nfunction versionLabel(agent: {\n version: number | null;\n pinned: boolean;\n draft?: boolean;\n}): string {\n if (agent.draft)\n return `draft v${agent.version ?? '?'} (testing, unpublished)`;\n return `v${agent.version ?? '?'} ${agent.pinned ? '(pinned)' : '(following)'}`;\n}\n\n/** What testing a draft on a team means, and the next step. */\nfunction draftLines(team: string, key: string): string[] {\n return [\n ' Only this team runs the draft, and only when started by hand: its triggers, schedules and hand-offs do not start it, and every write waits for approval.',\n ` Test it: ekanos agents test ${key} --team ${team} --prompt \"…\" --follow. Publishing (ekanos agents publish ${key}) puts this team back to following.`,\n ];\n}\n\n/**\n * An older host ignores `draft` and would have turned on, or unpinned to,\n * the published version instead. Say so rather than report a draft test\n * that is not happening.\n */\nfunction requireDraftHost(\n result: TeamAgentChangeResult,\n verb: 'enabled' | 'pinned',\n) {\n if (result.draft === true) return;\n throw invalidStateError(\n `This host does not support testing a draft on one team: it ${verb} ${result.slug} on v${result.version ?? '?'} ${result.pinned ? '(pinned)' : '(following)'} instead.`,\n `Check with \"ekanos teams agents list ${result.team.slug}\", and test once the host is updated.`,\n );\n}\n\n/**\n * What the agent still needs connected, each with why and the command that\n * makes it; then any product working on another connection than the one its\n * template names (the Source connection unusable, the team's own used).\n */\nexport function requirementLines(\n requirements: Requirement[],\n missing: Requirement[],\n team: string,\n source: string,\n): string[] {\n const missingLines = missing.flatMap((item) => {\n const fix = requirementFix(item, team, source);\n return [\n ` ✗ missing: ${item.name} (${item.kind === 'mcp' ? 'MCP server' : 'integration'} ${item.key})${item.reason && item.reason !== 'not_connected' ? ` — ${REASON_WORDS[item.reason]}` : ''}`,\n ...(fix ? [` → ${fix}`] : []),\n ];\n });\n const fallbacks = requirements\n .filter(\n (item) =>\n item.connected &&\n item.reason !== undefined &&\n item.reason !== null &&\n item.reason !== 'not_connected',\n )\n .flatMap((item) => {\n const fix = requirementFix(item, team, source);\n return [\n ` ! ${item.name} uses the team's own connection: ${REASON_WORDS[item.reason!]}`,\n ...(fix ? [` → ${fix}`] : []),\n ];\n });\n return [...missingLines, ...fallbacks];\n}\n\n/**\n * What the agent's triggers need installed before they can fire: missing\n * ones first, each with the command that installs it. A trigger listed above\n * with its channel missing here is one that will never start a run.\n */\nexport function channelLines(\n channels: ChannelRequirement[],\n team: string,\n source: string,\n): string[] {\n return channels.flatMap((channel) =>\n channel.ready\n ? [\n channel.arrival === undefined || channel.arrival === 'install'\n ? ` ✓ ${channel.name} installed — ${channel.triggers.join(', ')} can fire`\n : ` ✓ ${channel.triggers.join(', ')} reachable (${reachedVia(channel)}${channel.lastDeliveryAt ? `, last delivery ${channel.lastDeliveryAt}` : ''}) — can fire`,\n ]\n : [\n ` ✗ missing: ${channel.problem ?? `${channel.name} not ready`} — ${channel.triggers.join(', ')} can never fire until it is`,\n ` → ${fixLine(channelFix(channel, team, source))}`,\n ],\n );\n}\n\nfunction describeChange(\n result: TeamAgentChangeResult,\n title: string,\n source: string,\n options: { confirmRequested?: boolean } = {},\n): string {\n const lines = [\n `${options.confirmRequested && !result.accessConfirmed ? '!' : '✓'} ${title}`,\n ` ${result.status} · ${versionLabel(result)} · ${identityLabel(result.runsAs, result.ownership === 'personal')}`,\n ];\n const uses = result.access\n ? describeConnections(result.access, result.runsAs)\n : null;\n if (result.accessConfirmed) {\n if (uses) {\n lines.push(` Confirmed: in runs no one watches it may use ${uses}.`);\n }\n } else {\n if (options.confirmRequested) {\n // An older host ignores confirmAccess rather than refusing it.\n lines.push(\n ' This host did not record the confirmation: it may not support confirming from the CLI yet.',\n );\n }\n lines.push(\n ` Not confirmed: until you or one of the team's agent managers confirms what it may use${uses ? ` (${uses})` : ''}, it uses only what needs no confirmation.`,\n ` → ${confirmCommand(result.team.slug, result.key, source)}`,\n );\n }\n lines.push(...requirementLines([], result.missing, result.team.slug, source));\n if (result.draft) lines.push(...draftLines(result.team.slug, result.key));\n lines.push(...channelLines(result.channels ?? [], result.team.slug, source));\n return lines.join('\\n');\n}\n\nfunction confirmCommand(team: string, key: string, source: string): string {\n return `ekanos teams agents confirm ${team} ${key} --source ${source}`;\n}\n\nfunction expectOperands(run: TeamAgentRun, count: number) {\n const extra = run.operands[count];\n if (extra !== undefined) {\n throw usageError(`Unexpected argument \"${extra}\".`, usageFor('agents'));\n }\n}\n\nfunction stringFlag(run: TeamAgentRun, name: string): string | undefined {\n const value = run.args.flags?.[name];\n return typeof value === 'string' && value.trim() ? value.trim() : undefined;\n}\n\nfunction parseApproval(value: string | undefined): 'auto' | 'approve' | null {\n return value === 'auto' || value === 'approve' ? value : null;\n}\n\nfunction approvalFlag(\n run: TeamAgentRun,\n name: 'reads' | 'writes',\n): 'auto' | 'approve' | undefined {\n const value = stringFlag(run, name);\n if (value === undefined) return undefined;\n const mode = parseApproval(value);\n if (!mode) {\n throw usageError(`--${name} takes auto or approve.`, usageFor('agents'));\n }\n return mode;\n}\n"]}
1
+ {"version":3,"file":"team-agents-agents.js","sourceRoot":"","sources":["../../src/commands/team-agents-agents.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAIlB,2BAA2B,EAE3B,mBAAmB,EAGnB,qBAAqB,EAGrB,qBAAqB,EAErB,mBAAmB,GAEpB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEzE,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,YAAY,EACZ,cAAc,EACd,UAAU,EACV,sBAAsB,EACtB,OAA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,KAAK,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CAAC,GAAiB,EAAE,IAAY;;IACjD,MAAM,KAAK,GAAG,MAAA,GAAG,CAAC,IAAI,CAAC,KAAK,0CAAG,IAAI,CAAC,CAAC;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC9E,CAAC;AAED,SAAS,aAAa,CAAC,KAAyB;IAC9C,OAAO,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAChE,CAAC;AAED,SAAS,YAAY,CACnB,GAAiB,EACjB,IAAwB;IAExB,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACpC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IAClC,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,UAAU,CAAC,KAAK,IAAI,yBAAyB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC3E,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import {\n AgentRunListSchema,\n type ChannelRequirement,\n type Requirement,\n type TeamAgentChangeResult,\n TeamAgentChangeResultSchema,\n type TeamAgentEntry,\n TeamAgentListSchema,\n type TeamAgentPolicy,\n type TeamAgentPolicyChange,\n TeamAgentPolicySchema,\n type TeamAgentSkills,\n type TeamAgentSkillsChange,\n TeamAgentSkillsSchema,\n type TeamAgentTagsChange,\n TeamAgentTagsSchema,\n type TeamOwnAgent,\n} from '@ekanos/integration-schema';\n\nimport type { CliContext } from '../context';\nimport { invalidStateError, notFoundError, usageError } from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { cli } from '../invocation';\nimport { call, listTeamEvents } from '../teams-api';\nimport {\n describeAccess,\n describeConnections,\n identityLabel,\n personConnectionsOf,\n} from './team-agent-access';\nimport {\n REASON_WORDS,\n agentReadiness,\n channelFix,\n describeAgentReadiness,\n fixLine,\n liveLine,\n reachedVia,\n requirementFix,\n} from './team-agent-readiness';\nimport { type TeamAgentRun, requireOperand, usageFor } from './team-agents';\nimport { runTeamAgentDefine } from './team-agents-define';\nimport { confirmChange } from './teams-lifecycle';\n\nexport { describeAccess, describeConnections, identityLabel };\n\n/**\n * `ekanos teams agents list|show|create|apply|enable|confirm|disable|archive|unarchive|pin|unpin|policy|skills|tags` —\n * a team's provided agents, turned on, versioned, given an approval policy\n * and skills by the Source admin; and the team's own and personal agents,\n * made and changed from an agent.json with `create|apply`\n * (team-agents-define.ts), turned on with `enable`. A personal agent is\n * listed and shown to everyone, and changed by its creator alone. `enable|pin … --draft` puts one team on\n * the template's latest, unpublished version to test it there before\n * publishing. `confirm` (and `--confirm-access`) records the caller's own\n * confirmation that it may use its connections in runs no one watches:\n * whoever sets an agent up confirms it (plan 247.2), never a member.\n * `show` answers \"is this agent live, and if not, why?\" for one agent; `list`\n * ends each agent with the same verdict.\n */\nexport async function runTeamAgentsArea(\n ctx: CliContext,\n run: TeamAgentRun,\n): Promise<ExitCode> {\n const team = requireOperand(run.operands[0], 'team slug', 'agents');\n const base = `/api/partner/teams/${encodeURIComponent(team)}/agents`;\n\n if (run.verb === 'list') {\n expectOperands(run, 1);\n const list = await run.client.call((token) =>\n call(run.host, token, TeamAgentListSchema, {\n method: 'GET',\n path: base,\n source: run.source,\n }),\n );\n const target = { team: list.team.slug, source: run.source };\n const own = list.ownAgents ?? [];\n return ctx.succeed(\n {\n host: run.host,\n ...list,\n agents: list.agents.map((entry) => ({\n ...entry,\n readiness: agentReadiness(entry, target),\n })),\n },\n [\n ctx.ui.result({\n title:\n list.agents.length === 0 && own.length === 0\n ? `No agents are provided for ${list.team.slug}`\n : `Agents for ${list.team.slug}`,\n tone: list.agents.length === 0 && own.length === 0 ? 'warn' : 'ok',\n }),\n ...list.agents.map((entry) =>\n describeEntry(entry, list.team.slug, run.source),\n ),\n ...(own.length > 0\n ? [\n `\nThe team's own and personal agents:`,\n ...own.map((agent) =>\n describeOwnAgent(agent, list.team.slug, run.source),\n ),\n ]\n : []),\n list.mcpServers.length > 0\n ? `\\nMCP servers: ${list.mcpServers.map((server) => `${server.key} (${server.status})`).join(', ')}`\n : '',\n ]\n .filter(Boolean)\n .join('\\n'),\n );\n }\n\n if (run.verb === 'create' || run.verb === 'apply') {\n return runTeamAgentDefine(ctx, run, run.verb);\n }\n\n const key = requireOperand(run.operands[1], 'agent key', 'agents');\n const path = `${base}/${encodeURIComponent(key)}`;\n\n switch (run.verb) {\n case 'show':\n expectOperands(run, 2);\n return show(ctx, run, base, key);\n case 'enable': {\n expectOperands(run, 2);\n const as = stringFlag(run, 'as');\n const draft = run.args.flags?.draft === true;\n const confirmAccess = run.args.flags?.['confirm-access'] === true;\n const result = await change(run, `${path}/enable`, 'POST', {\n ...(as ? { as } : {}),\n ...(draft ? { draft: true } : {}),\n ...(confirmAccess ? { confirmAccess: true } : {}),\n });\n if (draft) requireDraftHost(result, 'enabled');\n return ctx.succeed(\n { host: run.host, ...result },\n describeChange(\n result,\n `${\n draft\n ? `Testing draft v${result.version ?? '?'} of ${result.slug} on ${result.team.slug}`\n : `Turned on ${result.slug} for ${result.team.slug}`\n }${confirmAccess && result.accessConfirmed ? ', and you confirmed what it may use' : ''}`,\n run.source,\n { confirmRequested: confirmAccess },\n ),\n );\n }\n case 'confirm': {\n expectOperands(run, 2);\n // Confirm what the person is shown, never a publish that lands after:\n // the host refuses if the version moved (AGENT_VERSION_CHANGED).\n const shown = await shownVersion(ctx, run, base, key);\n const result = await change(\n run,\n `${path}/confirm`,\n 'POST',\n shown === null ? {} : { expectedVersion: shown },\n );\n return ctx.succeed(\n { host: run.host, ...result },\n describeChange(\n result,\n `You confirmed what ${result.slug} on ${result.team.slug} may use`,\n run.source,\n { confirmRequested: true },\n ),\n );\n }\n case 'disable': {\n expectOperands(run, 2);\n if (!run.args.yes) {\n throw invalidStateError(\n `Turning ${key} off for ${team} pauses it: nothing starts it for that team until it is turned on again, and turning it on is refused once the person it runs as has left the team.`,\n `Re-run with --yes: ekanos teams agents disable ${team} ${key} --yes`,\n );\n }\n const result = await change(run, `${path}/disable`, 'POST', {});\n return ctx.succeed(\n { host: run.host, ...result },\n describeChange(\n result,\n `Turned off ${result.slug} for ${result.team.slug}`,\n run.source,\n ),\n );\n }\n case 'pin': {\n if (run.args.flags?.draft === true) {\n expectOperands(run, 2);\n const result = await change(run, `${path}/pin`, 'PUT', {\n version: null,\n draft: true,\n });\n requireDraftHost(result, 'pinned');\n return ctx.succeed(\n { host: run.host, ...result },\n describeChange(\n result,\n `Testing draft v${result.version ?? '?'} of ${result.slug} on ${result.team.slug}`,\n run.source,\n ),\n );\n }\n expectOperands(run, 3);\n const version = Number(run.operands[2]);\n if (!Number.isInteger(version) || version < 1) {\n throw usageError(\n run.operands[2]\n ? `\"${run.operands[2]}\" is not a version number.`\n : 'Name the version to pin.',\n `e.g. \"ekanos teams agents pin ${team} ${key} 3\", or \"--draft\" to test the unpublished draft. \"ekanos agents show ${key}\" lists its versions.`,\n );\n }\n const result = await change(run, `${path}/pin`, 'PUT', { version });\n return ctx.succeed(\n { host: run.host, ...result },\n describeChange(\n result,\n `${result.team.slug} stays on v${result.version ?? version} of ${result.slug}`,\n run.source,\n ),\n );\n }\n case 'unpin': {\n expectOperands(run, 2);\n const result = await change(run, `${path}/pin`, 'PUT', { version: null });\n return ctx.succeed(\n { host: run.host, ...result },\n describeChange(\n result,\n `${result.team.slug} follows each published version of ${result.slug}`,\n run.source,\n ),\n );\n }\n case 'archive': {\n expectOperands(run, 2);\n // Asked before any request: a script or an agent run passes --yes.\n if (!run.args.yes) {\n await confirmChange(ctx, run.args, {\n what: `Archiving ${key} on ${team} takes it off the team's list: nothing starts it until it is unarchived and turned on again. Its runs, approvals and setup are kept.`,\n command: `${cli()} teams agents archive ${team} ${key} --yes`,\n question: `Archive ${key} on ${team}? [y/N]`,\n });\n }\n const result = await change(run, `${path}/archive`, 'POST', {});\n return ctx.succeed(\n { host: run.host, ...result },\n [\n `✓ Archived ${result.slug} on ${result.team.slug}`,\n ` Bring it back, paused: ${cli()} teams agents unarchive ${result.team.slug} ${result.slug} --source ${run.source}`,\n ].join('\\n'),\n );\n }\n case 'unarchive': {\n expectOperands(run, 2);\n const result = await change(run, `${path}/unarchive`, 'POST', {});\n return ctx.succeed(\n { host: run.host, ...result },\n [\n `✓ Unarchived ${result.slug} on ${result.team.slug}: it is paused`,\n ` ${identityLabel(result.runsAs, result.ownership === 'personal')}`,\n ` Next: ${cli()} teams agents enable ${result.team.slug} ${result.slug} --source ${run.source}`,\n ].join('\\n'),\n );\n }\n case 'tags':\n return tags(ctx, run, team, key, `${path}/tags`);\n case 'policy':\n return policy(ctx, run, team, key, `${path}/policy`);\n case 'skills':\n return skills(ctx, run, team, key, `${path}/skills`);\n default:\n throw usageError(\n `Unknown teams agents subcommand \"${run.verb}\".`,\n usageFor('agents'),\n );\n }\n}\n\n/**\n * One agent on one team: each product and whose connection it acts through,\n * each trigger and how its events reach the agent (with the last event and\n * the last run), access, \"Live: yes/no\" and exactly one Next. Reads the\n * team's agents, then its recent runs and events; a host without the\n * activity reads still answers the rest.\n */\nasync function show(\n ctx: CliContext,\n run: TeamAgentRun,\n base: string,\n key: string,\n): Promise<ExitCode> {\n const list = await run.client.call((token) =>\n call(run.host, token, TeamAgentListSchema, {\n method: 'GET',\n path: base,\n source: run.source,\n }),\n );\n const entry = list.agents.find((candidate) => candidate.key === key);\n // The host finds an agent by its own slug first, as here: a team agent\n // named like a template that is not turned on is the team agent.\n const own = entry?.agent\n ? undefined\n : list.ownAgents?.find((candidate) => candidate.slug === key);\n if (own) {\n return ctx.succeed(\n { host: run.host, team: list.team, ownAgent: own },\n describeOwnAgent(own, list.team.slug, run.source).trimStart(),\n );\n }\n if (!entry) {\n throw notFoundError(\n `No agent \"${key}\" is provided for ${list.team.slug}.`,\n `\"ekanos teams agents list ${list.team.slug}\" lists the agents provided for it.`,\n );\n }\n const target = { team: list.team.slug, source: run.source };\n const readiness = agentReadiness(entry, target);\n const [runs, events] = entry.agent\n ? await Promise.all([\n activity(ctx, 'runs', () =>\n run.client.call((token) =>\n call(run.host, token, AgentRunListSchema, {\n method: 'GET',\n path: `/api/partner/teams/${encodeURIComponent(target.team)}/runs?agent=${encodeURIComponent(key)}`,\n source: run.source,\n }),\n ),\n ),\n entry.agent.triggers.some((trigger) => trigger.eventId)\n ? activity(ctx, 'events', () =>\n run.client.call((token) =>\n listTeamEvents(\n run.host,\n token,\n { source: run.source, team: target.team },\n { limit: 100 },\n ),\n ),\n )\n : Promise.resolve(null),\n ])\n : [null, null];\n\n return ctx.succeed(\n {\n host: run.host,\n team: list.team,\n agent: entry,\n readiness,\n lastRun: runs?.runs[0] ?? null,\n recentEvents: events\n ? events.events.filter((event) =>\n entry.agent?.triggers.some(\n (trigger) => trigger.eventId === event.eventId,\n ),\n )\n : null,\n },\n describeAgentReadiness(\n entry,\n target,\n readiness,\n {\n runs: runs?.runs ?? null,\n events: events?.events ?? null,\n },\n list.scope,\n ),\n );\n}\n\n/** A read `show` can do without: on failure, say so and carry on. */\nasync function activity<T>(\n ctx: CliContext,\n what: string,\n read: () => Promise<T>,\n): Promise<T | null> {\n try {\n return await read();\n } catch (error) {\n ctx.log(\n `Could not read the team's recent ${what}: ${error instanceof Error ? error.message : String(error)}`,\n );\n return null;\n }\n}\n\nasync function policy(\n ctx: CliContext,\n run: TeamAgentRun,\n team: string,\n key: string,\n path: string,\n): Promise<ExitCode> {\n const [action, tool, decision] = run.operands.slice(2);\n const change: TeamAgentPolicyChange = {};\n const reads = approvalFlag(run, 'reads');\n const writes = approvalFlag(run, 'writes');\n if (reads) change.reads = reads;\n if (writes) change.writes = writes;\n\n if (action === 'set') {\n const mode = parseApproval(decision);\n if (!tool || !mode) {\n throw usageError(\n 'policy set needs a tool and auto|approve.',\n `e.g. \"ekanos teams agents policy ${team} ${key} set zendesk_reply_to_ticket approve\".`,\n );\n }\n change.set = { [tool]: mode };\n } else if (action === 'unset') {\n if (!tool || decision) {\n throw usageError(\n 'policy unset needs exactly one tool.',\n `e.g. \"ekanos teams agents policy ${team} ${key} unset zendesk_reply_to_ticket\".`,\n );\n }\n change.unset = [tool];\n } else if (action !== undefined) {\n throw usageError(`Unknown policy action \"${action}\".`, usageFor('agents'));\n }\n\n const writing = Object.keys(change).length > 0;\n const confirmAccess = run.args.flags?.['confirm-access'] === true;\n if (confirmAccess && !writing) {\n throw usageError(\n '--confirm-access goes with a policy change.',\n `To confirm on its own: \"ekanos teams agents confirm ${team} ${key}\".`,\n );\n }\n const result = await run.client.call((token) =>\n call(run.host, token, TeamAgentPolicySchema, {\n method: writing ? 'PUT' : 'GET',\n path,\n source: run.source,\n ...(writing\n ? { body: { ...change, ...(confirmAccess ? { confirmAccess } : {}) } }\n : {}),\n }),\n );\n return ctx.succeed(\n { host: run.host, ...result },\n describePolicy(ctx, result, writing, run.source),\n );\n}\n\n/**\n * `teams agents skills <team> <key> [add|remove <skill>]` — the skills the\n * team's agent reads. A provided agent takes the team's own only where its\n * template allows (`teamCustomization.skills`); its template's stay.\n */\nasync function skills(\n ctx: CliContext,\n run: TeamAgentRun,\n team: string,\n key: string,\n path: string,\n): Promise<ExitCode> {\n const [action, slug, extra] = run.operands.slice(2);\n if (extra !== undefined) {\n throw usageError(`Unexpected argument \"${extra}\".`, usageFor('agents'));\n }\n let change: TeamAgentSkillsChange | null = null;\n if (action === 'add' || action === 'remove') {\n if (!slug) {\n throw usageError(\n `skills ${action} needs a skill slug.`,\n `e.g. \"ekanos teams agents skills ${team} ${key} ${action} refund-policy\". \"ekanos skills list --team ${team}\" lists the team's skills.`,\n );\n }\n change = { [action]: [slug.trim().toLowerCase()] };\n } else if (action !== undefined) {\n throw usageError(`Unknown skills action \"${action}\".`, usageFor('agents'));\n }\n\n const result = await run.client.call((token) =>\n call(run.host, token, TeamAgentSkillsSchema, {\n method: change ? 'PUT' : 'GET',\n path,\n source: run.source,\n ...(change ? { body: change } : {}),\n }),\n );\n return ctx.succeed(\n { host: run.host, ...result },\n describeSkills(ctx, result, change),\n );\n}\n\n/**\n * `teams agents tags <team> <key> [add|remove <tag>]` — the labels that\n * organize the team's agents; they grant nothing. A tag the team does not\n * have yet is made when it is added, as the app's New tag makes it.\n */\nasync function tags(\n ctx: CliContext,\n run: TeamAgentRun,\n team: string,\n key: string,\n path: string,\n): Promise<ExitCode> {\n const [action, tag, extra] = run.operands.slice(2);\n if (extra !== undefined) {\n throw usageError(\n `Unexpected argument \"${extra}\".`,\n 'Quote a tag name with spaces, e.g. \"Customer support\".',\n );\n }\n let change: TeamAgentTagsChange | null = null;\n if (action === 'add' || action === 'remove') {\n if (!tag?.trim()) {\n throw usageError(\n `tags ${action} needs a tag.`,\n `e.g. ${cli()} teams agents tags ${team} ${key} ${action} \"Customer support\"`,\n );\n }\n change = { [action]: tag.trim() };\n } else if (action !== undefined) {\n throw usageError(`Unknown tags action \"${action}\".`, usageFor('agents'));\n }\n\n const result = await run.client.call((token) =>\n call(run.host, token, TeamAgentTagsSchema, {\n method: change ? 'PUT' : 'GET',\n path,\n source: run.source,\n ...(change ? { body: change } : {}),\n }),\n );\n const title = change?.add\n ? `Tagged ${result.slug} on ${result.team.slug} \"${change.add}\"`\n : change?.remove\n ? `Took the tag \"${change.remove}\" off ${result.slug} on ${result.team.slug}`\n : `Tags of ${result.slug} on ${result.team.slug}`;\n const lines = [\n ctx.ui.result({\n title,\n tone: 'ok',\n rows: [\n [\n 'tags',\n result.tags.length === 0\n ? 'none'\n : result.tags.map((item) => item.name).join(', '),\n ],\n ],\n notes: result.createdTag\n ? [\n `${result.team.slug} had no tag \"${result.createdTag.name}\": it was made.`,\n ]\n : [],\n }),\n ];\n const others = result.teamTags.filter(\n (item) => !result.tags.some((on) => on.slug === item.slug),\n );\n if (!change && others.length > 0) {\n lines.push(\n `\\nThe team's other tags: ${others.map((item) => item.name).join(', ')}`,\n );\n }\n return ctx.succeed({ host: run.host, ...result }, lines.join('\\n'));\n}\n\nfunction describeSkills(\n ctx: CliContext,\n result: TeamAgentSkills,\n change: TeamAgentSkillsChange | null,\n): string {\n const [verb, slug] = change?.add\n ? ['Attached', change.add[0]]\n : change?.remove\n ? ['Detached', change.remove[0]]\n : [null, null];\n const head = ctx.ui.result({\n title: verb\n ? `${verb} ${slug} ${verb === 'Attached' ? 'to' : 'from'} ${result.slug} on ${result.team.slug}`\n : `Skills of ${result.slug} on ${result.team.slug}`,\n tone: result.editable ? 'ok' : 'warn',\n rows: [\n [\n 'team skills',\n result.editable ? 'allowed' : 'no — follows the template',\n ],\n ],\n notes: result.lockedReason ? [result.lockedReason] : [],\n });\n if (result.skills.length === 0) return `${head}\\n\\nNo skills attached.`;\n return `${head}\\n\\n${ctx.ui.table(\n ['skill', 'name', 'from'],\n result.skills.map((skill) => [\n skill.slug,\n skill.name,\n skill.fromTemplate ? 'the template' : `${skill.level} skill`,\n ]),\n )}`;\n}\n\nfunction describePolicy(\n ctx: CliContext,\n policy: TeamAgentPolicy,\n changed: boolean,\n source: string,\n): string {\n // Absent from an older host: say nothing rather than guess.\n const unconfirmed = policy.accessConfirmed === false;\n const head = ctx.ui.result({\n title: changed\n ? `Policy updated for ${policy.slug} on ${policy.team.slug}`\n : `Policy of ${policy.slug} on ${policy.team.slug}`,\n tone: policy.editable && !unconfirmed ? 'ok' : 'warn',\n rows: [\n ['reads', policy.reads],\n ['writes', policy.writes],\n ['editable', policy.editable ? 'yes' : 'no — follows the template'],\n ],\n notes: [\n ...(policy.lockedReason ? [policy.lockedReason] : []),\n ...(unconfirmed\n ? [\n `Not confirmed: until you or one of the team's agent managers confirms what it may use, it uses only what needs no confirmation (a looser policy drops a confirmation). Confirm it as yourself with --confirm-access on the change, or for a provided agent ${confirmCommand(policy.team.slug, policy.key, source)}; a team manager can also confirm on its page in the app`,\n ]\n : []),\n ],\n });\n if (policy.tools.length === 0) {\n return `${head}\\n\\nNo tools yet: connect its integrations or MCP servers.`;\n }\n return `${head}\\n\\n${ctx.ui.table(\n ['tool', 'from', 'effect', 'runs'],\n policy.tools.map((tool) => [\n tool.name,\n tool.source,\n tool.effect,\n `${tool.decision === 'auto' ? 'on its own' : 'waits for approval'}${tool.overridden ? ' (set per tool)' : ''}`,\n ]),\n )}`;\n}\n\n/**\n * The version `confirm` is about to approve — the one it runs — printed\n * before it is sent, so the person confirms what they saw. Null when the\n * team's agent has no version to name.\n */\nasync function shownVersion(\n ctx: CliContext,\n run: TeamAgentRun,\n base: string,\n key: string,\n): Promise<number | null> {\n const list = await run.client.call((token) =>\n call(run.host, token, TeamAgentListSchema, {\n method: 'GET',\n path: base,\n source: run.source,\n }),\n );\n const own = list.ownAgents?.find((entry) => entry.slug === key);\n if (own) {\n ctx.log(\n `Confirming what ${key} v${own.version} on ${list.team.slug} may use (it ${identityLabel(own.createdBy ?? null, own.ownership === 'personal', own.personConnections)}).`,\n );\n return own.version;\n }\n const agent = list.agents.find((entry) => entry.key === key)?.agent;\n if (!agent || agent.version === null) return null;\n ctx.log(\n `Confirming what ${key} v${agent.version} on ${list.team.slug} may use (it ${identityLabel(agent.runsAs, false, agent.personConnections)}).`,\n );\n return agent.version;\n}\n\nfunction change(\n run: TeamAgentRun,\n path: string,\n method: 'POST' | 'PUT',\n body: unknown,\n): Promise<TeamAgentChangeResult> {\n return run.client.call((token) =>\n call(run.host, token, TeamAgentChangeResultSchema, {\n method,\n path,\n source: run.source,\n body,\n }),\n );\n}\n\nfunction describeEntry(\n entry: TeamAgentEntry,\n team: string,\n source: string,\n): string {\n const readiness = agentReadiness(entry, { team, source });\n if (!entry.agent) {\n return `\\n${entry.key} — ${entry.name}\\n off · v${entry.publishedVersion ?? '?'} published\\n ${liveLine(readiness)} · Next: ${readiness.next}`;\n }\n const agent = entry.agent;\n const version = versionLabel(agent);\n const lines = [\n `\\n${entry.key} — ${entry.name}`,\n ` ${agent.status} · ${version} · ${identityLabel(agent.runsAs, false, agent.personConnections)}${agent.accessConfirmed ? '' : ` · access not confirmed (${confirmCommand(team, entry.key, source)})`}`,\n ` triggers: ${agent.triggers.length === 0 ? 'none' : agent.triggers.map((trigger) => `${trigger.type}${trigger.enabled ? '' : ' (off)'}`).join(', ')}`,\n ` links: ${agent.links.length === 0 ? 'none' : agent.links.map((link) => `${link.kind}${link.mode ? `/${link.mode}` : ''} → ${link.to}`).join(', ')}`,\n ];\n lines.push(\n ...requirementLines(agent.requirements, agent.missing, team, source),\n );\n if (agent.draft) lines.push(...draftLines(team, entry.key));\n lines.push(...channelLines(agent.channels ?? [], team, source));\n lines.push(\n ` ${liveLine(readiness)}${readiness.next ? ` · Next: ${readiness.next}` : ''}`,\n );\n return lines.join('\\n');\n}\n\n/**\n * One of the team's own agents, or a personal one: whose it is, its version\n * (what `apply --base-version` names), its triggers, and the next step.\n */\nfunction describeOwnAgent(\n agent: TeamOwnAgent,\n team: string,\n source: string,\n): string {\n const personal = agent.ownership === 'personal';\n const whose = personal\n ? `personal agent of ${agent.yours ? 'yours' : (agent.createdBy ?? 'a former member')}`\n : `team agent · ${identityLabel(agent.createdBy ?? null, false, agent.personConnections)}`;\n const lines = [\n `\n${agent.slug} — ${agent.name}`,\n ` ${agent.status} · v${agent.version} · ${whose}${agent.accessConfirmed ? '' : ' · access not confirmed'}`,\n ` triggers: ${agent.triggers.length === 0 ? 'none' : agent.triggers.map((trigger) => `${trigger.type}${trigger.enabled ? '' : ' (off)'}`).join(', ')}`,\n ];\n if (personal && !agent.yours) {\n lines.push(\n ' Only its creator changes it, runs it, decides its approvals or reads its runs.',\n );\n } else if (agent.status !== 'active') {\n lines.push(\n ` Next: ekanos teams agents enable ${team} ${agent.slug} --source ${source}`,\n );\n } else if (!agent.accessConfirmed) {\n lines.push(` Next: ${confirmCommand(team, agent.slug, source)}`);\n }\n return lines.join('\\n');\n}\n\nfunction versionLabel(agent: {\n version: number | null;\n pinned: boolean;\n draft?: boolean;\n}): string {\n if (agent.draft)\n return `draft v${agent.version ?? '?'} (testing, unpublished)`;\n return `v${agent.version ?? '?'} ${agent.pinned ? '(pinned)' : '(following)'}`;\n}\n\n/** What testing a draft on a team means, and the next step. */\nfunction draftLines(team: string, key: string): string[] {\n return [\n ' Only this team runs the draft, and only when started by hand: its triggers, schedules and hand-offs do not start it, and every write waits for approval.',\n ` Test it: ekanos agents test ${key} --team ${team} --prompt \"…\" --follow. Publishing (ekanos agents publish ${key}) puts this team back to following.`,\n ];\n}\n\n/**\n * An older host ignores `draft` and would have turned on, or unpinned to,\n * the published version instead. Say so rather than report a draft test\n * that is not happening.\n */\nfunction requireDraftHost(\n result: TeamAgentChangeResult,\n verb: 'enabled' | 'pinned',\n) {\n if (result.draft === true) return;\n throw invalidStateError(\n `This host does not support testing a draft on one team: it ${verb} ${result.slug} on v${result.version ?? '?'} ${result.pinned ? '(pinned)' : '(following)'} instead.`,\n `Check with \"ekanos teams agents list ${result.team.slug}\", and test once the host is updated.`,\n );\n}\n\n/**\n * What the agent still needs connected, each with why and the command that\n * makes it; then any product working on another connection than the one its\n * template names (the Source connection unusable, the team's own used).\n */\nexport function requirementLines(\n requirements: Requirement[],\n missing: Requirement[],\n team: string,\n source: string,\n): string[] {\n const missingLines = missing.flatMap((item) => {\n const fix = requirementFix(item, team, source);\n return [\n ` ✗ missing: ${item.name} (${item.kind === 'mcp' ? 'MCP server' : 'integration'} ${item.key})${item.reason && item.reason !== 'not_connected' ? ` — ${REASON_WORDS[item.reason]}` : ''}`,\n ...(fix ? [` → ${fix}`] : []),\n ];\n });\n const fallbacks = requirements\n .filter(\n (item) =>\n item.connected &&\n item.reason !== undefined &&\n item.reason !== null &&\n item.reason !== 'not_connected',\n )\n .flatMap((item) => {\n const fix = requirementFix(item, team, source);\n return [\n ` ! ${item.name} uses the team's own connection: ${REASON_WORDS[item.reason!]}`,\n ...(fix ? [` → ${fix}`] : []),\n ];\n });\n return [...missingLines, ...fallbacks];\n}\n\n/**\n * What the agent's triggers need installed before they can fire: missing\n * ones first, each with the command that installs it. A trigger listed above\n * with its channel missing here is one that will never start a run.\n */\nexport function channelLines(\n channels: ChannelRequirement[],\n team: string,\n source: string,\n): string[] {\n return channels.flatMap((channel) =>\n channel.ready\n ? [\n channel.arrival === undefined || channel.arrival === 'install'\n ? ` ✓ ${channel.name} installed — ${channel.triggers.join(', ')} can fire`\n : ` ✓ ${channel.triggers.join(', ')} reachable (${reachedVia(channel)}${channel.lastDeliveryAt ? `, last delivery ${channel.lastDeliveryAt}` : ''}) — can fire`,\n ]\n : [\n ` ✗ missing: ${channel.problem ?? `${channel.name} not ready`} — ${channel.triggers.join(', ')} can never fire until it is`,\n ` → ${fixLine(channelFix(channel, team, source))}`,\n ],\n );\n}\n\nfunction describeChange(\n result: TeamAgentChangeResult,\n title: string,\n source: string,\n options: { confirmRequested?: boolean } = {},\n): string {\n const lines = [\n `${options.confirmRequested && !result.accessConfirmed ? '!' : '✓'} ${title}`,\n ` ${result.status} · ${versionLabel(result)} · ${identityLabel(result.runsAs, result.ownership === 'personal', personConnectionsOf(result.access))}`,\n ];\n const uses = result.access\n ? describeConnections(result.access, result.runsAs)\n : null;\n if (result.accessConfirmed) {\n if (uses) {\n lines.push(` Confirmed: in runs no one watches it may use ${uses}.`);\n }\n } else {\n if (options.confirmRequested) {\n // An older host ignores confirmAccess rather than refusing it.\n lines.push(\n ' This host did not record the confirmation: it may not support confirming from the CLI yet.',\n );\n }\n lines.push(\n ` Not confirmed: until you or one of the team's agent managers confirms what it may use${uses ? ` (${uses})` : ''}, it uses only what needs no confirmation.`,\n ` → ${confirmCommand(result.team.slug, result.key, source)}`,\n );\n }\n lines.push(...requirementLines([], result.missing, result.team.slug, source));\n if (result.draft) lines.push(...draftLines(result.team.slug, result.key));\n lines.push(...channelLines(result.channels ?? [], result.team.slug, source));\n return lines.join('\\n');\n}\n\nfunction confirmCommand(team: string, key: string, source: string): string {\n return `ekanos teams agents confirm ${team} ${key} --source ${source}`;\n}\n\nfunction expectOperands(run: TeamAgentRun, count: number) {\n const extra = run.operands[count];\n if (extra !== undefined) {\n throw usageError(`Unexpected argument \"${extra}\".`, usageFor('agents'));\n }\n}\n\nfunction stringFlag(run: TeamAgentRun, name: string): string | undefined {\n const value = run.args.flags?.[name];\n return typeof value === 'string' && value.trim() ? value.trim() : undefined;\n}\n\nfunction parseApproval(value: string | undefined): 'auto' | 'approve' | null {\n return value === 'auto' || value === 'approve' ? value : null;\n}\n\nfunction approvalFlag(\n run: TeamAgentRun,\n name: 'reads' | 'writes',\n): 'auto' | 'approve' | undefined {\n const value = stringFlag(run, name);\n if (value === undefined) return undefined;\n const mode = parseApproval(value);\n if (!mode) {\n throw usageError(`--${name} takes auto or approve.`, usageFor('agents'));\n }\n return mode;\n}\n"]}