@ekanos/cli 0.14.0 → 0.16.0

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.
Files changed (115) hide show
  1. package/README.md +41 -4
  2. package/dist/auth/ekanos-api.d.ts +23 -0
  3. package/dist/auth/ekanos-api.js +33 -6
  4. package/dist/auth/ekanos-api.js.map +1 -1
  5. package/dist/commands/agents.d.ts +2 -2
  6. package/dist/commands/agents.js +14 -20
  7. package/dist/commands/agents.js.map +1 -1
  8. package/dist/commands/apps.d.ts +11 -3
  9. package/dist/commands/apps.js +86 -28
  10. package/dist/commands/apps.js.map +1 -1
  11. package/dist/commands/catalog.d.ts +4 -2
  12. package/dist/commands/catalog.js +166 -35
  13. package/dist/commands/catalog.js.map +1 -1
  14. package/dist/commands/login.d.ts +2 -0
  15. package/dist/commands/login.js +17 -0
  16. package/dist/commands/login.js.map +1 -1
  17. package/dist/commands/runs.d.ts +7 -3
  18. package/dist/commands/runs.js +24 -6
  19. package/dist/commands/runs.js.map +1 -1
  20. package/dist/commands/scope-notice.d.ts +7 -0
  21. package/dist/commands/scope-notice.js +4 -11
  22. package/dist/commands/scope-notice.js.map +1 -1
  23. package/dist/commands/sources-roles.d.ts +5 -0
  24. package/dist/commands/sources-roles.js +235 -0
  25. package/dist/commands/sources-roles.js.map +1 -0
  26. package/dist/commands/sources.d.ts +5 -0
  27. package/dist/commands/sources.js +6 -1
  28. package/dist/commands/sources.js.map +1 -1
  29. package/dist/commands/team-agent-readiness.d.ts +23 -17
  30. package/dist/commands/team-agent-readiness.js +57 -90
  31. package/dist/commands/team-agent-readiness.js.map +1 -1
  32. package/dist/commands/team-agents-agents.d.ts +8 -5
  33. package/dist/commands/team-agents-agents.js +173 -58
  34. package/dist/commands/team-agents-agents.js.map +1 -1
  35. package/dist/commands/team-agents-define.d.ts +31 -0
  36. package/dist/commands/team-agents-define.js +176 -0
  37. package/dist/commands/team-agents-define.js.map +1 -0
  38. package/dist/commands/team-agents-mcp.js +112 -10
  39. package/dist/commands/team-agents-mcp.js.map +1 -1
  40. package/dist/commands/team-agents-triggers.d.ts +1 -1
  41. package/dist/commands/team-agents-triggers.js +137 -5
  42. package/dist/commands/team-agents-triggers.js.map +1 -1
  43. package/dist/commands/team-agents.d.ts +4 -1
  44. package/dist/commands/team-agents.js +17 -4
  45. package/dist/commands/team-agents.js.map +1 -1
  46. package/dist/commands/team-llm-key.d.ts +14 -0
  47. package/dist/commands/team-llm-key.js +122 -0
  48. package/dist/commands/team-llm-key.js.map +1 -0
  49. package/dist/commands/teams-connect.js +123 -31
  50. package/dist/commands/teams-connect.js.map +1 -1
  51. package/dist/commands/teams-lifecycle.d.ts +90 -0
  52. package/dist/commands/teams-lifecycle.js +457 -0
  53. package/dist/commands/teams-lifecycle.js.map +1 -0
  54. package/dist/commands/teams-onboard.d.ts +14 -0
  55. package/dist/commands/teams-onboard.js +62 -13
  56. package/dist/commands/teams-onboard.js.map +1 -1
  57. package/dist/commands/teams-overview.js +7 -3
  58. package/dist/commands/teams-overview.js.map +1 -1
  59. package/dist/commands/teams.d.ts +25 -5
  60. package/dist/commands/teams.js +101 -39
  61. package/dist/commands/teams.js.map +1 -1
  62. package/dist/commands/workflows.d.ts +37 -0
  63. package/dist/commands/workflows.js +589 -0
  64. package/dist/commands/workflows.js.map +1 -0
  65. package/dist/connect-fields.d.ts +22 -0
  66. package/dist/connect-fields.js +115 -0
  67. package/dist/connect-fields.js.map +1 -0
  68. package/dist/context.d.ts +12 -0
  69. package/dist/context.js +32 -9
  70. package/dist/context.js.map +1 -1
  71. package/dist/index.d.ts +13 -0
  72. package/dist/index.js +367 -133
  73. package/dist/index.js.map +1 -1
  74. package/dist/invocation.d.ts +31 -0
  75. package/dist/invocation.js +58 -0
  76. package/dist/invocation.js.map +1 -0
  77. package/dist/runs-api.js +8 -3
  78. package/dist/runs-api.js.map +1 -1
  79. package/dist/safe-fs.d.ts +18 -0
  80. package/dist/safe-fs.js +57 -0
  81. package/dist/safe-fs.js.map +1 -1
  82. package/dist/secret-form.d.ts +48 -0
  83. package/dist/secret-form.js +212 -0
  84. package/dist/secret-form.js.map +1 -0
  85. package/dist/secret-input.d.ts +96 -0
  86. package/dist/secret-input.js +299 -0
  87. package/dist/secret-input.js.map +1 -0
  88. package/dist/team-connect-api.d.ts +78 -3
  89. package/dist/team-connect-api.js +17 -2
  90. package/dist/team-connect-api.js.map +1 -1
  91. package/dist/team-lifecycle-api.d.ts +435 -0
  92. package/dist/team-lifecycle-api.js +301 -0
  93. package/dist/team-lifecycle-api.js.map +1 -0
  94. package/dist/teams-api.d.ts +13 -1
  95. package/dist/teams-api.js +90 -31
  96. package/dist/teams-api.js.map +1 -1
  97. package/dist/unknown-command.d.ts +18 -0
  98. package/dist/unknown-command.js +50 -0
  99. package/dist/unknown-command.js.map +1 -0
  100. package/dist/workflows-api.d.ts +69 -0
  101. package/dist/workflows-api.js +182 -0
  102. package/dist/workflows-api.js.map +1 -0
  103. package/package.json +3 -3
  104. package/templates/AGENTS.md.tmpl +6 -4
  105. package/templates/claude-skill.md.tmpl +4 -1
  106. package/templates/package.json.tmpl +4 -4
  107. package/templates/skills/build-agent/SKILL.md +56 -22
  108. package/templates/skills/build-agent/references/agent-json.md +4 -1
  109. package/templates/skills/build-agent/references/app-setup.md +14 -7
  110. package/templates/skills/build-agent/references/rollout.md +40 -20
  111. package/templates/skills/build-agent/references/set-up-an-integration.md +46 -29
  112. package/templates/skills/build-agent/references/triggers.md +4 -3
  113. package/templates/skills/build-integration/references/widget-design.md +1 -1
  114. package/templates/skills/ekanos-platform/SKILL.md +77 -23
  115. package/templates/skills/polish-widgets/references/patterns.md +3 -3
