@ekanos/cli 0.9.0 → 0.11.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 +1 -0
- package/dist/commands/agents-edit.d.ts +49 -0
- package/dist/commands/agents-edit.js +385 -0
- package/dist/commands/agents-edit.js.map +1 -0
- package/dist/commands/agents.d.ts +24 -1
- package/dist/commands/agents.js +117 -8
- package/dist/commands/agents.js.map +1 -1
- package/dist/commands/apps.d.ts +3 -0
- package/dist/commands/apps.js +2 -2
- package/dist/commands/apps.js.map +1 -1
- package/dist/commands/reviewers.d.ts +21 -0
- package/dist/commands/reviewers.js +162 -0
- package/dist/commands/reviewers.js.map +1 -0
- package/dist/commands/runs.d.ts +42 -0
- package/dist/commands/runs.js +362 -0
- package/dist/commands/runs.js.map +1 -0
- package/dist/commands/skills.d.ts +60 -0
- package/dist/commands/skills.js +397 -0
- package/dist/commands/skills.js.map +1 -0
- package/dist/commands/team-agents-agents.d.ts +9 -0
- package/dist/commands/team-agents-agents.js +188 -0
- package/dist/commands/team-agents-agents.js.map +1 -0
- package/dist/commands/team-agents-mcp.d.ts +4 -0
- package/dist/commands/team-agents-mcp.js +218 -0
- package/dist/commands/team-agents-mcp.js.map +1 -0
- package/dist/commands/team-agents-triggers.d.ts +12 -0
- package/dist/commands/team-agents-triggers.js +251 -0
- package/dist/commands/team-agents-triggers.js.map +1 -0
- package/dist/commands/team-agents.d.ts +31 -0
- package/dist/commands/team-agents.js +71 -0
- package/dist/commands/team-agents.js.map +1 -0
- package/dist/commands/teams-onboard.d.ts +51 -0
- package/dist/commands/teams-onboard.js +261 -0
- package/dist/commands/teams-onboard.js.map +1 -0
- package/dist/commands/teams.d.ts +45 -0
- package/dist/commands/teams.js +314 -0
- package/dist/commands/teams.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +222 -2
- package/dist/index.js.map +1 -1
- package/dist/reviewers-api.d.ts +33 -0
- package/dist/reviewers-api.js +81 -0
- package/dist/reviewers-api.js.map +1 -0
- package/dist/runs-api.d.ts +34 -0
- package/dist/runs-api.js +112 -0
- package/dist/runs-api.js.map +1 -0
- package/dist/skills-api.d.ts +28 -0
- package/dist/skills-api.js +104 -0
- package/dist/skills-api.js.map +1 -0
- package/dist/teams-api.d.ts +85 -0
- package/dist/teams-api.js +168 -0
- package/dist/teams-api.js.map +1 -0
- package/package.json +2 -2
- package/templates/package.json.tmpl +4 -4
- package/templates/skills/build-agent/SKILL.md +106 -17
- package/templates/skills/build-agent/references/agent-json.md +78 -2
- package/templates/skills/build-agent/references/rollout.md +9 -1
- package/templates/skills/build-agent/references/set-up-an-integration.md +134 -0
- package/templates/skills/build-agent/references/skills.md +78 -0
- package/templates/skills/build-agent/references/triggers.md +27 -6
- package/templates/skills/ekanos-platform/SKILL.md +115 -5
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { refreshStoredSession, requireSession, resolveAuthEnvironment, } from '../auth/session.js';
|
|
2
|
+
import { authRequiredError, invalidStateError, usageError, validationError, } from '../errors.js';
|
|
3
|
+
import { resolveSourceTarget } from '../source-target.js';
|
|
4
|
+
import { listTeams, mintTeamWebhook, setTeamApp, showTeamIntegration, } from '../teams-api.js';
|
|
5
|
+
import { promptHidden, promptLine } from './apps.js';
|
|
6
|
+
import { isTeamAgentArea, runTeamAgentCommands } from './team-agents.js';
|
|
7
|
+
import { ONBOARDING_SUBCOMMANDS, isOnboardingSubcommand, parseOnboarding, runOnboarding, } from './teams-onboard.js';
|
|
8
|
+
export const TEAMS_SUBCOMMANDS = [
|
|
9
|
+
'list',
|
|
10
|
+
'show',
|
|
11
|
+
'app',
|
|
12
|
+
'webhook',
|
|
13
|
+
...ONBOARDING_SUBCOMMANDS,
|
|
14
|
+
];
|
|
15
|
+
/**
|
|
16
|
+
* `teams` — a Source admin's view of its teams' integration setup, the
|
|
17
|
+
* team-level counterpart of `apps`. `list` names the teams; `show` reads one
|
|
18
|
+
* team's setup of one product as a checklist; `app set` enters a team's own
|
|
19
|
+
* app (Zendesk's subdomain, client and signing secret) at the admin's
|
|
20
|
+
* terminal — never from a flag, a file or a non-interactive run, so an
|
|
21
|
+
* agent driving the CLI never handles a secret; `webhook` mints the URL the
|
|
22
|
+
* team's provider sends to, shown once.
|
|
23
|
+
*/
|
|
24
|
+
export async function runTeams(ctx, args) {
|
|
25
|
+
const [rawSubcommand, ...rest] = args.positionals;
|
|
26
|
+
if (isTeamAgentArea(rawSubcommand)) {
|
|
27
|
+
return runTeamAgentCommands(ctx, args);
|
|
28
|
+
}
|
|
29
|
+
const subcommand = parseSubcommand(rawSubcommand);
|
|
30
|
+
if (isOnboardingSubcommand(subcommand)) {
|
|
31
|
+
const plan = parseOnboarding(subcommand, rest, args);
|
|
32
|
+
const env = resolveAuthEnvironment(ctx, args.host, args.env, {
|
|
33
|
+
projectDir: args.dir,
|
|
34
|
+
});
|
|
35
|
+
const resolved = await resolveSourceTarget(env, requireSession(env.store, env.host), args);
|
|
36
|
+
return runOnboarding(ctx, new TeamsClient(env, resolved.session), env.host, resolved.source, plan);
|
|
37
|
+
}
|
|
38
|
+
if (subcommand === 'app' && rest[0] !== 'set') {
|
|
39
|
+
throw usageError(rest[0]
|
|
40
|
+
? `Unknown teams app subcommand "${rest[0]}".`
|
|
41
|
+
: 'teams app needs a subcommand.', 'Run "ekanos teams app set <team> <product>".');
|
|
42
|
+
}
|
|
43
|
+
const operands = subcommand === 'app' ? rest.slice(1) : rest;
|
|
44
|
+
if (subcommand === 'list' && operands.length > 0) {
|
|
45
|
+
throw usageError('teams list takes no arguments.', 'Run "ekanos teams list --source <slug>".');
|
|
46
|
+
}
|
|
47
|
+
const team = subcommand === 'list' ? '' : requireSlug(operands[0], 'team');
|
|
48
|
+
const product = subcommand === 'list' ? '' : requireSlug(operands[1], 'product');
|
|
49
|
+
const extra = operands.slice(subcommand === 'webhook' ? 3 : 2);
|
|
50
|
+
if (subcommand !== 'list' && extra.length > 0) {
|
|
51
|
+
throw usageError(`Unexpected argument "${extra[0]}".`, 'See "ekanos teams --help".');
|
|
52
|
+
}
|
|
53
|
+
if (subcommand === 'app' && !canPrompt(ctx, args)) {
|
|
54
|
+
throw usageError("teams app set takes the team's secrets at a terminal, never in a script or an agent run.", `Run it yourself in your terminal: npx @ekanos/cli teams app set ${team} ${product}${args.connection ? ` --connection ${args.connection}` : ''}${args.source ? ` --source ${args.source}` : ''}`);
|
|
55
|
+
}
|
|
56
|
+
const env = resolveAuthEnvironment(ctx, args.host, args.env, {
|
|
57
|
+
projectDir: args.dir,
|
|
58
|
+
});
|
|
59
|
+
const resolved = await resolveSourceTarget(env, requireSession(env.store, env.host), args);
|
|
60
|
+
const client = new TeamsClient(env, resolved.session);
|
|
61
|
+
const source = resolved.source;
|
|
62
|
+
if (subcommand === 'list') {
|
|
63
|
+
const list = await client.call((token) => listTeams(env.host, token, source));
|
|
64
|
+
return ctx.succeed(Object.assign({ host: env.host }, list), list.teams.length === 0
|
|
65
|
+
? ctx.ui.result({
|
|
66
|
+
title: `No teams on ${list.source.slug}`,
|
|
67
|
+
tone: 'warn',
|
|
68
|
+
})
|
|
69
|
+
: ctx.ui.result({
|
|
70
|
+
title: `Teams on ${list.source.slug}`,
|
|
71
|
+
rows: list.teams.map((entry) => [
|
|
72
|
+
entry.slug,
|
|
73
|
+
`${entry.name} · ${entry.memberCount} member${entry.memberCount === 1 ? '' : 's'}`,
|
|
74
|
+
]),
|
|
75
|
+
notes: [
|
|
76
|
+
'"ekanos teams show <team> <product>" shows a team\'s setup.',
|
|
77
|
+
],
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
const target = { source, team, product };
|
|
81
|
+
const status = await client.call((token) => showTeamIntegration(env.host, token, target));
|
|
82
|
+
if (subcommand === 'show') {
|
|
83
|
+
return ctx.succeed(Object.assign({ host: env.host }, status), checklist(status).join('\n'));
|
|
84
|
+
}
|
|
85
|
+
if (!status.enabled) {
|
|
86
|
+
throw invalidStateError(`"${product}" is not enabled on ${status.source.slug}.`, '"ekanos catalog" lists what this Source has; Ekanos enables a product for a Source.');
|
|
87
|
+
}
|
|
88
|
+
if (subcommand === 'app') {
|
|
89
|
+
return setApp(ctx, args, client, env.host, target, status);
|
|
90
|
+
}
|
|
91
|
+
return mintWebhook(ctx, args, client, env.host, target, status, operands[2]);
|
|
92
|
+
}
|
|
93
|
+
async function setApp(ctx, args, client, host, target, status) {
|
|
94
|
+
var _a, _b;
|
|
95
|
+
const app = chooseApp(status, args.connection);
|
|
96
|
+
ctx.log(appWalkthrough(status, app).join('\n'));
|
|
97
|
+
const fields = {};
|
|
98
|
+
for (const field of app.fields) {
|
|
99
|
+
const keep = field.set ? ' (set — Enter keeps it)' : '';
|
|
100
|
+
const question = field.sensitive
|
|
101
|
+
? `${field.label}${keep} (hidden): `
|
|
102
|
+
: `${field.label}${keep}: `;
|
|
103
|
+
const value = (await (field.sensitive
|
|
104
|
+
? ((_a = args.askSecret) !== null && _a !== void 0 ? _a : promptHidden)
|
|
105
|
+
: ((_b = args.ask) !== null && _b !== void 0 ? _b : promptLine))(question)).trim();
|
|
106
|
+
if (value)
|
|
107
|
+
fields[field.secretName] = value;
|
|
108
|
+
}
|
|
109
|
+
const missing = app.fields.filter((field) => !field.set && !fields[field.secretName]);
|
|
110
|
+
if (missing.length > 0) {
|
|
111
|
+
throw validationError(`Every field is needed: ${missing.map((field) => field.label).join(', ')}.`, `Run "ekanos teams app set ${target.team} ${target.product}" again.`);
|
|
112
|
+
}
|
|
113
|
+
if (Object.keys(fields).length === 0) {
|
|
114
|
+
throw validationError('Nothing was changed.', `Run "ekanos teams show ${target.team} ${target.product}" to see the current state.`);
|
|
115
|
+
}
|
|
116
|
+
const result = await client.call((token) => setTeamApp(host, token, target, {
|
|
117
|
+
connectionId: app.connectionId,
|
|
118
|
+
fields,
|
|
119
|
+
}));
|
|
120
|
+
const next = nextSteps(status, app, target);
|
|
121
|
+
return ctx.succeed(Object.assign({ host }, result), ctx.ui.result({
|
|
122
|
+
title: `Saved ${target.team}'s ${result.product.name} app`,
|
|
123
|
+
rows: [
|
|
124
|
+
['Source', status.source.slug],
|
|
125
|
+
[
|
|
126
|
+
'Fields',
|
|
127
|
+
result.fields.map((field) => `${mark(field.set)} ${field.label}`),
|
|
128
|
+
],
|
|
129
|
+
],
|
|
130
|
+
notes: next,
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
async function mintWebhook(ctx, args, client, host, target, status, requested) {
|
|
134
|
+
const webhooks = status.teamApps.flatMap((app) => app.webhooks);
|
|
135
|
+
if (webhooks.length === 0) {
|
|
136
|
+
throw invalidStateError(`${status.product.name} has no webhook a team's app sends.`, `Run "ekanos teams show ${target.team} ${target.product}" to see its setup.`);
|
|
137
|
+
}
|
|
138
|
+
const webhook = requested
|
|
139
|
+
? webhooks.find((entry) => entry.webhookId === requested)
|
|
140
|
+
: webhooks.length === 1
|
|
141
|
+
? webhooks[0]
|
|
142
|
+
: undefined;
|
|
143
|
+
if (!webhook) {
|
|
144
|
+
throw usageError(requested
|
|
145
|
+
? `${status.product.name} has no team-app webhook "${requested}".`
|
|
146
|
+
: `${status.product.name} has several webhooks; name one.`, `Run one of: ${webhooks.map((entry) => `ekanos teams webhook ${target.team} ${target.product} ${entry.webhookId}`).join(', ')}.`);
|
|
147
|
+
}
|
|
148
|
+
if (webhook.endpoint && !args.yes) {
|
|
149
|
+
throw invalidStateError(`${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.`, `Re-run with --yes when you are ready to update the provider: ekanos teams webhook ${target.team} ${target.product} ${webhook.webhookId} --yes`);
|
|
150
|
+
}
|
|
151
|
+
const minted = await client.call((token) => mintTeamWebhook(host, token, target, webhook.webhookId));
|
|
152
|
+
return ctx.succeed(Object.assign({ host }, minted), ctx.ui.result({
|
|
153
|
+
title: `Webhook URL for ${target.team} · ${webhook.webhookId}`,
|
|
154
|
+
tone: 'warn',
|
|
155
|
+
rows: [
|
|
156
|
+
['URL', minted.url],
|
|
157
|
+
[
|
|
158
|
+
'Paste it into',
|
|
159
|
+
`${status.product.name}'s webhook settings for this team`,
|
|
160
|
+
],
|
|
161
|
+
],
|
|
162
|
+
notes: [
|
|
163
|
+
'This URL is shown once and cannot be read again. Paste it now.',
|
|
164
|
+
...(minted.replaced
|
|
165
|
+
? ['The previous URL is revoked: the provider must use this one.']
|
|
166
|
+
: []),
|
|
167
|
+
],
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
170
|
+
/** `teams show`, read top to bottom like a setup checklist. */
|
|
171
|
+
export function checklist(status) {
|
|
172
|
+
var _a, _b;
|
|
173
|
+
const name = status.product.name;
|
|
174
|
+
const lines = [
|
|
175
|
+
`${name} for team ${status.team.slug} (${status.team.name}) on ${status.source.slug}`,
|
|
176
|
+
` ${mark(status.enabled)} Enabled on the Source`,
|
|
177
|
+
];
|
|
178
|
+
if (!status.enabled) {
|
|
179
|
+
lines.push(' "ekanos catalog" lists what this Source has; Ekanos enables a product for a Source.');
|
|
180
|
+
return lines;
|
|
181
|
+
}
|
|
182
|
+
const target = { team: status.team.slug, product: status.product.slug };
|
|
183
|
+
for (const app of status.teamApps) {
|
|
184
|
+
lines.push(` Team app: ${app.label} (${app.connectionId})`);
|
|
185
|
+
if ((_a = app.setup) === null || _a === void 0 ? void 0 : _a.consoleUrl)
|
|
186
|
+
lines.push(` Open: ${app.setup.consoleUrl}`);
|
|
187
|
+
(_b = app.setup) === null || _b === void 0 ? void 0 : _b.steps.forEach((step, index) => lines.push(` ${index + 1}. ${step}`));
|
|
188
|
+
lines.push(' Callback URLs to register:');
|
|
189
|
+
lines.push(...callbackUrls(app).map((url) => ` ${url}`));
|
|
190
|
+
if (app.guideUrl)
|
|
191
|
+
lines.push(` Guide: ${app.guideUrl}`);
|
|
192
|
+
for (const field of app.fields) {
|
|
193
|
+
lines.push(` ${mark(field.set)} ${field.label}`);
|
|
194
|
+
}
|
|
195
|
+
if (app.fields.some((field) => !field.set)) {
|
|
196
|
+
lines.push(` → in your terminal: npx @ekanos/cli teams app set ${target.team} ${target.product} --connection ${app.connectionId} --source ${status.source.slug}`);
|
|
197
|
+
}
|
|
198
|
+
for (const webhook of app.webhooks) {
|
|
199
|
+
lines.push(webhook.endpoint
|
|
200
|
+
? ` ${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'}`
|
|
201
|
+
: ` ${mark(false)} Webhook ${webhook.webhookId}: no URL yet`);
|
|
202
|
+
if (!webhook.endpoint) {
|
|
203
|
+
lines.push(` → ekanos teams webhook ${target.team} ${target.product} ${webhook.webhookId} --source ${status.source.slug}`);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
lines.push(app.connection
|
|
207
|
+
? ` ${mark(true)} Connected ${day(app.connection.connectedAt)}${app.connection.connectedBy ? ` by ${who(app.connection.connectedBy)}` : ''}`
|
|
208
|
+
: ` ${mark(false)} Connected: a team member clicks Connect at ${status.connectUrl}`);
|
|
209
|
+
}
|
|
210
|
+
lines.push(status.activation
|
|
211
|
+
? ` ${mark(true)} Activated for the team${status.activation.activatedAt ? ` ${day(status.activation.activatedAt)}` : ''}${status.activation.activatedBy ? ` by ${who(status.activation.activatedBy)}` : ''}`
|
|
212
|
+
: ` ${mark(false)} Activated: a team member connects at ${status.connectUrl}`);
|
|
213
|
+
lines.push(` Team page: ${status.connectUrl}`);
|
|
214
|
+
if (status.agentEvents.length > 0) {
|
|
215
|
+
lines.push(' Agent events it offers:');
|
|
216
|
+
lines.push(...status.agentEvents.map((event) => ` ${event.id} — ${event.label}`));
|
|
217
|
+
}
|
|
218
|
+
return lines;
|
|
219
|
+
}
|
|
220
|
+
function appWalkthrough(status, app) {
|
|
221
|
+
var _a, _b;
|
|
222
|
+
const lines = [
|
|
223
|
+
`${status.product.name} app for team ${status.team.slug} on ${status.source.slug}`,
|
|
224
|
+
];
|
|
225
|
+
if ((_a = app.setup) === null || _a === void 0 ? void 0 : _a.consoleUrl)
|
|
226
|
+
lines.push(` Open: ${app.setup.consoleUrl}`);
|
|
227
|
+
const steps = ((_b = app.setup) === null || _b === void 0 ? void 0 : _b.steps.length)
|
|
228
|
+
? [...app.setup.steps]
|
|
229
|
+
: [
|
|
230
|
+
`In ${status.product.name}, create an OAuth app for the team (or open the one it uses).`,
|
|
231
|
+
];
|
|
232
|
+
steps.push(`Check the app lists exactly: ${callbackUrls(app).join(', ')}`, "Enter its values below. Secrets are stored in Ekanos's vault and never shown again.");
|
|
233
|
+
lines.push(...steps.map((step, index) => ` ${index + 1}. ${step}`));
|
|
234
|
+
if (app.guideUrl)
|
|
235
|
+
lines.push(` Guide: ${app.guideUrl}`);
|
|
236
|
+
return lines;
|
|
237
|
+
}
|
|
238
|
+
function nextSteps(status, app, target) {
|
|
239
|
+
return [
|
|
240
|
+
...app.webhooks
|
|
241
|
+
.filter((webhook) => !webhook.endpoint)
|
|
242
|
+
.map((webhook) => `Next: "ekanos teams webhook ${target.team} ${target.product} ${webhook.webhookId}" for the provider's webhook URL.`),
|
|
243
|
+
...(app.connection
|
|
244
|
+
? []
|
|
245
|
+
: [`Then a team member clicks Connect at ${status.connectUrl}`]),
|
|
246
|
+
];
|
|
247
|
+
}
|
|
248
|
+
function chooseApp(status, connection) {
|
|
249
|
+
const apps = status.teamApps;
|
|
250
|
+
if (apps.length === 0) {
|
|
251
|
+
throw invalidStateError(`${status.product.name} takes no team app: teams connect through the Source's app, or need none.`, `Run "ekanos apps show ${status.product.slug}" for the Source's app.`);
|
|
252
|
+
}
|
|
253
|
+
const app = connection
|
|
254
|
+
? apps.find((entry) => entry.connectionId === connection)
|
|
255
|
+
: apps.length === 1
|
|
256
|
+
? apps[0]
|
|
257
|
+
: apps.find((entry) => entry.connectionId === 'default');
|
|
258
|
+
if (app)
|
|
259
|
+
return app;
|
|
260
|
+
throw usageError(connection
|
|
261
|
+
? `${status.product.name} has no team app "${connection}".`
|
|
262
|
+
: `${status.product.name} has several team apps; name one.`, `Pass --connection with one of: ${apps.map((entry) => entry.connectionId).join(', ')}.`);
|
|
263
|
+
}
|
|
264
|
+
export class TeamsClient {
|
|
265
|
+
constructor(env, session) {
|
|
266
|
+
this.env = env;
|
|
267
|
+
this.session = session;
|
|
268
|
+
}
|
|
269
|
+
async call(send) {
|
|
270
|
+
let result = await send(this.session.accessToken);
|
|
271
|
+
if (result.status === 'unauthorized') {
|
|
272
|
+
this.session = await refreshStoredSession(this.env, this.session);
|
|
273
|
+
result = await send(this.session.accessToken);
|
|
274
|
+
}
|
|
275
|
+
if (result.status === 'ok')
|
|
276
|
+
return result.data;
|
|
277
|
+
throw authRequiredError(`The session for ${this.env.host} could not authorize the teams call.`, `Run "ekanos login --host ${this.env.host}" and retry.`);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
function canPrompt(ctx, args) {
|
|
281
|
+
var _a;
|
|
282
|
+
return !ctx.jsonMode && ((_a = args.stdinIsTTY) !== null && _a !== void 0 ? _a : process.stdin.isTTY === true);
|
|
283
|
+
}
|
|
284
|
+
function parseSubcommand(value) {
|
|
285
|
+
const match = TEAMS_SUBCOMMANDS.find((name) => name === value);
|
|
286
|
+
if (match)
|
|
287
|
+
return match;
|
|
288
|
+
throw usageError(value
|
|
289
|
+
? `Unknown teams subcommand "${value}".`
|
|
290
|
+
: 'teams needs a subcommand.', 'Run one of: ekanos teams list, ekanos teams create <name>, ekanos teams members list <team>, ekanos teams roles list <team>, ekanos teams connect <team> <product>, ekanos teams show <team> <product>, ekanos teams app set <team> <product>, ekanos teams webhook <team> <product> [<webhook-id>], ekanos teams agents|triggers|links|mcp ….');
|
|
291
|
+
}
|
|
292
|
+
function requireSlug(value, what) {
|
|
293
|
+
const slug = value === null || value === void 0 ? void 0 : value.trim().toLowerCase();
|
|
294
|
+
if (slug && /^[a-z0-9][a-z0-9-]*$/.test(slug))
|
|
295
|
+
return slug;
|
|
296
|
+
throw usageError(value ? `"${value}" is not a ${what} slug.` : `Name the ${what}.`, what === 'team'
|
|
297
|
+
? '"ekanos teams list" lists the teams, e.g. "ekanos teams show acme-support zendesk".'
|
|
298
|
+
: '"ekanos catalog" lists the products, e.g. "ekanos teams show acme-support zendesk".');
|
|
299
|
+
}
|
|
300
|
+
function mark(done) {
|
|
301
|
+
return done ? '✓' : '✗';
|
|
302
|
+
}
|
|
303
|
+
function day(iso) {
|
|
304
|
+
return iso.slice(0, 10);
|
|
305
|
+
}
|
|
306
|
+
function who(member) {
|
|
307
|
+
var _a, _b;
|
|
308
|
+
return (_b = (_a = member.email) !== null && _a !== void 0 ? _a : member.name) !== null && _b !== void 0 ? _b : member.userId;
|
|
309
|
+
}
|
|
310
|
+
/** Every redirect URI to register. */
|
|
311
|
+
function callbackUrls(app) {
|
|
312
|
+
return app.callbackUrls.length ? app.callbackUrls : [app.callbackUrl];
|
|
313
|
+
}
|
|
314
|
+
//# sourceMappingURL=teams.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"teams.js","sourceRoot":"","sources":["../../src/commands/teams.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,oBAAoB,EACpB,cAAc,EACd,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EACV,eAAe,GAChB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAEL,SAAS,EACT,eAAe,EACf,UAAU,EACV,mBAAmB,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,eAAe,EACf,aAAa,GACd,MAAM,iBAAiB,CAA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CAAC,CAAC,YAAY,IAAI,GAAG,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 {\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 { 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 { isTeamAgentArea, runTeamAgentCommands } from './team-agents';\nimport {\n ONBOARDING_SUBCOMMANDS,\n isOnboardingSubcommand,\n parseOnboarding,\n runOnboarding,\n} from './teams-onboard';\n\nexport const TEAMS_SUBCOMMANDS = [\n 'list',\n 'show',\n 'app',\n 'webhook',\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 /** 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\ninterface 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 a team's own\n * app (Zendesk's subdomain, client and signing secret) at the admin's\n * terminal — never from a flag, a file or a non-interactive run, so an\n * agent driving the CLI never handles a secret; `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 (isOnboardingSubcommand(subcommand)) {\n const plan = parseOnboarding(subcommand, rest, args);\n const env = resolveAuthEnvironment(ctx, args.host, args.env, {\n projectDir: args.dir,\n });\n const resolved = await resolveSourceTarget(\n env,\n requireSession(env.store, env.host),\n args,\n );\n return runOnboarding(\n ctx,\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 const product =\n subcommand === 'list' ? '' : requireSlug(operands[1], 'product');\n const extra = operands.slice(subcommand === 'webhook' ? 3 : 2);\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 (subcommand === 'app' && !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.\",\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(\n env,\n requireSession(env.store, env.host),\n args,\n );\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> <product>\" shows a team\\'s setup.',\n ],\n }),\n );\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 catalog\" lists what this Source has; Ekanos enables a product for a Source.',\n );\n }\n\n if (subcommand === 'app') {\n return setApp(ctx, args, client, env.host, target, status);\n }\n return mintWebhook(ctx, args, client, env.host, target, status, operands[2]);\n}\n\nasync function setApp(\n ctx: CliContext,\n args: TeamsArgs,\n client: TeamsClient,\n host: string,\n target: Target,\n status: TeamIntegrationStatus,\n): Promise<ExitCode> {\n const app = chooseApp(status, args.connection);\n ctx.log(appWalkthrough(status, app).join('\\n'));\n\n const fields: Record<string, string> = {};\n for (const field of app.fields) {\n const keep = field.set ? ' (set — Enter keeps it)' : '';\n const question = field.sensitive\n ? `${field.label}${keep} (hidden): `\n : `${field.label}${keep}: `;\n const value = (\n await (\n field.sensitive\n ? (args.askSecret ?? promptHidden)\n : (args.ask ?? promptLine)\n )(question)\n ).trim();\n if (value) fields[field.secretName] = value;\n }\n\n const missing = app.fields.filter(\n (field) => !field.set && !fields[field.secretName],\n );\n if (missing.length > 0) {\n throw validationError(\n `Every field is needed: ${missing.map((field) => field.label).join(', ')}.`,\n `Run \"ekanos teams app set ${target.team} ${target.product}\" again.`,\n );\n }\n if (Object.keys(fields).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 const result = await client.call((token) =>\n setTeamApp(host, token, target, {\n connectionId: app.connectionId,\n fields,\n }),\n );\n const next = nextSteps(status, app, target);\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 [\n 'Fields',\n result.fields.map((field) => `${mark(field.set)} ${field.label}`),\n ],\n ],\n notes: next,\n }),\n );\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 const minted = await client.call((token) =>\n mintTeamWebhook(host, token, target, webhook.webhookId),\n );\n return ctx.succeed(\n { host, ...minted },\n ctx.ui.result({\n title: `Webhook URL for ${target.team} · ${webhook.webhookId}`,\n tone: 'warn',\n rows: [\n ['URL', minted.url],\n [\n 'Paste it into',\n `${status.product.name}'s webhook settings for this team`,\n ],\n ],\n notes: [\n 'This URL is shown once and cannot be read again. Paste it now.',\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 catalog\" lists what this Source has; Ekanos enables a product for a Source.',\n );\n return lines;\n }\n\n const target = { team: status.team.slug, product: status.product.slug };\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(` ${mark(field.set)} ${field.label}`);\n }\n if (app.fields.some((field) => !field.set)) {\n lines.push(\n ` → in your terminal: npx @ekanos/cli teams app set ${target.team} ${target.product} --connection ${app.connectionId} --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: a team member clicks Connect at ${status.connectUrl}`,\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: a team member connects at ${status.connectUrl}`,\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\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 a team member clicks Connect at ${status.connectUrl}`]),\n ];\n}\n\nfunction 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 `Run \"ekanos login --host ${this.env.host}\" and retry.`,\n );\n }\n}\n\nfunction 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 members list <team>, ekanos teams roles list <team>, ekanos teams connect <team> <product>, ekanos teams show <team> <product>, ekanos teams app set <team> <product>, ekanos teams webhook <team> <product> [<webhook-id>], 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"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export interface RunOptions {
|
|
|
16
16
|
*/
|
|
17
17
|
stdinIsTTY?: boolean;
|
|
18
18
|
confirm?: (question: string) => Promise<boolean>;
|
|
19
|
-
/** Test-only answers for `apps set`
|
|
19
|
+
/** Test-only answers for `apps set` / `teams app set` questions — never set from real CLI wiring. */
|
|
20
20
|
ask?: (question: string) => Promise<string>;
|
|
21
21
|
askSecret?: (question: string) => Promise<string>;
|
|
22
22
|
/**
|