@ekanos/cli 0.32.0 → 0.33.1

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 (54) hide show
  1. package/dist/apps-api.js +1 -1
  2. package/dist/apps-api.js.map +1 -1
  3. package/dist/commands/agents.js +2 -1
  4. package/dist/commands/agents.js.map +1 -1
  5. package/dist/commands/catalog.js +7 -2
  6. package/dist/commands/catalog.js.map +1 -1
  7. package/dist/commands/publish.js +3 -2
  8. package/dist/commands/publish.js.map +1 -1
  9. package/dist/commands/sources.js +4 -3
  10. package/dist/commands/sources.js.map +1 -1
  11. package/dist/commands/team-agent-access.d.ts +18 -0
  12. package/dist/commands/team-agent-access.js +60 -0
  13. package/dist/commands/team-agent-access.js.map +1 -0
  14. package/dist/commands/team-agent-readiness.js +4 -3
  15. package/dist/commands/team-agent-readiness.js.map +1 -1
  16. package/dist/commands/team-agents-agents.d.ts +3 -3
  17. package/dist/commands/team-agents-agents.js +19 -29
  18. package/dist/commands/team-agents-agents.js.map +1 -1
  19. package/dist/commands/team-agents-define.js +4 -4
  20. package/dist/commands/team-agents-define.js.map +1 -1
  21. package/dist/commands/teams-connect.d.ts +5 -0
  22. package/dist/commands/teams-connect.js +25 -11
  23. package/dist/commands/teams-connect.js.map +1 -1
  24. package/dist/commands/teams.js +29 -12
  25. package/dist/commands/teams.js.map +1 -1
  26. package/dist/commands/use.js +3 -2
  27. package/dist/commands/use.js.map +1 -1
  28. package/dist/connections-api.js +2 -2
  29. package/dist/connections-api.js.map +1 -1
  30. package/dist/names-api.js +1 -1
  31. package/dist/names-api.js.map +1 -1
  32. package/dist/publish-api.js +3 -2
  33. package/dist/publish-api.js.map +1 -1
  34. package/dist/routes-api.js +11 -1
  35. package/dist/routes-api.js.map +1 -1
  36. package/dist/runs-api.js +1 -1
  37. package/dist/runs-api.js.map +1 -1
  38. package/dist/secret-form.d.ts +6 -1
  39. package/dist/secret-form.js +2 -2
  40. package/dist/secret-form.js.map +1 -1
  41. package/dist/source-products-api.d.ts +3 -0
  42. package/dist/source-products-api.js +7 -4
  43. package/dist/source-products-api.js.map +1 -1
  44. package/dist/source-target.js +3 -1
  45. package/dist/source-target.js.map +1 -1
  46. package/dist/teams-api.d.ts +12 -3
  47. package/dist/teams-api.js +54 -4
  48. package/dist/teams-api.js.map +1 -1
  49. package/package.json +2 -2
  50. package/templates/claude-skill.md.tmpl +11 -1
  51. package/templates/experience/package.json.tmpl +4 -4
  52. package/templates/package.json.tmpl +4 -4
  53. package/templates/skills/build-agent/references/set-up-an-integration.md +4 -2
  54. package/templates/skills/ekanos-platform/SKILL.md +48 -4
@@ -4,8 +4,8 @@ import { usageError, validationError } from '../errors.js';
4
4
  import { call } from '../teams-api.js';
5
5
  import { readAgentInput } from './agents.js';
6
6
  import { AGENT_SKILLS_DIR, findAgentSkillFolders, pushSkillFolder, pushSummary, readSkillFolder, } from './skills.js';
7
+ import { describeConnections, identityLabel } from './team-agent-access.js';
7
8
  import { requireOperand, usageFor } from './team-agents.js';
