workos 0.16.0 → 0.17.1
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 +7 -3
- package/dist/bin.js +10 -4
- package/dist/bin.js.map +1 -1
- package/dist/doctor/checks/auth-patterns.js +1 -1
- package/dist/doctor/checks/auth-patterns.js.map +1 -1
- package/dist/lib/adapters/cli-adapter.d.ts +7 -0
- package/dist/lib/adapters/cli-adapter.js +49 -0
- package/dist/lib/adapters/cli-adapter.js.map +1 -1
- package/dist/lib/adapters/dashboard-adapter.d.ts +4 -0
- package/dist/lib/adapters/dashboard-adapter.js +24 -0
- package/dist/lib/adapters/dashboard-adapter.js.map +1 -1
- package/dist/lib/adapters/headless-adapter.d.ts +6 -0
- package/dist/lib/adapters/headless-adapter.js +26 -1
- package/dist/lib/adapters/headless-adapter.js.map +1 -1
- package/dist/lib/agent-runner.js +55 -16
- package/dist/lib/agent-runner.js.map +1 -1
- package/dist/lib/events.d.ts +15 -0
- package/dist/lib/events.js.map +1 -1
- package/dist/lib/installer-core.d.ts +61 -1
- package/dist/lib/installer-core.js +132 -6
- package/dist/lib/installer-core.js.map +1 -1
- package/dist/lib/installer-core.types.d.ts +24 -0
- package/dist/lib/installer-core.types.js.map +1 -1
- package/dist/lib/run-with-core.js +26 -1
- package/dist/lib/run-with-core.js.map +1 -1
- package/dist/lib/scaffold/index.d.ts +1 -0
- package/dist/lib/scaffold/index.js +2 -0
- package/dist/lib/scaffold/index.js.map +1 -0
- package/dist/lib/scaffold/scaffold.d.ts +66 -0
- package/dist/lib/scaffold/scaffold.js +156 -0
- package/dist/lib/scaffold/scaffold.js.map +1 -0
- package/dist/lib/validation/security-checks.d.ts +35 -0
- package/dist/lib/validation/security-checks.js +105 -0
- package/dist/lib/validation/security-checks.js.map +1 -0
- package/dist/run.d.ts +2 -2
- package/dist/run.js +2 -1
- package/dist/run.js.map +1 -1
- package/dist/utils/types.d.ts +10 -4
- package/dist/utils/types.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashboard-adapter.js","sourceRoot":"","sources":["../../../src/lib/adapters/dashboard-adapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAErE;;;;;GAKG;AACH,MAAM,OAAO,gBAAgB;IAClB,OAAO,CAAwB;IAChC,SAAS,CAA6B;IACtC,OAAO,GAAwB,IAAI,CAAC;IACpC,SAAS,GAAG,KAAK,CAAC;IAClB,cAAc,GAAkD,IAAI,CAAC;IAE7E,YAAY,MAAqB;QAC/B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAC9B,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,IAAI,CAAC,SAAS;YAAE,OAAO;QAC3B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QAEtB,uDAAuD;QACvD,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,CAAC;QACvC,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC;QAChD,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,MAAM,CAAC,yCAAyC,CAAC,CAAC;QAE9E,6CAA6C;QAC7C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,yBAAyB;QAC9D,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,sBAAsB;QACvD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,sBAAsB;QACtD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,cAAc;QAEjD,8CAA8C;QAC9C,MAAM,QAAQ,GAAG,MAAM,CAAC,aAAa,CAAC,SAA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,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC;QACtE,CAAC;IACH,CAAC,CAAC;IAEF;;OAEG;IACK,yBAAyB,GAAG,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAwC,EAAQ,EAAE;QACvG,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,uBAAuB,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IACtE,CAAC,CAAC;CACH","sourcesContent":["import type { InstallerAdapter, AdapterConfig } from './types.js';\nimport type { InstallerEventEmitter, InstallerEvents } from '../events.js';\nimport { renderCompletionSummary } from '../../utils/summary-box.js';\n\n/**\n * Dashboard adapter that renders wizard events via Ink/React TUI.\n *\n * Wraps the existing Dashboard component and passes the emitter to it.\n * The Dashboard component already handles most event rendering internally.\n */\nexport class DashboardAdapter implements InstallerAdapter {\n readonly emitter: InstallerEventEmitter;\n private sendEvent: AdapterConfig['sendEvent'];\n private cleanup: (() => void) | null = null;\n private isStarted = false;\n private completionData: { success: boolean; summary?: string } | null = null;\n\n constructor(config: AdapterConfig) {\n this.emitter = config.emitter;\n this.sendEvent = config.sendEvent;\n }\n\n async start(): Promise<void> {\n if (this.isStarted) return;\n this.isStarted = true;\n\n // Dynamic imports to avoid loading Ink when not needed\n const { render } = await import('ink');\n const { createElement } = await import('react');\n const { Dashboard } = await import('../../dashboard/components/Dashboard.js');\n\n // Enter fullscreen (alternate screen buffer)\n process.stdout.write('\\x1b[?1049h'); // Enter alternate screen\n process.stdout.write('\\x1b[2J'); // Clear entire screen\n process.stdout.write('\\x1b[H'); // Move cursor to home\n process.stdout.write('\\x1b[?25l'); // Hide cursor\n\n // Render the Dashboard component with emitter\n const instance = render(createElement(Dashboard, { emitter: this.emitter }));\n\n // Setup cleanup function\n this.cleanup = () => {\n instance.unmount();\n process.stdout.write('\\x1b[?25h'); // Show cursor\n process.stdout.write('\\x1b[?1049l'); // Exit alternate screen\n };\n\n // Wire up Dashboard responses back to the machine\n // The Dashboard component emits these when user interacts\n this.emitter.on('confirm:response', this.handleConfirmResponse);\n this.emitter.on('credentials:response', this.handleCredentialsResponse);\n\n // Track completion for post-exit summary\n this.emitter.on('complete', this.handleComplete);\n }\n\n /**\n * Capture completion data for display after exit.\n */\n private handleComplete = ({ success, summary }: InstallerEvents['complete']): void => {\n this.completionData = { success, summary };\n };\n\n async stop(): Promise<void> {\n if (!this.isStarted) return;\n\n // Unsubscribe from events\n this.emitter.off('confirm:response', this.handleConfirmResponse);\n this.emitter.off('credentials:response', this.handleCredentialsResponse);\n this.emitter.off('complete', this.handleComplete);\n\n // Run cleanup (unmount Ink, exit fullscreen)\n this.cleanup?.();\n this.cleanup = null;\n\n if (this.completionData) {\n console.log();\n console.log(renderCompletionSummary(this.completionData.success, this.completionData.summary));\n console.log();\n }\n\n this.isStarted = false;\n }\n\n /**\n * Handle confirm dialog responses from Dashboard.\n */\n private handleConfirmResponse = ({ id, confirmed }: { id: string; confirmed: boolean }): void => {\n if (id === 'git-status') {\n this.sendEvent({ type: confirmed ? 'GIT_CONFIRMED' : 'GIT_CANCELLED' });\n } else if (id === 'env-scan') {\n this.sendEvent({ type: confirmed ? 'ENV_SCAN_APPROVED' : 'ENV_SCAN_DECLINED' });\n } else if (id === 'branch-check') {\n // For dashboard, confirmed=true means create branch, false means continue on current\n this.sendEvent({ type: confirmed ? 'BRANCH_CREATE' : 'BRANCH_CONTINUE' });\n } else if (id === 'commit') {\n this.sendEvent({ type: confirmed ? 'COMMIT_APPROVED' : 'COMMIT_DECLINED' });\n } else if (id === 'pr') {\n this.sendEvent({ type: confirmed ? 'PR_APPROVED' : 'PR_DECLINED' });\n }\n };\n\n /**\n * Handle credentials form submission from Dashboard.\n */\n private handleCredentialsResponse = ({ apiKey, clientId }: { apiKey: string; clientId: string }): void => {\n this.sendEvent({ type: 'CREDENTIALS_SUBMITTED', apiKey, clientId });\n };\n}\n"]}
|
|
1
|
+
{"version":3,"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CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,sCAAsC,cAAc,KAAK,EAAE,CAAC,CAAC;IACtG,CAAC,CAAC;IAEM,sBAAsB,GAAG,GAAS,EAAE;QAC1C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,qBAAqB,EAAE,CAAC,CAAC;IAClE,CAAC,CAAC;IAEM,oBAAoB,GAAG,CAAC,EAAE,KAAK,EAAsC,EAAQ,EAAE;QACrF,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,oBAAoB,KAAK,EAAE,EAAE,CAAC,CAAC;IACxE,CAAC,CAAC;CACH","sourcesContent":["import type { InstallerAdapter, AdapterConfig } from './types.js';\nimport type { InstallerEventEmitter, InstallerEvents } from '../events.js';\nimport { renderCompletionSummary } from '../../utils/summary-box.js';\n\n/**\n * Dashboard adapter that renders wizard events via Ink/React TUI.\n *\n * Wraps the existing Dashboard component and passes the emitter to it.\n * The Dashboard component already handles most event rendering internally.\n */\nexport class DashboardAdapter implements InstallerAdapter {\n readonly emitter: InstallerEventEmitter;\n private sendEvent: AdapterConfig['sendEvent'];\n private cleanup: (() => void) | null = null;\n private isStarted = false;\n private completionData: { success: boolean; summary?: string } | null = null;\n\n constructor(config: AdapterConfig) {\n this.emitter = config.emitter;\n this.sendEvent = config.sendEvent;\n }\n\n async start(): Promise<void> {\n if (this.isStarted) return;\n this.isStarted = true;\n\n // Dynamic imports to avoid loading Ink when not needed\n const { render } = await import('ink');\n const { createElement } = await import('react');\n const { Dashboard } = await import('../../dashboard/components/Dashboard.js');\n\n // Enter fullscreen (alternate screen buffer)\n process.stdout.write('\\x1b[?1049h'); // Enter alternate screen\n process.stdout.write('\\x1b[2J'); // Clear entire screen\n process.stdout.write('\\x1b[H'); // Move cursor to home\n process.stdout.write('\\x1b[?25l'); // Hide cursor\n\n // Render the Dashboard component with emitter\n const instance = render(createElement(Dashboard, { emitter: this.emitter }));\n\n // Setup cleanup function\n this.cleanup = () => {\n instance.unmount();\n process.stdout.write('\\x1b[?25h'); // Show cursor\n process.stdout.write('\\x1b[?1049l'); // Exit alternate screen\n };\n\n // Wire up Dashboard responses back to the machine\n // The Dashboard component emits these when user interacts\n this.emitter.on('confirm:response', this.handleConfirmResponse);\n this.emitter.on('credentials:response', this.handleCredentialsResponse);\n\n // Scaffold (empty-dir): the TUI has no dedicated scaffold prompt yet, so\n // auto-proceed (the user ran the installer in an empty dir) and surface\n // progress through the `status` event the Dashboard already renders.\n this.emitter.on('scaffold:prompt', this.handleScaffoldPrompt);\n this.emitter.on('scaffold:start', this.handleScaffoldStart);\n this.emitter.on('scaffold:complete', this.handleScaffoldComplete);\n this.emitter.on('scaffold:failed', this.handleScaffoldFailed);\n\n // Track completion for post-exit summary\n this.emitter.on('complete', this.handleComplete);\n }\n\n /**\n * Capture completion data for display after exit.\n */\n private handleComplete = ({ success, summary }: InstallerEvents['complete']): void => {\n this.completionData = { success, summary };\n };\n\n async stop(): Promise<void> {\n if (!this.isStarted) return;\n\n // Unsubscribe from events\n this.emitter.off('confirm:response', this.handleConfirmResponse);\n this.emitter.off('credentials:response', this.handleCredentialsResponse);\n this.emitter.off('scaffold:prompt', this.handleScaffoldPrompt);\n this.emitter.off('scaffold:start', this.handleScaffoldStart);\n this.emitter.off('scaffold:complete', this.handleScaffoldComplete);\n this.emitter.off('scaffold:failed', this.handleScaffoldFailed);\n this.emitter.off('complete', this.handleComplete);\n\n // Run cleanup (unmount Ink, exit fullscreen)\n this.cleanup?.();\n this.cleanup = null;\n\n if (this.completionData) {\n console.log();\n console.log(renderCompletionSummary(this.completionData.success, this.completionData.summary));\n console.log();\n }\n\n this.isStarted = false;\n }\n\n /**\n * Handle confirm dialog responses from Dashboard.\n */\n private handleConfirmResponse = ({ id, confirmed }: { id: string; confirmed: boolean }): void => {\n if (id === 'git-status') {\n this.sendEvent({ type: confirmed ? 'GIT_CONFIRMED' : 'GIT_CANCELLED' });\n } else if (id === 'env-scan') {\n this.sendEvent({ type: confirmed ? 'ENV_SCAN_APPROVED' : 'ENV_SCAN_DECLINED' });\n } else if (id === 'branch-check') {\n // For dashboard, confirmed=true means create branch, false means continue on current\n this.sendEvent({ type: confirmed ? 'BRANCH_CREATE' : 'BRANCH_CONTINUE' });\n } else if (id === 'commit') {\n this.sendEvent({ type: confirmed ? 'COMMIT_APPROVED' : 'COMMIT_DECLINED' });\n } else if (id === 'pr') {\n this.sendEvent({ type: confirmed ? 'PR_APPROVED' : 'PR_DECLINED' });\n }\n };\n\n /**\n * Handle credentials form submission from Dashboard.\n */\n private handleCredentialsResponse = ({ apiKey, clientId }: { apiKey: string; clientId: string }): void => {\n this.sendEvent({ type: 'CREDENTIALS_SUBMITTED', apiKey, clientId });\n };\n\n // ===== Scaffold (empty-dir) handlers =====\n\n private handleScaffoldPrompt = (): void => {\n this.sendEvent({ type: 'SCAFFOLD_CONFIRMED' });\n };\n\n private handleScaffoldStart = ({ packageManager }: InstallerEvents['scaffold:start']): void => {\n this.emitter.emit('status', { message: `Scaffolding a new Next.js app with ${packageManager}...` });\n };\n\n private handleScaffoldComplete = (): void => {\n this.emitter.emit('status', { message: 'Next.js app created' });\n };\n\n private handleScaffoldFailed = ({ error }: InstallerEvents['scaffold:failed']): void => {\n this.emitter.emit('status', { message: `Scaffold failed: ${error}` });\n };\n}\n"]}
|
|
@@ -25,6 +25,7 @@ export declare class HeadlessAdapter implements InstallerAdapter {
|
|
|
25
25
|
private debug;
|
|
26
26
|
private options;
|
|
27
27
|
private isStarted;
|
|
28
|
+
private scaffolded;
|
|
28
29
|
private handlers;
|
|
29
30
|
constructor(config: AdapterConfig & {
|
|
30
31
|
options: HeadlessOptions;
|
|
@@ -35,6 +36,11 @@ export declare class HeadlessAdapter implements InstallerAdapter {
|
|
|
35
36
|
private debugLog;
|
|
36
37
|
private handleAuthSuccess;
|
|
37
38
|
private handleAuthFailure;
|
|
39
|
+
private handleScaffoldChecking;
|
|
40
|
+
private handleScaffoldStart;
|
|
41
|
+
private handleScaffoldProgress;
|
|
42
|
+
private handleScaffoldComplete;
|
|
43
|
+
private handleScaffoldFailed;
|
|
38
44
|
private handleDetectionComplete;
|
|
39
45
|
private handleDetectionNone;
|
|
40
46
|
private handleGitDirty;
|
|
@@ -13,6 +13,7 @@ export class HeadlessAdapter {
|
|
|
13
13
|
debug;
|
|
14
14
|
options;
|
|
15
15
|
isStarted = false;
|
|
16
|
+
scaffolded = false;
|
|
16
17
|
handlers = new Map();
|
|
17
18
|
constructor(config) {
|
|
18
19
|
this.emitter = config.emitter;
|
|
@@ -27,6 +28,12 @@ export class HeadlessAdapter {
|
|
|
27
28
|
// Auth events
|
|
28
29
|
this.subscribe('auth:success', this.handleAuthSuccess);
|
|
29
30
|
this.subscribe('auth:failure', this.handleAuthFailure);
|
|
31
|
+
// Scaffold events (empty-directory app scaffolding) — auto-routed, no prompt
|
|
32
|
+
this.subscribe('scaffold:checking', this.handleScaffoldChecking);
|
|
33
|
+
this.subscribe('scaffold:start', this.handleScaffoldStart);
|
|
34
|
+
this.subscribe('scaffold:progress', this.handleScaffoldProgress);
|
|
35
|
+
this.subscribe('scaffold:complete', this.handleScaffoldComplete);
|
|
36
|
+
this.subscribe('scaffold:failed', this.handleScaffoldFailed);
|
|
30
37
|
// Detection events
|
|
31
38
|
this.subscribe('detection:complete', this.handleDetectionComplete);
|
|
32
39
|
this.subscribe('detection:none', this.handleDetectionNone);
|
|
@@ -95,6 +102,24 @@ export class HeadlessAdapter {
|
|
|
95
102
|
writeNDJSON({ type: 'auth:required', message });
|
|
96
103
|
process.exit(ExitCode.AUTH_REQUIRED);
|
|
97
104
|
};
|
|
105
|
+
// ===== Scaffold Handlers (auto-routed) =====
|
|
106
|
+
handleScaffoldChecking = () => {
|
|
107
|
+
writeNDJSON({ type: 'scaffold:checking' });
|
|
108
|
+
};
|
|
109
|
+
handleScaffoldStart = ({ packageManager }) => {
|
|
110
|
+
writeNDJSON({ type: 'scaffold:start', packageManager });
|
|
111
|
+
};
|
|
112
|
+
// create-next-app output is verbose; surface it only under --debug.
|
|
113
|
+
handleScaffoldProgress = ({ text }) => {
|
|
114
|
+
this.debugLog(text);
|
|
115
|
+
};
|
|
116
|
+
handleScaffoldComplete = () => {
|
|
117
|
+
this.scaffolded = true;
|
|
118
|
+
writeNDJSON({ type: 'scaffold:complete' });
|
|
119
|
+
};
|
|
120
|
+
handleScaffoldFailed = ({ error }) => {
|
|
121
|
+
writeNDJSON({ type: 'scaffold:failed', error });
|
|
122
|
+
};
|
|
98
123
|
// ===== Detection Handlers =====
|
|
99
124
|
handleDetectionComplete = ({ integration }) => {
|
|
100
125
|
writeNDJSON({ type: 'detection:complete', integration });
|
|
@@ -253,7 +278,7 @@ export class HeadlessAdapter {
|
|
|
253
278
|
};
|
|
254
279
|
// ===== Terminal Events =====
|
|
255
280
|
handleComplete = ({ success, summary }) => {
|
|
256
|
-
writeNDJSON({ type: 'complete', success, summary });
|
|
281
|
+
writeNDJSON({ type: 'complete', success, summary, scaffolded: this.scaffolded });
|
|
257
282
|
};
|
|
258
283
|
handleError = ({ message, stack }) => {
|
|
259
284
|
const isServiceError = /\b50[0-9]\b/.test(message) || /server_error|internal_error|overloaded|service.*unavailable/i.test(message);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headless-adapter.js","sourceRoot":"","sources":["../../../src/lib/adapters/headless-adapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAerD;;;;;;GAMG;AACH,MAAM,OAAO,eAAe;IACjB,OAAO,CAAwB;IAChC,SAAS,CAA6B;IACtC,KAAK,CAAU;IACf,OAAO,CAAkB;IACzB,SAAS,GAAG,KAAK,CAAC;IAClB,QAAQ,GAAG,IAAI,GAAG,EAAwC,CAAC;IAEnE,YAAY,MAAoD;QAC9D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CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC3E,MAAM,cAAc,GAAG,gDAAgD,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACtF,MAAM,aAAa,GAAG,2BAA2B,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAEhE,IAAI,IAAI,GAAG,iBAAiB,CAAC;QAC7B,IAAI,cAAc,GAAG,OAAO,CAAC;QAE7B,IAAI,cAAc,EAAE,CAAC;YACnB,IAAI,GAAG,qBAAqB,CAAC;YAC7B,cAAc,GAAG,+EAA+E,CAAC;QACnG,CAAC;aAAM,IAAI,WAAW,EAAE,CAAC;YACvB,IAAI,GAAG,cAAc,CAAC;YACtB,cAAc,GAAG,+EAA+E,CAAC;QACnG,CAAC;aAAM,IAAI,cAAc,EAAE,CAAC;YAC1B,IAAI,GAAG,eAAe,CAAC;YACvB,cAAc,GAAG,oFAAoF,CAAC;QACxG,CAAC;aAAM,IAAI,aAAa,EAAE,CAAC;YACzB,IAAI,GAAG,eAAe,CAAC;YACvB,cAAc,GAAG,uFAAuF,CAAC;QAC3G,CAAC;QAED,WAAW,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC,CAAC;QAC9D,IAAI,CAAC,QAAQ,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAC7B,CAAC,CAAC;CACH","sourcesContent":["import type { InstallerAdapter, AdapterConfig } from './types.js';\nimport type { InstallerEventEmitter, InstallerEvents } from '../events.js';\nimport { writeNDJSON } from '../../utils/ndjson.js';\nimport { ExitCode } from '../../utils/exit-codes.js';\n\n/**\n * Options controlling headless adapter behavior.\n * Corresponds to CLI flags passed in non-interactive mode.\n */\nexport interface HeadlessOptions {\n apiKey?: string;\n clientId?: string;\n noBranch?: boolean;\n noCommit?: boolean;\n createPr?: boolean;\n noGitCheck?: boolean;\n}\n\n/**\n * Non-interactive adapter for CI/CD and agent consumption.\n *\n * Subscribes to the same installer events as CLIAdapter but never prompts.\n * All decisions are auto-resolved with sensible defaults (overridable via flags).\n * Progress is streamed as NDJSON to stdout.\n */\nexport class HeadlessAdapter implements InstallerAdapter {\n readonly emitter: InstallerEventEmitter;\n private sendEvent: AdapterConfig['sendEvent'];\n private debug: boolean;\n private options: HeadlessOptions;\n private isStarted = false;\n private handlers = new Map<string, (...args: unknown[]) => void>();\n\n constructor(config: AdapterConfig & { options: HeadlessOptions }) {\n this.emitter = config.emitter;\n this.sendEvent = config.sendEvent;\n this.debug = config.debug ?? false;\n this.options = config.options;\n }\n\n async start(): Promise<void> {\n if (this.isStarted) return;\n this.isStarted = true;\n\n // Auth events\n this.subscribe('auth:success', this.handleAuthSuccess);\n this.subscribe('auth:failure', this.handleAuthFailure);\n\n // Detection events\n this.subscribe('detection:complete', this.handleDetectionComplete);\n this.subscribe('detection:none', this.handleDetectionNone);\n\n // Git events — auto-resolve\n this.subscribe('git:dirty', this.handleGitDirty);\n\n // Credential events — auto-resolve\n this.subscribe('credentials:found', this.handleCredentialsFound);\n this.subscribe('credentials:request', this.handleCredentialsRequest);\n this.subscribe('credentials:env:prompt', this.handleEnvScanPrompt);\n this.subscribe('credentials:env:found', this.handleEnvCredentialsFound);\n\n // Device auth (should not happen in headless, but log if it does)\n this.subscribe('device:started', this.handleDeviceStarted);\n\n // Staging\n this.subscribe('staging:fetching', this.handleStagingFetching);\n this.subscribe('staging:success', this.handleStagingSuccess);\n\n // Config\n this.subscribe('config:complete', this.handleConfigComplete);\n\n // Agent progress\n this.subscribe('agent:start', this.handleAgentStart);\n this.subscribe('agent:progress', this.handleAgentProgress);\n\n // Validation\n this.subscribe('validation:start', this.handleValidationStart);\n this.subscribe('validation:issues', this.handleValidationIssues);\n this.subscribe('validation:complete', this.handleValidationComplete);\n\n // Branch — auto-resolve\n this.subscribe('branch:prompt', this.handleBranchPrompt);\n this.subscribe('branch:created', this.handleBranchCreated);\n\n // Post-install — auto-resolve\n this.subscribe('postinstall:changes', this.handlePostInstallChanges);\n this.subscribe('postinstall:commit:prompt', this.handleCommitPrompt);\n this.subscribe('postinstall:commit:success', this.handleCommitSuccess);\n this.subscribe('postinstall:commit:failed', this.handleCommitFailed);\n this.subscribe('postinstall:pr:prompt', this.handlePrPrompt);\n this.subscribe('postinstall:pr:success', this.handlePrSuccess);\n this.subscribe('postinstall:pr:failed', this.handlePrFailed);\n this.subscribe('postinstall:push:failed', this.handlePushFailed);\n this.subscribe('postinstall:manual', this.handleManualInstructions);\n\n // Terminal events\n this.subscribe('complete', this.handleComplete);\n this.subscribe('error', this.handleError);\n }\n\n async stop(): Promise<void> {\n if (!this.isStarted) return;\n\n for (const [event, handler] of this.handlers) {\n this.emitter.off(event as keyof InstallerEvents, handler as never);\n }\n this.handlers.clear();\n this.isStarted = false;\n }\n\n private subscribe<K extends keyof InstallerEvents>(\n event: K,\n handler: (payload: InstallerEvents[K]) => void | Promise<void>,\n ): void {\n const boundHandler = handler.bind(this);\n this.handlers.set(event, boundHandler as (...args: unknown[]) => void);\n this.emitter.on(event, boundHandler);\n }\n\n private debugLog(message: string): void {\n if (this.debug) {\n writeNDJSON({ type: 'debug', message });\n }\n }\n\n // ===== Auth Handlers =====\n\n private handleAuthSuccess = (): void => {\n writeNDJSON({ type: 'auth:success' });\n };\n\n private handleAuthFailure = ({ message }: InstallerEvents['auth:failure']): void => {\n writeNDJSON({ type: 'auth:required', message });\n process.exit(ExitCode.AUTH_REQUIRED);\n };\n\n // ===== Detection Handlers =====\n\n private handleDetectionComplete = ({ integration }: InstallerEvents['detection:complete']): void => {\n writeNDJSON({ type: 'detection:complete', integration });\n };\n\n private handleDetectionNone = (): void => {\n writeNDJSON({ type: 'detection:none' });\n };\n\n // ===== Git Handlers (auto-resolve) =====\n\n private handleGitDirty = ({ files }: InstallerEvents['git:dirty']): void => {\n writeNDJSON({ type: 'git:status', dirty: true, files });\n\n if (this.options.noGitCheck) {\n writeNDJSON({ type: 'git:decision', action: 'continue' });\n this.sendEvent({ type: 'GIT_CONFIRMED' });\n return;\n }\n\n writeNDJSON({\n type: 'error',\n code: 'git_dirty',\n message:\n 'Git working tree is dirty in non-interactive mode. ' +\n 'Commit or stash your changes, or rerun with --no-git-check to proceed.',\n });\n writeNDJSON({ type: 'git:decision', action: 'cancel' });\n this.sendEvent({ type: 'GIT_CANCELLED' });\n process.exit(ExitCode.GENERAL_ERROR);\n };\n\n // ===== Credential Handlers (auto-resolve) =====\n\n private handleCredentialsFound = (): void => {\n writeNDJSON({ type: 'credentials:found', source: 'env' });\n };\n\n private handleCredentialsRequest = ({ requiresApiKey }: InstallerEvents['credentials:request']): void => {\n if (!this.options.clientId) {\n writeNDJSON({\n type: 'error',\n code: 'missing_credentials',\n message: 'Client ID required in non-interactive mode. Pass --client-id flag.',\n });\n process.exit(ExitCode.GENERAL_ERROR);\n }\n\n if (requiresApiKey && !this.options.apiKey) {\n writeNDJSON({\n type: 'error',\n code: 'missing_credentials',\n message: 'API key required for this framework. Pass --api-key flag.',\n });\n process.exit(ExitCode.GENERAL_ERROR);\n }\n\n writeNDJSON({ type: 'credentials:provided', source: 'flag' });\n this.sendEvent({\n type: 'CREDENTIALS_SUBMITTED',\n apiKey: this.options.apiKey ?? '',\n clientId: this.options.clientId,\n });\n };\n\n private handleEnvScanPrompt = (): void => {\n writeNDJSON({ type: 'credentials:env:scanning' });\n this.sendEvent({ type: 'ENV_SCAN_APPROVED' });\n };\n\n private handleEnvCredentialsFound = ({ sourcePath }: InstallerEvents['credentials:env:found']): void => {\n writeNDJSON({ type: 'credentials:found', source: 'env', sourcePath });\n };\n\n // ===== Device Auth (should not occur in headless) =====\n\n private handleDeviceStarted = ({ verificationUri, userCode }: InstallerEvents['device:started']): void => {\n writeNDJSON({\n type: 'auth:device_required',\n verificationUri,\n userCode,\n message: 'Device auth cannot proceed in non-interactive mode',\n });\n };\n\n // ===== Staging =====\n\n private handleStagingFetching = (): void => {\n writeNDJSON({ type: 'staging:fetching' });\n };\n\n private handleStagingSuccess = (): void => {\n writeNDJSON({ type: 'staging:success' });\n };\n\n // ===== Config =====\n\n private handleConfigComplete = (): void => {\n writeNDJSON({ type: 'config:complete' });\n };\n\n // ===== Agent Progress =====\n\n private handleAgentStart = (): void => {\n writeNDJSON({ type: 'agent:start' });\n };\n\n private handleAgentProgress = ({ step, detail }: InstallerEvents['agent:progress']): void => {\n const message = detail ? `${step}: ${detail}` : step;\n writeNDJSON({ type: 'agent:progress', message });\n };\n\n // ===== Validation =====\n\n private handleValidationStart = ({ framework }: InstallerEvents['validation:start']): void => {\n writeNDJSON({ type: 'validation:start', framework });\n };\n\n private handleValidationIssues = ({ issues }: InstallerEvents['validation:issues']): void => {\n for (const issue of issues) {\n writeNDJSON({ type: 'validation:issue', severity: issue.severity, message: issue.message });\n }\n };\n\n private handleValidationComplete = ({ passed, issueCount }: InstallerEvents['validation:complete']): void => {\n writeNDJSON({ type: 'validation:complete', passed, issues: issueCount });\n };\n\n // ===== Branch (auto-resolve) =====\n\n private handleBranchPrompt = (): void => {\n if (this.options.noBranch) {\n writeNDJSON({ type: 'branch:skipped', reason: '--no-branch flag' });\n this.sendEvent({ type: 'BRANCH_CONTINUE' });\n } else {\n writeNDJSON({ type: 'branch:creating' });\n this.sendEvent({ type: 'BRANCH_CREATE' });\n }\n };\n\n private handleBranchCreated = ({ branch }: InstallerEvents['branch:created']): void => {\n writeNDJSON({ type: 'branch:created', name: branch });\n };\n\n // ===== Post-install (auto-resolve) =====\n\n private handlePostInstallChanges = ({ files }: InstallerEvents['postinstall:changes']): void => {\n writeNDJSON({ type: 'postinstall:changes', files, count: files.length });\n };\n\n private handleCommitPrompt = (): void => {\n if (this.options.noCommit) {\n writeNDJSON({ type: 'commit:skipped', reason: '--no-commit flag' });\n this.sendEvent({ type: 'COMMIT_DECLINED' });\n } else {\n writeNDJSON({ type: 'commit:auto' });\n this.sendEvent({ type: 'COMMIT_APPROVED' });\n }\n };\n\n private handleCommitSuccess = ({ message }: InstallerEvents['postinstall:commit:success']): void => {\n writeNDJSON({ type: 'commit:created', message });\n };\n\n private handleCommitFailed = ({ error }: InstallerEvents['postinstall:commit:failed']): void => {\n writeNDJSON({ type: 'commit:failed', error });\n };\n\n private handlePrPrompt = (): void => {\n if (this.options.createPr) {\n writeNDJSON({ type: 'pr:creating' });\n this.sendEvent({ type: 'PR_APPROVED' });\n } else {\n writeNDJSON({ type: 'pr:skipped', reason: '--create-pr not set' });\n this.sendEvent({ type: 'PR_DECLINED' });\n }\n };\n\n private handlePrSuccess = ({ url }: InstallerEvents['postinstall:pr:success']): void => {\n writeNDJSON({ type: 'pr:created', url });\n };\n\n private handlePrFailed = ({ error }: InstallerEvents['postinstall:pr:failed']): void => {\n writeNDJSON({ type: 'pr:failed', error });\n };\n\n private handlePushFailed = ({ error }: InstallerEvents['postinstall:push:failed']): void => {\n writeNDJSON({ type: 'push:failed', error });\n };\n\n private handleManualInstructions = ({ instructions }: InstallerEvents['postinstall:manual']): void => {\n writeNDJSON({ type: 'postinstall:manual', instructions });\n };\n\n // ===== Terminal Events =====\n\n private handleComplete = ({ success, summary }: InstallerEvents['complete']): void => {\n writeNDJSON({ type: 'complete', success, summary });\n };\n\n private handleError = ({ message, stack }: InstallerEvents['error']): void => {\n const isServiceError =\n /\\b50[0-9]\\b/.test(message) || /server_error|internal_error|overloaded|service.*unavailable/i.test(message);\n const isRateLimit = /\\b429\\b/.test(message) || /rate.limit/i.test(message);\n const isNetworkError = /ECONNREFUSED|ETIMEDOUT|ENOTFOUND|fetch failed/i.test(message);\n const isProcessExit = /process exited with code/i.test(message);\n\n let code = 'installer_error';\n let displayMessage = message;\n\n if (isServiceError) {\n code = 'service_unavailable';\n displayMessage = 'The AI service is temporarily unavailable. Please try again in a few minutes.';\n } else if (isRateLimit) {\n code = 'rate_limited';\n displayMessage = 'The AI service is currently rate-limited. Please wait a minute and try again.';\n } else if (isNetworkError) {\n code = 'network_error';\n displayMessage = 'Could not connect to the AI service. Check your internet connection and try again.';\n } else if (isProcessExit) {\n code = 'process_error';\n displayMessage = 'The AI agent process exited unexpectedly. Try running again with --debug for details.';\n }\n\n writeNDJSON({ type: 'error', code, message: displayMessage });\n this.debugLog(stack ?? '');\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"headless-adapter.js","sourceRoot":"","sources":["../../../src/lib/adapters/headless-adapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAerD;;;;;;GAMG;AACH,MAAM,OAAO,eAAe;IACjB,OAAO,CAAwB;IAChC,SAAS,CAA6B;IACtC,KAAK,CAAU;IACf,OAAO,CAAkB;IACzB,SAAS,GAAG,KAAK,CAAC;IAClB,UAAU,GAAG,KAAK,CAAC;IACnB,QAAQ,GAAG,IAAI,GAAG,EAAwC,CAAC;IAEnE,YAAY,MAAoD;QAC9D,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAC9B,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,KAAK,CAAC;QACnC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,IAAI,CAAC,SAAS;YAAE,OAAO;QAC3B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QAEtB,cAAc;QACd,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QACvD,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAEvD,6EAA6E;QAC7E,IAAI,CAAC,SAAS,CAAC,mBAAmB,EAAE,IAAI,CAAC,sBAAsB,CAAC,CAAC;QACjE,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAC3D,IAAI,CA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cAAc,EAAE,CAAC,CAAC;QAC9D,IAAI,CAAC,QAAQ,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAC7B,CAAC,CAAC;CACH","sourcesContent":["import type { InstallerAdapter, AdapterConfig } from './types.js';\nimport type { InstallerEventEmitter, InstallerEvents } from '../events.js';\nimport { writeNDJSON } from '../../utils/ndjson.js';\nimport { ExitCode } from '../../utils/exit-codes.js';\n\n/**\n * Options controlling headless adapter behavior.\n * Corresponds to CLI flags passed in non-interactive mode.\n */\nexport interface HeadlessOptions {\n apiKey?: string;\n clientId?: string;\n noBranch?: boolean;\n noCommit?: boolean;\n createPr?: boolean;\n noGitCheck?: boolean;\n}\n\n/**\n * Non-interactive adapter for CI/CD and agent consumption.\n *\n * Subscribes to the same installer events as CLIAdapter but never prompts.\n * All decisions are auto-resolved with sensible defaults (overridable via flags).\n * Progress is streamed as NDJSON to stdout.\n */\nexport class HeadlessAdapter implements InstallerAdapter {\n readonly emitter: InstallerEventEmitter;\n private sendEvent: AdapterConfig['sendEvent'];\n private debug: boolean;\n private options: HeadlessOptions;\n private isStarted = false;\n private scaffolded = false;\n private handlers = new Map<string, (...args: unknown[]) => void>();\n\n constructor(config: AdapterConfig & { options: HeadlessOptions }) {\n this.emitter = config.emitter;\n this.sendEvent = config.sendEvent;\n this.debug = config.debug ?? false;\n this.options = config.options;\n }\n\n async start(): Promise<void> {\n if (this.isStarted) return;\n this.isStarted = true;\n\n // Auth events\n this.subscribe('auth:success', this.handleAuthSuccess);\n this.subscribe('auth:failure', this.handleAuthFailure);\n\n // Scaffold events (empty-directory app scaffolding) — auto-routed, no prompt\n this.subscribe('scaffold:checking', this.handleScaffoldChecking);\n this.subscribe('scaffold:start', this.handleScaffoldStart);\n this.subscribe('scaffold:progress', this.handleScaffoldProgress);\n this.subscribe('scaffold:complete', this.handleScaffoldComplete);\n this.subscribe('scaffold:failed', this.handleScaffoldFailed);\n\n // Detection events\n this.subscribe('detection:complete', this.handleDetectionComplete);\n this.subscribe('detection:none', this.handleDetectionNone);\n\n // Git events — auto-resolve\n this.subscribe('git:dirty', this.handleGitDirty);\n\n // Credential events — auto-resolve\n this.subscribe('credentials:found', this.handleCredentialsFound);\n this.subscribe('credentials:request', this.handleCredentialsRequest);\n this.subscribe('credentials:env:prompt', this.handleEnvScanPrompt);\n this.subscribe('credentials:env:found', this.handleEnvCredentialsFound);\n\n // Device auth (should not happen in headless, but log if it does)\n this.subscribe('device:started', this.handleDeviceStarted);\n\n // Staging\n this.subscribe('staging:fetching', this.handleStagingFetching);\n this.subscribe('staging:success', this.handleStagingSuccess);\n\n // Config\n this.subscribe('config:complete', this.handleConfigComplete);\n\n // Agent progress\n this.subscribe('agent:start', this.handleAgentStart);\n this.subscribe('agent:progress', this.handleAgentProgress);\n\n // Validation\n this.subscribe('validation:start', this.handleValidationStart);\n this.subscribe('validation:issues', this.handleValidationIssues);\n this.subscribe('validation:complete', this.handleValidationComplete);\n\n // Branch — auto-resolve\n this.subscribe('branch:prompt', this.handleBranchPrompt);\n this.subscribe('branch:created', this.handleBranchCreated);\n\n // Post-install — auto-resolve\n this.subscribe('postinstall:changes', this.handlePostInstallChanges);\n this.subscribe('postinstall:commit:prompt', this.handleCommitPrompt);\n this.subscribe('postinstall:commit:success', this.handleCommitSuccess);\n this.subscribe('postinstall:commit:failed', this.handleCommitFailed);\n this.subscribe('postinstall:pr:prompt', this.handlePrPrompt);\n this.subscribe('postinstall:pr:success', this.handlePrSuccess);\n this.subscribe('postinstall:pr:failed', this.handlePrFailed);\n this.subscribe('postinstall:push:failed', this.handlePushFailed);\n this.subscribe('postinstall:manual', this.handleManualInstructions);\n\n // Terminal events\n this.subscribe('complete', this.handleComplete);\n this.subscribe('error', this.handleError);\n }\n\n async stop(): Promise<void> {\n if (!this.isStarted) return;\n\n for (const [event, handler] of this.handlers) {\n this.emitter.off(event as keyof InstallerEvents, handler as never);\n }\n this.handlers.clear();\n this.isStarted = false;\n }\n\n private subscribe<K extends keyof InstallerEvents>(\n event: K,\n handler: (payload: InstallerEvents[K]) => void | Promise<void>,\n ): void {\n const boundHandler = handler.bind(this);\n this.handlers.set(event, boundHandler as (...args: unknown[]) => void);\n this.emitter.on(event, boundHandler);\n }\n\n private debugLog(message: string): void {\n if (this.debug) {\n writeNDJSON({ type: 'debug', message });\n }\n }\n\n // ===== Auth Handlers =====\n\n private handleAuthSuccess = (): void => {\n writeNDJSON({ type: 'auth:success' });\n };\n\n private handleAuthFailure = ({ message }: InstallerEvents['auth:failure']): void => {\n writeNDJSON({ type: 'auth:required', message });\n process.exit(ExitCode.AUTH_REQUIRED);\n };\n\n // ===== Scaffold Handlers (auto-routed) =====\n\n private handleScaffoldChecking = (): void => {\n writeNDJSON({ type: 'scaffold:checking' });\n };\n\n private handleScaffoldStart = ({ packageManager }: InstallerEvents['scaffold:start']): void => {\n writeNDJSON({ type: 'scaffold:start', packageManager });\n };\n\n // create-next-app output is verbose; surface it only under --debug.\n private handleScaffoldProgress = ({ text }: InstallerEvents['scaffold:progress']): void => {\n this.debugLog(text);\n };\n\n private handleScaffoldComplete = (): void => {\n this.scaffolded = true;\n writeNDJSON({ type: 'scaffold:complete' });\n };\n\n private handleScaffoldFailed = ({ error }: InstallerEvents['scaffold:failed']): void => {\n writeNDJSON({ type: 'scaffold:failed', error });\n };\n\n // ===== Detection Handlers =====\n\n private handleDetectionComplete = ({ integration }: InstallerEvents['detection:complete']): void => {\n writeNDJSON({ type: 'detection:complete', integration });\n };\n\n private handleDetectionNone = (): void => {\n writeNDJSON({ type: 'detection:none' });\n };\n\n // ===== Git Handlers (auto-resolve) =====\n\n private handleGitDirty = ({ files }: InstallerEvents['git:dirty']): void => {\n writeNDJSON({ type: 'git:status', dirty: true, files });\n\n if (this.options.noGitCheck) {\n writeNDJSON({ type: 'git:decision', action: 'continue' });\n this.sendEvent({ type: 'GIT_CONFIRMED' });\n return;\n }\n\n writeNDJSON({\n type: 'error',\n code: 'git_dirty',\n message:\n 'Git working tree is dirty in non-interactive mode. ' +\n 'Commit or stash your changes, or rerun with --no-git-check to proceed.',\n });\n writeNDJSON({ type: 'git:decision', action: 'cancel' });\n this.sendEvent({ type: 'GIT_CANCELLED' });\n process.exit(ExitCode.GENERAL_ERROR);\n };\n\n // ===== Credential Handlers (auto-resolve) =====\n\n private handleCredentialsFound = (): void => {\n writeNDJSON({ type: 'credentials:found', source: 'env' });\n };\n\n private handleCredentialsRequest = ({ requiresApiKey }: InstallerEvents['credentials:request']): void => {\n if (!this.options.clientId) {\n writeNDJSON({\n type: 'error',\n code: 'missing_credentials',\n message: 'Client ID required in non-interactive mode. Pass --client-id flag.',\n });\n process.exit(ExitCode.GENERAL_ERROR);\n }\n\n if (requiresApiKey && !this.options.apiKey) {\n writeNDJSON({\n type: 'error',\n code: 'missing_credentials',\n message: 'API key required for this framework. Pass --api-key flag.',\n });\n process.exit(ExitCode.GENERAL_ERROR);\n }\n\n writeNDJSON({ type: 'credentials:provided', source: 'flag' });\n this.sendEvent({\n type: 'CREDENTIALS_SUBMITTED',\n apiKey: this.options.apiKey ?? '',\n clientId: this.options.clientId,\n });\n };\n\n private handleEnvScanPrompt = (): void => {\n writeNDJSON({ type: 'credentials:env:scanning' });\n this.sendEvent({ type: 'ENV_SCAN_APPROVED' });\n };\n\n private handleEnvCredentialsFound = ({ sourcePath }: InstallerEvents['credentials:env:found']): void => {\n writeNDJSON({ type: 'credentials:found', source: 'env', sourcePath });\n };\n\n // ===== Device Auth (should not occur in headless) =====\n\n private handleDeviceStarted = ({ verificationUri, userCode }: InstallerEvents['device:started']): void => {\n writeNDJSON({\n type: 'auth:device_required',\n verificationUri,\n userCode,\n message: 'Device auth cannot proceed in non-interactive mode',\n });\n };\n\n // ===== Staging =====\n\n private handleStagingFetching = (): void => {\n writeNDJSON({ type: 'staging:fetching' });\n };\n\n private handleStagingSuccess = (): void => {\n writeNDJSON({ type: 'staging:success' });\n };\n\n // ===== Config =====\n\n private handleConfigComplete = (): void => {\n writeNDJSON({ type: 'config:complete' });\n };\n\n // ===== Agent Progress =====\n\n private handleAgentStart = (): void => {\n writeNDJSON({ type: 'agent:start' });\n };\n\n private handleAgentProgress = ({ step, detail }: InstallerEvents['agent:progress']): void => {\n const message = detail ? `${step}: ${detail}` : step;\n writeNDJSON({ type: 'agent:progress', message });\n };\n\n // ===== Validation =====\n\n private handleValidationStart = ({ framework }: InstallerEvents['validation:start']): void => {\n writeNDJSON({ type: 'validation:start', framework });\n };\n\n private handleValidationIssues = ({ issues }: InstallerEvents['validation:issues']): void => {\n for (const issue of issues) {\n writeNDJSON({ type: 'validation:issue', severity: issue.severity, message: issue.message });\n }\n };\n\n private handleValidationComplete = ({ passed, issueCount }: InstallerEvents['validation:complete']): void => {\n writeNDJSON({ type: 'validation:complete', passed, issues: issueCount });\n };\n\n // ===== Branch (auto-resolve) =====\n\n private handleBranchPrompt = (): void => {\n if (this.options.noBranch) {\n writeNDJSON({ type: 'branch:skipped', reason: '--no-branch flag' });\n this.sendEvent({ type: 'BRANCH_CONTINUE' });\n } else {\n writeNDJSON({ type: 'branch:creating' });\n this.sendEvent({ type: 'BRANCH_CREATE' });\n }\n };\n\n private handleBranchCreated = ({ branch }: InstallerEvents['branch:created']): void => {\n writeNDJSON({ type: 'branch:created', name: branch });\n };\n\n // ===== Post-install (auto-resolve) =====\n\n private handlePostInstallChanges = ({ files }: InstallerEvents['postinstall:changes']): void => {\n writeNDJSON({ type: 'postinstall:changes', files, count: files.length });\n };\n\n private handleCommitPrompt = (): void => {\n if (this.options.noCommit) {\n writeNDJSON({ type: 'commit:skipped', reason: '--no-commit flag' });\n this.sendEvent({ type: 'COMMIT_DECLINED' });\n } else {\n writeNDJSON({ type: 'commit:auto' });\n this.sendEvent({ type: 'COMMIT_APPROVED' });\n }\n };\n\n private handleCommitSuccess = ({ message }: InstallerEvents['postinstall:commit:success']): void => {\n writeNDJSON({ type: 'commit:created', message });\n };\n\n private handleCommitFailed = ({ error }: InstallerEvents['postinstall:commit:failed']): void => {\n writeNDJSON({ type: 'commit:failed', error });\n };\n\n private handlePrPrompt = (): void => {\n if (this.options.createPr) {\n writeNDJSON({ type: 'pr:creating' });\n this.sendEvent({ type: 'PR_APPROVED' });\n } else {\n writeNDJSON({ type: 'pr:skipped', reason: '--create-pr not set' });\n this.sendEvent({ type: 'PR_DECLINED' });\n }\n };\n\n private handlePrSuccess = ({ url }: InstallerEvents['postinstall:pr:success']): void => {\n writeNDJSON({ type: 'pr:created', url });\n };\n\n private handlePrFailed = ({ error }: InstallerEvents['postinstall:pr:failed']): void => {\n writeNDJSON({ type: 'pr:failed', error });\n };\n\n private handlePushFailed = ({ error }: InstallerEvents['postinstall:push:failed']): void => {\n writeNDJSON({ type: 'push:failed', error });\n };\n\n private handleManualInstructions = ({ instructions }: InstallerEvents['postinstall:manual']): void => {\n writeNDJSON({ type: 'postinstall:manual', instructions });\n };\n\n // ===== Terminal Events =====\n\n private handleComplete = ({ success, summary }: InstallerEvents['complete']): void => {\n writeNDJSON({ type: 'complete', success, summary, scaffolded: this.scaffolded });\n };\n\n private handleError = ({ message, stack }: InstallerEvents['error']): void => {\n const isServiceError =\n /\\b50[0-9]\\b/.test(message) || /server_error|internal_error|overloaded|service.*unavailable/i.test(message);\n const isRateLimit = /\\b429\\b/.test(message) || /rate.limit/i.test(message);\n const isNetworkError = /ECONNREFUSED|ETIMEDOUT|ENOTFOUND|fetch failed/i.test(message);\n const isProcessExit = /process exited with code/i.test(message);\n\n let code = 'installer_error';\n let displayMessage = message;\n\n if (isServiceError) {\n code = 'service_unavailable';\n displayMessage = 'The AI service is temporarily unavailable. Please try again in a few minutes.';\n } else if (isRateLimit) {\n code = 'rate_limited';\n displayMessage = 'The AI service is currently rate-limited. Please wait a minute and try again.';\n } else if (isNetworkError) {\n code = 'network_error';\n displayMessage = 'Could not connect to the AI service. Check your internet connection and try again.';\n } else if (isProcessExit) {\n code = 'process_error';\n displayMessage = 'The AI agent process exited unexpectedly. Try running again with --debug for details.';\n }\n\n writeNDJSON({ type: 'error', code, message: displayMessage });\n this.debugLog(stack ?? '');\n };\n}\n"]}
|
package/dist/lib/agent-runner.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getReference } from '@workos/skills';
|
|
2
2
|
import { SPINNER_MESSAGE } from './framework-config.js';
|
|
3
3
|
import { validateInstallation, quickCheckValidateAndFormat } from './validation/index.js';
|
|
4
|
+
import { runInstallSecurityChecks, securityFindingsToIssues, formatSecurityFindingsForAgent, formatBlockingSecurityError, } from './validation/security-checks.js';
|
|
4
5
|
import { ensurePackageIsInstalled, getOrAskForWorkOSCredentials, getPackageDotJson, isUsingTypeScript, } from '../utils/clack-utils.js';
|
|
5
6
|
import { analytics } from '../utils/analytics.js';
|
|
6
7
|
import { INSTALLER_INTERACTION_EVENT_NAME } from './constants.js';
|
|
@@ -82,11 +83,27 @@ export async function runAgentInstaller(config, options) {
|
|
|
82
83
|
workOSApiKey: apiKey,
|
|
83
84
|
workOSApiHost: 'https://api.workos.com',
|
|
84
85
|
}, options);
|
|
86
|
+
const integration = config.metadata.integration;
|
|
85
87
|
const retryConfig = options.noValidate
|
|
86
88
|
? undefined
|
|
87
89
|
: {
|
|
88
90
|
maxRetries: options.maxRetries ?? 2,
|
|
89
|
-
|
|
91
|
+
// Self-correction combines two layers: build/typecheck (existing) AND the
|
|
92
|
+
// security subset of doctor's auth-pattern checks. The latter is what was
|
|
93
|
+
// missing — it's why an insecure GET sign-out could pass the build and
|
|
94
|
+
// ship as a "successful" install. Only error-severity security findings
|
|
95
|
+
// force a retry; warning findings ride along in the prompt only when a
|
|
96
|
+
// retry is already triggered by an error or a build failure (warnings are
|
|
97
|
+
// still surfaced in the final validation report regardless).
|
|
98
|
+
validateAndFormat: async (workingDirectory) => {
|
|
99
|
+
const quickPrompt = await quickCheckValidateAndFormat(workingDirectory);
|
|
100
|
+
const security = await runInstallSecurityChecks(integration, workingDirectory);
|
|
101
|
+
if (quickPrompt === null && security.blocking.length === 0)
|
|
102
|
+
return null;
|
|
103
|
+
return [quickPrompt, formatSecurityFindingsForAgent(security.findings)]
|
|
104
|
+
.filter((p) => Boolean(p))
|
|
105
|
+
.join('\n\n');
|
|
106
|
+
},
|
|
90
107
|
};
|
|
91
108
|
// Run agent with retry support — agent gets correction prompts on validation failure
|
|
92
109
|
const agentResult = await runAgent(agent, integrationPrompt, options, {
|
|
@@ -102,30 +119,52 @@ export async function runAgentInstaller(config, options) {
|
|
|
102
119
|
// "Agent SDK error:" — that prefix obscures the actionable text.
|
|
103
120
|
throw new Error(message);
|
|
104
121
|
}
|
|
105
|
-
// Track retry metrics
|
|
106
|
-
if (agentResult.retryCount !== undefined && agentResult.retryCount > 0) {
|
|
107
|
-
analytics.capture(INSTALLER_INTERACTION_EVENT_NAME, {
|
|
108
|
-
action: 'agent retry summary',
|
|
109
|
-
retry_count: agentResult.retryCount,
|
|
110
|
-
max_retries: options.maxRetries ?? 2,
|
|
111
|
-
passed_after_retry: true,
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
122
|
// Run full validation after agent (with retries) completes
|
|
115
123
|
// Quick checks already ran inside the retry loop — skip build
|
|
116
124
|
if (!options.noValidate) {
|
|
117
|
-
options.emitter?.emit('validation:start', { framework:
|
|
118
|
-
const validationResult = await validateInstallation(
|
|
125
|
+
options.emitter?.emit('validation:start', { framework: integration });
|
|
126
|
+
const validationResult = await validateInstallation(integration, options.installDir, {
|
|
119
127
|
runBuild: false,
|
|
120
128
|
});
|
|
121
|
-
|
|
122
|
-
|
|
129
|
+
// Run doctor's security subset as the final gate. Its absence here is the
|
|
130
|
+
// install-validate ↔ doctor gap: install reported success while `workos
|
|
131
|
+
// doctor` immediately found a SIGNOUT_GET_HANDLER hole.
|
|
132
|
+
const security = await runInstallSecurityChecks(integration, options.installDir);
|
|
133
|
+
const allIssues = [...validationResult.issues, ...securityFindingsToIssues(security.findings)];
|
|
134
|
+
if (allIssues.length > 0) {
|
|
135
|
+
options.emitter?.emit('validation:issues', { issues: allIssues });
|
|
123
136
|
}
|
|
124
137
|
options.emitter?.emit('validation:complete', {
|
|
125
|
-
passed: validationResult.passed,
|
|
126
|
-
issueCount:
|
|
138
|
+
passed: validationResult.passed && security.blocking.length === 0,
|
|
139
|
+
issueCount: allIssues.length,
|
|
127
140
|
durationMs: validationResult.durationMs,
|
|
128
141
|
});
|
|
142
|
+
// Block success: an error-severity security finding that survived the
|
|
143
|
+
// self-correction retries fails the install rather than shipping silently.
|
|
144
|
+
// Throwing routes through the state machine's error state (success: false,
|
|
145
|
+
// non-zero exit) and skips the commit/PR steps, leaving the insecure code
|
|
146
|
+
// uncommitted for the user to inspect.
|
|
147
|
+
if (security.blocking.length > 0) {
|
|
148
|
+
analytics.capture(INSTALLER_INTERACTION_EVENT_NAME, {
|
|
149
|
+
action: 'security gate blocked install',
|
|
150
|
+
integration,
|
|
151
|
+
codes: security.blocking.map((f) => f.code).join(','),
|
|
152
|
+
});
|
|
153
|
+
await analytics.shutdown('error');
|
|
154
|
+
throw new Error(formatBlockingSecurityError(security.blocking));
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
// Track retry metrics AFTER the security gate. `passed_after_retry` must
|
|
158
|
+
// reflect a genuinely successful install, not just an exhausted retry loop —
|
|
159
|
+
// emitting it before the gate could pair a "passed after retry" event with a
|
|
160
|
+
// "security gate blocked install" failure for the same run.
|
|
161
|
+
if (agentResult.retryCount !== undefined && agentResult.retryCount > 0) {
|
|
162
|
+
analytics.capture(INSTALLER_INTERACTION_EVENT_NAME, {
|
|
163
|
+
action: 'agent retry summary',
|
|
164
|
+
retry_count: agentResult.retryCount,
|
|
165
|
+
max_retries: options.maxRetries ?? 2,
|
|
166
|
+
passed_after_retry: true,
|
|
167
|
+
});
|
|
129
168
|
}
|
|
130
169
|
// Build environment variables from WorkOS credentials
|
|
131
170
|
const envVars = config.environment.getEnvVars(apiKey, clientId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-runner.js","sourceRoot":"","sources":["../../src/lib/agent-runner.ts"],"names":[],"mappings":"AA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B;IAC7F,MAAM,KAAK,GAAa,CAAC,wCAAwC,EAAE,EAAE,CAAC,CAAC;IAEvE,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,KAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAClC,KAAK,MAAM,MAAM,IAAI,OAAO;YAAE,KAAK,CAAC,IAAI,CAAC,KAAK,MAAM,EAAE,CAAC,CAAC;QACxD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IAED,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzB,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC1B,KAAK,MAAM,IAAI,IAAI,SAAS;YAAE,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;QACtD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,IAAI,CACR,eAAe,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,EACxC,EAAE,EACF,4GAA4G,CAC7G,CAAC;IAEF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC","sourcesContent":["import { getReference } from '@workos/skills';\nimport { SPINNER_MESSAGE, type FrameworkConfig } from './framework-config.js';\nimport { validateInstallation, quickCheckValidateAndFormat } from './validation/index.js';\nimport type { InstallerOptions } from '../utils/types.js';\nimport {\n ensurePackageIsInstalled,\n getOrAskForWorkOSCredentials,\n getPackageDotJson,\n isUsingTypeScript,\n} from '../utils/clack-utils.js';\nimport { analytics } from '../utils/analytics.js';\nimport { INSTALLER_INTERACTION_EVENT_NAME } from './constants.js';\nimport { initializeAgent, runAgent, type RetryConfig } from './agent-interface.js';\nimport { uploadEnvironmentVariablesStep } from '../steps/index.js';\nimport { autoConfigureWorkOSEnvironment } from './workos-management.js';\nimport { detectPort, getCallbackPath } from './port-detection.js';\nimport { writeEnvLocal } from './env-writer.js';\n\n/**\n * Universal agent-powered wizard runner.\n * Handles the complete flow for any framework using WorkOS MCP integration.\n *\n * @returns A detailed summary of what was done and next steps\n */\nexport async function runAgentInstaller(config: FrameworkConfig, options: InstallerOptions): Promise<string> {\n // Emit status for UI adapters to render\n options.emitter?.emit('status', {\n message: `Setting up WorkOS AuthKit for ${config.metadata.name}`,\n });\n\n const typeScriptDetected = isUsingTypeScript(options);\n\n // Git check is now handled by the state machine - no need to check here\n\n // Framework detection and version\n const packageJson = await getPackageDotJson(options);\n await ensurePackageIsInstalled(packageJson, config.detection.packageName, config.detection.packageDisplayName);\n\n const frameworkVersion = config.detection.getVersion(packageJson);\n\n // Set analytics tags for framework version\n if (frameworkVersion && config.detection.getVersionBucket) {\n const versionBucket = config.detection.getVersionBucket(frameworkVersion);\n analytics.setTag(`${config.metadata.integration}-version`, versionBucket);\n }\n\n analytics.capture(INSTALLER_INTERACTION_EVENT_NAME, {\n action: 'started agent integration',\n integration: config.metadata.integration,\n });\n\n // Get WorkOS credentials (API key optional for client-only SDKs)\n const { apiKey, clientId } = await getOrAskForWorkOSCredentials(options, config.environment.requiresApiKey);\n\n // Check if caller (state machine) already configured WorkOS environment\n // If credentials were passed via options, the caller handled config+env writing\n const callerHandledConfig = Boolean(options.apiKey || options.clientId);\n\n // Auto-configure WorkOS environment (redirect URI, CORS, homepage)\n // Skip if caller already handled this (prevents duplicate dashboard config output)\n if (!callerHandledConfig && apiKey && config.environment.requiresApiKey) {\n const port = detectPort(config.metadata.integration, options.installDir);\n await autoConfigureWorkOSEnvironment(apiKey, config.metadata.integration, port, {\n homepageUrl: options.homepageUrl,\n redirectUri: options.redirectUri,\n });\n }\n\n // Gather framework-specific context (e.g., Next.js router, React Native platform)\n const frameworkContext = config.metadata.gatherContext ? await config.metadata.gatherContext(options) : {};\n\n // Write environment variables to .env.local BEFORE agent runs\n // Skip if caller already handled this (prevents double-writing)\n if (!callerHandledConfig) {\n const port = detectPort(config.metadata.integration, options.installDir);\n const callbackPath = getCallbackPath(config.metadata.integration);\n const redirectUri = options.redirectUri || `http://localhost:${port}${callbackPath}`;\n\n // Next.js requires NEXT_PUBLIC_ prefix for client-side env vars\n const redirectUriKey =\n config.metadata.integration === 'nextjs' ? 'NEXT_PUBLIC_WORKOS_REDIRECT_URI' : 'WORKOS_REDIRECT_URI';\n\n writeEnvLocal(options.installDir, {\n ...(apiKey ? { WORKOS_API_KEY: apiKey } : {}),\n WORKOS_CLIENT_ID: clientId,\n [redirectUriKey]: redirectUri,\n });\n }\n\n // Set analytics tags from framework context\n const contextTags = config.analytics.getTags(frameworkContext);\n Object.entries(contextTags).forEach(([key, value]) => {\n analytics.setTag(key, value);\n });\n\n // Build integration prompt (credentials are already in .env.local)\n const integrationPrompt = await buildIntegrationPrompt(\n config,\n {\n frameworkVersion: frameworkVersion || 'latest',\n typescript: typeScriptDetected,\n },\n frameworkContext,\n );\n\n // Initialize and run agent\n // Spinner is now handled by adapters listening to agent:start/agent:progress events\n const agent = await initializeAgent(\n {\n workingDirectory: options.installDir,\n workOSApiKey: apiKey,\n workOSApiHost: 'https://api.workos.com',\n },\n options,\n );\n\n const retryConfig: RetryConfig | undefined = options.noValidate\n ? undefined\n : {\n maxRetries: options.maxRetries ?? 2,\n validateAndFormat: quickCheckValidateAndFormat,\n };\n\n // Run agent with retry support — agent gets correction prompts on validation failure\n const agentResult = await runAgent(\n agent,\n integrationPrompt,\n options,\n {\n spinnerMessage: SPINNER_MESSAGE,\n successMessage: config.ui.successMessage,\n errorMessage: 'Integration failed',\n },\n options.emitter,\n retryConfig,\n );\n\n // If agent returned an error, throw so state machine can handle it\n if (agentResult.error) {\n await analytics.shutdown('error');\n const message = agentResult.errorMessage || agentResult.error;\n // Pass user-friendly messages through without wrapping them in\n // \"Agent SDK error:\" — that prefix obscures the actionable text.\n throw new Error(message);\n }\n\n // Track retry metrics\n if (agentResult.retryCount !== undefined && agentResult.retryCount > 0) {\n analytics.capture(INSTALLER_INTERACTION_EVENT_NAME, {\n action: 'agent retry summary',\n retry_count: agentResult.retryCount,\n max_retries: options.maxRetries ?? 2,\n passed_after_retry: true,\n });\n }\n\n // Run full validation after agent (with retries) completes\n // Quick checks already ran inside the retry loop — skip build\n if (!options.noValidate) {\n options.emitter?.emit('validation:start', { framework: config.metadata.integration });\n\n const validationResult = await validateInstallation(config.metadata.integration, options.installDir, {\n runBuild: false,\n });\n\n if (validationResult.issues.length > 0) {\n options.emitter?.emit('validation:issues', { issues: validationResult.issues });\n }\n\n options.emitter?.emit('validation:complete', {\n passed: validationResult.passed,\n issueCount: validationResult.issues.length,\n durationMs: validationResult.durationMs,\n });\n }\n\n // Build environment variables from WorkOS credentials\n const envVars = config.environment.getEnvVars(apiKey, clientId);\n\n // Upload environment variables to hosting providers (if configured)\n let uploadedEnvVars: string[] = [];\n if (config.environment.uploadToHosting) {\n uploadedEnvVars = await uploadEnvironmentVariablesStep(envVars, {\n integration: config.metadata.integration,\n options,\n });\n }\n\n const changes = [\n ...config.ui.getOutroChanges(frameworkContext),\n Object.keys(envVars).length > 0 ? `Added environment variables to .env file` : '',\n uploadedEnvVars.length > 0 ? `Uploaded environment variables to your hosting provider` : '',\n ].filter(Boolean);\n\n const nextSteps = [\n ...config.ui.getOutroNextSteps(frameworkContext),\n uploadedEnvVars.length === 0 && config.environment.uploadToHosting\n ? `Upload your WorkOS credentials to your hosting provider`\n : '',\n ].filter(Boolean);\n\n const summary = buildCompletionSummary(config, changes, nextSteps);\n\n await analytics.shutdown('success');\n\n return summary;\n}\n\n/**\n * Build the integration prompt for the agent.\n * Reads reference content from @workos/skills and injects it directly into the prompt.\n * Note: Credentials are pre-written to .env.local, so not included in prompt.\n */\nasync function buildIntegrationPrompt(\n config: FrameworkConfig,\n context: {\n frameworkVersion: string;\n typescript: boolean;\n },\n frameworkContext: Record<string, any>,\n): Promise<string> {\n const additionalLines = config.prompts.getAdditionalContextLines\n ? config.prompts.getAdditionalContextLines(frameworkContext)\n : [];\n\n const additionalContext =\n additionalLines.length > 0 ? '\\n' + additionalLines.map((line) => `- ${line}`).join('\\n') : '';\n\n const skillName = config.metadata.skillName;\n if (!skillName) {\n throw new Error(`Framework ${config.metadata.name} missing skillName in config`);\n }\n\n // Read reference content from @workos/skills package\n // Base template has JS-centric assumptions (node_modules, lockfiles, AuthKitProvider)\n // so only load it for JavaScript integrations; backend SDKs bypass this entirely\n const isJavaScript = config.metadata.language === 'javascript';\n const [baseContent, refContent] = await Promise.all([\n isJavaScript ? getReference('workos-authkit-base') : Promise.resolve(''),\n getReference(skillName),\n ]);\n\n // Build env var list dynamically based on what was actually configured\n const envVars = [\n ...(config.environment.requiresApiKey ? ['WORKOS_API_KEY'] : []),\n 'WORKOS_CLIENT_ID',\n config.metadata.integration === 'nextjs' ? 'NEXT_PUBLIC_WORKOS_REDIRECT_URI' : 'WORKOS_REDIRECT_URI',\n 'WORKOS_COOKIE_PASSWORD',\n ];\n const envVarList = envVars.map((v) => `- ${v}`).join('\\n');\n\n return `You are integrating WorkOS AuthKit into this ${config.metadata.name} application.\n\n## Project Context\n\n- Framework: ${config.metadata.name} ${context.frameworkVersion}\n- TypeScript: ${context.typescript ? 'Yes' : 'No'}${additionalContext}\n\n## Environment\n\nThe following environment variables have been configured in .env.local:\n${envVarList}\n\n${baseContent ? `## General Guidelines\\n\\n${baseContent}\\n\\n` : ''}## Integration Instructions\n\n${refContent}\n\nReport your progress using [STATUS] prefixes.\n\nBegin integration now.`;\n}\n\nfunction buildCompletionSummary(config: FrameworkConfig, changes: string[], nextSteps: string[]): string {\n const lines: string[] = ['Successfully installed WorkOS AuthKit!', ''];\n\n if (changes.length > 0) {\n lines.push('What the agent did:');\n for (const change of changes) lines.push(`• ${change}`);\n lines.push('');\n }\n\n if (nextSteps.length > 0) {\n lines.push('Next steps:');\n for (const step of nextSteps) lines.push(`• ${step}`);\n lines.push('');\n }\n\n lines.push(\n `Learn more: ${config.metadata.docsUrl}`,\n '',\n 'Note: This installer uses an LLM agent to analyze and modify your project. Please review the changes made.',\n );\n\n return lines.join('\\n');\n}\n"]}
|
|
1
|
+
{"version":3,"file":"agent-runner.js","sourceRoot":"","sources":["../../src/lib/agent-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAwB,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAC1F,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,8BAA8B,EAC9B,2BAA2B,GAC5B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,wBAAwB,EACxB,4BAA4B,EAC5B,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,gCAAgC,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAoB,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAE,8BAA8B,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,MAAuB,EAAE,OAAyB;IACxF,wCAAwC;IACxC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE;QAC9B,OAAO,EAAE,iCAAiC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE;KACjE,CAAC,CAAC;IAEH,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAEtD,wEAAwE;IAExE,kCAAkC;IAClC,MAAM,WAAW,GAAG,MAAM,iBA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SPINNER_MESSAGE, type FrameworkConfig } from './framework-config.js';\nimport { validateInstallation, quickCheckValidateAndFormat } from './validation/index.js';\nimport {\n runInstallSecurityChecks,\n securityFindingsToIssues,\n formatSecurityFindingsForAgent,\n formatBlockingSecurityError,\n} from './validation/security-checks.js';\nimport type { InstallerOptions } from '../utils/types.js';\nimport {\n ensurePackageIsInstalled,\n getOrAskForWorkOSCredentials,\n getPackageDotJson,\n isUsingTypeScript,\n} from '../utils/clack-utils.js';\nimport { analytics } from '../utils/analytics.js';\nimport { INSTALLER_INTERACTION_EVENT_NAME } from './constants.js';\nimport { initializeAgent, runAgent, type RetryConfig } from './agent-interface.js';\nimport { uploadEnvironmentVariablesStep } from '../steps/index.js';\nimport { autoConfigureWorkOSEnvironment } from './workos-management.js';\nimport { detectPort, getCallbackPath } from './port-detection.js';\nimport { writeEnvLocal } from './env-writer.js';\n\n/**\n * Universal agent-powered wizard runner.\n * Handles the complete flow for any framework using WorkOS MCP integration.\n *\n * @returns A detailed summary of what was done and next steps\n */\nexport async function runAgentInstaller(config: FrameworkConfig, options: InstallerOptions): Promise<string> {\n // Emit status for UI adapters to render\n options.emitter?.emit('status', {\n message: `Setting up WorkOS AuthKit for ${config.metadata.name}`,\n });\n\n const typeScriptDetected = isUsingTypeScript(options);\n\n // Git check is now handled by the state machine - no need to check here\n\n // Framework detection and version\n const packageJson = await getPackageDotJson(options);\n await ensurePackageIsInstalled(packageJson, config.detection.packageName, config.detection.packageDisplayName);\n\n const frameworkVersion = config.detection.getVersion(packageJson);\n\n // Set analytics tags for framework version\n if (frameworkVersion && config.detection.getVersionBucket) {\n const versionBucket = config.detection.getVersionBucket(frameworkVersion);\n analytics.setTag(`${config.metadata.integration}-version`, versionBucket);\n }\n\n analytics.capture(INSTALLER_INTERACTION_EVENT_NAME, {\n action: 'started agent integration',\n integration: config.metadata.integration,\n });\n\n // Get WorkOS credentials (API key optional for client-only SDKs)\n const { apiKey, clientId } = await getOrAskForWorkOSCredentials(options, config.environment.requiresApiKey);\n\n // Check if caller (state machine) already configured WorkOS environment\n // If credentials were passed via options, the caller handled config+env writing\n const callerHandledConfig = Boolean(options.apiKey || options.clientId);\n\n // Auto-configure WorkOS environment (redirect URI, CORS, homepage)\n // Skip if caller already handled this (prevents duplicate dashboard config output)\n if (!callerHandledConfig && apiKey && config.environment.requiresApiKey) {\n const port = detectPort(config.metadata.integration, options.installDir);\n await autoConfigureWorkOSEnvironment(apiKey, config.metadata.integration, port, {\n homepageUrl: options.homepageUrl,\n redirectUri: options.redirectUri,\n });\n }\n\n // Gather framework-specific context (e.g., Next.js router, React Native platform)\n const frameworkContext = config.metadata.gatherContext ? await config.metadata.gatherContext(options) : {};\n\n // Write environment variables to .env.local BEFORE agent runs\n // Skip if caller already handled this (prevents double-writing)\n if (!callerHandledConfig) {\n const port = detectPort(config.metadata.integration, options.installDir);\n const callbackPath = getCallbackPath(config.metadata.integration);\n const redirectUri = options.redirectUri || `http://localhost:${port}${callbackPath}`;\n\n // Next.js requires NEXT_PUBLIC_ prefix for client-side env vars\n const redirectUriKey =\n config.metadata.integration === 'nextjs' ? 'NEXT_PUBLIC_WORKOS_REDIRECT_URI' : 'WORKOS_REDIRECT_URI';\n\n writeEnvLocal(options.installDir, {\n ...(apiKey ? { WORKOS_API_KEY: apiKey } : {}),\n WORKOS_CLIENT_ID: clientId,\n [redirectUriKey]: redirectUri,\n });\n }\n\n // Set analytics tags from framework context\n const contextTags = config.analytics.getTags(frameworkContext);\n Object.entries(contextTags).forEach(([key, value]) => {\n analytics.setTag(key, value);\n });\n\n // Build integration prompt (credentials are already in .env.local)\n const integrationPrompt = await buildIntegrationPrompt(\n config,\n {\n frameworkVersion: frameworkVersion || 'latest',\n typescript: typeScriptDetected,\n },\n frameworkContext,\n );\n\n // Initialize and run agent\n // Spinner is now handled by adapters listening to agent:start/agent:progress events\n const agent = await initializeAgent(\n {\n workingDirectory: options.installDir,\n workOSApiKey: apiKey,\n workOSApiHost: 'https://api.workos.com',\n },\n options,\n );\n\n const integration = config.metadata.integration;\n\n const retryConfig: RetryConfig | undefined = options.noValidate\n ? undefined\n : {\n maxRetries: options.maxRetries ?? 2,\n // Self-correction combines two layers: build/typecheck (existing) AND the\n // security subset of doctor's auth-pattern checks. The latter is what was\n // missing — it's why an insecure GET sign-out could pass the build and\n // ship as a \"successful\" install. Only error-severity security findings\n // force a retry; warning findings ride along in the prompt only when a\n // retry is already triggered by an error or a build failure (warnings are\n // still surfaced in the final validation report regardless).\n validateAndFormat: async (workingDirectory: string) => {\n const quickPrompt = await quickCheckValidateAndFormat(workingDirectory);\n const security = await runInstallSecurityChecks(integration, workingDirectory);\n if (quickPrompt === null && security.blocking.length === 0) return null;\n return [quickPrompt, formatSecurityFindingsForAgent(security.findings)]\n .filter((p): p is string => Boolean(p))\n .join('\\n\\n');\n },\n };\n\n // Run agent with retry support — agent gets correction prompts on validation failure\n const agentResult = await runAgent(\n agent,\n integrationPrompt,\n options,\n {\n spinnerMessage: SPINNER_MESSAGE,\n successMessage: config.ui.successMessage,\n errorMessage: 'Integration failed',\n },\n options.emitter,\n retryConfig,\n );\n\n // If agent returned an error, throw so state machine can handle it\n if (agentResult.error) {\n await analytics.shutdown('error');\n const message = agentResult.errorMessage || agentResult.error;\n // Pass user-friendly messages through without wrapping them in\n // \"Agent SDK error:\" — that prefix obscures the actionable text.\n throw new Error(message);\n }\n\n // Run full validation after agent (with retries) completes\n // Quick checks already ran inside the retry loop — skip build\n if (!options.noValidate) {\n options.emitter?.emit('validation:start', { framework: integration });\n\n const validationResult = await validateInstallation(integration, options.installDir, {\n runBuild: false,\n });\n\n // Run doctor's security subset as the final gate. Its absence here is the\n // install-validate ↔ doctor gap: install reported success while `workos\n // doctor` immediately found a SIGNOUT_GET_HANDLER hole.\n const security = await runInstallSecurityChecks(integration, options.installDir);\n const allIssues = [...validationResult.issues, ...securityFindingsToIssues(security.findings)];\n\n if (allIssues.length > 0) {\n options.emitter?.emit('validation:issues', { issues: allIssues });\n }\n\n options.emitter?.emit('validation:complete', {\n passed: validationResult.passed && security.blocking.length === 0,\n issueCount: allIssues.length,\n durationMs: validationResult.durationMs,\n });\n\n // Block success: an error-severity security finding that survived the\n // self-correction retries fails the install rather than shipping silently.\n // Throwing routes through the state machine's error state (success: false,\n // non-zero exit) and skips the commit/PR steps, leaving the insecure code\n // uncommitted for the user to inspect.\n if (security.blocking.length > 0) {\n analytics.capture(INSTALLER_INTERACTION_EVENT_NAME, {\n action: 'security gate blocked install',\n integration,\n codes: security.blocking.map((f) => f.code).join(','),\n });\n await analytics.shutdown('error');\n throw new Error(formatBlockingSecurityError(security.blocking));\n }\n }\n\n // Track retry metrics AFTER the security gate. `passed_after_retry` must\n // reflect a genuinely successful install, not just an exhausted retry loop —\n // emitting it before the gate could pair a \"passed after retry\" event with a\n // \"security gate blocked install\" failure for the same run.\n if (agentResult.retryCount !== undefined && agentResult.retryCount > 0) {\n analytics.capture(INSTALLER_INTERACTION_EVENT_NAME, {\n action: 'agent retry summary',\n retry_count: agentResult.retryCount,\n max_retries: options.maxRetries ?? 2,\n passed_after_retry: true,\n });\n }\n\n // Build environment variables from WorkOS credentials\n const envVars = config.environment.getEnvVars(apiKey, clientId);\n\n // Upload environment variables to hosting providers (if configured)\n let uploadedEnvVars: string[] = [];\n if (config.environment.uploadToHosting) {\n uploadedEnvVars = await uploadEnvironmentVariablesStep(envVars, {\n integration: config.metadata.integration,\n options,\n });\n }\n\n const changes = [\n ...config.ui.getOutroChanges(frameworkContext),\n Object.keys(envVars).length > 0 ? `Added environment variables to .env file` : '',\n uploadedEnvVars.length > 0 ? `Uploaded environment variables to your hosting provider` : '',\n ].filter(Boolean);\n\n const nextSteps = [\n ...config.ui.getOutroNextSteps(frameworkContext),\n uploadedEnvVars.length === 0 && config.environment.uploadToHosting\n ? `Upload your WorkOS credentials to your hosting provider`\n : '',\n ].filter(Boolean);\n\n const summary = buildCompletionSummary(config, changes, nextSteps);\n\n await analytics.shutdown('success');\n\n return summary;\n}\n\n/**\n * Build the integration prompt for the agent.\n * Reads reference content from @workos/skills and injects it directly into the prompt.\n * Note: Credentials are pre-written to .env.local, so not included in prompt.\n */\nasync function buildIntegrationPrompt(\n config: FrameworkConfig,\n context: {\n frameworkVersion: string;\n typescript: boolean;\n },\n frameworkContext: Record<string, any>,\n): Promise<string> {\n const additionalLines = config.prompts.getAdditionalContextLines\n ? config.prompts.getAdditionalContextLines(frameworkContext)\n : [];\n\n const additionalContext =\n additionalLines.length > 0 ? '\\n' + additionalLines.map((line) => `- ${line}`).join('\\n') : '';\n\n const skillName = config.metadata.skillName;\n if (!skillName) {\n throw new Error(`Framework ${config.metadata.name} missing skillName in config`);\n }\n\n // Read reference content from @workos/skills package\n // Base template has JS-centric assumptions (node_modules, lockfiles, AuthKitProvider)\n // so only load it for JavaScript integrations; backend SDKs bypass this entirely\n const isJavaScript = config.metadata.language === 'javascript';\n const [baseContent, refContent] = await Promise.all([\n isJavaScript ? getReference('workos-authkit-base') : Promise.resolve(''),\n getReference(skillName),\n ]);\n\n // Build env var list dynamically based on what was actually configured\n const envVars = [\n ...(config.environment.requiresApiKey ? ['WORKOS_API_KEY'] : []),\n 'WORKOS_CLIENT_ID',\n config.metadata.integration === 'nextjs' ? 'NEXT_PUBLIC_WORKOS_REDIRECT_URI' : 'WORKOS_REDIRECT_URI',\n 'WORKOS_COOKIE_PASSWORD',\n ];\n const envVarList = envVars.map((v) => `- ${v}`).join('\\n');\n\n return `You are integrating WorkOS AuthKit into this ${config.metadata.name} application.\n\n## Project Context\n\n- Framework: ${config.metadata.name} ${context.frameworkVersion}\n- TypeScript: ${context.typescript ? 'Yes' : 'No'}${additionalContext}\n\n## Environment\n\nThe following environment variables have been configured in .env.local:\n${envVarList}\n\n${baseContent ? `## General Guidelines\\n\\n${baseContent}\\n\\n` : ''}## Integration Instructions\n\n${refContent}\n\nReport your progress using [STATUS] prefixes.\n\nBegin integration now.`;\n}\n\nfunction buildCompletionSummary(config: FrameworkConfig, changes: string[], nextSteps: string[]): string {\n const lines: string[] = ['Successfully installed WorkOS AuthKit!', ''];\n\n if (changes.length > 0) {\n lines.push('What the agent did:');\n for (const change of changes) lines.push(`• ${change}`);\n lines.push('');\n }\n\n if (nextSteps.length > 0) {\n lines.push('Next steps:');\n for (const step of nextSteps) lines.push(`• ${step}`);\n lines.push('');\n }\n\n lines.push(\n `Learn more: ${config.metadata.docsUrl}`,\n '',\n 'Note: This installer uses an LLM agent to analyze and modify your project. Please review the changes made.',\n );\n\n return lines.join('\\n');\n}\n"]}
|
package/dist/lib/events.d.ts
CHANGED
|
@@ -144,6 +144,21 @@ export interface InstallerEvents {
|
|
|
144
144
|
issueCount: number;
|
|
145
145
|
durationMs: number;
|
|
146
146
|
};
|
|
147
|
+
'scaffold:checking': Record<string, never>;
|
|
148
|
+
'scaffold:prompt': {
|
|
149
|
+
packageManager: string;
|
|
150
|
+
};
|
|
151
|
+
'scaffold:start': {
|
|
152
|
+
packageManager: string;
|
|
153
|
+
};
|
|
154
|
+
'scaffold:progress': {
|
|
155
|
+
text: string;
|
|
156
|
+
};
|
|
157
|
+
'scaffold:complete': Record<string, never>;
|
|
158
|
+
'scaffold:failed': {
|
|
159
|
+
error: string;
|
|
160
|
+
};
|
|
161
|
+
'scaffold:skipped': Record<string, never>;
|
|
147
162
|
'branch:checking': Record<string, never>;
|
|
148
163
|
'branch:protected': {
|
|
149
164
|
branch: string;
|
package/dist/lib/events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/lib/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/lib/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAoGtC,MAAM,OAAO,qBAAsB,SAAQ,YAAY;IACrD,IAAI,CAA+B,KAAQ,EAAE,OAA2B;QACtE,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACpC,CAAC;IAED,EAAE,CAA+B,KAAQ,EAAE,QAA+C;QACxF,OAAO,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;IAED,GAAG,CAA+B,KAAQ,EAAE,QAA+C;QACzF,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACpC,CAAC;IAED,IAAI,CAA+B,KAAQ,EAAE,QAA+C;QAC1F,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACrC,CAAC;CACF;AAED,MAAM,UAAU,2BAA2B;IACzC,OAAO,IAAI,qBAAqB,EAAE,CAAC;AACrC,CAAC","sourcesContent":["import { EventEmitter } from 'events';\n\nexport interface InstallerEvents {\n status: { message: string };\n output: { text: string; isError?: boolean };\n 'file:write': { path: string; content: string };\n 'file:edit': { path: string; oldContent: string; newContent: string };\n 'prompt:request': { id: string; message: string; options?: string[] };\n 'prompt:response': { id: string; value: string };\n 'confirm:request': { id: string; message: string; warning?: string; files?: string[] };\n 'confirm:response': { id: string; confirmed: boolean };\n 'credentials:request': { requiresApiKey: boolean };\n 'credentials:response': { apiKey: string; clientId: string };\n complete: { success: boolean; summary?: string };\n error: { message: string; stack?: string };\n\n 'state:enter': { state: string };\n 'state:exit': { state: string };\n 'auth:checking': Record<string, never>;\n 'auth:required': Record<string, never>;\n 'auth:success': Record<string, never>;\n 'auth:failure': { message: string };\n 'detection:start': Record<string, never>;\n 'detection:complete': { integration: string };\n 'detection:none': Record<string, never>;\n 'git:checking': Record<string, never>;\n 'git:clean': Record<string, never>;\n 'git:dirty': { files: string[] };\n 'git:dirty:confirmed': Record<string, never>;\n 'git:dirty:cancelled': Record<string, never>;\n 'credentials:gathering': { requiresApiKey: boolean };\n 'credentials:found': Record<string, never>;\n // Credential discovery events\n 'credentials:env:detected': { files: string[] };\n 'credentials:env:prompt': { files: string[] };\n 'credentials:env:scanning': Record<string, never>;\n 'credentials:env:found': { sourcePath: string };\n 'credentials:env:notfound': Record<string, never>;\n // Device auth events\n 'device:started': { verificationUri: string; verificationUriComplete: string; userCode: string };\n 'device:polling': Record<string, never>;\n 'device:success': { email?: string };\n 'device:timeout': Record<string, never>;\n 'device:error': { message: string };\n // Staging API events\n 'staging:fetching': Record<string, never>;\n 'staging:success': Record<string, never>;\n 'staging:error': { message: string; statusCode?: number };\n 'config:start': Record<string, never>;\n 'config:complete': Record<string, never>;\n 'agent:start': Record<string, never>;\n 'agent:progress': { step: string; detail?: string };\n 'agent:success': { summary?: string };\n 'agent:failure': { message: string; stack?: string };\n 'agent:retry': { attempt: number; maxRetries: number };\n\n 'validation:retry:start': { attempt: number };\n 'validation:retry:complete': { attempt: number; passed: boolean };\n\n 'validation:start': { framework: string };\n 'validation:issues': { issues: import('./validation/types.js').ValidationIssue[] };\n 'validation:complete': { passed: boolean; issueCount: number; durationMs: number };\n\n // Scaffold events (empty-directory app scaffolding)\n 'scaffold:checking': Record<string, never>;\n 'scaffold:prompt': { packageManager: string };\n 'scaffold:start': { packageManager: string };\n 'scaffold:progress': { text: string };\n 'scaffold:complete': Record<string, never>;\n 'scaffold:failed': { error: string };\n 'scaffold:skipped': Record<string, never>;\n\n // Branch check events\n 'branch:checking': Record<string, never>;\n 'branch:protected': { branch: string };\n 'branch:prompt': { branch: string };\n 'branch:created': { branch: string };\n 'branch:create:failed': { error: string };\n 'branch:skipped': Record<string, never>;\n\n // Post-install events\n 'postinstall:changes': { files: string[] };\n 'postinstall:nochanges': Record<string, never>;\n 'postinstall:commit:prompt': Record<string, never>;\n 'postinstall:commit:generating': Record<string, never>;\n 'postinstall:commit:committing': { message: string };\n 'postinstall:commit:success': { message: string };\n 'postinstall:commit:failed': { error: string };\n 'postinstall:pr:prompt': Record<string, never>;\n 'postinstall:pr:generating': Record<string, never>;\n 'postinstall:pr:pushing': Record<string, never>;\n 'postinstall:pr:creating': Record<string, never>;\n 'postinstall:pr:success': { url: string };\n 'postinstall:pr:failed': { error: string };\n 'postinstall:push:failed': { error: string };\n 'postinstall:manual': { instructions: string };\n}\n\nexport type InstallerEventName = keyof InstallerEvents;\n\nexport class InstallerEventEmitter extends EventEmitter {\n emit<K extends InstallerEventName>(event: K, payload: InstallerEvents[K]): boolean {\n return super.emit(event, payload);\n }\n\n on<K extends InstallerEventName>(event: K, listener: (payload: InstallerEvents[K]) => void): this {\n return super.on(event, listener);\n }\n\n off<K extends InstallerEventName>(event: K, listener: (payload: InstallerEvents[K]) => void): this {\n return super.off(event, listener);\n }\n\n once<K extends InstallerEventName>(event: K, listener: (payload: InstallerEvents[K]) => void): this {\n return super.once(event, listener);\n }\n}\n\nexport function createInstallerEventEmitter(): InstallerEventEmitter {\n return new InstallerEventEmitter();\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ActorRefFrom } from 'xstate';
|
|
2
|
-
import type { InstallerMachineContext, InstallerMachineInput, DetectionOutput, GitCheckOutput, AgentOutput, EnvFileInfo, DiscoveryResult, BranchCheckOutput } from './installer-core.types.js';
|
|
2
|
+
import type { InstallerMachineContext, InstallerMachineInput, DetectionOutput, GitCheckOutput, AgentOutput, EnvFileInfo, DiscoveryResult, BranchCheckOutput, WorkspaceCheckOutput } from './installer-core.types.js';
|
|
3
3
|
import type { InstallerOptions } from '../utils/types.js';
|
|
4
4
|
import type { DeviceAuthResult, DeviceAuthResponse } from './device-auth.js';
|
|
5
5
|
import type { StagingCredentials } from './staging-api.js';
|
|
@@ -11,6 +11,10 @@ export declare const installerMachine: import("xstate").StateMachine<InstallerMa
|
|
|
11
11
|
type: "GIT_CONFIRMED";
|
|
12
12
|
} | {
|
|
13
13
|
type: "GIT_CANCELLED";
|
|
14
|
+
} | {
|
|
15
|
+
type: "SCAFFOLD_CONFIRMED";
|
|
16
|
+
} | {
|
|
17
|
+
type: "SCAFFOLD_CANCELLED";
|
|
14
18
|
} | {
|
|
15
19
|
type: "CREDENTIALS_SUBMITTED";
|
|
16
20
|
apiKey: string;
|
|
@@ -44,6 +48,10 @@ export declare const installerMachine: import("xstate").StateMachine<InstallerMa
|
|
|
44
48
|
cwd: string;
|
|
45
49
|
}, import("xstate").EventObject>> | import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<boolean, {
|
|
46
50
|
options: InstallerOptions;
|
|
51
|
+
}, import("xstate").EventObject>> | import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<WorkspaceCheckOutput, {
|
|
52
|
+
options: InstallerOptions;
|
|
53
|
+
}, import("xstate").EventObject>> | import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<void, {
|
|
54
|
+
context: InstallerMachineContext;
|
|
47
55
|
}, import("xstate").EventObject>> | import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<DetectionOutput, {
|
|
48
56
|
options: InstallerOptions;
|
|
49
57
|
}, import("xstate").EventObject>> | import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<GitCheckOutput, {
|
|
@@ -98,6 +106,18 @@ export declare const installerMachine: import("xstate").StateMachine<InstallerMa
|
|
|
98
106
|
options: InstallerOptions;
|
|
99
107
|
}, import("xstate").EventObject>;
|
|
100
108
|
id: string | undefined;
|
|
109
|
+
} | {
|
|
110
|
+
src: "checkWorkspace";
|
|
111
|
+
logic: import("xstate").PromiseActorLogic<WorkspaceCheckOutput, {
|
|
112
|
+
options: InstallerOptions;
|
|
113
|
+
}, import("xstate").EventObject>;
|
|
114
|
+
id: string | undefined;
|
|
115
|
+
} | {
|
|
116
|
+
src: "runScaffold";
|
|
117
|
+
logic: import("xstate").PromiseActorLogic<void, {
|
|
118
|
+
context: InstallerMachineContext;
|
|
119
|
+
}, import("xstate").EventObject>;
|
|
120
|
+
id: string | undefined;
|
|
101
121
|
} | {
|
|
102
122
|
src: "detectIntegration";
|
|
103
123
|
logic: import("xstate").PromiseActorLogic<DetectionOutput, {
|
|
@@ -244,6 +264,30 @@ export declare const installerMachine: import("xstate").StateMachine<InstallerMa
|
|
|
244
264
|
} | {
|
|
245
265
|
type: "emitGitCancelled";
|
|
246
266
|
params: unknown;
|
|
267
|
+
} | {
|
|
268
|
+
type: "emitScaffoldChecking";
|
|
269
|
+
params: unknown;
|
|
270
|
+
} | {
|
|
271
|
+
type: "emitScaffoldPrompt";
|
|
272
|
+
params: unknown;
|
|
273
|
+
} | {
|
|
274
|
+
type: "emitScaffoldStart";
|
|
275
|
+
params: unknown;
|
|
276
|
+
} | {
|
|
277
|
+
type: "emitScaffoldComplete";
|
|
278
|
+
params: unknown;
|
|
279
|
+
} | {
|
|
280
|
+
type: "emitScaffoldFailed";
|
|
281
|
+
params: unknown;
|
|
282
|
+
} | {
|
|
283
|
+
type: "emitScaffoldSkipped";
|
|
284
|
+
params: unknown;
|
|
285
|
+
} | {
|
|
286
|
+
type: "assignWorkspaceResult";
|
|
287
|
+
params: unknown;
|
|
288
|
+
} | {
|
|
289
|
+
type: "assignScaffolded";
|
|
290
|
+
params: unknown;
|
|
247
291
|
} | {
|
|
248
292
|
type: "emitBranchChecking";
|
|
249
293
|
params: unknown;
|
|
@@ -416,7 +460,15 @@ export declare const installerMachine: import("xstate").StateMachine<InstallerMa
|
|
|
416
460
|
} | {
|
|
417
461
|
type: "hasGhCli";
|
|
418
462
|
params: unknown;
|
|
463
|
+
} | {
|
|
464
|
+
type: "notScaffoldable";
|
|
465
|
+
params: unknown;
|
|
466
|
+
} | {
|
|
467
|
+
type: "shouldAutoScaffold";
|
|
468
|
+
params: unknown;
|
|
419
469
|
}, never, "error" | "cancelled" | "complete" | "idle" | "authenticating" | "configuring" | "runningAgent" | {
|
|
470
|
+
scaffold: "done" | "checking" | "running" | "prompting";
|
|
471
|
+
} | {
|
|
420
472
|
preparing: {
|
|
421
473
|
detection: "done" | "running";
|
|
422
474
|
gitCheck: "done" | "running" | "evaluating" | "awaitingConfirmation";
|
|
@@ -431,6 +483,14 @@ export declare const installerMachine: import("xstate").StateMachine<InstallerMa
|
|
|
431
483
|
states: {
|
|
432
484
|
readonly idle: {};
|
|
433
485
|
readonly authenticating: {};
|
|
486
|
+
readonly scaffold: {
|
|
487
|
+
states: {
|
|
488
|
+
readonly checking: {};
|
|
489
|
+
readonly prompting: {};
|
|
490
|
+
readonly running: {};
|
|
491
|
+
readonly done: {};
|
|
492
|
+
};
|
|
493
|
+
};
|
|
434
494
|
readonly preparing: {
|
|
435
495
|
states: {
|
|
436
496
|
readonly detection: {
|