workos 0.1.0 → 0.1.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.
@@ -1,5 +1,4 @@
1
1
  import { createActor, fromPromise } from 'xstate';
2
- import { createSkyInspector } from '@statelyai/inspect';
3
2
  import open from 'opn';
4
3
  import { existsSync, readFileSync } from 'fs';
5
4
  import { join } from 'path';
@@ -189,6 +188,7 @@ export async function runWithCore(options) {
189
188
  }),
190
189
  },
191
190
  });
191
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
192
192
  let inspector;
193
193
  if (augmentedOptions.inspect) {
194
194
  const originalLog = console.log;
@@ -205,6 +205,8 @@ export async function runWithCore(options) {
205
205
  originalLog.apply(console, args);
206
206
  }
207
207
  };
208
+ // Dynamic import - @statelyai/inspect is a devDependency
209
+ const { createSkyInspector } = await import('@statelyai/inspect');
208
210
  inspector = createSkyInspector();
209
211
  setTimeout(() => {
210
212
  console.log = originalLog;
@@ -1 +1 @@
1
- {"version":3,"file":"run-with-core.js","sourceRoot":"","sources":["../../../src/lib/run-with-core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,IAAI,MAAM,KAAK,CAAC;AACvB,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAInE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,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AAK,EAAE,CAAC,GAAG,EAAE,EAAE;oBACb,YAAY,GAAG,OAAO,CAAC;oBACvB,MAAM,CAAC,GAAG,CAAC,CAAC;gBACd,CAAC;aACF,CAAC,CAAC;YAEH,KAAM,CAAC,KAAK,EAAE,CAAC;YACf,KAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,YAAY,GAAG,OAAO,CAAC;QACvB,QAAQ,CAAC,2BAA2B,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAC7G,MAAM,KAAK,CAAC;IACd,CAAC;YAAS,CAAC;QACT,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QACpC,MAAM,SAAS,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QACvC,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC;IACvB,CAAC;AACH,CAAC","sourcesContent":["import { createActor, fromPromise } from 'xstate';\nimport { createSkyInspector } from '@statelyai/inspect';\nimport open from 'opn';\nimport { existsSync, readFileSync } from 'fs';\nimport { join } from 'path';\nimport { wizardMachine } from './wizard-core.js';\nimport { createWizardEventEmitter } from './events.js';\nimport { CLIAdapter } from './adapters/cli-adapter.js';\nimport { DashboardAdapter } from './adapters/dashboard-adapter.js';\nimport type { WizardAdapter } from './adapters/types.js';\nimport type { WizardOptions } from '../utils/types.js';\nimport type { WizardMachineContext, DetectionOutput, GitCheckOutput, AgentOutput } from './wizard-core.types.js';\nimport { Integration } from './constants.js';\nimport { parseEnvFile } from '../utils/env-parser.js';\nimport { enableDebugLogs, initLogFile, logInfo, logError } from '../utils/debug.js';\n\nimport { getAccessToken, getCredentials } from './credentials.js';\nimport { analytics } from '../utils/analytics.js';\nimport { getVersion } from './settings.js';\nimport { getLlmGatewayUrlFromHost } from '../utils/urls.js';\nimport { runLogin } from '../commands/login.js';\nimport { isInGitRepo, getUncommittedOrUntrackedFiles } from '../utils/clack-utils.js';\nimport { INTEGRATION_CONFIG, INTEGRATION_ORDER } from './config.js';\nimport { autoConfigureWorkOSEnvironment } from './workos-management.js';\nimport { detectPort, getCallbackPath } from './port-detection.js';\nimport { writeEnvLocal } from './env-writer.js';\nimport { runNextjsWizardAgent } from '../nextjs/nextjs-wizard-agent.js';\nimport { runReactWizardAgent } from '../react/react-wizard-agent.js';\nimport { runReactRouterWizardAgent } from '../react-router/react-router-wizard-agent.js';\nimport { runTanstackStartWizardAgent } from '../tanstack-start/tanstack-start-wizard-agent.js';\nimport { runVanillaJsWizardAgent } from '../vanilla-js/vanilla-js-wizard-agent.js';\n\nasync function runIntegrationWizardFn(integration: Integration, options: WizardOptions): Promise<string> {\n switch (integration) {\n case Integration.nextjs:\n return runNextjsWizardAgent(options);\n case Integration.react:\n return runReactWizardAgent(options);\n case Integration.reactRouter:\n return runReactRouterWizardAgent(options);\n case Integration.tanstackStart:\n return runTanstackStartWizardAgent(options);\n case Integration.vanillaJs:\n return runVanillaJsWizardAgent(options);\n default:\n throw new Error(`Unknown integration: ${integration}`);\n }\n}\n\nfunction readExistingCredentials(installDir: string): { apiKey?: string; clientId?: string } {\n const envPath = join(installDir, '.env.local');\n if (!existsSync(envPath)) {\n return {};\n }\n\n try {\n const content = readFileSync(envPath, 'utf-8');\n const envVars = parseEnvFile(content);\n return {\n apiKey: envVars.WORKOS_API_KEY || undefined,\n clientId: envVars.WORKOS_CLIENT_ID || undefined,\n };\n } catch {\n return {};\n }\n}\n\nasync function detectIntegrationFn(options: Pick<WizardOptions, 'installDir'>): Promise<Integration | undefined> {\n const integrationConfigs = Object.entries(INTEGRATION_CONFIG).sort(\n ([a], [b]) => INTEGRATION_ORDER.indexOf(a as Integration) - INTEGRATION_ORDER.indexOf(b as Integration),\n );\n\n for (const [integration, config] of integrationConfigs) {\n const detected = await config.detect(options);\n if (detected) {\n return integration as Integration;\n }\n }\n return undefined;\n}\n\nexport async function runWithCore(options: WizardOptions): Promise<void> {\n // Initialize debug/logging early so we capture all failures\n initLogFile();\n if (options.debug) {\n enableDebugLogs();\n }\n logInfo('Wizard starting with options:', {\n debug: options.debug,\n dashboard: options.dashboard,\n local: options.local,\n ci: options.ci,\n skipAuth: options.skipAuth,\n installDir: options.installDir,\n });\n\n // Configure telemetry endpoint (same URL as LLM gateway)\n const gatewayUrl = getLlmGatewayUrlFromHost();\n analytics.setGatewayUrl(gatewayUrl);\n\n const existingCreds = readExistingCredentials(options.installDir);\n const augmentedOptions: WizardOptions = {\n ...options,\n apiKey: options.apiKey || existingCreds.apiKey,\n clientId: options.clientId || existingCreds.clientId,\n };\n\n const emitter = createWizardEventEmitter();\n let actor: ReturnType<typeof createActor<typeof wizardMachine>> | null = null;\n\n const sendEvent = (event: { type: string; [key: string]: unknown }) => {\n if (actor) {\n actor.send(event as Parameters<typeof actor.send>[0]);\n }\n };\n\n const adapter: WizardAdapter = options.dashboard\n ? new DashboardAdapter({ emitter, sendEvent, debug: augmentedOptions.debug })\n : new CLIAdapter({ emitter, sendEvent, debug: augmentedOptions.debug });\n\n const machineWithActors = wizardMachine.provide({\n actors: {\n checkAuthentication: fromPromise(async () => {\n const token = getAccessToken();\n if (token) {\n // Set telemetry from existing credentials\n const creds = getCredentials();\n if (creds) {\n analytics.setAccessToken(creds.accessToken);\n analytics.setDistinctId(creds.userId);\n }\n return true;\n }\n\n await runLogin();\n\n const newToken = getAccessToken();\n if (!newToken) {\n throw new Error('Authentication failed. Please try again.');\n }\n\n // Set telemetry after fresh login\n const creds = getCredentials();\n if (creds) {\n analytics.setAccessToken(creds.accessToken);\n analytics.setDistinctId(creds.userId);\n }\n return true;\n }),\n\n detectIntegration: fromPromise<DetectionOutput, { options: WizardOptions }>(async ({ input }) => {\n const integration = await detectIntegrationFn({ installDir: input.options.installDir });\n return { integration };\n }),\n\n checkGitStatus: fromPromise<GitCheckOutput, { installDir: string }>(async () => {\n if (!isInGitRepo()) {\n return { isClean: true, files: [] };\n }\n const files = getUncommittedOrUntrackedFiles();\n return { isClean: files.length === 0, files };\n }),\n\n configureEnvironment: fromPromise<void, { context: WizardMachineContext }>(async ({ input }) => {\n const { context } = input;\n const { options: wizardOptions, integration, credentials } = context;\n\n if (!integration || !credentials) {\n throw new Error('Missing integration or credentials');\n }\n\n const port = detectPort(integration, wizardOptions.installDir);\n const callbackPath = getCallbackPath(integration);\n const redirectUri = wizardOptions.redirectUri || `http://localhost:${port}${callbackPath}`;\n\n const requiresApiKey = [Integration.nextjs, Integration.tanstackStart, Integration.reactRouter].includes(\n integration,\n );\n if (credentials.apiKey && requiresApiKey) {\n await autoConfigureWorkOSEnvironment(credentials.apiKey, integration, port, {\n homepageUrl: wizardOptions.homepageUrl,\n redirectUri: wizardOptions.redirectUri,\n });\n }\n\n const redirectUriKey =\n integration === Integration.nextjs ? 'NEXT_PUBLIC_WORKOS_REDIRECT_URI' : 'WORKOS_REDIRECT_URI';\n\n writeEnvLocal(wizardOptions.installDir, {\n ...(credentials.apiKey ? { WORKOS_API_KEY: credentials.apiKey } : {}),\n WORKOS_CLIENT_ID: credentials.clientId,\n [redirectUriKey]: redirectUri,\n });\n }),\n\n runAgent: fromPromise<AgentOutput, { context: WizardMachineContext }>(async ({ input }) => {\n const { context } = input;\n const { options: wizardOptions, integration, credentials } = context;\n\n if (!integration) {\n return { success: false, error: new Error('No integration specified') };\n }\n\n try {\n const agentOptions: WizardOptions = {\n ...wizardOptions,\n apiKey: credentials?.apiKey,\n clientId: credentials?.clientId,\n emitter: context.emitter,\n };\n const summary = await runIntegrationWizardFn(integration, agentOptions);\n return {\n success: true,\n summary: summary || `Successfully installed WorkOS AuthKit for ${integration}!`,\n };\n } catch (error) {\n return {\n success: false,\n error: error instanceof Error ? error : new Error(String(error)),\n };\n }\n }),\n },\n });\n\n let inspector: ReturnType<typeof createSkyInspector> | undefined;\n if (augmentedOptions.inspect) {\n const originalLog = console.log;\n let inspectUrl: string | undefined;\n\n console.log = (...args: unknown[]) => {\n const msg = args.join(' ');\n if (typeof msg === 'string' && msg.startsWith('https://stately.ai/inspect/')) {\n inspectUrl = msg;\n console.log = originalLog;\n console.log(`Opening XState inspector: ${inspectUrl}`);\n void open(inspectUrl);\n } else {\n originalLog.apply(console, args);\n }\n };\n\n inspector = createSkyInspector();\n setTimeout(() => {\n console.log = originalLog;\n }, 5000).unref();\n }\n\n actor = createActor(machineWithActors, {\n input: { emitter, options: augmentedOptions },\n inspect: inspector?.inspect,\n });\n\n await adapter.start();\n\n // Start telemetry session\n const mode = augmentedOptions.dashboard ? 'tui' : 'cli';\n analytics.sessionStart(mode, getVersion());\n\n let wizardStatus: 'success' | 'error' | 'cancelled' = 'success';\n\n // Handle ctrl+c by sending CANCEL to state machine for graceful shutdown\n const handleSigint = () => {\n wizardStatus = 'cancelled';\n actor?.send({ type: 'CANCEL' });\n };\n process.on('SIGINT', handleSigint);\n\n try {\n await new Promise<void>((resolve, reject) => {\n actor!.subscribe({\n complete: () => {\n const snapshot = actor!.getSnapshot();\n if (snapshot.value === 'error') {\n const err = snapshot.context.error;\n wizardStatus = 'error';\n reject(err ?? new Error('Wizard failed'));\n } else if (snapshot.value === 'cancelled') {\n wizardStatus = 'cancelled';\n resolve();\n } else {\n resolve();\n }\n },\n error: (err) => {\n wizardStatus = 'error';\n reject(err);\n },\n });\n\n actor!.start();\n actor!.send({ type: 'START' });\n });\n } catch (error) {\n wizardStatus = 'error';\n logError('Wizard failed with error:', error instanceof Error ? error.stack || error.message : String(error));\n throw error;\n } finally {\n process.off('SIGINT', handleSigint);\n await analytics.shutdown(wizardStatus);\n await adapter.stop();\n }\n}\n"]}
1
+ {"version":3,"file":"run-with-core.js","sourceRoot":"","sources":["../../../src/lib/run-with-core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,M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,IAAI,EAAE,CAAC;IACvB,CAAC;AACH,CAAC","sourcesContent":["import { createActor, fromPromise } from 'xstate';\nimport open from 'opn';\nimport { existsSync, readFileSync } from 'fs';\nimport { join } from 'path';\nimport { wizardMachine } from './wizard-core.js';\nimport { createWizardEventEmitter } from './events.js';\nimport { CLIAdapter } from './adapters/cli-adapter.js';\nimport { DashboardAdapter } from './adapters/dashboard-adapter.js';\nimport type { WizardAdapter } from './adapters/types.js';\nimport type { WizardOptions } from '../utils/types.js';\nimport type { WizardMachineContext, DetectionOutput, GitCheckOutput, AgentOutput } from './wizard-core.types.js';\nimport { Integration } from './constants.js';\nimport { parseEnvFile } from '../utils/env-parser.js';\nimport { enableDebugLogs, initLogFile, logInfo, logError } from '../utils/debug.js';\n\nimport { getAccessToken, getCredentials } from './credentials.js';\nimport { analytics } from '../utils/analytics.js';\nimport { getVersion } from './settings.js';\nimport { getLlmGatewayUrlFromHost } from '../utils/urls.js';\nimport { runLogin } from '../commands/login.js';\nimport { isInGitRepo, getUncommittedOrUntrackedFiles } from '../utils/clack-utils.js';\nimport { INTEGRATION_CONFIG, INTEGRATION_ORDER } from './config.js';\nimport { autoConfigureWorkOSEnvironment } from './workos-management.js';\nimport { detectPort, getCallbackPath } from './port-detection.js';\nimport { writeEnvLocal } from './env-writer.js';\nimport { runNextjsWizardAgent } from '../nextjs/nextjs-wizard-agent.js';\nimport { runReactWizardAgent } from '../react/react-wizard-agent.js';\nimport { runReactRouterWizardAgent } from '../react-router/react-router-wizard-agent.js';\nimport { runTanstackStartWizardAgent } from '../tanstack-start/tanstack-start-wizard-agent.js';\nimport { runVanillaJsWizardAgent } from '../vanilla-js/vanilla-js-wizard-agent.js';\n\nasync function runIntegrationWizardFn(integration: Integration, options: WizardOptions): Promise<string> {\n switch (integration) {\n case Integration.nextjs:\n return runNextjsWizardAgent(options);\n case Integration.react:\n return runReactWizardAgent(options);\n case Integration.reactRouter:\n return runReactRouterWizardAgent(options);\n case Integration.tanstackStart:\n return runTanstackStartWizardAgent(options);\n case Integration.vanillaJs:\n return runVanillaJsWizardAgent(options);\n default:\n throw new Error(`Unknown integration: ${integration}`);\n }\n}\n\nfunction readExistingCredentials(installDir: string): { apiKey?: string; clientId?: string } {\n const envPath = join(installDir, '.env.local');\n if (!existsSync(envPath)) {\n return {};\n }\n\n try {\n const content = readFileSync(envPath, 'utf-8');\n const envVars = parseEnvFile(content);\n return {\n apiKey: envVars.WORKOS_API_KEY || undefined,\n clientId: envVars.WORKOS_CLIENT_ID || undefined,\n };\n } catch {\n return {};\n }\n}\n\nasync function detectIntegrationFn(options: Pick<WizardOptions, 'installDir'>): Promise<Integration | undefined> {\n const integrationConfigs = Object.entries(INTEGRATION_CONFIG).sort(\n ([a], [b]) => INTEGRATION_ORDER.indexOf(a as Integration) - INTEGRATION_ORDER.indexOf(b as Integration),\n );\n\n for (const [integration, config] of integrationConfigs) {\n const detected = await config.detect(options);\n if (detected) {\n return integration as Integration;\n }\n }\n return undefined;\n}\n\nexport async function runWithCore(options: WizardOptions): Promise<void> {\n // Initialize debug/logging early so we capture all failures\n initLogFile();\n if (options.debug) {\n enableDebugLogs();\n }\n logInfo('Wizard starting with options:', {\n debug: options.debug,\n dashboard: options.dashboard,\n local: options.local,\n ci: options.ci,\n skipAuth: options.skipAuth,\n installDir: options.installDir,\n });\n\n // Configure telemetry endpoint (same URL as LLM gateway)\n const gatewayUrl = getLlmGatewayUrlFromHost();\n analytics.setGatewayUrl(gatewayUrl);\n\n const existingCreds = readExistingCredentials(options.installDir);\n const augmentedOptions: WizardOptions = {\n ...options,\n apiKey: options.apiKey || existingCreds.apiKey,\n clientId: options.clientId || existingCreds.clientId,\n };\n\n const emitter = createWizardEventEmitter();\n let actor: ReturnType<typeof createActor<typeof wizardMachine>> | null = null;\n\n const sendEvent = (event: { type: string; [key: string]: unknown }) => {\n if (actor) {\n actor.send(event as Parameters<typeof actor.send>[0]);\n }\n };\n\n const adapter: WizardAdapter = options.dashboard\n ? new DashboardAdapter({ emitter, sendEvent, debug: augmentedOptions.debug })\n : new CLIAdapter({ emitter, sendEvent, debug: augmentedOptions.debug });\n\n const machineWithActors = wizardMachine.provide({\n actors: {\n checkAuthentication: fromPromise(async () => {\n const token = getAccessToken();\n if (token) {\n // Set telemetry from existing credentials\n const creds = getCredentials();\n if (creds) {\n analytics.setAccessToken(creds.accessToken);\n analytics.setDistinctId(creds.userId);\n }\n return true;\n }\n\n await runLogin();\n\n const newToken = getAccessToken();\n if (!newToken) {\n throw new Error('Authentication failed. Please try again.');\n }\n\n // Set telemetry after fresh login\n const creds = getCredentials();\n if (creds) {\n analytics.setAccessToken(creds.accessToken);\n analytics.setDistinctId(creds.userId);\n }\n return true;\n }),\n\n detectIntegration: fromPromise<DetectionOutput, { options: WizardOptions }>(async ({ input }) => {\n const integration = await detectIntegrationFn({ installDir: input.options.installDir });\n return { integration };\n }),\n\n checkGitStatus: fromPromise<GitCheckOutput, { installDir: string }>(async () => {\n if (!isInGitRepo()) {\n return { isClean: true, files: [] };\n }\n const files = getUncommittedOrUntrackedFiles();\n return { isClean: files.length === 0, files };\n }),\n\n configureEnvironment: fromPromise<void, { context: WizardMachineContext }>(async ({ input }) => {\n const { context } = input;\n const { options: wizardOptions, integration, credentials } = context;\n\n if (!integration || !credentials) {\n throw new Error('Missing integration or credentials');\n }\n\n const port = detectPort(integration, wizardOptions.installDir);\n const callbackPath = getCallbackPath(integration);\n const redirectUri = wizardOptions.redirectUri || `http://localhost:${port}${callbackPath}`;\n\n const requiresApiKey = [Integration.nextjs, Integration.tanstackStart, Integration.reactRouter].includes(\n integration,\n );\n if (credentials.apiKey && requiresApiKey) {\n await autoConfigureWorkOSEnvironment(credentials.apiKey, integration, port, {\n homepageUrl: wizardOptions.homepageUrl,\n redirectUri: wizardOptions.redirectUri,\n });\n }\n\n const redirectUriKey =\n integration === Integration.nextjs ? 'NEXT_PUBLIC_WORKOS_REDIRECT_URI' : 'WORKOS_REDIRECT_URI';\n\n writeEnvLocal(wizardOptions.installDir, {\n ...(credentials.apiKey ? { WORKOS_API_KEY: credentials.apiKey } : {}),\n WORKOS_CLIENT_ID: credentials.clientId,\n [redirectUriKey]: redirectUri,\n });\n }),\n\n runAgent: fromPromise<AgentOutput, { context: WizardMachineContext }>(async ({ input }) => {\n const { context } = input;\n const { options: wizardOptions, integration, credentials } = context;\n\n if (!integration) {\n return { success: false, error: new Error('No integration specified') };\n }\n\n try {\n const agentOptions: WizardOptions = {\n ...wizardOptions,\n apiKey: credentials?.apiKey,\n clientId: credentials?.clientId,\n emitter: context.emitter,\n };\n const summary = await runIntegrationWizardFn(integration, agentOptions);\n return {\n success: true,\n summary: summary || `Successfully installed WorkOS AuthKit for ${integration}!`,\n };\n } catch (error) {\n return {\n success: false,\n error: error instanceof Error ? error : new Error(String(error)),\n };\n }\n }),\n },\n });\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let inspector: { inspect: any } | undefined;\n if (augmentedOptions.inspect) {\n const originalLog = console.log;\n let inspectUrl: string | undefined;\n\n console.log = (...args: unknown[]) => {\n const msg = args.join(' ');\n if (typeof msg === 'string' && msg.startsWith('https://stately.ai/inspect/')) {\n inspectUrl = msg;\n console.log = originalLog;\n console.log(`Opening XState inspector: ${inspectUrl}`);\n void open(inspectUrl);\n } else {\n originalLog.apply(console, args);\n }\n };\n\n // Dynamic import - @statelyai/inspect is a devDependency\n const { createSkyInspector } = await import('@statelyai/inspect');\n inspector = createSkyInspector();\n setTimeout(() => {\n console.log = originalLog;\n }, 5000).unref();\n }\n\n actor = createActor(machineWithActors, {\n input: { emitter, options: augmentedOptions },\n inspect: inspector?.inspect,\n });\n\n await adapter.start();\n\n // Start telemetry session\n const mode = augmentedOptions.dashboard ? 'tui' : 'cli';\n analytics.sessionStart(mode, getVersion());\n\n let wizardStatus: 'success' | 'error' | 'cancelled' = 'success';\n\n // Handle ctrl+c by sending CANCEL to state machine for graceful shutdown\n const handleSigint = () => {\n wizardStatus = 'cancelled';\n actor?.send({ type: 'CANCEL' });\n };\n process.on('SIGINT', handleSigint);\n\n try {\n await new Promise<void>((resolve, reject) => {\n actor!.subscribe({\n complete: () => {\n const snapshot = actor!.getSnapshot();\n if (snapshot.value === 'error') {\n const err = snapshot.context.error;\n wizardStatus = 'error';\n reject(err ?? new Error('Wizard failed'));\n } else if (snapshot.value === 'cancelled') {\n wizardStatus = 'cancelled';\n resolve();\n } else {\n resolve();\n }\n },\n error: (err) => {\n wizardStatus = 'error';\n reject(err);\n },\n });\n\n actor!.start();\n actor!.send({ type: 'START' });\n });\n } catch (error) {\n wizardStatus = 'error';\n logError('Wizard failed with error:', error instanceof Error ? error.stack || error.message : String(error));\n throw error;\n } finally {\n process.off('SIGINT', handleSigint);\n await analytics.shutdown(wizardStatus);\n await adapter.stop();\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workos",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "description": "The Official Workos CLI",
6
6
  "keywords": [