@ekanos/cli 0.25.0 → 0.26.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 +4 -0
- package/dist/catalog-api.d.ts +8 -1
- package/dist/catalog-api.js +26 -1
- package/dist/catalog-api.js.map +1 -1
- package/dist/commands/add.js +2 -1
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/apps.js +6 -4
- package/dist/commands/apps.js.map +1 -1
- package/dist/commands/dev.d.ts +5 -0
- package/dist/commands/dev.js +25 -9
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/routes.js +7 -1
- package/dist/commands/routes.js.map +1 -1
- package/dist/commands/sources.js +11 -8
- package/dist/commands/sources.js.map +1 -1
- package/dist/commands/sync.js +3 -2
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/teams-events.js +9 -1
- package/dist/commands/teams-events.js.map +1 -1
- package/dist/commands/teams-lifecycle.js +9 -1
- package/dist/commands/teams-lifecycle.js.map +1 -1
- package/dist/commands/teams-onboard.js +9 -1
- package/dist/commands/teams-onboard.js.map +1 -1
- package/dist/commands/teams-overview.d.ts +1 -1
- package/dist/commands/teams-overview.js +41 -14
- package/dist/commands/teams-overview.js.map +1 -1
- package/dist/commands/teams.js +9 -1
- package/dist/commands/teams.js.map +1 -1
- package/dist/compatibility.d.ts +7 -1
- package/dist/compatibility.js +7 -1
- package/dist/compatibility.js.map +1 -1
- package/dist/contracts-api.d.ts +32 -0
- package/dist/contracts-api.js +66 -0
- package/dist/contracts-api.js.map +1 -0
- package/dist/experience/host-contract-source.d.ts +35 -0
- package/dist/experience/host-contract-source.js +121 -0
- package/dist/experience/host-contract-source.js.map +1 -0
- package/dist/harness-scaffold.js +5 -0
- package/dist/harness-scaffold.js.map +1 -1
- package/dist/host-snapshots.d.ts +66 -0
- package/dist/host-snapshots.js +273 -0
- package/dist/host-snapshots.js.map +1 -0
- package/dist/product-slug.d.ts +8 -0
- package/dist/product-slug.js +13 -0
- package/dist/product-slug.js.map +1 -0
- package/package.json +2 -2
- package/templates/experience/package.json.tmpl +4 -4
- package/templates/harness/app/catalog/[slug]/page.tsx.tmpl +1 -0
- package/templates/harness/app/catalog/layout.tsx.tmpl +1 -0
- package/templates/harness/app/catalog/page.tsx.tmpl +1 -0
- package/templates/harness/app/experience/publishes/page.tsx.tmpl +1 -0
- package/templates/harness/app/integrations/[slug]/publishes/page.tsx.tmpl +1 -0
- package/templates/package.json.tmpl +4 -4
- package/templates/skills/build-integration/references/widget-design.md +24 -0
package/README.md
CHANGED
|
@@ -200,6 +200,7 @@ imply an isolation that does not exist.
|
|
|
200
200
|
app/integrations/[slug]/events/page.tsx
|
|
201
201
|
app/integrations/[slug]/health/page.tsx
|
|
202
202
|
app/integrations/[slug]/runs/page.tsx
|
|
203
|
+
app/integrations/[slug]/publishes/page.tsx
|
|
203
204
|
app/integrations/[slug]/preview/layout.tsx
|
|
204
205
|
app/integrations/[slug]/preview/page.tsx
|
|
205
206
|
app/integrations/[slug]/preview/widgets/page.tsx
|
|
@@ -207,6 +208,9 @@ imply an isolation that does not exist.
|
|
|
207
208
|
app/integrations/[slug]/preview/tile/page.tsx
|
|
208
209
|
app/integrations/[slug]/preview/activation/page.tsx
|
|
209
210
|
app/integrations/[slug]/preview/triggers/page.tsx
|
|
211
|
+
app/catalog/layout.tsx the Catalog: integrations and experiences to build on
|
|
212
|
+
app/catalog/page.tsx
|
|
213
|
+
app/catalog/[slug]/page.tsx
|
|
210
214
|
next.config.mjs transpiles @ekanos/harness, aliases the workspace mock
|
|
211
215
|
postcss.config.mjs @tailwindcss/postcss
|
|
212
216
|
tsconfig.json no baseUrl, no paths
|
package/dist/catalog-api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type SourceCatalog } from '@ekanos/integration-schema';
|
|
1
|
+
import { type PublicCatalog, type SourceCatalog } from '@ekanos/integration-schema';
|
|
2
2
|
/**
|
|
3
3
|
* The CLI's client for the Source catalog (plan 239.0).
|
|
4
4
|
*
|
|
@@ -24,3 +24,10 @@ export declare function fetchSourceCatalog(host: string, accessToken: string, qu
|
|
|
24
24
|
source: string;
|
|
25
25
|
product?: string;
|
|
26
26
|
}): Promise<FetchSourceCatalogResult>;
|
|
27
|
+
/**
|
|
28
|
+
* `GET /api/partner/catalog/public`: every global integration and experience
|
|
29
|
+
* on the host, for a developer with no Source (or before they pick one). No
|
|
30
|
+
* login: the route lists only what any Source could use. Null when the host
|
|
31
|
+
* predates the route.
|
|
32
|
+
*/
|
|
33
|
+
export declare function fetchPublicCatalog(host: string): Promise<PublicCatalog | null>;
|
package/dist/catalog-api.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SourceCatalogSchema, } from '@ekanos/integration-schema';
|
|
1
|
+
import { PublicCatalogSchema, SourceCatalogSchema, } from '@ekanos/integration-schema';
|
|
2
2
|
import { request } from './auth/ekanos-api.js';
|
|
3
3
|
import { authRequiredError, forbiddenError, networkError, notFoundError, } from './errors.js';
|
|
4
4
|
export async function fetchSourceCatalog(host, accessToken, query) {
|
|
@@ -58,4 +58,29 @@ function isRedirect(status) {
|
|
|
58
58
|
function str(value) {
|
|
59
59
|
return typeof value === 'string' && value.length > 0 ? value : null;
|
|
60
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* `GET /api/partner/catalog/public`: every global integration and experience
|
|
63
|
+
* on the host, for a developer with no Source (or before they pick one). No
|
|
64
|
+
* login: the route lists only what any Source could use. Null when the host
|
|
65
|
+
* predates the route.
|
|
66
|
+
*/
|
|
67
|
+
export async function fetchPublicCatalog(host) {
|
|
68
|
+
const response = await request(`${host}/api/partner/catalog/public`, {
|
|
69
|
+
method: 'GET',
|
|
70
|
+
headers: { accept: 'application/json' },
|
|
71
|
+
});
|
|
72
|
+
if (response.status === 404)
|
|
73
|
+
return null;
|
|
74
|
+
const body = await readOptionalJson(response);
|
|
75
|
+
if (!response.ok) {
|
|
76
|
+
throw networkError(`${host}/api/partner/catalog/public responded ${response.status}.`, response.status >= 500
|
|
77
|
+
? `The Ekanos deployment returned a server error. Retry shortly.`
|
|
78
|
+
: `Confirm the host runs a build that includes the public catalog route.`);
|
|
79
|
+
}
|
|
80
|
+
const parsed = PublicCatalogSchema.safeParse(body.data);
|
|
81
|
+
if (!parsed.success) {
|
|
82
|
+
throw networkError(`${host}/api/partner/catalog/public answered in a shape this CLI does not read.`, `Run "ekanos upgrade" — the CLI and the host disagree on the catalog contract.`);
|
|
83
|
+
}
|
|
84
|
+
return parsed.data;
|
|
85
|
+
}
|
|
61
86
|
//# sourceMappingURL=catalog-api.js.map
|
package/dist/catalog-api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog-api.js","sourceRoot":"","sources":["../src/catalog-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,aAAa,GACd,MAAM,UAAU,CAAC;AAsBlB,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,IAAY,EACZ,WAAmB,EACnB,KAA2C;;IAE3C,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7D,IAAI,KAAK,CAAC,OAAO;QAAE,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IAExD,MAAM,QAAQ,GAAG,MAAM,OAAO,CAC5B,GAAG,IAAI,wBAAwB,MAAM,CAAC,QAAQ,EAAE,EAAE,EAClD;QACE,MAAM,EAAE,KAAK;QACb,OAAO,EAAE;YACP,MAAM,EAAE,kBAAkB;YAC1B,aAAa,EAAE,UAAU,WAAW,EAAE;SACvC;KACF,CACF,CAAC;IAEF,IAAI,QAAQ,CAAC,MAAM,KAA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IAED,MAAM,MAAM,GAAG,mBAAmB,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,YAAY,CAChB,GAAG,IAAI,kEAAkE,EACzE,+EAA+E,CAChF,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;AAChD,CAAC;AAED,KAAK,UAAU,gBAAgB,CAC7B,QAAkB;IAElB,IAAI,CAAC;QACH,MAAM,MAAM,GAAY,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC9C,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI;YAClD,CAAC,CAAE,MAAkC;YACrC,CAAC,CAAC,EAAE,CAAC;IACT,CAAC;eAAO,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CAAC,MAAc;IAChC,OAAO,MAAM,IAAI,GAAG,IAAI,MAAM,GAAG,GAAG,CAAC;AACvC,CAAC;AAED,SAAS,GAAG,CAAC,KAAc;IACzB,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AACtE,CAAC","sourcesContent":["import {\n type SourceCatalog,\n SourceCatalogSchema,\n} from '@ekanos/integration-schema';\n\nimport { request } from './auth/ekanos-api';\nimport {\n authRequiredError,\n forbiddenError,\n networkError,\n notFoundError,\n} from './errors';\n\n/**\n * The CLI's client for the Source catalog (plan 239.0).\n *\n * ---------------------------------------------------------------------------\n * WIRE CONTRACT — `SourceCatalogSchema` in `@ekanos/integration-schema`,\n * which the host's `/api/partner/catalog` route builds and this parses.\n *\n * GET /api/partner/catalog?source=<slug|id>[&product=<slug>]\n * [Authorization: Bearer <access_token>]\n * → 200 { ok: true, data: SourceCatalog }\n * → 401 / 3xx refresh once and retry\n * → 403 { code: \"MFA_REQUIRED\" | \"FORBIDDEN\" }\n * → 404 { code: \"SOURCE_NOT_FOUND\" | \"PRODUCT_NOT_FOUND\" }\n * ---------------------------------------------------------------------------\n */\n\nexport type FetchSourceCatalogResult =\n | { status: 'ok'; catalog: SourceCatalog }\n | { status: 'unauthorized' };\n\nexport async function fetchSourceCatalog(\n host: string,\n accessToken: string,\n query: { source: string; product?: string },\n): Promise<FetchSourceCatalogResult> {\n const params = new URLSearchParams({ source: query.source });\n if (query.product) params.set('product', query.product);\n\n const response = await request(\n `${host}/api/partner/catalog?${params.toString()}`,\n {\n method: 'GET',\n headers: {\n accept: 'application/json',\n authorization: `Bearer ${accessToken}`,\n },\n },\n );\n\n if (response.status === 401 || isRedirect(response.status)) {\n return { status: 'unauthorized' };\n }\n\n const body = await readOptionalJson(response);\n const code = str(body.code);\n const message = str(body.error);\n\n if (response.status === 403 && code === 'MFA_REQUIRED') {\n throw authRequiredError(\n message ?? `${host} requires multi-factor authentication.`,\n `Complete MFA in the browser, then run \"ekanos login\" again.`,\n );\n }\n\n if (response.status === 403) {\n throw forbiddenError(\n message ?? `No seat on \"${query.source}\".`,\n `Run \"ekanos sources\" to list the sources you hold a seat on.`,\n );\n }\n\n if (response.status === 404) {\n throw notFoundError(\n message ?? `\"${query.product ?? query.source}\" was not found.`,\n code === 'PRODUCT_NOT_FOUND'\n ? `Run \"ekanos catalog\" to list the products this Source can use.`\n : `Run \"ekanos sources\" to list the sources you hold a seat on.`,\n );\n }\n\n if (!response.ok) {\n throw networkError(\n `${host}/api/partner/catalog responded ${response.status}.`,\n response.status >= 500\n ? `The Ekanos deployment returned a server error. Retry shortly.`\n : `Confirm the host runs a build that includes the catalog route.`,\n );\n }\n\n const parsed = SourceCatalogSchema.safeParse(body.data);\n if (!parsed.success) {\n throw networkError(\n `${host}/api/partner/catalog answered in a shape this CLI does not read.`,\n `Run \"ekanos upgrade\" — the CLI and the host disagree on the catalog contract.`,\n );\n }\n\n return { status: 'ok', catalog: parsed.data };\n}\n\nasync function readOptionalJson(\n response: Response,\n): Promise<Record<string, unknown>> {\n try {\n const parsed: unknown = await response.json();\n return typeof parsed === 'object' && parsed !== null\n ? (parsed as Record<string, unknown>)\n : {};\n } catch {\n return {};\n }\n}\n\nfunction isRedirect(status: number): boolean {\n return status >= 300 && status < 400;\n}\n\nfunction str(value: unknown): string | null {\n return typeof value === 'string' && value.length > 0 ? value : null;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"catalog-api.js","sourceRoot":"","sources":["../src/catalog-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,EAEnB,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,aAAa,GACd,MAAM,UAAU,CAAC;AAsBlB,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,IAAY,EACZ,WAAmB,EACnB,KAA2C;;IAE3C,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7D,IAAI,KAAK,CAAC,OAAO;QAAE,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IAExD,MAAM,QAAQ,GAAG,MAAM,OAAO,CAC5B,GAAG,IAAI,wBAAwB,MAAM,CAAC,QAAQ,EAAE,EAAE,EAClD;QACE,MAAM,EAAE,KAAK;QACb,OAAO,EAAE;YACP,MAAM,EAAE,kBAAkB;YAC1B,aAAa,EAAE,UAAU,WAAW,EAAE;SACvC;KACF,CACF,CAAC;IAEF,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3D,OAAO,EAAE,MAA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IAAI,yCAAyC,QAAQ,CAAC,MAAM,GAAG,EAClE,QAAQ,CAAC,MAAM,IAAI,GAAG;YACpB,CAAC,CAAC,+DAA+D;YACjE,CAAC,CAAC,uEAAuE,CAC5E,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAG,mBAAmB,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,YAAY,CAChB,GAAG,IAAI,yEAAyE,EAChF,+EAA+E,CAChF,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC","sourcesContent":["import {\n type PublicCatalog,\n PublicCatalogSchema,\n type SourceCatalog,\n SourceCatalogSchema,\n} from '@ekanos/integration-schema';\n\nimport { request } from './auth/ekanos-api';\nimport {\n authRequiredError,\n forbiddenError,\n networkError,\n notFoundError,\n} from './errors';\n\n/**\n * The CLI's client for the Source catalog (plan 239.0).\n *\n * ---------------------------------------------------------------------------\n * WIRE CONTRACT — `SourceCatalogSchema` in `@ekanos/integration-schema`,\n * which the host's `/api/partner/catalog` route builds and this parses.\n *\n * GET /api/partner/catalog?source=<slug|id>[&product=<slug>]\n * [Authorization: Bearer <access_token>]\n * → 200 { ok: true, data: SourceCatalog }\n * → 401 / 3xx refresh once and retry\n * → 403 { code: \"MFA_REQUIRED\" | \"FORBIDDEN\" }\n * → 404 { code: \"SOURCE_NOT_FOUND\" | \"PRODUCT_NOT_FOUND\" }\n * ---------------------------------------------------------------------------\n */\n\nexport type FetchSourceCatalogResult =\n | { status: 'ok'; catalog: SourceCatalog }\n | { status: 'unauthorized' };\n\nexport async function fetchSourceCatalog(\n host: string,\n accessToken: string,\n query: { source: string; product?: string },\n): Promise<FetchSourceCatalogResult> {\n const params = new URLSearchParams({ source: query.source });\n if (query.product) params.set('product', query.product);\n\n const response = await request(\n `${host}/api/partner/catalog?${params.toString()}`,\n {\n method: 'GET',\n headers: {\n accept: 'application/json',\n authorization: `Bearer ${accessToken}`,\n },\n },\n );\n\n if (response.status === 401 || isRedirect(response.status)) {\n return { status: 'unauthorized' };\n }\n\n const body = await readOptionalJson(response);\n const code = str(body.code);\n const message = str(body.error);\n\n if (response.status === 403 && code === 'MFA_REQUIRED') {\n throw authRequiredError(\n message ?? `${host} requires multi-factor authentication.`,\n `Complete MFA in the browser, then run \"ekanos login\" again.`,\n );\n }\n\n if (response.status === 403) {\n throw forbiddenError(\n message ?? `No seat on \"${query.source}\".`,\n `Run \"ekanos sources\" to list the sources you hold a seat on.`,\n );\n }\n\n if (response.status === 404) {\n throw notFoundError(\n message ?? `\"${query.product ?? query.source}\" was not found.`,\n code === 'PRODUCT_NOT_FOUND'\n ? `Run \"ekanos catalog\" to list the products this Source can use.`\n : `Run \"ekanos sources\" to list the sources you hold a seat on.`,\n );\n }\n\n if (!response.ok) {\n throw networkError(\n `${host}/api/partner/catalog responded ${response.status}.`,\n response.status >= 500\n ? `The Ekanos deployment returned a server error. Retry shortly.`\n : `Confirm the host runs a build that includes the catalog route.`,\n );\n }\n\n const parsed = SourceCatalogSchema.safeParse(body.data);\n if (!parsed.success) {\n throw networkError(\n `${host}/api/partner/catalog answered in a shape this CLI does not read.`,\n `Run \"ekanos upgrade\" — the CLI and the host disagree on the catalog contract.`,\n );\n }\n\n return { status: 'ok', catalog: parsed.data };\n}\n\nasync function readOptionalJson(\n response: Response,\n): Promise<Record<string, unknown>> {\n try {\n const parsed: unknown = await response.json();\n return typeof parsed === 'object' && parsed !== null\n ? (parsed as Record<string, unknown>)\n : {};\n } catch {\n return {};\n }\n}\n\nfunction isRedirect(status: number): boolean {\n return status >= 300 && status < 400;\n}\n\nfunction str(value: unknown): string | null {\n return typeof value === 'string' && value.length > 0 ? value : null;\n}\n\n/**\n * `GET /api/partner/catalog/public`: every global integration and experience\n * on the host, for a developer with no Source (or before they pick one). No\n * login: the route lists only what any Source could use. Null when the host\n * predates the route.\n */\nexport async function fetchPublicCatalog(\n host: string,\n): Promise<PublicCatalog | null> {\n const response = await request(`${host}/api/partner/catalog/public`, {\n method: 'GET',\n headers: { accept: 'application/json' },\n });\n if (response.status === 404) return null;\n\n const body = await readOptionalJson(response);\n if (!response.ok) {\n throw networkError(\n `${host}/api/partner/catalog/public responded ${response.status}.`,\n response.status >= 500\n ? `The Ekanos deployment returned a server error. Retry shortly.`\n : `Confirm the host runs a build that includes the public catalog route.`,\n );\n }\n\n const parsed = PublicCatalogSchema.safeParse(body.data);\n if (!parsed.success) {\n throw networkError(\n `${host}/api/partner/catalog/public answered in a shape this CLI does not read.`,\n `Run \"ekanos upgrade\" — the CLI and the host disagree on the catalog contract.`,\n );\n }\n return parsed.data;\n}\n"]}
|
package/dist/commands/add.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { harnessContractSources } from '../dev-experience.js';
|
|
2
2
|
import { invalidStateError, usageError } from '../errors.js';
|
|
3
3
|
import { defaultSources, resolveContract, } from '../experience/contract-sources.js';
|
|
4
|
+
import { hostContractSource, withHostBeforeSnapshots, } from '../experience/host-contract-source.js';
|
|
4
5
|
import { pinIntegration } from '../experience/pin-integration.js';
|
|
5
6
|
import { inContractOrder, readOperationIds, resolveOpTokens, } from '../experience/pin-ops.js';
|
|
6
7
|
import { DEPRECATED_USES } from '../experience/pins.js';
|
|
@@ -65,7 +66,7 @@ export const addCommand = {
|
|
|
65
66
|
fromDir: args.flags['from-dir'],
|
|
66
67
|
fromPath: args.flags['from-path'],
|
|
67
68
|
env: args.env,
|
|
68
|
-
}, await harnessContractSources(project.dir, args.env));
|
|
69
|
+
}, withHostBeforeSnapshots(await harnessContractSources(project.dir, args.env), hostContractSource({ ctx, env: args.env, projectDir: project.dir })));
|
|
69
70
|
const { contract, origin } = await resolveContract(sources, integration, version);
|
|
70
71
|
const existing = project.integrations.find((u) => u.name === integration);
|
|
71
72
|
if (existing && existing.version !== version) {
|
package/dist/commands/add.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|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E7D,MAAM,OAAO,GACX,mBAAmB;YACnB,IAAI,CAAC,eAAe;YACpB,IAAI,CAAC,WAAW;YAChB,YAAY,CAAC;QACf,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CACtC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,MAAM,KAAK,OAAO,CAAC,CACxE,CAAC;QAEF,OAAO,GAAG,CAAC,OAAO,CAChB;YACE,WAAW;YACX,OAAO;YACP,eAAe,EAAE,QAAQ,CAAC,eAAe;YACzC,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,UAAU;YACV,MAAM;YACN,MAAM;YACN,OAAO;YACP,KAAK,EAAE;gBACL,mBAAmB;gBACnB,eAAe,EAAE,IAAI,CAAC,eAAe;gBACrC,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,YAAY;aACb;SACF,EACD,OAAO;YACL,CAAC,CAAC,sBAAsB,WAAW,MAAM,WAAW,IAAI,OAAO,cAAc,QAAQ,CAAC,eAAe,UAAU,UAAU,CAAC,MAAM,aAAa,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG;YACrQ,CAAC,CAAC,gBAAgB,WAAW,6CAA6C,CAC7E,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import type { IntegrationEntry } from '@ekanos/integration-schema';\n\nimport { harnessContractSources } from '../dev-experience';\nimport { invalidStateError, usageError } from '../errors';\nimport {\n defaultSources,\n resolveContract,\n} from '../experience/contract-sources';\nimport { pinIntegration } from '../experience/pin-integration';\nimport {\n inContractOrder,\n readOperationIds,\n resolveOpTokens,\n} from '../experience/pin-ops';\nimport { DEPRECATED_USES } from '../experience/pins';\nimport {\n readExperienceProject,\n writeIntegrations,\n} from '../experience/project';\nimport { loadPins, regenerateIntegrations } from '../experience/regenerate';\nimport type { ExperienceCommand } from './index-experience';\n\nconst SPEC =\n /^((?:[a-z][a-z0-9]*(?:-[a-z0-9]+)*\\/)?[a-z][a-z0-9-]*)@(\\d+(?:\\.\\d+)?(?:\\.\\d+(?:[-+][0-9A-Za-z.-]+)?)?)$/;\n\n/** `1.2.3` (or `1.2.3-rc.1`) pins by its compat line, `1.2`; `0.x` lines keep minor. */\nfunction toCompatLine(version: string): string {\n return version.split(/[-+]/)[0]!.split('.').slice(0, 2).join('.');\n}\n\nexport const addCommand: ExperienceCommand = {\n name: 'add',\n usage: [\n ' add Add an integration to an experience: pin its contract,',\n ' record it in ekanos.json + ekanos.lock.json, regenerate types',\n ' (add <integration>@<version> [--ops a,b] [--from-dir <dir>])',\n ],\n positionals: ['spec'],\n specs: {\n dir: {\n type: 'string',\n description: 'Project directory (default: the current one)',\n },\n ops: {\n type: 'string',\n description:\n 'Operations to allow, comma-separated (tool/name, action/name or a unique bare name). On a new integration the list is exactly the operations named; prefix a name with + (e.g. +action/create-draft) to add it to the default, every read operation. With no --ops a new integration gets every read. On an existing pin the list is added to what is already allowed.',\n },\n as: {\n type: 'string',\n description:\n 'Removed: an experience addresses an integration by its own name',\n },\n 'from-dir': {\n type: 'string',\n description:\n 'Directory of <integration>.contract.json files (the contract source)',\n },\n 'from-path': {\n type: 'string',\n description:\n 'An integration project directory whose contract.json to pin',\n },\n },\n async run(ctx, args) {\n const spec = args.positionals[0];\n const match = spec ? SPEC.exec(spec) : null;\n if (!match) {\n throw usageError(\n spec\n ? `\"${spec}\" is not <integration>@<major>.<minor>.`\n : 'add needs <integration>@<major>.<minor>.',\n 'Pins are by compat line, e.g. \"ekanos add sanity@0.2 --from-dir ../contracts\".',\n );\n }\n const [, integration, rawVersion] = match as unknown as [\n string,\n string,\n string,\n ];\n const version = toCompatLine(rawVersion);\n if (version !== rawVersion) {\n ctx.warn(\n `Pins are by compat line: using ${integration}@${version} (from ${rawVersion}).`,\n );\n }\n if (args.flags.as !== undefined) {\n throw usageError(\n '--as is gone: an experience addresses an integration by its own name.',\n `Use \"${integration}\" in useOperation('${integration}', ...).`,\n );\n }\n\n const project = readExperienceProject(args.dir);\n if (project.deprecatedUses) ctx.warn(DEPRECATED_USES);\n const sources = defaultSources(\n project,\n {\n fromDir: args.flags['from-dir'] as string | undefined,\n fromPath: args.flags['from-path'] as string | undefined,\n env: args.env,\n },\n await harnessContractSources(project.dir, args.env),\n );\n const { contract, origin } = await resolveContract(\n sources,\n integration,\n version,\n );\n\n const existing = project.integrations.find((u) => u.name === integration);\n if (existing && existing.version !== version) {\n throw invalidStateError(\n `Integration \"${integration}\" is already pinned at ${existing.version}.`,\n `Move it to ${version} by editing its \"version\" in ekanos.json, then run \"ekanos sync\".`,\n );\n }\n\n const requested = ((args.flags.ops as string | undefined) ?? '')\n .split(',')\n .map((t) => t.trim())\n .filter(Boolean);\n const withDefaults = requested.some((t) => t.startsWith('+'));\n const explicit = resolveOpTokens(\n contract,\n requested.map((t) => t.replace(/^\\+/, '')),\n );\n const base = existing\n ? existing.operations\n : requested.length === 0 || withDefaults\n ? readOperationIds(contract)\n : [];\n const operations = inContractOrder(contract, [...base, ...explicit]);\n if (operations.length === 0) {\n throw usageError(\n `${integration}@${version} has no read operations to allow by default.`,\n 'Pass --ops <tool/name,...> to choose operations.',\n );\n }\n\n const entry: IntegrationEntry = {\n name: integration,\n version,\n operations,\n required: existing?.required ?? 'required',\n modes: existing?.modes ?? ['team'],\n };\n const integrations = existing\n ? project.integrations.map((u) => (u.name === integration ? entry : u))\n : [...project.integrations, entry];\n const integrationsChanged = writeIntegrations(project, integrations);\n\n const updated = { ...project, integrations };\n const pins = pinIntegration(updated, entry, contract);\n const { pinned } = loadPins(updated);\n const typesChanged = regenerateIntegrations(updated, pinned);\n\n const changed =\n integrationsChanged ||\n pins.snapshotChanged ||\n pins.lockChanged ||\n typesChanged;\n const writes = operations.filter((id) =>\n contract.operations.find((op) => op.id === id && op.effect === 'write'),\n );\n\n return ctx.succeed(\n {\n integration,\n version,\n contractVersion: contract.contractVersion,\n digest: contract.digest,\n operations,\n writes,\n origin,\n changed,\n files: {\n integrationsChanged,\n snapshotChanged: pins.snapshotChanged,\n lockChanged: pins.lockChanged,\n typesChanged,\n },\n },\n changed\n ? `Added integration \"${integration}\" (${integration}@${version}, contract ${contract.contractVersion}) with ${operations.length} operation${operations.length === 1 ? '' : 's'}${writes.length ? `, ${writes.length} write${writes.length === 1 ? '' : 's'}` : ''}.`\n : `Integration \"${integration}\" is already up to date (no files changed).`,\n );\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"add.js","sourceRoot":"","sources":["../../src/commands/add.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EACL,cAAc,EACd,eAAe,GAChB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EACL,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAG5E,MAAM,IAAI,GACR,0GAA0G,CAAC;AAE7G,wFAAwF;AACxF,SAAS,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YACN,OAAO;YACP,KAAK,EAAE;gBACL,mBAAmB;gBACnB,eAAe,EAAE,IAAI,CAAC,eAAe;gBACrC,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,YAAY;aACb;SACF,EACD,OAAO;YACL,CAAC,CAAC,sBAAsB,WAAW,MAAM,WAAW,IAAI,OAAO,cAAc,QAAQ,CAAC,eAAe,UAAU,UAAU,CAAC,MAAM,aAAa,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG;YACrQ,CAAC,CAAC,gBAAgB,WAAW,6CAA6C,CAC7E,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import type { IntegrationEntry } from '@ekanos/integration-schema';\n\nimport { harnessContractSources } from '../dev-experience';\nimport { invalidStateError, usageError } from '../errors';\nimport {\n defaultSources,\n resolveContract,\n} from '../experience/contract-sources';\nimport {\n hostContractSource,\n withHostBeforeSnapshots,\n} from '../experience/host-contract-source';\nimport { pinIntegration } from '../experience/pin-integration';\nimport {\n inContractOrder,\n readOperationIds,\n resolveOpTokens,\n} from '../experience/pin-ops';\nimport { DEPRECATED_USES } from '../experience/pins';\nimport {\n readExperienceProject,\n writeIntegrations,\n} from '../experience/project';\nimport { loadPins, regenerateIntegrations } from '../experience/regenerate';\nimport type { ExperienceCommand } from './index-experience';\n\nconst SPEC =\n /^((?:[a-z][a-z0-9]*(?:-[a-z0-9]+)*\\/)?[a-z][a-z0-9-]*)@(\\d+(?:\\.\\d+)?(?:\\.\\d+(?:[-+][0-9A-Za-z.-]+)?)?)$/;\n\n/** `1.2.3` (or `1.2.3-rc.1`) pins by its compat line, `1.2`; `0.x` lines keep minor. */\nfunction toCompatLine(version: string): string {\n return version.split(/[-+]/)[0]!.split('.').slice(0, 2).join('.');\n}\n\nexport const addCommand: ExperienceCommand = {\n name: 'add',\n usage: [\n ' add Add an integration to an experience: pin its contract,',\n ' record it in ekanos.json + ekanos.lock.json, regenerate types',\n ' (add <integration>@<version> [--ops a,b] [--from-dir <dir>])',\n ],\n positionals: ['spec'],\n specs: {\n dir: {\n type: 'string',\n description: 'Project directory (default: the current one)',\n },\n ops: {\n type: 'string',\n description:\n 'Operations to allow, comma-separated (tool/name, action/name or a unique bare name). On a new integration the list is exactly the operations named; prefix a name with + (e.g. +action/create-draft) to add it to the default, every read operation. With no --ops a new integration gets every read. On an existing pin the list is added to what is already allowed.',\n },\n as: {\n type: 'string',\n description:\n 'Removed: an experience addresses an integration by its own name',\n },\n 'from-dir': {\n type: 'string',\n description:\n 'Directory of <integration>.contract.json files (the contract source)',\n },\n 'from-path': {\n type: 'string',\n description:\n 'An integration project directory whose contract.json to pin',\n },\n },\n async run(ctx, args) {\n const spec = args.positionals[0];\n const match = spec ? SPEC.exec(spec) : null;\n if (!match) {\n throw usageError(\n spec\n ? `\"${spec}\" is not <integration>@<major>.<minor>.`\n : 'add needs <integration>@<major>.<minor>.',\n 'Pins are by compat line, e.g. \"ekanos add sanity@0.2 --from-dir ../contracts\".',\n );\n }\n const [, integration, rawVersion] = match as unknown as [\n string,\n string,\n string,\n ];\n const version = toCompatLine(rawVersion);\n if (version !== rawVersion) {\n ctx.warn(\n `Pins are by compat line: using ${integration}@${version} (from ${rawVersion}).`,\n );\n }\n if (args.flags.as !== undefined) {\n throw usageError(\n '--as is gone: an experience addresses an integration by its own name.',\n `Use \"${integration}\" in useOperation('${integration}', ...).`,\n );\n }\n\n const project = readExperienceProject(args.dir);\n if (project.deprecatedUses) ctx.warn(DEPRECATED_USES);\n const sources = defaultSources(\n project,\n {\n fromDir: args.flags['from-dir'] as string | undefined,\n fromPath: args.flags['from-path'] as string | undefined,\n env: args.env,\n },\n withHostBeforeSnapshots(\n await harnessContractSources(project.dir, args.env),\n hostContractSource({ ctx, env: args.env, projectDir: project.dir }),\n ),\n );\n const { contract, origin } = await resolveContract(\n sources,\n integration,\n version,\n );\n\n const existing = project.integrations.find((u) => u.name === integration);\n if (existing && existing.version !== version) {\n throw invalidStateError(\n `Integration \"${integration}\" is already pinned at ${existing.version}.`,\n `Move it to ${version} by editing its \"version\" in ekanos.json, then run \"ekanos sync\".`,\n );\n }\n\n const requested = ((args.flags.ops as string | undefined) ?? '')\n .split(',')\n .map((t) => t.trim())\n .filter(Boolean);\n const withDefaults = requested.some((t) => t.startsWith('+'));\n const explicit = resolveOpTokens(\n contract,\n requested.map((t) => t.replace(/^\\+/, '')),\n );\n const base = existing\n ? existing.operations\n : requested.length === 0 || withDefaults\n ? readOperationIds(contract)\n : [];\n const operations = inContractOrder(contract, [...base, ...explicit]);\n if (operations.length === 0) {\n throw usageError(\n `${integration}@${version} has no read operations to allow by default.`,\n 'Pass --ops <tool/name,...> to choose operations.',\n );\n }\n\n const entry: IntegrationEntry = {\n name: integration,\n version,\n operations,\n required: existing?.required ?? 'required',\n modes: existing?.modes ?? ['team'],\n };\n const integrations = existing\n ? project.integrations.map((u) => (u.name === integration ? entry : u))\n : [...project.integrations, entry];\n const integrationsChanged = writeIntegrations(project, integrations);\n\n const updated = { ...project, integrations };\n const pins = pinIntegration(updated, entry, contract);\n const { pinned } = loadPins(updated);\n const typesChanged = regenerateIntegrations(updated, pinned);\n\n const changed =\n integrationsChanged ||\n pins.snapshotChanged ||\n pins.lockChanged ||\n typesChanged;\n const writes = operations.filter((id) =>\n contract.operations.find((op) => op.id === id && op.effect === 'write'),\n );\n\n return ctx.succeed(\n {\n integration,\n version,\n contractVersion: contract.contractVersion,\n digest: contract.digest,\n operations,\n writes,\n origin,\n changed,\n files: {\n integrationsChanged,\n snapshotChanged: pins.snapshotChanged,\n lockChanged: pins.lockChanged,\n typesChanged,\n },\n },\n changed\n ? `Added integration \"${integration}\" (${integration}@${version}, contract ${contract.contractVersion}) with ${operations.length} operation${operations.length === 1 ? '' : 's'}${writes.length ? `, ${writes.length} write${writes.length === 1 ? '' : 's'}` : ''}.`\n : `Integration \"${integration}\" is already up to date (no files changed).`,\n );\n },\n};\n"]}
|
package/dist/commands/apps.js
CHANGED
|
@@ -4,6 +4,7 @@ import { refreshStoredSession, requireSession, resolveAuthEnvironment, } from '.
|
|
|
4
4
|
import { deleteConnection, listConnections, showConnection, startConnection, } from '../connections-api.js';
|
|
5
5
|
import { authRequiredError, invalidStateError, usageError, validationError, } from '../errors.js';
|
|
6
6
|
import { cli } from '../invocation.js';
|
|
7
|
+
import { PRODUCT_SLUG_SHAPE, isProductSlug } from '../product-slug.js';
|
|
7
8
|
import { collectSecrets, parsePlainValues, readSecretFlags, secretInputGiven, } from '../secret-input.js';
|
|
8
9
|
import { resolveSourceTarget } from '../source-target.js';
|
|
9
10
|
import { promptYesNo } from './publish.js';
|
|
@@ -456,11 +457,12 @@ function parseSubcommand(value) {
|
|
|
456
457
|
}
|
|
457
458
|
function requireProduct(value, verb) {
|
|
458
459
|
const slug = value === null || value === void 0 ? void 0 : value.trim().toLowerCase();
|
|
459
|
-
if (slug &&
|
|
460
|
+
if (slug && isProductSlug(slug))
|
|
460
461
|
return slug;
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
462
|
+
if (value) {
|
|
463
|
+
throw usageError(`"${value}" is not a product slug.`, `${PRODUCT_SLUG_SHAPE} "ekanos catalog" lists them.`);
|
|
464
|
+
}
|
|
465
|
+
throw usageError(`apps ${verb} needs a product.`, `Pass the product's slug, e.g. "ekanos apps ${verb} linear". "ekanos catalog" lists them.`);
|
|
464
466
|
}
|
|
465
467
|
export async function promptLine(question) {
|
|
466
468
|
const readline = await import('node:readline/promises');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apps.js","sourceRoot":"","sources":["../../src/commands/apps.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,cAAc,EACd,e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AAC,WAAW,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["import type { ProviderAppStatus } from '@ekanos/integration-schema';\n\nimport {\n type AppsApiResult,\n setProviderApp,\n showProviderApp,\n} from '../apps-api';\nimport type { StoredSession } from '../auth/credential-store';\nimport { loginHint } from '../auth/host-trust';\nimport {\n type AuthEnvironment,\n refreshStoredSession,\n requireSession,\n resolveAuthEnvironment,\n} from '../auth/session';\nimport {\n type ConnectionsApiResult,\n type SourceConnection,\n deleteConnection,\n listConnections,\n showConnection,\n startConnection,\n} from '../connections-api';\nimport type { CliContext } from '../context';\nimport {\n authRequiredError,\n invalidStateError,\n usageError,\n validationError,\n} from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { cli } from '../invocation';\nimport {\n type SecretIO,\n collectSecrets,\n parsePlainValues,\n readSecretFlags,\n secretInputGiven,\n} from '../secret-input';\nimport { resolveSourceTarget } from '../source-target';\nimport type { ResultRow } from '../ui';\nimport { promptYesNo } from './publish';\n\nexport const APPS_SUBCOMMANDS = [\n 'show',\n 'set',\n 'list',\n 'connect',\n 'disconnect',\n] as const;\ntype AppsSubcommand = (typeof APPS_SUBCOMMANDS)[number];\n\nexport interface AppsArgs {\n host?: string;\n source?: string;\n subcommand?: string;\n product?: string;\n dir: string;\n env: Record<string, string | undefined>;\n stdinIsTTY?: boolean;\n /** Test seams for the questions `set` and `connect` ask. */\n ask?: (question: string) => Promise<string>;\n askSecret?: (question: string) => Promise<string>;\n confirm?: (question: string) => Promise<boolean>;\n /** Test seam: `connect`'s wait between status polls. */\n pollDelayMs?: number;\n /** `connect --no-wait`: print the URL and return without polling. */\n noWait?: boolean;\n /** `disconnect --yes`: confirm without the question (a script, an agent run). */\n yes?: boolean;\n /** Every parsed flag: the secret-input flags and `set --set clientId=…`. */\n flags?: Record<string, string | boolean | string[]>;\n /** Test seams for the secret-input flags (`secret-input.ts`). */\n readStdin?: () => Promise<string>;\n openUrl?: (url: string) => void;\n secretFormTimeoutMs?: number;\n}\n\n/**\n * `apps` — a Source's provider apps: the OAuth client an integration signs\n * every team in through (Linear's, say). `show` says whether the Source has\n * one and which callback URL to register; `set` takes the client id and\n * secret — either on its own, the other keeping its saved value — at the\n * terminal with hidden input, or, with no terminal, from `--set clientId=…`\n * and the secret-input flags (`--secret-env`, `--secret-file`,\n * `--secret-stdin`, `--browser`; see `secret-input.ts`). Never as a value in\n * argv, so it lands in no shell history and no agent's context.\n */\nexport async function runApps(\n ctx: CliContext,\n args: AppsArgs,\n): Promise<ExitCode> {\n const subcommand = parseSubcommand(args.subcommand);\n if (subcommand === 'list') return runList(ctx, args);\n const product = requireProduct(args.product, subcommand);\n if (subcommand === 'connect' || subcommand === 'disconnect') {\n return runConnection(ctx, args, subcommand, product);\n }\n\n const secret = readSecretFlags(args.flags);\n const plain =\n subcommand === 'set'\n ? parsePlainValues(args.flags?.set, 'clientId=abc123')\n : {};\n for (const name of Object.keys(plain)) {\n if (name === 'clientId') continue;\n throw usageError(\n name === 'clientSecret'\n ? 'clientSecret is a secret: it is never passed as an argument.'\n : '--set takes clientId=<id> here; the client secret has flags of its own.',\n 'Pass the secret with --secret-env <NAME>, --secret-file <path>, --secret-stdin or --browser.',\n );\n }\n const again = `apps set ${product}${args.source ? ` --source ${args.source}` : ''}`;\n const interactive = canPrompt(ctx, args);\n if (\n subcommand === 'set' &&\n !interactive &&\n !secretInputGiven(secret) &&\n Object.keys(plain).length === 0\n ) {\n throw usageError(\n SET_REFUSAL,\n `Without a terminal, pass --set clientId=<id> and the secret as --secret-env <NAME>, --secret-file <path>, --secret-stdin, or --browser (a form in your browser on this computer). Or run it yourself in your terminal: ${cli()} ${again}`,\n );\n }\n\n const env = resolveAuthEnvironment(ctx, args.host, args.env, {\n projectDir: args.dir,\n });\n const resolved = await resolveSourceTarget(env, requireSession(env), args);\n const client = new AppsClient(env, resolved.session);\n const source = resolved.source;\n\n if (subcommand === 'show') {\n return showApp(ctx, env.host, client, source, product);\n }\n\n const status = await client.call((token) =>\n showProviderApp(env.host, token, source, product),\n );\n\n ctx.log(walkthrough(status).join('\\n'));\n\n // Either credential on its own: Enter keeps what is saved. An older host\n // sends no `fields`; then `configured` says whether both are saved.\n const saved = (name: 'clientId' | 'clientSecret') =>\n status.fields?.find((field) => field.name === name) ?? {\n set: status.configured,\n value: null,\n };\n const savedId = saved('clientId');\n const savedSecret = saved('clientSecret');\n const fields = [\n {\n name: 'clientId',\n label: 'Client ID',\n sensitive: false,\n set: savedId.set,\n value: savedId.value ?? null,\n },\n {\n name: 'clientSecret',\n label: 'Client secret',\n sensitive: true,\n set: savedSecret.set,\n },\n ];\n const collected = await collectSecrets(ctx, {\n fields,\n plain,\n flags: secret,\n io: secretIO(args),\n interactive,\n title: `the ${status.product.name} app on ${status.source.slug}`,\n refusal: SET_REFUSAL,\n again,\n prompt: (field) =>\n field.sensitive\n ? (args.askSecret ?? promptHidden)(\n savedSecret.set\n ? 'Client secret (saved — Enter to keep, hidden): '\n : 'Client secret (hidden): ',\n )\n : (args.ask ?? promptLine)(\n savedId.set\n ? `Client ID (current: ${savedId.value ?? 'saved'} — Enter to keep): `\n : 'Client ID: ',\n ),\n });\n const clientId = collected.clientId ?? '';\n const clientSecret = collected.clientSecret ?? '';\n if (!clientId && !clientSecret) {\n throw validationError(\n 'Nothing was changed.',\n `Run \"ekanos apps show ${product}\" to see the current state.`,\n );\n }\n\n const result = await client.call((token) =>\n setProviderApp(env.host, token, {\n source,\n product,\n ...(clientId ? { clientId } : {}),\n ...(clientSecret ? { clientSecret } : {}),\n }),\n );\n return ctx.succeed(\n { host: env.host, ...result },\n ctx.ui.result({\n title: result.replaced\n ? `Updated the ${result.product.name} app`\n : `Set up the ${result.product.name} app`,\n rows: [\n ['Source', result.source.slug],\n ...providerFieldRows(result),\n ['Teams can connect', result.configured ? 'yes' : 'not yet'],\n ['Callback URLs', callbackUrls(result)],\n ],\n }),\n );\n}\n\n/**\n * How to create the app: the integration's own steps (`oauth.setup`, with the\n * callback URL filled in) when it declares them, else the generic three.\n */\nexport function walkthrough(status: ProviderAppStatus): string[] {\n const name = status.product.name;\n const lines = [`${name} app for ${status.source.slug}`];\n if (status.setup?.consoleUrl) {\n lines.push(` Open: ${status.setup.consoleUrl}`);\n }\n const steps = status.setup?.steps.length\n ? [\n ...status.setup.steps,\n `Check the app lists exactly: ${callbackUrls(status).join(', ')}`,\n ]\n : [\n `In ${name}, create an OAuth app (or open the one you use).`,\n `Register exactly these callback URLs: ${callbackUrls(status).join(', ')}`,\n ];\n steps.push(\n \"Enter its client ID and secret below. The secret is stored in Ekanos's vault and never shown again.\",\n );\n lines.push(...steps.map((step, index) => ` ${index + 1}. ${step}`));\n if (status.setup?.guideUrl) lines.push(` Guide: ${status.setup.guideUrl}`);\n return lines;\n}\n\nfunction summary(ctx: CliContext, status: ProviderAppStatus): string {\n const rows: ResultRow[] = [\n ['Source', status.source.slug],\n ...(status.setup\n ? ([\n [\n 'How to create it',\n [\n ...(status.setup.consoleUrl\n ? [`Open ${status.setup.consoleUrl}`]\n : []),\n ...status.setup.steps.map(\n (step, index) => `${index + 1}. ${step}`,\n ),\n ],\n ],\n ] as const)\n : []),\n ...providerFieldRows(status),\n [\n 'App ready',\n status.configured\n ? 'yes — teams can connect'\n : 'no — no team can connect yet',\n ],\n ['Callback URLs', callbackUrls(status)],\n ];\n return [\n ctx.ui.result({ title: `${status.product.name} app`, rows }),\n ...(status.configured\n ? []\n : [\n ctx.ui.hint(\n `Run \"ekanos apps set ${status.product.slug}\" in your terminal to enter its credentials.`,\n ),\n ]),\n ].join('\\n');\n}\n\n/**\n * `apps show <product>`: the Source provider app, and — for an integration\n * that supports one — the Source connection (plan 241). A `teamApp`\n * integration (Zendesk) has no provider app but can have a Source\n * connection, so either half may be absent.\n */\nasync function showApp(\n ctx: CliContext,\n host: string,\n client: AppsClient,\n source: string,\n product: string,\n): Promise<ExitCode> {\n const [app, connection] = await Promise.all([\n client\n .call((token) => showProviderApp(host, token, source, product))\n .then(\n (status) => ({ ok: true as const, status }),\n (error: unknown) => ({ ok: false as const, error }),\n ),\n // A host without the connections routes (before plan 241), or one that\n // refuses, leaves `show` exactly as it was: the provider app alone.\n client\n .connection((token) => showConnection(host, token, source, product))\n .catch(() => ({ status: 'unavailable' as const })),\n ]);\n\n if (!app.ok && connection.status !== 'ok') throw app.error;\n\n const parts: string[] = [];\n if (app.ok) parts.push(summary(ctx, app.status));\n if (connection.status === 'ok') {\n parts.push(\n connectionSummary(ctx, connection.data.connection, {\n sourceSlug: connection.data.source.slug,\n callbackUrls: connection.data.callbackUrls,\n }),\n );\n }\n\n return ctx.succeed(\n {\n host,\n ...(app.ok ? app.status : {}),\n ...(connection.status === 'ok'\n ? {\n sourceConnection: connection.data.connection,\n sourceConnectionCallbackUrls: connection.data.callbackUrls,\n }\n : {}),\n },\n parts.join('\\n'),\n );\n}\n\n/** `apps list`: every integration the Source can connect once, with status. */\nasync function runList(ctx: CliContext, args: AppsArgs): Promise<ExitCode> {\n const { env, client, source } = await openClient(ctx, args);\n const result = await client.connection((token) =>\n listConnections(env.host, token, source),\n );\n if (result.status !== 'ok') {\n throw invalidStateError(\n 'The host could not list the connections.',\n 'Retry shortly.',\n );\n }\n const { connections } = result.data;\n const rows: ResultRow[] = connections.map((connection) => [\n `${connection.name} (${connection.slug})`,\n connectionState(connection),\n ]);\n return ctx.succeed(\n { host: env.host, ...result.data },\n connections.length === 0\n ? ctx.ui.hint(\n `No integration on ${result.data.source.slug} supports one connection for the whole Source yet.`,\n )\n : ctx.ui.result({\n title: `Source connections on ${result.data.source.slug}`,\n rows,\n }),\n );\n}\n\nfunction connectionState(connection: SourceConnection): string {\n if (connection.connected) {\n return [\n 'connected',\n connection.connectedAt ? ` ${connection.connectedAt}` : '',\n connection.connectedBy ? ` by ${connection.connectedBy}` : '',\n ].join('');\n }\n return connection.missing.length > 0\n ? `not connected — app fields missing: ${connection.missing.join(', ')}`\n : 'not connected';\n}\n\n/**\n * `apps connect <product>`: connect the integration ONCE for the whole Source,\n * for the Source's provided agents whose template says `owner: \"source\"`.\n * Asks for any missing app fields at the terminal (secrets hidden, never from\n * a flag), prints the provider's consent URL, then waits until the browser\n * finishes. `apps disconnect <product>` removes it.\n */\nasync function runConnection(\n ctx: CliContext,\n args: AppsArgs,\n subcommand: 'connect' | 'disconnect',\n product: string,\n): Promise<ExitCode> {\n const { env, client, source } = await openClient(ctx, args);\n\n if (subcommand === 'disconnect') {\n return disconnect(ctx, args, client, env.host, source, product);\n }\n\n const shown = await client.connection((token) =>\n showConnection(env.host, token, source, product),\n );\n if (shown.status === 'unsupported') {\n throw invalidStateError(\n shown.message,\n `Each team connects ${product} itself: \"ekanos teams connect <team> ${product}\".`,\n );\n }\n if (shown.status !== 'ok') {\n throw invalidStateError(\n 'The host could not read the connection.',\n 'Retry shortly.',\n );\n }\n const current = shown.data.connection;\n\n if (current.app === 'fields') {\n ctx.log(\n [\n `${current.name} app for ${shown.data.source.slug} (one for the whole Source)`,\n ` Register this redirect URL in the app: ${shown.data.callbackUrls.join(', ')}`,\n ].join('\\n'),\n );\n }\n\n const fields = await askFields(ctx, args, current, product);\n\n const started = await client.connection((token) =>\n startConnection(env.host, token, {\n source,\n product,\n ...(Object.keys(fields).length > 0 ? { fields } : {}),\n }),\n );\n if (started.status === 'not-configured') {\n throw validationError(\n `${current.name} is not set up for the Source yet — missing: ${started.missing.join(', ')}.`,\n current.app === 'source-app'\n ? `Run \"ekanos apps set ${product}\" to enter the Source's app first.`\n : `Run \"ekanos apps connect ${product}\" again and fill every field.`,\n );\n }\n if (started.status !== 'ok') {\n throw invalidStateError(\n 'The host could not start the connection.',\n 'Retry shortly.',\n );\n }\n\n ctx.log(\n [\n `Open this link and approve ${current.name} as the account the Source's agents should act as:`,\n ` ${started.data.authorizeUrl}`,\n ].join('\\n'),\n );\n\n if (args.noWait || ctx.jsonMode) {\n return ctx.succeed(\n {\n host: env.host,\n product,\n authorizeUrl: started.data.authorizeUrl,\n callbackUrl: started.data.callbackUrl,\n connected: false,\n },\n ctx.ui.hint(`Then check with \"ekanos apps show ${product}\".`),\n );\n }\n\n const deadline = Date.now() + 10 * 60 * 1000;\n const before = current.connectedAt;\n while (Date.now() < deadline) {\n await new Promise((resolve) =>\n setTimeout(resolve, args.pollDelayMs ?? 3000),\n );\n const polled = await client.connection((token) =>\n showConnection(env.host, token, source, product),\n );\n if (\n polled.status === 'ok' &&\n polled.data.connection.connected &&\n polled.data.connection.connectedAt !== before\n ) {\n return ctx.succeed(\n { host: env.host, product, connection: polled.data.connection },\n connectionSummary(ctx, polled.data.connection, {\n sourceSlug: polled.data.source.slug,\n callbackUrls: polled.data.callbackUrls,\n }),\n );\n }\n }\n throw validationError(\n 'The connection did not finish within ten minutes.',\n `Run \"ekanos apps connect ${product}\" again for a fresh link.`,\n );\n}\n\nasync function askFields(\n ctx: CliContext,\n args: AppsArgs,\n current: SourceConnection,\n product: string,\n): Promise<Record<string, string>> {\n const toAsk = current.fields.filter(\n (field) => !field.set || current.missing.includes(field.name),\n );\n if (toAsk.length === 0) return {};\n return collectSecrets(ctx, {\n fields: toAsk.map((field) => ({\n name: field.name,\n label: field.label,\n sensitive: field.sensitive,\n ...(field.description ? { description: field.description } : {}),\n set: false,\n required: current.missing.includes(field.name),\n })),\n plain: parsePlainValues(args.flags?.set),\n flags: readSecretFlags(args.flags),\n io: secretIO(args),\n interactive: canPrompt(ctx, args),\n title: `${current.name}'s app for the whole Source`,\n refusal: `${current.name} needs its app fields entered for the Source (${toAsk.map((field) => `${field.label} [${field.name}]`).join(', ')}), and there is no terminal to ask at.`,\n again: `apps connect ${product}${args.source ? ` --source ${args.source}` : ''}`,\n prompt: (field) =>\n field.sensitive\n ? (args.askSecret ?? promptHidden)(`${field.label} (hidden): `)\n : (args.ask ?? promptLine)(`${field.label}: `),\n });\n}\n\nasync function disconnect(\n ctx: CliContext,\n args: AppsArgs,\n client: AppsClient,\n host: string,\n source: string,\n product: string,\n): Promise<ExitCode> {\n if (!args.yes && !canPrompt(ctx, args)) {\n throw invalidStateError(\n `Disconnecting ${product} on ${source} stops it for every team's provided agents that use the Source connection, until someone connects it again.`,\n `Re-run with --yes: ekanos apps disconnect ${product} --source ${source} --yes`,\n );\n }\n if (!args.yes) {\n const sure = await (args.confirm ?? promptYesNo)(\n `Disconnect ${product} for every team's provided agents on ${source}? [y/N]`,\n );\n if (!sure) {\n throw validationError(\n 'Nothing was changed.',\n `Run \"ekanos apps show ${product}\" to see the current state.`,\n );\n }\n }\n const result = await client.connection((token) =>\n deleteConnection(host, token, source, product),\n );\n if (result.status === 'unsupported') {\n throw invalidStateError(\n result.message,\n `Each team connects ${product} itself: \"ekanos teams connect <team> ${product}\".`,\n );\n }\n if (result.status !== 'ok') {\n throw invalidStateError('The host could not disconnect.', 'Retry shortly.');\n }\n return ctx.succeed(\n { host, product, ...result.data },\n ctx.ui.result({\n title: result.data.removed\n ? `Disconnected the ${product} Source connection on ${source}`\n : `${product} had no Source connection on ${source}`,\n rows: [\n [\n 'Provided agents',\n 'their tools for this product stop until you connect again',\n ],\n ],\n }),\n );\n}\n\nfunction connectionSummary(\n ctx: CliContext,\n connection: SourceConnection,\n meta: { sourceSlug: string; callbackUrls: string[] },\n): string {\n const rows: ResultRow[] = [\n ['Source', meta.sourceSlug],\n ['Connected', connectionState(connection)],\n ...(connection.scope ? ([['Scope', connection.scope]] as ResultRow[]) : []),\n ...(connection.fields.length > 0\n ? ([\n [\n 'App fields',\n connection.fields.map(\n (field) =>\n `${field.label}: ${field.set ? (field.value ?? 'set') : 'missing'}`,\n ),\n ],\n ] as ResultRow[])\n : []),\n ['Redirect URL', meta.callbackUrls],\n [\n 'Used by',\n `provided agents whose template says connections.${connection.slug}.owner: \"source\", in every team`,\n ],\n ];\n return [\n ctx.ui.result({\n title: `${connection.name} — Source connection (one for every team's provided agents)`,\n rows,\n }),\n ...(connection.connected\n ? []\n : [\n ctx.ui.hint(\n `Run \"ekanos apps connect ${connection.slug}\" in your terminal to connect it.`,\n ),\n ]),\n ].join('\\n');\n}\n\nasync function openClient(ctx: CliContext, args: AppsArgs) {\n const env = resolveAuthEnvironment(ctx, args.host, args.env, {\n projectDir: args.dir,\n });\n const resolved = await resolveSourceTarget(env, requireSession(env), args);\n return {\n env,\n client: new AppsClient(env, resolved.session),\n source: resolved.source,\n };\n}\n\nclass AppsClient {\n constructor(\n private readonly env: AuthEnvironment,\n private session: StoredSession,\n ) {}\n\n async call<T>(\n send: (accessToken: string) => Promise<AppsApiResult<T>>,\n ): Promise<T> {\n let result = await send(this.session.accessToken);\n if (result.status === 'unauthorized') {\n this.session = await refreshStoredSession(this.env, this.session);\n result = await send(this.session.accessToken);\n }\n if (result.status === 'ok') return result.data;\n throw authRequiredError(\n `The session for ${this.env.host} could not authorize the apps call.`,\n loginHint(this.env),\n );\n }\n\n /** As `call`, for the connections client, whose 409s are answers. */\n async connection<T>(\n send: (accessToken: string) => Promise<ConnectionsApiResult<T>>,\n ): Promise<Exclude<ConnectionsApiResult<T>, { status: 'unauthorized' }>> {\n let result = await send(this.session.accessToken);\n if (result.status === 'unauthorized') {\n this.session = await refreshStoredSession(this.env, this.session);\n result = await send(this.session.accessToken);\n }\n if (result.status !== 'unauthorized') return result;\n throw authRequiredError(\n `The session for ${this.env.host} could not authorize the connections call.`,\n loginHint(this.env),\n );\n }\n}\n\nfunction canPrompt(ctx: CliContext, args: AppsArgs): boolean {\n return !ctx.jsonMode && (args.stdinIsTTY ?? process.stdin.isTTY === true);\n}\n\nconst SET_REFUSAL =\n 'apps set needs the client secret, and there is no terminal to ask at.';\n\nfunction secretIO(args: AppsArgs): SecretIO {\n return {\n env: args.env,\n stdinIsTTY: args.stdinIsTTY ?? process.stdin.isTTY === true,\n readStdin: args.readStdin,\n openUrl: args.openUrl,\n formTimeoutMs: args.secretFormTimeoutMs,\n };\n}\n\nfunction parseSubcommand(value: string | undefined): AppsSubcommand {\n const match = APPS_SUBCOMMANDS.find((name) => name === value);\n if (match) return match;\n throw usageError(\n value ? `Unknown apps subcommand \"${value}\".` : 'apps needs a subcommand.',\n `Run one of: ${APPS_SUBCOMMANDS.map((name) => `ekanos apps ${name} <product>`).join(', ')}.`,\n );\n}\n\nfunction requireProduct(value: string | undefined, verb: string): string {\n const slug = value?.trim().toLowerCase();\n if (slug && /^[a-z0-9][a-z0-9-]*$/.test(slug)) return slug;\n throw usageError(\n value\n ? `\"${value}\" is not a product slug.`\n : `apps ${verb} needs a product.`,\n `Pass the product's slug, e.g. \"ekanos apps ${verb} linear\". \"ekanos catalog\" lists them.`,\n );\n}\n\nexport async function promptLine(question: string): Promise<string> {\n const readline = await import('node:readline/promises');\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stderr,\n });\n try {\n return await rl.question(question);\n } finally {\n rl.close();\n }\n}\n\n/**\n * Read a line without echoing it: the secret never appears on screen or in\n * scrollback. The question is always printed; only the typed characters are\n * hidden (each shows as `*`, so a paste visibly landed).\n *\n * Raw mode by hand rather than readline: a terminal readline redraws its\n * line on `question()` — cursor to column 0, clear to the end of the screen —\n * which erased the question written before it, so the terminal sat on an\n * empty line and a hidden field looked skipped.\n */\nexport async function promptHidden(question: string): Promise<string> {\n const stdin = process.stdin;\n const stderr = process.stderr;\n stderr.write(question);\n\n if (!stdin.isTTY) {\n // Piped stdin echoes nothing: read one line as is.\n const readline = await import('node:readline/promises');\n const rl = readline.createInterface({ input: stdin, terminal: false });\n try {\n return await rl.question('');\n } finally {\n rl.close();\n stderr.write('\\n');\n }\n }\n\n return new Promise<string>((resolve) => {\n let value = '';\n let inEscape = false;\n const wasRaw = stdin.isRaw;\n const finish = () => {\n stdin.off('data', onData);\n stdin.setRawMode(wasRaw);\n stdin.pause();\n stderr.write('\\n');\n };\n const onData = (chunk: Buffer | string) => {\n for (const char of typeof chunk === 'string'\n ? chunk\n : chunk.toString('utf8')) {\n if (inEscape) {\n // An escape sequence (an arrow key) ends at its final letter.\n if (/[A-Za-z~]/.test(char)) inEscape = false;\n continue;\n }\n if (char === '\\u001b') {\n inEscape = true;\n continue;\n }\n if (char === '\\r' || char === '\\n' || char === '\\u0004') {\n finish();\n resolve(value);\n return;\n }\n if (char === '\\u0003') {\n // Ctrl-C: raw mode swallowed the signal, so leave as SIGINT would.\n finish();\n process.exit(130);\n }\n if (char === '\\u007f' || char === '\\b') {\n if (value.length > 0) {\n value = value.slice(0, -1);\n stderr.write('\\b \\b');\n }\n continue;\n }\n if (char === '\\u0015') {\n // Ctrl-U: clear what was typed.\n stderr.write('\\b \\b'.repeat(value.length));\n value = '';\n continue;\n }\n if (char < ' ') continue;\n value += char;\n stderr.write('*');\n }\n };\n stdin.setRawMode(true);\n stdin.resume();\n stdin.on('data', onData);\n });\n}\n\n/** Each credential's state: the client id's value, the secret as saved or not. */\nfunction providerFieldRows(status: ProviderAppStatus): ResultRow[] {\n return (status.fields ?? []).map((field) => [\n field.label,\n !field.set\n ? 'not set'\n : field.sensitive\n ? 'saved'\n : (field.value ?? 'saved'),\n ]);\n}\n\n/** Every redirect URI to register; an older host sends only the one. */\nfunction callbackUrls(status: ProviderAppStatus): string[] {\n return status.callbackUrls?.length\n ? status.callbackUrls\n : [status.callbackUrl];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"apps.js","sourceRoot":"","sources":["../../src/commands/apps.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,cAAc,EACd,eAAe,GAChB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAEL,oBAAoB,EACpB,cAAc,EACd,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAGL,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EACV,eAAe,GAChB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACp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ACX,CAAC;gBACD,IAAI,IAAI,GAAG,GAAG;oBAAE,SAAS;gBACzB,KAAK,IAAI,IAAI,CAAC;gBACd,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACpB,CAAC;QACH,CAAC,CAAC;QACF,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACvB,KAAK,CAAC,MAAM,EAAE,CAAC;QACf,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;AACL,CAAC;AAED,kFAAkF;AAClF,SAAS,iBAAiB,CAAC,MAAyB;;IAClD,OAAO,OAAC,MAAM,CAAC,MAAM,mCAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,kBAAC;QAC1C,KAAK,CAAC,KAAK;QACX,CAAC,KAAK,CAAC,GAAG;YACR,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,KAAK,CAAC,SAAS;gBACf,CAAC,CAAC,OAAO;gBACT,CAAC,CAAC,OAAC,KAAK,CAAC,KAAK,mCAAI,OAAO,CAAC;KAC/B,GAAA,CAAC,CAAC;AACL,CAAC;AAED,wEAAwE;AACxE,SAAS,YAAY,CAAC,MAAyB;;IAC7C,OAAO,CAAA,MAAA,MAAM,CAAC,YAAY,0CAAE,MAAM;QAChC,CAAC,CAAC,MAAM,CAAC,YAAY;QACrB,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["import type { ProviderAppStatus } from '@ekanos/integration-schema';\n\nimport {\n type AppsApiResult,\n setProviderApp,\n showProviderApp,\n} from '../apps-api';\nimport type { StoredSession } from '../auth/credential-store';\nimport { loginHint } from '../auth/host-trust';\nimport {\n type AuthEnvironment,\n refreshStoredSession,\n requireSession,\n resolveAuthEnvironment,\n} from '../auth/session';\nimport {\n type ConnectionsApiResult,\n type SourceConnection,\n deleteConnection,\n listConnections,\n showConnection,\n startConnection,\n} from '../connections-api';\nimport type { CliContext } from '../context';\nimport {\n authRequiredError,\n invalidStateError,\n usageError,\n validationError,\n} from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { cli } from '../invocation';\nimport { PRODUCT_SLUG_SHAPE, isProductSlug } from '../product-slug';\nimport {\n type SecretIO,\n collectSecrets,\n parsePlainValues,\n readSecretFlags,\n secretInputGiven,\n} from '../secret-input';\nimport { resolveSourceTarget } from '../source-target';\nimport type { ResultRow } from '../ui';\nimport { promptYesNo } from './publish';\n\nexport const APPS_SUBCOMMANDS = [\n 'show',\n 'set',\n 'list',\n 'connect',\n 'disconnect',\n] as const;\ntype AppsSubcommand = (typeof APPS_SUBCOMMANDS)[number];\n\nexport interface AppsArgs {\n host?: string;\n source?: string;\n subcommand?: string;\n product?: string;\n dir: string;\n env: Record<string, string | undefined>;\n stdinIsTTY?: boolean;\n /** Test seams for the questions `set` and `connect` ask. */\n ask?: (question: string) => Promise<string>;\n askSecret?: (question: string) => Promise<string>;\n confirm?: (question: string) => Promise<boolean>;\n /** Test seam: `connect`'s wait between status polls. */\n pollDelayMs?: number;\n /** `connect --no-wait`: print the URL and return without polling. */\n noWait?: boolean;\n /** `disconnect --yes`: confirm without the question (a script, an agent run). */\n yes?: boolean;\n /** Every parsed flag: the secret-input flags and `set --set clientId=…`. */\n flags?: Record<string, string | boolean | string[]>;\n /** Test seams for the secret-input flags (`secret-input.ts`). */\n readStdin?: () => Promise<string>;\n openUrl?: (url: string) => void;\n secretFormTimeoutMs?: number;\n}\n\n/**\n * `apps` — a Source's provider apps: the OAuth client an integration signs\n * every team in through (Linear's, say). `show` says whether the Source has\n * one and which callback URL to register; `set` takes the client id and\n * secret — either on its own, the other keeping its saved value — at the\n * terminal with hidden input, or, with no terminal, from `--set clientId=…`\n * and the secret-input flags (`--secret-env`, `--secret-file`,\n * `--secret-stdin`, `--browser`; see `secret-input.ts`). Never as a value in\n * argv, so it lands in no shell history and no agent's context.\n */\nexport async function runApps(\n ctx: CliContext,\n args: AppsArgs,\n): Promise<ExitCode> {\n const subcommand = parseSubcommand(args.subcommand);\n if (subcommand === 'list') return runList(ctx, args);\n const product = requireProduct(args.product, subcommand);\n if (subcommand === 'connect' || subcommand === 'disconnect') {\n return runConnection(ctx, args, subcommand, product);\n }\n\n const secret = readSecretFlags(args.flags);\n const plain =\n subcommand === 'set'\n ? parsePlainValues(args.flags?.set, 'clientId=abc123')\n : {};\n for (const name of Object.keys(plain)) {\n if (name === 'clientId') continue;\n throw usageError(\n name === 'clientSecret'\n ? 'clientSecret is a secret: it is never passed as an argument.'\n : '--set takes clientId=<id> here; the client secret has flags of its own.',\n 'Pass the secret with --secret-env <NAME>, --secret-file <path>, --secret-stdin or --browser.',\n );\n }\n const again = `apps set ${product}${args.source ? ` --source ${args.source}` : ''}`;\n const interactive = canPrompt(ctx, args);\n if (\n subcommand === 'set' &&\n !interactive &&\n !secretInputGiven(secret) &&\n Object.keys(plain).length === 0\n ) {\n throw usageError(\n SET_REFUSAL,\n `Without a terminal, pass --set clientId=<id> and the secret as --secret-env <NAME>, --secret-file <path>, --secret-stdin, or --browser (a form in your browser on this computer). Or run it yourself in your terminal: ${cli()} ${again}`,\n );\n }\n\n const env = resolveAuthEnvironment(ctx, args.host, args.env, {\n projectDir: args.dir,\n });\n const resolved = await resolveSourceTarget(env, requireSession(env), args);\n const client = new AppsClient(env, resolved.session);\n const source = resolved.source;\n\n if (subcommand === 'show') {\n return showApp(ctx, env.host, client, source, product);\n }\n\n const status = await client.call((token) =>\n showProviderApp(env.host, token, source, product),\n );\n\n ctx.log(walkthrough(status).join('\\n'));\n\n // Either credential on its own: Enter keeps what is saved. An older host\n // sends no `fields`; then `configured` says whether both are saved.\n const saved = (name: 'clientId' | 'clientSecret') =>\n status.fields?.find((field) => field.name === name) ?? {\n set: status.configured,\n value: null,\n };\n const savedId = saved('clientId');\n const savedSecret = saved('clientSecret');\n const fields = [\n {\n name: 'clientId',\n label: 'Client ID',\n sensitive: false,\n set: savedId.set,\n value: savedId.value ?? null,\n },\n {\n name: 'clientSecret',\n label: 'Client secret',\n sensitive: true,\n set: savedSecret.set,\n },\n ];\n const collected = await collectSecrets(ctx, {\n fields,\n plain,\n flags: secret,\n io: secretIO(args),\n interactive,\n title: `the ${status.product.name} app on ${status.source.slug}`,\n refusal: SET_REFUSAL,\n again,\n prompt: (field) =>\n field.sensitive\n ? (args.askSecret ?? promptHidden)(\n savedSecret.set\n ? 'Client secret (saved — Enter to keep, hidden): '\n : 'Client secret (hidden): ',\n )\n : (args.ask ?? promptLine)(\n savedId.set\n ? `Client ID (current: ${savedId.value ?? 'saved'} — Enter to keep): `\n : 'Client ID: ',\n ),\n });\n const clientId = collected.clientId ?? '';\n const clientSecret = collected.clientSecret ?? '';\n if (!clientId && !clientSecret) {\n throw validationError(\n 'Nothing was changed.',\n `Run \"ekanos apps show ${product}\" to see the current state.`,\n );\n }\n\n const result = await client.call((token) =>\n setProviderApp(env.host, token, {\n source,\n product,\n ...(clientId ? { clientId } : {}),\n ...(clientSecret ? { clientSecret } : {}),\n }),\n );\n return ctx.succeed(\n { host: env.host, ...result },\n ctx.ui.result({\n title: result.replaced\n ? `Updated the ${result.product.name} app`\n : `Set up the ${result.product.name} app`,\n rows: [\n ['Source', result.source.slug],\n ...providerFieldRows(result),\n ['Teams can connect', result.configured ? 'yes' : 'not yet'],\n ['Callback URLs', callbackUrls(result)],\n ],\n }),\n );\n}\n\n/**\n * How to create the app: the integration's own steps (`oauth.setup`, with the\n * callback URL filled in) when it declares them, else the generic three.\n */\nexport function walkthrough(status: ProviderAppStatus): string[] {\n const name = status.product.name;\n const lines = [`${name} app for ${status.source.slug}`];\n if (status.setup?.consoleUrl) {\n lines.push(` Open: ${status.setup.consoleUrl}`);\n }\n const steps = status.setup?.steps.length\n ? [\n ...status.setup.steps,\n `Check the app lists exactly: ${callbackUrls(status).join(', ')}`,\n ]\n : [\n `In ${name}, create an OAuth app (or open the one you use).`,\n `Register exactly these callback URLs: ${callbackUrls(status).join(', ')}`,\n ];\n steps.push(\n \"Enter its client ID and secret below. The secret is stored in Ekanos's vault and never shown again.\",\n );\n lines.push(...steps.map((step, index) => ` ${index + 1}. ${step}`));\n if (status.setup?.guideUrl) lines.push(` Guide: ${status.setup.guideUrl}`);\n return lines;\n}\n\nfunction summary(ctx: CliContext, status: ProviderAppStatus): string {\n const rows: ResultRow[] = [\n ['Source', status.source.slug],\n ...(status.setup\n ? ([\n [\n 'How to create it',\n [\n ...(status.setup.consoleUrl\n ? [`Open ${status.setup.consoleUrl}`]\n : []),\n ...status.setup.steps.map(\n (step, index) => `${index + 1}. ${step}`,\n ),\n ],\n ],\n ] as const)\n : []),\n ...providerFieldRows(status),\n [\n 'App ready',\n status.configured\n ? 'yes — teams can connect'\n : 'no — no team can connect yet',\n ],\n ['Callback URLs', callbackUrls(status)],\n ];\n return [\n ctx.ui.result({ title: `${status.product.name} app`, rows }),\n ...(status.configured\n ? []\n : [\n ctx.ui.hint(\n `Run \"ekanos apps set ${status.product.slug}\" in your terminal to enter its credentials.`,\n ),\n ]),\n ].join('\\n');\n}\n\n/**\n * `apps show <product>`: the Source provider app, and — for an integration\n * that supports one — the Source connection (plan 241). A `teamApp`\n * integration (Zendesk) has no provider app but can have a Source\n * connection, so either half may be absent.\n */\nasync function showApp(\n ctx: CliContext,\n host: string,\n client: AppsClient,\n source: string,\n product: string,\n): Promise<ExitCode> {\n const [app, connection] = await Promise.all([\n client\n .call((token) => showProviderApp(host, token, source, product))\n .then(\n (status) => ({ ok: true as const, status }),\n (error: unknown) => ({ ok: false as const, error }),\n ),\n // A host without the connections routes (before plan 241), or one that\n // refuses, leaves `show` exactly as it was: the provider app alone.\n client\n .connection((token) => showConnection(host, token, source, product))\n .catch(() => ({ status: 'unavailable' as const })),\n ]);\n\n if (!app.ok && connection.status !== 'ok') throw app.error;\n\n const parts: string[] = [];\n if (app.ok) parts.push(summary(ctx, app.status));\n if (connection.status === 'ok') {\n parts.push(\n connectionSummary(ctx, connection.data.connection, {\n sourceSlug: connection.data.source.slug,\n callbackUrls: connection.data.callbackUrls,\n }),\n );\n }\n\n return ctx.succeed(\n {\n host,\n ...(app.ok ? app.status : {}),\n ...(connection.status === 'ok'\n ? {\n sourceConnection: connection.data.connection,\n sourceConnectionCallbackUrls: connection.data.callbackUrls,\n }\n : {}),\n },\n parts.join('\\n'),\n );\n}\n\n/** `apps list`: every integration the Source can connect once, with status. */\nasync function runList(ctx: CliContext, args: AppsArgs): Promise<ExitCode> {\n const { env, client, source } = await openClient(ctx, args);\n const result = await client.connection((token) =>\n listConnections(env.host, token, source),\n );\n if (result.status !== 'ok') {\n throw invalidStateError(\n 'The host could not list the connections.',\n 'Retry shortly.',\n );\n }\n const { connections } = result.data;\n const rows: ResultRow[] = connections.map((connection) => [\n `${connection.name} (${connection.slug})`,\n connectionState(connection),\n ]);\n return ctx.succeed(\n { host: env.host, ...result.data },\n connections.length === 0\n ? ctx.ui.hint(\n `No integration on ${result.data.source.slug} supports one connection for the whole Source yet.`,\n )\n : ctx.ui.result({\n title: `Source connections on ${result.data.source.slug}`,\n rows,\n }),\n );\n}\n\nfunction connectionState(connection: SourceConnection): string {\n if (connection.connected) {\n return [\n 'connected',\n connection.connectedAt ? ` ${connection.connectedAt}` : '',\n connection.connectedBy ? ` by ${connection.connectedBy}` : '',\n ].join('');\n }\n return connection.missing.length > 0\n ? `not connected — app fields missing: ${connection.missing.join(', ')}`\n : 'not connected';\n}\n\n/**\n * `apps connect <product>`: connect the integration ONCE for the whole Source,\n * for the Source's provided agents whose template says `owner: \"source\"`.\n * Asks for any missing app fields at the terminal (secrets hidden, never from\n * a flag), prints the provider's consent URL, then waits until the browser\n * finishes. `apps disconnect <product>` removes it.\n */\nasync function runConnection(\n ctx: CliContext,\n args: AppsArgs,\n subcommand: 'connect' | 'disconnect',\n product: string,\n): Promise<ExitCode> {\n const { env, client, source } = await openClient(ctx, args);\n\n if (subcommand === 'disconnect') {\n return disconnect(ctx, args, client, env.host, source, product);\n }\n\n const shown = await client.connection((token) =>\n showConnection(env.host, token, source, product),\n );\n if (shown.status === 'unsupported') {\n throw invalidStateError(\n shown.message,\n `Each team connects ${product} itself: \"ekanos teams connect <team> ${product}\".`,\n );\n }\n if (shown.status !== 'ok') {\n throw invalidStateError(\n 'The host could not read the connection.',\n 'Retry shortly.',\n );\n }\n const current = shown.data.connection;\n\n if (current.app === 'fields') {\n ctx.log(\n [\n `${current.name} app for ${shown.data.source.slug} (one for the whole Source)`,\n ` Register this redirect URL in the app: ${shown.data.callbackUrls.join(', ')}`,\n ].join('\\n'),\n );\n }\n\n const fields = await askFields(ctx, args, current, product);\n\n const started = await client.connection((token) =>\n startConnection(env.host, token, {\n source,\n product,\n ...(Object.keys(fields).length > 0 ? { fields } : {}),\n }),\n );\n if (started.status === 'not-configured') {\n throw validationError(\n `${current.name} is not set up for the Source yet — missing: ${started.missing.join(', ')}.`,\n current.app === 'source-app'\n ? `Run \"ekanos apps set ${product}\" to enter the Source's app first.`\n : `Run \"ekanos apps connect ${product}\" again and fill every field.`,\n );\n }\n if (started.status !== 'ok') {\n throw invalidStateError(\n 'The host could not start the connection.',\n 'Retry shortly.',\n );\n }\n\n ctx.log(\n [\n `Open this link and approve ${current.name} as the account the Source's agents should act as:`,\n ` ${started.data.authorizeUrl}`,\n ].join('\\n'),\n );\n\n if (args.noWait || ctx.jsonMode) {\n return ctx.succeed(\n {\n host: env.host,\n product,\n authorizeUrl: started.data.authorizeUrl,\n callbackUrl: started.data.callbackUrl,\n connected: false,\n },\n ctx.ui.hint(`Then check with \"ekanos apps show ${product}\".`),\n );\n }\n\n const deadline = Date.now() + 10 * 60 * 1000;\n const before = current.connectedAt;\n while (Date.now() < deadline) {\n await new Promise((resolve) =>\n setTimeout(resolve, args.pollDelayMs ?? 3000),\n );\n const polled = await client.connection((token) =>\n showConnection(env.host, token, source, product),\n );\n if (\n polled.status === 'ok' &&\n polled.data.connection.connected &&\n polled.data.connection.connectedAt !== before\n ) {\n return ctx.succeed(\n { host: env.host, product, connection: polled.data.connection },\n connectionSummary(ctx, polled.data.connection, {\n sourceSlug: polled.data.source.slug,\n callbackUrls: polled.data.callbackUrls,\n }),\n );\n }\n }\n throw validationError(\n 'The connection did not finish within ten minutes.',\n `Run \"ekanos apps connect ${product}\" again for a fresh link.`,\n );\n}\n\nasync function askFields(\n ctx: CliContext,\n args: AppsArgs,\n current: SourceConnection,\n product: string,\n): Promise<Record<string, string>> {\n const toAsk = current.fields.filter(\n (field) => !field.set || current.missing.includes(field.name),\n );\n if (toAsk.length === 0) return {};\n return collectSecrets(ctx, {\n fields: toAsk.map((field) => ({\n name: field.name,\n label: field.label,\n sensitive: field.sensitive,\n ...(field.description ? { description: field.description } : {}),\n set: false,\n required: current.missing.includes(field.name),\n })),\n plain: parsePlainValues(args.flags?.set),\n flags: readSecretFlags(args.flags),\n io: secretIO(args),\n interactive: canPrompt(ctx, args),\n title: `${current.name}'s app for the whole Source`,\n refusal: `${current.name} needs its app fields entered for the Source (${toAsk.map((field) => `${field.label} [${field.name}]`).join(', ')}), and there is no terminal to ask at.`,\n again: `apps connect ${product}${args.source ? ` --source ${args.source}` : ''}`,\n prompt: (field) =>\n field.sensitive\n ? (args.askSecret ?? promptHidden)(`${field.label} (hidden): `)\n : (args.ask ?? promptLine)(`${field.label}: `),\n });\n}\n\nasync function disconnect(\n ctx: CliContext,\n args: AppsArgs,\n client: AppsClient,\n host: string,\n source: string,\n product: string,\n): Promise<ExitCode> {\n if (!args.yes && !canPrompt(ctx, args)) {\n throw invalidStateError(\n `Disconnecting ${product} on ${source} stops it for every team's provided agents that use the Source connection, until someone connects it again.`,\n `Re-run with --yes: ekanos apps disconnect ${product} --source ${source} --yes`,\n );\n }\n if (!args.yes) {\n const sure = await (args.confirm ?? promptYesNo)(\n `Disconnect ${product} for every team's provided agents on ${source}? [y/N]`,\n );\n if (!sure) {\n throw validationError(\n 'Nothing was changed.',\n `Run \"ekanos apps show ${product}\" to see the current state.`,\n );\n }\n }\n const result = await client.connection((token) =>\n deleteConnection(host, token, source, product),\n );\n if (result.status === 'unsupported') {\n throw invalidStateError(\n result.message,\n `Each team connects ${product} itself: \"ekanos teams connect <team> ${product}\".`,\n );\n }\n if (result.status !== 'ok') {\n throw invalidStateError('The host could not disconnect.', 'Retry shortly.');\n }\n return ctx.succeed(\n { host, product, ...result.data },\n ctx.ui.result({\n title: result.data.removed\n ? `Disconnected the ${product} Source connection on ${source}`\n : `${product} had no Source connection on ${source}`,\n rows: [\n [\n 'Provided agents',\n 'their tools for this product stop until you connect again',\n ],\n ],\n }),\n );\n}\n\nfunction connectionSummary(\n ctx: CliContext,\n connection: SourceConnection,\n meta: { sourceSlug: string; callbackUrls: string[] },\n): string {\n const rows: ResultRow[] = [\n ['Source', meta.sourceSlug],\n ['Connected', connectionState(connection)],\n ...(connection.scope ? ([['Scope', connection.scope]] as ResultRow[]) : []),\n ...(connection.fields.length > 0\n ? ([\n [\n 'App fields',\n connection.fields.map(\n (field) =>\n `${field.label}: ${field.set ? (field.value ?? 'set') : 'missing'}`,\n ),\n ],\n ] as ResultRow[])\n : []),\n ['Redirect URL', meta.callbackUrls],\n [\n 'Used by',\n `provided agents whose template says connections.${connection.slug}.owner: \"source\", in every team`,\n ],\n ];\n return [\n ctx.ui.result({\n title: `${connection.name} — Source connection (one for every team's provided agents)`,\n rows,\n }),\n ...(connection.connected\n ? []\n : [\n ctx.ui.hint(\n `Run \"ekanos apps connect ${connection.slug}\" in your terminal to connect it.`,\n ),\n ]),\n ].join('\\n');\n}\n\nasync function openClient(ctx: CliContext, args: AppsArgs) {\n const env = resolveAuthEnvironment(ctx, args.host, args.env, {\n projectDir: args.dir,\n });\n const resolved = await resolveSourceTarget(env, requireSession(env), args);\n return {\n env,\n client: new AppsClient(env, resolved.session),\n source: resolved.source,\n };\n}\n\nclass AppsClient {\n constructor(\n private readonly env: AuthEnvironment,\n private session: StoredSession,\n ) {}\n\n async call<T>(\n send: (accessToken: string) => Promise<AppsApiResult<T>>,\n ): Promise<T> {\n let result = await send(this.session.accessToken);\n if (result.status === 'unauthorized') {\n this.session = await refreshStoredSession(this.env, this.session);\n result = await send(this.session.accessToken);\n }\n if (result.status === 'ok') return result.data;\n throw authRequiredError(\n `The session for ${this.env.host} could not authorize the apps call.`,\n loginHint(this.env),\n );\n }\n\n /** As `call`, for the connections client, whose 409s are answers. */\n async connection<T>(\n send: (accessToken: string) => Promise<ConnectionsApiResult<T>>,\n ): Promise<Exclude<ConnectionsApiResult<T>, { status: 'unauthorized' }>> {\n let result = await send(this.session.accessToken);\n if (result.status === 'unauthorized') {\n this.session = await refreshStoredSession(this.env, this.session);\n result = await send(this.session.accessToken);\n }\n if (result.status !== 'unauthorized') return result;\n throw authRequiredError(\n `The session for ${this.env.host} could not authorize the connections call.`,\n loginHint(this.env),\n );\n }\n}\n\nfunction canPrompt(ctx: CliContext, args: AppsArgs): boolean {\n return !ctx.jsonMode && (args.stdinIsTTY ?? process.stdin.isTTY === true);\n}\n\nconst SET_REFUSAL =\n 'apps set needs the client secret, and there is no terminal to ask at.';\n\nfunction secretIO(args: AppsArgs): SecretIO {\n return {\n env: args.env,\n stdinIsTTY: args.stdinIsTTY ?? process.stdin.isTTY === true,\n readStdin: args.readStdin,\n openUrl: args.openUrl,\n formTimeoutMs: args.secretFormTimeoutMs,\n };\n}\n\nfunction parseSubcommand(value: string | undefined): AppsSubcommand {\n const match = APPS_SUBCOMMANDS.find((name) => name === value);\n if (match) return match;\n throw usageError(\n value ? `Unknown apps subcommand \"${value}\".` : 'apps needs a subcommand.',\n `Run one of: ${APPS_SUBCOMMANDS.map((name) => `ekanos apps ${name} <product>`).join(', ')}.`,\n );\n}\n\nfunction requireProduct(value: string | undefined, verb: string): string {\n const slug = value?.trim().toLowerCase();\n if (slug && isProductSlug(slug)) return slug;\n if (value) {\n throw usageError(\n `\"${value}\" is not a product slug.`,\n `${PRODUCT_SLUG_SHAPE} \"ekanos catalog\" lists them.`,\n );\n }\n throw usageError(\n `apps ${verb} needs a product.`,\n `Pass the product's slug, e.g. \"ekanos apps ${verb} linear\". \"ekanos catalog\" lists them.`,\n );\n}\n\nexport async function promptLine(question: string): Promise<string> {\n const readline = await import('node:readline/promises');\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stderr,\n });\n try {\n return await rl.question(question);\n } finally {\n rl.close();\n }\n}\n\n/**\n * Read a line without echoing it: the secret never appears on screen or in\n * scrollback. The question is always printed; only the typed characters are\n * hidden (each shows as `*`, so a paste visibly landed).\n *\n * Raw mode by hand rather than readline: a terminal readline redraws its\n * line on `question()` — cursor to column 0, clear to the end of the screen —\n * which erased the question written before it, so the terminal sat on an\n * empty line and a hidden field looked skipped.\n */\nexport async function promptHidden(question: string): Promise<string> {\n const stdin = process.stdin;\n const stderr = process.stderr;\n stderr.write(question);\n\n if (!stdin.isTTY) {\n // Piped stdin echoes nothing: read one line as is.\n const readline = await import('node:readline/promises');\n const rl = readline.createInterface({ input: stdin, terminal: false });\n try {\n return await rl.question('');\n } finally {\n rl.close();\n stderr.write('\\n');\n }\n }\n\n return new Promise<string>((resolve) => {\n let value = '';\n let inEscape = false;\n const wasRaw = stdin.isRaw;\n const finish = () => {\n stdin.off('data', onData);\n stdin.setRawMode(wasRaw);\n stdin.pause();\n stderr.write('\\n');\n };\n const onData = (chunk: Buffer | string) => {\n for (const char of typeof chunk === 'string'\n ? chunk\n : chunk.toString('utf8')) {\n if (inEscape) {\n // An escape sequence (an arrow key) ends at its final letter.\n if (/[A-Za-z~]/.test(char)) inEscape = false;\n continue;\n }\n if (char === '\\u001b') {\n inEscape = true;\n continue;\n }\n if (char === '\\r' || char === '\\n' || char === '\\u0004') {\n finish();\n resolve(value);\n return;\n }\n if (char === '\\u0003') {\n // Ctrl-C: raw mode swallowed the signal, so leave as SIGINT would.\n finish();\n process.exit(130);\n }\n if (char === '\\u007f' || char === '\\b') {\n if (value.length > 0) {\n value = value.slice(0, -1);\n stderr.write('\\b \\b');\n }\n continue;\n }\n if (char === '\\u0015') {\n // Ctrl-U: clear what was typed.\n stderr.write('\\b \\b'.repeat(value.length));\n value = '';\n continue;\n }\n if (char < ' ') continue;\n value += char;\n stderr.write('*');\n }\n };\n stdin.setRawMode(true);\n stdin.resume();\n stdin.on('data', onData);\n });\n}\n\n/** Each credential's state: the client id's value, the secret as saved or not. */\nfunction providerFieldRows(status: ProviderAppStatus): ResultRow[] {\n return (status.fields ?? []).map((field) => [\n field.label,\n !field.set\n ? 'not set'\n : field.sensitive\n ? 'saved'\n : (field.value ?? 'saved'),\n ]);\n}\n\n/** Every redirect URI to register; an older host sends only the one. */\nfunction callbackUrls(status: ProviderAppStatus): string[] {\n return status.callbackUrls?.length\n ? status.callbackUrls\n : [status.callbackUrl];\n}\n"]}
|
package/dist/commands/dev.d.ts
CHANGED
|
@@ -28,6 +28,11 @@ export interface DevArgs {
|
|
|
28
28
|
/** Test seams. */
|
|
29
29
|
loadResolver?: (projectDir: string) => Promise<HarnessResolver>;
|
|
30
30
|
fetchCatalog?: () => Promise<SourceCatalog | null>;
|
|
31
|
+
/**
|
|
32
|
+
* Keep `.ekanos/catalog.json` and `.ekanos/publish-status.json` fresh while
|
|
33
|
+
* the server runs. On by default; tests turn it off.
|
|
34
|
+
*/
|
|
35
|
+
hostSnapshots?: boolean;
|
|
31
36
|
}
|
|
32
37
|
/**
|
|
33
38
|
* `dev` — scaffold the local harness shell into the partner's project, then
|
package/dist/commands/dev.js
CHANGED
|
@@ -7,6 +7,7 @@ import { assertHarnessCompatible } from '../compatibility.js';
|
|
|
7
7
|
import { detectKind, loadHarnessResolver, readExperienceProject, writeSessionCatalog, } from '../dev-experience.js';
|
|
8
8
|
import { preconditionError, usageError } from '../errors.js';
|
|
9
9
|
import { BUILD_CACHE_DIR, HARNESS_DIR, HARNESS_PACKAGE, SHELL_REGISTRY_FILENAME, assertShellDirIsOurs, bootstrapHarnessConfig, ensureGitignoreEntry, missingDependencies, readInstalledHarness, scaffoldShell, } from '../harness-scaffold.js';
|
|
10
|
+
import { sharedPackageSource, startHostSnapshotRefresher, } from '../host-snapshots.js';
|
|
10
11
|
import { DUPLICATE_INSTANCE_HINT, describeDuplicates, scanLockfileInstances, } from '../lockfile-instances.js';
|
|
11
12
|
import { detectPackageManager, execArgs, formatCommand, installCommand, } from '../package-manager.js';
|
|
12
13
|
import { createOutputTail, findIgnoredBuilds, ignoredBuildsHint, } from '../pnpm-builds.js';
|
|
@@ -56,7 +57,7 @@ const LOCAL_SECRETS_PATH = path.join('.ekanos', 'local-secrets.json');
|
|
|
56
57
|
* and `.gitignore` never grows a duplicate line.
|
|
57
58
|
*/
|
|
58
59
|
export async function runDev(ctx, args) {
|
|
59
|
-
var _a, _b, _c;
|
|
60
|
+
var _a, _b, _c, _d;
|
|
60
61
|
// At a repo root one harness serves every package; anywhere else the
|
|
61
62
|
// project is a single integration or experience, exactly as before.
|
|
62
63
|
const repo = isRepoRoot(path.resolve(args.dir))
|
|
@@ -257,15 +258,30 @@ export async function runDev(ctx, args) {
|
|
|
257
258
|
}));
|
|
258
259
|
}
|
|
259
260
|
ctx.log(ctx.ui.dim(`Starting the harness on ${url} (${command})…`));
|
|
261
|
+
// The catalog and publish status the harness shows, read with this CLI's
|
|
262
|
+
// login and refreshed while the server runs; the harness never holds a token.
|
|
263
|
+
const stopHostSnapshots = args.hostSnapshots === false
|
|
264
|
+
? () => undefined
|
|
265
|
+
: startHostSnapshotRefresher(Object.assign({ ctx, env: (_d = args.env) !== null && _d !== void 0 ? _d : process.env, projectDir: loaded.projectDir }, (repo
|
|
266
|
+
? {
|
|
267
|
+
fallbackSource: sharedPackageSource(repo.packages.map((pkg) => pkg.dir)),
|
|
268
|
+
}
|
|
269
|
+
: {})));
|
|
260
270
|
const tail = createOutputTail();
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
271
|
+
let exitCode;
|
|
272
|
+
try {
|
|
273
|
+
exitCode = await spawnServer({
|
|
274
|
+
ctx,
|
|
275
|
+
tail,
|
|
276
|
+
bin: pm.bin,
|
|
277
|
+
argv: execArgs(pm, 'next', serverArgs),
|
|
278
|
+
cwd: shell.harnessDir,
|
|
279
|
+
env: serverEnv,
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
finally {
|
|
283
|
+
stopHostSnapshots();
|
|
284
|
+
}
|
|
269
285
|
const data = Object.assign(Object.assign({}, scaffold), { server: { started: true, command, url, port, host, exposed, exitCode } });
|
|
270
286
|
if (exitCode === 0) {
|
|
271
287
|
return ctx.succeed(data, ctx.ui.result({ title: 'Harness stopped', rows: [['URL', url]] }));
|