@@ -1,47 +1,18 @@
1
+ import { cli } from '../invocation.js';
1
2
  import { scopeFix, scopeHiddenWords } from './scope-notice.js';
2
- /**
3
- * "Is this agent live on this team, and if not, why?" — one answer for
4
- * `teams agents show` and the summary line of `teams agents list`, built only
5
- * from what the host already reports (CLI audit 2026-10-19, §3).
6
- *
7
- * Live is: on, on a published version, every connection it needs made,
8
- * access confirmed by the person it runs as, at least one trigger on, and
9
- * every trigger's events able to reach it. Each gap is a step with one fix,
10
- * in the order they have to be done; the first step's fix is "Next".
11
- *
12
- * An agent HELD on an earlier version (a newer one reaches further than the
13
- * person it runs as confirmed) is still live — it runs the version it is on
14
- * — so the hold is not a step: it is `pending`, said beside "Live", and its
15
- * confirm command is "Next" once nothing else is.
16
- */
17
- const CLI = 'npx @ekanos/cli';
18
3
  export function agentReadiness(entry, target) {
19
4
  var _a;
20
- var _b, _c;
5
+ var _b;
21
6
  const steps = readinessSteps(entry, target);
22
- const pending = pendingUpdate(entry, target);
23
7
  return {
24
8
  live: steps.length === 0,
25
9
  steps,
26
- pending,
27
- next: (_c = (_b = (_a = steps[0]) === null || _a === void 0 ? void 0 : _a.fix) !== null && _b !== void 0 ? _b : pending === null || pending === void 0 ? void 0 : pending.fix) !== null && _c !== void 0 ? _c : null,
28
- };
29
- }
30
- /** The update a held agent waits for, and who confirms it. */
31
- function pendingUpdate(entry, { team, source }) {
32
- var _a, _b;
33
- const agent = entry.agent;
34
- if (!(agent === null || agent === void 0 ? void 0 : agent.held))
35
- return null;
36
- const who = (_a = agent.runsAs) !== null && _a !== void 0 ? _a : 'the person it runs as';
37
- return {
38
- problem: `held on v${(_b = agent.version) !== null && _b !== void 0 ? _b : '?'}: v${agent.held.waiting} ${describeHold(agent.held)}, and waits for ${who} to confirm`,
39
- // Only that person can confirm, signed in as themselves.
40
- fix: `${who} runs: ${CLI} teams agents confirm ${team} ${entry.key} --source ${source} (or confirms in the app: Agents › ${entry.name} › Setup)`,
10
+ next: (_b = (_a = steps[0]) === null || _a === void 0 ? void 0 : _a.fix) !== null && _b !== void 0 ? _b : null,
41
11
  };
42
12
  }
