@ekanos/cli 0.15.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +103 -8
- package/dist/auth/ekanos-api.d.ts +23 -0
- package/dist/auth/ekanos-api.js +33 -6
- package/dist/auth/ekanos-api.js.map +1 -1
- package/dist/commands/add.d.ts +2 -0
- package/dist/commands/add.js +118 -0
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/agents.js +3 -2
- package/dist/commands/agents.js.map +1 -1
- package/dist/commands/apps.d.ts +11 -3
- package/dist/commands/apps.js +86 -28
- package/dist/commands/apps.js.map +1 -1
- package/dist/commands/audiences.d.ts +31 -0
- package/dist/commands/audiences.js +239 -0
- package/dist/commands/audiences.js.map +1 -0
- package/dist/commands/build.d.ts +2 -0
- package/dist/commands/build.js +41 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/catalog.d.ts +4 -2
- package/dist/commands/catalog.js +166 -35
- package/dist/commands/catalog.js.map +1 -1
- package/dist/commands/check.d.ts +2 -0
- package/dist/commands/check.js +43 -0
- package/dist/commands/check.js.map +1 -0
- package/dist/commands/codegen.d.ts +2 -0
- package/dist/commands/codegen.js +49 -0
- package/dist/commands/codegen.js.map +1 -0
- package/dist/commands/contract.d.ts +52 -0
- package/dist/commands/contract.js +300 -0
- package/dist/commands/contract.js.map +1 -0
- package/dist/commands/dev.d.ts +7 -0
- package/dist/commands/dev.js +186 -12
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/index-experience.d.ts +31 -0
- package/dist/commands/index-experience.js +21 -0
- package/dist/commands/index-experience.js.map +1 -0
- package/dist/commands/init.d.ts +7 -0
- package/dist/commands/init.js +12 -0
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/login.d.ts +2 -0
- package/dist/commands/login.js +17 -0
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/new.d.ts +2 -0
- package/dist/commands/new.js +39 -0
- package/dist/commands/new.js.map +1 -0
- package/dist/commands/publish.d.ts +59 -0
- package/dist/commands/publish.js +118 -65
- package/dist/commands/publish.js.map +1 -1
- package/dist/commands/runs.d.ts +7 -3
- package/dist/commands/runs.js +21 -5
- package/dist/commands/runs.js.map +1 -1
- package/dist/commands/scope-notice.d.ts +13 -0
- package/dist/commands/scope-notice.js +12 -4
- package/dist/commands/scope-notice.js.map +1 -1
- package/dist/commands/sources-roles.d.ts +5 -0
- package/dist/commands/sources-roles.js +235 -0
- package/dist/commands/sources-roles.js.map +1 -0
- package/dist/commands/sources.d.ts +5 -0
- package/dist/commands/sources.js +8 -1
- package/dist/commands/sources.js.map +1 -1
- package/dist/commands/sync.d.ts +2 -0
- package/dist/commands/sync.js +150 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/commands/team-agent-readiness.d.ts +18 -2
- package/dist/commands/team-agent-readiness.js +39 -39
- package/dist/commands/team-agent-readiness.js.map +1 -1
- package/dist/commands/team-agents-agents.d.ts +5 -2
- package/dist/commands/team-agents-agents.js +152 -15
- package/dist/commands/team-agents-agents.js.map +1 -1
- package/dist/commands/team-agents-define.d.ts +31 -0
- package/dist/commands/team-agents-define.js +176 -0
- package/dist/commands/team-agents-define.js.map +1 -0
- package/dist/commands/team-agents-mcp.js +112 -10
- package/dist/commands/team-agents-mcp.js.map +1 -1
- package/dist/commands/team-agents-triggers.d.ts +1 -1
- package/dist/commands/team-agents-triggers.js +137 -5
- package/dist/commands/team-agents-triggers.js.map +1 -1
- package/dist/commands/team-agents.d.ts +4 -1
- package/dist/commands/team-agents.js +17 -4
- package/dist/commands/team-agents.js.map +1 -1
- package/dist/commands/team-llm-key.d.ts +14 -0
- package/dist/commands/team-llm-key.js +122 -0
- package/dist/commands/team-llm-key.js.map +1 -0
- package/dist/commands/teams-audience.d.ts +12 -0
- package/dist/commands/teams-audience.js +144 -0
- package/dist/commands/teams-audience.js.map +1 -0
- package/dist/commands/teams-connect.js +123 -31
- package/dist/commands/teams-connect.js.map +1 -1
- package/dist/commands/teams-lifecycle.d.ts +90 -0
- package/dist/commands/teams-lifecycle.js +457 -0
- package/dist/commands/teams-lifecycle.js.map +1 -0
- package/dist/commands/teams-onboard.d.ts +14 -0
- package/dist/commands/teams-onboard.js +62 -13
- package/dist/commands/teams-onboard.js.map +1 -1
- package/dist/commands/teams-overview.js +6 -2
- package/dist/commands/teams-overview.js.map +1 -1
- package/dist/commands/teams-scope.js +4 -0
- package/dist/commands/teams-scope.js.map +1 -1
- package/dist/commands/teams.d.ts +25 -5
- package/dist/commands/teams.js +106 -39
- package/dist/commands/teams.js.map +1 -1
- package/dist/commands/workflows.d.ts +37 -0
- package/dist/commands/workflows.js +589 -0
- package/dist/commands/workflows.js.map +1 -0
- package/dist/compatibility.d.ts +10 -1
- package/dist/compatibility.js +10 -1
- package/dist/compatibility.js.map +1 -1
- package/dist/connect-fields.d.ts +22 -0
- package/dist/connect-fields.js +115 -0
- package/dist/connect-fields.js.map +1 -0
- package/dist/context.d.ts +12 -0
- package/dist/context.js +32 -9
- package/dist/context.js.map +1 -1
- package/dist/dev-experience.d.ts +125 -0
- package/dist/dev-experience.js +128 -0
- package/dist/dev-experience.js.map +1 -0
- package/dist/experience/boundary.d.ts +12 -0
- package/dist/experience/boundary.js +260 -0
- package/dist/experience/boundary.js.map +1 -0
- package/dist/experience/build.d.ts +16 -0
- package/dist/experience/build.js +90 -0
- package/dist/experience/build.js.map +1 -0
- package/dist/experience/checks.d.ts +29 -0
- package/dist/experience/checks.js +133 -0
- package/dist/experience/checks.js.map +1 -0
- package/dist/experience/contract-sources.d.ts +36 -0
- package/dist/experience/contract-sources.js +111 -0
- package/dist/experience/contract-sources.js.map +1 -0
- package/dist/experience/definition-checks.d.ts +26 -0
- package/dist/experience/definition-checks.js +201 -0
- package/dist/experience/definition-checks.js.map +1 -0
- package/dist/experience/definition-shape.d.ts +60 -0
- package/dist/experience/definition-shape.js +2 -0
- package/dist/experience/definition-shape.js.map +1 -0
- package/dist/experience/init.d.ts +10 -0
- package/dist/experience/init.js +64 -0
- package/dist/experience/init.js.map +1 -0
- package/dist/experience/integrations-codegen.d.ts +17 -0
- package/dist/experience/integrations-codegen.js +51 -0
- package/dist/experience/integrations-codegen.js.map +1 -0
- package/dist/experience/json-schema-to-ts.d.ts +1 -0
- package/dist/experience/json-schema-to-ts.js +90 -0
- package/dist/experience/json-schema-to-ts.js.map +1 -0
- package/dist/experience/load-experience.d.ts +23 -0
- package/dist/experience/load-experience.js +115 -0
- package/dist/experience/load-experience.js.map +1 -0
- package/dist/experience/overrides.d.ts +8 -0
- package/dist/experience/overrides.js +21 -0
- package/dist/experience/overrides.js.map +1 -0
- package/dist/experience/pin-integration.d.ts +8 -0
- package/dist/experience/pin-integration.js +17 -0
- package/dist/experience/pin-integration.js.map +1 -0
- package/dist/experience/pin-ops.d.ts +12 -0
- package/dist/experience/pin-ops.js +36 -0
- package/dist/experience/pin-ops.js.map +1 -0
- package/dist/experience/pins.d.ts +35 -0
- package/dist/experience/pins.js +91 -0
- package/dist/experience/pins.js.map +1 -0
- package/dist/experience/project.d.ts +52 -0
- package/dist/experience/project.js +149 -0
- package/dist/experience/project.js.map +1 -0
- package/dist/experience/publish.d.ts +51 -0
- package/dist/experience/publish.js +144 -0
- package/dist/experience/publish.js.map +1 -0
- package/dist/experience/regenerate.d.ts +10 -0
- package/dist/experience/regenerate.js +33 -0
- package/dist/experience/regenerate.js.map +1 -0
- package/dist/experience/report.d.ts +9 -0
- package/dist/experience/report.js +23 -0
- package/dist/experience/report.js.map +1 -0
- package/dist/harness-scaffold.d.ts +52 -18
- package/dist/harness-scaffold.js +189 -9
- package/dist/harness-scaffold.js.map +1 -1
- package/dist/index.d.ts +13 -0
- package/dist/index.js +494 -127
- package/dist/index.js.map +1 -1
- package/dist/invocation.d.ts +31 -0
- package/dist/invocation.js +58 -0
- package/dist/invocation.js.map +1 -0
- package/dist/project-checks.d.ts +12 -0
- package/dist/project-checks.js +46 -0
- package/dist/project-checks.js.map +1 -1
- package/dist/project.d.ts +14 -0
- package/dist/project.js +10 -0
- package/dist/project.js.map +1 -1
- package/dist/repo/publish.d.ts +42 -0
- package/dist/repo/publish.js +225 -0
- package/dist/repo/publish.js.map +1 -0
- package/dist/repo/scaffold.d.ts +30 -0
- package/dist/repo/scaffold.js +165 -0
- package/dist/repo/scaffold.js.map +1 -0
- package/dist/runs-api.js +8 -3
- package/dist/runs-api.js.map +1 -1
- package/dist/safe-fs.d.ts +18 -0
- package/dist/safe-fs.js +57 -0
- package/dist/safe-fs.js.map +1 -1
- package/dist/secret-form.d.ts +48 -0
- package/dist/secret-form.js +212 -0
- package/dist/secret-form.js.map +1 -0
- package/dist/secret-input.d.ts +96 -0
- package/dist/secret-input.js +299 -0
- package/dist/secret-input.js.map +1 -0
- package/dist/team-connect-api.d.ts +78 -3
- package/dist/team-connect-api.js +17 -2
- package/dist/team-connect-api.js.map +1 -1
- package/dist/team-lifecycle-api.d.ts +435 -0
- package/dist/team-lifecycle-api.js +301 -0
- package/dist/team-lifecycle-api.js.map +1 -0
- package/dist/teams-api.d.ts +49 -1
- package/dist/teams-api.js +149 -27
- package/dist/teams-api.js.map +1 -1
- package/dist/unknown-command.d.ts +18 -0
- package/dist/unknown-command.js +50 -0
- package/dist/unknown-command.js.map +1 -0
- package/dist/validate-findings.js +2 -1
- package/dist/validate-findings.js.map +1 -1
- package/dist/workflows-api.d.ts +69 -0
- package/dist/workflows-api.js +182 -0
- package/dist/workflows-api.js.map +1 -0
- package/package.json +3 -3
- package/templates/AGENTS.md.tmpl +6 -4
- package/templates/claude-skill.md.tmpl +4 -1
- package/templates/ekanos.json.tmpl +1 -0
- package/templates/experience/AGENTS.md.tmpl +22 -0
- package/templates/experience/ekanos.json.tmpl +7 -0
- package/templates/experience/ekanos.lock.json.tmpl +4 -0
- package/templates/experience/eslint.config.mjs.tmpl +25 -0
- package/templates/experience/gitignore.tmpl +17 -0
- package/templates/experience/package.json.tmpl +41 -0
- package/templates/experience/src/.ekanos/integrations.d.ts.tmpl +3 -0
- package/templates/experience/src/experience.ts.tmpl +30 -0
- package/templates/experience/src/widgets/hello-widget.tsx.tmpl +40 -0
- package/templates/experience/tsconfig.json.tmpl +20 -0
- package/templates/harness/app/%5F%5Fekanos/api/[...path]/route.ts.tmpl +9 -0
- package/templates/harness/app/[slug]/activation/page.tsx.tmpl +1 -1
- package/templates/harness/app/[slug]/page.tsx.tmpl +1 -1
- package/templates/harness/app/[slug]/tile/page.tsx.tmpl +1 -1
- package/templates/harness/app/[slug]/triggers/page.tsx.tmpl +1 -1
- package/templates/harness/app/[slug]/widgets/[widgetId]/page.tsx.tmpl +1 -1
- package/templates/harness/app/[slug]/widgets/page.tsx.tmpl +1 -1
- package/templates/harness/app/experience/layout.tsx.tmpl +17 -0
- package/templates/harness/app/experience/page.tsx.tmpl +1 -0
- package/templates/harness/app/experience/pages/[id]/page.tsx.tmpl +1 -0
- package/templates/harness/app/experience/review-queue/page.tsx.tmpl +1 -0
- package/templates/harness/app/experience/runs/page.tsx.tmpl +1 -0
- package/templates/harness/app/experience/widgets/[id]/page.tsx.tmpl +1 -0
- package/templates/harness/app/experience/widgets/page.tsx.tmpl +1 -0
- package/templates/harness/app/experience/workflows/[id]/page.tsx.tmpl +1 -0
- package/templates/harness/app/experience/workflows/page.tsx.tmpl +1 -0
- package/templates/harness/app/integrations/[slug]/connect/page.tsx.tmpl +1 -0
- package/templates/harness/app/integrations/[slug]/events/page.tsx.tmpl +1 -0
- package/templates/harness/app/integrations/[slug]/health/page.tsx.tmpl +1 -0
- package/templates/harness/app/integrations/[slug]/operations/[kind]/[name]/page.tsx.tmpl +1 -0
- package/templates/harness/app/integrations/[slug]/operations/page.tsx.tmpl +1 -0
- package/templates/harness/app/integrations/[slug]/page.tsx.tmpl +1 -0
- package/templates/harness/app/integrations/[slug]/preview/activation/page.tsx.tmpl +1 -0
- package/templates/harness/app/integrations/[slug]/preview/layout.tsx.tmpl +1 -0
- package/templates/harness/app/integrations/[slug]/preview/page.tsx.tmpl +1 -0
- package/templates/harness/app/integrations/[slug]/preview/tile/page.tsx.tmpl +1 -0
- package/templates/harness/app/integrations/[slug]/preview/triggers/page.tsx.tmpl +1 -0
- package/templates/harness/app/integrations/[slug]/preview/widgets/[widgetId]/page.tsx.tmpl +1 -0
- package/templates/harness/app/integrations/[slug]/preview/widgets/page.tsx.tmpl +1 -0
- package/templates/harness/app/integrations/[slug]/runs/page.tsx.tmpl +1 -0
- package/templates/harness/app/integrations/layout.tsx.tmpl +1 -0
- package/templates/harness/app/integrations/page.tsx.tmpl +1 -0
- package/templates/harness/app/page.experience.tsx.tmpl +5 -0
- package/templates/harness/repo/app/%5F%5Fekanos/api/[...path]/route.ts.tmpl +11 -0
- package/templates/harness/repo/app/(repo)/connections/page.tsx.tmpl +1 -0
- package/templates/harness/repo/app/(repo)/layout.tsx.tmpl +1 -0
- package/templates/harness/repo/app/(repo)/page.tsx.tmpl +1 -0
- package/templates/harness/repo/app/experiences/[name]/connect/page.tsx.tmpl +1 -0
- package/templates/harness/repo/app/experiences/[name]/layout.tsx.tmpl +9 -0
- package/templates/harness/repo/app/experiences/page.tsx.tmpl +5 -0
- package/templates/harness/repo/app/harness-shell.tsx.tmpl +9 -0
- package/templates/harness/repo/app/integrations/[slug]/layout.tsx.tmpl +1 -0
- package/templates/harness/repo/app/integrations/page.tsx.tmpl +5 -0
- package/templates/harness/repo/app/repo-experiences.ts.tmpl +5 -0
- package/templates/harness/styles/globals.css.tmpl +15 -1
- package/templates/package.json.tmpl +4 -4
- package/templates/skills/build-agent/SKILL.md +43 -10
- package/templates/skills/build-agent/references/agent-json.md +4 -1
- package/templates/skills/build-agent/references/app-setup.md +14 -7
- package/templates/skills/build-agent/references/rollout.md +26 -2
- package/templates/skills/build-agent/references/set-up-an-integration.md +46 -29
- package/templates/skills/build-integration/references/widget-design.md +1 -1
- package/templates/skills/ekanos-platform/SKILL.md +66 -14
- package/templates/skills/polish-widgets/references/patterns.md +3 -3
package/dist/commands/teams.js
CHANGED
|
@@ -12,13 +12,17 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { loginHint } from '../auth/host-trust.js';
|
|
13
13
|
import { refreshStoredSession, requireSession, resolveAuthEnvironment, } from '../auth/session.js';
|
|
14
14
|
import { authRequiredError, invalidStateError, usageError, validationError, } from '../errors.js';
|
|
15
|
+
import { cli } from '../invocation.js';
|
|
15
16
|
import { ensureSecretsDir, writeSecretFile } from '../secret-file.js';
|
|
17
|
+
import { FIELD_SECRET_FORMS, collectSecrets, parsePlainValues, readSecretFlags, secretInputGiven, } from '../secret-input.js';
|
|
16
18
|
import { resolveSourceTarget } from '../source-target.js';
|
|
17
19
|
import { listTeams, mintTeamWebhook, setTeamApp, showTeamIntegration, } from '../teams-api.js';
|
|
18
20
|
import { promptHidden, promptLine } from './apps.js';
|
|
19
21
|
import { scopeHiddenLines } from './scope-notice.js';
|
|
20
22
|
import { isTeamAgentArea, runTeamAgentCommands } from './team-agents.js';
|
|
23
|
+
import { runTeamAudience } from './teams-audience.js';
|
|
21
24
|
import { runTeamEvents } from './teams-events.js';
|
|
25
|
+
import { LIFECYCLE_SUBCOMMANDS, isLifecycleMemberVerb, isLifecycleSubcommand, parseLifecycle, runLifecycle, } from './teams-lifecycle.js';
|
|
22
26
|
import { ONBOARDING_SUBCOMMANDS, isOnboardingSubcommand, parseOnboarding, runOnboarding, } from './teams-onboard.js';
|
|
23
27
|
import { runTeamOverview } from './teams-overview.js';
|
|
24
28
|
import { runTeamScope } from './teams-scope.js';
|
|
@@ -29,7 +33,9 @@ export const TEAMS_SUBCOMMANDS = [
|
|
|
29
33
|
'webhook',
|
|
30
34
|
'events',
|
|
31
35
|
'scope',
|
|
36
|
+
'audience',
|
|
32
37
|
...ONBOARDING_SUBCOMMANDS,
|
|
38
|
+
...LIFECYCLE_SUBCOMMANDS,
|
|
33
39
|
];
|
|
34
40
|
/**
|
|
35
41
|
* `teams` — a Source admin's view of its teams' integration setup, the
|
|
@@ -37,13 +43,14 @@ export const TEAMS_SUBCOMMANDS = [
|
|
|
37
43
|
* team's setup of one product as a checklist; `app set` enters or updates
|
|
38
44
|
* any of a team's own app fields (Zendesk's subdomain, client and signing
|
|
39
45
|
* secret), one at a time if need be — a field left alone keeps its saved
|
|
40
|
-
* value.
|
|
41
|
-
*
|
|
42
|
-
*
|
|
46
|
+
* value. A secret is typed at the admin's terminal with hidden input or,
|
|
47
|
+
* without one, read from the environment, a private file, stdin or a form
|
|
48
|
+
* in the browser (`secret-input.ts`) — never a value in argv; a non-secret
|
|
49
|
+
* field may be passed as `--set name=value`; `webhook` mints the URL the
|
|
43
50
|
* team's provider sends to, shown once.
|
|
44
51
|
*/
|
|
45
52
|
export async function runTeams(ctx, args) {
|
|
46
|
-
var _a;
|
|
53
|
+
var _a, _b, _c;
|
|
47
54
|
const [rawSubcommand, ...rest] = args.positionals;
|
|
48
55
|
if (isTeamAgentArea(rawSubcommand)) {
|
|
49
56
|
return runTeamAgentCommands(ctx, args);
|
|
@@ -55,8 +62,15 @@ export async function runTeams(ctx, args) {
|
|
|
55
62
|
if (subcommand === 'scope') {
|
|
56
63
|
return runTeamScope(ctx, args, rest);
|
|
57
64
|
}
|
|
65
|
+
if (subcommand === 'audience') {
|
|
66
|
+
return runTeamAudience(ctx, args, rest);
|
|
67
|
+
}
|
|
68
|
+
if (isLifecycleSubcommand(subcommand) ||
|
|
69
|
+
(subcommand === 'members' && isLifecycleMemberVerb(rest[0]))) {
|
|
70
|
+
return runLifecycle(ctx, args, parseLifecycle(subcommand, rest, args));
|
|
71
|
+
}
|
|
58
72
|
if (isOnboardingSubcommand(subcommand)) {
|
|
59
|
-
const plan = parseOnboarding(subcommand, rest, Object.assign(Object.assign({}, args), { as: typeof ((_a = args.flags) === null || _a === void 0 ? void 0 : _a.as) === 'string' ? args.flags.as : undefined }));
|
|
73
|
+
const plan = parseOnboarding(subcommand, rest, Object.assign(Object.assign({}, args), { as: typeof ((_a = args.flags) === null || _a === void 0 ? void 0 : _a.as) === 'string' ? args.flags.as : undefined, self: ((_b = args.flags) === null || _b === void 0 ? void 0 : _b.self) === true, mine: ((_c = args.flags) === null || _c === void 0 ? void 0 : _c.mine) === true }));
|
|
60
74
|
const env = resolveAuthEnvironment(ctx, args.host, args.env, {
|
|
61
75
|
projectDir: args.dir,
|
|
62
76
|
});
|
|
@@ -83,8 +97,10 @@ export async function runTeams(ctx, args) {
|
|
|
83
97
|
if (subcommand !== 'list' && extra.length > 0) {
|
|
84
98
|
throw usageError(`Unexpected argument "${extra[0]}".`, 'See "ekanos teams --help".');
|
|
85
99
|
}
|
|
86
|
-
if ((appEdits === null || appEdits === void 0 ? void 0 : appEdits.prompts) &&
|
|
87
|
-
|
|
100
|
+
if ((appEdits === null || appEdits === void 0 ? void 0 : appEdits.prompts) &&
|
|
101
|
+
!canPrompt(ctx, args) &&
|
|
102
|
+
!secretInputGiven(appEdits.secret)) {
|
|
103
|
+
throw usageError("teams app set needs the team's secrets, and there is no terminal to ask at. Non-secret fields can be passed with --set <name>=<value>.", `Without a terminal, pass ${FIELD_SECRET_FORMS}. Or run it yourself in your terminal: ${cli()} teams app set ${team} ${product}${args.connection ? ` --connection ${args.connection}` : ''}${args.source ? ` --source ${args.source}` : ''}`);
|
|
88
104
|
}
|
|
89
105
|
const env = resolveAuthEnvironment(ctx, args.host, args.env, {
|
|
90
106
|
projectDir: args.dir,
|
|
@@ -101,12 +117,14 @@ export async function runTeams(ctx, args) {
|
|
|
101
117
|
})
|
|
102
118
|
: ctx.ui.result({
|
|
103
119
|
title: `Teams on ${list.source.slug}`,
|
|
104
|
-
rows: list.teams.map((entry) => [
|
|
105
|
-
entry.slug,
|
|
106
|
-
`${entry.name} · ${entry.memberCount} member${entry.memberCount === 1 ? '' : 's'}`,
|
|
107
|
-
]),
|
|
120
|
+
rows: list.teams.map((entry) => [entry.slug, teamLine(entry)]),
|
|
108
121
|
notes: [
|
|
109
122
|
'"ekanos teams show <team>" shows a team\'s setup; add a product for its checklist.',
|
|
123
|
+
...(list.teams.some((entry) => entry.callerIsMember === false && entry.memberCount > 0)
|
|
124
|
+
? [
|
|
125
|
+
'You manage every team of the Source as its admin without being a member. To connect your own account to one, join it: "ekanos teams members add <team> --self".',
|
|
126
|
+
]
|
|
127
|
+
: []),
|
|
110
128
|
],
|
|
111
129
|
}));
|
|
112
130
|
}
|
|
@@ -135,22 +153,18 @@ function parseAppEdits(flags) {
|
|
|
135
153
|
return raw;
|
|
136
154
|
return typeof raw === 'string' ? [raw] : [];
|
|
137
155
|
};
|
|
138
|
-
const values =
|
|
139
|
-
for (const pair of list('set')) {
|
|
140
|
-
const at = pair.indexOf('=');
|
|
141
|
-
if (at <= 0) {
|
|
142
|
-
throw usageError(`--set "${pair}" is not <field>=<value>.`, 'For example: --set subdomain=acme. Secrets are never passed as arguments: use --field <name> and enter it at the prompt.');
|
|
143
|
-
}
|
|
144
|
-
values[pair.slice(0, at).trim()] = pair.slice(at + 1).trim();
|
|
145
|
-
}
|
|
156
|
+
const values = parsePlainValues(flags === null || flags === void 0 ? void 0 : flags.set);
|
|
146
157
|
const only = list('field');
|
|
147
158
|
const clear = list('clear');
|
|
159
|
+
const secret = readSecretFlags(flags);
|
|
148
160
|
return {
|
|
149
161
|
only,
|
|
150
162
|
values,
|
|
151
163
|
clear,
|
|
164
|
+
secret,
|
|
152
165
|
// Bare `app set` walks every field; `--field` asks the named ones.
|
|
153
166
|
prompts: only.length > 0 ||
|
|
167
|
+
secretInputGiven(secret) ||
|
|
154
168
|
(Object.keys(values).length === 0 && clear.length === 0),
|
|
155
169
|
};
|
|
156
170
|
}
|
|
@@ -175,22 +189,27 @@ async function setApp(ctx, args, client, host, target, status, edits) {
|
|
|
175
189
|
notes: next,
|
|
176
190
|
}));
|
|
177
191
|
}
|
|
178
|
-
/**
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
192
|
+
/**
|
|
193
|
+
* Every field, in turn: bare `teams app set`, and `teams connect` — whose
|
|
194
|
+
* `--set` and secret-input flags fill the team's app too.
|
|
195
|
+
*/
|
|
196
|
+
function walkEveryField(flags) {
|
|
197
|
+
return {
|
|
198
|
+
only: [],
|
|
199
|
+
values: parsePlainValues(flags === null || flags === void 0 ? void 0 : flags.set),
|
|
200
|
+
clear: [],
|
|
201
|
+
secret: readSecretFlags(flags),
|
|
202
|
+
prompts: true,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
185
205
|
/**
|
|
186
206
|
* The `teams app set` walkthrough and prompts for one team app, then the
|
|
187
207
|
* save — of only what was entered: a field left empty keeps its saved value.
|
|
188
208
|
* Shared with `teams connect`, which runs it inline when the integration
|
|
189
209
|
* needs the team's own app (Zendesk) before anyone can sign in.
|
|
190
210
|
*/
|
|
191
|
-
export async function promptAndSaveTeamApp(ctx, args, client, host, target, status, app, edits =
|
|
211
|
+
export async function promptAndSaveTeamApp(ctx, args, client, host, target, status, app, edits = walkEveryField(args.flags)) {
|
|
192
212
|
var _a;
|
|
193
|
-
var _b, _c;
|
|
194
213
|
const known = new Map(app.fields.map((field) => [field.secretName, field]));
|
|
195
214
|
const names = app.fields.map((field) => field.secretName).join(', ');
|
|
196
215
|
for (const name of [
|
|
@@ -204,7 +223,7 @@ export async function promptAndSaveTeamApp(ctx, args, client, host, target, stat
|
|
|
204
223
|
}
|
|
205
224
|
for (const name of Object.keys(edits.values)) {
|
|
206
225
|
if ((_a = known.get(name)) === null || _a === void 0 ? void 0 : _a.sensitive) {
|
|
207
|
-
throw usageError(`"${name}" is a secret: it is never passed as an argument.`, `
|
|
226
|
+
throw usageError(`"${name}" is a secret: it is never passed as an argument.`, `Pass it as --set-secret ${name}=env:<NAME>|file:<path>|stdin, use --browser, or enter it at the prompt: ekanos teams app set ${target.team} ${target.product} --field ${name}`);
|
|
208
227
|
}
|
|
209
228
|
}
|
|
210
229
|
const fields = Object.assign({}, edits.values);
|
|
@@ -217,13 +236,35 @@ export async function promptAndSaveTeamApp(ctx, args, client, host, target, stat
|
|
|
217
236
|
else {
|
|
218
237
|
ctx.log(`${status.product.name} app for team ${target.team} on ${status.source.slug}`);
|
|
219
238
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
239
|
+
const byName = new Map(toAsk.map((field) => [field.secretName, field]));
|
|
240
|
+
const again = `teams app set ${target.team} ${target.product}${args.connection ? ` --connection ${args.connection}` : ''} --source ${status.source.slug}`;
|
|
241
|
+
Object.assign(fields, await collectSecrets(ctx, {
|
|
242
|
+
fields: toAsk
|
|
243
|
+
.filter((field) => edits.values[field.secretName] === undefined)
|
|
244
|
+
.map((field) => ({
|
|
245
|
+
name: field.secretName,
|
|
246
|
+
label: field.label,
|
|
247
|
+
sensitive: field.sensitive,
|
|
248
|
+
set: field.set,
|
|
249
|
+
value: field.sensitive ? null : field.value,
|
|
250
|
+
})),
|
|
251
|
+
flags: edits.secret,
|
|
252
|
+
io: teamsSecretIO(args),
|
|
253
|
+
interactive: canPrompt(ctx, args),
|
|
254
|
+
title: `${status.product.name} app for team ${target.team}`,
|
|
255
|
+
refusal: `${status.product.name}'s team app takes secrets (${toAsk
|
|
256
|
+
.filter((field) => field.sensitive)
|
|
257
|
+
.map((field) => field.secretName)
|
|
258
|
+
.join(', ')}), and there is no terminal to ask at.`,
|
|
259
|
+
again,
|
|
260
|
+
prompt: (spec) => {
|
|
261
|
+
var _a, _b;
|
|
262
|
+
const field = byName.get(spec.name);
|
|
263
|
+
return (field.sensitive
|
|
264
|
+
? ((_a = args.askSecret) !== null && _a !== void 0 ? _a : promptHidden)
|
|
265
|
+
: ((_b = args.ask) !== null && _b !== void 0 ? _b : promptLine))(fieldQuestion(field));
|
|
266
|
+
},
|
|
267
|
+
}));
|
|
227
268
|
}
|
|
228
269
|
if (Object.keys(fields).length === 0 && edits.clear.length === 0) {
|
|
229
270
|
throw validationError('Nothing was changed.', `Run "ekanos teams show ${target.team} ${target.product}" to see the current state.`);
|
|
@@ -332,7 +373,7 @@ export function checklist(status) {
|
|
|
332
373
|
}
|
|
333
374
|
const unset = app.fields.filter((field) => !field.set);
|
|
334
375
|
if (unset.length > 0) {
|
|
335
|
-
lines.push(` → in your terminal:
|
|
376
|
+
lines.push(` → in your terminal: ${cli()} teams app set ${target.team} ${target.product} --connection ${app.connectionId} ${unset.map((field) => `--field ${field.secretName}`).join(' ')} --source ${status.source.slug}`);
|
|
336
377
|
}
|
|
337
378
|
for (const webhook of app.webhooks) {
|
|
338
379
|
lines.push(webhook.endpoint
|
|
@@ -407,9 +448,24 @@ function connectionLines(status) {
|
|
|
407
448
|
}
|
|
408
449
|
return lines;
|
|
409
450
|
}
|
|
451
|
+
/**
|
|
452
|
+
* One team in `teams list`: its members, and whether the caller is one. A
|
|
453
|
+
* team nobody has joined says so with the command that joins it, rather than
|
|
454
|
+
* reading as a count of zero.
|
|
455
|
+
*/
|
|
456
|
+
export function teamLine(entry) {
|
|
457
|
+
const count = `${entry.memberCount} member${entry.memberCount === 1 ? '' : 's'}`;
|
|
458
|
+
if (entry.callerIsMember === undefined)
|
|
459
|
+
return `${entry.name} · ${count}`;
|
|
460
|
+
if (entry.callerIsMember)
|
|
461
|
+
return `${entry.name} · ${count}, you among them`;
|
|
462
|
+
return entry.memberCount === 0
|
|
463
|
+
? `${entry.name} · 0 members · you are not a member — ekanos teams members add ${entry.slug} --self`
|
|
464
|
+
: `${entry.name} · ${count} · you are not a member`;
|
|
465
|
+
}
|
|
410
466
|
/** The command that connects the team, for a hint: `--connection` only for a named one. */
|
|
411
467
|
function connectCommand(status, connectionId = 'default') {
|
|
412
|
-
return
|
|
468
|
+
return `${cli()} teams connect ${status.team.slug} ${status.product.slug}${connectionId === 'default' ? '' : ` --connection ${connectionId}`} --source ${status.source.slug}`;
|
|
413
469
|
}
|
|
414
470
|
function appWalkthrough(status, app) {
|
|
415
471
|
var _a, _b;
|
|
@@ -475,13 +531,24 @@ export function canPrompt(ctx, args) {
|
|
|
475
531
|
var _a;
|
|
476
532
|
return !ctx.jsonMode && ((_a = args.stdinIsTTY) !== null && _a !== void 0 ? _a : process.stdin.isTTY === true);
|
|
477
533
|
}
|
|
534
|
+
/** What the secret-input flags read from, with this run's test seams. */
|
|
535
|
+
export function teamsSecretIO(args) {
|
|
536
|
+
var _a;
|
|
537
|
+
return {
|
|
538
|
+
env: args.env,
|
|
539
|
+
stdinIsTTY: (_a = args.stdinIsTTY) !== null && _a !== void 0 ? _a : process.stdin.isTTY === true,
|
|
540
|
+
readStdin: args.readStdin,
|
|
541
|
+
openUrl: args.openUrl,
|
|
542
|
+
formTimeoutMs: args.secretFormTimeoutMs,
|
|
543
|
+
};
|
|
544
|
+
}
|
|
478
545
|
function parseSubcommand(value) {
|
|
479
546
|
const match = TEAMS_SUBCOMMANDS.find((name) => name === value);
|
|
480
547
|
if (match)
|
|
481
548
|
return match;
|
|
482
549
|
throw usageError(value
|
|
483
550
|
? `Unknown teams subcommand "${value}".`
|
|
484
|
-
: 'teams needs a subcommand.', 'Run one of: ekanos teams list, ekanos teams create <name>, ekanos teams rename <team> <name>, ekanos teams members list <team
|
|
551
|
+
: '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 ….');
|
|
485
552
|
}
|
|
486
553
|
function requireSlug(value, what) {
|
|
487
554
|
const slug = value === null || value === void 0 ? void 0 : value.trim().toLowerCase();
|
|
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G,EACjE,IAAI,KAAK,MAAM;QACb,CAAC,CAAC,qFAAqF;QACvF,CAAC,CAAC,qFAAqF,CAC1F,CAAC;AACJ,CAAC;AAED,SAAS,IAAI,CAAC,IAAa;IACzB,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;AAC1B,CAAC;AAED,SAAS,GAAG,CAAC,GAAW;IACtB,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC1B,CAAC;AAED,SAAS,GAAG,CAAC,MAIZ;;IACC,mBAAO,MAAM,CAAC,KAAK,mCAAI,MAAM,CAAC,IAAI,mCAAI,MAAM,CAAC,MAAM,CAAC;AACtD,CAAC;AAED,sCAAsC;AACtC,SAAS,YAAY,CAAC,GAAiB;IACrC,OAAO,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AACxE,CAAC","sourcesContent":["import type {\n TeamAppState,\n TeamIntegrationStatus,\n} from '@ekanos/integration-schema';\n\nimport type { StoredSession } from '../auth/credential-store';\nimport { loginHint } from '../auth/host-trust';\nimport {\n type AuthEnvironment,\n refreshStoredSession,\n requireSession,\n resolveAuthEnvironment,\n} from '../auth/session';\nimport type { CliContext } from '../context';\nimport {\n authRequiredError,\n invalidStateError,\n usageError,\n validationError,\n} from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { ensureSecretsDir, writeSecretFile } from '../secret-file';\nimport { resolveSourceTarget } from '../source-target';\nimport {\n type TeamsApiResult,\n listTeams,\n mintTeamWebhook,\n setTeamApp,\n showTeamIntegration,\n} from '../teams-api';\nimport { promptHidden, promptLine } from './apps';\nimport { scopeHiddenLines } from './scope-notice';\nimport { isTeamAgentArea, runTeamAgentCommands } from './team-agents';\nimport { runTeamEvents } from './teams-events';\nimport {\n ONBOARDING_SUBCOMMANDS,\n isOnboardingSubcommand,\n parseOnboarding,\n runOnboarding,\n} from './teams-onboard';\nimport { runTeamOverview } from './teams-overview';\nimport { runTeamScope } from './teams-scope';\n\nexport const TEAMS_SUBCOMMANDS = [\n 'list',\n 'show',\n 'app',\n 'webhook',\n 'events',\n 'scope',\n ...ONBOARDING_SUBCOMMANDS,\n] as const;\ntype TeamsSubcommand = (typeof TEAMS_SUBCOMMANDS)[number];\n\nexport interface TeamsArgs {\n host?: string;\n source?: string;\n /** `list`, `show <team> [<product>]`, `app set <team> <product>`, `webhook <team> <product> [<id>]`. */\n positionals: readonly string[];\n connection?: string;\n /** `create --slug`, `create --owner <email>`, `members invite --role`. */\n slug?: string;\n owner?: string;\n role?: string;\n yes: boolean;\n /** `connect --no-wait`: print the sign-in link and return without polling. */\n noWait?: boolean;\n /** `connect --no-open`: never open a browser, only print the link. */\n noOpen?: boolean;\n /** `connect --link-only`: print the team's page, as before connect did the work. */\n linkOnly?: boolean;\n /** `connect --reconnect`: connect again though it reads as connected. */\n reconnect?: boolean;\n /** Test seams for `connect`: the wait between polls, and the browser opener. */\n pollDelayMs?: number;\n openUrl?: (url: string) => void;\n /** Every parsed flag, for `teams agents|triggers|links|mcp` (team-agents.ts). */\n flags?: Record<string, string | boolean | string[]>;\n dir: string;\n env: Record<string, string | undefined>;\n stdinIsTTY?: boolean;\n /** Test seams for the questions `app set` asks. */\n ask?: (question: string) => Promise<string>;\n askSecret?: (question: string) => Promise<string>;\n}\n\nexport interface Target {\n source: string;\n team: string;\n product: string;\n}\n\n/**\n * `teams` — a Source admin's view of its teams' integration setup, the\n * team-level counterpart of `apps`. `list` names the teams; `show` reads one\n * team's setup of one product as a checklist; `app set` enters or updates\n * any of a team's own app fields (Zendesk's subdomain, client and signing\n * secret), one at a time if need be — a field left alone keeps its saved\n * value. Secrets are only ever typed at the admin's terminal, never from a\n * flag, a file or a non-interactive run, so an agent driving the CLI never\n * handles one; a non-secret field may be passed as `--set name=value`; `webhook` mints the URL the\n * team's provider sends to, shown once.\n */\nexport async function runTeams(\n ctx: CliContext,\n args: TeamsArgs,\n): Promise<ExitCode> {\n const [rawSubcommand, ...rest] = args.positionals;\n if (isTeamAgentArea(rawSubcommand)) {\n return runTeamAgentCommands(ctx, args);\n }\n const subcommand = parseSubcommand(rawSubcommand);\n\n if (subcommand === 'events') {\n return runTeamEvents(ctx, args, rest);\n }\n if (subcommand === 'scope') {\n return runTeamScope(ctx, args, rest);\n }\n\n if (isOnboardingSubcommand(subcommand)) {\n const plan = parseOnboarding(subcommand, rest, {\n ...args,\n as: typeof args.flags?.as === 'string' ? args.flags.as : undefined,\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 return runOnboarding(\n ctx,\n args,\n new TeamsClient(env, resolved.session),\n env.host,\n resolved.source,\n plan,\n );\n }\n\n if (subcommand === 'app' && rest[0] !== 'set') {\n throw usageError(\n rest[0]\n ? `Unknown teams app subcommand \"${rest[0]}\".`\n : 'teams app needs a subcommand.',\n 'Run \"ekanos teams app set <team> <product>\".',\n );\n }\n const operands = subcommand === 'app' ? rest.slice(1) : rest;\n\n if (subcommand === 'list' && operands.length > 0) {\n throw usageError(\n 'teams list takes no arguments.',\n 'Run \"ekanos teams list --source <slug>\".',\n );\n }\n\n const team = subcommand === 'list' ? '' : requireSlug(operands[0], 'team');\n // `teams show <team>` alone is the team's overview.\n const overview = subcommand === 'show' && operands[1] === undefined;\n const product =\n subcommand === 'list' || overview\n ? ''\n : requireSlug(operands[1], 'product');\n const extra = operands.slice(subcommand === 'webhook' ? 3 : 2);\n const appEdits = subcommand === 'app' ? parseAppEdits(args.flags) : null;\n if (subcommand !== 'list' && extra.length > 0) {\n throw usageError(\n `Unexpected argument \"${extra[0]}\".`,\n 'See \"ekanos teams --help\".',\n );\n }\n\n if (appEdits?.prompts && !canPrompt(ctx, args)) {\n throw usageError(\n \"teams app set takes the team's secrets at a terminal, never in a script or an agent run. Non-secret fields can be passed with --set <name>=<value>.\",\n `Run it yourself in your terminal: npx @ekanos/cli teams app set ${team} ${product}${args.connection ? ` --connection ${args.connection}` : ''}${args.source ? ` --source ${args.source}` : ''}`,\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 source = resolved.source;\n\n if (subcommand === 'list') {\n const list = await client.call((token) =>\n listTeams(env.host, token, source),\n );\n return ctx.succeed(\n { host: env.host, ...list },\n list.teams.length === 0\n ? ctx.ui.result({\n title: `No teams on ${list.source.slug}`,\n tone: 'warn',\n })\n : ctx.ui.result({\n title: `Teams on ${list.source.slug}`,\n rows: list.teams.map((entry) => [\n entry.slug,\n `${entry.name} · ${entry.memberCount} member${entry.memberCount === 1 ? '' : 's'}`,\n ]),\n notes: [\n '\"ekanos teams show <team>\" shows a team\\'s setup; add a product for its checklist.',\n ],\n }),\n );\n }\n\n if (overview) {\n return runTeamOverview(ctx, client, env.host, source, team);\n }\n\n const target: Target = { source, team, product };\n const status = await client.call((token) =>\n showTeamIntegration(env.host, token, target),\n );\n\n if (subcommand === 'show') {\n return ctx.succeed(\n { host: env.host, ...status },\n checklist(status).join('\\n'),\n );\n }\n\n if (!status.enabled) {\n throw invalidStateError(\n `\"${product}\" is not enabled on ${status.source.slug}.`,\n `\"ekanos sources products --source ${status.source.slug}\" shows what it has; only a super-admin enables a product for a Source (in /admin).`,\n );\n }\n\n if (subcommand === 'app' && appEdits) {\n return setApp(ctx, args, client, env.host, target, status, appEdits);\n }\n return mintWebhook(ctx, args, client, env.host, target, status, operands[2]);\n}\n\n/** What `teams app set` was asked to change, from its flags. */\ninterface AppEdits {\n /** `--field`: enter just these, at the terminal. */\n only: string[];\n /** `--set name=value`: non-secret values, no prompt. */\n values: Record<string, string>;\n /** `--clear name`: remove a saved value. */\n clear: string[];\n /** Whether anything is asked at the terminal. */\n prompts: boolean;\n}\n\nfunction parseAppEdits(flags: TeamsArgs['flags']): AppEdits {\n const list = (name: string): string[] => {\n const raw = flags?.[name];\n if (raw === undefined || raw === false) return [];\n if (Array.isArray(raw)) return raw;\n return typeof raw === 'string' ? [raw] : [];\n };\n const values: Record<string, string> = {};\n for (const pair of list('set')) {\n const at = pair.indexOf('=');\n if (at <= 0) {\n throw usageError(\n `--set \"${pair}\" is not <field>=<value>.`,\n 'For example: --set subdomain=acme. Secrets are never passed as arguments: use --field <name> and enter it at the prompt.',\n );\n }\n values[pair.slice(0, at).trim()] = pair.slice(at + 1).trim();\n }\n const only = list('field');\n const clear = list('clear');\n return {\n only,\n values,\n clear,\n // Bare `app set` walks every field; `--field` asks the named ones.\n prompts:\n only.length > 0 ||\n (Object.keys(values).length === 0 && clear.length === 0),\n };\n}\n\nasync function setApp(\n ctx: CliContext,\n args: TeamsArgs,\n client: TeamsClient,\n host: string,\n target: Target,\n status: TeamIntegrationStatus,\n edits: AppEdits,\n): Promise<ExitCode> {\n const app = chooseApp(status, args.connection);\n const result = await promptAndSaveTeamApp(\n ctx,\n args,\n client,\n host,\n target,\n status,\n app,\n edits,\n );\n const missing = result.fields.filter((field) => !field.set);\n const next = [\n ...(missing.length > 0\n ? [\n `Still not set: ${missing.map((field) => field.label).join(', ')} — a team member can't connect until it is. Run \"ekanos teams app set ${target.team} ${target.product} ${missing.map((field) => `--field ${field.secretName}`).join(' ')}\".`,\n ]\n : []),\n ...nextSteps(status, app, target),\n ];\n return ctx.succeed(\n { host, ...result },\n ctx.ui.result({\n title: `Saved ${target.team}'s ${result.product.name} app`,\n rows: [\n ['Source', status.source.slug],\n ['Fields', result.fields.map(fieldLine)],\n ],\n notes: next,\n }),\n );\n}\n\n/** Every field, asked in turn: bare `teams app set`, and `teams connect`. */\nconst WALK_EVERY_FIELD: AppEdits = {\n only: [],\n values: {},\n clear: [],\n prompts: true,\n};\n\n/**\n * The `teams app set` walkthrough and prompts for one team app, then the\n * save — of only what was entered: a field left empty keeps its saved value.\n * Shared with `teams connect`, which runs it inline when the integration\n * needs the team's own app (Zendesk) before anyone can sign in.\n */\nexport async function promptAndSaveTeamApp(\n ctx: CliContext,\n args: TeamsArgs,\n client: TeamsClient,\n host: string,\n target: Target,\n status: TeamIntegrationStatus,\n app: TeamAppState,\n edits: AppEdits = WALK_EVERY_FIELD,\n) {\n const known = new Map(app.fields.map((field) => [field.secretName, field]));\n const names = app.fields.map((field) => field.secretName).join(', ');\n for (const name of [\n ...edits.only,\n ...Object.keys(edits.values),\n ...edits.clear,\n ]) {\n if (!known.has(name)) {\n throw usageError(\n `${status.product.name}'s team app has no field \"${name}\".`,\n `Its fields are: ${names}.`,\n );\n }\n }\n for (const name of Object.keys(edits.values)) {\n if (known.get(name)?.sensitive) {\n throw usageError(\n `\"${name}\" is a secret: it is never passed as an argument.`,\n `Enter it at the prompt: ekanos teams app set ${target.team} ${target.product} --field ${name}`,\n );\n }\n }\n\n const fields: Record<string, string> = { ...edits.values };\n if (edits.prompts) {\n const toAsk =\n edits.only.length > 0\n ? app.fields.filter((field) => edits.only.includes(field.secretName))\n : app.fields;\n if (edits.only.length === 0)\n ctx.log(appWalkthrough(status, app).join('\\n'));\n else {\n ctx.log(\n `${status.product.name} app for team ${target.team} on ${status.source.slug}`,\n );\n }\n for (const field of toAsk) {\n const value = (\n await (\n field.sensitive\n ? (args.askSecret ?? promptHidden)\n : (args.ask ?? promptLine)\n )(fieldQuestion(field))\n ).trim();\n if (value) fields[field.secretName] = value;\n }\n }\n\n if (Object.keys(fields).length === 0 && edits.clear.length === 0) {\n throw validationError(\n 'Nothing was changed.',\n `Run \"ekanos teams show ${target.team} ${target.product}\" to see the current state.`,\n );\n }\n\n return client.call((token) =>\n setTeamApp(host, token, target, {\n connectionId: app.connectionId,\n fields,\n ...(edits.clear.length > 0 ? { clear: edits.clear } : {}),\n }),\n );\n}\n\n/** The prompt for one field: what is saved, and that Enter keeps it. */\nfunction fieldQuestion(field: TeamAppState['fields'][number]): string {\n const name = `${field.label} [${field.secretName}]`;\n if (field.sensitive) {\n return field.set\n ? `${name} (saved — Enter to keep, hidden): `\n : `${name} (hidden): `;\n }\n if (field.set) {\n return field.value\n ? `${name} (current: ${field.value} — Enter to keep): `\n : `${name} (saved — Enter to keep): `;\n }\n return `${name}: `;\n}\n\n/** One field's state: a secret only as saved / not set, never its value. */\nfunction fieldLine(field: TeamAppState['fields'][number]): string {\n const state = !field.set\n ? 'not set'\n : field.sensitive\n ? 'saved'\n : field.value\n ? field.value\n : 'saved';\n return `${mark(field.set)} ${field.label} (${field.secretName}): ${state}`;\n}\n\nasync function mintWebhook(\n ctx: CliContext,\n args: TeamsArgs,\n client: TeamsClient,\n host: string,\n target: Target,\n status: TeamIntegrationStatus,\n requested: string | undefined,\n): Promise<ExitCode> {\n const webhooks = status.teamApps.flatMap((app) => app.webhooks);\n if (webhooks.length === 0) {\n throw invalidStateError(\n `${status.product.name} has no webhook a team's app sends.`,\n `Run \"ekanos teams show ${target.team} ${target.product}\" to see its setup.`,\n );\n }\n const webhook = requested\n ? webhooks.find((entry) => entry.webhookId === requested)\n : webhooks.length === 1\n ? webhooks[0]\n : undefined;\n if (!webhook) {\n throw usageError(\n requested\n ? `${status.product.name} has no team-app webhook \"${requested}\".`\n : `${status.product.name} has several webhooks; name one.`,\n `Run one of: ${webhooks.map((entry) => `ekanos teams webhook ${target.team} ${target.product} ${entry.webhookId}`).join(', ')}.`,\n );\n }\n\n if (webhook.endpoint && !args.yes) {\n throw invalidStateError(\n `${target.team} already has a live URL for ${webhook.webhookId} (${webhook.endpoint.tokenPrefix}…). A new one revokes it, and the provider's webhook stops working until you paste the new URL there.`,\n `Re-run with --yes when you are ready to update the provider: ekanos teams webhook ${target.team} ${target.product} ${webhook.webhookId} --yes`,\n );\n }\n\n // The URL carries its token, so it goes to a 0600 file, never the output.\n const secrets = ensureSecretsDir(args.env);\n const minted = await client.call((token) =>\n mintTeamWebhook(host, token, target, webhook.webhookId),\n );\n const { url, ...rest } = minted;\n const secretFile = writeSecretFile(secrets, {\n owner: target.team,\n what: `${target.product}-${webhook.webhookId}-webhook-url`,\n purpose: `Webhook URL for team ${target.team}'s ${status.product.name} (${webhook.webhookId}). Paste it into ${status.product.name}'s webhook settings for this team; the token is part of the URL.`,\n values: [['WEBHOOK_URL', url]],\n again: `ekanos teams webhook ${target.team} ${target.product} ${webhook.webhookId} --yes`,\n });\n return ctx.succeed(\n { host, ...rest, secretFile },\n ctx.ui.result({\n title: `Webhook URL for ${target.team} · ${webhook.webhookId}`,\n tone: 'warn',\n rows: [\n ['URL', `saved to ${secretFile} (readable only by you)`],\n [\n 'Paste it into',\n `${status.product.name}'s webhook settings for this team`,\n ],\n ],\n notes: [\n 'The URL carries its token, so it is shown nowhere else and cannot be read again. Copy it from that file into the provider yourself — not into a chat or an agent session — then delete the file.',\n ...(minted.replaced\n ? ['The previous URL is revoked: the provider must use this one.']\n : []),\n ],\n }),\n );\n}\n\n/** `teams show`, read top to bottom like a setup checklist. */\nexport function checklist(status: TeamIntegrationStatus): string[] {\n const name = status.product.name;\n const lines = [\n `${name} for team ${status.team.slug} (${status.team.name}) on ${status.source.slug}`,\n ` ${mark(status.enabled)} Enabled on the Source`,\n ];\n if (!status.enabled) {\n lines.push(\n ` \"ekanos sources products --source ${status.source.slug}\" shows what it has; only a super-admin enables a product for a Source (in /admin).`,\n );\n return lines;\n }\n\n const target = { team: status.team.slug, product: status.product.slug };\n lines.push(\n ...scopeHiddenLines(status.scope, {\n ...target,\n source: status.source.slug,\n }).map((line) => ` ${line}`),\n );\n lines.push(...connectionLines(status));\n for (const app of status.teamApps) {\n lines.push(` Team app: ${app.label} (${app.connectionId})`);\n if (app.setup?.consoleUrl) lines.push(` Open: ${app.setup.consoleUrl}`);\n app.setup?.steps.forEach((step, index) =>\n lines.push(` ${index + 1}. ${step}`),\n );\n lines.push(' Callback URLs to register:');\n lines.push(...callbackUrls(app).map((url) => ` ${url}`));\n if (app.guideUrl) lines.push(` Guide: ${app.guideUrl}`);\n for (const field of app.fields) {\n lines.push(` ${fieldLine(field)}`);\n }\n const unset = app.fields.filter((field) => !field.set);\n if (unset.length > 0) {\n lines.push(\n ` → in your terminal: npx @ekanos/cli teams app set ${target.team} ${target.product} --connection ${app.connectionId} ${unset.map((field) => `--field ${field.secretName}`).join(' ')} --source ${status.source.slug}`,\n );\n }\n for (const webhook of app.webhooks) {\n lines.push(\n webhook.endpoint\n ? ` ${mark(true)} Webhook ${webhook.webhookId}: live URL ${webhook.endpoint.tokenPrefix}… since ${day(webhook.endpoint.createdAt)}${webhook.endpoint.lastUsedAt ? `, last delivery ${day(webhook.endpoint.lastUsedAt)}` : ', no delivery yet'}`\n : ` ${mark(false)} Webhook ${webhook.webhookId}: no URL yet`,\n );\n if (!webhook.endpoint) {\n lines.push(\n ` → ekanos teams webhook ${target.team} ${target.product} ${webhook.webhookId} --source ${status.source.slug}`,\n );\n }\n }\n lines.push(\n app.connection\n ? ` ${mark(true)} Connected ${day(app.connection.connectedAt)}${app.connection.connectedBy ? ` by ${who(app.connection.connectedBy)}` : ''}`\n : ` ${mark(false)} Connected: not yet\\n → in your terminal: ${connectCommand(status, app.connectionId)}`,\n );\n }\n\n lines.push(\n status.activation\n ? ` ${mark(true)} Activated for the team${status.activation.activatedAt ? ` ${day(status.activation.activatedAt)}` : ''}${status.activation.activatedBy ? ` by ${who(status.activation.activatedBy)}` : ''}`\n : ` ${mark(false)} Activated: not yet\\n → in your terminal: ${connectCommand(status)}`,\n );\n lines.push(` Team page: ${status.connectUrl}`);\n if (status.agentEvents.length > 0) {\n lines.push(' Agent events it offers:');\n lines.push(\n ...status.agentEvents.map((event) => ` ${event.id} — ${event.label}`),\n );\n }\n return lines;\n}\n\n/**\n * Each OAuth connection in one line — connected, or installed for a named\n * one, with its app's credentials and webhook URL — and which of the team's\n * agents wait on it. A named connection an agent's trigger needs and the team\n * has not installed is the gap no other line names: the trigger is stored\n * and on, and nothing ever reaches it.\n */\nfunction connectionLines(status: TeamIntegrationStatus): string[] {\n const connections = status.connections ?? [];\n if (connections.length === 0) return [];\n const lines = [' Connections:'];\n for (const entry of connections) {\n const named = entry.connectionId !== 'default';\n const app = status.teamApps.find(\n (candidate) => candidate.connectionId === entry.connectionId,\n );\n const webhooks = app?.webhooks ?? [];\n const steps = [\n ...(entry.credentialsSaved === null\n ? []\n : [\n `app credentials ${entry.credentialsSaved ? 'saved' : 'not saved'}`,\n ]),\n named\n ? entry.connected\n ? `installed ${day(entry.connectedAt ?? '')}`\n : 'not installed'\n : entry.connected\n ? `connected ${day(entry.connectedAt ?? '')}`\n : 'not connected',\n ...(webhooks.length > 0\n ? [\n webhooks.every((webhook) => webhook.endpoint)\n ? 'webhook URL made'\n : 'no webhook URL',\n ]\n : []),\n ];\n const ready =\n entry.connected &&\n entry.credentialsSaved !== false &&\n webhooks.every((webhook) => webhook.endpoint);\n lines.push(\n ` ${mark(ready)} ${entry.label} (${entry.connectionId}): ${steps.join(' · ')}${entry.connectedBy ? ` by ${who(entry.connectedBy)}` : ''}`,\n );\n if (entry.neededBy.length > 0) {\n lines.push(\n ` Needed by: ${entry.neededBy.map((need) => `${need.agent} (${need.triggers.join(', ')})`).join(', ')}`,\n );\n }\n if (!entry.connected) {\n lines.push(\n ` → in your terminal: ${connectCommand(status, entry.connectionId)}`,\n );\n }\n }\n return lines;\n}\n\n/** The command that connects the team, for a hint: `--connection` only for a named one. */\nfunction connectCommand(\n status: TeamIntegrationStatus,\n connectionId = 'default',\n): string {\n return `npx @ekanos/cli teams connect ${status.team.slug} ${status.product.slug}${connectionId === 'default' ? '' : ` --connection ${connectionId}`} --source ${status.source.slug}`;\n}\n\nfunction appWalkthrough(\n status: TeamIntegrationStatus,\n app: TeamAppState,\n): string[] {\n const lines = [\n `${status.product.name} app for team ${status.team.slug} on ${status.source.slug}`,\n ];\n if (app.setup?.consoleUrl) lines.push(` Open: ${app.setup.consoleUrl}`);\n const steps = app.setup?.steps.length\n ? [...app.setup.steps]\n : [\n `In ${status.product.name}, create an OAuth app for the team (or open the one it uses).`,\n ];\n steps.push(\n `Check the app lists exactly: ${callbackUrls(app).join(', ')}`,\n \"Enter its values below. Secrets are stored in Ekanos's vault and never shown again.\",\n );\n lines.push(...steps.map((step, index) => ` ${index + 1}. ${step}`));\n if (app.guideUrl) lines.push(` Guide: ${app.guideUrl}`);\n return lines;\n}\n\nfunction nextSteps(\n status: TeamIntegrationStatus,\n app: TeamAppState,\n target: Target,\n): string[] {\n return [\n ...app.webhooks\n .filter((webhook) => !webhook.endpoint)\n .map(\n (webhook) =>\n `Next: \"ekanos teams webhook ${target.team} ${target.product} ${webhook.webhookId}\" for the provider's webhook URL.`,\n ),\n ...(app.connection\n ? []\n : [`Then connect it: ${connectCommand(status, app.connectionId)}`]),\n ];\n}\n\nexport function chooseApp(\n status: TeamIntegrationStatus,\n connection: string | undefined,\n): TeamAppState {\n const apps = status.teamApps;\n if (apps.length === 0) {\n throw invalidStateError(\n `${status.product.name} takes no team app: teams connect through the Source's app, or need none.`,\n `Run \"ekanos apps show ${status.product.slug}\" for the Source's app.`,\n );\n }\n const app = connection\n ? apps.find((entry) => entry.connectionId === connection)\n : apps.length === 1\n ? apps[0]\n : apps.find((entry) => entry.connectionId === 'default');\n if (app) return app;\n throw usageError(\n connection\n ? `${status.product.name} has no team app \"${connection}\".`\n : `${status.product.name} has several team apps; name one.`,\n `Pass --connection with one of: ${apps.map((entry) => entry.connectionId).join(', ')}.`,\n );\n}\n\nexport class TeamsClient {\n constructor(\n private readonly env: AuthEnvironment,\n private session: StoredSession,\n ) {}\n\n async call<T>(\n send: (accessToken: string) => Promise<TeamsApiResult<T>>,\n ): Promise<T> {\n let result = await send(this.session.accessToken);\n if (result.status === 'unauthorized') {\n this.session = await refreshStoredSession(this.env, this.session);\n result = await send(this.session.accessToken);\n }\n if (result.status === 'ok') return result.data;\n throw authRequiredError(\n `The session for ${this.env.host} could not authorize the teams call.`,\n loginHint(this.env),\n );\n }\n}\n\nexport function canPrompt(ctx: CliContext, args: TeamsArgs): boolean {\n return !ctx.jsonMode && (args.stdinIsTTY ?? process.stdin.isTTY === true);\n}\n\nfunction parseSubcommand(value: string | undefined): TeamsSubcommand {\n const match = TEAMS_SUBCOMMANDS.find((name) => name === value);\n if (match) return match;\n throw usageError(\n value\n ? `Unknown teams subcommand \"${value}\".`\n : 'teams needs a subcommand.',\n 'Run one of: ekanos teams list, ekanos teams create <name>, ekanos teams rename <team> <name>, ekanos teams members list <team>, ekanos teams roles list <team>, ekanos teams connect <team> <product>, ekanos teams disconnect <team> <product> --yes, 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 scope show|set <team> …, ekanos teams agents|triggers|links|mcp ….',\n );\n}\n\nfunction requireSlug(value: string | undefined, what: 'team' | 'product') {\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 show acme-support zendesk\".'\n : '\"ekanos catalog\" lists the products, e.g. \"ekanos teams show acme-support zendesk\".',\n );\n}\n\nfunction mark(done: boolean): string {\n return done ? '✓' : '✗';\n}\n\nfunction day(iso: string): string {\n return iso.slice(0, 10);\n}\n\nfunction who(member: {\n name: string | null;\n email: string | null;\n userId: string;\n}) {\n return member.email ?? member.name ?? member.userId;\n}\n\n/** Every redirect URI to register. */\nfunction callbackUrls(app: TeamAppState): string[] {\n return app.callbackUrls.length ? app.callbackUrls : [app.callbackUrl];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"teams.js","sourceRoot":"","sources":["../../src/commands/teams.ts"],"names":[],"mappings":";;;;;;;;;;;AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAEL,oBAAoB,EACpB,cAAc,EACd,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AAEzB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egrationStatus,\n} from '@ekanos/integration-schema';\n\nimport type { StoredSession } from '../auth/credential-store';\nimport { loginHint } from '../auth/host-trust';\nimport {\n type AuthEnvironment,\n refreshStoredSession,\n requireSession,\n resolveAuthEnvironment,\n} from '../auth/session';\nimport type { CliContext } from '../context';\nimport {\n authRequiredError,\n invalidStateError,\n usageError,\n validationError,\n} from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { cli } from '../invocation';\nimport { ensureSecretsDir, writeSecretFile } from '../secret-file';\nimport {\n FIELD_SECRET_FORMS,\n type SecretFlags,\n type SecretIO,\n collectSecrets,\n parsePlainValues,\n readSecretFlags,\n secretInputGiven,\n} from '../secret-input';\nimport { resolveSourceTarget } from '../source-target';\nimport {\n type TeamsApiResult,\n listTeams,\n mintTeamWebhook,\n setTeamApp,\n showTeamIntegration,\n} from '../teams-api';\nimport { promptHidden, promptLine } from './apps';\nimport { scopeHiddenLines } from './scope-notice';\nimport { isTeamAgentArea, runTeamAgentCommands } from './team-agents';\nimport { runTeamAudience } from './teams-audience';\nimport { runTeamEvents } from './teams-events';\nimport {\n LIFECYCLE_SUBCOMMANDS,\n isLifecycleMemberVerb,\n isLifecycleSubcommand,\n parseLifecycle,\n runLifecycle,\n} from './teams-lifecycle';\nimport {\n ONBOARDING_SUBCOMMANDS,\n isOnboardingSubcommand,\n parseOnboarding,\n runOnboarding,\n} from './teams-onboard';\nimport { runTeamOverview } from './teams-overview';\nimport { runTeamScope } from './teams-scope';\n\nexport const TEAMS_SUBCOMMANDS = [\n 'list',\n 'show',\n 'app',\n 'webhook',\n 'events',\n 'scope',\n 'audience',\n ...ONBOARDING_SUBCOMMANDS,\n ...LIFECYCLE_SUBCOMMANDS,\n] as const;\ntype TeamsSubcommand = (typeof TEAMS_SUBCOMMANDS)[number];\n\nexport interface TeamsArgs {\n host?: string;\n source?: string;\n /** `list`, `show <team> [<product>]`, `app set <team> <product>`, `webhook <team> <product> [<id>]`. */\n positionals: readonly string[];\n connection?: string;\n /** `create --slug`, `create --owner <email>`, `members invite --role`. */\n slug?: string;\n owner?: string;\n role?: string;\n yes: boolean;\n /** `connect --no-wait`: print the sign-in link and return without polling. */\n noWait?: boolean;\n /** `connect --no-open`: never open a browser, only print the link. */\n noOpen?: boolean;\n /** `connect --link-only`: print the team's page, as before connect did the work. */\n linkOnly?: boolean;\n /** `connect --reconnect`: connect again though it reads as connected. */\n reconnect?: boolean;\n /** Test seams for `connect`: the wait between polls, and the browser opener. */\n pollDelayMs?: number;\n openUrl?: (url: string) => void;\n /** Every parsed flag, for `teams agents|triggers|links|mcp` (team-agents.ts). */\n flags?: Record<string, string | boolean | string[]>;\n dir: string;\n env: Record<string, string | undefined>;\n stdinIsTTY?: boolean;\n /** Test seams for the questions `app set` asks. */\n ask?: (question: string) => Promise<string>;\n askSecret?: (question: string) => Promise<string>;\n /** Test seams for the secret-input flags (`secret-input.ts`). */\n readStdin?: () => Promise<string>;\n secretFormTimeoutMs?: number;\n}\n\nexport interface Target {\n source: string;\n team: string;\n product: string;\n}\n\n/**\n * `teams` — a Source admin's view of its teams' integration setup, the\n * team-level counterpart of `apps`. `list` names the teams; `show` reads one\n * team's setup of one product as a checklist; `app set` enters or updates\n * any of a team's own app fields (Zendesk's subdomain, client and signing\n * secret), one at a time if need be — a field left alone keeps its saved\n * value. A secret is typed at the admin's terminal with hidden input or,\n * without one, read from the environment, a private file, stdin or a form\n * in the browser (`secret-input.ts`) — never a value in argv; a non-secret\n * field may be passed as `--set name=value`; `webhook` mints the URL the\n * team's provider sends to, shown once.\n */\nexport async function runTeams(\n ctx: CliContext,\n args: TeamsArgs,\n): Promise<ExitCode> {\n const [rawSubcommand, ...rest] = args.positionals;\n if (isTeamAgentArea(rawSubcommand)) {\n return runTeamAgentCommands(ctx, args);\n }\n const subcommand = parseSubcommand(rawSubcommand);\n\n if (subcommand === 'events') {\n return runTeamEvents(ctx, args, rest);\n }\n if (subcommand === 'scope') {\n return runTeamScope(ctx, args, rest);\n }\n if (subcommand === 'audience') {\n return runTeamAudience(ctx, args, rest);\n }\n\n if (\n isLifecycleSubcommand(subcommand) ||\n (subcommand === 'members' && isLifecycleMemberVerb(rest[0]))\n ) {\n return runLifecycle(ctx, args, parseLifecycle(subcommand, rest, args));\n }\n\n if (isOnboardingSubcommand(subcommand)) {\n const plan = parseOnboarding(subcommand, rest, {\n ...args,\n as: typeof args.flags?.as === 'string' ? args.flags.as : undefined,\n self: args.flags?.self === true,\n mine: args.flags?.mine === true,\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 return runOnboarding(\n ctx,\n args,\n new TeamsClient(env, resolved.session),\n env.host,\n resolved.source,\n plan,\n );\n }\n\n if (subcommand === 'app' && rest[0] !== 'set') {\n throw usageError(\n rest[0]\n ? `Unknown teams app subcommand \"${rest[0]}\".`\n : 'teams app needs a subcommand.',\n 'Run \"ekanos teams app set <team> <product>\".',\n );\n }\n const operands = subcommand === 'app' ? rest.slice(1) : rest;\n\n if (subcommand === 'list' && operands.length > 0) {\n throw usageError(\n 'teams list takes no arguments.',\n 'Run \"ekanos teams list --source <slug>\".',\n );\n }\n\n const team = subcommand === 'list' ? '' : requireSlug(operands[0], 'team');\n // `teams show <team>` alone is the team's overview.\n const overview = subcommand === 'show' && operands[1] === undefined;\n const product =\n subcommand === 'list' || overview\n ? ''\n : requireSlug(operands[1], 'product');\n const extra = operands.slice(subcommand === 'webhook' ? 3 : 2);\n const appEdits = subcommand === 'app' ? parseAppEdits(args.flags) : null;\n if (subcommand !== 'list' && extra.length > 0) {\n throw usageError(\n `Unexpected argument \"${extra[0]}\".`,\n 'See \"ekanos teams --help\".',\n );\n }\n\n if (\n appEdits?.prompts &&\n !canPrompt(ctx, args) &&\n !secretInputGiven(appEdits.secret)\n ) {\n throw usageError(\n \"teams app set needs the team's secrets, and there is no terminal to ask at. Non-secret fields can be passed with --set <name>=<value>.\",\n `Without a terminal, pass ${FIELD_SECRET_FORMS}. Or run it yourself in your terminal: ${cli()} teams app set ${team} ${product}${args.connection ? ` --connection ${args.connection}` : ''}${args.source ? ` --source ${args.source}` : ''}`,\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 source = resolved.source;\n\n if (subcommand === 'list') {\n const list = await client.call((token) =>\n listTeams(env.host, token, source),\n );\n return ctx.succeed(\n { host: env.host, ...list },\n list.teams.length === 0\n ? ctx.ui.result({\n title: `No teams on ${list.source.slug}`,\n tone: 'warn',\n })\n : ctx.ui.result({\n title: `Teams on ${list.source.slug}`,\n rows: list.teams.map((entry) => [entry.slug, teamLine(entry)]),\n notes: [\n '\"ekanos teams show <team>\" shows a team\\'s setup; add a product for its checklist.',\n ...(list.teams.some(\n (entry) =>\n entry.callerIsMember === false && entry.memberCount > 0,\n )\n ? [\n 'You manage every team of the Source as its admin without being a member. To connect your own account to one, join it: \"ekanos teams members add <team> --self\".',\n ]\n : []),\n ],\n }),\n );\n }\n\n if (overview) {\n return runTeamOverview(ctx, client, env.host, source, team);\n }\n\n const target: Target = { source, team, product };\n const status = await client.call((token) =>\n showTeamIntegration(env.host, token, target),\n );\n\n if (subcommand === 'show') {\n return ctx.succeed(\n { host: env.host, ...status },\n checklist(status).join('\\n'),\n );\n }\n\n if (!status.enabled) {\n throw invalidStateError(\n `\"${product}\" is not enabled on ${status.source.slug}.`,\n `\"ekanos sources products --source ${status.source.slug}\" shows what it has; only a super-admin enables a product for a Source (in /admin).`,\n );\n }\n\n if (subcommand === 'app' && appEdits) {\n return setApp(ctx, args, client, env.host, target, status, appEdits);\n }\n return mintWebhook(ctx, args, client, env.host, target, status, operands[2]);\n}\n\n/** What `teams app set` was asked to change, from its flags. */\ninterface AppEdits {\n /** `--field`: enter just these, at the terminal. */\n only: string[];\n /** `--set name=value`: non-secret values, no prompt. */\n values: Record<string, string>;\n /** `--clear name`: remove a saved value. */\n clear: string[];\n /** `--secret-*`, `--set-secret`, `--browser`: where secrets come from without a terminal. */\n secret: SecretFlags;\n /** Whether any field is collected (asked, or read from the secret-input flags). */\n prompts: boolean;\n}\n\nfunction parseAppEdits(flags: TeamsArgs['flags']): AppEdits {\n const list = (name: string): string[] => {\n const raw = flags?.[name];\n if (raw === undefined || raw === false) return [];\n if (Array.isArray(raw)) return raw;\n return typeof raw === 'string' ? [raw] : [];\n };\n const values = parsePlainValues(flags?.set);\n const only = list('field');\n const clear = list('clear');\n const secret = readSecretFlags(flags);\n return {\n only,\n values,\n clear,\n secret,\n // Bare `app set` walks every field; `--field` asks the named ones.\n prompts:\n only.length > 0 ||\n secretInputGiven(secret) ||\n (Object.keys(values).length === 0 && clear.length === 0),\n };\n}\n\nasync function setApp(\n ctx: CliContext,\n args: TeamsArgs,\n client: TeamsClient,\n host: string,\n target: Target,\n status: TeamIntegrationStatus,\n edits: AppEdits,\n): Promise<ExitCode> {\n const app = chooseApp(status, args.connection);\n const result = await promptAndSaveTeamApp(\n ctx,\n args,\n client,\n host,\n target,\n status,\n app,\n edits,\n );\n const missing = result.fields.filter((field) => !field.set);\n const next = [\n ...(missing.length > 0\n ? [\n `Still not set: ${missing.map((field) => field.label).join(', ')} — a team member can't connect until it is. Run \"ekanos teams app set ${target.team} ${target.product} ${missing.map((field) => `--field ${field.secretName}`).join(' ')}\".`,\n ]\n : []),\n ...nextSteps(status, app, target),\n ];\n return ctx.succeed(\n { host, ...result },\n ctx.ui.result({\n title: `Saved ${target.team}'s ${result.product.name} app`,\n rows: [\n ['Source', status.source.slug],\n ['Fields', result.fields.map(fieldLine)],\n ],\n notes: next,\n }),\n );\n}\n\n/**\n * Every field, in turn: bare `teams app set`, and `teams connect` — whose\n * `--set` and secret-input flags fill the team's app too.\n */\nfunction walkEveryField(flags: TeamsArgs['flags']): AppEdits {\n return {\n only: [],\n values: parsePlainValues(flags?.set),\n clear: [],\n secret: readSecretFlags(flags),\n prompts: true,\n };\n}\n\n/**\n * The `teams app set` walkthrough and prompts for one team app, then the\n * save — of only what was entered: a field left empty keeps its saved value.\n * Shared with `teams connect`, which runs it inline when the integration\n * needs the team's own app (Zendesk) before anyone can sign in.\n */\nexport async function promptAndSaveTeamApp(\n ctx: CliContext,\n args: TeamsArgs,\n client: TeamsClient,\n host: string,\n target: Target,\n status: TeamIntegrationStatus,\n app: TeamAppState,\n edits: AppEdits = walkEveryField(args.flags),\n) {\n const known = new Map(app.fields.map((field) => [field.secretName, field]));\n const names = app.fields.map((field) => field.secretName).join(', ');\n for (const name of [\n ...edits.only,\n ...Object.keys(edits.values),\n ...edits.clear,\n ]) {\n if (!known.has(name)) {\n throw usageError(\n `${status.product.name}'s team app has no field \"${name}\".`,\n `Its fields are: ${names}.`,\n );\n }\n }\n for (const name of Object.keys(edits.values)) {\n if (known.get(name)?.sensitive) {\n throw usageError(\n `\"${name}\" is a secret: it is never passed as an argument.`,\n `Pass it as --set-secret ${name}=env:<NAME>|file:<path>|stdin, use --browser, or enter it at the prompt: ekanos teams app set ${target.team} ${target.product} --field ${name}`,\n );\n }\n }\n\n const fields: Record<string, string> = { ...edits.values };\n if (edits.prompts) {\n const toAsk =\n edits.only.length > 0\n ? app.fields.filter((field) => edits.only.includes(field.secretName))\n : app.fields;\n if (edits.only.length === 0)\n ctx.log(appWalkthrough(status, app).join('\\n'));\n else {\n ctx.log(\n `${status.product.name} app for team ${target.team} on ${status.source.slug}`,\n );\n }\n const byName = new Map(toAsk.map((field) => [field.secretName, field]));\n const again = `teams app set ${target.team} ${target.product}${args.connection ? ` --connection ${args.connection}` : ''} --source ${status.source.slug}`;\n Object.assign(\n fields,\n await collectSecrets(ctx, {\n fields: toAsk\n .filter((field) => edits.values[field.secretName] === undefined)\n .map((field) => ({\n name: field.secretName,\n label: field.label,\n sensitive: field.sensitive,\n set: field.set,\n value: field.sensitive ? null : field.value,\n })),\n flags: edits.secret,\n io: teamsSecretIO(args),\n interactive: canPrompt(ctx, args),\n title: `${status.product.name} app for team ${target.team}`,\n refusal: `${status.product.name}'s team app takes secrets (${toAsk\n .filter((field) => field.sensitive)\n .map((field) => field.secretName)\n .join(', ')}), and there is no terminal to ask at.`,\n again,\n prompt: (spec) => {\n const field = byName.get(spec.name)!;\n return (\n field.sensitive\n ? (args.askSecret ?? promptHidden)\n : (args.ask ?? promptLine)\n )(fieldQuestion(field));\n },\n }),\n );\n }\n\n if (Object.keys(fields).length === 0 && edits.clear.length === 0) {\n throw validationError(\n 'Nothing was changed.',\n `Run \"ekanos teams show ${target.team} ${target.product}\" to see the current state.`,\n );\n }\n\n return client.call((token) =>\n setTeamApp(host, token, target, {\n connectionId: app.connectionId,\n fields,\n ...(edits.clear.length > 0 ? { clear: edits.clear } : {}),\n }),\n );\n}\n\n/** The prompt for one field: what is saved, and that Enter keeps it. */\nfunction fieldQuestion(field: TeamAppState['fields'][number]): string {\n const name = `${field.label} [${field.secretName}]`;\n if (field.sensitive) {\n return field.set\n ? `${name} (saved — Enter to keep, hidden): `\n : `${name} (hidden): `;\n }\n if (field.set) {\n return field.value\n ? `${name} (current: ${field.value} — Enter to keep): `\n : `${name} (saved — Enter to keep): `;\n }\n return `${name}: `;\n}\n\n/** One field's state: a secret only as saved / not set, never its value. */\nfunction fieldLine(field: TeamAppState['fields'][number]): string {\n const state = !field.set\n ? 'not set'\n : field.sensitive\n ? 'saved'\n : field.value\n ? field.value\n : 'saved';\n return `${mark(field.set)} ${field.label} (${field.secretName}): ${state}`;\n}\n\nasync function mintWebhook(\n ctx: CliContext,\n args: TeamsArgs,\n client: TeamsClient,\n host: string,\n target: Target,\n status: TeamIntegrationStatus,\n requested: string | undefined,\n): Promise<ExitCode> {\n const webhooks = status.teamApps.flatMap((app) => app.webhooks);\n if (webhooks.length === 0) {\n throw invalidStateError(\n `${status.product.name} has no webhook a team's app sends.`,\n `Run \"ekanos teams show ${target.team} ${target.product}\" to see its setup.`,\n );\n }\n const webhook = requested\n ? webhooks.find((entry) => entry.webhookId === requested)\n : webhooks.length === 1\n ? webhooks[0]\n : undefined;\n if (!webhook) {\n throw usageError(\n requested\n ? `${status.product.name} has no team-app webhook \"${requested}\".`\n : `${status.product.name} has several webhooks; name one.`,\n `Run one of: ${webhooks.map((entry) => `ekanos teams webhook ${target.team} ${target.product} ${entry.webhookId}`).join(', ')}.`,\n );\n }\n\n if (webhook.endpoint && !args.yes) {\n throw invalidStateError(\n `${target.team} already has a live URL for ${webhook.webhookId} (${webhook.endpoint.tokenPrefix}…). A new one revokes it, and the provider's webhook stops working until you paste the new URL there.`,\n `Re-run with --yes when you are ready to update the provider: ekanos teams webhook ${target.team} ${target.product} ${webhook.webhookId} --yes`,\n );\n }\n\n // The URL carries its token, so it goes to a 0600 file, never the output.\n const secrets = ensureSecretsDir(args.env);\n const minted = await client.call((token) =>\n mintTeamWebhook(host, token, target, webhook.webhookId),\n );\n const { url, ...rest } = minted;\n const secretFile = writeSecretFile(secrets, {\n owner: target.team,\n what: `${target.product}-${webhook.webhookId}-webhook-url`,\n purpose: `Webhook URL for team ${target.team}'s ${status.product.name} (${webhook.webhookId}). Paste it into ${status.product.name}'s webhook settings for this team; the token is part of the URL.`,\n values: [['WEBHOOK_URL', url]],\n again: `ekanos teams webhook ${target.team} ${target.product} ${webhook.webhookId} --yes`,\n });\n return ctx.succeed(\n { host, ...rest, secretFile },\n ctx.ui.result({\n title: `Webhook URL for ${target.team} · ${webhook.webhookId}`,\n tone: 'warn',\n rows: [\n ['URL', `saved to ${secretFile} (readable only by you)`],\n [\n 'Paste it into',\n `${status.product.name}'s webhook settings for this team`,\n ],\n ],\n notes: [\n 'The URL carries its token, so it is shown nowhere else and cannot be read again. Copy it from that file into the provider yourself — not into a chat or an agent session — then delete the file.',\n ...(minted.replaced\n ? ['The previous URL is revoked: the provider must use this one.']\n : []),\n ],\n }),\n );\n}\n\n/** `teams show`, read top to bottom like a setup checklist. */\nexport function checklist(status: TeamIntegrationStatus): string[] {\n const name = status.product.name;\n const lines = [\n `${name} for team ${status.team.slug} (${status.team.name}) on ${status.source.slug}`,\n ` ${mark(status.enabled)} Enabled on the Source`,\n ];\n if (!status.enabled) {\n lines.push(\n ` \"ekanos sources products --source ${status.source.slug}\" shows what it has; only a super-admin enables a product for a Source (in /admin).`,\n );\n return lines;\n }\n\n const target = { team: status.team.slug, product: status.product.slug };\n lines.push(\n ...scopeHiddenLines(status.scope, {\n ...target,\n source: status.source.slug,\n }).map((line) => ` ${line}`),\n );\n lines.push(...connectionLines(status));\n for (const app of status.teamApps) {\n lines.push(` Team app: ${app.label} (${app.connectionId})`);\n if (app.setup?.consoleUrl) lines.push(` Open: ${app.setup.consoleUrl}`);\n app.setup?.steps.forEach((step, index) =>\n lines.push(` ${index + 1}. ${step}`),\n );\n lines.push(' Callback URLs to register:');\n lines.push(...callbackUrls(app).map((url) => ` ${url}`));\n if (app.guideUrl) lines.push(` Guide: ${app.guideUrl}`);\n for (const field of app.fields) {\n lines.push(` ${fieldLine(field)}`);\n }\n const unset = app.fields.filter((field) => !field.set);\n if (unset.length > 0) {\n lines.push(\n ` → in your terminal: ${cli()} teams app set ${target.team} ${target.product} --connection ${app.connectionId} ${unset.map((field) => `--field ${field.secretName}`).join(' ')} --source ${status.source.slug}`,\n );\n }\n for (const webhook of app.webhooks) {\n lines.push(\n webhook.endpoint\n ? ` ${mark(true)} Webhook ${webhook.webhookId}: live URL ${webhook.endpoint.tokenPrefix}… since ${day(webhook.endpoint.createdAt)}${webhook.endpoint.lastUsedAt ? `, last delivery ${day(webhook.endpoint.lastUsedAt)}` : ', no delivery yet'}`\n : ` ${mark(false)} Webhook ${webhook.webhookId}: no URL yet`,\n );\n if (!webhook.endpoint) {\n lines.push(\n ` → ekanos teams webhook ${target.team} ${target.product} ${webhook.webhookId} --source ${status.source.slug}`,\n );\n }\n }\n lines.push(\n app.connection\n ? ` ${mark(true)} Connected ${day(app.connection.connectedAt)}${app.connection.connectedBy ? ` by ${who(app.connection.connectedBy)}` : ''}`\n : ` ${mark(false)} Connected: not yet\\n → in your terminal: ${connectCommand(status, app.connectionId)}`,\n );\n }\n\n lines.push(\n status.activation\n ? ` ${mark(true)} Activated for the team${status.activation.activatedAt ? ` ${day(status.activation.activatedAt)}` : ''}${status.activation.activatedBy ? ` by ${who(status.activation.activatedBy)}` : ''}`\n : ` ${mark(false)} Activated: not yet\\n → in your terminal: ${connectCommand(status)}`,\n );\n lines.push(` Team page: ${status.connectUrl}`);\n if (status.agentEvents.length > 0) {\n lines.push(' Agent events it offers:');\n lines.push(\n ...status.agentEvents.map((event) => ` ${event.id} — ${event.label}`),\n );\n }\n return lines;\n}\n\n/**\n * Each OAuth connection in one line — connected, or installed for a named\n * one, with its app's credentials and webhook URL — and which of the team's\n * agents wait on it. A named connection an agent's trigger needs and the team\n * has not installed is the gap no other line names: the trigger is stored\n * and on, and nothing ever reaches it.\n */\nfunction connectionLines(status: TeamIntegrationStatus): string[] {\n const connections = status.connections ?? [];\n if (connections.length === 0) return [];\n const lines = [' Connections:'];\n for (const entry of connections) {\n const named = entry.connectionId !== 'default';\n const app = status.teamApps.find(\n (candidate) => candidate.connectionId === entry.connectionId,\n );\n const webhooks = app?.webhooks ?? [];\n const steps = [\n ...(entry.credentialsSaved === null\n ? []\n : [\n `app credentials ${entry.credentialsSaved ? 'saved' : 'not saved'}`,\n ]),\n named\n ? entry.connected\n ? `installed ${day(entry.connectedAt ?? '')}`\n : 'not installed'\n : entry.connected\n ? `connected ${day(entry.connectedAt ?? '')}`\n : 'not connected',\n ...(webhooks.length > 0\n ? [\n webhooks.every((webhook) => webhook.endpoint)\n ? 'webhook URL made'\n : 'no webhook URL',\n ]\n : []),\n ];\n const ready =\n entry.connected &&\n entry.credentialsSaved !== false &&\n webhooks.every((webhook) => webhook.endpoint);\n lines.push(\n ` ${mark(ready)} ${entry.label} (${entry.connectionId}): ${steps.join(' · ')}${entry.connectedBy ? ` by ${who(entry.connectedBy)}` : ''}`,\n );\n if (entry.neededBy.length > 0) {\n lines.push(\n ` Needed by: ${entry.neededBy.map((need) => `${need.agent} (${need.triggers.join(', ')})`).join(', ')}`,\n );\n }\n if (!entry.connected) {\n lines.push(\n ` → in your terminal: ${connectCommand(status, entry.connectionId)}`,\n );\n }\n }\n return lines;\n}\n\n/**\n * One team in `teams list`: its members, and whether the caller is one. A\n * team nobody has joined says so with the command that joins it, rather than\n * reading as a count of zero.\n */\nexport function teamLine(entry: {\n slug: string;\n name: string;\n memberCount: number;\n callerIsMember?: boolean;\n}): string {\n const count = `${entry.memberCount} member${entry.memberCount === 1 ? '' : 's'}`;\n if (entry.callerIsMember === undefined) return `${entry.name} · ${count}`;\n if (entry.callerIsMember) return `${entry.name} · ${count}, you among them`;\n return entry.memberCount === 0\n ? `${entry.name} · 0 members · you are not a member — ekanos teams members add ${entry.slug} --self`\n : `${entry.name} · ${count} · you are not a member`;\n}\n\n/** The command that connects the team, for a hint: `--connection` only for a named one. */\nfunction connectCommand(\n status: TeamIntegrationStatus,\n connectionId = 'default',\n): string {\n return `${cli()} teams connect ${status.team.slug} ${status.product.slug}${connectionId === 'default' ? '' : ` --connection ${connectionId}`} --source ${status.source.slug}`;\n}\n\nfunction appWalkthrough(\n status: TeamIntegrationStatus,\n app: TeamAppState,\n): string[] {\n const lines = [\n `${status.product.name} app for team ${status.team.slug} on ${status.source.slug}`,\n ];\n if (app.setup?.consoleUrl) lines.push(` Open: ${app.setup.consoleUrl}`);\n const steps = app.setup?.steps.length\n ? [...app.setup.steps]\n : [\n `In ${status.product.name}, create an OAuth app for the team (or open the one it uses).`,\n ];\n steps.push(\n `Check the app lists exactly: ${callbackUrls(app).join(', ')}`,\n \"Enter its values below. Secrets are stored in Ekanos's vault and never shown again.\",\n );\n lines.push(...steps.map((step, index) => ` ${index + 1}. ${step}`));\n if (app.guideUrl) lines.push(` Guide: ${app.guideUrl}`);\n return lines;\n}\n\nfunction nextSteps(\n status: TeamIntegrationStatus,\n app: TeamAppState,\n target: Target,\n): string[] {\n return [\n ...app.webhooks\n .filter((webhook) => !webhook.endpoint)\n .map(\n (webhook) =>\n `Next: \"ekanos teams webhook ${target.team} ${target.product} ${webhook.webhookId}\" for the provider's webhook URL.`,\n ),\n ...(app.connection\n ? []\n : [`Then connect it: ${connectCommand(status, app.connectionId)}`]),\n ];\n}\n\nexport function chooseApp(\n status: TeamIntegrationStatus,\n connection: string | undefined,\n): TeamAppState {\n const apps = status.teamApps;\n if (apps.length === 0) {\n throw invalidStateError(\n `${status.product.name} takes no team app: teams connect through the Source's app, or need none.`,\n `Run \"ekanos apps show ${status.product.slug}\" for the Source's app.`,\n );\n }\n const app = connection\n ? apps.find((entry) => entry.connectionId === connection)\n : apps.length === 1\n ? apps[0]\n : apps.find((entry) => entry.connectionId === 'default');\n if (app) return app;\n throw usageError(\n connection\n ? `${status.product.name} has no team app \"${connection}\".`\n : `${status.product.name} has several team apps; name one.`,\n `Pass --connection with one of: ${apps.map((entry) => entry.connectionId).join(', ')}.`,\n );\n}\n\nexport class TeamsClient {\n constructor(\n private readonly env: AuthEnvironment,\n private session: StoredSession,\n ) {}\n\n async call<T>(\n send: (accessToken: string) => Promise<TeamsApiResult<T>>,\n ): Promise<T> {\n let result = await send(this.session.accessToken);\n if (result.status === 'unauthorized') {\n this.session = await refreshStoredSession(this.env, this.session);\n result = await send(this.session.accessToken);\n }\n if (result.status === 'ok') return result.data;\n throw authRequiredError(\n `The session for ${this.env.host} could not authorize the teams call.`,\n loginHint(this.env),\n );\n }\n}\n\nexport function canPrompt(ctx: CliContext, args: TeamsArgs): boolean {\n return !ctx.jsonMode && (args.stdinIsTTY ?? process.stdin.isTTY === true);\n}\n\n/** What the secret-input flags read from, with this run's test seams. */\nexport function teamsSecretIO(args: TeamsArgs): SecretIO {\n return {\n env: args.env,\n stdinIsTTY: args.stdinIsTTY ?? process.stdin.isTTY === true,\n readStdin: args.readStdin,\n openUrl: args.openUrl,\n formTimeoutMs: args.secretFormTimeoutMs,\n };\n}\n\nfunction parseSubcommand(value: string | undefined): TeamsSubcommand {\n const match = TEAMS_SUBCOMMANDS.find((name) => name === value);\n if (match) return match;\n throw usageError(\n value\n ? `Unknown teams subcommand \"${value}\".`\n : 'teams needs a subcommand.',\n '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 ….',\n );\n}\n\nfunction requireSlug(value: string | undefined, what: 'team' | 'product') {\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 show acme-support zendesk\".'\n : '\"ekanos catalog\" lists the products, e.g. \"ekanos teams show acme-support zendesk\".',\n );\n}\n\nfunction mark(done: boolean): string {\n return done ? '✓' : '✗';\n}\n\nfunction day(iso: string): string {\n return iso.slice(0, 10);\n}\n\nfunction who(member: {\n name: string | null;\n email: string | null;\n userId: string;\n}) {\n return member.email ?? member.name ?? member.userId;\n}\n\n/** Every redirect URI to register. */\nfunction callbackUrls(app: TeamAppState): string[] {\n return app.callbackUrls.length ? app.callbackUrls : [app.callbackUrl];\n}\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { CliContext } from '../context.js';
|
|
2
|
+
import type { ExitCode } from '../exit-codes.js';
|
|
3
|
+
export declare const WORKFLOWS_SUBCOMMANDS: readonly ['list', 'show', 'pull', 'apply', 'enable', 'disable', 'run', 'runs', 'approvals'];
|
|
4
|
+
/** The file `pull` writes and a directory given to `apply` is read from. */
|
|
5
|
+
export declare const WORKFLOW_FILE = "workflow.json";
|
|
6
|
+
export interface WorkflowsArgs {
|
|
7
|
+
host?: string;
|
|
8
|
+
source?: string;
|
|
9
|
+
positionals: readonly string[];
|
|
10
|
+
team?: string;
|
|
11
|
+
all: boolean;
|
|
12
|
+
out?: string;
|
|
13
|
+
force: boolean;
|
|
14
|
+
update?: string;
|
|
15
|
+
confirmAccess: boolean;
|
|
16
|
+
dryRun: boolean;
|
|
17
|
+
input?: string;
|
|
18
|
+
follow: boolean;
|
|
19
|
+
workflow?: string;
|
|
20
|
+
status?: string;
|
|
21
|
+
reason?: string;
|
|
22
|
+
yes: boolean;
|
|
23
|
+
dir: string;
|
|
24
|
+
env: Record<string, string | undefined>;
|
|
25
|
+
/** Test seams: the `--follow` poll delay, and the confirmations. */
|
|
26
|
+
sleep?: (ms: number) => Promise<void>;
|
|
27
|
+
stdinIsTTY?: boolean;
|
|
28
|
+
confirm?: (question: string) => Promise<boolean>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* `workflows` — a team's workflows, for its Source admin: the same
|
|
32
|
+
* definitions the visual editor saves, saved through the same checks
|
|
33
|
+
* (shape, effect pinning, Custom Code review, write-behind-gate), activated
|
|
34
|
+
* through the same gate, run and approved through the same paths. A
|
|
35
|
+
* member's personal workflow is theirs alone and never reachable here.
|
|
36
|
+
*/
|
|
37
|
+
export declare function runWorkflows(ctx: CliContext, args: WorkflowsArgs): Promise<ExitCode>;
|