@ekanos/cli 0.15.0 → 0.17.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 (287) hide show
  1. package/README.md +103 -8
  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/add.d.ts +2 -0
  6. package/dist/commands/add.js +118 -0
  7. package/dist/commands/add.js.map +1 -0
  8. package/dist/commands/agents.js +3 -2
  9. package/dist/commands/agents.js.map +1 -1
  10. package/dist/commands/apps.d.ts +11 -3
  11. package/dist/commands/apps.js +86 -28
  12. package/dist/commands/apps.js.map +1 -1
  13. package/dist/commands/audiences.d.ts +31 -0
  14. package/dist/commands/audiences.js +239 -0
  15. package/dist/commands/audiences.js.map +1 -0
  16. package/dist/commands/build.d.ts +2 -0
  17. package/dist/commands/build.js +41 -0
  18. package/dist/commands/build.js.map +1 -0
  19. package/dist/commands/catalog.d.ts +4 -2
  20. package/dist/commands/catalog.js +166 -35
  21. package/dist/commands/catalog.js.map +1 -1
  22. package/dist/commands/check.d.ts +2 -0
  23. package/dist/commands/check.js +43 -0
  24. package/dist/commands/check.js.map +1 -0
  25. package/dist/commands/codegen.d.ts +2 -0
  26. package/dist/commands/codegen.js +49 -0
  27. package/dist/commands/codegen.js.map +1 -0
  28. package/dist/commands/contract.d.ts +52 -0
  29. package/dist/commands/contract.js +300 -0
  30. package/dist/commands/contract.js.map +1 -0
  31. package/dist/commands/dev.d.ts +7 -0
  32. package/dist/commands/dev.js +186 -12
  33. package/dist/commands/dev.js.map +1 -1
  34. package/dist/commands/index-experience.d.ts +31 -0
  35. package/dist/commands/index-experience.js +21 -0
  36. package/dist/commands/index-experience.js.map +1 -0
  37. package/dist/commands/init.d.ts +7 -0
  38. package/dist/commands/init.js +12 -0
  39. package/dist/commands/init.js.map +1 -1
  40. package/dist/commands/login.d.ts +2 -0
  41. package/dist/commands/login.js +17 -0
  42. package/dist/commands/login.js.map +1 -1
  43. package/dist/commands/new.d.ts +2 -0
  44. package/dist/commands/new.js +39 -0
  45. package/dist/commands/new.js.map +1 -0
  46. package/dist/commands/publish.d.ts +59 -0
  47. package/dist/commands/publish.js +118 -65
  48. package/dist/commands/publish.js.map +1 -1
  49. package/dist/commands/runs.d.ts +7 -3
  50. package/dist/commands/runs.js +21 -5
  51. package/dist/commands/runs.js.map +1 -1
  52. package/dist/commands/scope-notice.d.ts +13 -0
  53. package/dist/commands/scope-notice.js +12 -4
  54. package/dist/commands/scope-notice.js.map +1 -1
  55. package/dist/commands/sources-roles.d.ts +5 -0
  56. package/dist/commands/sources-roles.js +235 -0
  57. package/dist/commands/sources-roles.js.map +1 -0
  58. package/dist/commands/sources.d.ts +5 -0
  59. package/dist/commands/sources.js +8 -1
  60. package/dist/commands/sources.js.map +1 -1
  61. package/dist/commands/sync.d.ts +2 -0
  62. package/dist/commands/sync.js +150 -0
  63. package/dist/commands/sync.js.map +1 -0
  64. package/dist/commands/team-agent-readiness.d.ts +18 -2
  65. package/dist/commands/team-agent-readiness.js +39 -39
  66. package/dist/commands/team-agent-readiness.js.map +1 -1
  67. package/dist/commands/team-agents-agents.d.ts +5 -2
  68. package/dist/commands/team-agents-agents.js +152 -15
  69. package/dist/commands/team-agents-agents.js.map +1 -1
  70. package/dist/commands/team-agents-define.d.ts +31 -0
  71. package/dist/commands/team-agents-define.js +176 -0
  72. package/dist/commands/team-agents-define.js.map +1 -0
  73. package/dist/commands/team-agents-mcp.js +112 -10
  74. package/dist/commands/team-agents-mcp.js.map +1 -1
  75. package/dist/commands/team-agents-triggers.d.ts +1 -1
  76. package/dist/commands/team-agents-triggers.js +137 -5
  77. package/dist/commands/team-agents-triggers.js.map +1 -1
  78. package/dist/commands/team-agents.d.ts +4 -1
  79. package/dist/commands/team-agents.js +17 -4
  80. package/dist/commands/team-agents.js.map +1 -1
  81. package/dist/commands/team-llm-key.d.ts +14 -0
  82. package/dist/commands/team-llm-key.js +122 -0
  83. package/dist/commands/team-llm-key.js.map +1 -0
  84. package/dist/commands/teams-audience.d.ts +12 -0
  85. package/dist/commands/teams-audience.js +144 -0
  86. package/dist/commands/teams-audience.js.map +1 -0
  87. package/dist/commands/teams-connect.js +123 -31
  88. package/dist/commands/teams-connect.js.map +1 -1
  89. package/dist/commands/teams-lifecycle.d.ts +90 -0
  90. package/dist/commands/teams-lifecycle.js +457 -0
  91. package/dist/commands/teams-lifecycle.js.map +1 -0
  92. package/dist/commands/teams-onboard.d.ts +14 -0
  93. package/dist/commands/teams-onboard.js +62 -13
  94. package/dist/commands/teams-onboard.js.map +1 -1
  95. package/dist/commands/teams-overview.js +6 -2
  96. package/dist/commands/teams-overview.js.map +1 -1
  97. package/dist/commands/teams-scope.js +4 -0
  98. package/dist/commands/teams-scope.js.map +1 -1
  99. package/dist/commands/teams.d.ts +25 -5
  100. package/dist/commands/teams.js +106 -39
  101. package/dist/commands/teams.js.map +1 -1
  102. package/dist/commands/workflows.d.ts +37 -0
  103. package/dist/commands/workflows.js +589 -0
  104. package/dist/commands/workflows.js.map +1 -0
  105. package/dist/compatibility.d.ts +10 -1
  106. package/dist/compatibility.js +10 -1
  107. package/dist/compatibility.js.map +1 -1
  108. package/dist/connect-fields.d.ts +22 -0
  109. package/dist/connect-fields.js +115 -0
  110. package/dist/connect-fields.js.map +1 -0
  111. package/dist/context.d.ts +12 -0
  112. package/dist/context.js +32 -9
  113. package/dist/context.js.map +1 -1
  114. package/dist/dev-experience.d.ts +125 -0
  115. package/dist/dev-experience.js +128 -0
  116. package/dist/dev-experience.js.map +1 -0
  117. package/dist/experience/boundary.d.ts +12 -0
  118. package/dist/experience/boundary.js +260 -0
  119. package/dist/experience/boundary.js.map +1 -0
  120. package/dist/experience/build.d.ts +16 -0
  121. package/dist/experience/build.js +90 -0
  122. package/dist/experience/build.js.map +1 -0
  123. package/dist/experience/checks.d.ts +29 -0
  124. package/dist/experience/checks.js +133 -0
  125. package/dist/experience/checks.js.map +1 -0
  126. package/dist/experience/contract-sources.d.ts +36 -0
  127. package/dist/experience/contract-sources.js +111 -0
  128. package/dist/experience/contract-sources.js.map +1 -0
  129. package/dist/experience/definition-checks.d.ts +26 -0
  130. package/dist/experience/definition-checks.js +201 -0
  131. package/dist/experience/definition-checks.js.map +1 -0
  132. package/dist/experience/definition-shape.d.ts +60 -0
  133. package/dist/experience/definition-shape.js +2 -0
  134. package/dist/experience/definition-shape.js.map +1 -0
  135. package/dist/experience/init.d.ts +10 -0
  136. package/dist/experience/init.js +64 -0
  137. package/dist/experience/init.js.map +1 -0
  138. package/dist/experience/integrations-codegen.d.ts +17 -0
  139. package/dist/experience/integrations-codegen.js +51 -0
  140. package/dist/experience/integrations-codegen.js.map +1 -0
  141. package/dist/experience/json-schema-to-ts.d.ts +1 -0
  142. package/dist/experience/json-schema-to-ts.js +90 -0
  143. package/dist/experience/json-schema-to-ts.js.map +1 -0
  144. package/dist/experience/load-experience.d.ts +23 -0
  145. package/dist/experience/load-experience.js +115 -0
  146. package/dist/experience/load-experience.js.map +1 -0
  147. package/dist/experience/overrides.d.ts +8 -0
  148. package/dist/experience/overrides.js +21 -0
  149. package/dist/experience/overrides.js.map +1 -0
  150. package/dist/experience/pin-integration.d.ts +8 -0
  151. package/dist/experience/pin-integration.js +17 -0
  152. package/dist/experience/pin-integration.js.map +1 -0
  153. package/dist/experience/pin-ops.d.ts +12 -0
  154. package/dist/experience/pin-ops.js +36 -0
  155. package/dist/experience/pin-ops.js.map +1 -0
  156. package/dist/experience/pins.d.ts +35 -0
  157. package/dist/experience/pins.js +91 -0
  158. package/dist/experience/pins.js.map +1 -0
  159. package/dist/experience/project.d.ts +52 -0
  160. package/dist/experience/project.js +149 -0
  161. package/dist/experience/project.js.map +1 -0
  162. package/dist/experience/publish.d.ts +51 -0
  163. package/dist/experience/publish.js +144 -0
  164. package/dist/experience/publish.js.map +1 -0
  165. package/dist/experience/regenerate.d.ts +10 -0
  166. package/dist/experience/regenerate.js +33 -0
  167. package/dist/experience/regenerate.js.map +1 -0
  168. package/dist/experience/report.d.ts +9 -0
  169. package/dist/experience/report.js +23 -0
  170. package/dist/experience/report.js.map +1 -0
  171. package/dist/harness-scaffold.d.ts +52 -18
  172. package/dist/harness-scaffold.js +189 -9
  173. package/dist/harness-scaffold.js.map +1 -1
  174. package/dist/index.d.ts +13 -0
  175. package/dist/index.js +494 -127
  176. package/dist/index.js.map +1 -1
  177. package/dist/invocation.d.ts +31 -0
  178. package/dist/invocation.js +58 -0
  179. package/dist/invocation.js.map +1 -0
  180. package/dist/project-checks.d.ts +12 -0
  181. package/dist/project-checks.js +46 -0
  182. package/dist/project-checks.js.map +1 -1
  183. package/dist/project.d.ts +14 -0
  184. package/dist/project.js +10 -0
  185. package/dist/project.js.map +1 -1
  186. package/dist/repo/publish.d.ts +42 -0
  187. package/dist/repo/publish.js +225 -0
  188. package/dist/repo/publish.js.map +1 -0
  189. package/dist/repo/scaffold.d.ts +30 -0
  190. package/dist/repo/scaffold.js +165 -0
  191. package/dist/repo/scaffold.js.map +1 -0
  192. package/dist/runs-api.js +8 -3
  193. package/dist/runs-api.js.map +1 -1
  194. package/dist/safe-fs.d.ts +18 -0
  195. package/dist/safe-fs.js +57 -0
  196. package/dist/safe-fs.js.map +1 -1
  197. package/dist/secret-form.d.ts +48 -0
  198. package/dist/secret-form.js +212 -0
  199. package/dist/secret-form.js.map +1 -0
  200. package/dist/secret-input.d.ts +96 -0
  201. package/dist/secret-input.js +299 -0
  202. package/dist/secret-input.js.map +1 -0
  203. package/dist/team-connect-api.d.ts +78 -3
  204. package/dist/team-connect-api.js +17 -2
  205. package/dist/team-connect-api.js.map +1 -1
  206. package/dist/team-lifecycle-api.d.ts +435 -0
  207. package/dist/team-lifecycle-api.js +301 -0
  208. package/dist/team-lifecycle-api.js.map +1 -0
  209. package/dist/teams-api.d.ts +49 -1
  210. package/dist/teams-api.js +149 -27
  211. package/dist/teams-api.js.map +1 -1
  212. package/dist/unknown-command.d.ts +18 -0
  213. package/dist/unknown-command.js +50 -0
  214. package/dist/unknown-command.js.map +1 -0
  215. package/dist/validate-findings.js +2 -1
  216. package/dist/validate-findings.js.map +1 -1
  217. package/dist/workflows-api.d.ts +69 -0
  218. package/dist/workflows-api.js +182 -0
  219. package/dist/workflows-api.js.map +1 -0
  220. package/package.json +3 -3
  221. package/templates/AGENTS.md.tmpl +6 -4
  222. package/templates/claude-skill.md.tmpl +4 -1
  223. package/templates/ekanos.json.tmpl +1 -0
  224. package/templates/experience/AGENTS.md.tmpl +22 -0
  225. package/templates/experience/ekanos.json.tmpl +7 -0
  226. package/templates/experience/ekanos.lock.json.tmpl +4 -0
  227. package/templates/experience/eslint.config.mjs.tmpl +25 -0
  228. package/templates/experience/gitignore.tmpl +17 -0
  229. package/templates/experience/package.json.tmpl +41 -0
  230. package/templates/experience/src/.ekanos/integrations.d.ts.tmpl +3 -0
  231. package/templates/experience/src/experience.ts.tmpl +30 -0
  232. package/templates/experience/src/widgets/hello-widget.tsx.tmpl +40 -0
  233. package/templates/experience/tsconfig.json.tmpl +20 -0
  234. package/templates/harness/app/%5F%5Fekanos/api/[...path]/route.ts.tmpl +9 -0
  235. package/templates/harness/app/[slug]/activation/page.tsx.tmpl +1 -1
  236. package/templates/harness/app/[slug]/page.tsx.tmpl +1 -1
  237. package/templates/harness/app/[slug]/tile/page.tsx.tmpl +1 -1
  238. package/templates/harness/app/[slug]/triggers/page.tsx.tmpl +1 -1
  239. package/templates/harness/app/[slug]/widgets/[widgetId]/page.tsx.tmpl +1 -1
  240. package/templates/harness/app/[slug]/widgets/page.tsx.tmpl +1 -1
  241. package/templates/harness/app/experience/layout.tsx.tmpl +17 -0
  242. package/templates/harness/app/experience/page.tsx.tmpl +1 -0
  243. package/templates/harness/app/experience/pages/[id]/page.tsx.tmpl +1 -0
  244. package/templates/harness/app/experience/review-queue/page.tsx.tmpl +1 -0
  245. package/templates/harness/app/experience/runs/page.tsx.tmpl +1 -0
  246. package/templates/harness/app/experience/widgets/[id]/page.tsx.tmpl +1 -0
  247. package/templates/harness/app/experience/widgets/page.tsx.tmpl +1 -0
  248. package/templates/harness/app/experience/workflows/[id]/page.tsx.tmpl +1 -0
  249. package/templates/harness/app/experience/workflows/page.tsx.tmpl +1 -0
  250. package/templates/harness/app/integrations/[slug]/connect/page.tsx.tmpl +1 -0
  251. package/templates/harness/app/integrations/[slug]/events/page.tsx.tmpl +1 -0
  252. package/templates/harness/app/integrations/[slug]/health/page.tsx.tmpl +1 -0
  253. package/templates/harness/app/integrations/[slug]/operations/[kind]/[name]/page.tsx.tmpl +1 -0
  254. package/templates/harness/app/integrations/[slug]/operations/page.tsx.tmpl +1 -0
  255. package/templates/harness/app/integrations/[slug]/page.tsx.tmpl +1 -0
  256. package/templates/harness/app/integrations/[slug]/preview/activation/page.tsx.tmpl +1 -0
  257. package/templates/harness/app/integrations/[slug]/preview/layout.tsx.tmpl +1 -0
  258. package/templates/harness/app/integrations/[slug]/preview/page.tsx.tmpl +1 -0
  259. package/templates/harness/app/integrations/[slug]/preview/tile/page.tsx.tmpl +1 -0
  260. package/templates/harness/app/integrations/[slug]/preview/triggers/page.tsx.tmpl +1 -0
  261. package/templates/harness/app/integrations/[slug]/preview/widgets/[widgetId]/page.tsx.tmpl +1 -0
  262. package/templates/harness/app/integrations/[slug]/preview/widgets/page.tsx.tmpl +1 -0
  263. package/templates/harness/app/integrations/[slug]/runs/page.tsx.tmpl +1 -0
  264. package/templates/harness/app/integrations/layout.tsx.tmpl +1 -0
  265. package/templates/harness/app/integrations/page.tsx.tmpl +1 -0
  266. package/templates/harness/app/page.experience.tsx.tmpl +5 -0
  267. package/templates/harness/repo/app/%5F%5Fekanos/api/[...path]/route.ts.tmpl +11 -0
  268. package/templates/harness/repo/app/(repo)/connections/page.tsx.tmpl +1 -0
  269. package/templates/harness/repo/app/(repo)/layout.tsx.tmpl +1 -0
  270. package/templates/harness/repo/app/(repo)/page.tsx.tmpl +1 -0
  271. package/templates/harness/repo/app/experiences/[name]/connect/page.tsx.tmpl +1 -0
  272. package/templates/harness/repo/app/experiences/[name]/layout.tsx.tmpl +9 -0
  273. package/templates/harness/repo/app/experiences/page.tsx.tmpl +5 -0
  274. package/templates/harness/repo/app/harness-shell.tsx.tmpl +9 -0
  275. package/templates/harness/repo/app/integrations/[slug]/layout.tsx.tmpl +1 -0
  276. package/templates/harness/repo/app/integrations/page.tsx.tmpl +5 -0
  277. package/templates/harness/repo/app/repo-experiences.ts.tmpl +5 -0
  278. package/templates/harness/styles/globals.css.tmpl +15 -1
  279. package/templates/package.json.tmpl +4 -4
  280. package/templates/skills/build-agent/SKILL.md +43 -10
  281. package/templates/skills/build-agent/references/agent-json.md +4 -1
  282. package/templates/skills/build-agent/references/app-setup.md +14 -7
  283. package/templates/skills/build-agent/references/rollout.md +26 -2
  284. package/templates/skills/build-agent/references/set-up-an-integration.md +46 -29
  285. package/templates/skills/build-integration/references/widget-design.md +1 -1
  286. package/templates/skills/ekanos-platform/SKILL.md +66 -14
  287. package/templates/skills/polish-widgets/references/patterns.md +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"teams-connect.js","sourceRoot":"","sources":["../../src/commands/teams-connect.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,GAEpB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE3E,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAEL,eAAe,EACf,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAGL,SAAS,EACT,SAAS,EACT,oBAAoB,GACrB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,CAAC,CAAC,EAAE,EAAE,CAAC;AAC9G,CAAC","sourcesContent":["import {\n TeamAgentListSchema,\n type TeamIntegrationStatus,\n} from '@ekanos/integration-schema';\n\nimport type { CliContext } from '../context';\nimport { invalidStateError, usageError, validationError } from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { assertBrowserSafeUrl, openInBrowser } from '../open-url';\nimport {\n type TeamConnectPlan,\n showTeamConnect,\n startTeamConnect,\n} from '../team-connect-api';\nimport { call, showTeamIntegration } from '../teams-api';\nimport type { ResultRow } from '../ui';\nimport { promptHidden, promptLine } from './apps';\nimport { scopeHiddenLines } from './scope-notice';\nimport {\n type TeamsArgs,\n type TeamsClient,\n canPrompt,\n checklist,\n promptAndSaveTeamApp,\n} from './teams';\nimport { isTeamChannel, runTeamChannelInstall } from './teams-channel-install';\n\n/**\n * `teams connect <team> <product>` — connect a product for one team, doing\n * whichever the integration needs (the host's plan decides, never the CLI):\n *\n * - works as shipped → says so; not self-serve or not enabled → refuses\n * with the reason (and points at `sources products` for the latter);\n * - form fields → asks them here (secrets hidden, never as arguments) and\n * activates exactly as the app's form does;\n * - OAuth → runs `teams app set` inline when the team's own app is needed\n * first (Zendesk), then a one-time sign-in link for the member who\n * consents: the caller when a member, else `--as <email>`. Opens it for\n * the caller (unless `--no-open`), always prints it, and waits until the\n * team is connected (unless `--no-wait`);\n * - a form only the browser can fill → prints the team's page.\n *\n * `--connection <id>` connects one of the integration's named connections\n * instead of the main one — Linear's `agent`, the team's own Linear app\n * installed as a workspace member, which is what makes Linear send the\n * @mention and assignment webhooks an agent's triggers listen for. It runs\n * the same way: the team app's fields when missing, then the sign-in, then\n * the wait until it is installed.\n *\n * Without `--connection`, once the main connection is made (or already\n * was), a named connection the team's agents' triggers wait on is offered\n * next — at a terminal it asks and installs it, otherwise it names the\n * command. \"Connected\" is not the goal; an agent that can be reached is.\n *\n * `--reconnect` connects it again even though it reads as connected — for\n * a revoked or expired sign-in, or new form values. An OAuth reconnect\n * prints the link and returns: the team already reads as connected, so\n * there is nothing to wait for.\n *\n * `--link-only` keeps the old behaviour: the team's page and its status.\n *\n * `slack` and `linear-app` install the channels agent triggers answer\n * through — Slack, and Ekanos's own Linear Agents app — by the same\n * link-and-wait (`teams-channel-install.ts`).\n */\nexport async function runTeamConnect(\n ctx: CliContext,\n args: TeamsArgs,\n client: TeamsClient,\n host: string,\n source: string,\n input: { team: string; product: string; as?: string; connection?: string },\n): Promise<ExitCode> {\n const target = {\n source,\n team: input.team,\n product: input.product,\n ...(input.connection ? { connection: input.connection } : {}),\n };\n\n // Slack and Ekanos's Linear Agents app: the channels a `slack` or `linear`\n // agent trigger answers through, installed by their own flows.\n if (!input.connection && !args.linkOnly && isTeamChannel(input.product)) {\n return runTeamChannelInstall(ctx, args, client, host, source, {\n team: input.team,\n channel: input.product,\n ...(input.as ? { as: input.as } : {}),\n open: args.openUrl ?? openInBrowser,\n });\n }\n\n if (args.linkOnly) return printLink(ctx, client, host, target);\n\n const { plan } = await client.call((token) =>\n showTeamConnect(host, token, target, input.as),\n );\n const named = isNamed(plan);\n const name = named\n ? await connectionLabel(client, host, target, plan)\n : plan.product.name;\n await warnOtherRunsAs(ctx, client, host, source, plan);\n for (const line of scopeHiddenLines(plan.productScope, {\n team: plan.team.slug,\n product: plan.product.slug,\n source: plan.source.slug,\n })) {\n ctx.warn(line);\n }\n\n switch (plan.mode) {\n case 'not-entitled':\n throw invalidStateError(\n plan.reason ??\n `\"${input.product}\" is not enabled on ${plan.source.slug}.`,\n `Enable it for the Source first: \"ekanos sources products enable ${input.product}\" as a Source admin if ${plan.source.slug} built it, otherwise a super-admin (/admin in the browser). \"ekanos sources products\" shows what ${plan.source.slug} has.`,\n );\n case 'not-self-serve':\n throw invalidStateError(\n plan.reason ?? `${name} is not connected by a team.`,\n plan.product.kind === 'experience'\n ? `\"ekanos sources products --source ${plan.source.slug}\" shows whether it is on for the Source.`\n : 'It is turned on for the Source by Ekanos; there is nothing for the team to do.',\n );\n case 'unsupported':\n throw invalidStateError(\n plan.reason ?? `${name} cannot be connected from here.`,\n `Open the team's page instead: ${plan.connectUrl}`,\n );\n case 'works-as-shipped':\n return ctx.succeed(\n { host, plan, connected: true },\n ctx.ui.result({\n title: `${name} works as shipped for ${plan.team.slug}`,\n rows: [['Status', 'nothing to connect']],\n }),\n );\n case 'browser':\n return ctx.succeed(\n { host, plan, connected: plan.connected },\n ctx.ui.result({\n title: plan.connected\n ? `${plan.team.slug} has connected ${name}`\n : `${name} connects in the app for ${plan.team.slug}`,\n tone: plan.connected ? 'ok' : 'warn',\n rows: [\n ['Open', plan.connectUrl],\n ['Status', statusOf(plan)],\n ],\n notes: plan.connected\n ? []\n : [\n plan.reason ??\n `${name} connects through its own form in the app.`,\n 'A team admin signs in there and clicks Connect.',\n ],\n }),\n );\n default:\n break;\n }\n\n if (plan.connected && !args.reconnect) {\n const summary = ctx.ui.result({\n title: `${plan.team.slug} has already ${named ? 'installed' : 'connected'} ${name}`,\n rows: [\n ['Status', statusOf(plan, named)],\n ['Team page', plan.connectUrl],\n ],\n notes: [\n `\"ekanos teams show ${plan.team.slug} ${plan.product.slug}\" shows the full setup.`,\n `Broken (revoked or expired)? Connect it again: ekanos teams connect ${plan.team.slug} ${plan.product.slug}${named ? ` --connection ${plan.connectionId}` : ''} --reconnect`,\n ],\n });\n return named\n ? ctx.succeed({ host, plan, connected: true }, summary)\n : offerChannels(ctx, args, client, host, source, input, {\n data: { host, plan, connected: true },\n summary,\n });\n }\n\n if (plan.mode === 'fields' || plan.mode === 'no-fields') {\n return activate(ctx, args, client, host, target, plan);\n }\n return connectOAuth(ctx, args, client, host, target, plan, input.as, {\n name,\n then: named\n ? undefined\n : (done) => offerChannels(ctx, args, client, host, source, input, done),\n });\n}\n\n/**\n * A personal connection belongs to whoever makes it, but a provided agent\n * uses the personal connection of the person it runs as — so connecting\n * your own leaves the agent missing it (CLI audit P0-5). Name each agent\n * that runs as someone else and the command that connects it for them.\n */\nasync function warnOtherRunsAs(\n ctx: CliContext,\n client: TeamsClient,\n host: string,\n source: string,\n plan: TeamConnectPlan,\n): Promise<void> {\n const email = plan.member?.email?.toLowerCase();\n if (plan.scope !== 'user' || !email) return;\n let list;\n try {\n list = await client.call((token) =>\n call(host, token, TeamAgentListSchema, {\n method: 'GET',\n path: `/api/partner/teams/${encodeURIComponent(plan.team.slug)}/agents`,\n source,\n }),\n );\n } catch (error) {\n ctx.log(\n `Could not check who ${plan.team.slug}'s agents run as: ${error instanceof Error ? error.message : String(error)}`,\n );\n return;\n }\n for (const entry of list.agents) {\n const runsAs = entry.agent?.requirements.find(\n (item) =>\n item.key === plan.product.slug &&\n item.via === 'person' &&\n item.viaDetail &&\n item.viaDetail.toLowerCase() !== email,\n )?.viaDetail;\n if (!runsAs) continue;\n ctx.warn(\n `Note: ${entry.key} runs as ${runsAs} and uses ${runsAs}'s ${plan.product.name} connection, not ${email}'s. For the agent, run: npx @ekanos/cli teams connect ${plan.team.slug} ${plan.product.slug} --as ${runsAs} --source ${source}`,\n );\n }\n}\n\n/**\n * After the main connection: the named connections the team's agents'\n * triggers wait on and the team has not installed (Linear's agent). At a\n * terminal, ask and install each; otherwise name the command, in the\n * result and its JSON (`channelsToInstall`).\n */\nasync function offerChannels(\n ctx: CliContext,\n args: TeamsArgs,\n client: TeamsClient,\n host: string,\n source: string,\n input: { team: string; product: string; as?: string },\n done: { data: Record<string, unknown>; summary: string },\n): Promise<ExitCode> {\n const status = await client.call((token) =>\n showTeamIntegration(host, token, {\n source,\n team: input.team,\n product: input.product,\n }),\n );\n const waiting = channelsToInstall(status);\n if (waiting.length === 0) return ctx.succeed(done.data, done.summary);\n\n const command = (connectionId: string) =>\n `ekanos teams connect ${input.team} ${input.product} --connection ${connectionId} --source ${status.source.slug}`;\n const why = (entry: (typeof waiting)[number]) =>\n `${entry.label} is not installed for ${input.team}, and ${entry.neededBy.map((need) => `${need.agent} (${need.triggers.join(', ')})`).join(', ')} only start${entry.neededBy.length === 1 ? 's' : ''} through it.`;\n\n if (!canPrompt(ctx, args)) {\n return ctx.succeed(\n {\n ...done.data,\n channelsToInstall: waiting.map((entry) => ({\n connectionId: entry.connectionId,\n label: entry.label,\n neededBy: entry.neededBy,\n command: command(entry.connectionId),\n })),\n },\n [\n done.summary,\n ...waiting.flatMap((entry) => [\n `Next: ${why(entry)}`,\n ` Install it in your terminal: npx @ekanos/cli ${command(entry.connectionId)}`,\n ]),\n ].join('\\n'),\n );\n }\n\n ctx.log(done.summary);\n let code: ExitCode = 0;\n for (const entry of waiting) {\n ctx.log(why(entry));\n const answer = (\n await (args.ask ?? promptLine)(`Install ${entry.label} now? [Y/n] `)\n )\n .trim()\n .toLowerCase();\n if (answer !== '' && answer !== 'y' && answer !== 'yes') {\n ctx.log(`Skipped. Later: ${command(entry.connectionId)}`);\n continue;\n }\n code = await runTeamConnect(ctx, args, client, host, source, {\n ...input,\n connection: entry.connectionId,\n });\n }\n return code;\n}\n\n/** Named connections the team's agents wait on and the team has not installed. */\nexport function channelsToInstall(status: TeamIntegrationStatus) {\n return (status.connections ?? []).filter(\n (entry) =>\n entry.connectionId !== 'default' &&\n !entry.connected &&\n entry.neededBy.length > 0,\n );\n}\n\nfunction isNamed(plan: TeamConnectPlan): boolean {\n return Boolean(plan.connectionId && plan.connectionId !== 'default');\n}\n\nasync function connectionLabel(\n client: TeamsClient,\n host: string,\n target: { source: string; team: string; product: string },\n plan: TeamConnectPlan,\n): Promise<string> {\n const status = await client.call((token) =>\n showTeamIntegration(host, token, target),\n );\n return (\n status.connections?.find(\n (entry) => entry.connectionId === plan.connectionId,\n )?.label ??\n status.teamApps.find((entry) => entry.connectionId === plan.connectionId)\n ?.label ??\n `${plan.product.name} (${plan.connectionId})`\n );\n}\n\nasync function activate(\n ctx: CliContext,\n args: TeamsArgs,\n client: TeamsClient,\n host: string,\n target: { source: string; team: string; product: string },\n plan: TeamConnectPlan,\n): Promise<ExitCode> {\n if (plan.scope === 'user' && !plan.member) {\n throw invalidStateError(\n plan.memberProblem ??\n `${plan.product.name} is a personal connection: each member connects their own.`,\n `A member connects it for themselves on the team's page: ${plan.connectUrl}`,\n );\n }\n\n const fields: Record<string, string> = {};\n if (plan.mode === 'fields') {\n if (!canPrompt(ctx, args)) {\n throw usageError(\n `${plan.product.name} needs its fields typed at a terminal (${plan.fields.map((field) => field.label).join(', ')}), never in a script or an agent run.`,\n `Run it yourself in your terminal: npx @ekanos/cli teams connect ${target.team} ${target.product} --source ${plan.source.slug}`,\n );\n }\n ctx.log(\n `${plan.product.name} for ${plan.scope === 'user' ? 'you, in' : 'team'} ${plan.team.slug}: enter what the app's form asks. Secrets are hidden and never shown again.`,\n );\n for (const field of plan.fields) {\n if (field.description) ctx.log(` ${field.description}`);\n const suffix = `${field.required ? '' : ' (optional — Enter skips)'}${field.sensitive ? ' (hidden)' : ''}: `;\n const value = (\n await (\n field.sensitive\n ? (args.askSecret ?? promptHidden)\n : (args.ask ?? promptLine)\n )(`${field.label}${suffix}`)\n ).trim();\n if (value) fields[field.name] = value;\n else if (field.required) {\n throw validationError(\n `${field.label} is needed.`,\n `Run \"ekanos teams connect ${target.team} ${target.product}\" again.`,\n );\n }\n }\n }\n\n const started = await client.call((token) =>\n startTeamConnect(host, token, target, { fields }),\n );\n return ctx.succeed(\n { host, ...started, connected: started.plan.connected },\n ctx.ui.result({\n title: `Connected ${started.plan.product.name} for ${started.plan.team.slug}`,\n rows: [\n ['Status', statusOf(started.plan)],\n [\n 'For',\n started.plan.scope === 'user'\n ? `you (${started.plan.member?.email ?? 'your account'}) — a personal connection`\n : 'the whole team',\n ],\n ['Team page', started.plan.connectUrl],\n ],\n }),\n );\n}\n\nasync function connectOAuth(\n ctx: CliContext,\n args: TeamsArgs,\n client: TeamsClient,\n host: string,\n target: {\n source: string;\n team: string;\n product: string;\n connection?: string;\n },\n plan: TeamConnectPlan,\n asEmail: string | undefined,\n options: {\n /** What is being connected: the product, or a named connection's label. */\n name: string;\n /** On success, instead of finishing: the main connection's follow-ups. */\n then?: (done: {\n data: Record<string, unknown>;\n summary: string;\n }) => Promise<ExitCode>;\n },\n): Promise<ExitCode> {\n const named = isNamed(plan);\n const name = options.name;\n const again = `ekanos teams connect ${target.team} ${target.product}${named ? ` --connection ${plan.connectionId}` : ''}`;\n if (!plan.member) {\n throw invalidStateError(\n plan.memberProblem ?? 'No member of the team can sign in yet.',\n `Name a member of ${plan.team.slug} who signs in: ${again} --as <email>`,\n );\n }\n\n if (plan.teamApp) {\n const status = await client.call((token) =>\n showTeamIntegration(host, token, target),\n );\n const connectionId = plan.connectionId ?? 'default';\n const app =\n status.teamApps.find((entry) => entry.connectionId === connectionId) ??\n (named ? undefined : status.teamApps[0]);\n if (app && app.fields.some((field) => !field.set)) {\n if (!canPrompt(ctx, args)) {\n throw usageError(\n `${name} needs ${plan.team.slug}'s own app first, entered at a terminal.`,\n `Run it yourself in your terminal: npx @ekanos/cli ${again} --source ${plan.source.slug}`,\n );\n }\n ctx.log(\n `${name} signs ${plan.team.slug} in through the team's own app. Set it up first:`,\n );\n await promptAndSaveTeamApp(ctx, args, client, host, target, status, app);\n }\n }\n\n const started = await client.call((token) =>\n startTeamConnect(host, token, target, asEmail ? { as: asEmail } : {}),\n );\n if (started.result !== 'consent') {\n throw invalidStateError(\n `The host answered \"${started.result}\" where a sign-in link was expected.`,\n 'Run \"ekanos upgrade\" — the CLI and the host disagree on the connect contract.',\n );\n }\n assertBrowserSafeUrl(started.authorizeUrl, 'sign-in link');\n\n const member = started.plan.member ?? plan.member;\n const forCaller = member.isCaller;\n const expires = started.expiresAt.replace('T', ' ').slice(0, 16);\n ctx.log(\n forCaller\n ? [\n named\n ? `Install ${name} for ${plan.team.slug} — sign in as an admin of the workspace it goes into, and approve it:`\n : `Sign in to ${plan.product.name} as the account ${plan.team.slug} should use${plan.scope === 'user' ? ' (a personal connection: yours)' : ''}:`,\n ` ${started.authorizeUrl}`,\n ` (one-time link, valid until ${expires} UTC)`,\n ].join('\\n')\n : [\n `Send this link to ${member.email ?? 'the member'} — they ${named ? `install ${name}` : `sign in to ${plan.product.name}`} for ${plan.team.slug}${plan.scope === 'user' ? ' (a personal connection: theirs)' : ''}:`,\n ` ${started.authorizeUrl}`,\n ` (one-time, for them only, valid until ${expires} UTC)`,\n ].join('\\n'),\n );\n\n // Only ever the caller's own browser: opening a link meant for another\n // member would sign the caller's provider account in for them.\n if (forCaller && !args.noOpen && !ctx.jsonMode) {\n (args.openUrl ?? openInBrowser)(started.authorizeUrl);\n }\n\n // A reconnect can't be waited on: the team already reads as connected, so\n // nothing the host reports changes when the new sign-in lands.\n const reconnecting = args.reconnect === true && plan.connected;\n if (args.noWait || ctx.jsonMode || reconnecting) {\n return ctx.succeed(\n {\n host,\n plan: started.plan,\n authorizeUrl: started.authorizeUrl,\n expiresAt: started.expiresAt,\n connected: false,\n },\n ctx.ui.hint(\n reconnecting\n ? `The current connection keeps working until the sign-in finishes; then its tokens are replaced. Check with \"ekanos teams show ${target.team} ${target.product}\".`\n : `Then check with \"ekanos teams show ${target.team} ${target.product}\".`,\n ),\n );\n }\n\n ctx.log(\n 'Waiting for the sign-in to finish (Ctrl-C stops waiting; the link stays valid)…',\n );\n const deadline = Date.parse(started.expiresAt) || Date.now() + 10 * 60 * 1000;\n while (Date.now() < deadline) {\n await new Promise((resolve) =>\n setTimeout(resolve, args.pollDelayMs ?? 3000),\n );\n const polled = await client.call((token) =>\n showTeamConnect(host, token, target, asEmail),\n );\n if (polled.plan.connected) {\n const status = await client.call((token) =>\n showTeamIntegration(host, token, target),\n );\n const done = {\n data: { host, plan: polled.plan, status, connected: true },\n summary: [\n ctx.ui.result({\n title: `${named ? 'Installed' : 'Connected'} ${name} for ${plan.team.slug}`,\n rows: [\n ['Signed in by', member.email ?? member.userId],\n ['Status', statusOf(polled.plan, named)],\n ],\n notes: named\n ? [\n `Prove it end to end: @mention the agent in ${plan.product.name}, then \"ekanos runs list --team ${plan.team.slug}\" shows the run it started.`,\n ]\n : [],\n }),\n checklist(status).join('\\n'),\n ].join('\\n'),\n };\n return options.then\n ? options.then(done)\n : ctx.succeed(done.data, done.summary);\n }\n }\n throw validationError(\n 'The sign-in did not finish before the link expired.',\n `Run \"${again}${asEmail ? ` --as ${asEmail}` : ''}\" again for a fresh link.`,\n );\n}\n\n/** `--link-only`: the team's page and whether it is connected. */\nasync function printLink(\n ctx: CliContext,\n client: TeamsClient,\n host: string,\n target: { source: string; team: string; product: string },\n): Promise<ExitCode> {\n const status = await client.call((token) =>\n showTeamIntegration(host, token, target),\n );\n if (!status.enabled) {\n throw invalidStateError(\n `\"${target.product}\" is not enabled on ${status.source.slug}.`,\n `\"ekanos sources products --source ${status.source.slug}\" shows what this Source has; a super-admin enables a product for a Source.`,\n );\n }\n const connected = status.activation !== null;\n const rows: ResultRow[] = [\n ['Open', status.connectUrl],\n [\n 'Status',\n connected\n ? `connected${status.activation?.activatedAt ? ` ${status.activation.activatedAt.slice(0, 10)}` : ''}`\n : 'not connected',\n ],\n ];\n return ctx.succeed(\n { host, ...status },\n ctx.ui.result({\n title: connected\n ? `${status.team.slug} has connected ${status.product.name}`\n : `Connect link for ${status.team.slug} · ${status.product.name}`,\n tone: connected ? 'ok' : 'warn',\n rows,\n notes: [\n 'A team member signs in there and clicks Connect.',\n `\"ekanos teams connect ${status.team.slug} ${status.product.slug}\" (without --link-only) connects it from here.`,\n ],\n }),\n );\n}\n\nfunction statusOf(plan: TeamConnectPlan, named = false): string {\n if (!plan.connected) return named ? 'not installed' : 'not connected';\n return `${named ? 'installed' : 'connected'}${plan.connectedAt ? ` ${plan.connectedAt.slice(0, 10)}` : ''}`;\n}\n"]}