43
13
  /**
44
- * What a waiting version adds over the one running, in words:
14
+ * What a newer version adds over the one a team runs, in words (a publish's
15
+ * report of the teams pinned to another version):
45
16
  * "adds zendesk_update_ticket; lets zendesk_add_tag run without approval".
46
17
  */
47
18
  export function describeHold(hold) {
@@ -68,8 +39,8 @@ export function describeHold(hold) {
68
39
  return parts.length > 0 ? parts.join('; ') : 'reaches further';
69
40
  }
70
41
  function readinessSteps(entry, { team, source }) {
71
- var _a, _b, _c, _d, _e, _f;
72
- const enable = `${CLI} teams agents enable ${team} ${entry.key} --source ${source}`;
42
+ var _a, _b, _c, _d, _e;
43
+ const enable = `${cli()} teams agents enable ${team} ${entry.key} --source ${source}`;
73
44
  const agent = entry.agent;
74
45
  if (!agent)
75
46
  return [{ problem: `off for ${team}`, fix: enable }];
@@ -81,40 +52,40 @@ function readinessSteps(entry, { team, source }) {
81
52
  // A team testing a draft runs it only when started by hand.
82
53
  steps.push({
83
54
  problem: `testing unpublished draft v${(_a = agent.version) !== null && _a !== void 0 ? _a : '?'}: its triggers do not start it`,
84
- fix: `${CLI} agents publish ${entry.key} --source ${source}`,
55
+ fix: `${cli()} agents publish ${entry.key} --source ${source}`,
85
56
  });
86
57
  }
87
58
  else if (agent.version === null) {
88
59
  steps.push({
89
60
  problem: 'no published version',
90
- fix: `${CLI} agents publish ${entry.key} --source ${source}`,
61
+ fix: `${cli()} agents publish ${entry.key} --source ${source}`,
91
62
  });
92
63
  }
93
64
  for (const item of agent.missing) {
94
65
  steps.push({
95
66
  problem: `${item.name}: ${REASON_WORDS[(_b = item.reason) !== null && _b !== void 0 ? _b : 'not_connected']}`,
96
- fix: (_c = requirementFix(item, team, source)) !== null && _c !== void 0 ? _c : `${CLI} teams mcp status ${team} ${item.key} --source ${source}`,
67
+ fix: (_c = requirementFix(item, team, source)) !== null && _c !== void 0 ? _c : `${cli()} teams mcp status ${team} ${item.key} --source ${source}`,
97
68
  });
98
69
  }
99
70
  if (!agent.accessConfirmed) {
100
- const who = (_d = agent.runsAs) !== null && _d !== void 0 ? _d : 'the person it runs as';
101
71
  steps.push({
102
- problem: `${who} has not confirmed it may use their connections`,
103
- // Only that person can confirm, signed in as themselves.
104
- fix: `${who} runs: ${CLI} teams agents confirm ${team} ${entry.key} --source ${source} (or confirms in the app: Agents › ${entry.name} › Setup)`,
72
+ problem: 'nobody has confirmed what it may use',
73
+ // Whoever sets it up confirms, as themselves: the Source admin here,
74
+ // or a team manager in the app (plan 247.2).
75
+ fix: `${cli()} teams agents confirm ${team} ${entry.key} --source ${source} (or a team manager confirms in the app: Agents › ${entry.name} › Setup)`,
105
76
  });
106
77
  }
107
78
  if (!agent.triggers.some((trigger) => trigger.enabled)) {
108
79
  steps.push({
109
80
  problem: 'no trigger is on, so it only runs when started by hand',
110
- fix: `${CLI} teams triggers add ${team} ${entry.key} event <event-id> --source ${source} (event ids: ${CLI} catalog --source ${source})`,
81
+ fix: `${cli()} teams triggers add ${team} ${entry.key} event <event-id> --source ${source} (event ids: ${cli()} catalog --source ${source})`,
111
82
  });
112
83
  }
113
- for (const channel of (_e = agent.channels) !== null && _e !== void 0 ? _e : []) {
84
+ for (const channel of (_d = agent.channels) !== null && _d !== void 0 ? _d : []) {
114
85
  if (channel.ready)
115
86
  continue;
116
87
  steps.push({
117
- problem: (_f = channel.problem) !== null && _f !== void 0 ? _f : `${channel.name} not ready`,
88
+ problem: (_e = channel.problem) !== null && _e !== void 0 ? _e : `${channel.name} not ready`,
118
89
  fix: channelFix(channel, team, source),
119
90
  });
120
91
  }
@@ -133,38 +104,50 @@ export function requirementFix(item, team, source) {
133
104
  return null;
134
105
  switch (item.reason) {
135
106
  case 'no_route':
136
- return `${CLI} routes set ${item.key} <value> ${team} --source ${source} (values: ${CLI} routes options ${item.key} --source ${source})`;
107
+ return `${cli()} routes set ${item.key} <value> ${team} --source ${source} (values: ${cli()} routes options ${item.key} --source ${source})`;
137
108
  case 'source_not_connected':
138
- return `${CLI} apps connect ${item.key} --source ${source}`;
109
+ return `${cli()} apps connect ${item.key} --source ${source}`;
139
110
  case 'source_not_entitled':
140
- return `a super-admin enables it for the Source (${CLI} sources products --source ${source})`;
111
+ return `a super-admin enables it for the Source (${cli()} sources products --source ${source})`;
141
112
  case 'source_unsupported':
142
- return `set connections.${item.key}.owner to "team" in agent.json, then ${CLI} agents apply`;
113
+ return `set connections.${item.key}.owner to "team" in agent.json, then ${cli()} agents apply`;
143
114
  default:
144
115
  if (item.connected)
145
116
  return null;
146
117
  // A per-person product is the runs-as person's connection, not the
147
118
  // caller's: connecting your own leaves the agent missing it.
148
119
  return item.via === 'person' && item.viaDetail
149
- ? `${CLI} teams connect ${team} ${item.key} --as ${item.viaDetail} --source ${source}`
150
- : `${CLI} teams connect ${team} ${item.key} --source ${source}`;
120
+ ? `${cli()} teams connect ${team} ${item.key} --as ${item.viaDetail} --source ${source}`
121
+ : `${cli()} teams connect ${team} ${item.key} --source ${source}`;
151
122
  }
152
123
  }
153
- /** The one command that makes a channel ready, or the app step. */
124
+ /**
125
+ * The one command that makes a channel ready. An older host sends no
126
+ * `arrival`: the channel's key (`<product>:webhook`, `<product>:route`,
127
+ * `<product>:<connection>`) still says which command it is.
128
+ */
154
129
  export function channelFix(channel, team, source) {
155
- switch (channel.arrival) {
130
+ var _a, _b;
131
+ const suffix = channel.key.includes(':') ? channel.key.split(':')[1] : null;
132
+ const arrival = (_a = channel.arrival) !== null && _a !== void 0 ? _a : (suffix === 'webhook'
133
+ ? 'team-webhook'
134
+ : suffix === 'route'
135
+ ? 'source-route'
136
+ : 'install');
137
+ switch (arrival) {
156
138
  case 'team-webhook':
157
- return `${CLI} teams webhook ${team} ${channel.product} --source ${source}`;
139
+ return `${cli()} teams webhook ${team} ${channel.product} --source ${source}`;
158
140
  case 'source-route':
159
141
  return channel.webhook
160
- ? `${CLI} routes set ${channel.product} <value> ${team} --source ${source} (values: ${CLI} routes options ${channel.product} --source ${source})`
161
- : `${CLI} routes webhook ${channel.product} --source ${source}`;
162
- default:
163
- return channel.connectionId
164
- ? `${CLI} teams connect ${team} ${channel.product} --connection ${channel.connectionId} --source ${source}`
165
- : channel.key === 'slack' || channel.key === 'linear-app'
166
- ? `${CLI} teams connect ${team} ${channel.key} --source ${source}`
167
- : `install it on the agent's Triggers tab in the app`;
142
+ ? `${cli()} routes set ${channel.product} <value> ${team} --source ${source} (values: ${cli()} routes options ${channel.product} --source ${source})`
143
+ : `${cli()} routes webhook ${channel.product} --source ${source}`;
144
+ default: {
145
+ if (channel.key === 'slack' || channel.key === 'linear-app') {
146
+ return `${cli()} teams connect ${team} ${channel.key} --source ${source}`;
147
+ }
148
+ const connection = (_b = channel.connectionId) !== null && _b !== void 0 ? _b : suffix;
149
+ return `${cli()} teams connect ${team} ${channel.product}${connection ? ` --connection ${connection}` : ''} --source ${source}`;
150
+ }
168
151
  }
169
152
  }
170
153
  /** How the events of a ready channel reach the agent. */
@@ -178,23 +161,16 @@ export function reachedVia(channel) {
178
161
  return `${channel.name} installed`;
179
162
  }
180
163
  }
181
- /** A fix as a line: a command is run in the terminal, an app step is not. */
164
+ /** A fix as a line: a command is run in the terminal; anything else is a person's step. */
182
165
  export function fixLine(fix) {
183
- return fix.startsWith(CLI) ? `in your terminal: ${fix}` : fix;
166
+ return fix.startsWith(cli()) ? `in your terminal: ${fix}` : fix;
184
167
  }
185
- /**
186
- * "Live: yes" or "Live: no — N steps left", and an update waiting for
187
- * confirmation: "Live: yes (on v4; v5 waiting for confirmation)".
188
- */
189
- export function liveLine(readiness, agent) {
190
- var _a;
168
+ /** "Live: yes" or "Live: no — N steps left". */
169
+ export function liveLine(readiness) {
191
170
  const left = readiness.steps.length;
192
- const held = (agent === null || agent === void 0 ? void 0 : agent.held)
193
- ? ` (on v${(_a = agent.version) !== null && _a !== void 0 ? _a : '?'}; v${agent.held.waiting} waiting for confirmation)`
194
- : '';
195
171
  return readiness.live
196
- ? `Live: yes${held}`
197
- : `Live: no — ${left} step${left === 1 ? '' : 's'} left${held}`;
172
+ ? 'Live: yes'
173
+ : `Live: no — ${left} step${left === 1 ? '' : 's'} left`;
198
174
  }
199
175
  /**
200
176
  * One line per product, per trigger, then Live and Next. A product the
@@ -202,7 +178,7 @@ export function liveLine(readiness, agent) {
202
178
  * the team cannot see it there (`scope`, the team's scopes).
203
179
  */
204
180
  export function describeAgentReadiness(entry, target, readiness, activity, scope) {
205
- var _a, _b, _c, _d, _e;
181
+ var _a, _b, _c, _d;
206
182
  const agent = entry.agent;
207
183
  if (!agent) {
208
184
  return [
@@ -215,11 +191,9 @@ export function describeAgentReadiness(entry, target, readiness, activity, scope
215
191
  `${entry.key} on ${target.team}`,
216
192
  agent.draft
217
193
  ? `draft v${(_b = agent.version) !== null && _b !== void 0 ? _b : '?'} (testing, unpublished)`
218
- : agent.held
219
- ? `held on v${(_c = agent.version) !== null && _c !== void 0 ? _c : '?'}, v${agent.held.waiting} waiting for confirmation`
220
- : `v${(_d = agent.version) !== null && _d !== void 0 ? _d : '?'} (${agent.pinned ? 'pinned' : 'following'})`,
194
+ : `v${(_c = agent.version) !== null && _c !== void 0 ? _c : '?'} (${agent.pinned ? 'pinned' : 'following'})`,
221
195
  ...(agent.status === 'active' ? [] : [agent.status]),
222
- `runs as ${(_e = agent.runsAs) !== null && _e !== void 0 ? _e : 'nobody'}`,
196
+ `runs as ${(_d = agent.runsAs) !== null && _d !== void 0 ? _d : 'nobody'}`,
223
197
  agent.accessConfirmed ? '✓ access confirmed' : '✗ access not confirmed',
224
198
  ].join(' · ');
225
199
  const width = Math.max(8, ...agent.requirements.map((item) => item.key.length));
@@ -229,7 +203,7 @@ export function describeAgentReadiness(entry, target, readiness, activity, scope
229
203
  var _a;
230
204
  const fix = item.connected
231
205
  ? null
232
- : ((_a = requirementFix(item, target.team, target.source)) !== null && _a !== void 0 ? _a : `${CLI} teams mcp status ${target.team} ${item.key} --source ${target.source}`);
206
+ : ((_a = requirementFix(item, target.team, target.source)) !== null && _a !== void 0 ? _a : `${cli()} teams mcp status ${target.team} ${item.key} --source ${target.source}`);
233
207
  const hidden = item.hiddenByScope && scope
234
208
  ? [
235
209
  `${indent}! ${scopeHiddenWords(scope)}`,
@@ -292,18 +266,11 @@ export function describeAgentReadiness(entry, target, readiness, activity, scope
292
266
  : []),
293
267
  ];
294
268
  });
295
- const update = readiness.pending
296
- ? [
297
- ` ${pad('update')} ${readiness.pending.problem}`,
298
- `${indent}→ ${readiness.pending.fix}`,
299
- ]
300
- : [];
301
269
  return [
302
270
  head,
303
271
  ...products,
304
272
  ...(agent.triggers.length > 0 ? triggers : [` ${pad('triggers')} none`]),
305
- ...update,
306
- ` ${liveLine(readiness, agent)}`,
273
+ ` ${liveLine(readiness)}`,
307
274
  ...(readiness.next ? [` Next: ${readiness.next}`] : []),
308
275
  ].join('\n');
309
276
  }
@@ -1 +1 @@
1
- {"version":3,"file":"team-agent-readiness.js","sourceRoot":"","sources":["../../src/commands/team-agent-readiness.ts"],"names":[],"mappings":"AASA,OAAO,EAAmB,QAAQ,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAE7E;;;;;;;;;;;;;;GAcG;AAEH,MAAM,GAAG,GAAG,iBAAiB,CAAC;AA0B9B,MAAM,UAAU,cAAc,CAC5B,KAAqB,EACrB,MAAuB;;;IAEvB,MAAM,KAAK,GAAG,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC7C,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,MAAM,KAAK,CAAC;QACxB,KAAK;QACL,OAAO;QACP,IAAI,cAAE,MAAA,KAAK,CAAC,CAAC,CAAC,0CAAE,GAAG,mCAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,GAAG,mCAAI,IAAI;KAC5C,CAAC;AACJ,CAAC;AAED,8DAA8D;AAC9D,SAAS,aAAa,CACpB,KAAqB,EACrB,EAAE,IAAI,EAAE,MAAM,EAAmB;;IAEjC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IAC1B,IAAI,EAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,CAAA;QAAE,OAAO,IAAI,CAAC;IAC9B,MAAM,GAAG,SAAG,KAAK,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,CAAC,CAAC,uBAAuB;QACzB,CAAC,CAAC,IAAI,CAAC,GAAG,KAAK,QAAQ;YACrB,CAAC,CAAC,OAAO,MAAA,IAAI,CAAC,SAAS,mCAAI,oBAAoB,wBAAwB;YACvE,CAAC,CAAC,IAAI,CAAC,GAAG,KAAK,MAAM;gBACnB,CAAC,CAAC,qBAAqB;gBACvB,CAAC,CAAC,IAAI,CAAC;IACf,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;QACnB,MAAM,MAAM,GACV,IAAI,CAAC,GAAG,KAAK,QAAQ,IAAI,IAAI,CAAC,SAAS;YACrC,CAAC,CAAC,cAAc,IAAI,CAAC,SAAS,EAAE;YAChC,CAAC,CAAC,EAAE,CAAC;QACT,MAAM,QAAQ,GACZ,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,KAAK,eAAe;YAC5C,CAAC,CAAC,KAAK,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 { type ScopeFacts, scopeFix, scopeHiddenWords } from './scope-notice';\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 the person it runs as, at least one trigger on, and\n * every trigger's events able to reach it. Each gap is a step with one fix,\n * in the order they have to be done; the first step's fix is \"Next\".\n *\n * An agent HELD on an earlier version (a newer one reaches further than the\n * person it runs as confirmed) is still live — it runs the version it is on\n * — so the hold is not a step: it is `pending`, said beside \"Live\", and its\n * confirm command is \"Next\" once nothing else is.\n */\n\nconst CLI = 'npx @ekanos/cli';\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 /**\n * An update waiting for the runs-as person's confirmation; the agent runs\n * its current version meanwhile. Null when none.\n */\n pending: ReadinessStep | null;\n /** The first step's fix, else the pending update's; null when neither. */\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 const pending = pendingUpdate(entry, target);\n return {\n live: steps.length === 0,\n steps,\n pending,\n next: steps[0]?.fix ?? pending?.fix ?? null,\n };\n}\n\n/** The update a held agent waits for, and who confirms it. */\nfunction pendingUpdate(\n entry: TeamAgentEntry,\n { team, source }: ReadinessTarget,\n): ReadinessStep | null {\n const agent = entry.agent;\n if (!agent?.held) return null;\n const who = agent.runsAs ?? 'the person it runs as';\n return {\n problem: `held on v${agent.version ?? '?'}: v${agent.held.waiting} ${describeHold(agent.held)}, and waits for ${who} to confirm`,\n // Only that person can confirm, signed in as themselves.\n fix: `${who} runs: ${CLI} teams agents confirm ${team} ${entry.key} --source ${source} (or confirms in the app: Agents › ${entry.name} › Setup)`,\n };\n}\n\n/**\n * What a waiting version adds over the one running, in words:\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 const who = agent.runsAs ?? 'the person it runs as';\n steps.push({\n problem: `${who} has not confirmed it may use their connections`,\n // Only that person can confirm, signed in as themselves.\n fix: `${who} runs: ${CLI} teams agents confirm ${team} ${entry.key} --source ${source} (or 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 `a super-admin enables it for the Source (${CLI} sources products --source ${source})`;\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/** The one command that makes a channel ready, or the app step. */\nexport function channelFix(\n channel: ChannelRequirement,\n team: string,\n source: string,\n): string {\n switch (channel.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 return channel.connectionId\n ? `${CLI} teams connect ${team} ${channel.product} --connection ${channel.connectionId} --source ${source}`\n : channel.key === 'slack' || channel.key === 'linear-app'\n ? `${CLI} teams connect ${team} ${channel.key} --source ${source}`\n : `install it on the agent's Triggers tab in the app`;\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, an app step is not. */\nexport function fixLine(fix: string): string {\n return fix.startsWith(CLI) ? `in your terminal: ${fix}` : fix;\n}\n\n/**\n * \"Live: yes\" or \"Live: no — N steps left\", and an update waiting for\n * confirmation: \"Live: yes (on v4; v5 waiting for confirmation)\".\n */\nexport function liveLine(\n readiness: AgentReadiness,\n agent?: { version: number | null; held?: TeamAgentHold | null } | null,\n): string {\n const left = readiness.steps.length;\n const held = agent?.held\n ? ` (on v${agent.version ?? '?'}; v${agent.held.waiting} waiting for confirmation)`\n : '';\n return readiness.live\n ? `Live: yes${held}`\n : `Live: no — ${left} step${left === 1 ? '' : 's'} left${held}`;\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 : agent.held\n ? `held on v${agent.version ?? '?'}, v${agent.held.waiting} waiting for confirmation`\n : `v${agent.version ?? '?'} (${agent.pinned ? 'pinned' : 'following'})`,\n ...(agent.status === 'active' ? [] : [agent.status]),\n `runs as ${agent.runsAs ?? 'nobody'}`,\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 const update = readiness.pending\n ? [\n ` ${pad('update')} ${readiness.pending.problem}`,\n `${indent}→ ${readiness.pending.fix}`,\n ]\n : [];\n\n return [\n head,\n ...products,\n ...(agent.triggers.length > 0 ? triggers : [` ${pad('triggers')} none`]),\n ...update,\n ` ${liveLine(readiness, agent)}`,\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;AAkC7E,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,CAAC;QACtE,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK;KACnB,CAAC;IACF,MAAM,OAAO,GAAG;QACd,GAAG,CAAC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irement,\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';\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 `a super-admin enables it for the Source (${cli()} sources products --source ${source})`;\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 `runs as ${agent.runsAs ?? 'nobody'}`,\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"]}
@@ -3,13 +3,16 @@ import type { CliContext } from '../context.js';
3
3
  import type { ExitCode } from '../exit-codes.js';
4
4
  import { type TeamAgentRun } from './team-agents.js';
5
5
  /**
6
- * `ekanos teams agents list|show|enable|confirm|disable|pin|unpin|policy|skills` —
6
+ * `ekanos teams agents list|show|create|apply|enable|confirm|disable|archive|unarchive|pin|unpin|policy|skills|tags` —
7
7
  * a team's provided agents, turned on, versioned, given an approval policy
8
- * and skills by the Source admin. `enable|pin … --draft` puts one team on
8
+ * and skills by the Source admin; and the team's own and personal agents,
9
+ * made and changed from an agent.json with `create|apply`
10
+ * (team-agents-define.ts), turned on with `enable`. A personal agent is
11
+ * listed and shown to everyone, and changed by its creator alone. `enable|pin … --draft` puts one team on
9
12
  * the template's latest, unpublished version to test it there before
10
- * publishing. `confirm` (and `--confirm-access`) is the one thing only the
11
- * person the agent runs as can do: consent, as themselves, that it may use
12
- * their connections in runs no one watches.
13
+ * publishing. `confirm` (and `--confirm-access`) records the caller's own
14
+ * confirmation that it may use its connections in runs no one watches:
15
+ * whoever sets an agent up confirms it (plan 247.2), never a member.
13
16
  * `show` answers "is this agent live, and if not, why?" for one agent; `list`
14
17
  * ends each agent with the same verdict.
15
18
  */