@ekanos/cli 0.26.0 → 0.27.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 -1
- package/dist/catalog-api.d.ts +4 -1
- package/dist/catalog-api.js +3 -1
- package/dist/catalog-api.js.map +1 -1
- package/dist/commands/catalog.d.ts +5 -2
- package/dist/commands/catalog.js +8 -3
- package/dist/commands/catalog.js.map +1 -1
- package/dist/commands/dev.js +6 -4
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/teams-overview.js +2 -1
- package/dist/commands/teams-overview.js.map +1 -1
- package/dist/experience/publish.js +7 -11
- package/dist/experience/publish.js.map +1 -1
- package/dist/host-snapshots.d.ts +10 -0
- package/dist/host-snapshots.js +48 -21
- package/dist/host-snapshots.js.map +1 -1
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/templates/claude-skill.md.tmpl +4 -3
- package/templates/experience/package.json.tmpl +4 -4
- package/templates/package.json.tmpl +4 -4
- package/templates/skills/build-agent/SKILL.md +1 -1
- package/templates/skills/build-agent/references/agent-json.md +2 -2
- package/templates/skills/build-agent/references/app-setup.md +1 -1
- package/templates/skills/build-agent/references/set-up-an-integration.md +1 -1
- package/templates/skills/build-agent/references/triggers.md +1 -1
- package/templates/skills/ekanos-platform/SKILL.md +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"teams-overview.js","sourceRoot":"","sources":["../../src/commands/teams-overview.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,mBAAmB,EACnB,mBAAmB,GAEpB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAY,aAAa,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,WAAW,EAAiB,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,mBAAmB,EAAE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ACxB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,IAAI,IAAI,EAAE,CAAC;QACxD,OAAO,CAAC,IAAI,CACV,GAAG,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CACnE,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import {\n type CatalogProduct,\n type Requirement,\n SourceCatalogSchema,\n TeamAgentListSchema,\n type TeamIntegrationStatus,\n} from '@ekanos/integration-schema';\n\nimport type { CliContext } from '../context';\nimport { CliError, notFoundError, toCliError } from '../errors';\nimport { ERROR_CODES, type ExitCode } from '../exit-codes';\nimport { cli } from '../invocation';\nimport { call, listTeams, showTeamIntegration } from '../teams-api';\nimport { scopeFix, scopeHiddenWords } from './scope-notice';\nimport {\n REASON_WORDS,\n agentReadiness,\n liveLine,\n requirementFix,\n} from './team-agent-readiness';\nimport type { TeamsClient } from './teams';\n\n/**\n * `ekanos teams show <team>` with no product: one screen per team (CLI audit\n * P1-7) — its members, one line per Integration the Source has enabled (whose\n * connection, or the step to make it), and one line per provided agent with\n * the same verdict as `teams agents show`. Reads the team list, the Source\n * catalog, the team's agents, and each enabled Integration's status.\n */\nexport async function runTeamOverview(\n ctx: CliContext,\n client: TeamsClient,\n host: string,\n source: string,\n team: string,\n): Promise<ExitCode> {\n const [teams, catalog, agents] = await Promise.all([\n client.call((token) => listTeams(host, token, source)),\n client.call((token) =>\n call(host, token, SourceCatalogSchema, {\n method: 'GET',\n path: '/api/partner/catalog',\n source,\n }),\n ),\n client.call((token) =>\n call(host, token, TeamAgentListSchema, {\n method: 'GET',\n path: `/api/partner/teams/${encodeURIComponent(team)}/agents`,\n source,\n }),\n ),\n ]);\n const ref = teams.teams.find((entry) => entry.slug === team);\n if (!ref) {\n throw notFoundError(\n `No team \"${team}\" on ${teams.source.slug}.`,\n 'Run \"ekanos teams list\" to see the teams on this Source.',\n );\n }\n\n const integrations = catalog.products.filter(\n (product) =>\n product.kind === 'integration' &&\n product.availability === 'enabled' &&\n // A catalog row with no package on this host has no team status to read.\n product.registered !== false,\n );\n // One product the host cannot answer for is a row of its own, never the\n // whole overview: the slugs are the server's, so its refusal is about that\n // product. Sign-in, permission and network failures still stop the command.\n const reads = await inBatches(integrations, 4, (product) =>\n client\n .call((token) =>\n showTeamIntegration(host, token, {\n source,\n team,\n product: product.slug,\n }),\n )\n .then(\n (status): IntegrationRead => ({ ok: true, status }),\n (error: unknown): IntegrationRead => {\n const failure = toCliError(error);\n if (STOPS_THE_OVERVIEW.has(failure.code)) throw failure;\n return { ok: false, error: failure };\n },\n ),\n );\n\n // What the team's agents need of each product, and whose connection it is.\n const needs = new Map<string, Requirement>();\n for (const entry of agents.agents) {\n for (const item of entry.agent?.requirements ?? []) {\n if (item.kind === 'product' && !needs.has(item.key)) {\n needs.set(item.key, item);\n }\n }\n }\n\n const target = { team, source };\n const agentRows = agents.agents.map((entry) => ({\n key: entry.key,\n name: entry.name,\n on: entry.agent?.status === 'active',\n readiness: agentReadiness(entry, target),\n }));\n const integrationRows = integrations.map((product, index) => {\n const read = reads[index]!;\n return {\n slug: product.slug,\n name: product.name,\n line: read.ok\n ? withScope(\n integrationLine(\n product,\n read.status,\n needs.get(product.slug),\n target,\n ),\n read.status,\n { ...target, product: product.slug },\n )\n : {\n state: `? couldn't read its status — ${read.error.message}`,\n fix: `\"${cli()} teams show ${team} ${product.slug} --source ${source}\" shows the details.`,\n },\n };\n });\n\n const width = Math.max(\n 8,\n ...integrations.map((product) => product.slug.length),\n ...agents.agents.map((entry) => entry.key.length),\n );\n const pad = (label: string) => label.padEnd(width);\n const live = agentRows.filter((row) => row.readiness.live).length;\n\n return ctx.succeed(\n {\n host,\n team: { slug: ref.slug, name: ref.name, memberCount: ref.memberCount },\n integrations: integrationRows.map((row, index) => ({\n slug: row.slug,\n name: row.name,\n status: reads[index]!.ok ? reads[index]!.status : null,\n ...(reads[index]!.ok\n ? {}\n : {\n error: {\n code: reads[index]!.error.code,\n message: reads[index]!.error.message,\n },\n }),\n agentsNeed: needs.get(row.slug) ?? null,\n })),\n agents: agentRows,\n },\n [\n `${ref.name} (${ref.slug}) · ${ref.memberCount} member${ref.memberCount === 1 ? '' : 's'} · ${agentRows.filter((row) => row.on).length} agent${agentRows.filter((row) => row.on).length === 1 ? '' : 's'} on, ${live} live`,\n '',\n 'Integrations',\n ...(integrationRows.length === 0\n ? [' none enabled for the Source']\n : integrationRows.flatMap((row) => [\n ` ${pad(row.slug)} ${row.line.state}`,\n ...(row.line.fix ? [` ${pad('')} → ${row.line.fix}`] : []),\n ])),\n '',\n 'Agents',\n ...(agentRows.length === 0\n ? [' none provided']\n : agentRows.map(\n (row) =>\n ` ${pad(row.key)} ${liveLine(row.readiness)}${row.readiness.next ? ` · Next: ${row.readiness.next}` : ''}`,\n )),\n '',\n `\"ekanos teams agents show ${team} <key>\" explains one agent; \"ekanos teams show ${team} <product>\" one integration.`,\n ].join('\\n'),\n );\n}\n\nfunction integrationLine(\n product: CatalogProduct,\n status: TeamIntegrationStatus,\n need: Requirement | undefined,\n target: { team: string; source: string },\n): { state: string; fix: string | null } {\n if (need?.owner === 'source' || need?.via === 'source') {\n const problem =\n need.reason && need.reason !== 'not_connected'\n ? REASON_WORDS[need.reason]\n : null;\n const state = !need.connected\n ? `✗ via Source connection — ${problem ?? REASON_WORDS.not_connected}`\n : need.via === 'source'\n ? `✓ via Source connection${need.viaDetail ? ` · routes: ${need.viaDetail}` : ''}`\n : `! via team connection (${problem ?? 'the Source connection is not used'})`;\n return {\n state,\n fix:\n need.connected && need.via === 'source'\n ? null\n : requirementFix(need, target.team, target.source),\n };\n }\n if (!product.requiresActivation) {\n return { state: '✓ works as shipped', fix: null };\n }\n if (product.scope === 'user') {\n const person =\n need?.via === 'person' && need.viaDetail\n ? need.connected\n ? ` · ✓ ${need.viaDetail} connected (an agent runs as them)`\n : ` · ✗ ${need.viaDetail} not connected (an agent runs as them)`\n : '';\n return {\n state: `personal: each person connects their own${person}`,\n fix:\n need && !need.connected\n ? requirementFix(need, target.team, target.source)\n : null,\n };\n }\n const webhooks = status.teamApps.flatMap((app) => app.webhooks);\n const made = webhooks.filter((webhook) => webhook.endpoint).length;\n const webhookNote =\n webhooks.length > 0 ? ` · webhook URL ${made}/${webhooks.length} made` : '';\n if (status.activation) {\n const by = status.activation.activatedBy?.email;\n return {\n state: `✓ connected${status.activation.activatedAt ? ` ${status.activation.activatedAt.slice(0, 10)}` : ''}${by ? ` by ${by}` : ''}${webhookNote}`,\n fix: null,\n };\n }\n return {\n state: `✗ not connected${webhookNote}`,\n fix: `${cli()} teams connect ${target.team} ${product.slug} --source ${target.source}`,\n };\n}\n\n/** A product the team's scopes hide from it in the app says so, whatever else is true. */\nfunction withScope(\n line: { state: string; fix: string | null },\n status: TeamIntegrationStatus,\n target: { team: string; source: string; product: string },\n): { state: string; fix: string | null } {\n if (!status.scope?.hidden) return line;\n return {\n state: `${line.state} · ! ${scopeHiddenWords(status.scope)}`,\n fix: line.fix ?? scopeFix(status.scope, target),\n };\n}\n\ntype IntegrationRead =\n | { ok: true; status: TeamIntegrationStatus }\n | { ok: false; error: CliError };\n\nconst STOPS_THE_OVERVIEW = new Set<string>([\n ERROR_CODES.AUTH_REQUIRED,\n ERROR_CODES.FORBIDDEN,\n ERROR_CODES.NETWORK,\n ERROR_CODES.TIMEOUT,\n]);\n\n/** Each item through `read`, at most `size` at a time, in order. */\nasync function inBatches<T, R>(\n items: T[],\n size: number,\n read: (item: T) => Promise<R>,\n): Promise<R[]> {\n const results: R[] = [];\n for (let start = 0; start < items.length; start += size) {\n results.push(\n ...(await Promise.all(items.slice(start, start + size).map(read))),\n );\n }\n return results;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"teams-overview.js","sourceRoot":"","sources":["../../src/commands/teams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KAAK,EAAE,MAAM,CAAC;KAChD,CAAC;AACJ,CAAC;AAMD,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAS;IACzC,WAAW,CAAC,aAAa;IACzB,WAAW,CAAC,SAAS;IACrB,WAAW,CAAC,OAAO;IACnB,WAAW,CAAC,OAAO;CACpB,CAAC,CAAC;AAEH,oEAAoE;AACpE,KAAK,UAAU,SAAS,CACtB,KAAU,EACV,IAAY,EACZ,IAA6B;IAE7B,MAAM,OAAO,GAAQ,EAAE,CAAC;IACxB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,IAAI,IAAI,EAAE,CAAC;QACxD,OAAO,CAAC,IAAI,CACV,GAAG,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CACnE,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import {\n type CatalogProduct,\n type Requirement,\n SourceCatalogSchema,\n TeamAgentListSchema,\n type TeamIntegrationStatus,\n} from '@ekanos/integration-schema';\n\nimport type { CliContext } from '../context';\nimport { CliError, notFoundError, toCliError } from '../errors';\nimport { ERROR_CODES, type ExitCode } from '../exit-codes';\nimport { cli } from '../invocation';\nimport { call, listTeams, showTeamIntegration } from '../teams-api';\nimport { scopeFix, scopeHiddenWords } from './scope-notice';\nimport {\n REASON_WORDS,\n agentReadiness,\n liveLine,\n requirementFix,\n} from './team-agent-readiness';\nimport type { TeamsClient } from './teams';\n\n/**\n * `ekanos teams show <team>` with no product: one screen per team (CLI audit\n * P1-7) — its members, one line per Integration the Source has enabled (whose\n * connection, or the step to make it), and one line per provided agent with\n * the same verdict as `teams agents show`. Reads the team list, the Source\n * catalog, the team's agents, and each enabled Integration's status.\n */\nexport async function runTeamOverview(\n ctx: CliContext,\n client: TeamsClient,\n host: string,\n source: string,\n team: string,\n): Promise<ExitCode> {\n const [teams, catalog, agents] = await Promise.all([\n client.call((token) => listTeams(host, token, source)),\n client.call((token) =>\n call(host, token, SourceCatalogSchema, {\n method: 'GET',\n // Every integration the Source runs, not only SDK packages.\n path: '/api/partner/catalog?scope=all',\n source,\n }),\n ),\n client.call((token) =>\n call(host, token, TeamAgentListSchema, {\n method: 'GET',\n path: `/api/partner/teams/${encodeURIComponent(team)}/agents`,\n source,\n }),\n ),\n ]);\n const ref = teams.teams.find((entry) => entry.slug === team);\n if (!ref) {\n throw notFoundError(\n `No team \"${team}\" on ${teams.source.slug}.`,\n 'Run \"ekanos teams list\" to see the teams on this Source.',\n );\n }\n\n const integrations = catalog.products.filter(\n (product) =>\n product.kind === 'integration' &&\n product.availability === 'enabled' &&\n // A catalog row with no package on this host has no team status to read.\n product.registered !== false,\n );\n // One product the host cannot answer for is a row of its own, never the\n // whole overview: the slugs are the server's, so its refusal is about that\n // product. Sign-in, permission and network failures still stop the command.\n const reads = await inBatches(integrations, 4, (product) =>\n client\n .call((token) =>\n showTeamIntegration(host, token, {\n source,\n team,\n product: product.slug,\n }),\n )\n .then(\n (status): IntegrationRead => ({ ok: true, status }),\n (error: unknown): IntegrationRead => {\n const failure = toCliError(error);\n if (STOPS_THE_OVERVIEW.has(failure.code)) throw failure;\n return { ok: false, error: failure };\n },\n ),\n );\n\n // What the team's agents need of each product, and whose connection it is.\n const needs = new Map<string, Requirement>();\n for (const entry of agents.agents) {\n for (const item of entry.agent?.requirements ?? []) {\n if (item.kind === 'product' && !needs.has(item.key)) {\n needs.set(item.key, item);\n }\n }\n }\n\n const target = { team, source };\n const agentRows = agents.agents.map((entry) => ({\n key: entry.key,\n name: entry.name,\n on: entry.agent?.status === 'active',\n readiness: agentReadiness(entry, target),\n }));\n const integrationRows = integrations.map((product, index) => {\n const read = reads[index]!;\n return {\n slug: product.slug,\n name: product.name,\n line: read.ok\n ? withScope(\n integrationLine(\n product,\n read.status,\n needs.get(product.slug),\n target,\n ),\n read.status,\n { ...target, product: product.slug },\n )\n : {\n state: `? couldn't read its status — ${read.error.message}`,\n fix: `\"${cli()} teams show ${team} ${product.slug} --source ${source}\" shows the details.`,\n },\n };\n });\n\n const width = Math.max(\n 8,\n ...integrations.map((product) => product.slug.length),\n ...agents.agents.map((entry) => entry.key.length),\n );\n const pad = (label: string) => label.padEnd(width);\n const live = agentRows.filter((row) => row.readiness.live).length;\n\n return ctx.succeed(\n {\n host,\n team: { slug: ref.slug, name: ref.name, memberCount: ref.memberCount },\n integrations: integrationRows.map((row, index) => ({\n slug: row.slug,\n name: row.name,\n status: reads[index]!.ok ? reads[index]!.status : null,\n ...(reads[index]!.ok\n ? {}\n : {\n error: {\n code: reads[index]!.error.code,\n message: reads[index]!.error.message,\n },\n }),\n agentsNeed: needs.get(row.slug) ?? null,\n })),\n agents: agentRows,\n },\n [\n `${ref.name} (${ref.slug}) · ${ref.memberCount} member${ref.memberCount === 1 ? '' : 's'} · ${agentRows.filter((row) => row.on).length} agent${agentRows.filter((row) => row.on).length === 1 ? '' : 's'} on, ${live} live`,\n '',\n 'Integrations',\n ...(integrationRows.length === 0\n ? [' none enabled for the Source']\n : integrationRows.flatMap((row) => [\n ` ${pad(row.slug)} ${row.line.state}`,\n ...(row.line.fix ? [` ${pad('')} → ${row.line.fix}`] : []),\n ])),\n '',\n 'Agents',\n ...(agentRows.length === 0\n ? [' none provided']\n : agentRows.map(\n (row) =>\n ` ${pad(row.key)} ${liveLine(row.readiness)}${row.readiness.next ? ` · Next: ${row.readiness.next}` : ''}`,\n )),\n '',\n `\"ekanos teams agents show ${team} <key>\" explains one agent; \"ekanos teams show ${team} <product>\" one integration.`,\n ].join('\\n'),\n );\n}\n\nfunction integrationLine(\n product: CatalogProduct,\n status: TeamIntegrationStatus,\n need: Requirement | undefined,\n target: { team: string; source: string },\n): { state: string; fix: string | null } {\n if (need?.owner === 'source' || need?.via === 'source') {\n const problem =\n need.reason && need.reason !== 'not_connected'\n ? REASON_WORDS[need.reason]\n : null;\n const state = !need.connected\n ? `✗ via Source connection — ${problem ?? REASON_WORDS.not_connected}`\n : need.via === 'source'\n ? `✓ via Source connection${need.viaDetail ? ` · routes: ${need.viaDetail}` : ''}`\n : `! via team connection (${problem ?? 'the Source connection is not used'})`;\n return {\n state,\n fix:\n need.connected && need.via === 'source'\n ? null\n : requirementFix(need, target.team, target.source),\n };\n }\n if (!product.requiresActivation) {\n return { state: '✓ works as shipped', fix: null };\n }\n if (product.scope === 'user') {\n const person =\n need?.via === 'person' && need.viaDetail\n ? need.connected\n ? ` · ✓ ${need.viaDetail} connected (an agent runs as them)`\n : ` · ✗ ${need.viaDetail} not connected (an agent runs as them)`\n : '';\n return {\n state: `personal: each person connects their own${person}`,\n fix:\n need && !need.connected\n ? requirementFix(need, target.team, target.source)\n : null,\n };\n }\n const webhooks = status.teamApps.flatMap((app) => app.webhooks);\n const made = webhooks.filter((webhook) => webhook.endpoint).length;\n const webhookNote =\n webhooks.length > 0 ? ` · webhook URL ${made}/${webhooks.length} made` : '';\n if (status.activation) {\n const by = status.activation.activatedBy?.email;\n return {\n state: `✓ connected${status.activation.activatedAt ? ` ${status.activation.activatedAt.slice(0, 10)}` : ''}${by ? ` by ${by}` : ''}${webhookNote}`,\n fix: null,\n };\n }\n return {\n state: `✗ not connected${webhookNote}`,\n fix: `${cli()} teams connect ${target.team} ${product.slug} --source ${target.source}`,\n };\n}\n\n/** A product the team's scopes hide from it in the app says so, whatever else is true. */\nfunction withScope(\n line: { state: string; fix: string | null },\n status: TeamIntegrationStatus,\n target: { team: string; source: string; product: string },\n): { state: string; fix: string | null } {\n if (!status.scope?.hidden) return line;\n return {\n state: `${line.state} · ! ${scopeHiddenWords(status.scope)}`,\n fix: line.fix ?? scopeFix(status.scope, target),\n };\n}\n\ntype IntegrationRead =\n | { ok: true; status: TeamIntegrationStatus }\n | { ok: false; error: CliError };\n\nconst STOPS_THE_OVERVIEW = new Set<string>([\n ERROR_CODES.AUTH_REQUIRED,\n ERROR_CODES.FORBIDDEN,\n ERROR_CODES.NETWORK,\n ERROR_CODES.TIMEOUT,\n]);\n\n/** Each item through `read`, at most `size` at a time, in order. */\nasync function inBatches<T, R>(\n items: T[],\n size: number,\n read: (item: T) => Promise<R>,\n): Promise<R[]> {\n const results: R[] = [];\n for (let start = 0; start < items.length; start += size) {\n results.push(\n ...(await Promise.all(items.slice(start, start + size).map(read))),\n );\n }\n return results;\n}\n"]}
|
|
@@ -175,8 +175,8 @@ export async function packExperience(gate, artifactDir) {
|
|
|
175
175
|
* archive in its own gate.
|
|
176
176
|
*/
|
|
177
177
|
export async function submitExperience(ctx, args, gate) {
|
|
178
|
-
var _a;
|
|
179
|
-
var
|
|
178
|
+
var _a, _b;
|
|
179
|
+
var _c, _d;
|
|
180
180
|
const { project } = gate;
|
|
181
181
|
const env = resolveAuthEnvironment(ctx, args.host, args.env, {
|
|
182
182
|
projectDir: project.dir,
|
|
@@ -192,8 +192,8 @@ export async function submitExperience(ctx, args, gate) {
|
|
|
192
192
|
slug: project.slug,
|
|
193
193
|
version,
|
|
194
194
|
yes: args.yes === true,
|
|
195
|
-
stdinIsTTY: (
|
|
196
|
-
confirm: (
|
|
195
|
+
stdinIsTTY: (_c = args.stdinIsTTY) !== null && _c !== void 0 ? _c : process.stdin.isTTY === true,
|
|
196
|
+
confirm: (_d = args.confirm) !== null && _d !== void 0 ? _d : promptYesNo,
|
|
197
197
|
});
|
|
198
198
|
const toolchain = await fetchToolchainReport(env.host, verified.session.accessToken);
|
|
199
199
|
if (toolchain.status !== 'ok' ||
|
|
@@ -228,15 +228,11 @@ export async function submitExperience(ctx, args, gate) {
|
|
|
228
228
|
ctx.log(ctx.ui.ok(`${ctx.ui.glyphs.ok} packed ${project.slug}@${version} (${files.length} files).`));
|
|
229
229
|
}
|
|
230
230
|
const source = verified.sourceSeat.slug;
|
|
231
|
+
const availability = (_b = project.ekanos.availability) === null || _b === void 0 ? void 0 : _b.mode;
|
|
231
232
|
ctx.log(`Submitting to ${env.host} (source "${source}")…`);
|
|
232
|
-
const receipt = await submitWithOneRefresh(env, verified.session, {
|
|
233
|
-
source,
|
|
234
|
-
slug: project.slug,
|
|
235
|
-
kind: 'experience',
|
|
236
|
-
version,
|
|
233
|
+
const receipt = await submitWithOneRefresh(env, verified.session, Object.assign({ source, slug: project.slug, kind: 'experience', version,
|
|
237
234
|
manifest,
|
|
238
|
-
archive,
|
|
239
|
-
});
|
|
235
|
+
archive }, (availability ? { availability } : {})));
|
|
240
236
|
if (!ctx.jsonMode) {
|
|
241
237
|
ctx.log(ctx.ui.ok(`${ctx.ui.glyphs.ok} submitted ${receipt.slug}@${receipt.version} (state "${receipt.state}").`));
|
|
242
238
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../../src/experience/publish.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEhF,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBA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GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,CAAC;IAE1C,OAAO,GAAG,CAAC,OAAO,CAChB;QACE,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE;YACP,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,SAAS,EAAE,MAAM,CAAC,SAAS;SAC5B;QACD,SAAS,EAAE,KAAK;KACjB,EACD,mBAAmB,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,OAAO,KAAK,MAAM,CAAC,KAAK,CAAC,MAAM,WAAW,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,4BAA4B,CAC1I,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,wBAAwB,GACnC,4DAA4D,CAAC","sourcesContent":["import { canonicalJson } from '@ekanos/integration-schema';\nimport { execFileSync } from 'node:child_process';\nimport * as fs from 'node:fs';\nimport * as os from 'node:os';\nimport * as path from 'node:path';\n\nimport type { StoredSession } from '../auth/credential-store';\nimport { requireSession, resolveAuthEnvironment } from '../auth/session';\nimport {\n promptYesNo,\n resolveSourceSlug,\n submitWithOneRefresh,\n verifyPublishTarget,\n} from '../commands/publish';\nimport type { CliContext } from '../context';\nimport { activeOverridesFor, harnessPinsResolver } from '../dev-experience';\nimport { gateFailedError, preconditionError, validationError } from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { MAX_ARCHIVE_BYTES } from '../pack';\nimport { MAX_MANIFEST_BYTES } from '../publish-api';\nimport { fetchToolchainReport } from '../toolchain-api';\nimport { shortHost } from '../ui';\nimport { emitExperience } from './build';\nimport { type ExperienceCheckResult, runExperienceChecks } from './checks';\nimport {\n CLEAN_ROOM_ENV,\n buildInCleanRoom,\n hasBuildableLockfile,\n} from './clean-room';\nimport { isOverridesFileTracked } from './overrides';\nimport {\n type ExperienceProject,\n LOCAL_OVERRIDES_FILE,\n readExperienceProject,\n} from './project';\nimport { failOnErrors } from './report';\n\nexport interface ExperiencePublishArgs {\n dir: string;\n dryRun: boolean;\n env: Record<string, string | undefined>;\n /** The host to submit to (a real run only). Falls back to ekanos.json, then the stored login. */\n host?: string;\n /** The source slug to submit for (a real run only). Falls back to ekanos.json \"source\". */\n source?: string;\n /** Skips the multi-seat confirmation when the source came from ekanos.json. */\n yes?: boolean;\n /** Whether stdin is a real terminal; injectable for tests. */\n stdinIsTTY?: boolean;\n /** The y/N prompt; injectable for tests. */\n confirm?: (question: string) => Promise<boolean>;\n}\n\n/**\n * What a packed experience may contain: its own source, build output and pins,\n * nothing else. The source ships because the host rebuilds `dist/` from it in\n * a clean room and refuses a package whose bundle is not what that source\n * produces; the lockfile ships so that rebuild resolves the same dependencies.\n */\nconst ALLOWED_PACK_PATHS = [\n /^package\\.json$/,\n /^npm-shrinkwrap\\.json$/,\n /^tsconfig[^/]*\\.json$/,\n /^src\\/.+/,\n /^ekanos\\.json$/,\n /^manifest\\.json$/,\n /^ekanos\\.lock\\.json$/,\n /^contracts\\/[^/]+\\.contract\\.json$/,\n /^contracts\\/\\.gitkeep$/,\n /^dist\\/[^/]+$/,\n /^README\\.md$/,\n /^LICENSE$/,\n];\n\nexport interface ExperienceGate {\n project: ExperienceProject;\n result: ExperienceCheckResult;\n /** The caller's environment (read for the clean-room switches). */\n env?: Record<string, string | undefined>;\n}\n\n/**\n * The refusals and the gate every experience publish passes, before anything\n * is built: active overrides, a tracked overrides file, `ignore` entries, then\n * the experience checks. Throws a CliError for the first three; the findings\n * come back for the caller to render (one envelope for one package, a table\n * for a repo).\n */\nexport async function gateExperience(\n args: ExperiencePublishArgs,\n): Promise<ExperienceGate> {\n const project = readExperienceProject(args.dir);\n\n const overrides = await activeOverridesFor(project.dir, args.env);\n if (overrides.length > 0) {\n throw validationError(\n `Cannot publish with ${overrides.length} local integration override${overrides.length === 1 ? '' : 's'} active: ${overrides\n .map((o) => `${o.integration} -> ${o.path}`)\n .join(', ')}.`,\n `Delete ${LOCAL_OVERRIDES_FILE} (and unset EKANOS_INTEGRATION_OVERRIDE_*) so every integration resolves to its published version, then re-run.`,\n );\n }\n\n if (isOverridesFileTracked(project)) {\n throw validationError(\n `${LOCAL_OVERRIDES_FILE} is tracked by git.`,\n `It is per-developer: \"git rm --cached ${LOCAL_OVERRIDES_FILE}\" and add it to .gitignore.`,\n );\n }\n\n const ignored = project.ekanos.ignore ?? [];\n if (ignored.length > 0) {\n throw validationError(\n `ekanos.json \"ignore\" excludes ${ignored.join(', ')} from the boundary scan, so it cannot be published.`,\n 'Remove the \"ignore\" entries (move the archive out of the project) and re-run.',\n );\n }\n\n const result = await runExperienceChecks(project, {\n typecheck: false,\n loadDefinition: true,\n inlineSdk: args.env.EKANOS_INLINE_SDK,\n pinsResolver: await harnessPinsResolver(project.dir, args.env),\n });\n\n return { project, result, env: args.env };\n}\n\n/**\n * npm never packs `package-lock.json`, but it does pack `npm-shrinkwrap.json`\n * (and `npm ci` honours it). The host rebuilds the shipped source against the\n * dependencies it was built with, so the lockfile the bundle was built from\n * travels under that name for the pack and is removed afterwards. A project\n * that keeps its own shrinkwrap is left as it is.\n */\nfunction stageShrinkwrap(\n dir: string,\n content: string | null,\n): { restore: () => void } {\n const shrinkwrap = path.join(dir, 'npm-shrinkwrap.json');\n\n if (content === null || fs.existsSync(shrinkwrap)) {\n return { restore: () => {} };\n }\n fs.writeFileSync(shrinkwrap, content);\n\n return { restore: () => fs.rmSync(shrinkwrap, { force: true }) };\n}\n\nexport interface PackedExperience {\n slug: string;\n version: string;\n digest: string;\n filename: string | undefined;\n files: string[];\n integrity: string | undefined;\n /** Where the tarball was kept, when `artifactDir` was given. */\n tarball: string | undefined;\n}\n\n/**\n * Build the experience and pack it with `npm pack`, checking the tarball holds\n * nothing but its own build output. `artifactDir` keeps the tarball (a repo\n * dry run puts it under `.ekanos/publish/`); otherwise it is discarded.\n */\nexport async function packExperience(\n gate: ExperienceGate,\n artifactDir?: string,\n): Promise<PackedExperience> {\n const { project, result } = gate;\n if (!hasBuildableLockfile(project.dir)) {\n throw preconditionError(\n 'There is no lockfile (package-lock.json, npm-shrinkwrap.json or pnpm-lock.yaml), so the host could not rebuild this experience from its source with the dependencies you built with.',\n 'Run \"npm install --package-lock-only\" (or install with pnpm in a workspace) and commit the lockfile, then re-run.',\n );\n }\n const output = await emitExperience(project, result);\n\n // The bundle that ships is the one built in a clean room from the lockfile\n // that ships, the way the host's gate rebuilds it, not the one built in the\n // working tree (a pnpm workspace's tree is not what a clean `npm ci` makes).\n const ownLock = path.join(project.dir, 'package-lock.json');\n let shippedLockfile: string | null = fs.existsSync(ownLock)\n ? fs.readFileSync(ownLock, 'utf8')\n : null;\n if (gate.env?.[CLEAN_ROOM_ENV] !== 'off') {\n const room = await buildInCleanRoom(project, gate.env);\n fs.writeFileSync(\n path.join(project.dir, 'dist', 'experience.js'),\n room.bundle,\n );\n const written = JSON.parse(\n fs.readFileSync(path.join(project.dir, 'dist', 'surfaces.json'), 'utf8'),\n ) as unknown;\n if (canonicalJson(written) !== canonicalJson(room.surfaces)) {\n throw validationError(\n 'The surfaces your working tree declares are not what the clean-room build declares (different dependency versions, or a stale build).',\n 'Reinstall dependencies from the lockfile, run \"ekanos build\", and re-run \"ekanos publish\".',\n );\n }\n shippedLockfile = room.lockfile;\n }\n\n const scratch = fs.mkdtempSync(path.join(os.tmpdir(), 'ekanos-exp-pack-'));\n let packed: Array<{\n filename: string;\n files: Array<{ path: string; size: number }>;\n integrity?: string;\n }>;\n let tarball: string | undefined;\n const shrinkwrap = stageShrinkwrap(project.dir, shippedLockfile);\n try {\n const stdout = execFileSync(\n 'npm',\n ['pack', '--json', '--ignore-scripts', '--pack-destination', scratch],\n { cwd: project.dir, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] },\n );\n packed = JSON.parse(stdout) as typeof packed;\n const first = packed[0];\n if (artifactDir && first) {\n fs.mkdirSync(artifactDir, { recursive: true });\n tarball = path.join(artifactDir, path.basename(first.filename));\n fs.copyFileSync(path.join(scratch, first.filename), tarball);\n }\n } catch (error) {\n throw preconditionError(\n `npm pack failed: ${error instanceof Error ? error.message : String(error)}`,\n 'Make sure npm is installed and package.json \"files\" lists src, dist, manifest.json, ekanos.json, ekanos.lock.json, contracts, tsconfig.json and npm-shrinkwrap.json.',\n );\n } finally {\n shrinkwrap.restore();\n fs.rmSync(scratch, { recursive: true, force: true });\n }\n\n const entry = packed[0];\n const files = (entry?.files ?? []).map((f) => f.path);\n const stray = files.filter(\n (f) => !ALLOWED_PACK_PATHS.some((re) => re.test(f)),\n );\n if (stray.length > 0) {\n throw validationError(\n `The package would ship files an experience must not contain: ${stray.slice(0, 5).join(', ')}.`,\n 'Restrict package.json \"files\" to src, dist, manifest.json, ekanos.json, ekanos.lock.json, contracts, tsconfig.json and npm-shrinkwrap.json.',\n );\n }\n for (const required of [\n 'manifest.json',\n 'dist/experience.js',\n 'dist/surfaces.json',\n 'ekanos.lock.json',\n 'npm-shrinkwrap.json',\n project.entry,\n ]) {\n if (!files.includes(required)) {\n throw validationError(\n `The package would be missing ${required}.`,\n 'Add it to package.json \"files\".',\n );\n }\n }\n\n return {\n slug: project.slug,\n version: output.manifest.version,\n digest: output.manifest.digest,\n filename: entry?.filename,\n files,\n integrity: entry?.integrity,\n tarball,\n };\n}\n\n/** What submitting a gated, packed experience came to. */\nexport type ExperienceSubmission =\n | { status: 'unsupported'; host: string }\n | { status: 'submitted'; data: Record<string, unknown>; human: string };\n\n/**\n * Submit a gated experience to a host that admits them.\n *\n * The host is asked first (the toolchain route's `capabilities`), because an\n * older deployment answers a `kind=experience` submission as if it were an\n * integration and would file it under the wrong gate: a host that does not\n * advertise `experienceSubmissions` gets nothing sent and the caller keeps the\n * dry-run-only message. Authorization is the same as an integration's (the\n * developer seat on the source, checked server-side; the session refreshed\n * once on a 401). The submission is the packed tarball plus the built\n * `manifest.json`, which the host re-validates and cross-checks against the\n * archive in its own gate.\n */\nexport async function submitExperience(\n ctx: CliContext,\n args: ExperiencePublishArgs,\n gate: ExperienceGate,\n): Promise<ExperienceSubmission> {\n const { project } = gate;\n const env = resolveAuthEnvironment(ctx, args.host, args.env, {\n projectDir: project.dir,\n });\n const session: StoredSession = requireSession(env);\n\n const resolution = await resolveSourceSlug(env, session, args.source, {\n project: { source: project.ekanos.source },\n });\n\n const version = readVersion(gate);\n const verified = await verifyPublishTarget(ctx, env, resolution.session, {\n source: resolution.source,\n explicit: resolution.explicit,\n slug: project.slug,\n version,\n yes: args.yes === true,\n stdinIsTTY: args.stdinIsTTY ?? process.stdin.isTTY === true,\n confirm: args.confirm ?? promptYesNo,\n });\n\n const toolchain = await fetchToolchainReport(\n env.host,\n verified.session.accessToken,\n );\n if (\n toolchain.status !== 'ok' ||\n toolchain.report.capabilities?.experienceSubmissions !== true\n ) {\n return { status: 'unsupported', host: env.host };\n }\n\n ctx.log(`Packing ${project.slug}@${version}…`);\n\n const artifactDir = fs.mkdtempSync(\n path.join(os.tmpdir(), 'ekanos-exp-submit-'),\n );\n let archive: Uint8Array;\n let digest: string;\n let files: string[];\n try {\n const packed = await packExperience(gate, artifactDir);\n if (!packed.tarball) {\n throw preconditionError(\n 'The packed experience was not kept.',\n 'This is a bug in @ekanos/cli; report it.',\n );\n }\n archive = new Uint8Array(fs.readFileSync(packed.tarball));\n digest = packed.digest;\n files = packed.files;\n } finally {\n fs.rmSync(artifactDir, { recursive: true, force: true });\n }\n\n if (archive.length > MAX_ARCHIVE_BYTES) {\n throw validationError(\n `The packed experience is ${archive.length} bytes, over the ${MAX_ARCHIVE_BYTES}-byte submission limit.`,\n 'Drop dependencies the bundle does not need, or split the experience.',\n );\n }\n\n const manifest = fs.readFileSync(\n path.join(project.dir, 'manifest.json'),\n 'utf8',\n );\n if (Buffer.byteLength(manifest, 'utf8') > MAX_MANIFEST_BYTES) {\n throw validationError(\n `manifest.json is larger than the ${MAX_MANIFEST_BYTES}-byte manifest limit.`,\n 'Trim the workflow templates or widget declarations it carries.',\n );\n }\n\n if (!ctx.jsonMode) {\n ctx.log(\n ctx.ui.ok(\n `${ctx.ui.glyphs.ok} packed ${project.slug}@${version} (${files.length} files).`,\n ),\n );\n }\n\n const source = verified.sourceSeat.slug;\n ctx.log(`Submitting to ${env.host} (source \"${source}\")…`);\n\n const receipt = await submitWithOneRefresh(env, verified.session, {\n source,\n slug: project.slug,\n kind: 'experience',\n version,\n manifest,\n archive,\n });\n\n if (!ctx.jsonMode) {\n ctx.log(\n ctx.ui.ok(\n `${ctx.ui.glyphs.ok} submitted ${receipt.slug}@${receipt.version} (state \"${receipt.state}\").`,\n ),\n );\n }\n\n return {\n status: 'submitted',\n data: {\n host: env.host,\n source: {\n id: verified.sourceSeat.id,\n slug: verified.sourceSeat.slug,\n name: verified.sourceSeat.name,\n },\n kind: 'experience',\n slug: receipt.slug,\n version: receipt.version,\n submissionId: receipt.submissionId,\n state: receipt.state,\n archiveSha256: receipt.archiveSha256,\n digest,\n files,\n published: true,\n },\n human: ctx.ui.result({\n title: 'Submitted',\n rows: [\n ['Experience', `${receipt.slug}@${receipt.version}`],\n ['State', receipt.state],\n ['Source', source],\n ['Host', shortHost(env.host)],\n ],\n notes: [],\n }),\n };\n}\n\nfunction readVersion(gate: ExperienceGate): string {\n try {\n const pkg = JSON.parse(\n fs.readFileSync(path.join(gate.project.dir, 'package.json'), 'utf8'),\n ) as { version?: unknown };\n if (typeof pkg.version === 'string' && pkg.version.length > 0) {\n return pkg.version;\n }\n } catch {\n // Reported below with the fix.\n }\n\n throw preconditionError(\n 'package.json is missing or has no \"version\".',\n 'An experience is an npm package; set a semver \"version\" in package.json.',\n );\n}\n\n/**\n * `ekanos publish` for an experience.\n *\n * 1. Active integration overrides refuse it (exit 3, naming each integration and path): what\n * you ran is not what a host would resolve. An integration of the same repo is not an override.\n * 2. A tracked ekanos.local.json, any `ignore` entry, or a failing gate refuse.\n * 3. With --dry-run it builds and packs, and checks the tarball holds no\n * integration code. Nothing is sent.\n * 4. Without --dry-run it builds, packs and submits to a host that advertises\n * experience submissions. A host that does not (an older deployment) gets\n * nothing and the run ends with the dry-run-only message, as before.\n *\n * The refusals and the dry run run before any login: a dry run needs no session.\n */\nexport async function runExperiencePublish(\n ctx: CliContext,\n args: ExperiencePublishArgs,\n): Promise<ExitCode> {\n const gate = await gateExperience(args);\n const { project, result } = gate;\n const failed = failOnErrors(\n ctx,\n 'publish',\n result.findings,\n { slug: project.slug },\n project.dir,\n );\n if (failed !== null) return failed;\n\n if (!args.dryRun) {\n const submission = await submitExperience(ctx, args, gate);\n\n if (submission.status === 'unsupported') {\n throw gateFailedError(\n EXPERIENCE_NOT_SUPPORTED,\n `Run \"ekanos publish --dry-run\" to build and pack it; ${submission.host} has no admission path for experiences until it ships one.`,\n );\n }\n\n return ctx.succeed(submission.data, submission.human);\n }\n\n const packed = await packExperience(gate);\n\n return ctx.succeed(\n {\n slug: packed.slug,\n version: packed.version,\n digest: packed.digest,\n dryRun: true,\n package: {\n filename: packed.filename,\n files: packed.files,\n integrity: packed.integrity,\n },\n published: false,\n },\n `Dry run: packed ${packed.slug}@${packed.version} (${packed.files.length} files, ${packed.digest.slice(0, 18)}…). Nothing was published.`,\n );\n}\n\nexport const EXPERIENCE_NOT_SUPPORTED =\n 'Publishing an experience is not supported by the host yet.';\n"]}
|
|
1
|
+
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../../src/experience/publish.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,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,EACf,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,EACtB,OAAO,CAAC,GAAG,CACZ,CAAC;IACF,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC;IAEnC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACjB,MAAM,UAAU,GAAG,MAAM,gBAAgB,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAE3D,IAAI,UAAU,CAAC,MAAM,KAAK,aAAa,EAAE,CAAC;YACxC,MAAM,eAAe,CACnB,wBAAwB,EACxB,wDAAwD,UAAU,CAAC,IAAI,4DAA4D,CACpI,CAAC;QACJ,CAAC;QAED,OAAO,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;IACxD,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,CAAC;IAE1C,OAAO,GAAG,CAAC,OAAO,CAChB;QACE,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE;YACP,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,SAAS,EAAE,MAAM,CAAC,SAAS;SAC5B;QACD,SAAS,EAAE,KAAK;KACjB,EACD,mBAAmB,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,OAAO,KAAK,MAAM,CAAC,KAAK,CAAC,MAAM,WAAW,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,4BAA4B,CAC1I,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,wBAAwB,GACnC,4DAA4D,CAAC","sourcesContent":["import { canonicalJson } from '@ekanos/integration-schema';\nimport { execFileSync } from 'node:child_process';\nimport * as fs from 'node:fs';\nimport * as os from 'node:os';\nimport * as path from 'node:path';\n\nimport type { StoredSession } from '../auth/credential-store';\nimport { requireSession, resolveAuthEnvironment } from '../auth/session';\nimport {\n promptYesNo,\n resolveSourceSlug,\n submitWithOneRefresh,\n verifyPublishTarget,\n} from '../commands/publish';\nimport type { CliContext } from '../context';\nimport { activeOverridesFor, harnessPinsResolver } from '../dev-experience';\nimport { gateFailedError, preconditionError, validationError } from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { MAX_ARCHIVE_BYTES } from '../pack';\nimport { MAX_MANIFEST_BYTES } from '../publish-api';\nimport { fetchToolchainReport } from '../toolchain-api';\nimport { shortHost } from '../ui';\nimport { emitExperience } from './build';\nimport { type ExperienceCheckResult, runExperienceChecks } from './checks';\nimport {\n CLEAN_ROOM_ENV,\n buildInCleanRoom,\n hasBuildableLockfile,\n} from './clean-room';\nimport { isOverridesFileTracked } from './overrides';\nimport {\n type ExperienceProject,\n LOCAL_OVERRIDES_FILE,\n readExperienceProject,\n} from './project';\nimport { failOnErrors } from './report';\n\nexport interface ExperiencePublishArgs {\n dir: string;\n dryRun: boolean;\n env: Record<string, string | undefined>;\n /** The host to submit to (a real run only). Falls back to ekanos.json, then the stored login. */\n host?: string;\n /** The source slug to submit for (a real run only). Falls back to ekanos.json \"source\". */\n source?: string;\n /** Skips the multi-seat confirmation when the source came from ekanos.json. */\n yes?: boolean;\n /** Whether stdin is a real terminal; injectable for tests. */\n stdinIsTTY?: boolean;\n /** The y/N prompt; injectable for tests. */\n confirm?: (question: string) => Promise<boolean>;\n}\n\n/**\n * What a packed experience may contain: its own source, build output and pins,\n * nothing else. The source ships because the host rebuilds `dist/` from it in\n * a clean room and refuses a package whose bundle is not what that source\n * produces; the lockfile ships so that rebuild resolves the same dependencies.\n */\nconst ALLOWED_PACK_PATHS = [\n /^package\\.json$/,\n /^npm-shrinkwrap\\.json$/,\n /^tsconfig[^/]*\\.json$/,\n /^src\\/.+/,\n /^ekanos\\.json$/,\n /^manifest\\.json$/,\n /^ekanos\\.lock\\.json$/,\n /^contracts\\/[^/]+\\.contract\\.json$/,\n /^contracts\\/\\.gitkeep$/,\n /^dist\\/[^/]+$/,\n /^README\\.md$/,\n /^LICENSE$/,\n];\n\nexport interface ExperienceGate {\n project: ExperienceProject;\n result: ExperienceCheckResult;\n /** The caller's environment (read for the clean-room switches). */\n env?: Record<string, string | undefined>;\n}\n\n/**\n * The refusals and the gate every experience publish passes, before anything\n * is built: active overrides, a tracked overrides file, `ignore` entries, then\n * the experience checks. Throws a CliError for the first three; the findings\n * come back for the caller to render (one envelope for one package, a table\n * for a repo).\n */\nexport async function gateExperience(\n args: ExperiencePublishArgs,\n): Promise<ExperienceGate> {\n const project = readExperienceProject(args.dir);\n\n const overrides = await activeOverridesFor(project.dir, args.env);\n if (overrides.length > 0) {\n throw validationError(\n `Cannot publish with ${overrides.length} local integration override${overrides.length === 1 ? '' : 's'} active: ${overrides\n .map((o) => `${o.integration} -> ${o.path}`)\n .join(', ')}.`,\n `Delete ${LOCAL_OVERRIDES_FILE} (and unset EKANOS_INTEGRATION_OVERRIDE_*) so every integration resolves to its published version, then re-run.`,\n );\n }\n\n if (isOverridesFileTracked(project)) {\n throw validationError(\n `${LOCAL_OVERRIDES_FILE} is tracked by git.`,\n `It is per-developer: \"git rm --cached ${LOCAL_OVERRIDES_FILE}\" and add it to .gitignore.`,\n );\n }\n\n const ignored = project.ekanos.ignore ?? [];\n if (ignored.length > 0) {\n throw validationError(\n `ekanos.json \"ignore\" excludes ${ignored.join(', ')} from the boundary scan, so it cannot be published.`,\n 'Remove the \"ignore\" entries (move the archive out of the project) and re-run.',\n );\n }\n\n const result = await runExperienceChecks(project, {\n typecheck: false,\n loadDefinition: true,\n inlineSdk: args.env.EKANOS_INLINE_SDK,\n pinsResolver: await harnessPinsResolver(project.dir, args.env),\n });\n\n return { project, result, env: args.env };\n}\n\n/**\n * npm never packs `package-lock.json`, but it does pack `npm-shrinkwrap.json`\n * (and `npm ci` honours it). The host rebuilds the shipped source against the\n * dependencies it was built with, so the lockfile the bundle was built from\n * travels under that name for the pack and is removed afterwards. A project\n * that keeps its own shrinkwrap is left as it is.\n */\nfunction stageShrinkwrap(\n dir: string,\n content: string | null,\n): { restore: () => void } {\n const shrinkwrap = path.join(dir, 'npm-shrinkwrap.json');\n\n if (content === null || fs.existsSync(shrinkwrap)) {\n return { restore: () => {} };\n }\n fs.writeFileSync(shrinkwrap, content);\n\n return { restore: () => fs.rmSync(shrinkwrap, { force: true }) };\n}\n\nexport interface PackedExperience {\n slug: string;\n version: string;\n digest: string;\n filename: string | undefined;\n files: string[];\n integrity: string | undefined;\n /** Where the tarball was kept, when `artifactDir` was given. */\n tarball: string | undefined;\n}\n\n/**\n * Build the experience and pack it with `npm pack`, checking the tarball holds\n * nothing but its own build output. `artifactDir` keeps the tarball (a repo\n * dry run puts it under `.ekanos/publish/`); otherwise it is discarded.\n */\nexport async function packExperience(\n gate: ExperienceGate,\n artifactDir?: string,\n): Promise<PackedExperience> {\n const { project, result } = gate;\n if (!hasBuildableLockfile(project.dir)) {\n throw preconditionError(\n 'There is no lockfile (package-lock.json, npm-shrinkwrap.json or pnpm-lock.yaml), so the host could not rebuild this experience from its source with the dependencies you built with.',\n 'Run \"npm install --package-lock-only\" (or install with pnpm in a workspace) and commit the lockfile, then re-run.',\n );\n }\n const output = await emitExperience(project, result);\n\n // The bundle that ships is the one built in a clean room from the lockfile\n // that ships, the way the host's gate rebuilds it, not the one built in the\n // working tree (a pnpm workspace's tree is not what a clean `npm ci` makes).\n const ownLock = path.join(project.dir, 'package-lock.json');\n let shippedLockfile: string | null = fs.existsSync(ownLock)\n ? fs.readFileSync(ownLock, 'utf8')\n : null;\n if (gate.env?.[CLEAN_ROOM_ENV] !== 'off') {\n const room = await buildInCleanRoom(project, gate.env);\n fs.writeFileSync(\n path.join(project.dir, 'dist', 'experience.js'),\n room.bundle,\n );\n const written = JSON.parse(\n fs.readFileSync(path.join(project.dir, 'dist', 'surfaces.json'), 'utf8'),\n ) as unknown;\n if (canonicalJson(written) !== canonicalJson(room.surfaces)) {\n throw validationError(\n 'The surfaces your working tree declares are not what the clean-room build declares (different dependency versions, or a stale build).',\n 'Reinstall dependencies from the lockfile, run \"ekanos build\", and re-run \"ekanos publish\".',\n );\n }\n shippedLockfile = room.lockfile;\n }\n\n const scratch = fs.mkdtempSync(path.join(os.tmpdir(), 'ekanos-exp-pack-'));\n let packed: Array<{\n filename: string;\n files: Array<{ path: string; size: number }>;\n integrity?: string;\n }>;\n let tarball: string | undefined;\n const shrinkwrap = stageShrinkwrap(project.dir, shippedLockfile);\n try {\n const stdout = execFileSync(\n 'npm',\n ['pack', '--json', '--ignore-scripts', '--pack-destination', scratch],\n { cwd: project.dir, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] },\n );\n packed = JSON.parse(stdout) as typeof packed;\n const first = packed[0];\n if (artifactDir && first) {\n fs.mkdirSync(artifactDir, { recursive: true });\n tarball = path.join(artifactDir, path.basename(first.filename));\n fs.copyFileSync(path.join(scratch, first.filename), tarball);\n }\n } catch (error) {\n throw preconditionError(\n `npm pack failed: ${error instanceof Error ? error.message : String(error)}`,\n 'Make sure npm is installed and package.json \"files\" lists src, dist, manifest.json, ekanos.json, ekanos.lock.json, contracts, tsconfig.json and npm-shrinkwrap.json.',\n );\n } finally {\n shrinkwrap.restore();\n fs.rmSync(scratch, { recursive: true, force: true });\n }\n\n const entry = packed[0];\n const files = (entry?.files ?? []).map((f) => f.path);\n const stray = files.filter(\n (f) => !ALLOWED_PACK_PATHS.some((re) => re.test(f)),\n );\n if (stray.length > 0) {\n throw validationError(\n `The package would ship files an experience must not contain: ${stray.slice(0, 5).join(', ')}.`,\n 'Restrict package.json \"files\" to src, dist, manifest.json, ekanos.json, ekanos.lock.json, contracts, tsconfig.json and npm-shrinkwrap.json.',\n );\n }\n for (const required of [\n 'manifest.json',\n 'dist/experience.js',\n 'dist/surfaces.json',\n 'ekanos.lock.json',\n 'npm-shrinkwrap.json',\n project.entry,\n ]) {\n if (!files.includes(required)) {\n throw validationError(\n `The package would be missing ${required}.`,\n 'Add it to package.json \"files\".',\n );\n }\n }\n\n return {\n slug: project.slug,\n version: output.manifest.version,\n digest: output.manifest.digest,\n filename: entry?.filename,\n files,\n integrity: entry?.integrity,\n tarball,\n };\n}\n\n/** What submitting a gated, packed experience came to. */\nexport type ExperienceSubmission =\n | { status: 'unsupported'; host: string }\n | { status: 'submitted'; data: Record<string, unknown>; human: string };\n\n/**\n * Submit a gated experience to a host that admits them.\n *\n * The host is asked first (the toolchain route's `capabilities`), because an\n * older deployment answers a `kind=experience` submission as if it were an\n * integration and would file it under the wrong gate: a host that does not\n * advertise `experienceSubmissions` gets nothing sent and the caller keeps the\n * dry-run-only message. Authorization is the same as an integration's (the\n * developer seat on the source, checked server-side; the session refreshed\n * once on a 401). The submission is the packed tarball plus the built\n * `manifest.json`, which the host re-validates and cross-checks against the\n * archive in its own gate.\n */\nexport async function submitExperience(\n ctx: CliContext,\n args: ExperiencePublishArgs,\n gate: ExperienceGate,\n): Promise<ExperienceSubmission> {\n const { project } = gate;\n const env = resolveAuthEnvironment(ctx, args.host, args.env, {\n projectDir: project.dir,\n });\n const session: StoredSession = requireSession(env);\n\n const resolution = await resolveSourceSlug(env, session, args.source, {\n project: { source: project.ekanos.source },\n });\n\n const version = readVersion(gate);\n const verified = await verifyPublishTarget(ctx, env, resolution.session, {\n source: resolution.source,\n explicit: resolution.explicit,\n slug: project.slug,\n version,\n yes: args.yes === true,\n stdinIsTTY: args.stdinIsTTY ?? process.stdin.isTTY === true,\n confirm: args.confirm ?? promptYesNo,\n });\n\n const toolchain = await fetchToolchainReport(\n env.host,\n verified.session.accessToken,\n );\n if (\n toolchain.status !== 'ok' ||\n toolchain.report.capabilities?.experienceSubmissions !== true\n ) {\n return { status: 'unsupported', host: env.host };\n }\n\n ctx.log(`Packing ${project.slug}@${version}…`);\n\n const artifactDir = fs.mkdtempSync(\n path.join(os.tmpdir(), 'ekanos-exp-submit-'),\n );\n let archive: Uint8Array;\n let digest: string;\n let files: string[];\n try {\n const packed = await packExperience(gate, artifactDir);\n if (!packed.tarball) {\n throw preconditionError(\n 'The packed experience was not kept.',\n 'This is a bug in @ekanos/cli; report it.',\n );\n }\n archive = new Uint8Array(fs.readFileSync(packed.tarball));\n digest = packed.digest;\n files = packed.files;\n } finally {\n fs.rmSync(artifactDir, { recursive: true, force: true });\n }\n\n if (archive.length > MAX_ARCHIVE_BYTES) {\n throw validationError(\n `The packed experience is ${archive.length} bytes, over the ${MAX_ARCHIVE_BYTES}-byte submission limit.`,\n 'Drop dependencies the bundle does not need, or split the experience.',\n );\n }\n\n const manifest = fs.readFileSync(\n path.join(project.dir, 'manifest.json'),\n 'utf8',\n );\n if (Buffer.byteLength(manifest, 'utf8') > MAX_MANIFEST_BYTES) {\n throw validationError(\n `manifest.json is larger than the ${MAX_MANIFEST_BYTES}-byte manifest limit.`,\n 'Trim the workflow templates or widget declarations it carries.',\n );\n }\n\n if (!ctx.jsonMode) {\n ctx.log(\n ctx.ui.ok(\n `${ctx.ui.glyphs.ok} packed ${project.slug}@${version} (${files.length} files).`,\n ),\n );\n }\n\n const source = verified.sourceSeat.slug;\n const availability = project.ekanos.availability?.mode;\n ctx.log(`Submitting to ${env.host} (source \"${source}\")…`);\n\n const receipt = await submitWithOneRefresh(env, verified.session, {\n source,\n slug: project.slug,\n kind: 'experience',\n version,\n manifest,\n archive,\n ...(availability ? { availability } : {}),\n });\n\n if (!ctx.jsonMode) {\n ctx.log(\n ctx.ui.ok(\n `${ctx.ui.glyphs.ok} submitted ${receipt.slug}@${receipt.version} (state \"${receipt.state}\").`,\n ),\n );\n }\n\n return {\n status: 'submitted',\n data: {\n host: env.host,\n source: {\n id: verified.sourceSeat.id,\n slug: verified.sourceSeat.slug,\n name: verified.sourceSeat.name,\n },\n kind: 'experience',\n slug: receipt.slug,\n version: receipt.version,\n submissionId: receipt.submissionId,\n state: receipt.state,\n archiveSha256: receipt.archiveSha256,\n digest,\n files,\n published: true,\n },\n human: ctx.ui.result({\n title: 'Submitted',\n rows: [\n ['Experience', `${receipt.slug}@${receipt.version}`],\n ['State', receipt.state],\n ['Source', source],\n ['Host', shortHost(env.host)],\n ],\n notes: [],\n }),\n };\n}\n\nfunction readVersion(gate: ExperienceGate): string {\n try {\n const pkg = JSON.parse(\n fs.readFileSync(path.join(gate.project.dir, 'package.json'), 'utf8'),\n ) as { version?: unknown };\n if (typeof pkg.version === 'string' && pkg.version.length > 0) {\n return pkg.version;\n }\n } catch {\n // Reported below with the fix.\n }\n\n throw preconditionError(\n 'package.json is missing or has no \"version\".',\n 'An experience is an npm package; set a semver \"version\" in package.json.',\n );\n}\n\n/**\n * `ekanos publish` for an experience.\n *\n * 1. Active integration overrides refuse it (exit 3, naming each integration and path): what\n * you ran is not what a host would resolve. An integration of the same repo is not an override.\n * 2. A tracked ekanos.local.json, any `ignore` entry, or a failing gate refuse.\n * 3. With --dry-run it builds and packs, and checks the tarball holds no\n * integration code. Nothing is sent.\n * 4. Without --dry-run it builds, packs and submits to a host that advertises\n * experience submissions. A host that does not (an older deployment) gets\n * nothing and the run ends with the dry-run-only message, as before.\n *\n * The refusals and the dry run run before any login: a dry run needs no session.\n */\nexport async function runExperiencePublish(\n ctx: CliContext,\n args: ExperiencePublishArgs,\n): Promise<ExitCode> {\n const gate = await gateExperience(args);\n const { project, result } = gate;\n const failed = failOnErrors(\n ctx,\n 'publish',\n result.findings,\n { slug: project.slug },\n project.dir,\n );\n if (failed !== null) return failed;\n\n if (!args.dryRun) {\n const submission = await submitExperience(ctx, args, gate);\n\n if (submission.status === 'unsupported') {\n throw gateFailedError(\n EXPERIENCE_NOT_SUPPORTED,\n `Run \"ekanos publish --dry-run\" to build and pack it; ${submission.host} has no admission path for experiences until it ships one.`,\n );\n }\n\n return ctx.succeed(submission.data, submission.human);\n }\n\n const packed = await packExperience(gate);\n\n return ctx.succeed(\n {\n slug: packed.slug,\n version: packed.version,\n digest: packed.digest,\n dryRun: true,\n package: {\n filename: packed.filename,\n files: packed.files,\n integrity: packed.integrity,\n },\n published: false,\n },\n `Dry run: packed ${packed.slug}@${packed.version} (${packed.files.length} files, ${packed.digest.slice(0, 18)}…). Nothing was published.`,\n );\n}\n\nexport const EXPERIENCE_NOT_SUPPORTED =\n 'Publishing an experience is not supported by the host yet.';\n"]}
|
package/dist/host-snapshots.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { refreshStoredSession } from './auth/session.js';
|
|
|
3
3
|
import { fetchPublicCatalog, fetchSourceCatalog } from './catalog-api.js';
|
|
4
4
|
import type { CliContext } from './context.js';
|
|
5
5
|
import { listSubmissions } from './publish-api.js';
|
|
6
|
+
import { fetchSeatsWithOneRefresh } from './seats.js';
|
|
6
7
|
import { resolveSourceTarget } from './source-target.js';
|
|
7
8
|
/**
|
|
8
9
|
* What `ekanos dev` hands the harness about the host, beside the session
|
|
@@ -15,6 +16,12 @@ import { resolveSourceTarget } from './source-target.js';
|
|
|
15
16
|
export declare const CATALOG_SNAPSHOT_FILE: string;
|
|
16
17
|
export declare const PUBLISH_STATUS_FILE: string;
|
|
17
18
|
export declare const REFRESH_REQUEST_FILE = "refresh-request";
|
|
19
|
+
/**
|
|
20
|
+
* The Source the harness's switcher picked (`{ "source": "<slug>" }`). It
|
|
21
|
+
* decides which Source the harness reads, ahead of ekanos.json, while it is
|
|
22
|
+
* still one of the developer's seats; it never changes where `publish` goes.
|
|
23
|
+
*/
|
|
24
|
+
export declare const SOURCE_SELECTION_FILE: string;
|
|
18
25
|
export declare const IN_FLIGHT_INTERVAL_MS = 30000;
|
|
19
26
|
export declare const IDLE_INTERVAL_MS = 300000;
|
|
20
27
|
export interface HostSnapshots {
|
|
@@ -26,6 +33,7 @@ export interface HostSnapshotDeps {
|
|
|
26
33
|
fetchSourceCatalog: typeof fetchSourceCatalog;
|
|
27
34
|
fetchPublicCatalog: typeof fetchPublicCatalog;
|
|
28
35
|
listSubmissions: typeof listSubmissions;
|
|
36
|
+
fetchSeats: typeof fetchSeatsWithOneRefresh;
|
|
29
37
|
resolveSourceTarget: typeof resolveSourceTarget;
|
|
30
38
|
refreshStoredSession: typeof refreshStoredSession;
|
|
31
39
|
now: () => Date;
|
|
@@ -42,6 +50,8 @@ export declare function readHostSnapshots(params: {
|
|
|
42
50
|
fallbackSource?: string | null;
|
|
43
51
|
deps?: Partial<HostSnapshotDeps>;
|
|
44
52
|
}): Promise<HostSnapshots>;
|
|
53
|
+
/** The Source the harness's switcher picked, or null. Never throws. */
|
|
54
|
+
export declare function readSourceSelection(projectDir: string): string | null;
|
|
45
55
|
/**
|
|
46
56
|
* The one Source every package of a repo names in its `ekanos.json`, or null
|
|
47
57
|
* when they name none or disagree (then the account's seats decide, as for
|
package/dist/host-snapshots.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CatalogSnapshotSchema, PublishStatusSnapshotSchema, } from '@ekanos/integration-schema';
|
|
1
|
+
import { CatalogSnapshotSchema, PublishStatusSnapshotSchema, SourceSelectionSchema, } from '@ekanos/integration-schema';
|
|
2
2
|
import * as fs from 'node:fs';
|
|
3
3
|
import * as path from 'node:path';
|
|
4
4
|
import { refreshStoredSession, resolveAuthEnvironment, } from './auth/session.js';
|
|
@@ -6,6 +6,7 @@ import { fetchPublicCatalog, fetchSourceCatalog } from './catalog-api.js';
|
|
|
6
6
|
import { readActiveSource } from './commands/sources.js';
|
|
7
7
|
import { CliError } from './errors.js';
|
|
8
8
|
import { listSubmissions } from './publish-api.js';
|
|
9
|
+
import { fetchSeatsWithOneRefresh } from './seats.js';
|
|
9
10
|
import { resolveSourceTarget } from './source-target.js';
|
|
10
11
|
/**
|
|
11
12
|
* What `ekanos dev` hands the harness about the host, beside the session
|
|
@@ -18,6 +19,12 @@ import { resolveSourceTarget } from './source-target.js';
|
|
|
18
19
|
export const CATALOG_SNAPSHOT_FILE = path.join('.ekanos', 'catalog.json');
|
|
19
20
|
export const PUBLISH_STATUS_FILE = path.join('.ekanos', 'publish-status.json');
|
|
20
21
|
export const REFRESH_REQUEST_FILE = 'refresh-request';
|
|
22
|
+
/**
|
|
23
|
+
* The Source the harness's switcher picked (`{ "source": "<slug>" }`). It
|
|
24
|
+
* decides which Source the harness reads, ahead of ekanos.json, while it is
|
|
25
|
+
* still one of the developer's seats; it never changes where `publish` goes.
|
|
26
|
+
*/
|
|
27
|
+
export const SOURCE_SELECTION_FILE = path.join('.ekanos', 'source-selection.json');
|
|
21
28
|
/** Poll fast while a version is still moving through the pipeline. */
|
|
22
29
|
const IN_FLIGHT_STATES = new Set(['submitted', 'gated']);
|
|
23
30
|
export const IN_FLIGHT_INTERVAL_MS = 30000;
|
|
@@ -26,6 +33,7 @@ const DEFAULT_DEPS = {
|
|
|
26
33
|
fetchSourceCatalog,
|
|
27
34
|
fetchPublicCatalog,
|
|
28
35
|
listSubmissions,
|
|
36
|
+
fetchSeats: fetchSeatsWithOneRefresh,
|
|
29
37
|
resolveSourceTarget,
|
|
30
38
|
refreshStoredSession,
|
|
31
39
|
now: () => new Date(),
|
|
@@ -46,15 +54,11 @@ function messageWithHint(error) {
|
|
|
46
54
|
export async function readHostSnapshots(params) {
|
|
47
55
|
const deps = Object.assign(Object.assign({}, DEFAULT_DEPS), params.deps);
|
|
48
56
|
const fetchedAt = deps.now().toISOString();
|
|
57
|
+
/** The developer's seats, once read: the harness's switcher offers them. */
|
|
58
|
+
let seats;
|
|
49
59
|
const empty = (host, unavailable) => ({
|
|
50
|
-
catalog: {
|
|
51
|
-
|
|
52
|
-
host,
|
|
53
|
-
scope: null,
|
|
54
|
-
source: null,
|
|
55
|
-
unavailable,
|
|
56
|
-
products: [],
|
|
57
|
-
},
|
|
60
|
+
catalog: Object.assign({ fetchedAt,
|
|
61
|
+
host, scope: null, source: null, unavailable, products: [] }, (seats ? { seats } : {})),
|
|
58
62
|
publish: {
|
|
59
63
|
fetchedAt,
|
|
60
64
|
host,
|
|
@@ -100,11 +104,30 @@ export async function readHostSnapshots(params) {
|
|
|
100
104
|
message: `Not logged in to ${host}. Run "ekanos login" to see your Source's catalog and your publishes.`,
|
|
101
105
|
});
|
|
102
106
|
}
|
|
107
|
+
// The seats, for the switcher and to hold the harness's pick to one. A
|
|
108
|
+
// failed read only leaves the switcher out; the catalog route still checks.
|
|
109
|
+
try {
|
|
110
|
+
const listed = await deps.fetchSeats(auth, session);
|
|
111
|
+
if (listed.status === 'ok') {
|
|
112
|
+
session = listed.session;
|
|
113
|
+
seats = listed.sources.map((seat) => ({
|
|
114
|
+
slug: seat.slug,
|
|
115
|
+
name: seat.name,
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
catch (_b) {
|
|
120
|
+
seats = undefined;
|
|
121
|
+
}
|
|
122
|
+
const selected = readSourceSelection(params.projectDir);
|
|
123
|
+
const picked = selected && (seats === null || seats === void 0 ? void 0 : seats.some((seat) => seat.slug === selected)) ? selected : null;
|
|
103
124
|
let source;
|
|
104
125
|
try {
|
|
105
|
-
const target = await deps.resolveSourceTarget(auth, session, Object.assign({ dir: params.projectDir }, (
|
|
106
|
-
? { source:
|
|
107
|
-
:
|
|
126
|
+
const target = await deps.resolveSourceTarget(auth, session, Object.assign({ dir: params.projectDir }, (picked
|
|
127
|
+
? { source: picked }
|
|
128
|
+
: params.fallbackSource && !readActiveSource(params.projectDir)
|
|
129
|
+
? { source: params.fallbackSource }
|
|
130
|
+
: {})));
|
|
108
131
|
source = target.source;
|
|
109
132
|
session = target.session;
|
|
110
133
|
}
|
|
@@ -128,17 +151,11 @@ export async function readHostSnapshots(params) {
|
|
|
128
151
|
try {
|
|
129
152
|
const catalog = await withSession((token) => deps.fetchSourceCatalog(host, token, { source }));
|
|
130
153
|
if (catalog.status === 'ok') {
|
|
131
|
-
result.catalog = {
|
|
132
|
-
|
|
133
|
-
host,
|
|
134
|
-
scope: 'source',
|
|
135
|
-
source: {
|
|
154
|
+
result.catalog = Object.assign({ fetchedAt,
|
|
155
|
+
host, scope: 'source', source: {
|
|
136
156
|
slug: catalog.catalog.source.slug,
|
|
137
157
|
name: catalog.catalog.source.name,
|
|
138
|
-
},
|
|
139
|
-
unavailable: null,
|
|
140
|
-
products: catalog.catalog.products,
|
|
141
|
-
};
|
|
158
|
+
}, unavailable: null, products: catalog.catalog.products }, (seats ? { seats } : {}));
|
|
142
159
|
}
|
|
143
160
|
else {
|
|
144
161
|
result.catalog.unavailable = {
|
|
@@ -173,6 +190,16 @@ export async function readHostSnapshots(params) {
|
|
|
173
190
|
}
|
|
174
191
|
return result;
|
|
175
192
|
}
|
|
193
|
+
/** The Source the harness's switcher picked, or null. Never throws. */
|
|
194
|
+
export function readSourceSelection(projectDir) {
|
|
195
|
+
try {
|
|
196
|
+
const parsed = SourceSelectionSchema.safeParse(JSON.parse(fs.readFileSync(path.join(projectDir, SOURCE_SELECTION_FILE), 'utf8')));
|
|
197
|
+
return parsed.success ? parsed.data.source : null;
|
|
198
|
+
}
|
|
199
|
+
catch (_a) {
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
176
203
|
/**
|
|
177
204
|
* The one Source every package of a repo names in its `ekanos.json`, or null
|
|
178
205
|
* when they name none or disagree (then the account's seats decide, as for
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-snapshots.js","sourceRoot":"","sources":["../src/host-snapshots.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,qBAAqB,EACrB,2BAA2B,GAG5B,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC,OAAO,EAEL,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC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AC;YACT,OAAO,GAAG,KAAK,CAAC;QAClB,CAAC;QACD,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,GAAG,KAAK,CAAC;YACf,KAAK,OAAO,EAAE,CAAC;YACf,OAAO;QACT,CAAC;QACD,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClB,CAAC,CAAC;IAEF,IAAI,OAAO,GAAwB,IAAI,CAAC;IACxC,IAAI,CAAC;QACH,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE;YAC3C,IAAI,QAAQ,KAAK,oBAAoB;gBAAE,KAAK,OAAO,EAAE,CAAC;QACxD,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,GAAG,CAAC,GAAG,CACZ,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CACf,mEAAmE,SAAS,CAAC,KAAK,CAAC,EAAE,CACtF,CACF,CAAC;IACJ,CAAC;IAED,KAAK,OAAO,EAAE,CAAC;IAEf,OAAO,GAAG,EAAE;QACV,OAAO,GAAG,IAAI,CAAC;QACf,IAAI,KAAK;YAAE,YAAY,CAAC,KAAK,CAAC,CAAC;QAC/B,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,EAAE,CAAC;IACnB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {\n type CatalogProduct,\n type CatalogSnapshot,\n CatalogSnapshotSchema,\n PublishStatusSnapshotSchema,\n type PublishStatusSnapshot,\n type PublishedPackage,\n} from '@ekanos/integration-schema';\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport type { StoredSession } from './auth/credential-store';\nimport {\n type AuthEnvironment,\n refreshStoredSession,\n resolveAuthEnvironment,\n} from './auth/session';\nimport { fetchPublicCatalog, fetchSourceCatalog } from './catalog-api';\nimport { readActiveSource } from './commands/sources';\nimport type { CliContext } from './context';\nimport { CliError } from './errors';\nimport { listSubmissions } from './publish-api';\nimport { resolveSourceTarget } from './source-target';\n\n/**\n * What `ekanos dev` hands the harness about the host, beside the session\n * catalog: the catalog a developer browses (`catalog.json`) and the Source's\n * published packages (`publish-status.json`). The CLI holds the login, so the\n * harness never sees a token and never refreshes one (a second refresher would\n * race the CLI for the rotating refresh token). The harness asks for a fresh\n * read by writing `refresh-request`.\n */\nexport const CATALOG_SNAPSHOT_FILE = path.join('.ekanos', 'catalog.json');\nexport const PUBLISH_STATUS_FILE = path.join('.ekanos', 'publish-status.json');\nexport const REFRESH_REQUEST_FILE = 'refresh-request';\n\n/** Poll fast while a version is still moving through the pipeline. */\nconst IN_FLIGHT_STATES = new Set(['submitted', 'gated']);\nexport const IN_FLIGHT_INTERVAL_MS = 30_000;\nexport const IDLE_INTERVAL_MS = 300_000;\n\ntype Unavailable = NonNullable<CatalogSnapshot['unavailable']>;\n\nexport interface HostSnapshots {\n catalog: CatalogSnapshot;\n publish: PublishStatusSnapshot;\n}\n\n/** The network calls, injectable for tests. */\nexport interface HostSnapshotDeps {\n fetchSourceCatalog: typeof fetchSourceCatalog;\n fetchPublicCatalog: typeof fetchPublicCatalog;\n listSubmissions: typeof listSubmissions;\n resolveSourceTarget: typeof resolveSourceTarget;\n refreshStoredSession: typeof refreshStoredSession;\n now: () => Date;\n}\n\nconst DEFAULT_DEPS: HostSnapshotDeps = {\n fetchSourceCatalog,\n fetchPublicCatalog,\n listSubmissions,\n resolveSourceTarget,\n refreshStoredSession,\n now: () => new Date(),\n};\n\nfunction messageOf(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\n/** The error's message and, for a CLI error, what to do about it. */\nfunction messageWithHint(error: unknown): string {\n if (error instanceof CliError) return `${error.message} ${error.hint}`;\n return messageOf(error);\n}\n\n/**\n * Read both snapshots from the host, never throwing: every way it can fail is\n * written down as `unavailable`, in words the harness shows as is.\n */\nexport async function readHostSnapshots(params: {\n ctx: CliContext;\n env: Record<string, string | undefined>;\n projectDir: string;\n /** The Source to read when the project itself names none (a repo's packages' shared one). */\n fallbackSource?: string | null;\n deps?: Partial<HostSnapshotDeps>;\n}): Promise<HostSnapshots> {\n const deps = { ...DEFAULT_DEPS, ...params.deps };\n const fetchedAt = deps.now().toISOString();\n\n const empty = (\n host: string | null,\n unavailable: Unavailable | null,\n ): HostSnapshots => ({\n catalog: {\n fetchedAt,\n host,\n scope: null,\n source: null,\n unavailable,\n products: [],\n },\n publish: {\n fetchedAt,\n host,\n source: null,\n unavailable,\n packages: [],\n },\n });\n\n let auth: AuthEnvironment;\n try {\n auth = resolveAuthEnvironment(params.ctx, undefined, params.env, {\n projectDir: params.projectDir,\n });\n } catch {\n return empty(null, {\n reason: 'not-logged-in',\n message:\n 'No Ekanos host is known for this project. Run \"ekanos login\" to see the catalog and your publishes.',\n });\n }\n const host = auth.host;\n\n /** The host's public catalog, for a developer with no Source to read. */\n const publicCatalog = async (\n unavailable: Unavailable,\n ): Promise<HostSnapshots> => {\n const result = empty(host, unavailable);\n try {\n const catalog = await deps.fetchPublicCatalog(host);\n if (catalog) {\n result.catalog = {\n ...result.catalog,\n scope: 'public',\n unavailable: null,\n products: catalog.products,\n };\n }\n } catch (error) {\n result.catalog.unavailable = {\n reason: 'host-error',\n message: `Could not read the public catalog from ${host}: ${messageOf(error)}`,\n };\n }\n return result;\n };\n\n let session: StoredSession | null = auth.store.read(host);\n if (!session) {\n return publicCatalog({\n reason: 'not-logged-in',\n message: `Not logged in to ${host}. Run \"ekanos login\" to see your Source's catalog and your publishes.`,\n });\n }\n\n let source: string;\n try {\n const target = await deps.resolveSourceTarget(auth, session, {\n dir: params.projectDir,\n ...(params.fallbackSource && !readActiveSource(params.projectDir)\n ? { source: params.fallbackSource }\n : {}),\n });\n source = target.source;\n session = target.session;\n } catch (error) {\n return publicCatalog({\n reason: 'no-source',\n message: messageWithHint(error),\n });\n }\n\n /** One call, retried once with a refreshed session on a 401. */\n async function withSession<T extends { status: string }>(\n call: (token: string) => Promise<T>,\n ): Promise<T> {\n const current = session!;\n const first = await call(current.accessToken);\n if (first.status !== 'unauthorized') return first;\n session = await deps.refreshStoredSession(auth, current);\n return call(session.accessToken);\n }\n\n const result = empty(host, null);\n result.publish.source = source;\n\n try {\n const catalog = await withSession((token) =>\n deps.fetchSourceCatalog(host, token, { source }),\n );\n if (catalog.status === 'ok') {\n result.catalog = {\n fetchedAt,\n host,\n scope: 'source',\n source: {\n slug: catalog.catalog.source.slug,\n name: catalog.catalog.source.name,\n },\n unavailable: null,\n products: catalog.catalog.products satisfies CatalogProduct[],\n };\n } else {\n result.catalog.unavailable = {\n reason: 'not-logged-in',\n message: `The session for ${host} has expired. Run \"ekanos login\".`,\n };\n }\n } catch (error) {\n result.catalog.unavailable = {\n reason: 'host-error',\n message: `Could not read the catalog for ${source}: ${messageOf(error)}`,\n };\n }\n\n try {\n const listed = await withSession((token) =>\n deps.listSubmissions(host, token, source, { detail: 'findings' }),\n );\n if (listed.status === 'ok') {\n result.publish.packages = listed.integrations as PublishedPackage[];\n } else {\n result.publish.unavailable = {\n reason: 'not-logged-in',\n message: `The session for ${host} has expired. Run \"ekanos login\".`,\n };\n }\n } catch (error) {\n result.publish.unavailable = {\n reason: 'host-error',\n message: `Could not read the publishes for ${source}: ${messageOf(error)}`,\n };\n }\n\n return result;\n}\n\n/**\n * The one Source every package of a repo names in its `ekanos.json`, or null\n * when they name none or disagree (then the account's seats decide, as for\n * any project).\n */\nexport function sharedPackageSource(dirs: readonly string[]): string | null {\n const named = new Set(\n dirs.map((dir) => readActiveSource(dir)).filter((v): v is string => !!v),\n );\n return named.size === 1 ? [...named][0]! : null;\n}\n\n/** Write both snapshots for the harness, owner-only, never a token. */\nexport function writeHostSnapshots(\n projectDir: string,\n snapshots: HostSnapshots,\n): void {\n const write = (file: string, value: unknown) => {\n const target = path.join(projectDir, file);\n fs.mkdirSync(path.dirname(target), { recursive: true });\n const temp = `${target}.tmp`;\n fs.writeFileSync(temp, `${JSON.stringify(value)}\\n`, { mode: 0o600 });\n fs.renameSync(temp, target);\n };\n const catalog = CatalogSnapshotSchema.safeParse(snapshots.catalog);\n if (catalog.success) write(CATALOG_SNAPSHOT_FILE, catalog.data);\n const publish = PublishStatusSnapshotSchema.safeParse(snapshots.publish);\n if (publish.success) write(PUBLISH_STATUS_FILE, publish.data);\n}\n\n/** How long to wait before the next read: fast while a version is in flight. */\nexport function nextRefreshDelay(publish: PublishStatusSnapshot): number {\n const inFlight = publish.packages.some((pkg) =>\n pkg.versions.some((version) => IN_FLIGHT_STATES.has(version.state)),\n );\n return inFlight ? IN_FLIGHT_INTERVAL_MS : IDLE_INTERVAL_MS;\n}\n\n/**\n * Keep both snapshots fresh while the harness runs: read now, then again on a\n * timer (30 s while a version is in flight, 5 min otherwise) and whenever the\n * harness writes `.ekanos/refresh-request`. Returns a stop function.\n */\nexport function startHostSnapshotRefresher(params: {\n ctx: CliContext;\n env: Record<string, string | undefined>;\n projectDir: string;\n fallbackSource?: string | null;\n deps?: Partial<HostSnapshotDeps>;\n}): () => void {\n const dir = path.join(params.projectDir, '.ekanos');\n fs.mkdirSync(dir, { recursive: true });\n\n let stopped = false;\n let running = false;\n let queued = false;\n let timer: NodeJS.Timeout | null = null;\n\n const schedule = (delay: number) => {\n if (stopped) return;\n if (timer) clearTimeout(timer);\n timer = setTimeout(() => void refresh(), delay);\n timer.unref();\n };\n\n const refresh = async () => {\n if (stopped) return;\n if (running) {\n queued = true;\n return;\n }\n running = true;\n let delay = IDLE_INTERVAL_MS;\n try {\n const snapshots = await readHostSnapshots(params);\n if (!stopped) writeHostSnapshots(params.projectDir, snapshots);\n delay = nextRefreshDelay(snapshots.publish);\n } catch (error) {\n params.ctx.log(\n params.ctx.ui.dim(\n `Could not refresh the catalog and publish status: ${messageOf(error)}`,\n ),\n );\n } finally {\n running = false;\n }\n if (queued) {\n queued = false;\n void refresh();\n return;\n }\n schedule(delay);\n };\n\n let watcher: fs.FSWatcher | null = null;\n try {\n watcher = fs.watch(dir, (_event, filename) => {\n if (filename === REFRESH_REQUEST_FILE) void refresh();\n });\n watcher.unref();\n } catch (error) {\n params.ctx.log(\n params.ctx.ui.dim(\n `The harness's Refresh button will wait for the next timed read: ${messageOf(error)}`,\n ),\n );\n }\n\n void refresh();\n\n return () => {\n stopped = true;\n if (timer) clearTimeout(timer);\n watcher?.close();\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"host-snapshots.js","sourceRoot":"","sources":["../src/host-snapshots.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,qBAAqB,EACrB,2BAA2B,EAG3B,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC,OAAO,EAEL,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;AAC1E,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,qBAAqB,CAAC,CAAC;AAC/E,MAAM,CAAC,MAAM,oBAAoB,GAAG,iBAAiB,CAAC;AACtD;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC,IAAI,CAC5C,SAAS,EACT,u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X,MAAM,GAAG,KAAK,CAAC;YACf,KAAK,OAAO,EAAE,CAAC;YACf,OAAO;QACT,CAAC;QACD,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClB,CAAC,CAAC;IAEF,IAAI,OAAO,GAAwB,IAAI,CAAC;IACxC,IAAI,CAAC;QACH,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE;YAC3C,IAAI,QAAQ,KAAK,oBAAoB;gBAAE,KAAK,OAAO,EAAE,CAAC;QACxD,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,GAAG,CAAC,GAAG,CACZ,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CACf,mEAAmE,SAAS,CAAC,KAAK,CAAC,EAAE,CACtF,CACF,CAAC;IACJ,CAAC;IAED,KAAK,OAAO,EAAE,CAAC;IAEf,OAAO,GAAG,EAAE;QACV,OAAO,GAAG,IAAI,CAAC;QACf,IAAI,KAAK;YAAE,YAAY,CAAC,KAAK,CAAC,CAAC;QAC/B,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,EAAE,CAAC;IACnB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {\n type CatalogProduct,\n type CatalogSnapshot,\n CatalogSnapshotSchema,\n PublishStatusSnapshotSchema,\n type PublishStatusSnapshot,\n type PublishedPackage,\n SourceSelectionSchema,\n} from '@ekanos/integration-schema';\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport type { StoredSession } from './auth/credential-store';\nimport {\n type AuthEnvironment,\n refreshStoredSession,\n resolveAuthEnvironment,\n} from './auth/session';\nimport { fetchPublicCatalog, fetchSourceCatalog } from './catalog-api';\nimport { readActiveSource } from './commands/sources';\nimport type { CliContext } from './context';\nimport { CliError } from './errors';\nimport { listSubmissions } from './publish-api';\nimport { fetchSeatsWithOneRefresh } from './seats';\nimport { resolveSourceTarget } from './source-target';\n\n/**\n * What `ekanos dev` hands the harness about the host, beside the session\n * catalog: the catalog a developer browses (`catalog.json`) and the Source's\n * published packages (`publish-status.json`). The CLI holds the login, so the\n * harness never sees a token and never refreshes one (a second refresher would\n * race the CLI for the rotating refresh token). The harness asks for a fresh\n * read by writing `refresh-request`.\n */\nexport const CATALOG_SNAPSHOT_FILE = path.join('.ekanos', 'catalog.json');\nexport const PUBLISH_STATUS_FILE = path.join('.ekanos', 'publish-status.json');\nexport const REFRESH_REQUEST_FILE = 'refresh-request';\n/**\n * The Source the harness's switcher picked (`{ \"source\": \"<slug>\" }`). It\n * decides which Source the harness reads, ahead of ekanos.json, while it is\n * still one of the developer's seats; it never changes where `publish` goes.\n */\nexport const SOURCE_SELECTION_FILE = path.join(\n '.ekanos',\n 'source-selection.json',\n);\n\n/** Poll fast while a version is still moving through the pipeline. */\nconst IN_FLIGHT_STATES = new Set(['submitted', 'gated']);\nexport const IN_FLIGHT_INTERVAL_MS = 30_000;\nexport const IDLE_INTERVAL_MS = 300_000;\n\ntype Unavailable = NonNullable<CatalogSnapshot['unavailable']>;\n\nexport interface HostSnapshots {\n catalog: CatalogSnapshot;\n publish: PublishStatusSnapshot;\n}\n\n/** The network calls, injectable for tests. */\nexport interface HostSnapshotDeps {\n fetchSourceCatalog: typeof fetchSourceCatalog;\n fetchPublicCatalog: typeof fetchPublicCatalog;\n listSubmissions: typeof listSubmissions;\n fetchSeats: typeof fetchSeatsWithOneRefresh;\n resolveSourceTarget: typeof resolveSourceTarget;\n refreshStoredSession: typeof refreshStoredSession;\n now: () => Date;\n}\n\nconst DEFAULT_DEPS: HostSnapshotDeps = {\n fetchSourceCatalog,\n fetchPublicCatalog,\n listSubmissions,\n fetchSeats: fetchSeatsWithOneRefresh,\n resolveSourceTarget,\n refreshStoredSession,\n now: () => new Date(),\n};\n\nfunction messageOf(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\n/** The error's message and, for a CLI error, what to do about it. */\nfunction messageWithHint(error: unknown): string {\n if (error instanceof CliError) return `${error.message} ${error.hint}`;\n return messageOf(error);\n}\n\n/**\n * Read both snapshots from the host, never throwing: every way it can fail is\n * written down as `unavailable`, in words the harness shows as is.\n */\nexport async function readHostSnapshots(params: {\n ctx: CliContext;\n env: Record<string, string | undefined>;\n projectDir: string;\n /** The Source to read when the project itself names none (a repo's packages' shared one). */\n fallbackSource?: string | null;\n deps?: Partial<HostSnapshotDeps>;\n}): Promise<HostSnapshots> {\n const deps = { ...DEFAULT_DEPS, ...params.deps };\n const fetchedAt = deps.now().toISOString();\n /** The developer's seats, once read: the harness's switcher offers them. */\n let seats: Array<{ slug: string; name: string | null }> | undefined;\n\n const empty = (\n host: string | null,\n unavailable: Unavailable | null,\n ): HostSnapshots => ({\n catalog: {\n fetchedAt,\n host,\n scope: null,\n source: null,\n unavailable,\n products: [],\n ...(seats ? { seats } : {}),\n },\n publish: {\n fetchedAt,\n host,\n source: null,\n unavailable,\n packages: [],\n },\n });\n\n let auth: AuthEnvironment;\n try {\n auth = resolveAuthEnvironment(params.ctx, undefined, params.env, {\n projectDir: params.projectDir,\n });\n } catch {\n return empty(null, {\n reason: 'not-logged-in',\n message:\n 'No Ekanos host is known for this project. Run \"ekanos login\" to see the catalog and your publishes.',\n });\n }\n const host = auth.host;\n\n /** The host's public catalog, for a developer with no Source to read. */\n const publicCatalog = async (\n unavailable: Unavailable,\n ): Promise<HostSnapshots> => {\n const result = empty(host, unavailable);\n try {\n const catalog = await deps.fetchPublicCatalog(host);\n if (catalog) {\n result.catalog = {\n ...result.catalog,\n scope: 'public',\n unavailable: null,\n products: catalog.products,\n };\n }\n } catch (error) {\n result.catalog.unavailable = {\n reason: 'host-error',\n message: `Could not read the public catalog from ${host}: ${messageOf(error)}`,\n };\n }\n return result;\n };\n\n let session: StoredSession | null = auth.store.read(host);\n if (!session) {\n return publicCatalog({\n reason: 'not-logged-in',\n message: `Not logged in to ${host}. Run \"ekanos login\" to see your Source's catalog and your publishes.`,\n });\n }\n\n // The seats, for the switcher and to hold the harness's pick to one. A\n // failed read only leaves the switcher out; the catalog route still checks.\n try {\n const listed = await deps.fetchSeats(auth, session);\n if (listed.status === 'ok') {\n session = listed.session;\n seats = listed.sources.map((seat) => ({\n slug: seat.slug,\n name: seat.name,\n }));\n }\n } catch {\n seats = undefined;\n }\n const selected = readSourceSelection(params.projectDir);\n const picked =\n selected && seats?.some((seat) => seat.slug === selected) ? selected : null;\n\n let source: string;\n try {\n const target = await deps.resolveSourceTarget(auth, session, {\n dir: params.projectDir,\n ...(picked\n ? { source: picked }\n : params.fallbackSource && !readActiveSource(params.projectDir)\n ? { source: params.fallbackSource }\n : {}),\n });\n source = target.source;\n session = target.session;\n } catch (error) {\n return publicCatalog({\n reason: 'no-source',\n message: messageWithHint(error),\n });\n }\n\n /** One call, retried once with a refreshed session on a 401. */\n async function withSession<T extends { status: string }>(\n call: (token: string) => Promise<T>,\n ): Promise<T> {\n const current = session!;\n const first = await call(current.accessToken);\n if (first.status !== 'unauthorized') return first;\n session = await deps.refreshStoredSession(auth, current);\n return call(session.accessToken);\n }\n\n const result = empty(host, null);\n result.publish.source = source;\n\n try {\n const catalog = await withSession((token) =>\n deps.fetchSourceCatalog(host, token, { source }),\n );\n if (catalog.status === 'ok') {\n result.catalog = {\n fetchedAt,\n host,\n scope: 'source',\n source: {\n slug: catalog.catalog.source.slug,\n name: catalog.catalog.source.name,\n },\n unavailable: null,\n products: catalog.catalog.products satisfies CatalogProduct[],\n ...(seats ? { seats } : {}),\n };\n } else {\n result.catalog.unavailable = {\n reason: 'not-logged-in',\n message: `The session for ${host} has expired. Run \"ekanos login\".`,\n };\n }\n } catch (error) {\n result.catalog.unavailable = {\n reason: 'host-error',\n message: `Could not read the catalog for ${source}: ${messageOf(error)}`,\n };\n }\n\n try {\n const listed = await withSession((token) =>\n deps.listSubmissions(host, token, source, { detail: 'findings' }),\n );\n if (listed.status === 'ok') {\n result.publish.packages = listed.integrations as PublishedPackage[];\n } else {\n result.publish.unavailable = {\n reason: 'not-logged-in',\n message: `The session for ${host} has expired. Run \"ekanos login\".`,\n };\n }\n } catch (error) {\n result.publish.unavailable = {\n reason: 'host-error',\n message: `Could not read the publishes for ${source}: ${messageOf(error)}`,\n };\n }\n\n return result;\n}\n\n/** The Source the harness's switcher picked, or null. Never throws. */\nexport function readSourceSelection(projectDir: string): string | null {\n try {\n const parsed = SourceSelectionSchema.safeParse(\n JSON.parse(\n fs.readFileSync(path.join(projectDir, SOURCE_SELECTION_FILE), 'utf8'),\n ),\n );\n return parsed.success ? parsed.data.source : null;\n } catch {\n return null;\n }\n}\n\n/**\n * The one Source every package of a repo names in its `ekanos.json`, or null\n * when they name none or disagree (then the account's seats decide, as for\n * any project).\n */\nexport function sharedPackageSource(dirs: readonly string[]): string | null {\n const named = new Set(\n dirs.map((dir) => readActiveSource(dir)).filter((v): v is string => !!v),\n );\n return named.size === 1 ? [...named][0]! : null;\n}\n\n/** Write both snapshots for the harness, owner-only, never a token. */\nexport function writeHostSnapshots(\n projectDir: string,\n snapshots: HostSnapshots,\n): void {\n const write = (file: string, value: unknown) => {\n const target = path.join(projectDir, file);\n fs.mkdirSync(path.dirname(target), { recursive: true });\n const temp = `${target}.tmp`;\n fs.writeFileSync(temp, `${JSON.stringify(value)}\\n`, { mode: 0o600 });\n fs.renameSync(temp, target);\n };\n const catalog = CatalogSnapshotSchema.safeParse(snapshots.catalog);\n if (catalog.success) write(CATALOG_SNAPSHOT_FILE, catalog.data);\n const publish = PublishStatusSnapshotSchema.safeParse(snapshots.publish);\n if (publish.success) write(PUBLISH_STATUS_FILE, publish.data);\n}\n\n/** How long to wait before the next read: fast while a version is in flight. */\nexport function nextRefreshDelay(publish: PublishStatusSnapshot): number {\n const inFlight = publish.packages.some((pkg) =>\n pkg.versions.some((version) => IN_FLIGHT_STATES.has(version.state)),\n );\n return inFlight ? IN_FLIGHT_INTERVAL_MS : IDLE_INTERVAL_MS;\n}\n\n/**\n * Keep both snapshots fresh while the harness runs: read now, then again on a\n * timer (30 s while a version is in flight, 5 min otherwise) and whenever the\n * harness writes `.ekanos/refresh-request`. Returns a stop function.\n */\nexport function startHostSnapshotRefresher(params: {\n ctx: CliContext;\n env: Record<string, string | undefined>;\n projectDir: string;\n fallbackSource?: string | null;\n deps?: Partial<HostSnapshotDeps>;\n}): () => void {\n const dir = path.join(params.projectDir, '.ekanos');\n fs.mkdirSync(dir, { recursive: true });\n\n let stopped = false;\n let running = false;\n let queued = false;\n let timer: NodeJS.Timeout | null = null;\n\n const schedule = (delay: number) => {\n if (stopped) return;\n if (timer) clearTimeout(timer);\n timer = setTimeout(() => void refresh(), delay);\n timer.unref();\n };\n\n const refresh = async () => {\n if (stopped) return;\n if (running) {\n queued = true;\n return;\n }\n running = true;\n let delay = IDLE_INTERVAL_MS;\n try {\n const snapshots = await readHostSnapshots(params);\n if (!stopped) writeHostSnapshots(params.projectDir, snapshots);\n delay = nextRefreshDelay(snapshots.publish);\n } catch (error) {\n params.ctx.log(\n params.ctx.ui.dim(\n `Could not refresh the catalog and publish status: ${messageOf(error)}`,\n ),\n );\n } finally {\n running = false;\n }\n if (queued) {\n queued = false;\n void refresh();\n return;\n }\n schedule(delay);\n };\n\n let watcher: fs.FSWatcher | null = null;\n try {\n watcher = fs.watch(dir, (_event, filename) => {\n if (filename === REFRESH_REQUEST_FILE) void refresh();\n });\n watcher.unref();\n } catch (error) {\n params.ctx.log(\n params.ctx.ui.dim(\n `The harness's Refresh button will wait for the next timed read: ${messageOf(error)}`,\n ),\n );\n }\n\n void refresh();\n\n return () => {\n stopped = true;\n if (timer) clearTimeout(timer);\n watcher?.close();\n };\n}\n"]}
|
package/dist/index.js
CHANGED
|
@@ -293,6 +293,10 @@ const COMMAND_SPECS = {
|
|
|
293
293
|
host: HOST,
|
|
294
294
|
source: SOURCE,
|
|
295
295
|
dir: DIR,
|
|
296
|
+
all: {
|
|
297
|
+
type: 'boolean',
|
|
298
|
+
description: "not only SDK packages: the Source's in-repo integrations and Features too",
|
|
299
|
+
},
|
|
296
300
|
},
|
|
297
301
|
apps: Object.assign({ host: HOST, source: SOURCE, dir: DIR, 'no-wait': {
|
|
298
302
|
type: 'boolean',
|
|
@@ -889,10 +893,11 @@ const USAGE = [
|
|
|
889
893
|
' dropping a product needs --yes). A team is put on one (its',
|
|
890
894
|
' business type) with "teams audience <team> [<audience>]"; its',
|
|
891
895
|
' groups narrow it per person ("teams groups")',
|
|
892
|
-
' catalog What a source can
|
|
893
|
-
'
|
|
894
|
-
'
|
|
895
|
-
'
|
|
896
|
+
' catalog What a source can build on: SDK packages that are global or',
|
|
897
|
+
' attached to it (--all adds its in-repo integrations and',
|
|
898
|
+
' Features); one product shows its tools with their inputs and',
|
|
899
|
+
' whose connection agent runs use',
|
|
900
|
+
' ("ekanos catalog [<product-slug>] --source <slug> [--all]", --json)',
|
|
896
901
|
" apps The Source's app for an integration teams sign in through:",
|
|
897
902
|
' show <product> | set <product> (Source admin; takes the secret',
|
|
898
903
|
' at your terminal, Enter keeps a saved value; without one,',
|
|
@@ -1319,6 +1324,7 @@ export async function run(argv, options = {}) {
|
|
|
1319
1324
|
host: parsed.flags.host,
|
|
1320
1325
|
source: parsed.flags.source,
|
|
1321
1326
|
product: parsed.positionals[0],
|
|
1327
|
+
all: parsed.flags.all === true,
|
|
1322
1328
|
dir,
|
|
1323
1329
|
env,
|
|
1324
1330
|
});
|