@ekanos/cli 0.34.0 → 0.35.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 (36) hide show
  1. package/README.md +2 -1
  2. package/dist/commands/index-experience.js +2 -0
  3. package/dist/commands/index-experience.js.map +1 -1
  4. package/dist/commands/migrate.d.ts +2 -0
  5. package/dist/commands/migrate.js +180 -0
  6. package/dist/commands/migrate.js.map +1 -0
  7. package/dist/commands/status.js +18 -2
  8. package/dist/commands/status.js.map +1 -1
  9. package/dist/commands/team-agents.d.ts +1 -1
  10. package/dist/commands/team-agents.js +6 -0
  11. package/dist/commands/team-agents.js.map +1 -1
  12. package/dist/commands/team-api-keys.d.ts +4 -0
  13. package/dist/commands/team-api-keys.js +277 -0
  14. package/dist/commands/team-api-keys.js.map +1 -0
  15. package/dist/commands/teams.js +1 -1
  16. package/dist/commands/teams.js.map +1 -1
  17. package/dist/host-load.d.ts +8 -0
  18. package/dist/host-load.js +115 -0
  19. package/dist/host-load.js.map +1 -0
  20. package/dist/index.js +16 -3
  21. package/dist/index.js.map +1 -1
  22. package/dist/migrate-connection.d.ts +29 -0
  23. package/dist/migrate-connection.js +569 -0
  24. package/dist/migrate-connection.js.map +1 -0
  25. package/dist/teams-api.js +6 -0
  26. package/dist/teams-api.js.map +1 -1
  27. package/dist/validate-findings.js +5 -1
  28. package/dist/validate-findings.js.map +1 -1
  29. package/loader/declaration-loader.hooks.mjs +187 -0
  30. package/loader/host-load-probe.mjs +20 -0
  31. package/loader/register-declaration-loader.mjs +3 -0
  32. package/package.json +5 -4
  33. package/templates/AGENTS.md.tmpl +17 -3
  34. package/templates/experience/package.json.tmpl +4 -4
  35. package/templates/package.json.tmpl +4 -4
  36. package/templates/skills/build-integration/references/oauth-setup.md +3 -3
@@ -5,6 +5,7 @@ import { SkillsClient } from './skills.js';
5
5
  import { runTeamAgentsArea } from './team-agents-agents.js';
6
6
  import { runTeamMcp } from './team-agents-mcp.js';
7
7
  import { runTeamLinks, runTeamTriggers } from './team-agents-triggers.js';
8
+ import { runTeamApiKeys } from './team-api-keys.js';
8
9
  import { runTeamLlmKey } from './team-llm-key.js';
9
10
  import { TeamsClient } from './teams.js';