1
+ {"version":3,"file":"teams-connect.js","sourceRoot":"","sources":["../../src/commands/teams-connect.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,GAEpB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEjE,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,W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C,SAAS;QAAE,OAAO,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC;IACtE,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AAC9G,CAAC","sourcesContent":["import {\n TeamAgentListSchema,\n type TeamIntegrationStatus,\n} from '@ekanos/integration-schema';\n\nimport { fieldPrompt, parseFieldValue } from '../connect-fields';\nimport type { CliContext } from '../context';\nimport { invalidStateError, usageError, validationError } from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { cli } from '../invocation';\nimport { assertBrowserSafeUrl, openInBrowser } from '../open-url';\nimport {\n FIELD_SECRET_FORMS,\n collectSecrets,\n parsePlainValues,\n readSecretFlags,\n secretInputGiven,\n} from '../secret-input';\nimport {\n type FieldValue,\n type TeamConnectPlan,\n showTeamConnect,\n startTeamConnect,\n} from '../team-connect-api';\nimport { call, showTeamIntegration } from '../teams-api';\nimport type { ResultRow } from '../ui';\nimport { promptHidden, promptLine } from './apps';\nimport { scopeHiddenLines } from './scope-notice';\nimport {\n type TeamsArgs,\n type TeamsClient,\n canPrompt,\n checklist,\n promptAndSaveTeamApp,\n teamsSecretIO,\n} from './teams';\nimport { isTeamChannel, runTeamChannelInstall } from './teams-channel-install';\n\n/**\n * `teams connect <team> <product>` — connect a product for one team, doing\n * whichever the integration needs (the host's plan decides, never the CLI):\n *\n * - works as shipped → says so; not self-serve or not enabled → refuses\n * with the reason (and points at `sources products` for the latter);\n * - form fields → asks them here (secrets hidden, never as arguments) and\n * activates exactly as the app's form does;\n * - OAuth → runs `teams app set` inline when the team's own app is needed\n * first (Zendesk), then a one-time sign-in link for the member who\n * consents: the caller when a member, else `--as <email>`. Opens it for\n * the caller (unless `--no-open`), always prints it, and waits until the\n * team is connected (unless `--no-wait`);\n * - a form only the browser can fill → prints the team's page.\n *\n * `--connection <id>` connects one of the integration's named connections\n * instead of the main one — Linear's `agent`, the team's own Linear app\n * installed as a workspace member, which is what makes Linear send the\n * @mention and assignment webhooks an agent's triggers listen for. It runs\n * the same way: the team app's fields when missing, then the sign-in, then\n * the wait until it is installed.\n *\n * Without `--connection`, once the main connection is made (or already\n * was), a named connection the team's agents' triggers wait on is offered\n * next — at a terminal it asks and installs it, otherwise it names the\n * command. \"Connected\" is not the goal; an agent that can be reached is.\n *\n * `--reconnect` connects it again even though it reads as connected — for\n * a revoked or expired sign-in, or new form values. An OAuth reconnect\n * prints the link and returns: the team already reads as connected, so\n * there is nothing to wait for.\n *\n * `--link-only` keeps the old behaviour: the team's page and its status.\n *\n * `slack` and `linear-app` install the channels agent triggers answer\n * through — Slack, and Ekanos's own Linear Agents app — by the same\n * link-and-wait (`teams-channel-install.ts`).\n */\nexport async function runTeamConnect(\n ctx: CliContext,\n args: TeamsArgs,\n client: TeamsClient,\n host: string,\n source: string,\n input: { team: string; product: string; as?: string; connection?: string },\n): Promise<ExitCode> {\n const target = {\n source,\n team: input.team,\n product: input.product,\n ...(input.connection ? { connection: input.connection } : {}),\n };\n\n // Slack and Ekanos's Linear Agents app: the channels a `slack` or `linear`\n // agent trigger answers through, installed by their own flows.\n if (!input.connection && !args.linkOnly && isTeamChannel(input.product)) {\n return runTeamChannelInstall(ctx, args, client, host, source, {\n team: input.team,\n channel: input.product,\n ...(input.as ? { as: input.as } : {}),\n open: args.openUrl ?? openInBrowser,\n });\n }\n\n if (args.linkOnly) return printLink(ctx, client, host, target);\n\n const { plan } = await client.call((token) =>\n showTeamConnect(host, token, target, input.as),\n );\n const named = isNamed(plan);\n const name = named\n ? await connectionLabel(client, host, target, plan)\n : plan.product.name;\n await warnOtherRunsAs(ctx, client, host, source, plan);\n for (const line of scopeHiddenLines(plan.productScope, {\n team: plan.team.slug,\n product: plan.product.slug,\n source: plan.source.slug,\n })) {\n ctx.warn(line);\n }\n\n switch (plan.mode) {\n case 'not-entitled':\n throw invalidStateError(\n plan.reason ??\n `\"${input.product}\" is not enabled on ${plan.source.slug}.`,\n `Enable it for the Source first: \"ekanos sources products enable ${input.product}\" as a Source admin if ${plan.source.slug} built it, otherwise a super-admin (/admin in the browser). \"ekanos sources products\" shows what ${plan.source.slug} has.`,\n );\n case 'not-self-serve':\n throw invalidStateError(\n plan.reason ?? `${name} is not connected by a team.`,\n plan.product.kind === 'experience'\n ? `\"ekanos sources products --source ${plan.source.slug}\" shows whether it is on for the Source.`\n : 'It is turned on for the Source by Ekanos; there is nothing for the team to do.',\n );\n case 'unsupported':\n throw invalidStateError(\n plan.reason ?? `${name} cannot be connected from here.`,\n `Open the team's page instead: ${plan.connectUrl}`,\n );\n case 'works-as-shipped':\n return ctx.succeed(\n { host, plan, connected: true },\n ctx.ui.result({\n title: `${name} works as shipped for ${plan.team.slug}`,\n rows: [['Status', 'nothing to connect']],\n }),\n );\n case 'browser':\n return ctx.succeed(\n { host, plan, connected: plan.connected },\n ctx.ui.result({\n title: plan.connected\n ? `${plan.team.slug} has connected ${name}`\n : `${name} connects in the app for ${plan.team.slug}`,\n tone: plan.connected ? 'ok' : 'warn',\n rows: [\n ['Open', plan.connectUrl],\n ['Status', statusOf(plan)],\n ],\n notes: plan.connected\n ? []\n : [\n plan.reason ??\n `${name} connects through its own form in the app.`,\n 'A team admin signs in there and clicks Connect.',\n ],\n }),\n );\n default:\n break;\n }\n\n if (plan.connected && !args.reconnect) {\n const summary = ctx.ui.result({\n title: `${plan.team.slug} has already ${named ? 'installed' : 'connected'} ${name}`,\n rows: [\n ['Status', statusOf(plan, named)],\n ['Team page', plan.connectUrl],\n ],\n notes: [\n `\"ekanos teams show ${plan.team.slug} ${plan.product.slug}\" shows the full setup.`,\n `Broken (revoked or expired)? Connect it again: ekanos teams connect ${plan.team.slug} ${plan.product.slug}${named ? ` --connection ${plan.connectionId}` : ''} --reconnect`,\n ],\n });\n return named\n ? ctx.succeed({ host, plan, connected: true }, summary)\n : offerChannels(ctx, args, client, host, source, input, {\n data: { host, plan, connected: true },\n summary,\n });\n }\n\n if (plan.mode === 'fields' || plan.mode === 'no-fields') {\n return activate(ctx, args, client, host, target, plan);\n }\n return connectOAuth(ctx, args, client, host, target, plan, input.as, {\n name,\n then: named\n ? undefined\n : (done) => offerChannels(ctx, args, client, host, source, input, done),\n });\n}\n\n/**\n * A personal connection belongs to whoever makes it, but a provided agent\n * uses the personal connection of the person it runs as — so connecting\n * your own leaves the agent missing it (CLI audit P0-5). Name each agent\n * that runs as someone else and the command that connects it for them.\n */\nasync function warnOtherRunsAs(\n ctx: CliContext,\n client: TeamsClient,\n host: string,\n source: string,\n plan: TeamConnectPlan,\n): Promise<void> {\n const email = plan.member?.email?.toLowerCase();\n if (plan.scope !== 'user' || !email) return;\n let list;\n try {\n list = await client.call((token) =>\n call(host, token, TeamAgentListSchema, {\n method: 'GET',\n path: `/api/partner/teams/${encodeURIComponent(plan.team.slug)}/agents`,\n source,\n }),\n );\n } catch (error) {\n ctx.log(\n `Could not check who ${plan.team.slug}'s agents run as: ${error instanceof Error ? error.message : String(error)}`,\n );\n return;\n }\n for (const entry of list.agents) {\n const runsAs = entry.agent?.requirements.find(\n (item) =>\n item.key === plan.product.slug &&\n item.via === 'person' &&\n item.viaDetail &&\n item.viaDetail.toLowerCase() !== email,\n )?.viaDetail;\n if (!runsAs) continue;\n ctx.warn(\n `Note: ${entry.key} runs as ${runsAs} and uses ${runsAs}'s ${plan.product.name} connection, not ${email}'s. For the agent, run: ${cli()} teams connect ${plan.team.slug} ${plan.product.slug} --as ${runsAs} --source ${source}`,\n );\n }\n}\n\n/**\n * After the main connection: the named connections the team's agents'\n * triggers wait on and the team has not installed (Linear's agent). At a\n * terminal, ask and install each; otherwise name the command, in the\n * result and its JSON (`channelsToInstall`).\n */\nasync function offerChannels(\n ctx: CliContext,\n args: TeamsArgs,\n client: TeamsClient,\n host: string,\n source: string,\n input: { team: string; product: string; as?: string },\n done: { data: Record<string, unknown>; summary: string },\n): Promise<ExitCode> {\n const status = await client.call((token) =>\n showTeamIntegration(host, token, {\n source,\n team: input.team,\n product: input.product,\n }),\n );\n const waiting = channelsToInstall(status);\n if (waiting.length === 0) return ctx.succeed(done.data, done.summary);\n\n const command = (connectionId: string) =>\n `ekanos teams connect ${input.team} ${input.product} --connection ${connectionId} --source ${status.source.slug}`;\n const why = (entry: (typeof waiting)[number]) =>\n `${entry.label} is not installed for ${input.team}, and ${entry.neededBy.map((need) => `${need.agent} (${need.triggers.join(', ')})`).join(', ')} only start${entry.neededBy.length === 1 ? 's' : ''} through it.`;\n\n if (!canPrompt(ctx, args)) {\n return ctx.succeed(\n {\n ...done.data,\n channelsToInstall: waiting.map((entry) => ({\n connectionId: entry.connectionId,\n label: entry.label,\n neededBy: entry.neededBy,\n command: command(entry.connectionId),\n })),\n },\n [\n done.summary,\n ...waiting.flatMap((entry) => [\n `Next: ${why(entry)}`,\n ` Install it in your terminal: ${cli()} ${command(entry.connectionId)}`,\n ]),\n ].join('\\n'),\n );\n }\n\n ctx.log(done.summary);\n let code: ExitCode = 0;\n for (const entry of waiting) {\n ctx.log(why(entry));\n const answer = (\n await (args.ask ?? promptLine)(`Install ${entry.label} now? [Y/n] `)\n )\n .trim()\n .toLowerCase();\n if (answer !== '' && answer !== 'y' && answer !== 'yes') {\n ctx.log(`Skipped. Later: ${command(entry.connectionId)}`);\n continue;\n }\n code = await runTeamConnect(ctx, args, client, host, source, {\n ...input,\n connection: entry.connectionId,\n });\n }\n return code;\n}\n\n/** Named connections the team's agents wait on and the team has not installed. */\nexport function channelsToInstall(status: TeamIntegrationStatus) {\n return (status.connections ?? []).filter(\n (entry) =>\n entry.connectionId !== 'default' &&\n !entry.connected &&\n entry.neededBy.length > 0,\n );\n}\n\nfunction isNamed(plan: TeamConnectPlan): boolean {\n return Boolean(plan.connectionId && plan.connectionId !== 'default');\n}\n\nasync function connectionLabel(\n client: TeamsClient,\n host: string,\n target: { source: string; team: string; product: string },\n plan: TeamConnectPlan,\n): Promise<string> {\n const status = await client.call((token) =>\n showTeamIntegration(host, token, target),\n );\n return (\n status.connections?.find(\n (entry) => entry.connectionId === plan.connectionId,\n )?.label ??\n status.teamApps.find((entry) => entry.connectionId === plan.connectionId)\n ?.label ??\n `${plan.product.name} (${plan.connectionId})`\n );\n}\n\nasync function activate(\n ctx: CliContext,\n args: TeamsArgs,\n client: TeamsClient,\n host: string,\n target: { source: string; team: string; product: string },\n plan: TeamConnectPlan,\n): Promise<ExitCode> {\n if (plan.scope === 'user' && !plan.member) {\n throw invalidStateError(\n plan.memberProblem ??\n `${plan.product.name} is a personal connection: each member connects their own.`,\n joinHint(plan, target),\n );\n }\n\n const entered =\n plan.mode === 'fields'\n ? await enterFields(ctx, args, plan, connectAgain(target, plan))\n : { fields: {}, set: [] };\n const started = await client.call((token) =>\n startTeamConnect(host, token, target, {\n fields: entered.fields,\n ...(entered.set.length > 0 ? { set: entered.set } : {}),\n }),\n );\n return ctx.succeed(\n { host, ...started, connected: started.plan.connected },\n ctx.ui.result({\n title: `Connected ${started.plan.product.name} for ${started.plan.team.slug}`,\n rows: [\n ['Status', statusOf(started.plan)],\n [\n 'For',\n started.plan.scope === 'user'\n ? `you (${started.plan.member?.email ?? 'your account'}) — a personal connection`\n : 'the whole team',\n ],\n ['Team page', started.plan.connectUrl],\n ],\n }),\n );\n}\n\nasync function connectOAuth(\n ctx: CliContext,\n args: TeamsArgs,\n client: TeamsClient,\n host: string,\n target: {\n source: string;\n team: string;\n product: string;\n connection?: string;\n },\n plan: TeamConnectPlan,\n asEmail: string | undefined,\n options: {\n /** What is being connected: the product, or a named connection's label. */\n name: string;\n /** On success, instead of finishing: the main connection's follow-ups. */\n then?: (done: {\n data: Record<string, unknown>;\n summary: string;\n }) => Promise<ExitCode>;\n },\n): Promise<ExitCode> {\n const named = isNamed(plan);\n const name = options.name;\n const again = `ekanos teams connect ${target.team} ${target.product}${named ? ` --connection ${plan.connectionId}` : ''}`;\n if (!plan.member) {\n throw invalidStateError(\n plan.memberProblem ?? 'No member of the team can sign in yet.',\n plan.scope === 'user'\n ? joinHint(plan, target)\n : `Name a member of ${plan.team.slug} who signs in: ${again} --as <email>. Or join it and sign in yourself: ekanos teams members add ${plan.team.slug} --self --role admin`,\n );\n }\n\n if (plan.teamApp) {\n const status = await client.call((token) =>\n showTeamIntegration(host, token, target),\n );\n const connectionId = plan.connectionId ?? 'default';\n const app =\n status.teamApps.find((entry) => entry.connectionId === connectionId) ??\n (named ? undefined : status.teamApps[0]);\n if (app && app.fields.some((field) => !field.set)) {\n if (\n !canPrompt(ctx, args) &&\n !secretInputGiven(readSecretFlags(args.flags))\n ) {\n throw usageError(\n `${name} needs ${plan.team.slug}'s own app first (${app.fields\n .filter((field) => !field.set)\n .map((field) => field.secretName)\n .join(', ')}), and there is no terminal to ask at.`,\n `Without a terminal, pass --set <field>=<value> for the plain fields and ${FIELD_SECRET_FORMS}. Or run it yourself in your terminal: ${cli()} ${again} --source ${plan.source.slug}`,\n );\n }\n ctx.log(\n `${name} signs ${plan.team.slug} in through the team's own app. Set it up first:`,\n );\n await promptAndSaveTeamApp(ctx, args, client, host, target, status, app);\n }\n }\n\n // An app sign-in (GitHub, ROAM) activates on return with what the app's\n // form would add after the sign-in: asked now, applied then.\n const entered =\n plan.signIn === 'app' && plan.fields.length > 0\n ? await enterFields(\n ctx,\n args,\n plan,\n `${again} --source ${plan.source.slug}`,\n )\n : undefined;\n const started = await client.call((token) =>\n startTeamConnect(host, token, target, {\n ...(asEmail ? { as: asEmail } : {}),\n ...(entered ? { fields: entered.fields } : {}),\n ...(entered && entered.set.length > 0 ? { set: entered.set } : {}),\n }),\n );\n if (started.result !== 'consent') {\n throw invalidStateError(\n `The host answered \"${started.result}\" where a sign-in link was expected.`,\n 'Run \"ekanos upgrade\" — the CLI and the host disagree on the connect contract.',\n );\n }\n assertBrowserSafeUrl(started.authorizeUrl, 'sign-in link');\n\n const member = started.plan.member ?? plan.member;\n const forCaller = member.isCaller;\n const expires = started.expiresAt.replace('T', ' ').slice(0, 16);\n ctx.log(\n forCaller\n ? [\n named\n ? `Install ${name} for ${plan.team.slug} — sign in as an admin of the workspace it goes into, and approve it:`\n : `Sign in to ${plan.product.name} as the account ${plan.team.slug} should use${plan.scope === 'user' ? ' (a personal connection: yours)' : ''}:`,\n ` ${started.authorizeUrl}`,\n ` (one-time link, valid until ${expires} UTC)`,\n ...(plan.signIn === 'app'\n ? [\n ` It opens ${plan.product.name}'s sign-in through ${plan.source.slug}'s app: if the browser asks you to sign in to the app first, do, then open the link again.`,\n ]\n : []),\n ].join('\\n')\n : [\n `Send this link to ${member.email ?? 'the member'} — they ${named ? `install ${name}` : `sign in to ${plan.product.name}`} for ${plan.team.slug}${plan.scope === 'user' ? ' (a personal connection: theirs)' : ''}:`,\n ` ${started.authorizeUrl}`,\n ` (one-time, for them only, valid until ${expires} UTC)`,\n ...(plan.signIn === 'app'\n ? [\n ` They open it signed in to ${plan.source.slug}'s app as themselves.`,\n ]\n : []),\n ].join('\\n'),\n );\n\n // Only ever the caller's own browser: opening a link meant for another\n // member would sign the caller's provider account in for them.\n if (forCaller && !args.noOpen && !ctx.jsonMode) {\n (args.openUrl ?? openInBrowser)(started.authorizeUrl);\n }\n\n // A reconnect can't be waited on: the team already reads as connected, so\n // nothing the host reports changes when the new sign-in lands.\n const reconnecting = args.reconnect === true && plan.connected;\n if (args.noWait || ctx.jsonMode || reconnecting) {\n return ctx.succeed(\n {\n host,\n plan: started.plan,\n authorizeUrl: started.authorizeUrl,\n expiresAt: started.expiresAt,\n connected: false,\n },\n ctx.ui.hint(\n reconnecting\n ? `The current connection keeps working until the sign-in finishes; then its tokens are replaced. Check with \"ekanos teams show ${target.team} ${target.product}\".`\n : `Then check with \"ekanos teams show ${target.team} ${target.product}\".`,\n ),\n );\n }\n\n ctx.log(\n 'Waiting for the sign-in to finish (Ctrl-C stops waiting; the link stays valid)…',\n );\n const deadline = Date.parse(started.expiresAt) || Date.now() + 10 * 60 * 1000;\n while (Date.now() < deadline) {\n await new Promise((resolve) =>\n setTimeout(resolve, args.pollDelayMs ?? 3000),\n );\n const polled = await client.call((token) =>\n showTeamConnect(host, token, target, asEmail),\n );\n if (polled.plan.connected) {\n const status = await client.call((token) =>\n showTeamIntegration(host, token, target),\n );\n const done = {\n data: { host, plan: polled.plan, status, connected: true },\n summary: [\n ctx.ui.result({\n title: `${named ? 'Installed' : 'Connected'} ${name} for ${plan.team.slug}`,\n rows: [\n ['Signed in by', member.email ?? member.userId],\n ['Status', statusOf(polled.plan, named)],\n ],\n notes: named\n ? [\n `Prove it end to end: @mention the agent in ${plan.product.name}, then \"ekanos runs list --team ${plan.team.slug}\" shows the run it started.`,\n ]\n : [],\n }),\n checklist(status).join('\\n'),\n ].join('\\n'),\n };\n return options.then\n ? options.then(done)\n : ctx.succeed(done.data, done.summary);\n }\n }\n throw validationError(\n 'The sign-in did not finish before the link expired.',\n `Run \"${again}${asEmail ? ` --as ${asEmail}` : ''}\" again for a fresh link.`,\n );\n}\n\n/** The command that connects it again, for a hint. */\nfunction connectAgain(\n target: { team: string; product: string },\n plan: TeamConnectPlan,\n): string {\n return `ekanos teams connect ${target.team} ${target.product} --source ${plan.source.slug}`;\n}\n\n/**\n * A personal connection is the member's own: whoever runs connect makes\n * theirs, so a caller who is not on the team joins it first.\n */\nfunction joinHint(\n plan: TeamConnectPlan,\n target: { team: string; product: string },\n): string {\n return `It is yours to connect once you are a member: ekanos teams members add ${plan.team.slug} --self, then ${connectAgain(target, plan)}. For someone else's, send them a link: ${connectAgain(target, plan)} --as <their-email>.`;\n}\n\n/**\n * The activation fields, through the shared secret input (`secret-input.ts`)\n * that every command taking a secret uses: `--set <field>=<value>` for a\n * plain field; for a secret (which includes a JSON value, which can carry\n * one) `--set-secret <field>=env:…|file:…|stdin`, `--secret-env|file|stdin`\n * for a single one, or `--browser`; otherwise a prompt at a terminal, hidden\n * for a secret. Each value is then typed by its field (`connect-fields.ts`).\n *\n * In a script or an agent run with no secret flags, an optional field\n * nobody gave is skipped rather than refused, so a product whose fields are\n * all optional (GitHub) goes straight to its sign-in.\n *\n * `set` names the fields given by `--set`: the host refuses a secret among\n * them (`SECRET_AS_ARGUMENT`), as `--set` here already does.\n */\nasync function enterFields(\n ctx: CliContext,\n args: TeamsArgs,\n plan: TeamConnectPlan,\n again: string,\n): Promise<{ fields: Record<string, FieldValue>; set: string[] }> {\n const plain = parsePlainValues(args.flags?.set, 'default_labels=bug,triage');\n const secret = readSecretFlags(args.flags);\n const interactive = canPrompt(ctx, args);\n const asking = interactive || secretInputGiven(secret);\n // Without a terminal, a secret flag or any --set, only the required fields\n // are asked for (and refused); an optional one is skipped.\n const fields =\n asking || Object.keys(plain).length > 0\n ? plan.fields\n : plan.fields.filter((field) => field.required);\n if (\n interactive &&\n !secretInputGiven(secret) &&\n fields.some((field) => !(field.name in plain))\n ) {\n ctx.log(\n `${plan.product.name} for ${plan.scope === 'user' ? 'you, in' : 'team'} ${plan.team.slug}: enter what the app's form asks${plan.signIn === 'app' ? ' after the sign-in' : ''}. Secrets are hidden and never shown again.`,\n );\n }\n\n const byName = new Map(plan.fields.map((field) => [field.name, field]));\n const raw =\n fields.length === 0 && Object.keys(plain).length === 0\n ? {}\n : await collectSecrets(ctx, {\n fields: fields.map((field) => ({\n name: field.name,\n label: field.label,\n sensitive: field.sensitive,\n required: field.required,\n ...(field.description ? { description: field.description } : {}),\n })),\n plain,\n flags: secret,\n io: teamsSecretIO(args),\n interactive,\n title: `${plan.product.name} for ${plan.team.slug}`,\n refusal: `${plan.product.name} needs its form's fields (${fields\n .filter((field) => field.required)\n .map((field) => `${field.label} [${field.name}]`)\n .join(', ')}), and there is no terminal to ask at.`,\n again: again.replace(/^ekanos /, ''),\n prompt: (spec) => {\n const field = byName.get(spec.name)!;\n if (field.description) ctx.log(` ${field.description}`);\n return (\n field.sensitive\n ? (args.askSecret ?? promptHidden)\n : (args.ask ?? promptLine)\n )(fieldPrompt(field));\n },\n });\n\n const values: Record<string, FieldValue> = {};\n for (const [name, text] of Object.entries(raw)) {\n const field = byName.get(name);\n if (!field) continue;\n const value = parseFieldValue(field, text);\n if (value !== undefined) values[name] = value;\n }\n const missing = plan.fields.filter(\n (field) => field.required && values[field.name] === undefined,\n );\n if (missing.length > 0) {\n throw validationError(\n `${missing.map((field) => `${field.label} (${field.name})`).join(', ')} ${missing.length === 1 ? 'is' : 'are'} needed.`,\n `Run \"${again}\" again.`,\n );\n }\n return {\n fields: values,\n set: Object.keys(plain).filter((name) => plain[name] !== ''),\n };\n}\n\n/** `--link-only`: the team's page and whether it is connected. */\nasync function printLink(\n ctx: CliContext,\n client: TeamsClient,\n host: string,\n target: { source: string; team: string; product: string },\n): Promise<ExitCode> {\n const status = await client.call((token) =>\n showTeamIntegration(host, token, target),\n );\n if (!status.enabled) {\n throw invalidStateError(\n `\"${target.product}\" is not enabled on ${status.source.slug}.`,\n `\"ekanos sources products --source ${status.source.slug}\" shows what this Source has; a super-admin enables a product for a Source.`,\n );\n }\n const connected = status.activation !== null;\n const rows: ResultRow[] = [\n ['Open', status.connectUrl],\n [\n 'Status',\n connected\n ? `connected${status.activation?.activatedAt ? ` ${status.activation.activatedAt.slice(0, 10)}` : ''}`\n : 'not connected',\n ],\n ];\n return ctx.succeed(\n { host, ...status },\n ctx.ui.result({\n title: connected\n ? `${status.team.slug} has connected ${status.product.name}`\n : `Connect link for ${status.team.slug} · ${status.product.name}`,\n tone: connected ? 'ok' : 'warn',\n rows,\n notes: [\n 'A team member signs in there and clicks Connect.',\n `\"ekanos teams connect ${status.team.slug} ${status.product.slug}\" (without --link-only) connects it from here.`,\n ],\n }),\n );\n}\n\nfunction statusOf(plan: TeamConnectPlan, named = false): string {\n if (!plan.connected) return named ? 'not installed' : 'not connected';\n return `${named ? 'installed' : 'connected'}${plan.connectedAt ? ` ${plan.connectedAt.slice(0, 10)}` : ''}`;\n}\n"]}
@@ -0,0 +1,90 @@
1
+ import type { CliContext } from '../context.js';
2
+ import type { ExitCode } from '../exit-codes.js';
3
+ import { type TeamsArgs } from './teams.js';
4
+ /**
5
+ * A team's lifecycle from the terminal, for the Source admin:
6
+ * `teams members resend`, `teams leave`, `teams groups …`, `teams health`
7
+ * and `teams workspace …`. Each is parsed before a session is touched
8
+ * (`parseLifecycle`), and a change that takes something away is confirmed
9
+ * first — asked at a terminal, `--yes` in a script or agent run — so a usage
10
+ * error or an unconfirmed change never costs a request. The host does the
11
+ * rest through the services the app's own screens use, with an Admin Audit
12
+ * row per write.
13
+ *
14
+ * Ownership transfer and team deletion are not here: in the app they are
15
+ * the primary owner's alone, confirmed by a code emailed to them.
16
+ */
17
+ export declare const LIFECYCLE_SUBCOMMANDS: readonly ['leave', 'groups', 'health', 'workspace'];
18
+ type LifecycleSubcommand = (typeof LIFECYCLE_SUBCOMMANDS)[number];
19
+ /** `teams members <verb>` verbs handled here rather than in onboarding. */
20
+ export declare const LIFECYCLE_MEMBER_VERBS: readonly ['resend'];
21
+ /** What an unconfirmed change says, and the question a terminal is asked. */
22
+ export interface Confirmation {
23
+ what: string;
24
+ command: string;
25
+ question: string;
26
+ }
27
+ export type LifecyclePlan = ({
28
+ kind: 'resend';
29
+ team: string;
30
+ email: string;
31
+ } | {
32
+ kind: 'leave';
33
+ team: string;
34
+ } | {
35
+ kind: 'groups-list';
36
+ team: string;
37
+ } | {
38
+ kind: 'groups-create';
39
+ team: string;
40
+ name: string;
41
+ description?: string;
42
+ products?: string[];
43
+ } | {
44
+ kind: 'groups-update';
45
+ team: string;
46
+ group: string;
47
+ name?: string;
48
+ description?: string | null;
49
+ products?: string[];
50
+ } | {
51
+ kind: 'groups-delete';
52
+ team: string;
53
+ group: string;
54
+ } | {
55
+ kind: 'groups-member';
56
+ team: string;
57
+ group: string;
58
+ email: string;
59
+ member: boolean;
60
+ } | {
61
+ kind: 'health';
62
+ team: string;
63
+ product?: string;
64
+ run: boolean;
65
+ /** `--mine`: the caller's own personal connection to <product>. */
66
+ mine?: boolean;
67
+ } | {
68
+ kind: 'workspace-list';
69
+ team: string;
70
+ } | {
71
+ kind: 'workspace-default';
72
+ team: string;
73
+ workspace: string;
74
+ }) & {
75
+ confirm?: Confirmation;
76
+ };
77
+ export declare function isLifecycleSubcommand(value: string | undefined): value is LifecycleSubcommand;
78
+ export declare function isLifecycleMemberVerb(value: string | undefined): boolean;
79
+ /**
80
+ * `subcommand` is `members` (with `resend` first in `rest`) or one
81
+ * of {@link LIFECYCLE_SUBCOMMANDS}.
82
+ */
83
+ export declare function parseLifecycle(subcommand: string, rest: readonly string[], args: Pick<TeamsArgs, 'yes' | 'flags'>): LifecyclePlan;
84
+ export declare function runLifecycle(ctx: CliContext, args: TeamsArgs, plan: LifecyclePlan): Promise<ExitCode>;
85
+ /**
86
+ * A change that takes something away: asked at a terminal; a script, an
87
+ * agent run or `--json` passes `--yes` instead. Asked before any request.
88
+ */
89
+ export declare function confirmChange(ctx: CliContext, args: TeamsArgs, confirm: Confirmation): Promise<void>;
90
+ export {};