@ekanos/cli 0.12.0 → 0.14.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.
- package/README.md +25 -8
- package/dist/agents-api.d.ts +11 -2
- package/dist/agents-api.js +39 -3
- package/dist/agents-api.js.map +1 -1
- package/dist/apps-api.d.ts +3 -2
- package/dist/apps-api.js +3 -7
- package/dist/apps-api.js.map +1 -1
- package/dist/auth/ekanos-api.d.ts +16 -2
- package/dist/auth/ekanos-api.js +101 -15
- package/dist/auth/ekanos-api.js.map +1 -1
- package/dist/auth/host-trust.d.ts +46 -0
- package/dist/auth/host-trust.js +79 -0
- package/dist/auth/host-trust.js.map +1 -0
- package/dist/auth/session.d.ts +10 -1
- package/dist/auth/session.js +28 -28
- package/dist/auth/session.js.map +1 -1
- package/dist/commands/agents-edit.d.ts +6 -2
- package/dist/commands/agents-edit.js +57 -26
- package/dist/commands/agents-edit.js.map +1 -1
- package/dist/commands/agents.d.ts +13 -2
- package/dist/commands/agents.js +148 -36
- package/dist/commands/agents.js.map +1 -1
- package/dist/commands/apps.d.ts +15 -4
- package/dist/commands/apps.js +133 -51
- package/dist/commands/apps.js.map +1 -1
- package/dist/commands/catalog.js +7 -6
- package/dist/commands/catalog.js.map +1 -1
- package/dist/commands/knowledge.d.ts +56 -0
- package/dist/commands/knowledge.js +456 -0
- package/dist/commands/knowledge.js.map +1 -0
- package/dist/commands/login.d.ts +4 -0
- package/dist/commands/login.js +30 -2
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logout.d.ts +9 -1
- package/dist/commands/logout.js +56 -7
- package/dist/commands/logout.js.map +1 -1
- package/dist/commands/publish.js +3 -3
- package/dist/commands/publish.js.map +1 -1
- package/dist/commands/reviewers.d.ts +2 -0
- package/dist/commands/reviewers.js +7 -3
- package/dist/commands/reviewers.js.map +1 -1
- package/dist/commands/routes.d.ts +2 -0
- package/dist/commands/routes.js +42 -9
- package/dist/commands/routes.js.map +1 -1
- package/dist/commands/runs.d.ts +13 -2
- package/dist/commands/runs.js +96 -15
- package/dist/commands/runs.js.map +1 -1
- package/dist/commands/scope-notice.d.ts +21 -0
- package/dist/commands/scope-notice.js +35 -0
- package/dist/commands/scope-notice.js.map +1 -0
- package/dist/commands/skills.d.ts +7 -1
- package/dist/commands/skills.js +80 -24
- package/dist/commands/skills.js.map +1 -1
- package/dist/commands/sources.d.ts +4 -0
- package/dist/commands/sources.js +233 -5
- package/dist/commands/sources.js.map +1 -1
- package/dist/commands/status.js +5 -4
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/team-agent-readiness.d.ts +59 -0
- package/dist/commands/team-agent-readiness.js +341 -0
- package/dist/commands/team-agent-readiness.js.map +1 -0
- package/dist/commands/team-agents-agents.d.ts +24 -3
- package/dist/commands/team-agents-agents.js +336 -35
- package/dist/commands/team-agents-agents.js.map +1 -1
- package/dist/commands/team-agents-mcp.js +32 -3
- package/dist/commands/team-agents-mcp.js.map +1 -1
- package/dist/commands/team-agents-triggers.js +230 -54
- package/dist/commands/team-agents-triggers.js.map +1 -1
- package/dist/commands/team-agents.d.ts +3 -1
- package/dist/commands/team-agents.js +27 -7
- package/dist/commands/team-agents.js.map +1 -1
- package/dist/commands/teams-channel-install.d.ts +24 -0
- package/dist/commands/teams-channel-install.js +94 -0
- package/dist/commands/teams-channel-install.js.map +1 -0
- package/dist/commands/teams-connect.d.ts +66 -0
- package/dist/commands/teams-connect.js +397 -0
- package/dist/commands/teams-connect.js.map +1 -0
- package/dist/commands/teams-events.d.ts +12 -0
- package/dist/commands/teams-events.js +138 -0
- package/dist/commands/teams-events.js.map +1 -0
- package/dist/commands/teams-onboard.d.ts +16 -5
- package/dist/commands/teams-onboard.js +61 -36
- package/dist/commands/teams-onboard.js.map +1 -1
- package/dist/commands/teams-overview.d.ts +11 -0
- package/dist/commands/teams-overview.js +160 -0
- package/dist/commands/teams-overview.js.map +1 -0
- package/dist/commands/teams-scope.d.ts +10 -0
- package/dist/commands/teams-scope.js +109 -0
- package/dist/commands/teams-scope.js.map +1 -0
- package/dist/commands/teams.d.ts +64 -7
- package/dist/commands/teams.js +254 -60
- package/dist/commands/teams.js.map +1 -1
- package/dist/commands/upgrade.js +12 -2
- package/dist/commands/upgrade.js.map +1 -1
- package/dist/commands/use.js +2 -2
- package/dist/commands/use.js.map +1 -1
- package/dist/commands/whoami.js +1 -1
- package/dist/commands/whoami.js.map +1 -1
- package/dist/connections-api.js +1 -1
- package/dist/connections-api.js.map +1 -1
- package/dist/delegate.js +11 -4
- package/dist/delegate.js.map +1 -1
- package/dist/harness-scaffold.js +12 -0
- package/dist/harness-scaffold.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.js +724 -152
- package/dist/index.js.map +1 -1
- package/dist/knowledge-api.d.ts +175 -0
- package/dist/knowledge-api.js +169 -0
- package/dist/knowledge-api.js.map +1 -0
- package/dist/open-url.d.ts +16 -0
- package/dist/open-url.js +73 -0
- package/dist/open-url.js.map +1 -0
- package/dist/parse-argv.d.ts +2 -0
- package/dist/parse-argv.js.map +1 -1
- package/dist/publish-api.d.ts +2 -1
- package/dist/publish-api.js +4 -3
- package/dist/publish-api.js.map +1 -1
- package/dist/pull-write.d.ts +27 -0
- package/dist/pull-write.js +60 -0
- package/dist/pull-write.js.map +1 -0
- package/dist/routes-api.d.ts +3 -0
- package/dist/routes-api.js +9 -4
- package/dist/routes-api.js.map +1 -1
- package/dist/runs-api.d.ts +7 -1
- package/dist/runs-api.js +21 -6
- package/dist/runs-api.js.map +1 -1
- package/dist/safe-fs.d.ts +2 -0
- package/dist/safe-fs.js +12 -6
- package/dist/safe-fs.js.map +1 -1
- package/dist/secret-file.d.ts +17 -0
- package/dist/secret-file.js +69 -0
- package/dist/secret-file.js.map +1 -0
- package/dist/skills-api.d.ts +10 -2
- package/dist/skills-api.js +37 -2
- package/dist/skills-api.js.map +1 -1
- package/dist/source-products-api.d.ts +63 -0
- package/dist/source-products-api.js +123 -0
- package/dist/source-products-api.js.map +1 -0
- package/dist/source-target.js +2 -1
- package/dist/source-target.js.map +1 -1
- package/dist/sources-api.d.ts +2 -1
- package/dist/sources-api.js +3 -2
- package/dist/sources-api.js.map +1 -1
- package/dist/team-connect-api.d.ts +286 -0
- package/dist/team-connect-api.js +107 -0
- package/dist/team-connect-api.js.map +1 -0
- package/dist/teams-api.d.ts +42 -1
- package/dist/teams-api.js +98 -20
- package/dist/teams-api.js.map +1 -1
- package/dist/toolchain-api.d.ts +9 -0
- package/dist/toolchain-api.js +17 -2
- package/dist/toolchain-api.js.map +1 -1
- package/dist/toolchain-resolve.d.ts +3 -0
- package/dist/toolchain-resolve.js +15 -1
- package/dist/toolchain-resolve.js.map +1 -1
- package/dist/toolchain.d.ts +6 -0
- package/dist/toolchain.js +19 -0
- package/dist/toolchain.js.map +1 -1
- package/dist/update-notice.js +2 -1
- package/dist/update-notice.js.map +1 -1
- package/package.json +2 -2
- package/templates/AGENTS.md.tmpl +6 -1
- package/templates/claude-skill.md.tmpl +5 -0
- package/templates/package.json.tmpl +4 -4
- package/templates/skills/build-agent/SKILL.md +115 -16
- package/templates/skills/build-agent/references/agent-json.md +26 -8
- package/templates/skills/build-agent/references/app-setup.md +2 -1
- package/templates/skills/build-agent/references/rollout.md +27 -4
- package/templates/skills/build-agent/references/set-up-an-integration.md +74 -15
- package/templates/skills/build-agent/references/skills.md +20 -1
- package/templates/skills/build-agent/references/triggers.md +84 -20
- package/templates/skills/build-integration/references/widget-design.md +3 -3
- package/templates/skills/ekanos-platform/SKILL.md +70 -17
- package/templates/skills/polish-widgets/references/patterns.md +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"teams-onboard.js","sourceRoot":"","sources":["../../src/commands/teams-onboard.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE1D,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EAC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,CAAC;AACH,CAAC;AAED,SAAS,MAAM,CAAC,KAAyB,EAAE,IAAwB;IACjE,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,QAAQ,CAAC,CAAC,CAAC,YAAY,IAAI,GAAG,EACjE,IAAI,KAAK,MAAM;QACb,CAAC,CAAC,+EAA+E;QACjF,CAAC,CAAC,kFAAkF,CACvF,CAAC;AACJ,CAAC;AAED,SAAS,OAAO,CAAC,KAAyB;IACxC,MAAM,KAAK,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,GAAG,WAAW,EAAE,CAAC;IAC1C,IAAI,KAAK,IAAI,4BAA4B,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACpE,MAAM,UAAU,CACd,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,4BAA4B,CAAC,CAAC,CAAC,2BAA2B,EAC3E,yEAAyE,CAC1E,CAAC;AACJ,CAAC;AAED,SAAS,MAAM,CAAC,KAAa;IAC3B,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACxC,IAAI,yBAAyB,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACtD,MAAM,UAAU,CACd,IAAI,KAAK,uBAAuB,EAChC,oEAAoE,CACrE,CAAC;AACJ,CAAC","sourcesContent":["import type { CliContext } from '../context';\nimport { invalidStateError, usageError } from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport {\n createTeam,\n inviteTeamMember,\n listTeamMembers,\n listTeamRoles,\n removeTeamMember,\n setTeamMemberRole,\n showTeamIntegration,\n} from '../teams-api';\nimport type { TeamsClient } from './teams';\n\n/**\n * Onboarding a team from the terminal, for the Source admin: `teams create`,\n * `teams members list|invite|role|remove`, `teams roles list` and\n * `teams connect`. Parsed before any session is touched (`parseOnboarding`)\n * so a usage error never costs a network round-trip, then run against the\n * session `runTeams` resolved.\n */\n\nexport const ONBOARDING_SUBCOMMANDS = [\n 'create',\n 'members',\n 'roles',\n 'connect',\n] as const;\nexport type OnboardingSubcommand = (typeof ONBOARDING_SUBCOMMANDS)[number];\n\nexport interface OnboardingFlags {\n slug?: string;\n owner?: string;\n role?: string;\n yes: boolean;\n}\n\nexport type OnboardingPlan =\n | { kind: 'create'; name: string; slug?: string; ownerEmail?: string }\n | { kind: 'members-list'; team: string }\n | { kind: 'members-invite'; team: string; email: string; role: string }\n | { kind: 'members-role'; team: string; email: string; role: string }\n | { kind: 'members-remove'; team: string; email: string }\n | { kind: 'roles-list'; team: string }\n | { kind: 'connect'; team: string; product: string };\n\nconst MEMBERS_VERBS = ['list', 'invite', 'role', 'remove'] as const;\n\nexport function isOnboardingSubcommand(\n value: string,\n): value is OnboardingSubcommand {\n return (ONBOARDING_SUBCOMMANDS as readonly string[]).includes(value);\n}\n\nexport function parseOnboarding(\n subcommand: OnboardingSubcommand,\n rest: readonly string[],\n flags: OnboardingFlags,\n): OnboardingPlan {\n if (subcommand === 'create') {\n const [name, ...extra] = rest;\n if (!name?.trim()) {\n throw usageError(\n 'Name the team.',\n 'Run \"ekanos teams create \\\\\"Bank A\\\\\" [--slug bank-a] [--owner <email>]\".',\n );\n }\n noExtra(extra);\n return {\n kind: 'create',\n name: name.trim(),\n slug: flags.slug === undefined ? undefined : slugOf(flags.slug, 'team'),\n ownerEmail: flags.owner === undefined ? undefined : emailOf(flags.owner),\n };\n }\n\n if (subcommand === 'connect') {\n const [team, product, ...extra] = rest;\n noExtra(extra);\n return {\n kind: 'connect',\n team: slugOf(team, 'team'),\n product: slugOf(product, 'product'),\n };\n }\n\n if (subcommand === 'roles') {\n const [verb, team, ...extra] = rest;\n if (verb !== 'list') {\n throw usageError(\n verb\n ? `Unknown teams roles subcommand \"${verb}\".`\n : 'teams roles needs a subcommand.',\n 'Run \"ekanos teams roles list <team>\".',\n );\n }\n noExtra(extra);\n return { kind: 'roles-list', team: slugOf(team, 'team') };\n }\n\n const [verb, team, email, role, ...extra] = rest;\n const match = MEMBERS_VERBS.find((name) => name === verb);\n if (!match) {\n throw usageError(\n verb\n ? `Unknown teams members subcommand \"${verb}\".`\n : 'teams members needs a subcommand.',\n 'Run one of: ekanos teams members list <team>, ekanos teams members invite <team> <email> --role <role>, ekanos teams members role <team> <email> <role>, ekanos teams members remove <team> <email> --yes.',\n );\n }\n noExtra(extra);\n\n if (match === 'list') {\n if (email !== undefined) noExtra([email]);\n return { kind: 'members-list', team: slugOf(team, 'team') };\n }\n\n const teamSlug = slugOf(team, 'team');\n const address = emailOf(email);\n\n if (match === 'invite') {\n if (role !== undefined) noExtra([role]);\n return {\n kind: 'members-invite',\n team: teamSlug,\n email: address,\n role: roleOf(flags.role ?? 'member'),\n };\n }\n\n if (match === 'role') {\n const named = role ?? flags.role;\n if (!named) {\n throw usageError(\n 'Name the new role.',\n `Run \"ekanos teams members role ${teamSlug} ${address} <role>\"; \"ekanos teams roles list ${teamSlug}\" lists them.`,\n );\n }\n return {\n kind: 'members-role',\n team: teamSlug,\n email: address,\n role: roleOf(named),\n };\n }\n\n if (role !== undefined) noExtra([role]);\n if (!flags.yes) {\n throw invalidStateError(\n `Removing ${address} from ${teamSlug} ends their access to the team (a pending invitation is withdrawn instead).`,\n `Re-run with --yes: ekanos teams members remove ${teamSlug} ${address} --yes`,\n );\n }\n return { kind: 'members-remove', team: teamSlug, email: address };\n}\n\nexport async function runOnboarding(\n ctx: CliContext,\n client: TeamsClient,\n host: string,\n source: string,\n plan: OnboardingPlan,\n): Promise<ExitCode> {\n switch (plan.kind) {\n case 'create': {\n const created = await client.call((token) =>\n createTeam(host, token, source, {\n name: plan.name,\n slug: plan.slug,\n ownerEmail: plan.ownerEmail,\n }),\n );\n return ctx.succeed(\n { host, ...created },\n ctx.ui.result({\n title: `Created team ${created.team.slug}`,\n rows: [\n ['Name', created.team.name],\n ['Source', created.source.slug],\n [\n 'Owner',\n created.owner.kind === 'caller'\n ? `you${created.owner.email ? ` (${created.owner.email})` : ''}`\n : `${created.owner.email} — invited; ownership moves to them on accept`,\n ],\n ['Team home', created.teamUrl],\n ],\n notes: [\n `Next: \"ekanos teams members invite ${created.team.slug} <email> --role <role>\" (\"ekanos teams roles list ${created.team.slug}\" lists the roles).`,\n `Then \"ekanos teams connect ${created.team.slug} <product>\" for the link a member opens to connect an integration.`,\n ],\n }),\n );\n }\n\n case 'members-list': {\n const list = await client.call((token) =>\n listTeamMembers(host, token, { source, team: plan.team }),\n );\n const rows: [string, string][] = list.members.map((member) => [\n member.email ?? member.userId,\n `${member.role}${member.primaryOwner ? ' · primary owner' : ''}${member.status === 'active' ? '' : ` · ${member.status}`}${member.name ? ` · ${member.name}` : ''}`,\n ]);\n for (const invitation of list.invitations) {\n rows.push([\n invitation.email,\n `${invitation.role} · invited, expires ${invitation.expiresAt.slice(0, 10)}`,\n ]);\n }\n return ctx.succeed(\n { host, ...list },\n ctx.ui.result({\n title: `Members of ${list.team.slug} (${list.team.name})`,\n tone: rows.length === 0 ? 'warn' : 'ok',\n rows,\n notes: [\n `\"ekanos teams members invite ${list.team.slug} <email> --role <role>\" adds one.`,\n ],\n }),\n );\n }\n\n case 'members-invite': {\n const invited = await client.call((token) =>\n inviteTeamMember(\n host,\n token,\n { source, team: plan.team },\n { email: plan.email, role: plan.role },\n ),\n );\n return ctx.succeed(\n { host, ...invited },\n ctx.ui.result({\n title: `Invited ${invited.invitation.email} to ${invited.team.slug}`,\n rows: [\n ['Role', invited.invitation.role],\n ['Expires', invited.invitation.expiresAt.slice(0, 10)],\n ],\n notes: [\n 'The invitation email is on its way; they join when they accept it.',\n ],\n }),\n );\n }\n\n case 'members-role': {\n const changed = await client.call((token) =>\n setTeamMemberRole(\n host,\n token,\n { source, team: plan.team, email: plan.email },\n plan.role,\n ),\n );\n return ctx.succeed(\n { host, ...changed },\n ctx.ui.result({\n title:\n changed.before === changed.after\n ? `${changed.email} is already ${changed.after} on ${changed.team.slug}`\n : `${changed.email} is now ${changed.after} on ${changed.team.slug}`,\n rows: [\n ['Was', changed.before ?? '—'],\n [\n 'Applies to',\n changed.kind === 'member'\n ? 'their membership'\n : 'their pending invitation',\n ],\n ],\n }),\n );\n }\n\n case 'members-remove': {\n const removed = await client.call((token) =>\n removeTeamMember(host, token, {\n source,\n team: plan.team,\n email: plan.email,\n }),\n );\n return ctx.succeed(\n { host, ...removed },\n ctx.ui.result({\n title:\n removed.kind === 'member'\n ? `Removed ${removed.email} from ${removed.team.slug}`\n : `Withdrew ${removed.email}'s invitation to ${removed.team.slug}`,\n rows: [['Role was', removed.before ?? '—']],\n }),\n );\n }\n\n case 'roles-list': {\n const roles = await client.call((token) =>\n listTeamRoles(host, token, { source, team: plan.team }),\n );\n return ctx.succeed(\n { host, ...roles },\n ctx.ui.result({\n title: `Roles on ${roles.team.slug}`,\n rows: roles.roles.map((role) => [\n `${role.name} (${role.displayName})`,\n role.permissions.length > 0 ? role.permissions : ['no permissions'],\n ]),\n notes: [\n 'Lower roles are listed last. Give one with \"ekanos teams members role <team> <email> <role>\".',\n ],\n }),\n );\n }\n\n case 'connect': {\n const status = await client.call((token) =>\n showTeamIntegration(host, token, {\n source,\n team: plan.team,\n product: plan.product,\n }),\n );\n if (!status.enabled) {\n throw invalidStateError(\n `\"${plan.product}\" is not enabled on ${status.source.slug}.`,\n '\"ekanos catalog\" lists what this Source has; Ekanos enables a product for a Source.',\n );\n }\n const connected = status.activation !== null;\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 ['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 notes: [\n 'A team member signs in there and clicks Connect: sign-in happens in their browser, never in a terminal.',\n `\"ekanos teams show ${status.team.slug} ${status.product.slug}\" shows the full setup checklist.`,\n ],\n }),\n );\n }\n }\n}\n\nfunction noExtra(extra: readonly string[]) {\n if (extra.length > 0) {\n throw usageError(\n `Unexpected argument \"${extra[0]}\".`,\n 'See \"ekanos teams --help\".',\n );\n }\n}\n\nfunction slugOf(value: string | undefined, what: 'team' | 'product'): 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} slug.` : `Name the ${what}.`,\n what === 'team'\n ? '\"ekanos teams list\" lists the teams, e.g. \"ekanos teams members list bank-a\".'\n : '\"ekanos catalog\" lists the products, e.g. \"ekanos teams connect bank-a zendesk\".',\n );\n}\n\nfunction emailOf(value: string | undefined): string {\n const email = value?.trim().toLowerCase();\n if (email && /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(email)) return email;\n throw usageError(\n value ? `\"${value}\" is not an email address.` : 'Name the person by email.',\n 'e.g. \"ekanos teams members invite bank-a ana@bank-a.com --role member\".',\n );\n}\n\nfunction roleOf(value: string): string {\n const role = value.trim().toLowerCase();\n if (/^[a-z][a-z0-9_-]{0,49}$/.test(role)) return role;\n throw usageError(\n `\"${value}\" is not a role name.`,\n '\"ekanos teams roles list <team>\" lists the roles this Source uses.',\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"teams-onboard.js","sourceRoot":"","sources":["../../src/commands/teams-onboard.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE1D,OAAO,EACL,UAAU,EACV,yBAAyB,EACzB,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,U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AAI,CAAC;IAC3D,MAAM,UAAU,CACd,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,cAAc,IAAI,QAAQ,CAAC,CAAC,CAAC,YAAY,IAAI,GAAG,EACjE,IAAI,KAAK,MAAM;QACb,CAAC,CAAC,+EAA+E;QACjF,CAAC,CAAC,kFAAkF,CACvF,CAAC;AACJ,CAAC;AAED,SAAS,OAAO,CAAC,KAAyB;IACxC,MAAM,KAAK,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,GAAG,WAAW,EAAE,CAAC;IAC1C,IAAI,KAAK,IAAI,4BAA4B,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACpE,MAAM,UAAU,CACd,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,4BAA4B,CAAC,CAAC,CAAC,2BAA2B,EAC3E,yEAAyE,CAC1E,CAAC;AACJ,CAAC;AAED,SAAS,MAAM,CAAC,KAAa;IAC3B,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACxC,IAAI,yBAAyB,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACtD,MAAM,UAAU,CACd,IAAI,KAAK,uBAAuB,EAChC,oEAAoE,CACrE,CAAC;AACJ,CAAC","sourcesContent":["import type { CliContext } from '../context';\nimport { invalidStateError, usageError } from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport {\n createTeam,\n disconnectTeamIntegration,\n inviteTeamMember,\n listTeamMembers,\n listTeamRoles,\n removeTeamMember,\n renameTeam,\n setTeamMemberRole,\n} from '../teams-api';\nimport type { TeamsArgs, TeamsClient } from './teams';\nimport { runTeamConnect } from './teams-connect';\n\n/**\n * Onboarding a team from the terminal, for the Source admin: `teams create`,\n * `teams members list|invite|role|remove`, `teams roles list`,\n * `teams connect` and `teams disconnect`. Parsed before any session is touched (`parseOnboarding`)\n * so a usage error never costs a network round-trip, then run against the\n * session `runTeams` resolved.\n */\n\nexport const ONBOARDING_SUBCOMMANDS = [\n 'create',\n 'rename',\n 'members',\n 'roles',\n 'connect',\n 'disconnect',\n] as const;\nexport type OnboardingSubcommand = (typeof ONBOARDING_SUBCOMMANDS)[number];\n\nexport interface OnboardingFlags {\n slug?: string;\n owner?: string;\n role?: string;\n /** `connect --as <member-email>`: the member who signs in. */\n as?: string;\n yes: boolean;\n}\n\nexport type OnboardingPlan =\n | { kind: 'create'; name: string; slug?: string; ownerEmail?: string }\n | { kind: 'rename'; team: string; name: string }\n | { kind: 'members-list'; team: string }\n | { kind: 'members-invite'; team: string; email: string; role: string }\n | { kind: 'members-role'; team: string; email: string; role: string }\n | { kind: 'members-remove'; team: string; email: string }\n | { kind: 'roles-list'; team: string }\n | { kind: 'connect'; team: string; product: string; as?: string }\n | { kind: 'disconnect'; team: string; product: string };\n\nconst MEMBERS_VERBS = ['list', 'invite', 'role', 'remove'] as const;\n\nexport function isOnboardingSubcommand(\n value: string,\n): value is OnboardingSubcommand {\n return (ONBOARDING_SUBCOMMANDS as readonly string[]).includes(value);\n}\n\nexport function parseOnboarding(\n subcommand: OnboardingSubcommand,\n rest: readonly string[],\n flags: OnboardingFlags,\n): OnboardingPlan {\n if (subcommand === 'create') {\n const [name, ...extra] = rest;\n if (!name?.trim()) {\n throw usageError(\n 'Name the team.',\n 'Run \"ekanos teams create \\\\\"Bank A\\\\\" [--slug bank-a] [--owner <email>]\".',\n );\n }\n noExtra(extra);\n return {\n kind: 'create',\n name: name.trim(),\n slug: flags.slug === undefined ? undefined : slugOf(flags.slug, 'team'),\n ownerEmail: flags.owner === undefined ? undefined : emailOf(flags.owner),\n };\n }\n\n if (subcommand === 'rename') {\n const [team, name, ...extra] = rest;\n const teamSlug = slugOf(team, 'team');\n if (!name?.trim()) {\n throw usageError(\n 'Name the team’s new name.',\n `Run \"ekanos teams rename ${teamSlug} \\\\\"Bank A Support\\\\\"\".`,\n );\n }\n noExtra(extra);\n return { kind: 'rename', team: teamSlug, name: name.trim() };\n }\n\n if (subcommand === 'connect') {\n const [team, product, ...extra] = rest;\n noExtra(extra);\n return {\n kind: 'connect',\n team: slugOf(team, 'team'),\n product: slugOf(product, 'product'),\n ...(flags.as === undefined ? {} : { as: emailOf(flags.as) }),\n };\n }\n\n if (subcommand === 'disconnect') {\n const [team, product, ...extra] = rest;\n noExtra(extra);\n const teamSlug = slugOf(team, 'team');\n const productSlug = slugOf(product, 'product');\n if (!flags.yes) {\n throw invalidStateError(\n `Disconnecting ${productSlug} from ${teamSlug} removes the team's connection and its tokens: every widget, workflow and agent of the team that uses it stops until someone connects it again. The team's own app (its saved fields) stays.`,\n `Re-run with --yes: ekanos teams disconnect ${teamSlug} ${productSlug} --yes`,\n );\n }\n return { kind: 'disconnect', team: teamSlug, product: productSlug };\n }\n\n if (subcommand === 'roles') {\n const [verb, team, ...extra] = rest;\n if (verb !== 'list') {\n throw usageError(\n verb\n ? `Unknown teams roles subcommand \"${verb}\".`\n : 'teams roles needs a subcommand.',\n 'Run \"ekanos teams roles list <team>\".',\n );\n }\n noExtra(extra);\n return { kind: 'roles-list', team: slugOf(team, 'team') };\n }\n\n const [verb, team, email, role, ...extra] = rest;\n const match = MEMBERS_VERBS.find((name) => name === verb);\n if (!match) {\n throw usageError(\n verb\n ? `Unknown teams members subcommand \"${verb}\".`\n : 'teams members needs a subcommand.',\n 'Run one of: ekanos teams members list <team>, ekanos teams members invite <team> <email> --role <role>, ekanos teams members role <team> <email> <role>, ekanos teams members remove <team> <email> --yes.',\n );\n }\n noExtra(extra);\n\n if (match === 'list') {\n if (email !== undefined) noExtra([email]);\n return { kind: 'members-list', team: slugOf(team, 'team') };\n }\n\n const teamSlug = slugOf(team, 'team');\n const address = emailOf(email);\n\n if (match === 'invite') {\n if (role !== undefined) noExtra([role]);\n return {\n kind: 'members-invite',\n team: teamSlug,\n email: address,\n role: roleOf(flags.role ?? 'member'),\n };\n }\n\n if (match === 'role') {\n const named = role ?? flags.role;\n if (!named) {\n throw usageError(\n 'Name the new role.',\n `Run \"ekanos teams members role ${teamSlug} ${address} <role>\"; \"ekanos teams roles list ${teamSlug}\" lists them.`,\n );\n }\n return {\n kind: 'members-role',\n team: teamSlug,\n email: address,\n role: roleOf(named),\n };\n }\n\n if (role !== undefined) noExtra([role]);\n if (!flags.yes) {\n throw invalidStateError(\n `Removing ${address} from ${teamSlug} ends their access to the team (a pending invitation is withdrawn instead).`,\n `Re-run with --yes: ekanos teams members remove ${teamSlug} ${address} --yes`,\n );\n }\n return { kind: 'members-remove', team: teamSlug, email: address };\n}\n\nexport async function runOnboarding(\n ctx: CliContext,\n args: TeamsArgs,\n client: TeamsClient,\n host: string,\n source: string,\n plan: OnboardingPlan,\n): Promise<ExitCode> {\n switch (plan.kind) {\n case 'create': {\n const created = await client.call((token) =>\n createTeam(host, token, source, {\n name: plan.name,\n slug: plan.slug,\n ownerEmail: plan.ownerEmail,\n }),\n );\n return ctx.succeed(\n { host, ...created },\n ctx.ui.result({\n title: `Created team ${created.team.slug}`,\n rows: [\n ['Name', created.team.name],\n ['Source', created.source.slug],\n [\n 'Owner',\n created.owner.kind === 'caller'\n ? `you${created.owner.email ? ` (${created.owner.email})` : ''}`\n : `${created.owner.email} — invited; ownership moves to them on accept`,\n ],\n ['Team home', created.teamUrl],\n ],\n notes: [\n `Next: \"ekanos teams members invite ${created.team.slug} <email> --role <role>\" (\"ekanos teams roles list ${created.team.slug}\" lists the roles).`,\n `Then \"ekanos teams connect ${created.team.slug} <product>\" connects an integration for the team.`,\n ],\n }),\n );\n }\n\n case 'rename': {\n const renamed = await client.call((token) =>\n renameTeam(host, token, { source, team: plan.team }, plan.name),\n );\n const moved = renamed.team.slug !== renamed.previous.slug;\n return ctx.succeed(\n { host, ...renamed },\n ctx.ui.result({\n title:\n renamed.team.name === renamed.previous.name\n ? `${renamed.team.slug} is already named ${renamed.team.name}`\n : `Renamed ${renamed.previous.slug} to ${renamed.team.name}`,\n rows: [\n ['Name', renamed.team.name],\n ['Slug', renamed.team.slug],\n ['Team home', renamed.teamUrl],\n ],\n notes: moved\n ? [\n `The slug followed the name: use \"${renamed.team.slug}\" from now on. Links and scripts naming \"${renamed.previous.slug}\" no longer reach the team.`,\n ]\n : [],\n tone: moved ? 'warn' : 'ok',\n }),\n );\n }\n\n case 'members-list': {\n const list = await client.call((token) =>\n listTeamMembers(host, token, { source, team: plan.team }),\n );\n const rows: [string, string][] = list.members.map((member) => [\n member.email ?? member.userId,\n `${member.role}${member.primaryOwner ? ' · primary owner' : ''}${member.status === 'active' ? '' : ` · ${member.status}`}${member.name ? ` · ${member.name}` : ''}`,\n ]);\n for (const invitation of list.invitations) {\n rows.push([\n invitation.email,\n `${invitation.role} · invited, expires ${invitation.expiresAt.slice(0, 10)}`,\n ]);\n }\n return ctx.succeed(\n { host, ...list },\n ctx.ui.result({\n title: `Members of ${list.team.slug} (${list.team.name})`,\n tone: rows.length === 0 ? 'warn' : 'ok',\n rows,\n notes: [\n `\"ekanos teams members invite ${list.team.slug} <email> --role <role>\" adds one.`,\n ],\n }),\n );\n }\n\n case 'members-invite': {\n const invited = await client.call((token) =>\n inviteTeamMember(\n host,\n token,\n { source, team: plan.team },\n { email: plan.email, role: plan.role },\n ),\n );\n return ctx.succeed(\n { host, ...invited },\n ctx.ui.result({\n title: `Invited ${invited.invitation.email} to ${invited.team.slug}`,\n rows: [\n ['Role', invited.invitation.role],\n ['Expires', invited.invitation.expiresAt.slice(0, 10)],\n ],\n notes: [\n 'The invitation email is on its way; they join when they accept it.',\n ],\n }),\n );\n }\n\n case 'members-role': {\n const changed = await client.call((token) =>\n setTeamMemberRole(\n host,\n token,\n { source, team: plan.team, email: plan.email },\n plan.role,\n ),\n );\n return ctx.succeed(\n { host, ...changed },\n ctx.ui.result({\n title:\n changed.before === changed.after\n ? `${changed.email} is already ${changed.after} on ${changed.team.slug}`\n : `${changed.email} is now ${changed.after} on ${changed.team.slug}`,\n rows: [\n ['Was', changed.before ?? '—'],\n [\n 'Applies to',\n changed.kind === 'member'\n ? 'their membership'\n : 'their pending invitation',\n ],\n ],\n }),\n );\n }\n\n case 'members-remove': {\n const removed = await client.call((token) =>\n removeTeamMember(host, token, {\n source,\n team: plan.team,\n email: plan.email,\n }),\n );\n return ctx.succeed(\n { host, ...removed },\n ctx.ui.result({\n title:\n removed.kind === 'member'\n ? `Removed ${removed.email} from ${removed.team.slug}`\n : `Withdrew ${removed.email}'s invitation to ${removed.team.slug}`,\n rows: [['Role was', removed.before ?? '—']],\n }),\n );\n }\n\n case 'roles-list': {\n const roles = await client.call((token) =>\n listTeamRoles(host, token, { source, team: plan.team }),\n );\n return ctx.succeed(\n { host, ...roles },\n ctx.ui.result({\n title: `Roles on ${roles.team.slug}`,\n rows: roles.roles.map((role) => [\n `${role.name} (${role.displayName})`,\n role.permissions.length > 0 ? role.permissions : ['no permissions'],\n ]),\n notes: [\n 'Lower roles are listed last. Give one with \"ekanos teams members role <team> <email> <role>\".',\n ],\n }),\n );\n }\n\n case 'disconnect': {\n const done = await client.call((token) =>\n disconnectTeamIntegration(host, token, {\n source,\n team: plan.team,\n product: plan.product,\n }),\n );\n return ctx.succeed(\n { host, ...done },\n ctx.ui.result({\n title: done.wasConnected\n ? `Disconnected ${done.product.name} from ${done.team.slug}`\n : `${done.team.slug} had no ${done.product.name} connection; cleared what was left`,\n tone: 'warn',\n notes: [\n `Connect it again with \"ekanos teams connect ${done.team.slug} ${done.product.slug}\".`,\n ],\n }),\n );\n }\n\n case 'connect':\n return runTeamConnect(ctx, args, client, host, source, {\n team: plan.team,\n product: plan.product,\n as: plan.as,\n ...(args.connection ? { connection: args.connection } : {}),\n });\n }\n}\n\nfunction noExtra(extra: readonly string[]) {\n if (extra.length > 0) {\n throw usageError(\n `Unexpected argument \"${extra[0]}\".`,\n 'See \"ekanos teams --help\".',\n );\n }\n}\n\nfunction slugOf(value: string | undefined, what: 'team' | 'product'): 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} slug.` : `Name the ${what}.`,\n what === 'team'\n ? '\"ekanos teams list\" lists the teams, e.g. \"ekanos teams members list bank-a\".'\n : '\"ekanos catalog\" lists the products, e.g. \"ekanos teams connect bank-a zendesk\".',\n );\n}\n\nfunction emailOf(value: string | undefined): string {\n const email = value?.trim().toLowerCase();\n if (email && /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(email)) return email;\n throw usageError(\n value ? `\"${value}\" is not an email address.` : 'Name the person by email.',\n 'e.g. \"ekanos teams members invite bank-a ana@bank-a.com --role member\".',\n );\n}\n\nfunction roleOf(value: string): string {\n const role = value.trim().toLowerCase();\n if (/^[a-z][a-z0-9_-]{0,49}$/.test(role)) return role;\n throw usageError(\n `\"${value}\" is not a role name.`,\n '\"ekanos teams roles list <team>\" lists the roles this Source uses.',\n );\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CliContext } from '../context.js';
|
|
2
|
+
import type { ExitCode } from '../exit-codes.js';
|
|
3
|
+
import type { TeamsClient } from './teams.js';
|
|
4
|
+
/**
|
|
5
|
+
* `ekanos teams show <team>` with no product: one screen per team (CLI audit
|
|
6
|
+
* P1-7) — its members, one line per Integration the Source has enabled (whose
|
|
7
|
+
* connection, or the step to make it), and one line per provided agent with
|
|
8
|
+
* the same verdict as `teams agents show`. Reads the team list, the Source
|
|
9
|
+
* catalog, the team's agents, and each enabled Integration's status.
|
|
10
|
+
*/
|
|
11
|
+
export declare function runTeamOverview(ctx: CliContext, client: TeamsClient, host: string, source: string, team: string): Promise<ExitCode>;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { SourceCatalogSchema, TeamAgentListSchema, } from '@ekanos/integration-schema';
|
|
2
|
+
import { notFoundError } from '../errors.js';
|
|
3
|
+
import { call, listTeams, showTeamIntegration } from '../teams-api.js';
|
|
4
|
+
import { scopeFix, scopeHiddenWords } from './scope-notice.js';
|
|
5
|
+
import { REASON_WORDS, agentReadiness, liveLine, requirementFix, } from './team-agent-readiness.js';
|
|
6
|
+
/**
|
|
7
|
+
* `ekanos teams show <team>` with no product: one screen per team (CLI audit
|
|
8
|
+
* P1-7) — its members, one line per Integration the Source has enabled (whose
|
|
9
|
+
* connection, or the step to make it), and one line per provided agent with
|
|
10
|
+
* the same verdict as `teams agents show`. Reads the team list, the Source
|
|
11
|
+
* catalog, the team's agents, and each enabled Integration's status.
|
|
12
|
+
*/
|
|
13
|
+
export async function runTeamOverview(ctx, client, host, source, team) {
|
|
14
|
+
var _a;
|
|
15
|
+
var _b;
|
|
16
|
+
const [teams, catalog, agents] = await Promise.all([
|
|
17
|
+
client.call((token) => listTeams(host, token, source)),
|
|
18
|
+
client.call((token) => call(host, token, SourceCatalogSchema, {
|
|
19
|
+
method: 'GET',
|
|
20
|
+
path: '/api/partner/catalog',
|
|
21
|
+
source,
|
|
22
|
+
})),
|
|
23
|
+
client.call((token) => call(host, token, TeamAgentListSchema, {
|
|
24
|
+
method: 'GET',
|
|
25
|
+
path: `/api/partner/teams/${encodeURIComponent(team)}/agents`,
|
|
26
|
+
source,
|
|
27
|
+
})),
|
|
28
|
+
]);
|
|
29
|
+
const ref = teams.teams.find((entry) => entry.slug === team);
|
|
30
|
+
if (!ref) {
|
|
31
|
+
throw notFoundError(`No team "${team}" on ${teams.source.slug}.`, 'Run "ekanos teams list" to see the teams on this Source.');
|
|
32
|
+
}
|
|
33
|
+
const integrations = catalog.products.filter((product) => product.kind === 'integration' && product.availability === 'enabled');
|
|
34
|
+
const statuses = await inBatches(integrations, 4, (product) => client.call((token) => showTeamIntegration(host, token, {
|
|
35
|
+
source,
|
|
36
|
+
team,
|
|
37
|
+
product: product.slug,
|
|
38
|
+
})));
|
|
39
|
+
// What the team's agents need of each product, and whose connection it is.
|
|
40
|
+
const needs = new Map();
|
|
41
|
+
for (const entry of agents.agents) {
|
|
42
|
+
for (const item of (_b = (_a = entry.agent) === null || _a === void 0 ? void 0 : _a.requirements) !== null && _b !== void 0 ? _b : []) {
|
|
43
|
+
if (item.kind === 'product' && !needs.has(item.key)) {
|
|
44
|
+
needs.set(item.key, item);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const target = { team, source };
|
|
49
|
+
const agentRows = agents.agents.map((entry) => { var _a; return ({
|
|
50
|
+
key: entry.key,
|
|
51
|
+
name: entry.name,
|
|
52
|
+
on: ((_a = entry.agent) === null || _a === void 0 ? void 0 : _a.status) === 'active',
|
|
53
|
+
readiness: agentReadiness(entry, target),
|
|
54
|
+
}); });
|
|
55
|
+
const integrationRows = integrations.map((product, index) => ({
|
|
56
|
+
slug: product.slug,
|
|
57
|
+
name: product.name,
|
|
58
|
+
line: withScope(integrationLine(product, statuses[index], needs.get(product.slug), target), statuses[index], Object.assign(Object.assign({}, target), { product: product.slug })),
|
|
59
|
+
}));
|
|
60
|
+
const width = Math.max(8, ...integrations.map((product) => product.slug.length), ...agents.agents.map((entry) => entry.key.length));
|
|
61
|
+
const pad = (label) => label.padEnd(width);
|
|
62
|
+
const live = agentRows.filter((row) => row.readiness.live).length;
|
|
63
|
+
return ctx.succeed({
|
|
64
|
+
host,
|
|
65
|
+
team: { slug: ref.slug, name: ref.name, memberCount: ref.memberCount },
|
|
66
|
+
integrations: integrationRows.map((row, index) => { var _a; return ({
|
|
67
|
+
slug: row.slug,
|
|
68
|
+
name: row.name,
|
|
69
|
+
status: statuses[index],
|
|
70
|
+
agentsNeed: (_a = needs.get(row.slug)) !== null && _a !== void 0 ? _a : null,
|
|
71
|
+
}); }),
|
|
72
|
+
agents: agentRows,
|
|
73
|
+
}, [
|
|
74
|
+
`${ref.name} (${ref.slug}) · ${ref.memberCount} member${ref.memberCount === 1 ? '' : 's'} · ${agentRows.filter((row) => row.on).length} agent${agentRows.filter((row) => row.on).length === 1 ? '' : 's'} on, ${live} live`,
|
|
75
|
+
'',
|
|
76
|
+
'Integrations',
|
|
77
|
+
...(integrationRows.length === 0
|
|
78
|
+
? [' none enabled for the Source']
|
|
79
|
+
: integrationRows.flatMap((row) => [
|
|
80
|
+
` ${pad(row.slug)} ${row.line.state}`,
|
|
81
|
+
...(row.line.fix ? [` ${pad('')} → ${row.line.fix}`] : []),
|
|
82
|
+
])),
|
|
83
|
+
'',
|
|
84
|
+
'Agents',
|
|
85
|
+
...(agentRows.length === 0
|
|
86
|
+
? [' none provided']
|
|
87
|
+
: agentRows.map((row, index) => { var _a; return ` ${pad(row.key)} ${liveLine(row.readiness, (_a = agents.agents[index]) === null || _a === void 0 ? void 0 : _a.agent)}${row.readiness.next ? ` · Next: ${row.readiness.next}` : ''}`; })),
|
|
88
|
+
'',
|
|
89
|
+
`"ekanos teams agents show ${team} <key>" explains one agent; "ekanos teams show ${team} <product>" one integration.`,
|
|
90
|
+
].join('\n'));
|
|
91
|
+
}
|
|
92
|
+
function integrationLine(product, status, need, target) {
|
|
93
|
+
var _a;
|
|
94
|
+
if ((need === null || need === void 0 ? void 0 : need.owner) === 'source' || (need === null || need === void 0 ? void 0 : need.via) === 'source') {
|
|
95
|
+
const problem = need.reason && need.reason !== 'not_connected'
|
|
96
|
+
? REASON_WORDS[need.reason]
|
|
97
|
+
: null;
|
|
98
|
+
const state = !need.connected
|
|
99
|
+
? `✗ via Source connection — ${problem !== null && problem !== void 0 ? problem : REASON_WORDS.not_connected}`
|
|
100
|
+
: need.via === 'source'
|
|
101
|
+
? `✓ via Source connection${need.viaDetail ? ` · routes: ${need.viaDetail}` : ''}`
|
|
102
|
+
: `! via team connection (${problem !== null && problem !== void 0 ? problem : 'the Source connection is not used'})`;
|
|
103
|
+
return {
|
|
104
|
+
state,
|
|
105
|
+
fix: need.connected && need.via === 'source'
|
|
106
|
+
? null
|
|
107
|
+
: requirementFix(need, target.team, target.source),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
if (!product.requiresActivation) {
|
|
111
|
+
return { state: '✓ works as shipped', fix: null };
|
|
112
|
+
}
|
|
113
|
+
if (product.scope === 'user') {
|
|
114
|
+
const person = (need === null || need === void 0 ? void 0 : need.via) === 'person' && need.viaDetail
|
|
115
|
+
? need.connected
|
|
116
|
+
? ` · ✓ ${need.viaDetail} connected (an agent runs as them)`
|
|
117
|
+
: ` · ✗ ${need.viaDetail} not connected (an agent runs as them)`
|
|
118
|
+
: '';
|
|
119
|
+
return {
|
|
120
|
+
state: `personal: each person connects their own${person}`,
|
|
121
|
+
fix: need && !need.connected
|
|
122
|
+
? requirementFix(need, target.team, target.source)
|
|
123
|
+
: null,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
const webhooks = status.teamApps.flatMap((app) => app.webhooks);
|
|
127
|
+
const made = webhooks.filter((webhook) => webhook.endpoint).length;
|
|
128
|
+
const webhookNote = webhooks.length > 0 ? ` · webhook URL ${made}/${webhooks.length} made` : '';
|
|
129
|
+
if (status.activation) {
|
|
130
|
+
const by = (_a = status.activation.activatedBy) === null || _a === void 0 ? void 0 : _a.email;
|
|
131
|
+
return {
|
|
132
|
+
state: `✓ connected${status.activation.activatedAt ? ` ${status.activation.activatedAt.slice(0, 10)}` : ''}${by ? ` by ${by}` : ''}${webhookNote}`,
|
|
133
|
+
fix: null,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
state: `✗ not connected${webhookNote}`,
|
|
138
|
+
fix: `npx @ekanos/cli teams connect ${target.team} ${product.slug} --source ${target.source}`,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/** A product the team's scopes hide from it in the app says so, whatever else is true. */
|
|
142
|
+
function withScope(line, status, target) {
|
|
143
|
+
var _a;
|
|
144
|
+
var _b;
|
|
145
|
+
if (!((_a = status.scope) === null || _a === void 0 ? void 0 : _a.hidden))
|
|
146
|
+
return line;
|
|
147
|
+
return {
|
|
148
|
+
state: `${line.state} · ! ${scopeHiddenWords(status.scope)}`,
|
|
149
|
+
fix: (_b = line.fix) !== null && _b !== void 0 ? _b : scopeFix(status.scope, target),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
/** Each item through `read`, at most `size` at a time, in order. */
|
|
153
|
+
async function inBatches(items, size, read) {
|
|
154
|
+
const results = [];
|
|
155
|
+
for (let start = 0; start < items.length; start += size) {
|
|
156
|
+
results.push(...(await Promise.all(items.slice(start, start + size).map(read))));
|
|
157
|
+
}
|
|
158
|
+
return results;
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=teams-overview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"teams-overview.js","sourceRoot":"","sources":["../../src/commands/teams-overview.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,mBAAmB,EACnB,mBAAmB,GAEpB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EACL,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,cAAc,GACf,MAAM,wBAAwB,CAAC;AAGhC;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,GAAe,EACf,MAAmB,EACnB,IAAY,EACZ,MAAc,EACd,IAAY;;;IAEZ,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACjD,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;QACtD,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CACpB,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,mBAAmB,EAAE;YACrC,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,sBAAsB;YAC5B,MAAM;SACP,CAAC,CACH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;QACtC,GAAG,EAAE,iCAAiC,MAAM,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,aAAa,MAAM,CAAC,MAAM,EAAE;KAC9F,CAAC;AACJ,CAAC;AAED,0FAA0F;AAC1F,SAAS,SAAS,CAChB,IAA2C,EAC3C,MAA6B,EAC7B,MAAyD;;;IAEzD,IAAI,EAAC,MAAA,MAAM,CAAC,KAAK,0CAAE,MAAM,CAAA;QAAE,OAAO,IAAI,CAAC;IACvC,OAAO;QACL,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,QAAQ,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;QAC5D,GAAG,QAAE,IAAI,CAAC,GAAG,mCAAI,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC;KAChD,CAAC;AACJ,CAAC;AAED,oEAAoE;AACpE,KAAK,UAAU,SAAS,CACtB,KAAU,EACV,IAAY,EACZ,IAA6B;IAE7B,MAAM,OAAO,GAAQ,EAAE,CAAC;IACxB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,IAAI,IAAI,EAAE,CAAC;QACxD,OAAO,CAAC,IAAI,CACV,GAAG,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CACnE,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import {\n type CatalogProduct,\n type Requirement,\n SourceCatalogSchema,\n TeamAgentListSchema,\n type TeamIntegrationStatus,\n} from '@ekanos/integration-schema';\n\nimport type { CliContext } from '../context';\nimport { notFoundError } from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { call, listTeams, showTeamIntegration } from '../teams-api';\nimport { scopeFix, scopeHiddenWords } from './scope-notice';\nimport {\n REASON_WORDS,\n agentReadiness,\n liveLine,\n requirementFix,\n} from './team-agent-readiness';\nimport type { TeamsClient } from './teams';\n\n/**\n * `ekanos teams show <team>` with no product: one screen per team (CLI audit\n * P1-7) — its members, one line per Integration the Source has enabled (whose\n * connection, or the step to make it), and one line per provided agent with\n * the same verdict as `teams agents show`. Reads the team list, the Source\n * catalog, the team's agents, and each enabled Integration's status.\n */\nexport async function runTeamOverview(\n ctx: CliContext,\n client: TeamsClient,\n host: string,\n source: string,\n team: string,\n): Promise<ExitCode> {\n const [teams, catalog, agents] = await Promise.all([\n client.call((token) => listTeams(host, token, source)),\n client.call((token) =>\n call(host, token, SourceCatalogSchema, {\n method: 'GET',\n path: '/api/partner/catalog',\n source,\n }),\n ),\n client.call((token) =>\n call(host, token, TeamAgentListSchema, {\n method: 'GET',\n path: `/api/partner/teams/${encodeURIComponent(team)}/agents`,\n source,\n }),\n ),\n ]);\n const ref = teams.teams.find((entry) => entry.slug === team);\n if (!ref) {\n throw notFoundError(\n `No team \"${team}\" on ${teams.source.slug}.`,\n 'Run \"ekanos teams list\" to see the teams on this Source.',\n );\n }\n\n const integrations = catalog.products.filter(\n (product) =>\n product.kind === 'integration' && product.availability === 'enabled',\n );\n const statuses = await inBatches(integrations, 4, (product) =>\n client.call((token) =>\n showTeamIntegration(host, token, {\n source,\n team,\n product: product.slug,\n }),\n ),\n );\n\n // What the team's agents need of each product, and whose connection it is.\n const needs = new Map<string, Requirement>();\n for (const entry of agents.agents) {\n for (const item of entry.agent?.requirements ?? []) {\n if (item.kind === 'product' && !needs.has(item.key)) {\n needs.set(item.key, item);\n }\n }\n }\n\n const target = { team, source };\n const agentRows = agents.agents.map((entry) => ({\n key: entry.key,\n name: entry.name,\n on: entry.agent?.status === 'active',\n readiness: agentReadiness(entry, target),\n }));\n const integrationRows = integrations.map((product, index) => ({\n slug: product.slug,\n name: product.name,\n line: withScope(\n integrationLine(\n product,\n statuses[index]!,\n needs.get(product.slug),\n target,\n ),\n statuses[index]!,\n { ...target, product: product.slug },\n ),\n }));\n\n const width = Math.max(\n 8,\n ...integrations.map((product) => product.slug.length),\n ...agents.agents.map((entry) => entry.key.length),\n );\n const pad = (label: string) => label.padEnd(width);\n const live = agentRows.filter((row) => row.readiness.live).length;\n\n return ctx.succeed(\n {\n host,\n team: { slug: ref.slug, name: ref.name, memberCount: ref.memberCount },\n integrations: integrationRows.map((row, index) => ({\n slug: row.slug,\n name: row.name,\n status: statuses[index],\n agentsNeed: needs.get(row.slug) ?? null,\n })),\n agents: agentRows,\n },\n [\n `${ref.name} (${ref.slug}) · ${ref.memberCount} member${ref.memberCount === 1 ? '' : 's'} · ${agentRows.filter((row) => row.on).length} agent${agentRows.filter((row) => row.on).length === 1 ? '' : 's'} on, ${live} live`,\n '',\n 'Integrations',\n ...(integrationRows.length === 0\n ? [' none enabled for the Source']\n : integrationRows.flatMap((row) => [\n ` ${pad(row.slug)} ${row.line.state}`,\n ...(row.line.fix ? [` ${pad('')} → ${row.line.fix}`] : []),\n ])),\n '',\n 'Agents',\n ...(agentRows.length === 0\n ? [' none provided']\n : agentRows.map(\n (row, index) =>\n ` ${pad(row.key)} ${liveLine(row.readiness, agents.agents[index]?.agent)}${row.readiness.next ? ` · Next: ${row.readiness.next}` : ''}`,\n )),\n '',\n `\"ekanos teams agents show ${team} <key>\" explains one agent; \"ekanos teams show ${team} <product>\" one integration.`,\n ].join('\\n'),\n );\n}\n\nfunction integrationLine(\n product: CatalogProduct,\n status: TeamIntegrationStatus,\n need: Requirement | undefined,\n target: { team: string; source: string },\n): { state: string; fix: string | null } {\n if (need?.owner === 'source' || need?.via === 'source') {\n const problem =\n need.reason && need.reason !== 'not_connected'\n ? REASON_WORDS[need.reason]\n : null;\n const state = !need.connected\n ? `✗ via Source connection — ${problem ?? REASON_WORDS.not_connected}`\n : need.via === 'source'\n ? `✓ via Source connection${need.viaDetail ? ` · routes: ${need.viaDetail}` : ''}`\n : `! via team connection (${problem ?? 'the Source connection is not used'})`;\n return {\n state,\n fix:\n need.connected && need.via === 'source'\n ? null\n : requirementFix(need, target.team, target.source),\n };\n }\n if (!product.requiresActivation) {\n return { state: '✓ works as shipped', fix: null };\n }\n if (product.scope === 'user') {\n const person =\n need?.via === 'person' && need.viaDetail\n ? need.connected\n ? ` · ✓ ${need.viaDetail} connected (an agent runs as them)`\n : ` · ✗ ${need.viaDetail} not connected (an agent runs as them)`\n : '';\n return {\n state: `personal: each person connects their own${person}`,\n fix:\n need && !need.connected\n ? requirementFix(need, target.team, target.source)\n : null,\n };\n }\n const webhooks = status.teamApps.flatMap((app) => app.webhooks);\n const made = webhooks.filter((webhook) => webhook.endpoint).length;\n const webhookNote =\n webhooks.length > 0 ? ` · webhook URL ${made}/${webhooks.length} made` : '';\n if (status.activation) {\n const by = status.activation.activatedBy?.email;\n return {\n state: `✓ connected${status.activation.activatedAt ? ` ${status.activation.activatedAt.slice(0, 10)}` : ''}${by ? ` by ${by}` : ''}${webhookNote}`,\n fix: null,\n };\n }\n return {\n state: `✗ not connected${webhookNote}`,\n fix: `npx @ekanos/cli teams connect ${target.team} ${product.slug} --source ${target.source}`,\n };\n}\n\n/** A product the team's scopes hide from it in the app says so, whatever else is true. */\nfunction withScope(\n line: { state: string; fix: string | null },\n status: TeamIntegrationStatus,\n target: { team: string; source: string; product: string },\n): { state: string; fix: string | null } {\n if (!status.scope?.hidden) return line;\n return {\n state: `${line.state} · ! ${scopeHiddenWords(status.scope)}`,\n fix: line.fix ?? scopeFix(status.scope, target),\n };\n}\n\n/** Each item through `read`, at most `size` at a time, in order. */\nasync function inBatches<T, R>(\n items: T[],\n size: number,\n read: (item: T) => Promise<R>,\n): Promise<R[]> {\n const results: R[] = [];\n for (let start = 0; start < items.length; start += size) {\n results.push(\n ...(await Promise.all(items.slice(start, start + size).map(read))),\n );\n }\n return results;\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CliContext } from '../context.js';
|
|
2
|
+
import type { ExitCode } from '../exit-codes.js';
|
|
3
|
+
import { type TeamsArgs } from './teams.js';
|
|
4
|
+
/**
|
|
5
|
+
* `teams scope show|set <team>` — which of the Source's product scopes a team
|
|
6
|
+
* holds, and so which products it sees in the app. `set` replaces them
|
|
7
|
+
* (names or ids); taking one away can hide products the team uses, so that
|
|
8
|
+
* needs `--yes`. The Source's scopes and their products: `sources scopes`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function runTeamScope(ctx: CliContext, args: TeamsArgs, rest: readonly string[]): Promise<ExitCode>;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { requireSession, resolveAuthEnvironment } from '../auth/session.js';
|
|
2
|
+
import { invalidStateError, usageError } from '../errors.js';
|
|
3
|
+
import { resolveSourceTarget } from '../source-target.js';
|
|
4
|
+
import { setTeamScopes, showTeamScopes } from '../teams-api.js';
|
|
5
|
+
import { TeamsClient } from './teams.js';
|
|
6
|
+
const USAGE = 'Run "ekanos teams scope show <team>" or "ekanos teams scope set <team> <scope> [<scope>…] [--yes]".';
|
|
7
|
+
/**
|
|
8
|
+
* `teams scope show|set <team>` — which of the Source's product scopes a team
|
|
9
|
+
* holds, and so which products it sees in the app. `set` replaces them
|
|
10
|
+
* (names or ids); taking one away can hide products the team uses, so that
|
|
11
|
+
* needs `--yes`. The Source's scopes and their products: `sources scopes`.
|
|
12
|
+
*/
|
|
13
|
+
export async function runTeamScope(ctx, args, rest) {
|
|
14
|
+
const [verb, rawTeam, ...scopes] = rest;
|
|
15
|
+
if (verb !== 'show' && verb !== 'set') {
|
|
16
|
+
throw usageError(verb
|
|
17
|
+
? `Unknown teams scope subcommand "${verb}".`
|
|
18
|
+
: 'teams scope needs a subcommand.', USAGE);
|
|
19
|
+
}
|
|
20
|
+
const team = rawTeam === null || rawTeam === void 0 ? void 0 : rawTeam.trim().toLowerCase();
|
|
21
|
+
if (!team || !/^[a-z0-9][a-z0-9-]*$/.test(team)) {
|
|
22
|
+
throw usageError(rawTeam
|
|
23
|
+
? `"${rawTeam}" is not a team slug.`
|
|
24
|
+
: `teams scope ${verb} needs a team.`, USAGE);
|
|
25
|
+
}
|
|
26
|
+
if (verb === 'show' && scopes.length > 0) {
|
|
27
|
+
throw usageError(`Unexpected argument "${scopes[0]}".`, USAGE);
|
|
28
|
+
}
|
|
29
|
+
if (verb === 'set' && scopes.length === 0) {
|
|
30
|
+
throw usageError('Name the scope (or scopes) the team should hold.', `"ekanos sources scopes" lists them, e.g. "ekanos teams scope set ${team} Gold".`);
|
|
31
|
+
}
|
|
32
|
+
const env = resolveAuthEnvironment(ctx, args.host, args.env, {
|
|
33
|
+
projectDir: args.dir,
|
|
34
|
+
});
|
|
35
|
+
const resolved = await resolveSourceTarget(env, requireSession(env), args);
|
|
36
|
+
const client = new TeamsClient(env, resolved.session);
|
|
37
|
+
const target = { source: resolved.source, team };
|
|
38
|
+
const current = await client.call((token) => showTeamScopes(env.host, token, target));
|
|
39
|
+
if (verb === 'show') {
|
|
40
|
+
return ctx.succeed(Object.assign({ host: env.host }, current), describe(ctx.ui, current, resolved.source));
|
|
41
|
+
}
|
|
42
|
+
const wanted = scopes.map((scope) => scope.trim().toLowerCase());
|
|
43
|
+
const dropped = current.scopes.filter((scope) => !wanted.includes(scope.name.toLowerCase()) && !wanted.includes(scope.id));
|
|
44
|
+
if (dropped.length > 0 && !args.yes) {
|
|
45
|
+
throw invalidStateError(`${team} would no longer hold ${dropped.map((scope) => scope.name).join(', ')}: any product only ${dropped.length === 1 ? 'it shows' : 'they show'} disappears from the team in the app.`, `Re-run with --yes: ekanos teams scope set ${team} ${scopes.map(quote).join(' ')} --source ${resolved.source} --yes`);
|
|
46
|
+
}
|
|
47
|
+
const result = await client.call((token) => setTeamScopes(env.host, token, target, scopes));
|
|
48
|
+
return ctx.succeed(Object.assign({ host: env.host }, result), [
|
|
49
|
+
ctx.ui.result({
|
|
50
|
+
title: `${result.team.slug} holds ${names(result.scopes)}`,
|
|
51
|
+
tone: result.hidden.length > 0 ? 'warn' : 'ok',
|
|
52
|
+
rows: [
|
|
53
|
+
['Before', names(result.before)],
|
|
54
|
+
...(result.hidden.length > 0
|
|
55
|
+
? [
|
|
56
|
+
[
|
|
57
|
+
'No longer sees',
|
|
58
|
+
result.hidden.map((product) => product.slug),
|
|
59
|
+
],
|
|
60
|
+
]
|
|
61
|
+
: []),
|
|
62
|
+
],
|
|
63
|
+
}),
|
|
64
|
+
describe(ctx.ui, result, resolved.source),
|
|
65
|
+
].join('\n\n'));
|
|
66
|
+
}
|
|
67
|
+
function describe(ui, scopes, source) {
|
|
68
|
+
var _a, _b;
|
|
69
|
+
if (scopes.state === 'unscoped') {
|
|
70
|
+
return ui.result({
|
|
71
|
+
title: `${scopes.team.slug} sees every product ${scopes.source.slug} has`,
|
|
72
|
+
rows: [['Scopes', `none: ${scopes.source.slug} has no product scopes`]],
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
if (scopes.state === 'locked_out') {
|
|
76
|
+
return ui.result({
|
|
77
|
+
title: `${scopes.team.slug} sees no product in the app`,
|
|
78
|
+
tone: 'warn',
|
|
79
|
+
rows: [['Scopes', `none of ${scopes.source.slug}'s`]],
|
|
80
|
+
notes: [
|
|
81
|
+
`Give it one: ekanos teams scope set ${scopes.team.slug} <scope> --source ${source} ("ekanos sources scopes" lists them).`,
|
|
82
|
+
],
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return ui.result({
|
|
86
|
+
title: `What ${scopes.team.slug} sees in the app`,
|
|
87
|
+
rows: [
|
|
88
|
+
['Scopes', names(scopes.scopes)],
|
|
89
|
+
[
|
|
90
|
+
'Products',
|
|
91
|
+
((_a = scopes.products) !== null && _a !== void 0 ? _a : []).length > 0
|
|
92
|
+
? ((_b = scopes.products) !== null && _b !== void 0 ? _b : []).map((product) => product.slug)
|
|
93
|
+
: 'none',
|
|
94
|
+
],
|
|
95
|
+
],
|
|
96
|
+
notes: [
|
|
97
|
+
`"ekanos sources scopes add <scope> <product>" shows a product to every team on a scope.`,
|
|
98
|
+
],
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
function names(scopes) {
|
|
102
|
+
return scopes.length > 0
|
|
103
|
+
? scopes.map((scope) => scope.name).join(', ')
|
|
104
|
+
: 'no scope';
|
|
105
|
+
}
|
|
106
|
+
function quote(name) {
|
|
107
|
+
return /^[A-Za-z0-9._-]+$/.test(name) ? name : `"${name}"`;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=teams-scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"teams-scope.js","sourceRoot":"","sources":["../../src/commands/teams-scope.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEzE,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE7D,OAAO,EAAE,WAAW,EAAkB,MAAM,SAAS,CAAC;AAEtD,MAAM,KAAK,GACT,qGAAqG,CAAC;AAExG;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,GAAe,EACf,IAAe,EACf,IAAuB;IAEvB,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,GAAG,IAAI,CAAC;IACxC,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QACtC,MAAM,UAAU,CACd,IAAI;YACF,CAAC,CAAC,mCAAmC,IAAI,IAAI;YAC7C,CAAC,CAAC,iCAAiC,EACrC,KAAK,CACN,CAAC;IACJ,CAAC;IACD,MAAM,IAAI,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,GAAG,WAAW,EAAE,CAAC;IAC3C,IAAI,CAAC,IAAI,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAChD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E,CAAC,CAAC,QAAQ,EAAE,WAAW,MAAM,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC;YACrD,KAAK,EAAE;gBACL,uCAAuC,MAAM,CAAC,IAAI,CAAC,IAAI,qBAAqB,MAAM,wCAAwC;aAC3H;SACF,CAAC,CAAC;IACL,CAAC;IACD,OAAO,EAAE,CAAC,MAAM,CAAC;QACf,KAAK,EAAE,QAAQ,MAAM,CAAC,IAAI,CAAC,IAAI,kBAAkB;QACjD,IAAI,EAAE;YACJ,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAChC;gBACE,UAAU;gBACV,OAAC,MAAM,CAAC,QAAQ,mCAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC;oBAChC,CAAC,CAAC,OAAC,MAAM,CAAC,QAAQ,mCAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;oBACxD,CAAC,CAAC,MAAM;aACX;SACF;QACD,KAAK,EAAE;YACL,yFAAyF;SAC1F;KACF,CAAC,CAAC;AACL,CAAC;AAED,SAAS,KAAK,CAAC,MAA+B;IAC5C,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC;QACtB,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QAC9C,CAAC,CAAC,UAAU,CAAC;AACjB,CAAC;AAED,SAAS,KAAK,CAAC,IAAY;IACzB,OAAO,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,GAAG,CAAC;AAC7D,CAAC","sourcesContent":["import type { TeamScopes } from '@ekanos/integration-schema';\n\nimport { requireSession, resolveAuthEnvironment } from '../auth/session';\nimport type { CliContext } from '../context';\nimport { invalidStateError, usageError } from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { resolveSourceTarget } from '../source-target';\nimport { setTeamScopes, showTeamScopes } from '../teams-api';\nimport type { Ui } from '../ui';\nimport { TeamsClient, type TeamsArgs } from './teams';\n\nconst USAGE =\n 'Run \"ekanos teams scope show <team>\" or \"ekanos teams scope set <team> <scope> [<scope>…] [--yes]\".';\n\n/**\n * `teams scope show|set <team>` — which of the Source's product scopes a team\n * holds, and so which products it sees in the app. `set` replaces them\n * (names or ids); taking one away can hide products the team uses, so that\n * needs `--yes`. The Source's scopes and their products: `sources scopes`.\n */\nexport async function runTeamScope(\n ctx: CliContext,\n args: TeamsArgs,\n rest: readonly string[],\n): Promise<ExitCode> {\n const [verb, rawTeam, ...scopes] = rest;\n if (verb !== 'show' && verb !== 'set') {\n throw usageError(\n verb\n ? `Unknown teams scope subcommand \"${verb}\".`\n : 'teams scope needs a subcommand.',\n USAGE,\n );\n }\n const team = rawTeam?.trim().toLowerCase();\n if (!team || !/^[a-z0-9][a-z0-9-]*$/.test(team)) {\n throw usageError(\n rawTeam\n ? `\"${rawTeam}\" is not a team slug.`\n : `teams scope ${verb} needs a team.`,\n USAGE,\n );\n }\n if (verb === 'show' && scopes.length > 0) {\n throw usageError(`Unexpected argument \"${scopes[0]}\".`, USAGE);\n }\n if (verb === 'set' && scopes.length === 0) {\n throw usageError(\n 'Name the scope (or scopes) the team should hold.',\n `\"ekanos sources scopes\" lists them, e.g. \"ekanos teams scope set ${team} Gold\".`,\n );\n }\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 client = new TeamsClient(env, resolved.session);\n const target = { source: resolved.source, team };\n\n const current = await client.call((token) =>\n showTeamScopes(env.host, token, target),\n );\n if (verb === 'show') {\n return ctx.succeed(\n { host: env.host, ...current },\n describe(ctx.ui, current, resolved.source),\n );\n }\n\n const wanted = scopes.map((scope) => scope.trim().toLowerCase());\n const dropped = current.scopes.filter(\n (scope) =>\n !wanted.includes(scope.name.toLowerCase()) && !wanted.includes(scope.id),\n );\n if (dropped.length > 0 && !args.yes) {\n throw invalidStateError(\n `${team} would no longer hold ${dropped.map((scope) => scope.name).join(', ')}: any product only ${dropped.length === 1 ? 'it shows' : 'they show'} disappears from the team in the app.`,\n `Re-run with --yes: ekanos teams scope set ${team} ${scopes.map(quote).join(' ')} --source ${resolved.source} --yes`,\n );\n }\n\n const result = await client.call((token) =>\n setTeamScopes(env.host, token, target, scopes),\n );\n return ctx.succeed(\n { host: env.host, ...result },\n [\n ctx.ui.result({\n title: `${result.team.slug} holds ${names(result.scopes)}`,\n tone: result.hidden.length > 0 ? 'warn' : 'ok',\n rows: [\n ['Before', names(result.before)],\n ...(result.hidden.length > 0\n ? ([\n [\n 'No longer sees',\n result.hidden.map((product) => product.slug),\n ],\n ] as Array<[string, string[]]>)\n : []),\n ],\n }),\n describe(ctx.ui, result, resolved.source),\n ].join('\\n\\n'),\n );\n}\n\nfunction describe(ui: Ui, scopes: TeamScopes, source: string): string {\n if (scopes.state === 'unscoped') {\n return ui.result({\n title: `${scopes.team.slug} sees every product ${scopes.source.slug} has`,\n rows: [['Scopes', `none: ${scopes.source.slug} has no product scopes`]],\n });\n }\n if (scopes.state === 'locked_out') {\n return ui.result({\n title: `${scopes.team.slug} sees no product in the app`,\n tone: 'warn',\n rows: [['Scopes', `none of ${scopes.source.slug}'s`]],\n notes: [\n `Give it one: ekanos teams scope set ${scopes.team.slug} <scope> --source ${source} (\"ekanos sources scopes\" lists them).`,\n ],\n });\n }\n return ui.result({\n title: `What ${scopes.team.slug} sees in the app`,\n rows: [\n ['Scopes', names(scopes.scopes)],\n [\n 'Products',\n (scopes.products ?? []).length > 0\n ? (scopes.products ?? []).map((product) => product.slug)\n : 'none',\n ],\n ],\n notes: [\n `\"ekanos sources scopes add <scope> <product>\" shows a product to every team on a scope.`,\n ],\n });\n}\n\nfunction names(scopes: Array<{ name: string }>): string {\n return scopes.length > 0\n ? scopes.map((scope) => scope.name).join(', ')\n : 'no scope';\n}\n\nfunction quote(name: string): string {\n return /^[A-Za-z0-9._-]+$/.test(name) ? name : `\"${name}\"`;\n}\n"]}
|
package/dist/commands/teams.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type { TeamIntegrationStatus } from '@ekanos/integration-schema';
|
|
1
|
+
import type { TeamAppState, TeamIntegrationStatus } from '@ekanos/integration-schema';
|
|
2
2
|
import type { StoredSession } from '../auth/credential-store.js';
|
|
3
3
|
import { type AuthEnvironment } from '../auth/session.js';
|
|
4
4
|
import type { CliContext } from '../context.js';
|
|
5
5
|
import type { ExitCode } from '../exit-codes.js';
|
|
6
6
|
import { type TeamsApiResult } from '../teams-api.js';
|
|
7
|
-
export declare const TEAMS_SUBCOMMANDS: readonly ["list", "show", "app", "webhook", "create", "members", "roles", "connect"];
|
|
7
|
+
export declare const TEAMS_SUBCOMMANDS: readonly ["list", "show", "app", "webhook", "events", "scope", "create", "rename", "members", "roles", "connect", "disconnect"];
|
|
8
8
|
export interface TeamsArgs {
|
|
9
9
|
host?: string;
|
|
10
10
|
source?: string;
|
|
11
|
-
/** `list`, `show <team> <product
|
|
11
|
+
/** `list`, `show <team> [<product>]`, `app set <team> <product>`, `webhook <team> <product> [<id>]`. */
|
|
12
12
|
positionals: readonly string[];
|
|
13
13
|
connection?: string;
|
|
14
14
|
/** `create --slug`, `create --owner <email>`, `members invite --role`. */
|
|
@@ -16,6 +16,17 @@ export interface TeamsArgs {
|
|
|
16
16
|
owner?: string;
|
|
17
17
|
role?: string;
|
|
18
18
|
yes: boolean;
|
|
19
|
+
/** `connect --no-wait`: print the sign-in link and return without polling. */
|
|
20
|
+
noWait?: boolean;
|
|
21
|
+
/** `connect --no-open`: never open a browser, only print the link. */
|
|
22
|
+
noOpen?: boolean;
|
|
23
|
+
/** `connect --link-only`: print the team's page, as before connect did the work. */
|
|
24
|
+
linkOnly?: boolean;
|
|
25
|
+
/** `connect --reconnect`: connect again though it reads as connected. */
|
|
26
|
+
reconnect?: boolean;
|
|
27
|
+
/** Test seams for `connect`: the wait between polls, and the browser opener. */
|
|
28
|
+
pollDelayMs?: number;
|
|
29
|
+
openUrl?: (url: string) => void;
|
|
19
30
|
/** Every parsed flag, for `teams agents|triggers|links|mcp` (team-agents.ts). */
|
|
20
31
|
flags?: Record<string, string | boolean | string[]>;
|
|
21
32
|
dir: string;
|
|
@@ -25,21 +36,67 @@ export interface TeamsArgs {
|
|
|
25
36
|
ask?: (question: string) => Promise<string>;
|
|
26
37
|
askSecret?: (question: string) => Promise<string>;
|
|
27
38
|
}
|
|
39
|
+
export interface Target {
|
|
40
|
+
source: string;
|
|
41
|
+
team: string;
|
|
42
|
+
product: string;
|
|
43
|
+
}
|
|
28
44
|
/**
|
|
29
45
|
* `teams` — a Source admin's view of its teams' integration setup, the
|
|
30
46
|
* team-level counterpart of `apps`. `list` names the teams; `show` reads one
|
|
31
|
-
* team's setup of one product as a checklist; `app set` enters
|
|
32
|
-
* app (Zendesk's subdomain, client and signing
|
|
33
|
-
*
|
|
34
|
-
*
|
|
47
|
+
* team's setup of one product as a checklist; `app set` enters or updates
|
|
48
|
+
* any of a team's own app fields (Zendesk's subdomain, client and signing
|
|
49
|
+
* secret), one at a time if need be — a field left alone keeps its saved
|
|
50
|
+
* value. Secrets are only ever typed at the admin's terminal, never from a
|
|
51
|
+
* flag, a file or a non-interactive run, so an agent driving the CLI never
|
|
52
|
+
* handles one; a non-secret field may be passed as `--set name=value`; `webhook` mints the URL the
|
|
35
53
|
* team's provider sends to, shown once.
|
|
36
54
|
*/
|
|
37
55
|
export declare function runTeams(ctx: CliContext, args: TeamsArgs): Promise<ExitCode>;
|
|
56
|
+
/** What `teams app set` was asked to change, from its flags. */
|
|
57
|
+
interface AppEdits {
|
|
58
|
+
/** `--field`: enter just these, at the terminal. */
|
|
59
|
+
only: string[];
|
|
60
|
+
/** `--set name=value`: non-secret values, no prompt. */
|
|
61
|
+
values: Record<string, string>;
|
|
62
|
+
/** `--clear name`: remove a saved value. */
|
|
63
|
+
clear: string[];
|
|
64
|
+
/** Whether anything is asked at the terminal. */
|
|
65
|
+
prompts: boolean;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The `teams app set` walkthrough and prompts for one team app, then the
|
|
69
|
+
* save — of only what was entered: a field left empty keeps its saved value.
|
|
70
|
+
* Shared with `teams connect`, which runs it inline when the integration
|
|
71
|
+
* needs the team's own app (Zendesk) before anyone can sign in.
|
|
72
|
+
*/
|
|
73
|
+
export declare function promptAndSaveTeamApp(ctx: CliContext, args: TeamsArgs, client: TeamsClient, host: string, target: Target, status: TeamIntegrationStatus, app: TeamAppState, edits?: AppEdits): Promise<{
|
|
74
|
+
team: {
|
|
75
|
+
slug: string;
|
|
76
|
+
name: string;
|
|
77
|
+
};
|
|
78
|
+
product: {
|
|
79
|
+
slug: string;
|
|
80
|
+
name: string;
|
|
81
|
+
};
|
|
82
|
+
connectionId: string;
|
|
83
|
+
fields: {
|
|
84
|
+
secretName: string;
|
|
85
|
+
label: string;
|
|
86
|
+
description: string | null;
|
|
87
|
+
sensitive: boolean;
|
|
88
|
+
set: boolean;
|
|
89
|
+
value?: string | null | undefined;
|
|
90
|
+
}[];
|
|
91
|
+
}>;
|
|
38
92
|
/** `teams show`, read top to bottom like a setup checklist. */
|
|
39
93
|
export declare function checklist(status: TeamIntegrationStatus): string[];
|
|
94
|
+
export declare function chooseApp(status: TeamIntegrationStatus, connection: string | undefined): TeamAppState;
|
|
40
95
|
export declare class TeamsClient {
|
|
41
96
|
private readonly env;
|
|
42
97
|
private session;
|
|
43
98
|
constructor(env: AuthEnvironment, session: StoredSession);
|
|
44
99
|
call<T>(send: (accessToken: string) => Promise<TeamsApiResult<T>>): Promise<T>;
|
|
45
100
|
}
|
|
101
|
+
export declare function canPrompt(ctx: CliContext, args: TeamsArgs): boolean;
|
|
102
|
+
export {};
|