8
- import { describeAccess } from './team-agents-agents.js';
9
9
  /**
10
10
  * `ekanos teams agents create <team> --from <dir|file> [--personal]` and
11
11
  * `ekanos teams agents apply <team> <dir|file> [--personal]` — one of the
@@ -119,7 +119,7 @@ function withLocalSkills(body, slugs) {
119
119
  return Object.assign(Object.assign({}, body), { skills });
120
120
  }
121
121
  function describeResult(ctx, result, source) {
122
- var _a, _b;
122
+ var _a;
123
123
  const team = result.team.slug;
124
124
  const personal = result.ownership === 'personal';
125
125
  const title = result.outcome === 'created'
@@ -130,13 +130,13 @@ function describeResult(ctx, result, source) {
130
130
  const rows = [
131
131
  ['Agent', `${result.name} (${result.slug})`],
132
132
  ['Owned by', personal ? `${(_a = result.createdBy) !== null && _a !== void 0 ? _a : 'you'} alone` : 'the team'],
133
- ['Runs as', (_b = result.createdBy) !== null && _b !== void 0 ? _b : 'nobody (its creator left the team)'],
133
+ ['Identity', identityLabel(result.createdBy, personal)],
134
134
  ['Version', `v${result.version}`],
135
135
  ['Status', result.status],
136
136
  ['Skills', result.skills.length > 0 ? result.skills.join(', ') : 'none'],
137
137
  [
138
138
  'Access',
139
- `${describeAccess(result.access)} — ${result.accessConfirmed ? 'confirmed' : 'not confirmed'}`,
139
+ `${describeConnections(result.access, result.createdBy)} — ${result.accessConfirmed ? 'confirmed' : 'not confirmed'}`,
140
140
  ],
141
141
  ];
142
142
  const next = [];
@@ -1 +1 @@
1
- {"version":3,"file":"team-agents-define.js","sourceRoot":"","sources":["../../src/commands/team-agents-define.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,0BAA0B,EAG1B,0BAA0B,EAE1B,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAExD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,eAAe,EACf,WAAW,EACX,eAAe,GAChB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAqB,cAAc,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,GAAe,EACf,GAAiB,EACjB,IAAwB;;;IAExB,MAAM,IAAI,GAAG,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;IACpE,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACrC,MAAM,UAAU,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IACnC,IAAI,GAAG,CAAC,Q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entApplyResult,\n TeamAgentApplyResultSchema,\n type TeamAgentBody,\n TeamAgentBodySchema,\n} from '@ekanos/integration-schema';\nimport * as path from 'node:path';\n\nimport type { CliContext } from '../context';\nimport { usageError, validationError } from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { call } from '../teams-api';\nimport type { ResultRow } from '../ui';\nimport { readAgentInput } from './agents';\nimport {\n AGENT_SKILLS_DIR,\n findAgentSkillFolders,\n pushSkillFolder,\n pushSummary,\n readSkillFolder,\n} from './skills';\nimport { type TeamAgentRun, requireOperand, usageFor } from './team-agents';\nimport { describeAccess } from './team-agents-agents';\n\n/**\n * `ekanos teams agents create <team> --from <dir|file> [--personal]` and\n * `ekanos teams agents apply <team> <dir|file> [--personal]` — one of the\n * team's own agents, or the caller's personal one, from the same\n * `agent.json` (+ `AGENT.md`, + `skills/<slug>/` folders) that `ekanos\n * agents apply` reads for a Source template, read by the same loader.\n *\n * Why two verbs: `apply` is `agents apply` at team level — it creates the\n * agent when there is none and changes it when there is, refusing a change\n * made since the version you name (`--base-version`, the version `teams\n * agents show` reports; `--overwrite` replaces it anyway), so a CI job or\n * an agent can run it again and again. `create` is the same request that\n * only ever makes a new agent: it never names a version, so an agent that\n * exists already is refused rather than changed. The file's own\n * `baseVersion` is a template version and is never sent here.\n *\n * Creating makes you the agent's creator — its tools run as you, and a\n * personal one acts for you on every trigger — so you must be an active\n * member of the team. A personal agent is yours alone to change.\n */\nexport async function runTeamAgentDefine(\n ctx: CliContext,\n run: TeamAgentRun,\n verb: 'create' | 'apply',\n): Promise<ExitCode> {\n const team = requireOperand(run.operands[0], 'team slug', 'agents');\n const from = flagString(run, 'from');\n const positional = run.operands[1];\n if (run.operands.length > 2 || (from && positional)) {\n throw usageError(\n `teams agents ${verb} takes the team and one agent directory or file.`,\n usageFor('agents'),\n );\n }\n const target = from ?? positional;\n if (!target) {\n throw usageError(\n `teams agents ${verb} needs an agent directory or agent.json.`,\n verb === 'create'\n ? `e.g. ekanos teams agents create ${team} --from agents/triage [--personal]`\n : `e.g. ekanos teams agents apply ${team} agents/triage --base-version 3`,\n );\n }\n\n const personal = run.args.flags?.personal === true;\n const overwrite = run.args.flags?.overwrite === true;\n const baseVersion = parseBaseVersion(flagString(run, 'base-version'));\n if (verb === 'create' && (baseVersion !== null || overwrite)) {\n throw usageError(\n 'create only makes a new agent, so it takes no --base-version or --overwrite.',\n `Change an existing one with: ekanos teams agents apply ${team} ${target} --base-version <n>`,\n );\n }\n\n // Read the local input before any network call, so a bad file fails fast.\n const input = readAgentInput(target, run.args.dir);\n const pushSkills = run.args.flags?.skills !== false;\n const folders =\n input.file && pushSkills\n ? findAgentSkillFolders(path.dirname(input.file)).map((dir) =>\n readSkillFolder(dir, run.args.dir),\n )\n : [];\n const body = withLocalSkills(\n teamAgentBody(input.body, input.file ?? target),\n folders.map((folder) => folder.slug),\n );\n\n // The skills first, so the agent can name them: the team's own level.\n const pushed = [];\n for (const folder of folders) {\n pushed.push(\n await pushSkillFolder(run.skills, run.host, {\n source: run.source,\n team,\n folder,\n }),\n );\n }\n\n const request: TeamAgentApplyRequest = {\n key: input.key,\n ownership: personal ? 'personal' : 'team',\n body,\n baseVersion,\n overwrite,\n ...(run.args.flags?.['confirm-access'] === true\n ? { confirmAccess: true }\n : {}),\n };\n const result = await run.client.call((token) =>\n call(run.host, token, TeamAgentApplyResultSchema, {\n method: 'POST',\n path: `/api/partner/teams/${encodeURIComponent(team)}/agents`,\n source: run.source,\n body: request,\n }),\n );\n\n return ctx.succeed(\n { host: run.host, ...result, skillsPushed: pushed },\n [\n ...pushed.map((entry) => pushSummary(ctx.ui, entry)),\n describeResult(ctx, result, run.source),\n ].join('\\n\\n'),\n );\n}\n\n/**\n * The definition fields of a template body. A field that sets a template up\n * on every team's copy is refused rather than dropped, so a file never\n * reads as doing something it does not.\n */\nexport function teamAgentBody(\n body: AgentTemplateBody,\n file: string,\n): TeamAgentBody {\n const set = TEMPLATE_ONLY_AGENT_FIELDS.filter((field) => {\n const value = body[field];\n if (value === undefined) return false;\n if (Array.isArray(value)) return value.length > 0;\n return Object.values(value).some((entry) => entry !== false);\n });\n if (set.length > 0) {\n throw validationError(\n `${file} sets ${set.join(', ')}, which only a Source template has: they say how it is set up on every team's copy.`,\n 'Drop them for a team or personal agent. Add its triggers with \"ekanos teams triggers add <team> <key> schedule|webhook …\", or publish it to every team with \"ekanos agents apply\".',\n );\n }\n return TeamAgentBodySchema.parse({\n name: body.name,\n description: body.description,\n instructions: body.instructions,\n model: body.model,\n maxTurns: body.maxTurns,\n tools: body.tools,\n policy: body.policy,\n skills: body.skills,\n });\n}\n\n/** The agent's skills plus the folders beside it, which it uses by being there. */\nfunction withLocalSkills(body: TeamAgentBody, slugs: string[]): TeamAgentBody {\n const skills = [...body.skills];\n for (const slug of slugs) if (!skills.includes(slug)) skills.push(slug);\n if (skills.length > 50) {\n throw validationError(\n `The agent would name ${skills.length} skills (with its ${AGENT_SKILLS_DIR}/ folders); the limit is 50.`,\n 'Drop some, or pass --no-skills and list them in agent.json.',\n );\n }\n return { ...body, skills };\n}\n\nfunction describeResult(\n ctx: CliContext,\n result: TeamAgentApplyResult,\n source: string,\n): string {\n const team = result.team.slug;\n const personal = result.ownership === 'personal';\n const title =\n result.outcome === 'created'\n ? `Created ${personal ? 'your personal agent' : 'agent'} ${result.slug} on ${team}`\n : result.outcome === 'updated'\n ? `Updated ${result.slug} on ${team} to v${result.version}`\n : `${result.slug} on ${team} already matches the file`;\n const rows: ResultRow[] = [\n ['Agent', `${result.name} (${result.slug})`],\n ['Owned by', personal ? `${result.createdBy ?? 'you'} alone` : 'the team'],\n ['Runs as', result.createdBy ?? 'nobody (its creator left the team)'],\n ['Version', `v${result.version}`],\n ['Status', result.status],\n ['Skills', result.skills.length > 0 ? result.skills.join(', ') : 'none'],\n [\n 'Access',\n `${describeAccess(result.access)} — ${result.accessConfirmed ? 'confirmed' : 'not confirmed'}`,\n ],\n ];\n const next: string[] = [];\n if (!result.accessConfirmed) {\n next.push(\n `Until someone who sets it up confirms what it may use, it runs only the tools that need no confirmation: ekanos teams agents confirm ${team} ${result.slug} --source ${source}`,\n );\n }\n if (result.status !== 'active') {\n next.push(\n `It is ${result.status}: turn it on with ekanos teams agents enable ${team} ${result.slug} --source ${source}`,\n );\n }\n next.push(\n `Start it from a schedule or a webhook: ekanos teams triggers add ${team} ${result.slug} schedule --cron \"0 9 * * 1-5\" --prompt \"…\"`,\n );\n if (personal) {\n next.push(\n 'It acts for you, with your own connections, on every trigger: only you change it, run it, decide its approvals or cancel its runs.',\n );\n }\n return ctx.ui.result({\n title,\n tone:\n result.outcome === 'unchanged' || !result.accessConfirmed ? 'warn' : 'ok',\n rows,\n notes: [\n ...next,\n `Change it later from the same file: ekanos teams agents apply ${team} <dir> --base-version ${result.version}${personal ? ' --personal' : ''}`,\n ],\n });\n}\n\nfunction parseBaseVersion(value: string | undefined): number | null {\n if (value === undefined) return null;\n const version = Number(value);\n if (Number.isInteger(version) && version >= 1) return version;\n throw usageError(\n `--base-version must be a version number (got \"${value}\").`,\n '\"ekanos teams agents show <team> <key>\" shows the version.',\n );\n}\n\nfunction flagString(run: TeamAgentRun, name: string): string | undefined {\n const value = run.args.flags?.[name];\n return typeof value === 'string' && value.trim() ? value.trim() : undefined;\n}\n"]}
1
+ {"version":3,"file":"team-agents-define.js","sourceRoot":"","sources":["../../src/commands/team-agents-define.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,0BAA0B,EAG1B,0BAA0B,EAE1B,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAExD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,eAAe,EACf,WAAW,EACX,eAAe,GAChB,MAA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,CAAC,CAAC;IAC9B,IAAI,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,OAAO,IAAI,CAAC;QAAE,OAAO,OAAO,CAAC;IAC9D,MAAM,UAAU,CACd,iDAAiD,KAAK,KAAK,EAC3D,4DAA4D,CAC7D,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,GAAiB,EAAE,IAAY;;IACjD,MAAM,KAAK,GAAG,MAAA,GAAG,CAAC,IAAI,CAAC,KAAK,0CAAG,IAAI,CAAC,CAAC;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC9E,CAAC","sourcesContent":["import {\n type AgentTemplateBody,\n TEMPLATE_ONLY_AGENT_FIELDS,\n type TeamAgentApplyRequest,\n type TeamAgentApplyResult,\n TeamAgentApplyResultSchema,\n type TeamAgentBody,\n TeamAgentBodySchema,\n} from '@ekanos/integration-schema';\nimport * as path from 'node:path';\n\nimport type { CliContext } from '../context';\nimport { usageError, validationError } from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { call } from '../teams-api';\nimport type { ResultRow } from '../ui';\nimport { readAgentInput } from './agents';\nimport {\n AGENT_SKILLS_DIR,\n findAgentSkillFolders,\n pushSkillFolder,\n pushSummary,\n readSkillFolder,\n} from './skills';\nimport { describeConnections, identityLabel } from './team-agent-access';\nimport { type TeamAgentRun, requireOperand, usageFor } from './team-agents';\n\n/**\n * `ekanos teams agents create <team> --from <dir|file> [--personal]` and\n * `ekanos teams agents apply <team> <dir|file> [--personal]` — one of the\n * team's own agents, or the caller's personal one, from the same\n * `agent.json` (+ `AGENT.md`, + `skills/<slug>/` folders) that `ekanos\n * agents apply` reads for a Source template, read by the same loader.\n *\n * Why two verbs: `apply` is `agents apply` at team level — it creates the\n * agent when there is none and changes it when there is, refusing a change\n * made since the version you name (`--base-version`, the version `teams\n * agents show` reports; `--overwrite` replaces it anyway), so a CI job or\n * an agent can run it again and again. `create` is the same request that\n * only ever makes a new agent: it never names a version, so an agent that\n * exists already is refused rather than changed. The file's own\n * `baseVersion` is a template version and is never sent here.\n *\n * Creating makes you the agent's creator — its tools run as you, and a\n * personal one acts for you on every trigger — so you must be an active\n * member of the team. A personal agent is yours alone to change.\n */\nexport async function runTeamAgentDefine(\n ctx: CliContext,\n run: TeamAgentRun,\n verb: 'create' | 'apply',\n): Promise<ExitCode> {\n const team = requireOperand(run.operands[0], 'team slug', 'agents');\n const from = flagString(run, 'from');\n const positional = run.operands[1];\n if (run.operands.length > 2 || (from && positional)) {\n throw usageError(\n `teams agents ${verb} takes the team and one agent directory or file.`,\n usageFor('agents'),\n );\n }\n const target = from ?? positional;\n if (!target) {\n throw usageError(\n `teams agents ${verb} needs an agent directory or agent.json.`,\n verb === 'create'\n ? `e.g. ekanos teams agents create ${team} --from agents/triage [--personal]`\n : `e.g. ekanos teams agents apply ${team} agents/triage --base-version 3`,\n );\n }\n\n const personal = run.args.flags?.personal === true;\n const overwrite = run.args.flags?.overwrite === true;\n const baseVersion = parseBaseVersion(flagString(run, 'base-version'));\n if (verb === 'create' && (baseVersion !== null || overwrite)) {\n throw usageError(\n 'create only makes a new agent, so it takes no --base-version or --overwrite.',\n `Change an existing one with: ekanos teams agents apply ${team} ${target} --base-version <n>`,\n );\n }\n\n // Read the local input before any network call, so a bad file fails fast.\n const input = readAgentInput(target, run.args.dir);\n const pushSkills = run.args.flags?.skills !== false;\n const folders =\n input.file && pushSkills\n ? findAgentSkillFolders(path.dirname(input.file)).map((dir) =>\n readSkillFolder(dir, run.args.dir),\n )\n : [];\n const body = withLocalSkills(\n teamAgentBody(input.body, input.file ?? target),\n folders.map((folder) => folder.slug),\n );\n\n // The skills first, so the agent can name them: the team's own level.\n const pushed = [];\n for (const folder of folders) {\n pushed.push(\n await pushSkillFolder(run.skills, run.host, {\n source: run.source,\n team,\n folder,\n }),\n );\n }\n\n const request: TeamAgentApplyRequest = {\n key: input.key,\n ownership: personal ? 'personal' : 'team',\n body,\n baseVersion,\n overwrite,\n ...(run.args.flags?.['confirm-access'] === true\n ? { confirmAccess: true }\n : {}),\n };\n const result = await run.client.call((token) =>\n call(run.host, token, TeamAgentApplyResultSchema, {\n method: 'POST',\n path: `/api/partner/teams/${encodeURIComponent(team)}/agents`,\n source: run.source,\n body: request,\n }),\n );\n\n return ctx.succeed(\n { host: run.host, ...result, skillsPushed: pushed },\n [\n ...pushed.map((entry) => pushSummary(ctx.ui, entry)),\n describeResult(ctx, result, run.source),\n ].join('\\n\\n'),\n );\n}\n\n/**\n * The definition fields of a template body. A field that sets a template up\n * on every team's copy is refused rather than dropped, so a file never\n * reads as doing something it does not.\n */\nexport function teamAgentBody(\n body: AgentTemplateBody,\n file: string,\n): TeamAgentBody {\n const set = TEMPLATE_ONLY_AGENT_FIELDS.filter((field) => {\n const value = body[field];\n if (value === undefined) return false;\n if (Array.isArray(value)) return value.length > 0;\n return Object.values(value).some((entry) => entry !== false);\n });\n if (set.length > 0) {\n throw validationError(\n `${file} sets ${set.join(', ')}, which only a Source template has: they say how it is set up on every team's copy.`,\n 'Drop them for a team or personal agent. Add its triggers with \"ekanos teams triggers add <team> <key> schedule|webhook …\", or publish it to every team with \"ekanos agents apply\".',\n );\n }\n return TeamAgentBodySchema.parse({\n name: body.name,\n description: body.description,\n instructions: body.instructions,\n model: body.model,\n maxTurns: body.maxTurns,\n tools: body.tools,\n policy: body.policy,\n skills: body.skills,\n });\n}\n\n/** The agent's skills plus the folders beside it, which it uses by being there. */\nfunction withLocalSkills(body: TeamAgentBody, slugs: string[]): TeamAgentBody {\n const skills = [...body.skills];\n for (const slug of slugs) if (!skills.includes(slug)) skills.push(slug);\n if (skills.length > 50) {\n throw validationError(\n `The agent would name ${skills.length} skills (with its ${AGENT_SKILLS_DIR}/ folders); the limit is 50.`,\n 'Drop some, or pass --no-skills and list them in agent.json.',\n );\n }\n return { ...body, skills };\n}\n\nfunction describeResult(\n ctx: CliContext,\n result: TeamAgentApplyResult,\n source: string,\n): string {\n const team = result.team.slug;\n const personal = result.ownership === 'personal';\n const title =\n result.outcome === 'created'\n ? `Created ${personal ? 'your personal agent' : 'agent'} ${result.slug} on ${team}`\n : result.outcome === 'updated'\n ? `Updated ${result.slug} on ${team} to v${result.version}`\n : `${result.slug} on ${team} already matches the file`;\n const rows: ResultRow[] = [\n ['Agent', `${result.name} (${result.slug})`],\n ['Owned by', personal ? `${result.createdBy ?? 'you'} alone` : 'the team'],\n ['Identity', identityLabel(result.createdBy, personal)],\n ['Version', `v${result.version}`],\n ['Status', result.status],\n ['Skills', result.skills.length > 0 ? result.skills.join(', ') : 'none'],\n [\n 'Access',\n `${describeConnections(result.access, result.createdBy)} — ${result.accessConfirmed ? 'confirmed' : 'not confirmed'}`,\n ],\n ];\n const next: string[] = [];\n if (!result.accessConfirmed) {\n next.push(\n `Until someone who sets it up confirms what it may use, it runs only the tools that need no confirmation: ekanos teams agents confirm ${team} ${result.slug} --source ${source}`,\n );\n }\n if (result.status !== 'active') {\n next.push(\n `It is ${result.status}: turn it on with ekanos teams agents enable ${team} ${result.slug} --source ${source}`,\n );\n }\n next.push(\n `Start it from a schedule or a webhook: ekanos teams triggers add ${team} ${result.slug} schedule --cron \"0 9 * * 1-5\" --prompt \"…\"`,\n );\n if (personal) {\n next.push(\n 'It acts for you, with your own connections, on every trigger: only you change it, run it, decide its approvals or cancel its runs.',\n );\n }\n return ctx.ui.result({\n title,\n tone:\n result.outcome === 'unchanged' || !result.accessConfirmed ? 'warn' : 'ok',\n rows,\n notes: [\n ...next,\n `Change it later from the same file: ekanos teams agents apply ${team} <dir> --base-version ${result.version}${personal ? ' --personal' : ''}`,\n ],\n });\n}\n\nfunction parseBaseVersion(value: string | undefined): number | null {\n if (value === undefined) return null;\n const version = Number(value);\n if (Number.isInteger(version) && version >= 1) return version;\n throw usageError(\n `--base-version must be a version number (got \"${value}\").`,\n '\"ekanos teams agents show <team> <key>\" shows the version.',\n );\n}\n\nfunction flagString(run: TeamAgentRun, name: string): string | undefined {\n const value = run.args.flags?.[name];\n return typeof value === 'string' && value.trim() ? value.trim() : undefined;\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import { type TeamIntegrationStatus } from '@ekanos/integration-schema';
2
2
  import type { CliContext } from '../context.js';
3
3
  import type { ExitCode } from '../exit-codes.js';
4
+ import { type TeamConnectPlan } from '../team-connect-api.js';
4
5
  import { type TeamsArgs, type TeamsClient } from './teams.js';
5
6
  /**
6
7
  * `teams connect <team> <product>` — connect a product for one team, doing
@@ -59,8 +60,12 @@ export declare function channelsToInstall(status: TeamIntegrationStatus): {
59
60
  name: string | null;
60
61
  email: string | null;
61
62
  } | null;
63
+ level?: "source" | "team" | "user" | undefined;
64
+ personal?: boolean | undefined;
65
+ membersConnected?: number | null | undefined;
62
66
  neededBy: {
63
67
  agent: string;
64
68
  triggers: string[];
65
69
  }[];
66
70
  }[];
71
+ export declare function statusOf(plan: TeamConnectPlan, named?: boolean): string;
@@ -73,7 +73,7 @@ export async function runTeamConnect(ctx, args, client, host, source, input) {
73
73
  }
74
74
  switch (plan.mode) {
75
75
  case 'not-entitled':
76
- throw invalidStateError((_b = plan.reason) !== null && _b !== void 0 ? _b : `"${input.product}" is not enabled on ${plan.source.slug}.`, `Enable it for the Source first: "ekanos sources products enable ${input.product}" as a Source admin if ${plan.source.slug} built it, otherwise Ekanos. "ekanos sources products" shows what ${plan.source.slug} has.`);
76
+ throw invalidStateError((_b = plan.reason) !== null && _b !== void 0 ? _b : `"${input.product}" is not enabled on ${plan.source.slug}.`, `Enable it for the Source first: "ekanos sources products enable ${input.product}" as a Source admin, for an integration ${plan.source.slug} built or a global release; Ekanos enables anything else. "ekanos sources products" shows what ${plan.source.slug} has.`);
77
77
  case 'not-self-serve':
78
78
  throw invalidStateError((_c = plan.reason) !== null && _c !== void 0 ? _c : `${name} is not connected by a team.`, plan.product.kind === 'feature' || plan.product.kind === 'experience'
79
79
  ? `"ekanos sources products --source ${plan.source.slug}" shows whether it is on for the Source.`
@@ -454,20 +454,28 @@ async function enterFields(ctx, args, plan, again) {
454
454
  }
455
455
  /** `--link-only`: the team's page and whether it is connected. */
456
456
  async function printLink(ctx, client, host, target) {
457
- var _a;
457
+ var _a, _b;
458
+ var _c;
458
459
  const status = await client.call((token) => showTeamIntegration(host, token, target));
459
460
  if (!status.enabled) {
460
- throw invalidStateError(`"${target.product}" is not enabled on ${status.source.slug}.`, `"ekanos sources products --source ${status.source.slug}" shows what this Source has; Ekanos enables a product for a Source.`);
461
+ throw invalidStateError(`"${target.product}" is not enabled on ${status.source.slug}.`, `"ekanos sources products --source ${status.source.slug}" shows what this Source has. A Source admin enables an integration the Source built or a global release with "ekanos sources products enable ${target.product}"; Ekanos enables anything else.`);
461
462
  }
462
- const connected = status.activation !== null;
463
+ // A hosted sign-in is connected by its main connection, and a per-person
464
+ // one by the caller's own; the activation row then holds only settings.
465
+ const main = (_a = status.connections) === null || _a === void 0 ? void 0 : _a.find((entry) => entry.connectionId === 'default');
466
+ const connected = main ? main.connected : status.activation !== null;
467
+ const connectedAt = main
468
+ ? main.connectedAt
469
+ : ((_c = (_b = status.activation) === null || _b === void 0 ? void 0 : _b.activatedAt) !== null && _c !== void 0 ? _c : null);
463
470
  const rows = [
464
471
  ['Open', status.connectUrl],
465
472
  [
466
473
  'Status',
467
- connected
468
- ? `connected${((_a = status.activation) === null || _a === void 0 ? void 0 : _a.activatedAt) ? ` ${status.activation.activatedAt.slice(0, 10)}` : ''}`
469
- : 'not connected',
474
+ `${(main === null || main === void 0 ? void 0 : main.personal) ? 'yours ' : ''}${connected ? `connected${connectedAt ? ` ${connectedAt.slice(0, 10)}` : ''}` : 'not connected'}`,
470
475
  ],
476
+ ...((main === null || main === void 0 ? void 0 : main.personal) && typeof main.membersConnected === 'number'
477
+ ? [['Members connected', String(main.membersConnected)]]
478
+ : []),
471
479
  ];
472
480
  return ctx.succeed(Object.assign({ host }, status), ctx.ui.result({
473
481
  title: connected
@@ -481,9 +489,15 @@ async function printLink(ctx, client, host, target) {
481
489
  ],
482
490
  }));
483
491
  }
484
- function statusOf(plan, named = false) {
485
- if (!plan.connected)
486
- return named ? 'not installed' : 'not connected';
487
- return `${named ? 'installed' : 'connected'}${plan.connectedAt ? ` ${plan.connectedAt.slice(0, 10)}` : ''}`;
492
+ export function statusOf(plan, named = false) {
493
+ var _a;
494
+ // A personal connection is the member's own, never the team's.
495
+ const whose = plan.scope === 'user'
496
+ ? `${((_a = plan.member) === null || _a === void 0 ? void 0 : _a.isCaller) === false ? 'theirs' : 'yours'} `
497
+ : '';
498
+ if (!plan.connected) {
499
+ return `${whose}${named ? 'not installed' : 'not connected'}`;
500
+ }
501
+ return `${whose}${named ? 'installed' : 'connected'}${plan.connectedAt ? ` ${plan.connectedAt.slice(0, 10)}` : ''}`;
488
502
  }
489
503
  //# sourceMappingURL=teams-connect.js.map
@@ -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;AAEpC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEjE,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE3E,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAGL,eAAe,EACf,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,UAAU,EAA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\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 Ekanos. \"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 === 'feature' || 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; Ekanos 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,WAAW,CAAC;AAE3E,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,aAA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,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AACtH,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, for an integration ${plan.source.slug} built or a global release; Ekanos enables anything else. \"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 === 'feature' || 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 Source admin enables an integration the Source built or a global release with \"ekanos sources products enable ${target.product}\"; Ekanos enables anything else.`,\n );\n }\n // A hosted sign-in is connected by its main connection, and a per-person\n // one by the caller's own; the activation row then holds only settings.\n const main = status.connections?.find(\n (entry) => entry.connectionId === 'default',\n );\n const connected = main ? main.connected : status.activation !== null;\n const connectedAt = main\n ? main.connectedAt\n : (status.activation?.activatedAt ?? null);\n const rows: ResultRow[] = [\n ['Open', status.connectUrl],\n [\n 'Status',\n `${main?.personal ? 'yours ' : ''}${connected ? `connected${connectedAt ? ` ${connectedAt.slice(0, 10)}` : ''}` : 'not connected'}`,\n ],\n ...(main?.personal && typeof main.membersConnected === 'number'\n ? ([['Members connected', String(main.membersConnected)]] as ResultRow[])\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\nexport function statusOf(plan: TeamConnectPlan, named = false): string {\n // A personal connection is the member's own, never the team's.\n const whose =\n plan.scope === 'user'\n ? `${plan.member?.isCaller === false ? 'theirs' : 'yours'} `\n : '';\n if (!plan.connected) {\n return `${whose}${named ? 'not installed' : 'not connected'}`;\n }\n return `${whose}${named ? 'installed' : 'connected'}${plan.connectedAt ? ` ${plan.connectedAt.slice(0, 10)}` : ''}`;\n}\n"]}
@@ -138,7 +138,7 @@ export async function runTeams(ctx, args) {
138
138
  return ctx.succeed(Object.assign({ host: env.host }, status), checklist(status).join('\n'));
139
139
  }
140
140
  if (!status.enabled) {
141
- throw invalidStateError(`"${product}" is not enabled on ${status.source.slug}.`, `"ekanos sources products --source ${status.source.slug}" shows what it has; only Ekanos enables a product for a Source.`);
141
+ throw invalidStateError(`"${product}" is not enabled on ${status.source.slug}.`, `"ekanos sources products --source ${status.source.slug}" shows what it has. A Source admin enables an integration the Source built or a global release with "ekanos sources products enable ${product}"; Ekanos enables anything else.`);
142
142
  }
143
143
  if (subcommand === 'app' && appEdits) {
144
144
  return setApp(ctx, args, client, env.host, target, status, appEdits);
@@ -348,6 +348,7 @@ async function mintWebhook(ctx, args, client, host, target, status, requested) {
348
348
  /** `teams show`, read top to bottom like a setup checklist. */
349
349
  export function checklist(status) {
350
350
  var _a, _b;
351
+ var _c;
351
352
  const name = status.product.name;
352
353
  const lines = [
353
354
  `${name} for team ${status.team.slug} (${status.team.name}) on ${status.source.slug}`,
@@ -388,9 +389,16 @@ export function checklist(status) {
388
389
  ? ` ${mark(true)} Connected ${day(app.connection.connectedAt)}${app.connection.connectedBy ? ` by ${who(app.connection.connectedBy)}` : ''}`
389
390
  : ` ${mark(false)} Connected: not yet\n → in your terminal: ${connectCommand(status, app.connectionId)}`);
390
391
  }
391
- lines.push(status.activation
392
- ? ` ${mark(true)} Activated for the team${status.activation.activatedAt ? ` ${day(status.activation.activatedAt)}` : ''}${status.activation.activatedBy ? ` by ${who(status.activation.activatedBy)}` : ''}`
393
- : ` ${mark(false)} Activated: not yet\n → in your terminal: ${connectCommand(status)}`);
392
+ // A hosted sign-in's main connection is what connects it (its line is
393
+ // above); the team's activation row beside it holds only its settings.
394
+ const signsIn = ((_c = status.connections) !== null && _c !== void 0 ? _c : []).some((entry) => entry.connectionId === 'default');
395
+ lines.push(signsIn
396
+ ? status.activation
397
+ ? ` ${mark(true)} Team settings saved${status.activation.activatedAt ? ` ${day(status.activation.activatedAt)}` : ''}${status.activation.activatedBy ? ` by ${who(status.activation.activatedBy)}` : ''}`
398
+ : ` · Team settings: none saved`
399
+ : status.activation
400
+ ? ` ${mark(true)} Activated for the team${status.activation.activatedAt ? ` ${day(status.activation.activatedAt)}` : ''}${status.activation.activatedBy ? ` by ${who(status.activation.activatedBy)}` : ''}`
401
+ : ` ${mark(false)} Activated: not yet\n → in your terminal: ${connectCommand(status)}`);
394
402
  lines.push(` Team page: ${status.connectUrl}`);
395
403
  if (status.agentEvents.length > 0) {
396
404
  lines.push(' Agent events it offers:');
@@ -406,7 +414,7 @@ export function checklist(status) {
406
414
  * and on, and nothing ever reaches it.
407
415
  */
408
416
  function connectionLines(status) {
409
- var _a, _b, _c, _d;
417
+ var _a, _b, _c, _d, _e;
410
418
  const connections = (_a = status.connections) !== null && _a !== void 0 ? _a : [];
411
419
  if (connections.length === 0)
412
420
  return [];
@@ -421,13 +429,22 @@ function connectionLines(status) {
421
429
  : [
422
430
  `app credentials ${entry.credentialsSaved ? 'saved' : 'not saved'}`,
423
431
  ]),
424
- named
432
+ entry.personal
425
433
  ? entry.connected
426
- ? `installed ${day((_c = entry.connectedAt) !== null && _c !== void 0 ? _c : '')}`
427
- : 'not installed'
428
- : entry.connected
429
- ? `connected ${day((_d = entry.connectedAt) !== null && _d !== void 0 ? _d : '')}`
430
- : 'not connected',
434
+ ? `yours connected ${day((_c = entry.connectedAt) !== null && _c !== void 0 ? _c : '')}`
435
+ : 'yours not connected'
436
+ : named
437
+ ? entry.connected
438
+ ? `installed ${day((_d = entry.connectedAt) !== null && _d !== void 0 ? _d : '')}`
439
+ : 'not installed'
440
+ : entry.connected
441
+ ? `connected ${day((_e = entry.connectedAt) !== null && _e !== void 0 ? _e : '')}`
442
+ : 'not connected',
443
+ ...(entry.personal && typeof entry.membersConnected === 'number'
444
+ ? [
445
+ `${entry.membersConnected} ${entry.membersConnected === 1 ? 'member has' : 'members have'} connected their own`,
446
+ ]
447
+ : []),
431
448
  ...(webhooks.length > 0
432
449
  ? [
433
450
  webhooks.every((webhook) => webhook.endpoint)
@@ -439,7 +456,7 @@ function connectionLines(status) {
439
456
  const ready = entry.connected &&
440
457
  entry.credentialsSaved !== false &&
441
458
  webhooks.every((webhook) => webhook.endpoint);
442
- lines.push(` ${mark(ready)} ${entry.label} (${entry.connectionId}): ${steps.join(' · ')}${entry.connectedBy ? ` by ${who(entry.connectedBy)}` : ''}`);
459
+ lines.push(` ${mark(ready)} ${entry.label} (${entry.connectionId}${entry.personal ? ', personal: each member signs in for themselves' : ''}): ${steps.join(' · ')}${entry.connectedBy && !entry.personal ? ` by ${who(entry.connectedBy)}` : ''}`);
443
460
  if (entry.neededBy.length > 0) {
444
461
  lines.push(` Needed by: ${entry.neededBy.map((need) => `${need.agent} (${need.triggers.join(', ')})`).join(', ')}`);
445
462
  }