10
11
  export const TEAM_AGENT_AREAS = [
@@ -13,6 +14,7 @@ export const TEAM_AGENT_AREAS = [
13
14
  'links',
14
15
  'mcp',
15
16
  'llm-key',
17
+ 'api-keys',
16
18
  ];
17
19
  export function isTeamAgentArea(value) {
18
20
  return TEAM_AGENT_AREAS.some((area) => area === value);
@@ -51,6 +53,8 @@ export async function runTeamAgentCommands(ctx, args) {
51
53
  return runTeamMcp(ctx, run);
52
54
  case 'llm-key':
53
55
  return runTeamLlmKey(ctx, run);
56
+ case 'api-keys':
57
+ return runTeamApiKeys(ctx, run);
54
58
  }
55
59
  }
56
60
  export function usageFor(area) {
@@ -65,6 +69,8 @@ export function usageFor(area) {
65
69
  return 'Run one of: ekanos teams mcp list <team> | add <team> <server-key> --url <url> [--auth none|token|oauth] [--name <name>] | status <team> <server-key> | token <team> <server-key> (hidden input at your terminal, or --secret-env|--secret-file|--secret-stdin|--browser) | effect <team> <server-key> <tool> read|write | refresh <team> <server-key> (or --agent <agent-key>: every server it has) | attach <team> <server-key> <agent-key> | detach <team> <server-key> <agent-key> [--yes] | remove <team> <server-key> --yes.';
66
70
  case 'llm-key':
67
71
  return "Run one of: ekanos teams llm-key show <team> (provider, and the key's last four characters if one is saved) | set <team> (hidden input at your terminal, or --secret-env|--secret-file|--secret-stdin|--browser) | remove <team> --yes.";
72
+ case 'api-keys':
73
+ return 'Run one of: ekanos teams api-keys list <team> | create <team> --name <name> --products <slug,slug> [--tools <name,name>] [--expires <ISO date>] (alone, --products grants every read-only tool of those products; --tools grants only the named ones, a write tool included; the secret saved to a 0600 file, never printed) | rotate <team> <key-id> [--yes] (a new secret, the old one revoked) | revoke <team> <key-id> [--yes].';
68
74
  }
69
75
  }
70
76
  function withTeamFlag(operands, flag) {
@@ -1 +1 @@
1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uB,KAAK,UAAU;YACb,OAAO,+kBAA+kB,CAAC;QACzlB,KAAK,OAAO;YACV,OAAO,gPAAgP,CAAC;QAC1P,KAAK,KAAK;YACR,OAAO,ogBAAogB,CAAC;QAC9gB,KAAK,SAAS;YACZ,OAAO,yOAAyO,CAAC;IACrP,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CACnB,QAA2B,EAC3B,IAA6C;;IAE7C,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAC;IACxC,MAAM,IAAI,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACvE,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,UAAU,CAAC,2BAA2B,EAAE,oBAAoB,CAAC,CAAC;IACtE,CAAC;IACD,OAAO,CAAA,MAAA,QAAQ,CAAC,CAAC,CAAC,0CAAE,IAAI,GAAG,WAAW,EAAE,MAAK,IAAI;QAC/C,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,KAAyB,EACzB,IAAY,EACZ,IAAmB;IAEnB,MAAM,IAAI,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,GAAG,WAAW,EAAE,CAAC;IACzC,IAAI,IAAI,IAAI,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAC3D,MAAM,UAAU,CACd,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,cAAc,IAAI,GAAG,CAAC,CAAC,CAAC,YAAY,IAAI,GAAG,EAC5D,QAAQ,CAAC,IAAI,CAAC,CACf,CAAC;AACJ,CAAC","sourcesContent":["import { requireSession, resolveAuthEnvironment } from '../auth/session';\nimport type { CliContext } from '../context';\nimport { usageError } from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { resolveSourceTarget } from '../source-target';\nimport { SkillsClient } from './skills';\nimport { runTeamAgentsArea } from './team-agents-agents';\nimport { runTeamMcp } from './team-agents-mcp';\nimport { runTeamLinks, runTeamTriggers } from './team-agents-triggers';\nimport { runTeamLlmKey } from './team-llm-key';\nimport { TeamsClient, type TeamsArgs } from './teams';\n\nexport const TEAM_AGENT_AREAS = [\n 'agents',\n 'triggers',\n 'links',\n 'mcp',\n 'llm-key',\n] as const;\nexport type TeamAgentArea = (typeof TEAM_AGENT_AREAS)[number];\n\nexport function isTeamAgentArea(\n value: string | undefined,\n): value is TeamAgentArea {\n return TEAM_AGENT_AREAS.some((area) => area === value);\n}\n\nexport interface TeamAgentRun {\n args: TeamsArgs;\n client: TeamsClient;\n skills: SkillsClient;\n host: string;\n source: string;\n verb: string;\n operands: readonly string[];\n}\n\nexport async function runTeamAgentCommands(\n ctx: CliContext,\n args: TeamsArgs,\n): Promise<ExitCode> {\n const [area, verb, ...positional] = args.positionals;\n if (!isTeamAgentArea(area)) {\n throw usageError(\n `Unknown teams area \"${area ?? ''}\".`,\n 'See \"ekanos teams --help\".',\n );\n }\n if (!verb) {\n throw usageError(`teams ${area} needs a subcommand.`, usageFor(area));\n }\n const operands = withTeamFlag(positional, args.flags?.team);\n\n const env = resolveAuthEnvironment(ctx, args.host, args.env, {\n projectDir: args.dir,\n });\n const resolved = await resolveSourceTarget(env, requireSession(env), args);\n const run: TeamAgentRun = {\n args,\n client: new TeamsClient(env, resolved.session),\n skills: new SkillsClient(env, resolved.session),\n host: env.host,\n source: resolved.source,\n verb,\n operands,\n };\n\n switch (area) {\n case 'agents':\n return runTeamAgentsArea(ctx, run);\n case 'triggers':\n return runTeamTriggers(ctx, run);\n case 'links':\n return runTeamLinks(ctx, run);\n case 'mcp':\n return runTeamMcp(ctx, run);\n case 'llm-key':\n return runTeamLlmKey(ctx, run);\n }\n}\n\nexport function usageFor(area: TeamAgentArea): string {\n switch (area) {\n case 'agents':\n return 'Run one of: ekanos teams agents list <team> | show <team> <key> | create <team> --from <dir|agent.json> [--personal] [--confirm-access] [--no-skills] | apply <team> <dir|agent.json> [--personal] [--base-version <n>] [--overwrite] [--confirm-access] [--no-skills] | enable <team> <key> [--as <member-email>] [--draft] [--confirm-access] | confirm <team> <key> | disable <team> <key> --yes | archive <team> <key> [--yes] | unarchive <team> <key> | pin <team> <key> <version> | pin <team> <key> --draft | unpin <team> <key> | policy <team> <key> [set <tool> auto|approve | unset <tool> | --reads auto|approve --writes auto|approve] [--confirm-access] | skills <team> <key> [add|remove <skill>] | tags <team> <key> [add|remove <tag>].';\n case 'triggers':\n return 'Run one of: ekanos teams triggers list <team> <key> | add <team> <key> <manual|schedule|webhook|event|slack|linear> … (a personal agent: schedule or webhook, its creator only) | remove <team> <key> <trigger-id|key> --yes | rotate <team> <key> <trigger-key|id> [--yes] | enable <team> <key> <trigger-id|key> | disable <team> <key> <trigger-id|key> [--yes] | edit <team> <key> <trigger-id|key> [--prompt <text>] [--cron <expr>] [--timezone <zone>] [--filter …] [--channel <#name|id>…] [--dms|--no-dms] [--label <name>…] [--mention|--no-mention] (in place: a webhook keeps its URL and token).';\n case 'links':\n return 'Run one of: ekanos teams links list <team> <key> | add <team> <from-key> <to-key> --kind talk|delegate [--mode await|handoff] | remove <team> <from-key> <link-id|to-key> [--kind talk|delegate] --yes. The team may be --team <slug> instead.';\n case 'mcp':\n return 'Run one of: ekanos teams mcp list <team> | add <team> <server-key> --url <url> [--auth none|token|oauth] [--name <name>] | status <team> <server-key> | token <team> <server-key> (hidden input at your terminal, or --secret-env|--secret-file|--secret-stdin|--browser) | effect <team> <server-key> <tool> read|write | refresh <team> <server-key> (or --agent <agent-key>: every server it has) | attach <team> <server-key> <agent-key> | detach <team> <server-key> <agent-key> [--yes] | remove <team> <server-key> --yes.';\n case 'llm-key':\n return \"Run one of: ekanos teams llm-key show <team> (provider, and the key's last four characters if one is saved) | set <team> (hidden input at your terminal, or --secret-env|--secret-file|--secret-stdin|--browser) | remove <team> --yes.\";\n }\n}\n\nfunction withTeamFlag(\n operands: readonly string[],\n flag: string | boolean | string[] | undefined,\n): readonly string[] {\n if (flag === undefined) return operands;\n const team = typeof flag === 'string' ? flag.trim().toLowerCase() : '';\n if (!team) {\n throw usageError('--team needs a team slug.', 'e.g. --team bank-a');\n }\n return operands[0]?.trim().toLowerCase() === team\n ? operands\n : [team, ...operands];\n}\n\nexport function requireOperand(\n value: string | undefined,\n what: string,\n area: TeamAgentArea,\n): string {\n const slug = value?.trim().toLowerCase();\n if (slug && /^[a-z0-9][a-z0-9-]*$/.test(slug)) return slug;\n throw usageError(\n value ? `\"${value}\" is not a ${what}.` : `Name the ${what}.`,\n usageFor(area),\n );\n}\n"]}
1
+ {"version":3,"file":"team-agents.js","sourceRoot":"","sources":["../../src/commands/team-agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEzE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAkB,MAAM,SAAS,CAAC;AAEtD,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,QAAQ;IACR,UAAU;IACV,OAAO;IACP,KAAK;IACL,SAAS;IACT,UAAU;CACF,CAAC;AAGX,MAAM,UAAU,eAAe,CAC7B,KA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AC,CAAC,CAAC,0CAAE,IAAI,GAAG,WAAW,EAAE,MAAK,IAAI;QAC/C,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,KAAyB,EACzB,IAAY,EACZ,IAAmB;IAEnB,MAAM,IAAI,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,GAAG,WAAW,EAAE,CAAC;IACzC,IAAI,IAAI,IAAI,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAC3D,MAAM,UAAU,CACd,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,cAAc,IAAI,GAAG,CAAC,CAAC,CAAC,YAAY,IAAI,GAAG,EAC5D,QAAQ,CAAC,IAAI,CAAC,CACf,CAAC;AACJ,CAAC","sourcesContent":["import { requireSession, resolveAuthEnvironment } from '../auth/session';\nimport type { CliContext } from '../context';\nimport { usageError } from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { resolveSourceTarget } from '../source-target';\nimport { SkillsClient } from './skills';\nimport { runTeamAgentsArea } from './team-agents-agents';\nimport { runTeamMcp } from './team-agents-mcp';\nimport { runTeamLinks, runTeamTriggers } from './team-agents-triggers';\nimport { runTeamApiKeys } from './team-api-keys';\nimport { runTeamLlmKey } from './team-llm-key';\nimport { TeamsClient, type TeamsArgs } from './teams';\n\nexport const TEAM_AGENT_AREAS = [\n 'agents',\n 'triggers',\n 'links',\n 'mcp',\n 'llm-key',\n 'api-keys',\n] as const;\nexport type TeamAgentArea = (typeof TEAM_AGENT_AREAS)[number];\n\nexport function isTeamAgentArea(\n value: string | undefined,\n): value is TeamAgentArea {\n return TEAM_AGENT_AREAS.some((area) => area === value);\n}\n\nexport interface TeamAgentRun {\n args: TeamsArgs;\n client: TeamsClient;\n skills: SkillsClient;\n host: string;\n source: string;\n verb: string;\n operands: readonly string[];\n}\n\nexport async function runTeamAgentCommands(\n ctx: CliContext,\n args: TeamsArgs,\n): Promise<ExitCode> {\n const [area, verb, ...positional] = args.positionals;\n if (!isTeamAgentArea(area)) {\n throw usageError(\n `Unknown teams area \"${area ?? ''}\".`,\n 'See \"ekanos teams --help\".',\n );\n }\n if (!verb) {\n throw usageError(`teams ${area} needs a subcommand.`, usageFor(area));\n }\n const operands = withTeamFlag(positional, args.flags?.team);\n\n const env = resolveAuthEnvironment(ctx, args.host, args.env, {\n projectDir: args.dir,\n });\n const resolved = await resolveSourceTarget(env, requireSession(env), args);\n const run: TeamAgentRun = {\n args,\n client: new TeamsClient(env, resolved.session),\n skills: new SkillsClient(env, resolved.session),\n host: env.host,\n source: resolved.source,\n verb,\n operands,\n };\n\n switch (area) {\n case 'agents':\n return runTeamAgentsArea(ctx, run);\n case 'triggers':\n return runTeamTriggers(ctx, run);\n case 'links':\n return runTeamLinks(ctx, run);\n case 'mcp':\n return runTeamMcp(ctx, run);\n case 'llm-key':\n return runTeamLlmKey(ctx, run);\n case 'api-keys':\n return runTeamApiKeys(ctx, run);\n }\n}\n\nexport function usageFor(area: TeamAgentArea): string {\n switch (area) {\n case 'agents':\n return 'Run one of: ekanos teams agents list <team> | show <team> <key> | create <team> --from <dir|agent.json> [--personal] [--confirm-access] [--no-skills] | apply <team> <dir|agent.json> [--personal] [--base-version <n>] [--overwrite] [--confirm-access] [--no-skills] | enable <team> <key> [--as <member-email>] [--draft] [--confirm-access] | confirm <team> <key> | disable <team> <key> --yes | archive <team> <key> [--yes] | unarchive <team> <key> | pin <team> <key> <version> | pin <team> <key> --draft | unpin <team> <key> | policy <team> <key> [set <tool> auto|approve | unset <tool> | --reads auto|approve --writes auto|approve] [--confirm-access] | skills <team> <key> [add|remove <skill>] | tags <team> <key> [add|remove <tag>].';\n case 'triggers':\n return 'Run one of: ekanos teams triggers list <team> <key> | add <team> <key> <manual|schedule|webhook|event|slack|linear> … (a personal agent: schedule or webhook, its creator only) | remove <team> <key> <trigger-id|key> --yes | rotate <team> <key> <trigger-key|id> [--yes] | enable <team> <key> <trigger-id|key> | disable <team> <key> <trigger-id|key> [--yes] | edit <team> <key> <trigger-id|key> [--prompt <text>] [--cron <expr>] [--timezone <zone>] [--filter …] [--channel <#name|id>…] [--dms|--no-dms] [--label <name>…] [--mention|--no-mention] (in place: a webhook keeps its URL and token).';\n case 'links':\n return 'Run one of: ekanos teams links list <team> <key> | add <team> <from-key> <to-key> --kind talk|delegate [--mode await|handoff] | remove <team> <from-key> <link-id|to-key> [--kind talk|delegate] --yes. The team may be --team <slug> instead.';\n case 'mcp':\n return 'Run one of: ekanos teams mcp list <team> | add <team> <server-key> --url <url> [--auth none|token|oauth] [--name <name>] | status <team> <server-key> | token <team> <server-key> (hidden input at your terminal, or --secret-env|--secret-file|--secret-stdin|--browser) | effect <team> <server-key> <tool> read|write | refresh <team> <server-key> (or --agent <agent-key>: every server it has) | attach <team> <server-key> <agent-key> | detach <team> <server-key> <agent-key> [--yes] | remove <team> <server-key> --yes.';\n case 'llm-key':\n return \"Run one of: ekanos teams llm-key show <team> (provider, and the key's last four characters if one is saved) | set <team> (hidden input at your terminal, or --secret-env|--secret-file|--secret-stdin|--browser) | remove <team> --yes.\";\n case 'api-keys':\n return 'Run one of: ekanos teams api-keys list <team> | create <team> --name <name> --products <slug,slug> [--tools <name,name>] [--expires <ISO date>] (alone, --products grants every read-only tool of those products; --tools grants only the named ones, a write tool included; the secret saved to a 0600 file, never printed) | rotate <team> <key-id> [--yes] (a new secret, the old one revoked) | revoke <team> <key-id> [--yes].';\n }\n}\n\nfunction withTeamFlag(\n operands: readonly string[],\n flag: string | boolean | string[] | undefined,\n): readonly string[] {\n if (flag === undefined) return operands;\n const team = typeof flag === 'string' ? flag.trim().toLowerCase() : '';\n if (!team) {\n throw usageError('--team needs a team slug.', 'e.g. --team bank-a');\n }\n return operands[0]?.trim().toLowerCase() === team\n ? operands\n : [team, ...operands];\n}\n\nexport function requireOperand(\n value: string | undefined,\n what: string,\n area: TeamAgentArea,\n): string {\n const slug = value?.trim().toLowerCase();\n if (slug && /^[a-z0-9][a-z0-9-]*$/.test(slug)) return slug;\n throw usageError(\n value ? `\"${value}\" is not a ${what}.` : `Name the ${what}.`,\n usageFor(area),\n );\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { CliContext } from '../context.js';
2
+ import type { ExitCode } from '../exit-codes.js';
3
+ import { type TeamAgentRun } from './team-agents.js';
4
+ export declare function runTeamApiKeys(ctx: CliContext, run: TeamAgentRun): Promise<ExitCode>;
@@ -0,0 +1,277 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { z } from 'zod';
13
+ import { usageError } from '../errors.js';
14
+ import { cli } from '../invocation.js';
15
+ import { PRODUCT_SLUG_SHAPE, isProductSlug } from '../product-slug.js';
16
+ import { ensureSecretsDir, writeSecretFile } from '../secret-file.js';
17
+ import { call } from '../teams-api.js';
18
+ import { requireOperand, usageFor } from './team-agents.js';
19
+ import { confirmChange } from './teams-lifecycle.js';
20
+ const TeamRefSchema = z.object({ slug: z.string(), name: z.string() });
21
+ const TeamApiKeyGrantSchema = z.object({
22
+ product: z.string(),
23
+ tool: z.string().nullable(),
24
+ effect: z.enum(['read', 'write']),
25
+ });
26
+ const TeamApiKeySchema = z.object({
27
+ id: z.string(),
28
+ name: z.string(),
29
+ prefix: z.string(),
30
+ createdAt: z.string(),
31
+ lastUsedAt: z.string().nullable(),
32
+ expiresAt: z.string().nullable(),
33
+ grants: z.array(TeamApiKeyGrantSchema),
34
+ });
35
+ const TeamApiKeyListSchema = z.object({
36
+ team: TeamRefSchema,
37
+ keys: z.array(TeamApiKeySchema),
38
+ });
39
+ const TeamApiKeyMintSchema = z.object({
40
+ team: TeamRefSchema,
41
+ key: TeamApiKeySchema,
42
+ secret: z.string(),
43
+ mcpUrls: z.array(z.object({ product: z.string(), url: z.string() })),
44
+ });
45
+ const TeamApiKeyRevokeSchema = z.object({
46
+ team: TeamRefSchema,
47
+ keyId: z.string(),
48
+ revoked: z.literal(true),
49
+ });
50
+ export async function runTeamApiKeys(ctx, run) {
51
+ const team = requireOperand(run.operands[0], 'team slug', 'api-keys');
52
+ const base = `/api/partner/teams/${encodeURIComponent(team)}/api-keys`;
53
+ switch (run.verb) {
54
+ case 'list': {
55
+ noExtra(run.operands, 1);
56
+ const list = await run.client.call((token) => call(run.host, token, TeamApiKeyListSchema, {
57
+ method: 'GET',
58
+ path: base,
59
+ source: run.source,
60
+ }));
61
+ return ctx.succeed(Object.assign({ host: run.host }, list), list.keys.length === 0
62
+ ? ctx.ui.result({
63
+ title: `${list.team.slug} has no API keys`,
64
+ notes: [
65
+ `"${cli()} teams api-keys create ${list.team.slug} --name <name> --products <slug,slug>" makes one for an outside MCP client such as a Vapi voice agent.`,
66
+ ],
67
+ })
68
+ : ctx.ui.result({
69
+ title: `API keys of ${list.team.slug}`,
70
+ rows: list.keys.map(keyRow),
71
+ notes: [
72
+ `Rotate one with "${cli()} teams api-keys rotate ${list.team.slug} <key-id>", revoke one with "${cli()} teams api-keys revoke ${list.team.slug} <key-id>".`,
73
+ ],
74
+ }));
75
+ }
76
+ case 'create': {
77
+ noExtra(run.operands, 1);
78
+ const body = createBody(run, team);
79
+ const secrets = ensureSecretsDir(run.args.env);
80
+ const minted = await run.client.call((token) => call(run.host, token, TeamApiKeyMintSchema, {
81
+ method: 'POST',
82
+ path: base,
83
+ source: run.source,
84
+ body,
85
+ }));
86
+ return mintedResult(ctx, run, secrets, minted, {
87
+ title: `New API key ${minted.key.name} for ${minted.team.slug}`,
88
+ notes: [],
89
+ });
90
+ }
91
+ case 'rotate': {
92
+ const keyId = requireKeyId(run.operands[1], team);
93
+ noExtra(run.operands, 2);
94
+ if (!run.args.yes) {
95
+ await confirmChange(ctx, run.args, {
96
+ what: `Rotating API key ${keyId} of ${team} revokes its current secret: an MCP client still sending it is refused until it has the new one.`,
97
+ command: `${cli()} teams api-keys rotate ${team} ${keyId} --yes`,
98
+ question: `Rotate API key ${keyId} of ${team}? [y/N]`,
99
+ });
100
+ }
101
+ const secrets = ensureSecretsDir(run.args.env);
102
+ const minted = await run.client.call((token) => call(run.host, token, TeamApiKeyMintSchema, {
103
+ method: 'POST',
104
+ path: `${base}/${encodeURIComponent(keyId)}/rotate`,
105
+ source: run.source,
106
+ }));
107
+ return mintedResult(ctx, run, secrets, minted, {
108
+ title: `New secret for API key ${minted.key.name} of ${minted.team.slug}`,
109
+ notes: [
110
+ 'The previous secret is revoked: every client must use this one.',
111
+ ],
112
+ });
113
+ }
114
+ case 'revoke': {
115
+ const keyId = requireKeyId(run.operands[1], team);
116
+ noExtra(run.operands, 2);
117
+ if (!run.args.yes) {
118
+ await confirmChange(ctx, run.args, {
119
+ what: `Revoking API key ${keyId} of ${team} stops every MCP client that uses it, for good.`,
120
+ command: `${cli()} teams api-keys revoke ${team} ${keyId} --yes`,
121
+ question: `Revoke API key ${keyId} of ${team}? [y/N]`,
122
+ });
123
+ }
124
+ const revoked = await run.client.call((token) => call(run.host, token, TeamApiKeyRevokeSchema, {
125
+ method: 'DELETE',
126
+ path: `${base}/${encodeURIComponent(keyId)}`,
127
+ source: run.source,
128
+ }));
129
+ return ctx.succeed(Object.assign({ host: run.host }, revoked), ctx.ui.result({
130
+ title: `Revoked API key ${revoked.keyId} of ${revoked.team.slug}`,
131
+ tone: 'warn',
132
+ notes: [
133
+ 'A client that sends it is refused from now on. Remove it from that client.',
134
+ ],
135
+ }));
136
+ }
137
+ default:
138
+ throw usageError(`Unknown teams api-keys subcommand "${run.verb}".`, usageFor('api-keys'));
139
+ }
140
+ }
141
+ function createBody(run, team) {
142
+ var _a;
143
+ const flags = (_a = run.args.flags) !== null && _a !== void 0 ? _a : {};
144
+ const example = `${cli()} teams api-keys create ${team} --name "Vapi agent" --products linear`;
145
+ const name = typeof flags.name === 'string' ? flags.name.trim() : '';
146
+ if (!name) {
147
+ throw usageError('Name the key with --name, so you can tell it apart later.', `e.g. ${example}`);
148
+ }
149
+ const products = listFlag(flags.products).map((slug) => {
150
+ const lower = slug.toLowerCase();
151
+ if (isProductSlug(lower))
152
+ return lower;
153
+ throw usageError(`"${slug}" is not a product slug.`, `${PRODUCT_SLUG_SHAPE} "ekanos sources products" lists the Source's.`);
154
+ });
155
+ if (products.length === 0) {
156
+ throw usageError('Name the products the key reaches with --products <slug,slug>.', `e.g. ${example} (alone: every read-only tool of those products; add --tools <name,name> for only those tools, writes included).`);
157
+ }
158
+ const tools = listFlag(flags.tools);
159
+ for (const tool of tools) {
160
+ if (/\s/.test(tool)) {
161
+ throw usageError(`"${tool}" is not a tool name.`, '"ekanos catalog <product>" lists each tool by name.');
162
+ }
163
+ }
164
+ if (flags.tools !== undefined && tools.length === 0) {
165
+ throw usageError('--tools needs at least one tool name.', 'Leave --tools out for every read-only tool of the products, or name them: --tools <name,name>.');
166
+ }
167
+ const expiresAt = expiresFlag(flags.expires);
168
+ return Object.assign(Object.assign({ name, products: [...new Set(products)] }, (tools.length > 0 ? { tools: [...new Set(tools)] } : {})), (expiresAt ? { expiresAt } : {}));
169
+ }
170
+ function listFlag(value) {
171
+ const raw = Array.isArray(value)
172
+ ? value.join(',')
173
+ : typeof value === 'string'
174
+ ? value
175
+ : '';
176
+ return raw
177
+ .split(',')
178
+ .map((entry) => entry.trim())
179
+ .filter(Boolean);
180
+ }
181
+ function expiresFlag(value) {
182
+ if (value === undefined)
183
+ return undefined;
184
+ const raw = typeof value === 'string' ? value.trim() : '';
185
+ const at = raw ? new Date(raw) : null;
186
+ if (!at || Number.isNaN(at.getTime())) {
187
+ throw usageError(`"${raw}" is not a date.`, 'Pass --expires as an ISO date, e.g. --expires 2027-06-30 or --expires 2027-06-30T17:00:00Z.');
188
+ }
189
+ if (at.getTime() <= Date.now()) {
190
+ throw usageError(`${at.toISOString()} has already passed.`, 'Pass a date in the future, or leave --expires out for a key that does not expire.');
191
+ }
192
+ return at.toISOString();
193
+ }
194
+ function requireKeyId(value, team) {
195
+ const id = value === null || value === void 0 ? void 0 : value.trim();
196
+ if (id && !/[\s/]/.test(id))
197
+ return id;
198
+ throw usageError(id ? `"${id}" is not a key id.` : 'Name the key by its id.', `"${cli()} teams api-keys list ${team}" lists the keys and their ids.`);
199
+ }
200
+ function noExtra(operands, expected) {
201
+ const extra = operands[expected];
202
+ if (extra !== undefined) {
203
+ throw usageError(`Unexpected argument "${extra}".`, usageFor('api-keys'));
204
+ }
205
+ }
206
+ function mintedResult(ctx, run, secrets, minted, copy) {
207
+ var _a;
208
+ const { secret } = minted, rest = __rest(minted, ["secret"]);
209
+ const team = minted.team.slug;
210
+ const secretFile = writeSecretFile(secrets, {
211
+ owner: team,
212
+ what: `${minted.key.name}-api-key`,
213
+ purpose: `API key ${minted.key.name} (${minted.key.prefix}…) of team ${team} on source ${run.source}. An MCP client sends it as "Authorization: Bearer <key>" to each MCP_URL below.`,
214
+ values: [
215
+ ['API_KEY', secret],
216
+ ...minted.mcpUrls.map(({ product, url }) => [
217
+ minted.mcpUrls.length === 1 ? 'MCP_URL' : `MCP_URL_${envName(product)}`,
218
+ url,
219
+ ]),
220
+ ],
221
+ again: `${cli()} teams api-keys rotate ${team} ${minted.key.id} --yes`,
222
+ });
223
+ return ctx.succeed(Object.assign(Object.assign({ host: run.host }, rest), { secretFile }), ctx.ui.result({
224
+ title: copy.title,
225
+ tone: 'warn',
226
+ rows: [
227
+ ['Key', `${minted.key.prefix}… (id ${minted.key.id})`],
228
+ ['Secret', `saved to ${secretFile} (readable only by you)`],
229
+ [
230
+ 'MCP URLs',
231
+ minted.mcpUrls.length === 0
232
+ ? ['none']
233
+ : minted.mcpUrls.map(({ product, url }) => `${product}: ${url}`),
234
+ ],
235
+ ['Grants', grantLines(minted.key)],
236
+ ['Expires', (_a = minted.key.expiresAt) !== null && _a !== void 0 ? _a : 'never'],
237
+ ],
238
+ notes: [
239
+ 'In Vapi, add an "mcp" tool per URL: server.url set to the MCP URL, and the header "Authorization: Bearer <the API_KEY from that file>".',
240
+ 'The secret is shown nowhere else and cannot be read again. Copy it from that file into the client yourself — not into a chat or an agent session — then delete the file.',
241
+ ...copy.notes,
242
+ ],
243
+ }));
244
+ }
245
+ function keyRow(key) {
246
+ return [
247
+ `${key.prefix}…`,
248
+ [
249
+ `${key.name} (id ${key.id})`,
250
+ ...grantLines(key),
251
+ `created ${day(key.createdAt)} · ${key.lastUsedAt ? `last used ${day(key.lastUsedAt)}` : 'never used'} · ${key.expiresAt ? `expires ${day(key.expiresAt)}` : 'no expiry'}`,
252
+ ],
253
+ ];
254
+ }
255
+ function grantLines(key) {
256
+ var _a;
257
+ if (key.grants.length === 0)
258
+ return ['no tools'];
259
+ const byProduct = new Map();
260
+ for (const grant of key.grants) {
261
+ const entry = grant.tool === null
262
+ ? 'every read-only tool'
263
+ : `${grant.tool}${grant.effect === 'write' ? ' (write)' : ''}`;
264
+ byProduct.set(grant.product, [
265
+ ...((_a = byProduct.get(grant.product)) !== null && _a !== void 0 ? _a : []),
266
+ entry,
267
+ ]);
268
+ }
269
+ return [...byProduct].map(([product, entries]) => `${product}: ${entries.join(', ')}`);
270
+ }
271
+ function envName(product) {
272
+ return product.toUpperCase().replace(/[^A-Z0-9]+/g, '_');
273
+ }
274
+ function day(iso) {
275
+ return iso.slice(0, 10);
276
+ }
277
+ //# sourceMappingURL=team-api-keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"team-api-keys.js","sourceRoot":"","sources":["../../src/commands/team-api-keys.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;A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MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACjD,MAAM,SAAS,GAAG,IAAI,GAAG,EAAoB,CAAC;IAC9C,KAAK,MAAM,KAAK,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;QAC/B,MAAM,KAAK,GACT,KAAK,CAAC,IAAI,KAAK,IAAI;YACjB,CAAC,CAAC,sBAAsB;YACxB,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QACnE,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE;YAC3B,GAAG,OAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,mCAAI,EAAE,CAAC;YACvC,KAAK;SACN,CAAC,CAAC;IACL,CAAC;IACD,OAAO,CAAC,GAAG,SAAS,CAAC,CAAC,GAAG,CACvB,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,GAAG,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC5D,CAAC;AACJ,CAAC;AAED,SAAS,OAAO,CAAC,OAAe;IAC9B,OAAO,OAAO,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;AAC3D,CAAC;AAED,SAAS,GAAG,CAAC,GAAW;IACtB,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC1B,CAAC","sourcesContent":["import { z } from 'zod';\n\nimport type { CliContext } from '../context';\nimport { usageError } from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { cli } from '../invocation';\nimport { PRODUCT_SLUG_SHAPE, isProductSlug } from '../product-slug';\nimport { ensureSecretsDir, writeSecretFile } from '../secret-file';\nimport { call } from '../teams-api';\nimport type { ResultRow } from '../ui';\nimport { type TeamAgentRun, requireOperand, usageFor } from './team-agents';\nimport { confirmChange } from './teams-lifecycle';\n\nconst TeamRefSchema = z.object({ slug: z.string(), name: z.string() });\n\nconst TeamApiKeyGrantSchema = z.object({\n product: z.string(),\n tool: z.string().nullable(),\n effect: z.enum(['read', 'write']),\n});\n\nconst TeamApiKeySchema = z.object({\n id: z.string(),\n name: z.string(),\n prefix: z.string(),\n createdAt: z.string(),\n lastUsedAt: z.string().nullable(),\n expiresAt: z.string().nullable(),\n grants: z.array(TeamApiKeyGrantSchema),\n});\n\nconst TeamApiKeyListSchema = z.object({\n team: TeamRefSchema,\n keys: z.array(TeamApiKeySchema),\n});\n\nconst TeamApiKeyMintSchema = z.object({\n team: TeamRefSchema,\n key: TeamApiKeySchema,\n secret: z.string(),\n mcpUrls: z.array(z.object({ product: z.string(), url: z.string() })),\n});\n\nconst TeamApiKeyRevokeSchema = z.object({\n team: TeamRefSchema,\n keyId: z.string(),\n revoked: z.literal(true),\n});\n\ntype TeamApiKey = z.infer<typeof TeamApiKeySchema>;\ntype TeamApiKeyMint = z.infer<typeof TeamApiKeyMintSchema>;\n\nexport async function runTeamApiKeys(\n ctx: CliContext,\n run: TeamAgentRun,\n): Promise<ExitCode> {\n const team = requireOperand(run.operands[0], 'team slug', 'api-keys');\n const base = `/api/partner/teams/${encodeURIComponent(team)}/api-keys`;\n\n switch (run.verb) {\n case 'list': {\n noExtra(run.operands, 1);\n const list = await run.client.call((token) =>\n call(run.host, token, TeamApiKeyListSchema, {\n method: 'GET',\n path: base,\n source: run.source,\n }),\n );\n return ctx.succeed(\n { host: run.host, ...list },\n list.keys.length === 0\n ? ctx.ui.result({\n title: `${list.team.slug} has no API keys`,\n notes: [\n `\"${cli()} teams api-keys create ${list.team.slug} --name <name> --products <slug,slug>\" makes one for an outside MCP client such as a Vapi voice agent.`,\n ],\n })\n : ctx.ui.result({\n title: `API keys of ${list.team.slug}`,\n rows: list.keys.map(keyRow),\n notes: [\n `Rotate one with \"${cli()} teams api-keys rotate ${list.team.slug} <key-id>\", revoke one with \"${cli()} teams api-keys revoke ${list.team.slug} <key-id>\".`,\n ],\n }),\n );\n }\n case 'create': {\n noExtra(run.operands, 1);\n const body = createBody(run, team);\n const secrets = ensureSecretsDir(run.args.env);\n const minted = await run.client.call((token) =>\n call(run.host, token, TeamApiKeyMintSchema, {\n method: 'POST',\n path: base,\n source: run.source,\n body,\n }),\n );\n return mintedResult(ctx, run, secrets, minted, {\n title: `New API key ${minted.key.name} for ${minted.team.slug}`,\n notes: [],\n });\n }\n case 'rotate': {\n const keyId = requireKeyId(run.operands[1], team);\n noExtra(run.operands, 2);\n if (!run.args.yes) {\n await confirmChange(ctx, run.args, {\n what: `Rotating API key ${keyId} of ${team} revokes its current secret: an MCP client still sending it is refused until it has the new one.`,\n command: `${cli()} teams api-keys rotate ${team} ${keyId} --yes`,\n question: `Rotate API key ${keyId} of ${team}? [y/N]`,\n });\n }\n const secrets = ensureSecretsDir(run.args.env);\n const minted = await run.client.call((token) =>\n call(run.host, token, TeamApiKeyMintSchema, {\n method: 'POST',\n path: `${base}/${encodeURIComponent(keyId)}/rotate`,\n source: run.source,\n }),\n );\n return mintedResult(ctx, run, secrets, minted, {\n title: `New secret for API key ${minted.key.name} of ${minted.team.slug}`,\n notes: [\n 'The previous secret is revoked: every client must use this one.',\n ],\n });\n }\n case 'revoke': {\n const keyId = requireKeyId(run.operands[1], team);\n noExtra(run.operands, 2);\n if (!run.args.yes) {\n await confirmChange(ctx, run.args, {\n what: `Revoking API key ${keyId} of ${team} stops every MCP client that uses it, for good.`,\n command: `${cli()} teams api-keys revoke ${team} ${keyId} --yes`,\n question: `Revoke API key ${keyId} of ${team}? [y/N]`,\n });\n }\n const revoked = await run.client.call((token) =>\n call(run.host, token, TeamApiKeyRevokeSchema, {\n method: 'DELETE',\n path: `${base}/${encodeURIComponent(keyId)}`,\n source: run.source,\n }),\n );\n return ctx.succeed(\n { host: run.host, ...revoked },\n ctx.ui.result({\n title: `Revoked API key ${revoked.keyId} of ${revoked.team.slug}`,\n tone: 'warn',\n notes: [\n 'A client that sends it is refused from now on. Remove it from that client.',\n ],\n }),\n );\n }\n default:\n throw usageError(\n `Unknown teams api-keys subcommand \"${run.verb}\".`,\n usageFor('api-keys'),\n );\n }\n}\n\nfunction createBody(\n run: TeamAgentRun,\n team: string,\n): { name: string; products: string[]; tools?: string[]; expiresAt?: string } {\n const flags = run.args.flags ?? {};\n const example = `${cli()} teams api-keys create ${team} --name \"Vapi agent\" --products linear`;\n const name = typeof flags.name === 'string' ? flags.name.trim() : '';\n if (!name) {\n throw usageError(\n 'Name the key with --name, so you can tell it apart later.',\n `e.g. ${example}`,\n );\n }\n const products = listFlag(flags.products).map((slug) => {\n const lower = slug.toLowerCase();\n if (isProductSlug(lower)) return lower;\n throw usageError(\n `\"${slug}\" is not a product slug.`,\n `${PRODUCT_SLUG_SHAPE} \"ekanos sources products\" lists the Source's.`,\n );\n });\n if (products.length === 0) {\n throw usageError(\n 'Name the products the key reaches with --products <slug,slug>.',\n `e.g. ${example} (alone: every read-only tool of those products; add --tools <name,name> for only those tools, writes included).`,\n );\n }\n const tools = listFlag(flags.tools);\n for (const tool of tools) {\n if (/\\s/.test(tool)) {\n throw usageError(\n `\"${tool}\" is not a tool name.`,\n '\"ekanos catalog <product>\" lists each tool by name.',\n );\n }\n }\n if (flags.tools !== undefined && tools.length === 0) {\n throw usageError(\n '--tools needs at least one tool name.',\n 'Leave --tools out for every read-only tool of the products, or name them: --tools <name,name>.',\n );\n }\n const expiresAt = expiresFlag(flags.expires);\n return {\n name,\n products: [...new Set(products)],\n ...(tools.length > 0 ? { tools: [...new Set(tools)] } : {}),\n ...(expiresAt ? { expiresAt } : {}),\n };\n}\n\nfunction listFlag(value: unknown): string[] {\n const raw = Array.isArray(value)\n ? value.join(',')\n : typeof value === 'string'\n ? value\n : '';\n return raw\n .split(',')\n .map((entry) => entry.trim())\n .filter(Boolean);\n}\n\nfunction expiresFlag(value: unknown): string | undefined {\n if (value === undefined) return undefined;\n const raw = typeof value === 'string' ? value.trim() : '';\n const at = raw ? new Date(raw) : null;\n if (!at || Number.isNaN(at.getTime())) {\n throw usageError(\n `\"${raw}\" is not a date.`,\n 'Pass --expires as an ISO date, e.g. --expires 2027-06-30 or --expires 2027-06-30T17:00:00Z.',\n );\n }\n if (at.getTime() <= Date.now()) {\n throw usageError(\n `${at.toISOString()} has already passed.`,\n 'Pass a date in the future, or leave --expires out for a key that does not expire.',\n );\n }\n return at.toISOString();\n}\n\nfunction requireKeyId(value: string | undefined, team: string): string {\n const id = value?.trim();\n if (id && !/[\\s/]/.test(id)) return id;\n throw usageError(\n id ? `\"${id}\" is not a key id.` : 'Name the key by its id.',\n `\"${cli()} teams api-keys list ${team}\" lists the keys and their ids.`,\n );\n}\n\nfunction noExtra(operands: readonly string[], expected: number) {\n const extra = operands[expected];\n if (extra !== undefined) {\n throw usageError(`Unexpected argument \"${extra}\".`, usageFor('api-keys'));\n }\n}\n\nfunction mintedResult(\n ctx: CliContext,\n run: TeamAgentRun,\n secrets: string,\n minted: TeamApiKeyMint,\n copy: { title: string; notes: string[] },\n): ExitCode {\n const { secret, ...rest } = minted;\n const team = minted.team.slug;\n const secretFile = writeSecretFile(secrets, {\n owner: team,\n what: `${minted.key.name}-api-key`,\n purpose: `API key ${minted.key.name} (${minted.key.prefix}…) of team ${team} on source ${run.source}. An MCP client sends it as \"Authorization: Bearer <key>\" to each MCP_URL below.`,\n values: [\n ['API_KEY', secret],\n ...minted.mcpUrls.map(({ product, url }): [string, string] => [\n minted.mcpUrls.length === 1 ? 'MCP_URL' : `MCP_URL_${envName(product)}`,\n url,\n ]),\n ],\n again: `${cli()} teams api-keys rotate ${team} ${minted.key.id} --yes`,\n });\n return ctx.succeed(\n { host: run.host, ...rest, secretFile },\n ctx.ui.result({\n title: copy.title,\n tone: 'warn',\n rows: [\n ['Key', `${minted.key.prefix}… (id ${minted.key.id})`],\n ['Secret', `saved to ${secretFile} (readable only by you)`],\n [\n 'MCP URLs',\n minted.mcpUrls.length === 0\n ? ['none']\n : minted.mcpUrls.map(({ product, url }) => `${product}: ${url}`),\n ],\n ['Grants', grantLines(minted.key)],\n ['Expires', minted.key.expiresAt ?? 'never'],\n ],\n notes: [\n 'In Vapi, add an \"mcp\" tool per URL: server.url set to the MCP URL, and the header \"Authorization: Bearer <the API_KEY from that file>\".',\n 'The secret is shown nowhere else and cannot be read again. Copy it from that file into the client yourself — not into a chat or an agent session — then delete the file.',\n ...copy.notes,\n ],\n }),\n );\n}\n\nfunction keyRow(key: TeamApiKey): ResultRow {\n return [\n `${key.prefix}…`,\n [\n `${key.name} (id ${key.id})`,\n ...grantLines(key),\n `created ${day(key.createdAt)} · ${key.lastUsedAt ? `last used ${day(key.lastUsedAt)}` : 'never used'} · ${key.expiresAt ? `expires ${day(key.expiresAt)}` : 'no expiry'}`,\n ],\n ];\n}\n\nfunction grantLines(key: TeamApiKey): string[] {\n if (key.grants.length === 0) return ['no tools'];\n const byProduct = new Map<string, string[]>();\n for (const grant of key.grants) {\n const entry =\n grant.tool === null\n ? 'every read-only tool'\n : `${grant.tool}${grant.effect === 'write' ? ' (write)' : ''}`;\n byProduct.set(grant.product, [\n ...(byProduct.get(grant.product) ?? []),\n entry,\n ]);\n }\n return [...byProduct].map(\n ([product, entries]) => `${product}: ${entries.join(', ')}`,\n );\n}\n\nfunction envName(product: string): string {\n return product.toUpperCase().replace(/[^A-Z0-9]+/g, '_');\n}\n\nfunction day(iso: string): string {\n return iso.slice(0, 10);\n}\n"]}
@@ -522,7 +522,7 @@ function parseSubcommand(value) {
522
522
  return match;
523
523
  throw usageError(value
524
524
  ? `Unknown teams subcommand "${value}".`
525
- : 'teams needs a subcommand.', 'Run one of: ekanos teams list, ekanos teams create <name>, ekanos teams rename <team> <name>, ekanos teams members list|add|invite|role|remove|resend <team> … (add <team> --self joins you), ekanos teams roles list <team>, ekanos teams leave <team> --yes, ekanos teams groups list|create|update|delete|members <team> …, ekanos teams health <team> [<product>] [--run] (<product> --mine: your own personal connection), ekanos teams workspace list|default <team> …, ekanos teams connect <team> <product>, ekanos teams disconnect <team> <product> --yes (--mine: your own personal connection), ekanos teams show <team> [<product>], ekanos teams app set <team> <product>, ekanos teams webhook <team> <product> [<webhook-id>], ekanos teams events <team> [<product>], ekanos teams audience <team> [<audience>] [--member <email>], ekanos teams scope show|set <team> … (deprecated: audiences), ekanos teams agents|triggers|links|mcp|llm-key ….');
525
+ : 'teams needs a subcommand.', 'Run one of: ekanos teams list, ekanos teams create <name>, ekanos teams rename <team> <name>, ekanos teams members list|add|invite|role|remove|resend <team> … (add <team> --self joins you), ekanos teams roles list <team>, ekanos teams leave <team> --yes, ekanos teams groups list|create|update|delete|members <team> …, ekanos teams health <team> [<product>] [--run] (<product> --mine: your own personal connection), ekanos teams workspace list|default <team> …, ekanos teams connect <team> <product>, ekanos teams disconnect <team> <product> --yes (--mine: your own personal connection), ekanos teams show <team> [<product>], ekanos teams app set <team> <product>, ekanos teams webhook <team> <product> [<webhook-id>], ekanos teams events <team> [<product>], ekanos teams audience <team> [<audience>] [--member <email>], ekanos teams scope show|set <team> … (deprecated: audiences), ekanos teams agents|triggers|links|mcp|llm-key|api-keys ….');
526
526
  }
527
527
  function requireSlug(value, what) {
528
528
  const slug = value === null || value === void 0 ? void 0 : value.trim().toLowerCase();