@ekanos/cli 0.26.1 → 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/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,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,QAAQ,EAA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AAG,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-overview.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,mBAAmB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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"]}
|
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,E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QACJ,CAAC;gBAAS,CAAC;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,IAA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,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 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
|
});
|