@bastani/atomic 0.9.10-alpha.1 → 0.9.11-alpha.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.
Files changed (94) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/dist/builtin/cursor/CHANGELOG.md +12 -0
  3. package/dist/builtin/cursor/package.json +2 -2
  4. package/dist/builtin/intercom/CHANGELOG.md +21 -0
  5. package/dist/builtin/intercom/package.json +2 -2
  6. package/dist/builtin/mcp/CHANGELOG.md +17 -0
  7. package/dist/builtin/mcp/package.json +1 -1
  8. package/dist/builtin/subagents/CHANGELOG.md +27 -0
  9. package/dist/builtin/subagents/package.json +1 -1
  10. package/dist/builtin/web-access/CHANGELOG.md +17 -0
  11. package/dist/builtin/web-access/package.json +1 -1
  12. package/dist/builtin/workflows/CHANGELOG.md +93 -0
  13. package/dist/builtin/workflows/README.md +8 -3
  14. package/dist/builtin/workflows/builtin/deep-research-codebase.ts +1 -1
  15. package/dist/builtin/workflows/package.json +1 -1
  16. package/dist/builtin/workflows/src/durable/backend.ts +2 -2
  17. package/dist/builtin/workflows/src/durable/dbos-embedded-postgres-root.ts +173 -0
  18. package/dist/builtin/workflows/src/durable/dbos-embedded-postgres.ts +36 -12
  19. package/dist/builtin/workflows/src/durable/dbos-lifecycle.ts +9 -3
  20. package/dist/builtin/workflows/src/durable/factory.ts +35 -6
  21. package/dist/builtin/workflows/src/durable/local-command.ts +11 -2
  22. package/dist/builtin/workflows/src/extension/extension-lifecycle.ts +14 -2
  23. package/dist/builtin/workflows/src/extension/public-types.ts +3 -4
  24. package/dist/builtin/workflows/src/extension/render-call.ts +4 -0
  25. package/dist/builtin/workflows/src/extension/render-result.ts +31 -1
  26. package/dist/builtin/workflows/src/extension/workflow-prompts.ts +5 -2
  27. package/dist/builtin/workflows/src/extension/workflow-schema.ts +3 -2
  28. package/dist/builtin/workflows/src/extension/workflow-tool-content.ts +1 -0
  29. package/dist/builtin/workflows/src/extension/workflow-tool-control.ts +88 -2
  30. package/dist/builtin/workflows/src/extension/workflow-tool.ts +13 -0
  31. package/dist/core/agent-session-events.d.ts.map +1 -1
  32. package/dist/core/agent-session-events.js +2 -1
  33. package/dist/core/agent-session-events.js.map +1 -1
  34. package/dist/core/agent-session-retry.d.ts.map +1 -1
  35. package/dist/core/agent-session-retry.js +7 -0
  36. package/dist/core/agent-session-retry.js.map +1 -1
  37. package/dist/core/agent-session-runtime.d.ts +13 -0
  38. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  39. package/dist/core/agent-session-runtime.js +12 -0
  40. package/dist/core/agent-session-runtime.js.map +1 -1
  41. package/dist/core/atomic-guide-command.d.ts.map +1 -1
  42. package/dist/core/atomic-guide-command.js +2 -0
  43. package/dist/core/atomic-guide-command.js.map +1 -1
  44. package/dist/core/auth-storage-backends.d.ts +4 -0
  45. package/dist/core/auth-storage-backends.d.ts.map +1 -1
  46. package/dist/core/auth-storage-backends.js +48 -3
  47. package/dist/core/auth-storage-backends.js.map +1 -1
  48. package/dist/core/auth-storage.d.ts.map +1 -1
  49. package/dist/core/auth-storage.js +27 -11
  50. package/dist/core/auth-storage.js.map +1 -1
  51. package/dist/core/codex-errors.d.ts +3 -0
  52. package/dist/core/codex-errors.d.ts.map +1 -0
  53. package/dist/core/codex-errors.js +12 -0
  54. package/dist/core/codex-errors.js.map +1 -0
  55. package/dist/core/slash-commands.js +1 -1
  56. package/dist/core/slash-commands.js.map +1 -1
  57. package/dist/modes/interactive/interactive-auth-routing.d.ts +2 -1
  58. package/dist/modes/interactive/interactive-auth-routing.d.ts.map +1 -1
  59. package/dist/modes/interactive/interactive-auth-routing.js +10 -5
  60. package/dist/modes/interactive/interactive-auth-routing.js.map +1 -1
  61. package/dist/modes/interactive/interactive-autocomplete.js +12 -2
  62. package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
  63. package/dist/modes/interactive-engine/extension-ui-bridge.d.ts +3 -1
  64. package/dist/modes/interactive-engine/extension-ui-bridge.d.ts.map +1 -1
  65. package/dist/modes/interactive-engine/extension-ui-bridge.js +6 -0
  66. package/dist/modes/interactive-engine/extension-ui-bridge.js.map +1 -1
  67. package/dist/modes/interactive-engine/isolated-runtime.d.ts +4 -5
  68. package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
  69. package/dist/modes/interactive-engine/isolated-runtime.js +14 -24
  70. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  71. package/dist/modes/interactive-engine/remote-model-catalog.d.ts +15 -0
  72. package/dist/modes/interactive-engine/remote-model-catalog.d.ts.map +1 -0
  73. package/dist/modes/interactive-engine/remote-model-catalog.js +67 -0
  74. package/dist/modes/interactive-engine/remote-model-catalog.js.map +1 -0
  75. package/dist/modes/rpc/rpc-client-api.d.ts +8 -1
  76. package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
  77. package/dist/modes/rpc/rpc-client-api.js +9 -0
  78. package/dist/modes/rpc/rpc-client-api.js.map +1 -1
  79. package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
  80. package/dist/modes/rpc/rpc-command-handler.js +30 -0
  81. package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
  82. package/dist/modes/rpc/rpc-types.d.ts +67 -7
  83. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  84. package/dist/modes/rpc/rpc-types.js.map +1 -1
  85. package/docs/docs.json +9 -1
  86. package/docs/models/artificial-analysis-index.md +82 -0
  87. package/docs/models/model-selection.md +63 -0
  88. package/docs/models/pareto-efficiency.md +64 -0
  89. package/docs/providers.md +5 -1
  90. package/docs/quickstart.md +1 -1
  91. package/docs/rpc.md +27 -0
  92. package/docs/workflows.md +20 -7
  93. package/npm-shrinkwrap.json +24 -24
  94. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"auth-storage.js","sourceRoot":"","sources":["../../src/core/auth-storage.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MA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C,gBAAgB,CAAC,OAAO,CAAC,CAAC;wBAC5C,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC;wBACxB,gBAAgB,GAAG,IAAI,CAAC;wBACxB,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;oBACnE,CAAC,CAAC,CAAC;oBACH,IAAI,gBAAgB,EAAE,CAAC;wBACtB,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;wBAC7B,IAAI,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;oBACxC,CAAC;oBACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;gBACvB,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBAChB,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;oBACxB,MAAM,KAAK,CAAC;gBACb,CAAC;YACF,CAAC,CAAC;SACH,CAAC;IACH,CAAC;CACD","sourcesContent":["/**\n * Credential storage for API keys and OAuth tokens.\n * Handles loading, saving, and refreshing credentials from auth.json.\n *\n * Uses file locking to prevent race conditions when multiple pi instances\n * try to refresh tokens simultaneously.\n */\n\nimport {\n\ttype Credential,\n\ttype CredentialInfo,\n\ttype CredentialStore,\n\ttype ModelAuth,\n\ttype OAuthCredential as PiOAuthCredential,\n\ttype OAuthCredentials,\n} from \"@earendil-works/pi-ai\";\nimport { findEnvKeys, getEnvApiKey } from \"@earendil-works/pi-ai/compat\";\nimport { join } from \"path\";\nimport { getAgentConfigPaths, getAgentDir } from \"../config.ts\";\nimport { FileAuthStorageBackend, InMemoryAuthStorageBackend, type AuthStorageBackend } from \"./auth-storage-backends.ts\";\nimport {\n\ttype AtomicOAuthLoginCallbacks,\n\tgetOAuthProviderDescriptors,\n\tloginOAuthProvider,\n\toauthCredentialToAuth,\n\trefreshOAuthProvider,\n} from \"./oauth-provider-bridge.ts\";\nimport { resolveConfigValue } from \"./resolve-config-value.ts\";\n\nexport type ApiKeyCredential = {\n\ttype: \"api_key\";\n\tkey: string;\n};\n\nexport type OAuthCredential = {\n\ttype: \"oauth\";\n} & OAuthCredentials;\n\nexport type AuthCredential = ApiKeyCredential | OAuthCredential;\n\nexport type AuthStorageData = Record<string, AuthCredential>;\n\nexport type AuthStatus = {\n\tconfigured: boolean;\n\tsource?: \"stored\" | \"runtime\" | \"environment\" | \"fallback\" | \"models_json_key\" | \"models_json_command\";\n\tlabel?: string;\n};\n\nexport { FileAuthStorageBackend, InMemoryAuthStorageBackend, type AuthStorageBackend } from \"./auth-storage-backends.ts\";\n\n/**\n * Credential storage backed by a JSON file.\n */\nexport class AuthStorage {\n\tprivate data: AuthStorageData = {};\n\tprivate runtimeOverrides: Map<string, string> = new Map();\n\tprivate fallbackResolver?: (provider: string) => string | undefined;\n\tprivate loadError: Error | null = null;\n\tprivate errors: Error[] = [];\n\tprivate credentialMutationTail: Promise<void> = Promise.resolve();\n\tprivate credentialVersions = new Map<string, number>();\n\n\tdeclare private storage: AuthStorageBackend;\n\n\tprivate constructor(storage: AuthStorageBackend) {\n\t\tthis.storage = storage;\n\t\tthis.reload();\n\t}\n\n\tstatic create(authPath?: string | string[]): AuthStorage {\n\t\tconst paths = authPath === undefined\n\t\t\t? getAgentConfigPaths(\"auth.json\")\n\t\t\t: Array.isArray(authPath) ? authPath : [authPath];\n\t\treturn new AuthStorage(new FileAuthStorageBackend(paths[0] ?? join(getAgentDir(), \"auth.json\"), paths));\n\t}\n\n\tstatic fromStorage(storage: AuthStorageBackend): AuthStorage {\n\t\treturn new AuthStorage(storage);\n\t}\n\n\tstatic inMemory(data: AuthStorageData = {}): AuthStorage {\n\t\tconst storage = new InMemoryAuthStorageBackend();\n\t\tstorage.withLock(() => ({ result: undefined, next: JSON.stringify(data, null, 2) }));\n\t\treturn AuthStorage.fromStorage(storage);\n\t}\n\n\t/**\n\t * Set a runtime API key override (not persisted to disk).\n\t * Used for CLI --api-key flag.\n\t */\n\tsetRuntimeApiKey(provider: string, apiKey: string): void {\n\t\tthis.runtimeOverrides.set(provider, apiKey);\n\t}\n\t/** Read a non-persisted request override without resolving stored credentials. */\n\tgetRuntimeApiKey(provider: string): string | undefined {\n\t\treturn this.runtimeOverrides.get(provider);\n\t}\n\n\n\t/**\n\t * Remove a runtime API key override.\n\t */\n\tremoveRuntimeApiKey(provider: string): void {\n\t\tthis.runtimeOverrides.delete(provider);\n\t}\n\n\t/**\n\t * Set a fallback resolver for API keys not found in auth.json or env vars.\n\t * Used for custom provider keys from models.json.\n\t */\n\tsetFallbackResolver(resolver: (provider: string) => string | undefined): void {\n\t\tthis.fallbackResolver = resolver;\n\t}\n\n\tprivate recordError(error: unknown): void {\n\t\tconst normalizedError = error instanceof Error ? error : new Error(String(error));\n\t\tthis.errors.push(normalizedError);\n\t}\n\n\tprivate parseStorageData(content: string | undefined): AuthStorageData {\n\t\tif (!content) {\n\t\t\treturn {};\n\t\t}\n\t\treturn JSON.parse(content) as AuthStorageData;\n\t}\n\n\t/**\n\t * Reload credentials from storage.\n\t */\n\treload(): void {\n\t\ttry {\n\t\t\t// Pure read: never take the exclusive write lock. Writers replace\n\t\t\t// auth.json atomically, so a lock-free read always sees a complete\n\t\t\t// snapshot. This keeps many concurrent sessions from starving each other\n\t\t\t// on the lock and misreporting configured providers as unreadable under\n\t\t\t// contention (issue #1431).\n\t\t\tconst content = this.readSnapshot();\n\t\t\tthis.data = this.parseStorageData(content);\n\t\t\tthis.loadError = null;\n\t\t} catch (error) {\n\t\t\tthis.loadError = error as Error;\n\t\t\tthis.recordError(error);\n\t\t}\n\t}\n\n\t/**\n\t * Read the credential snapshot, preferring the backend's lock-free `read()`.\n\t * Falls back to a `withLock`-based read for custom backends that predate\n\t * `read()` so the released `AuthStorageBackend` interface stays compatible.\n\t */\n\tprivate readSnapshot(): string | undefined {\n\t\tif (this.storage.read) {\n\t\t\treturn this.storage.read();\n\t\t}\n\t\tlet content: string | undefined;\n\t\tthis.storage.withLock((current) => {\n\t\t\tcontent = current;\n\t\t\treturn { result: undefined };\n\t\t});\n\t\treturn content;\n\t}\n\n\tprivate bumpCredentialVersion(provider: string): void {\n\t\tthis.credentialVersions.set(provider, (this.credentialVersions.get(provider) ?? 0) + 1);\n\t}\n\n\tprivate persistProviderChange(provider: string, credential: AuthCredential | undefined): void {\n\t\tif (this.loadError) {\n\t\t\tthis.reload();\n\t\t\tif (this.loadError) throw this.loadError;\n\t\t}\n\n\t\ttry {\n\t\t\tconst persistedData = this.storage.withLock((current) => {\n\t\t\t\tconst currentData = this.parseStorageData(current);\n\t\t\t\tconst merged: AuthStorageData = { ...currentData };\n\t\t\t\tif (credential) {\n\t\t\t\t\tmerged[provider] = credential;\n\t\t\t\t} else {\n\t\t\t\t\tdelete merged[provider];\n\t\t\t\t}\n\t\t\t\treturn { result: merged, next: JSON.stringify(merged, null, 2) };\n\t\t\t});\n\t\t\tthis.data = persistedData;\n\t\t\tthis.bumpCredentialVersion(provider);\n\t\t\tthis.loadError = null;\n\t\t} catch (error) {\n\t\t\tthis.recordError(error);\n\t\t\tthrow error instanceof Error ? error : new Error(String(error));\n\t\t}\n\t}\n\n\t/**\n\t * Get credential for a provider.\n\t */\n\tget(provider: string): AuthCredential | undefined {\n\t\treturn this.data[provider] ?? undefined;\n\t}\n\n\t/**\n\t * Set credential for a provider.\n\t */\n\tset(provider: string, credential: AuthCredential): void {\n\t\tthis.persistProviderChange(provider, credential);\n\t}\n\n\t/**\n\t * Remove credential for a provider.\n\t */\n\tremove(provider: string): void {\n\t\tthis.persistProviderChange(provider, undefined);\n\t}\n\n\t/**\n\t * List all providers with credentials.\n\t */\n\tlist(): string[] {\n\t\treturn Object.keys(this.data);\n\t}\n\n\t/**\n\t * Check if credentials exist for a provider in auth.json.\n\t */\n\thas(provider: string): boolean {\n\t\treturn provider in this.data;\n\t}\n\n\t/**\n\t * Check if any form of auth is configured for a provider.\n\t * Unlike getApiKey(), this doesn't refresh OAuth tokens.\n\t */\n\thasAuth(provider: string): boolean {\n\t\tif (this.runtimeOverrides.has(provider)) return true;\n\t\tif (this.data[provider]) return true;\n\t\tif (getEnvApiKey(provider)) return true;\n\t\tif (this.fallbackResolver?.(provider)) return true;\n\t\treturn false;\n\t}\n\n\t/**\n\t * Return auth status without exposing credential values or refreshing tokens.\n\t */\n\tgetAuthStatus(provider: string): AuthStatus {\n\t\tif (this.data[provider]) {\n\t\t\treturn { configured: true, source: \"stored\" };\n\t\t}\n\n\t\tif (this.runtimeOverrides.has(provider)) {\n\t\t\treturn { configured: false, source: \"runtime\", label: \"--api-key\" };\n\t\t}\n\n\t\tconst envKeys = findEnvKeys(provider);\n\t\tif (envKeys?.[0]) {\n\t\t\treturn { configured: false, source: \"environment\", label: envKeys[0] };\n\t\t}\n\n\t\tif (this.fallbackResolver?.(provider)) {\n\t\t\treturn { configured: false, source: \"fallback\", label: \"custom provider config\" };\n\t\t}\n\n\t\treturn { configured: false };\n\t}\n\n\t/** Return a copy of all persisted credentials. */\n\tgetAll(): AuthStorageData {\n\t\treturn { ...this.data };\n\t}\n\n\tdrainErrors(): Error[] {\n\t\tconst drained = [...this.errors];\n\t\tthis.errors = [];\n\t\treturn drained;\n\t}\n\n\t/**\n\t * Returns the error from the most recent failed credential load, or null when\n\t * the last reload succeeded.\n\t *\n\t * A non-null value means stored credentials could NOT be read — e.g. the auth\n\t * file was temporarily locked by another process (ELOCKED) or contained\n\t * invalid JSON — so an empty/absent credential set is NOT authoritative.\n\t * Callers that would otherwise report \"No API key found\" should surface this\n\t * load failure instead of treating the provider as unauthenticated\n\t * (issue #1431).\n\t */\n\tgetLoadError(): Error | null {\n\t\treturn this.loadError;\n\t}\n\n\t/**\n\t * Login to an OAuth provider.\n\t */\n\tasync login(providerId: string, callbacks: AtomicOAuthLoginCallbacks): Promise<void> {\n\t\tconst credential = await loginOAuthProvider(providerId, callbacks);\n\t\tawait this.asCredentialStore().modify(providerId, async () => credential);\n\t}\n\n\t/** Logout through the preserved synchronous persistence path. */\n\tlogout(provider: string): void {\n\t\tthis.remove(provider);\n\t}\n\n\t/** Serialized logout for callers that need persistence completion. */\n\tasync logoutAsync(provider: string): Promise<void> {\n\t\tawait this.asCredentialStore().delete(provider);\n\t}\n\n\t/**\n\t * Refresh OAuth token with backend locking to prevent race conditions.\n\t * Multiple pi instances may try to refresh simultaneously when tokens expire.\n\t */\n\tprivate async refreshOAuthTokenWithLock(\n\t\tproviderId: string,\n\t): Promise<{ auth: ModelAuth; newCredentials: OAuthCredentials } | null> {\n\t\treturn this.runCredentialMutation(async () => {\n\t\t\tlet synchronizedData: AuthStorageData | undefined;\n\t\t\tconst credentialVersion = this.credentialVersions.get(providerId) ?? 0;\n\t\t\tconst result = await this.storage.withLockAsync(async (current) => {\n\t\t\t\tconst currentData = this.parseStorageData(current);\n\t\t\t\tsynchronizedData = currentData;\n\t\t\t\tconst cred = currentData[providerId];\n\t\t\t\tif (cred?.type !== \"oauth\") return { result: null };\n\n\t\t\t\tconst oauthCredential: PiOAuthCredential = { ...cred, type: \"oauth\" };\n\t\t\t\tif (Date.now() < cred.expires) {\n\t\t\t\t\tconst auth = await oauthCredentialToAuth(providerId, oauthCredential);\n\t\t\t\t\treturn { result: auth ? { auth, newCredentials: cred } : null };\n\t\t\t\t}\n\n\t\t\t\tconst refreshed = await refreshOAuthProvider(providerId, oauthCredential);\n\t\t\t\tif (!refreshed) return { result: null };\n\t\t\t\tif ((this.credentialVersions.get(providerId) ?? 0) !== credentialVersion) {\n\t\t\t\t\tsynchronizedData = undefined;\n\t\t\t\t\treturn { result: null };\n\t\t\t\t}\n\t\t\t\tconst merged: AuthStorageData = {\n\t\t\t\t\t...currentData,\n\t\t\t\t\t[providerId]: refreshed.credential,\n\t\t\t\t};\n\t\t\t\tsynchronizedData = merged;\n\t\t\t\treturn {\n\t\t\t\t\tresult: { auth: refreshed.auth, newCredentials: refreshed.credential },\n\t\t\t\t\tnext: JSON.stringify(merged, null, 2),\n\t\t\t\t};\n\t\t\t});\n\n\t\t\tif (synchronizedData) this.data = synchronizedData;\n\t\t\tthis.loadError = null;\n\t\t\treturn result;\n\t\t});\n\t}\n\n\t/**\n\t * Get API key for a provider.\n\t * Priority:\n\t * 1. Runtime override (CLI --api-key)\n\t * 2. API key from auth.json\n\t * 3. OAuth token from auth.json (auto-refreshed with locking)\n\t * 4. Environment variable\n\t * 5. Fallback resolver (models.json custom providers)\n\t */\n\tasync getModelAuth(providerId: string, options?: { includeFallback?: boolean }): Promise<ModelAuth | undefined> {\n\t\tconst runtimeKey = this.runtimeOverrides.get(providerId);\n\t\tif (runtimeKey) return { apiKey: runtimeKey };\n\n\t\tconst cred = this.data[providerId];\n\t\tif (cred?.type === \"api_key\") return { apiKey: resolveConfigValue(cred.key) };\n\n\t\tif (cred?.type === \"oauth\") {\n\t\t\ttry {\n\t\t\t\tif (Date.now() >= cred.expires) {\n\t\t\t\t\treturn (await this.refreshOAuthTokenWithLock(providerId))?.auth;\n\t\t\t\t}\n\t\t\t\treturn await oauthCredentialToAuth(providerId, { ...cred, type: \"oauth\" });\n\t\t\t} catch (error) {\n\t\t\t\tthis.recordError(error);\n\t\t\t\tthis.reload();\n\t\t\t\tconst updated = this.data[providerId];\n\t\t\t\tif (updated?.type === \"oauth\" && Date.now() < updated.expires) {\n\t\t\t\t\treturn oauthCredentialToAuth(providerId, { ...updated, type: \"oauth\" });\n\t\t\t\t}\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\n\t\tconst envKey = getEnvApiKey(providerId);\n\t\tif (envKey) return { apiKey: envKey };\n\t\tif (options?.includeFallback !== false) {\n\t\t\tconst fallback = this.fallbackResolver?.(providerId);\n\t\t\tif (fallback) return { apiKey: fallback };\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tasync getApiKey(providerId: string, options?: { includeFallback?: boolean }): Promise<string | undefined> {\n\t\treturn (await this.getModelAuth(providerId, options))?.apiKey;\n\t}\n\n\t/**\n\t * Get all registered OAuth providers\n\t */\n\tgetOAuthProviders() {\n\t\treturn getOAuthProviderDescriptors();\n\t}\n\n\tprivate runCredentialMutation<T>(operation: () => Promise<T>): Promise<T> {\n\t\tconst result = this.credentialMutationTail.then(operation, operation);\n\t\tthis.credentialMutationTail = result.then(\n\t\t\t() => undefined,\n\t\t\t() => undefined,\n\t\t);\n\t\treturn result;\n\t}\n\n\t/** Private async adapter for pi-ai's provider-owned Models runtime. */\n\tasCredentialStore(): CredentialStore {\n\t\tconst runtimeCredential = (providerId: string): Credential | undefined => {\n\t\t\tconst key = this.runtimeOverrides.get(providerId);\n\t\t\treturn key === undefined ? undefined : { type: \"api_key\", key };\n\t\t};\n\t\treturn {\n\t\t\tread: async (providerId) => runtimeCredential(providerId) ?? (this.get(providerId) as Credential | undefined),\n\t\t\tlist: async (): Promise<readonly CredentialInfo[]> => {\n\t\t\t\tconst providers = new Set([...this.list(), ...this.runtimeOverrides.keys()]);\n\t\t\t\treturn [...providers].map((providerId) => ({\n\t\t\t\t\tproviderId,\n\t\t\t\t\ttype: runtimeCredential(providerId)?.type ?? this.data[providerId].type,\n\t\t\t\t}));\n\t\t\t},\n\t\t\tmodify: (providerId, fn) =>\n\t\t\t\tthis.runCredentialMutation(async () => {\n\t\t\t\t\tlet synchronizedData: AuthStorageData | undefined;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst result = await this.storage.withLockAsync(async (current) => {\n\t\t\t\t\t\t\tconst data = this.parseStorageData(current);\n\t\t\t\t\t\t\tconst next = await fn(data[providerId] as Credential | undefined);\n\t\t\t\t\t\t\tif (next === undefined) {\n\t\t\t\t\t\t\t\tsynchronizedData = data;\n\t\t\t\t\t\t\t\treturn { result: data[providerId] as Credential | undefined };\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst merged = { ...data, [providerId]: next as AuthCredential };\n\t\t\t\t\t\t\tsynchronizedData = merged;\n\t\t\t\t\t\t\treturn { result: next, next: JSON.stringify(merged, null, 2) };\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (synchronizedData) {\n\t\t\t\t\t\t\tthis.data = synchronizedData;\n\t\t\t\t\t\t\tthis.bumpCredentialVersion(providerId);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthis.loadError = null;\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tthis.recordError(error);\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\tdelete: (providerId) =>\n\t\t\t\tthis.runCredentialMutation(async () => {\n\t\t\t\t\tlet synchronizedData: AuthStorageData | undefined;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.storage.withLockAsync(async (current) => {\n\t\t\t\t\t\t\tconst data = this.parseStorageData(current);\n\t\t\t\t\t\t\tdelete data[providerId];\n\t\t\t\t\t\t\tsynchronizedData = data;\n\t\t\t\t\t\t\treturn { result: undefined, next: JSON.stringify(data, null, 2) };\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (synchronizedData) {\n\t\t\t\t\t\t\tthis.data = synchronizedData;\n\t\t\t\t\t\t\tthis.bumpCredentialVersion(providerId);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthis.loadError = null;\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tthis.recordError(error);\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t};\n\t}\n}\n"]}
1
+ {"version":3,"file":"auth-storage.js","sourceRoot":"","sources":["../../src/core/auth-storage.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,0BAA0B,EAA2B,MAAM,4BAA4B,CAAC;AACzH,OAAO,EAEN,2BAA2B,EAC3B,kBAAkB,EAClB,qBAAqB,EACrB,oBAA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AC;YACF,CAAC,CAAC;YACH,MAAM,EAAE,CAAC,UAAU,EAAE,EAAE,CACtB,IAAI,CAAC,qBAAqB,CAAC,KAAK,IAAI,EAAE;gBACrC,IAAI,CAAC;oBACJ,IAAI,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,CAAC;wBACtC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC,CAAC;oBACvF,CAAC;yBAAM,CAAC;wBACP,IAAI,gBAA6C,CAAC;wBAClD,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;4BAClD,MAAM,IAAI,GAAG,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;4BAC5C,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC;4BACxB,gBAAgB,GAAG,IAAI,CAAC;4BACxB,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;wBACnE,CAAC,CAAC,CAAC;wBACH,IAAI,gBAAgB;4BAAE,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;oBACpD,CAAC;oBACD,IAAI,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;oBACvC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;gBACvB,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBAChB,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;oBACxB,MAAM,KAAK,CAAC;gBACb,CAAC;YACF,CAAC,CAAC;SACH,CAAC;IACH,CAAC;CACD","sourcesContent":["/**\n * Credential storage for API keys and OAuth tokens.\n * Handles loading, saving, and refreshing credentials from auth.json.\n *\n * Uses file locking to prevent race conditions when multiple pi instances\n * try to refresh tokens simultaneously.\n */\n\nimport {\n\ttype Credential,\n\ttype CredentialInfo,\n\ttype CredentialStore,\n\ttype ModelAuth,\n\ttype OAuthCredential as PiOAuthCredential,\n\ttype OAuthCredentials,\n} from \"@earendil-works/pi-ai\";\nimport { findEnvKeys, getEnvApiKey } from \"@earendil-works/pi-ai/compat\";\nimport { join } from \"path\";\nimport { getAgentConfigPaths, getAgentDir } from \"../config.ts\";\nimport { FileAuthStorageBackend, InMemoryAuthStorageBackend, type AuthStorageBackend } from \"./auth-storage-backends.ts\";\nimport {\n\ttype AtomicOAuthLoginCallbacks,\n\tgetOAuthProviderDescriptors,\n\tloginOAuthProvider,\n\toauthCredentialToAuth,\n\trefreshOAuthProvider,\n} from \"./oauth-provider-bridge.ts\";\nimport { resolveConfigValue } from \"./resolve-config-value.ts\";\n\nexport type ApiKeyCredential = {\n\ttype: \"api_key\";\n\tkey: string;\n};\n\nexport type OAuthCredential = {\n\ttype: \"oauth\";\n} & OAuthCredentials;\n\nexport type AuthCredential = ApiKeyCredential | OAuthCredential;\n\nexport type AuthStorageData = Record<string, AuthCredential>;\n\nexport type AuthStatus = {\n\tconfigured: boolean;\n\tsource?: \"stored\" | \"runtime\" | \"environment\" | \"fallback\" | \"models_json_key\" | \"models_json_command\";\n\tlabel?: string;\n};\n\nexport { FileAuthStorageBackend, InMemoryAuthStorageBackend, type AuthStorageBackend } from \"./auth-storage-backends.ts\";\n\n/**\n * Credential storage backed by a JSON file.\n */\nexport class AuthStorage {\n\tprivate data: AuthStorageData = {};\n\tprivate runtimeOverrides: Map<string, string> = new Map();\n\tprivate fallbackResolver?: (provider: string) => string | undefined;\n\tprivate loadError: Error | null = null;\n\tprivate errors: Error[] = [];\n\tprivate credentialMutationTail: Promise<void> = Promise.resolve();\n\tprivate credentialVersions = new Map<string, number>();\n\n\tdeclare private storage: AuthStorageBackend;\n\n\tprivate constructor(storage: AuthStorageBackend) {\n\t\tthis.storage = storage;\n\t\tthis.reload();\n\t}\n\n\tstatic create(authPath?: string | string[]): AuthStorage {\n\t\tconst paths = authPath === undefined\n\t\t\t? getAgentConfigPaths(\"auth.json\")\n\t\t\t: Array.isArray(authPath) ? authPath : [authPath];\n\t\treturn new AuthStorage(new FileAuthStorageBackend(paths[0] ?? join(getAgentDir(), \"auth.json\"), paths));\n\t}\n\n\tstatic fromStorage(storage: AuthStorageBackend): AuthStorage {\n\t\treturn new AuthStorage(storage);\n\t}\n\n\tstatic inMemory(data: AuthStorageData = {}): AuthStorage {\n\t\tconst storage = new InMemoryAuthStorageBackend();\n\t\tstorage.withLock(() => ({ result: undefined, next: JSON.stringify(data, null, 2) }));\n\t\treturn AuthStorage.fromStorage(storage);\n\t}\n\n\t/**\n\t * Set a runtime API key override (not persisted to disk).\n\t * Used for CLI --api-key flag.\n\t */\n\tsetRuntimeApiKey(provider: string, apiKey: string): void {\n\t\tthis.runtimeOverrides.set(provider, apiKey);\n\t}\n\t/** Read a non-persisted request override without resolving stored credentials. */\n\tgetRuntimeApiKey(provider: string): string | undefined {\n\t\treturn this.runtimeOverrides.get(provider);\n\t}\n\n\n\t/**\n\t * Remove a runtime API key override.\n\t */\n\tremoveRuntimeApiKey(provider: string): void {\n\t\tthis.runtimeOverrides.delete(provider);\n\t}\n\n\t/**\n\t * Set a fallback resolver for API keys not found in auth.json or env vars.\n\t * Used for custom provider keys from models.json.\n\t */\n\tsetFallbackResolver(resolver: (provider: string) => string | undefined): void {\n\t\tthis.fallbackResolver = resolver;\n\t}\n\n\tprivate recordError(error: unknown): void {\n\t\tconst normalizedError = error instanceof Error ? error : new Error(String(error));\n\t\tthis.errors.push(normalizedError);\n\t}\n\n\tprivate parseStorageData(content: string | undefined): AuthStorageData {\n\t\tif (!content) {\n\t\t\treturn {};\n\t\t}\n\t\treturn JSON.parse(content) as AuthStorageData;\n\t}\n\n\t/**\n\t * Reload credentials from storage.\n\t */\n\treload(): void {\n\t\ttry {\n\t\t\t// Pure read: never take the exclusive write lock. Writers replace\n\t\t\t// auth.json atomically, so a lock-free read always sees a complete\n\t\t\t// snapshot. This keeps many concurrent sessions from starving each other\n\t\t\t// on the lock and misreporting configured providers as unreadable under\n\t\t\t// contention (issue #1431).\n\t\t\tconst content = this.readSnapshot();\n\t\t\tthis.data = this.parseStorageData(content);\n\t\t\tthis.loadError = null;\n\t\t} catch (error) {\n\t\t\tthis.loadError = error as Error;\n\t\t\tthis.recordError(error);\n\t\t}\n\t}\n\n\t/**\n\t * Read the credential snapshot, preferring the backend's lock-free `read()`.\n\t * Falls back to a `withLock`-based read for custom backends that predate\n\t * `read()` so the released `AuthStorageBackend` interface stays compatible.\n\t */\n\tprivate readSnapshot(): string | undefined {\n\t\tif (this.storage.read) {\n\t\t\treturn this.storage.read();\n\t\t}\n\t\tlet content: string | undefined;\n\t\tthis.storage.withLock((current) => {\n\t\t\tcontent = current;\n\t\t\treturn { result: undefined };\n\t\t});\n\t\treturn content;\n\t}\n\n\tprivate bumpCredentialVersion(provider: string): void {\n\t\tthis.credentialVersions.set(provider, (this.credentialVersions.get(provider) ?? 0) + 1);\n\t}\n\n\tprivate persistProviderChange(provider: string, credential: AuthCredential | undefined): void {\n\t\tif (this.loadError) {\n\t\t\tthis.reload();\n\t\t\tif (this.loadError) throw this.loadError;\n\t\t}\n\n\t\ttry {\n\t\t\tconst persistedData = this.storage.withLock((current) => {\n\t\t\t\tconst currentData = this.parseStorageData(current);\n\t\t\t\tconst merged: AuthStorageData = { ...currentData };\n\t\t\t\tif (credential) {\n\t\t\t\t\tmerged[provider] = credential;\n\t\t\t\t} else {\n\t\t\t\t\tdelete merged[provider];\n\t\t\t\t}\n\t\t\t\treturn { result: merged, next: JSON.stringify(merged, null, 2) };\n\t\t\t});\n\t\t\tthis.data = persistedData;\n\t\t\tthis.bumpCredentialVersion(provider);\n\t\t\tthis.loadError = null;\n\t\t} catch (error) {\n\t\t\tthis.recordError(error);\n\t\t\tthrow error instanceof Error ? error : new Error(String(error));\n\t\t}\n\t}\n\n\t/**\n\t * Get credential for a provider.\n\t */\n\tget(provider: string): AuthCredential | undefined {\n\t\treturn this.data[provider] ?? undefined;\n\t}\n\n\t/**\n\t * Set credential for a provider.\n\t */\n\tset(provider: string, credential: AuthCredential): void {\n\t\tthis.persistProviderChange(provider, credential);\n\t}\n\n\t/**\n\t * Remove credential for a provider.\n\t */\n\tremove(provider: string): void {\n\t\tif (!this.storage.deleteProvider) {\n\t\t\tthis.persistProviderChange(provider, undefined);\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tthis.data = this.parseStorageData(this.storage.deleteProvider(provider));\n\t\t\tthis.bumpCredentialVersion(provider);\n\t\t\tthis.loadError = null;\n\t\t} catch (error) {\n\t\t\tthis.recordError(error);\n\t\t\tthrow error instanceof Error ? error : new Error(String(error));\n\t\t}\n\t}\n\n\t/**\n\t * List all providers with credentials.\n\t */\n\tlist(): string[] {\n\t\treturn Object.keys(this.data);\n\t}\n\n\t/**\n\t * Check if credentials exist for a provider in auth.json.\n\t */\n\thas(provider: string): boolean {\n\t\treturn provider in this.data;\n\t}\n\n\t/**\n\t * Check if any form of auth is configured for a provider.\n\t * Unlike getApiKey(), this doesn't refresh OAuth tokens.\n\t */\n\thasAuth(provider: string): boolean {\n\t\tif (this.runtimeOverrides.has(provider)) return true;\n\t\tif (this.data[provider]) return true;\n\t\tif (getEnvApiKey(provider)) return true;\n\t\tif (this.fallbackResolver?.(provider)) return true;\n\t\treturn false;\n\t}\n\n\t/**\n\t * Return auth status without exposing credential values or refreshing tokens.\n\t */\n\tgetAuthStatus(provider: string): AuthStatus {\n\t\tif (this.data[provider]) {\n\t\t\treturn { configured: true, source: \"stored\" };\n\t\t}\n\n\t\tif (this.runtimeOverrides.has(provider)) {\n\t\t\treturn { configured: false, source: \"runtime\", label: \"--api-key\" };\n\t\t}\n\n\t\tconst envKeys = findEnvKeys(provider);\n\t\tif (envKeys?.[0]) {\n\t\t\treturn { configured: false, source: \"environment\", label: envKeys[0] };\n\t\t}\n\n\t\tif (this.fallbackResolver?.(provider)) {\n\t\t\treturn { configured: false, source: \"fallback\", label: \"custom provider config\" };\n\t\t}\n\n\t\treturn { configured: false };\n\t}\n\n\t/** Return a copy of all persisted credentials. */\n\tgetAll(): AuthStorageData {\n\t\treturn { ...this.data };\n\t}\n\n\tdrainErrors(): Error[] {\n\t\tconst drained = [...this.errors];\n\t\tthis.errors = [];\n\t\treturn drained;\n\t}\n\n\t/**\n\t * Returns the error from the most recent failed credential load, or null when\n\t * the last reload succeeded.\n\t *\n\t * A non-null value means stored credentials could NOT be read — e.g. the auth\n\t * file was temporarily locked by another process (ELOCKED) or contained\n\t * invalid JSON — so an empty/absent credential set is NOT authoritative.\n\t * Callers that would otherwise report \"No API key found\" should surface this\n\t * load failure instead of treating the provider as unauthenticated\n\t * (issue #1431).\n\t */\n\tgetLoadError(): Error | null {\n\t\treturn this.loadError;\n\t}\n\n\t/**\n\t * Login to an OAuth provider.\n\t */\n\tasync login(providerId: string, callbacks: AtomicOAuthLoginCallbacks): Promise<void> {\n\t\tconst credential = await loginOAuthProvider(providerId, callbacks);\n\t\tawait this.asCredentialStore().modify(providerId, async () => credential);\n\t}\n\n\t/** Logout through the preserved synchronous persistence path. */\n\tlogout(provider: string): void {\n\t\tthis.remove(provider);\n\t}\n\n\t/** Serialized logout for callers that need persistence completion. */\n\tasync logoutAsync(provider: string): Promise<void> {\n\t\tawait this.asCredentialStore().delete(provider);\n\t}\n\n\t/**\n\t * Refresh OAuth token with backend locking to prevent race conditions.\n\t * Multiple pi instances may try to refresh simultaneously when tokens expire.\n\t */\n\tprivate async refreshOAuthTokenWithLock(\n\t\tproviderId: string,\n\t): Promise<{ auth: ModelAuth; newCredentials: OAuthCredentials } | null> {\n\t\treturn this.runCredentialMutation(async () => {\n\t\t\tlet synchronizedData: AuthStorageData | undefined;\n\t\t\tconst credentialVersion = this.credentialVersions.get(providerId) ?? 0;\n\t\t\tconst result = await this.storage.withLockAsync(async (current) => {\n\t\t\t\tconst currentData = this.parseStorageData(current);\n\t\t\t\tsynchronizedData = currentData;\n\t\t\t\tconst cred = currentData[providerId];\n\t\t\t\tif (cred?.type !== \"oauth\") return { result: null };\n\n\t\t\t\tconst oauthCredential: PiOAuthCredential = { ...cred, type: \"oauth\" };\n\t\t\t\tif (Date.now() < cred.expires) {\n\t\t\t\t\tconst auth = await oauthCredentialToAuth(providerId, oauthCredential);\n\t\t\t\t\treturn { result: auth ? { auth, newCredentials: cred } : null };\n\t\t\t\t}\n\n\t\t\t\tconst refreshed = await refreshOAuthProvider(providerId, oauthCredential);\n\t\t\t\tif (!refreshed) return { result: null };\n\t\t\t\tif ((this.credentialVersions.get(providerId) ?? 0) !== credentialVersion) {\n\t\t\t\t\tsynchronizedData = undefined;\n\t\t\t\t\treturn { result: null };\n\t\t\t\t}\n\t\t\t\tconst merged: AuthStorageData = {\n\t\t\t\t\t...currentData,\n\t\t\t\t\t[providerId]: refreshed.credential,\n\t\t\t\t};\n\t\t\t\tsynchronizedData = merged;\n\t\t\t\treturn {\n\t\t\t\t\tresult: { auth: refreshed.auth, newCredentials: refreshed.credential },\n\t\t\t\t\tnext: JSON.stringify(merged, null, 2),\n\t\t\t\t};\n\t\t\t});\n\n\t\t\tif (synchronizedData) this.data = synchronizedData;\n\t\t\tthis.loadError = null;\n\t\t\treturn result;\n\t\t});\n\t}\n\n\t/**\n\t * Get API key for a provider.\n\t * Priority:\n\t * 1. Runtime override (CLI --api-key)\n\t * 2. API key from auth.json\n\t * 3. OAuth token from auth.json (auto-refreshed with locking)\n\t * 4. Environment variable\n\t * 5. Fallback resolver (models.json custom providers)\n\t */\n\tasync getModelAuth(providerId: string, options?: { includeFallback?: boolean }): Promise<ModelAuth | undefined> {\n\t\tconst runtimeKey = this.runtimeOverrides.get(providerId);\n\t\tif (runtimeKey) return { apiKey: runtimeKey };\n\n\t\tconst cred = this.data[providerId];\n\t\tif (cred?.type === \"api_key\") return { apiKey: resolveConfigValue(cred.key) };\n\n\t\tif (cred?.type === \"oauth\") {\n\t\t\ttry {\n\t\t\t\tif (Date.now() >= cred.expires) {\n\t\t\t\t\treturn (await this.refreshOAuthTokenWithLock(providerId))?.auth;\n\t\t\t\t}\n\t\t\t\treturn await oauthCredentialToAuth(providerId, { ...cred, type: \"oauth\" });\n\t\t\t} catch (error) {\n\t\t\t\tthis.recordError(error);\n\t\t\t\tthis.reload();\n\t\t\t\tconst updated = this.data[providerId];\n\t\t\t\tif (updated?.type === \"oauth\" && Date.now() < updated.expires) {\n\t\t\t\t\treturn oauthCredentialToAuth(providerId, { ...updated, type: \"oauth\" });\n\t\t\t\t}\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\n\t\tconst envKey = getEnvApiKey(providerId);\n\t\tif (envKey) return { apiKey: envKey };\n\t\tif (options?.includeFallback !== false) {\n\t\t\tconst fallback = this.fallbackResolver?.(providerId);\n\t\t\tif (fallback) return { apiKey: fallback };\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tasync getApiKey(providerId: string, options?: { includeFallback?: boolean }): Promise<string | undefined> {\n\t\treturn (await this.getModelAuth(providerId, options))?.apiKey;\n\t}\n\n\t/**\n\t * Get all registered OAuth providers\n\t */\n\tgetOAuthProviders() {\n\t\treturn getOAuthProviderDescriptors();\n\t}\n\n\tprivate runCredentialMutation<T>(operation: () => Promise<T>): Promise<T> {\n\t\tconst result = this.credentialMutationTail.then(operation, operation);\n\t\tthis.credentialMutationTail = result.then(\n\t\t\t() => undefined,\n\t\t\t() => undefined,\n\t\t);\n\t\treturn result;\n\t}\n\n\t/** Private async adapter for pi-ai's provider-owned Models runtime. */\n\tasCredentialStore(): CredentialStore {\n\t\tconst runtimeCredential = (providerId: string): Credential | undefined => {\n\t\t\tconst key = this.runtimeOverrides.get(providerId);\n\t\t\treturn key === undefined ? undefined : { type: \"api_key\", key };\n\t\t};\n\t\treturn {\n\t\t\tread: async (providerId) => runtimeCredential(providerId) ?? (this.get(providerId) as Credential | undefined),\n\t\t\tlist: async (): Promise<readonly CredentialInfo[]> => {\n\t\t\t\tconst providers = new Set([...this.list(), ...this.runtimeOverrides.keys()]);\n\t\t\t\treturn [...providers].map((providerId) => ({\n\t\t\t\t\tproviderId,\n\t\t\t\t\ttype: runtimeCredential(providerId)?.type ?? this.data[providerId].type,\n\t\t\t\t}));\n\t\t\t},\n\t\t\tmodify: (providerId, fn) =>\n\t\t\t\tthis.runCredentialMutation(async () => {\n\t\t\t\t\tlet synchronizedData: AuthStorageData | undefined;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst result = await this.storage.withLockAsync(async (current) => {\n\t\t\t\t\t\t\tconst data = this.parseStorageData(current);\n\t\t\t\t\t\t\tconst next = await fn(data[providerId] as Credential | undefined);\n\t\t\t\t\t\t\tif (next === undefined) {\n\t\t\t\t\t\t\t\tsynchronizedData = data;\n\t\t\t\t\t\t\t\treturn { result: data[providerId] as Credential | undefined };\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst merged = { ...data, [providerId]: next as AuthCredential };\n\t\t\t\t\t\t\tsynchronizedData = merged;\n\t\t\t\t\t\t\treturn { result: next, next: JSON.stringify(merged, null, 2) };\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (synchronizedData) {\n\t\t\t\t\t\t\tthis.data = synchronizedData;\n\t\t\t\t\t\t\tthis.bumpCredentialVersion(providerId);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthis.loadError = null;\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tthis.recordError(error);\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\tdelete: (providerId) =>\n\t\t\t\tthis.runCredentialMutation(async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (this.storage.deleteProviderAsync) {\n\t\t\t\t\t\t\tthis.data = this.parseStorageData(await this.storage.deleteProviderAsync(providerId));\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tlet synchronizedData: AuthStorageData | undefined;\n\t\t\t\t\t\t\tawait this.storage.withLockAsync(async (current) => {\n\t\t\t\t\t\t\t\tconst data = this.parseStorageData(current);\n\t\t\t\t\t\t\t\tdelete data[providerId];\n\t\t\t\t\t\t\t\tsynchronizedData = data;\n\t\t\t\t\t\t\t\treturn { result: undefined, next: JSON.stringify(data, null, 2) };\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tif (synchronizedData) this.data = synchronizedData;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthis.bumpCredentialVersion(providerId);\n\t\t\t\t\t\tthis.loadError = null;\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tthis.recordError(error);\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t};\n\t}\n}\n"]}
@@ -0,0 +1,3 @@
1
+ export declare function isCodexTokenInvalidationError(provider: string, errorMessage: string | undefined): boolean;
2
+ export declare function formatCodexProviderError(provider: string, errorMessage: string): string;
3
+ //# sourceMappingURL=codex-errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codex-errors.d.ts","sourceRoot":"","sources":["../../src/core/codex-errors.ts"],"names":[],"mappings":"AAIA,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAEzG;AAED,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAKvF"}
@@ -0,0 +1,12 @@
1
+ const CODEX_INVALIDATED_TOKEN_PATTERN = /\binvalidated\s+(?:oauth|auth)\s+token\b|\btoken_revoked\b/i;
2
+ const CODEX_RECOVERY_GUIDANCE = "This Codex session may no longer be valid. Retry the request once in case the rejection is transient. If it persists, run `/logout` and select OpenAI ChatGPT Plus/Pro. Then run `/login`, authenticate OpenAI ChatGPT Plus/Pro again, and retry the request.";
3
+ export function isCodexTokenInvalidationError(provider, errorMessage) {
4
+ return provider === "openai-codex" && errorMessage !== undefined && CODEX_INVALIDATED_TOKEN_PATTERN.test(errorMessage);
5
+ }
6
+ export function formatCodexProviderError(provider, errorMessage) {
7
+ if (!isCodexTokenInvalidationError(provider, errorMessage) || errorMessage.includes(CODEX_RECOVERY_GUIDANCE)) {
8
+ return errorMessage;
9
+ }
10
+ return `${errorMessage}\n\n${CODEX_RECOVERY_GUIDANCE}`;
11
+ }
12
+ //# sourceMappingURL=codex-errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codex-errors.js","sourceRoot":"","sources":["../../src/core/codex-errors.ts"],"names":[],"mappings":"AAAA,MAAM,+BAA+B,GAAG,6DAA6D,CAAC;AACtG,MAAM,uBAAuB,GAC5B,+PAA+P,CAAC;AAEjQ,MAAM,UAAU,6BAA6B,CAAC,QAAgB,EAAE,YAAgC;IAC/F,OAAO,QAAQ,KAAK,cAAc,IAAI,YAAY,KAAK,SAAS,IAAI,+BAA+B,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;AACxH,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,QAAgB,EAAE,YAAoB;IAC9E,IAAI,CAAC,6BAA6B,CAAC,QAAQ,EAAE,YAAY,CAAC,IAAI,YAAY,CAAC,QAAQ,CAAC,uBAAuB,CAAC,EAAE,CAAC;QAC9G,OAAO,YAAY,CAAC;IACrB,CAAC;IACD,OAAO,GAAG,YAAY,OAAO,uBAAuB,EAAE,CAAC;AACxD,CAAC","sourcesContent":["const CODEX_INVALIDATED_TOKEN_PATTERN = /\\binvalidated\\s+(?:oauth|auth)\\s+token\\b|\\btoken_revoked\\b/i;\nconst CODEX_RECOVERY_GUIDANCE =\n\t\"This Codex session may no longer be valid. Retry the request once in case the rejection is transient. If it persists, run `/logout` and select OpenAI ChatGPT Plus/Pro. Then run `/login`, authenticate OpenAI ChatGPT Plus/Pro again, and retry the request.\";\n\nexport function isCodexTokenInvalidationError(provider: string, errorMessage: string | undefined): boolean {\n\treturn provider === \"openai-codex\" && errorMessage !== undefined && CODEX_INVALIDATED_TOKEN_PATTERN.test(errorMessage);\n}\n\nexport function formatCodexProviderError(provider: string, errorMessage: string): string {\n\tif (!isCodexTokenInvalidationError(provider, errorMessage) || errorMessage.includes(CODEX_RECOVERY_GUIDANCE)) {\n\t\treturn errorMessage;\n\t}\n\treturn `${errorMessage}\\n\\n${CODEX_RECOVERY_GUIDANCE}`;\n}\n"]}
@@ -15,7 +15,7 @@ const WORKFLOW_ADMIN_COMPLETIONS = [
15
15
  const BUNDLED_WORKFLOW_COMPLETION_METADATA = [
16
16
  {
17
17
  name: "deep-research-codebase",
18
- description: "Scout + research-history chain parallel specialist waves → aggregator for deep codebase research.",
18
+ description: "Heavy research for tasks requiring comprehensive, whole-repository context.",
19
19
  inputs: {
20
20
  prompt: { description: "Research question or investigation focus for the codebase.", kind: "string" },
21
21
  max_partitions: { description: "Maximum number of codebase partitions to explore in parallel.", kind: "number" },
@@ -1 +1 @@
1
- {"version":3,"file":"slash-commands.js","sourceRoot":"","sources":["../../src/core/slash-commands.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EACN,gCAAgC,EAChC,yBAAyB,EACzB,iCAAiC,GACjC,MAAM,2BAA2B,CAAC;AA+BnC,MAAM,0BAA0B,GAAuB;IACtD,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,mCAAmC,EAAE;IACzF,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,yCAAyC,EAAE;IAC7F,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,2BAA2B,EAAE;IAC3E,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,wDAAwD,EAAE;IAC5G,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,iBAAiB,EAAE;IAC3E,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK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;IACnE,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,yBAAyB,EAAE;IAC7D,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,+BAA+B,EAAE;CAClE,CAAC","sourcesContent":["import type { AutocompleteItem } from \"@earendil-works/pi-tui\";\nimport { APP_NAME } from \"../config.ts\";\nimport {\n\tATOMIC_GUIDE_COMMAND_DESCRIPTION,\n\tATOMIC_GUIDE_COMMAND_NAME,\n\tgetAtomicGuideArgumentCompletions,\n} from \"./atomic-guide-command.ts\";\nimport type { SourceInfo } from \"./source-info.ts\";\n\nexport type SlashCommandSource = \"extension\" | \"prompt\" | \"skill\";\n\nexport interface SlashCommandInfo {\n\tname: string;\n\tdescription?: string;\n\tsource: SlashCommandSource;\n\tsourceInfo: SourceInfo;\n}\n\nexport interface BuiltinSlashCommand {\n\tname: string;\n\tdescription: string;\n\tgetArgumentCompletions?: (\n\t\targumentPrefix: string,\n\t) => AutocompleteItem[] | null | Promise<AutocompleteItem[] | null>;\n}\n\ntype WorkflowInputCompletionMetadata = {\n\tdescription: string;\n\tkind?: \"boolean\" | \"number\" | \"string\";\n};\n\ntype WorkflowCompletionMetadata = {\n\tname: string;\n\tdescription: string;\n\tinputs: Record<string, WorkflowInputCompletionMetadata>;\n};\n\nconst WORKFLOW_ADMIN_COMPLETIONS: AutocompleteItem[] = [\n\t{ value: \"connect \", label: \"connect\", description: \"Attach to a run (picker if no id)\" },\n\t{ value: \"attach \", label: \"attach\", description: \"Open the in-place attach pane on a node\" },\n\t{ value: \"list \", label: \"list\", description: \"List registered workflows\" },\n\t{ value: \"status \", label: \"status\", description: \"List current-session active and retained terminal runs\" },\n\t{ value: \"interrupt \", label: \"interrupt\", description: \"Interrupt a run\" },\n\t{ value: \"quit \", label: \"quit\", description: \"Quit a run and keep it resumable\" },\n\t{ value: \"pause \", label: \"pause\", description: \"Pause a run or stage\" },\n\t{ value: \"resume \", label: \"resume\", description: \"Re-open overlay for a run\" },\n\t{ value: \"inputs \", label: \"inputs\", description: \"Show a workflow's input schema\" },\n\t{ value: \"reload \", label: \"reload\", description: \"Reload workflow resources\" },\n];\n\nconst BUNDLED_WORKFLOW_COMPLETION_METADATA: WorkflowCompletionMetadata[] = [\n\t{\n\t\tname: \"deep-research-codebase\",\n\t\tdescription: \"Scout + research-history chain → parallel specialist waves → aggregator for deep codebase research.\",\n\t\tinputs: {\n\t\t\tprompt: { description: \"Research question or investigation focus for the codebase.\", kind: \"string\" },\n\t\t\tmax_partitions: { description: \"Maximum number of codebase partitions to explore in parallel.\", kind: \"number\" },\n\t\t\tmax_concurrency: { description: \"Maximum number of workflow stages to run concurrently during deep research.\", kind: \"number\" },\n\t\t},\n\t},\n\t{\n\t\tname: \"goal\",\n\t\tdescription: \"Goal Runner workflow with bounded LM turns, acceptance criteria, ledger artifacts, reviewers, and reducer-gated completion.\",\n\t\tinputs: {\n\t\t\tobjective: { description: \"The objective or delta for this Goal Runner workflow run.\", kind: \"string\" },\n\t\t\tacceptance_criteria: { description: \"Original immutable task contract this run must remain consistent with.\", kind: \"string\" },\n\t\t\tmax_turns: { description: \"Maximum worker/review turns before Goal Runner stops as needs_human.\", kind: \"number\" },\n\t\t\tbase_branch: { description: \"Optional branch reviewers compare the current code delta against.\", kind: \"string\" },\n\t\t\tgit_worktree_dir: { description: \"Optional Git worktree path.\", kind: \"string\" },\n\t\t\tcreate_pr: { description: \"Whether to run the final pull-request creation stage after approval.\", kind: \"boolean\" },\n\t\t},\n\t},\n\t{\n\t\tname: \"open-claude-design\",\n\t\tdescription: \"AI-powered design workflow: discovery, reference research, HTML generation, refinement, and handoff.\",\n\t\tinputs: {\n\t\t\tprompt: { description: \"What to design, such as a dashboard, page, component, or prototype.\", kind: \"string\" },\n\t\t\tdiscover_references: { description: \"Discover current reference designs and feed them to generation.\", kind: \"boolean\" },\n\t\t\tmax_refinements: { description: \"Maximum generate/user-feedback loop iterations.\", kind: \"number\" },\n\t\t},\n\t},\n\t{\n\t\tname: \"ralph\",\n\t\tdescription: \"Raw prompt → research → orchestrate → multi-model parallel review loop with bounded iteration.\",\n\t\tinputs: {\n\t\t\tprompt: { description: \"The task or goal to research, execute, and refine.\", kind: \"string\" },\n\t\t\tacceptance_criteria: { description: \"Original immutable task contract this run must remain consistent with.\", kind: \"string\" },\n\t\t\tmax_loops: { description: \"Maximum research/orchestrate/review iterations.\", kind: \"number\" },\n\t\t\tbase_branch: { description: \"Branch reviewers compare the current code delta against.\", kind: \"string\" },\n\t\t\tgit_worktree_dir: { description: \"Optional Git worktree path.\", kind: \"string\" },\n\t\t\tcreate_pr: { description: \"Whether to run the final pull-request creation stage.\", kind: \"boolean\" },\n\t\t},\n\t},\n];\n\nfunction completeWorkflowToken(argumentText: string, candidates: AutocompleteItem[]): AutocompleteItem[] | null {\n\tconst tokenStart = /\\s$/.test(argumentText)\n\t\t? argumentText.length\n\t\t: Math.max(argumentText.lastIndexOf(\" \"), argumentText.lastIndexOf(\"\\t\")) + 1;\n\tconst head = argumentText.slice(0, tokenStart);\n\tconst token = argumentText.slice(tokenStart);\n\tconst normalizedToken = token.trimEnd();\n\tconst filtered = candidates\n\t\t.filter((candidate) => candidate.value.startsWith(token) && candidate.value.trimEnd() !== normalizedToken)\n\t\t.map((candidate) => ({ ...candidate, value: `${head}${candidate.value}` }));\n\treturn filtered.length > 0 ? filtered : null;\n}\n\nfunction bundledWorkflowNameItems(): AutocompleteItem[] {\n\treturn BUNDLED_WORKFLOW_COMPLETION_METADATA.map((workflow) => ({\n\t\tvalue: `${workflow.name} `,\n\t\tlabel: workflow.name,\n\t\tdescription: `Run workflow: ${workflow.name}`,\n\t}));\n}\n\nexport function getBundledWorkflowArgumentCompletions(argumentPrefix: string): AutocompleteItem[] | null {\n\tconst parts = argumentPrefix.trim().split(/\\s+/).filter(Boolean);\n\tconst subcommand = parts[0] ?? \"\";\n\tconst workflowItems = bundledWorkflowNameItems();\n\tif (!argumentPrefix.includes(\" \")) {\n\t\treturn completeWorkflowToken(argumentPrefix, [...WORKFLOW_ADMIN_COMPLETIONS, ...workflowItems]);\n\t}\n\tif (subcommand === \"inputs\") return completeWorkflowToken(argumentPrefix, workflowItems);\n\tif (subcommand === \"interrupt\") {\n\t\treturn completeWorkflowToken(argumentPrefix, [\n\t\t\t{ value: \"--all \", label: \"--all\", description: \"Interrupt all in-flight runs\" },\n\t\t\t{ value: \"--yes \", label: \"--yes\", description: \"Skip confirmation\" },\n\t\t\t{ value: \"-y \", label: \"-y\", description: \"Skip confirmation\" },\n\t\t]);\n\t}\n\tif (subcommand === \"quit\") {\n\t\treturn completeWorkflowToken(argumentPrefix, [\n\t\t\t{ value: \"--all \", label: \"--all\", description: \"Quit and keep all in-flight runs resumable\" },\n\t\t]);\n\t}\n\tif (!subcommand) return completeWorkflowToken(argumentPrefix, [...WORKFLOW_ADMIN_COMPLETIONS, ...workflowItems]);\n\n\tconst workflow = BUNDLED_WORKFLOW_COMPLETION_METADATA.find((candidate) => candidate.name === subcommand);\n\tif (!workflow) return null;\n\tconst tokenStart = /\\s$/.test(argumentPrefix)\n\t\t? argumentPrefix.length\n\t\t: Math.max(argumentPrefix.lastIndexOf(\" \"), argumentPrefix.lastIndexOf(\"\\t\")) + 1;\n\tconst token = argumentPrefix.slice(tokenStart);\n\tconst equalsIndex = token.indexOf(\"=\");\n\tif (equalsIndex > 0) {\n\t\tconst inputName = token.slice(0, equalsIndex);\n\t\tconst input = workflow.inputs[inputName];\n\t\tif (input?.kind !== \"boolean\") return null;\n\t\treturn completeWorkflowToken(argumentPrefix, [\n\t\t\t{ value: `${inputName}=true `, label: \"true\", description: inputName },\n\t\t\t{ value: `${inputName}=false `, label: \"false\", description: inputName },\n\t\t]);\n\t}\n\n\treturn completeWorkflowToken(argumentPrefix, [\n\t\t{ value: \"--no-picker \", label: \"--no-picker\", description: \"Skip interactive input picker\" },\n\t\t{ value: \"--help \", label: \"--help\", description: \"Show this workflow's input schema\" },\n\t\t...Object.entries(workflow.inputs).map(([name, input]) => ({\n\t\t\tvalue: `${name}=`,\n\t\t\tlabel: name,\n\t\t\tdescription: input.description,\n\t\t})),\n\t]);\n}\n\nexport const BUILTIN_SLASH_COMMANDS: ReadonlyArray<BuiltinSlashCommand> = [\n\t{ name: \"settings\", description: \"Open settings menu\" },\n\t{ name: \"model\", description: \"Select model (opens selector UI)\" },\n\t{ name: \"scoped-models\", description: \"Enable/disable models for ctrl+p cycling\" },\n\t{ name: \"fast\", description: \"Configure Codex fast mode for chat and workflows\" },\n\t{ name: \"export\", description: \"Export session (HTML default, or specify path: .html/.jsonl)\" },\n\t{ name: \"import\", description: \"Import and resume a session from a JSONL file\" },\n\t{ name: \"share\", description: \"Share session as a secret GitHub gist\" },\n\t{ name: \"copy\", description: \"Copy last agent message to clipboard\" },\n\t{ name: \"name\", description: \"Set session display name\" },\n\t{ name: \"session\", description: \"Show session info and stats\" },\n\t{ name: \"changelog\", description: \"Show changelog entries\" },\n\t{\n\t\tname: ATOMIC_GUIDE_COMMAND_NAME,\n\t\tdescription: ATOMIC_GUIDE_COMMAND_DESCRIPTION,\n\t\tgetArgumentCompletions: getAtomicGuideArgumentCompletions,\n\t},\n\t{ name: \"hotkeys\", description: \"Show all keyboard shortcuts\" },\n\t{ name: \"fork\", description: \"Create a new fork from a previous user message\" },\n\t{ name: \"clone\", description: \"Duplicate the current session at the current position\" },\n\t{ name: \"tree\", description: \"Navigate session tree (switch branches)\" },\n\t{ name: \"trust\", description: \"Save project trust decision for future sessions\" },\n\t{ name: \"login\", description: \"Configure provider authentication\" },\n\t{ name: \"logout\", description: \"Remove provider authentication\" },\n\t{ name: \"new\", description: \"Start a new session\" },\n\t{ name: \"compact\", description: \"Compact older context with verbatim line ranges\" },\n\t{ name: \"resume\", description: \"Resume a different session\" },\n\t{ name: \"reload\", description: \"Reload keybindings, extensions, skills, prompts, and themes\" },\n\t{ name: \"exit\", description: `Exit ${APP_NAME}` },\n\t{ name: \"quit\", description: `Quit ${APP_NAME}` },\n];\n\nexport const BUNDLED_EXTENSION_SLASH_COMMANDS: ReadonlyArray<BuiltinSlashCommand> = [\n\t{\n\t\tname: \"workflow\",\n\t\tdescription: \"Run or inspect Atomic workflows. Usage: /workflow <name> [key=value…] | /workflow [list|status|connect|attach|interrupt|quit|pause|resume|inputs|reload] [args]\",\n\t\tgetArgumentCompletions: getBundledWorkflowArgumentCompletions,\n\t},\n\t{ name: \"run\", description: \"Run a subagent directly: /run agent[output=file] [task] [--bg] [--fork]\" },\n\t{ name: \"chain\", description: \"Run agents in sequence: /chain scout task -> planner [--bg] [--fork]\" },\n\t{ name: \"run-chain\", description: \"Run a saved chain: /run-chain chainName -- task [--bg] [--fork]\" },\n\t{ name: \"parallel\", description: \"Run agents in parallel: /parallel scout task1 -> reviewer task2 [--bg] [--fork]\" },\n\t{ name: \"subagents-doctor\", description: \"Show subagent diagnostics\" },\n\t{ name: \"mcp\", description: \"Show MCP server status\" },\n\t{ name: \"mcp-auth\", description: \"Authenticate with an MCP server (OAuth)\" },\n\t{ name: \"curator\", description: \"Toggle or configure the search curator workflow\" },\n\t{ name: \"google-account\", description: \"Show the active Google account for Gemini Web\" },\n\t{ name: \"search\", description: \"Browse stored web search results\" },\n\t{ name: \"websearch\", description: \"Open web search curator\" },\n\t{ name: \"intercom\", description: \"Open session intercom overlay\" },\n];\n"]}
1
+ {"version":3,"file":"slash-commands.js","sourceRoot":"","sources":["../../src/core/slash-commands.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EACN,gCAAgC,EAChC,yBAAyB,EACzB,iCAAiC,GACjC,MAAM,2BAA2B,CAAC;AA+BnC,MAAM,0BAA0B,GAAuB;IACtD,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,mCAAmC,EAAE;IACzF,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,yCAAyC,EAAE;IAC7F,EAAE,KAAK,EAAE,O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,WAAW,EAAE,wBAAwB,EAAE;IACtD,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,yCAAyC,EAAE;IAC5E,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,iDAAiD,EAAE;IACnF,EAAE,IAAI,EAAE,gBAAgB,EAAE,WAAW,EAAE,+CAA+C,EAAE;IACxF,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,kCAAkC,EAAE;IACnE,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,yBAAyB,EAAE;IAC7D,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,+BAA+B,EAAE;CAClE,CAAC","sourcesContent":["import type { AutocompleteItem } from \"@earendil-works/pi-tui\";\nimport { APP_NAME } from \"../config.ts\";\nimport {\n\tATOMIC_GUIDE_COMMAND_DESCRIPTION,\n\tATOMIC_GUIDE_COMMAND_NAME,\n\tgetAtomicGuideArgumentCompletions,\n} from \"./atomic-guide-command.ts\";\nimport type { SourceInfo } from \"./source-info.ts\";\n\nexport type SlashCommandSource = \"extension\" | \"prompt\" | \"skill\";\n\nexport interface SlashCommandInfo {\n\tname: string;\n\tdescription?: string;\n\tsource: SlashCommandSource;\n\tsourceInfo: SourceInfo;\n}\n\nexport interface BuiltinSlashCommand {\n\tname: string;\n\tdescription: string;\n\tgetArgumentCompletions?: (\n\t\targumentPrefix: string,\n\t) => AutocompleteItem[] | null | Promise<AutocompleteItem[] | null>;\n}\n\ntype WorkflowInputCompletionMetadata = {\n\tdescription: string;\n\tkind?: \"boolean\" | \"number\" | \"string\";\n};\n\ntype WorkflowCompletionMetadata = {\n\tname: string;\n\tdescription: string;\n\tinputs: Record<string, WorkflowInputCompletionMetadata>;\n};\n\nconst WORKFLOW_ADMIN_COMPLETIONS: AutocompleteItem[] = [\n\t{ value: \"connect \", label: \"connect\", description: \"Attach to a run (picker if no id)\" },\n\t{ value: \"attach \", label: \"attach\", description: \"Open the in-place attach pane on a node\" },\n\t{ value: \"list \", label: \"list\", description: \"List registered workflows\" },\n\t{ value: \"status \", label: \"status\", description: \"List current-session active and retained terminal runs\" },\n\t{ value: \"interrupt \", label: \"interrupt\", description: \"Interrupt a run\" },\n\t{ value: \"quit \", label: \"quit\", description: \"Quit a run and keep it resumable\" },\n\t{ value: \"pause \", label: \"pause\", description: \"Pause a run or stage\" },\n\t{ value: \"resume \", label: \"resume\", description: \"Re-open overlay for a run\" },\n\t{ value: \"inputs \", label: \"inputs\", description: \"Show a workflow's input schema\" },\n\t{ value: \"reload \", label: \"reload\", description: \"Reload workflow resources\" },\n];\n\nconst BUNDLED_WORKFLOW_COMPLETION_METADATA: WorkflowCompletionMetadata[] = [\n\t{\n\t\tname: \"deep-research-codebase\",\n\t\tdescription: \"Heavy research for tasks requiring comprehensive, whole-repository context.\",\n\t\tinputs: {\n\t\t\tprompt: { description: \"Research question or investigation focus for the codebase.\", kind: \"string\" },\n\t\t\tmax_partitions: { description: \"Maximum number of codebase partitions to explore in parallel.\", kind: \"number\" },\n\t\t\tmax_concurrency: { description: \"Maximum number of workflow stages to run concurrently during deep research.\", kind: \"number\" },\n\t\t},\n\t},\n\t{\n\t\tname: \"goal\",\n\t\tdescription: \"Goal Runner workflow with bounded LM turns, acceptance criteria, ledger artifacts, reviewers, and reducer-gated completion.\",\n\t\tinputs: {\n\t\t\tobjective: { description: \"The objective or delta for this Goal Runner workflow run.\", kind: \"string\" },\n\t\t\tacceptance_criteria: { description: \"Original immutable task contract this run must remain consistent with.\", kind: \"string\" },\n\t\t\tmax_turns: { description: \"Maximum worker/review turns before Goal Runner stops as needs_human.\", kind: \"number\" },\n\t\t\tbase_branch: { description: \"Optional branch reviewers compare the current code delta against.\", kind: \"string\" },\n\t\t\tgit_worktree_dir: { description: \"Optional Git worktree path.\", kind: \"string\" },\n\t\t\tcreate_pr: { description: \"Whether to run the final pull-request creation stage after approval.\", kind: \"boolean\" },\n\t\t},\n\t},\n\t{\n\t\tname: \"open-claude-design\",\n\t\tdescription: \"AI-powered design workflow: discovery, reference research, HTML generation, refinement, and handoff.\",\n\t\tinputs: {\n\t\t\tprompt: { description: \"What to design, such as a dashboard, page, component, or prototype.\", kind: \"string\" },\n\t\t\tdiscover_references: { description: \"Discover current reference designs and feed them to generation.\", kind: \"boolean\" },\n\t\t\tmax_refinements: { description: \"Maximum generate/user-feedback loop iterations.\", kind: \"number\" },\n\t\t},\n\t},\n\t{\n\t\tname: \"ralph\",\n\t\tdescription: \"Raw prompt → research → orchestrate → multi-model parallel review loop with bounded iteration.\",\n\t\tinputs: {\n\t\t\tprompt: { description: \"The task or goal to research, execute, and refine.\", kind: \"string\" },\n\t\t\tacceptance_criteria: { description: \"Original immutable task contract this run must remain consistent with.\", kind: \"string\" },\n\t\t\tmax_loops: { description: \"Maximum research/orchestrate/review iterations.\", kind: \"number\" },\n\t\t\tbase_branch: { description: \"Branch reviewers compare the current code delta against.\", kind: \"string\" },\n\t\t\tgit_worktree_dir: { description: \"Optional Git worktree path.\", kind: \"string\" },\n\t\t\tcreate_pr: { description: \"Whether to run the final pull-request creation stage.\", kind: \"boolean\" },\n\t\t},\n\t},\n];\n\nfunction completeWorkflowToken(argumentText: string, candidates: AutocompleteItem[]): AutocompleteItem[] | null {\n\tconst tokenStart = /\\s$/.test(argumentText)\n\t\t? argumentText.length\n\t\t: Math.max(argumentText.lastIndexOf(\" \"), argumentText.lastIndexOf(\"\\t\")) + 1;\n\tconst head = argumentText.slice(0, tokenStart);\n\tconst token = argumentText.slice(tokenStart);\n\tconst normalizedToken = token.trimEnd();\n\tconst filtered = candidates\n\t\t.filter((candidate) => candidate.value.startsWith(token) && candidate.value.trimEnd() !== normalizedToken)\n\t\t.map((candidate) => ({ ...candidate, value: `${head}${candidate.value}` }));\n\treturn filtered.length > 0 ? filtered : null;\n}\n\nfunction bundledWorkflowNameItems(): AutocompleteItem[] {\n\treturn BUNDLED_WORKFLOW_COMPLETION_METADATA.map((workflow) => ({\n\t\tvalue: `${workflow.name} `,\n\t\tlabel: workflow.name,\n\t\tdescription: `Run workflow: ${workflow.name}`,\n\t}));\n}\n\nexport function getBundledWorkflowArgumentCompletions(argumentPrefix: string): AutocompleteItem[] | null {\n\tconst parts = argumentPrefix.trim().split(/\\s+/).filter(Boolean);\n\tconst subcommand = parts[0] ?? \"\";\n\tconst workflowItems = bundledWorkflowNameItems();\n\tif (!argumentPrefix.includes(\" \")) {\n\t\treturn completeWorkflowToken(argumentPrefix, [...WORKFLOW_ADMIN_COMPLETIONS, ...workflowItems]);\n\t}\n\tif (subcommand === \"inputs\") return completeWorkflowToken(argumentPrefix, workflowItems);\n\tif (subcommand === \"interrupt\") {\n\t\treturn completeWorkflowToken(argumentPrefix, [\n\t\t\t{ value: \"--all \", label: \"--all\", description: \"Interrupt all in-flight runs\" },\n\t\t\t{ value: \"--yes \", label: \"--yes\", description: \"Skip confirmation\" },\n\t\t\t{ value: \"-y \", label: \"-y\", description: \"Skip confirmation\" },\n\t\t]);\n\t}\n\tif (subcommand === \"quit\") {\n\t\treturn completeWorkflowToken(argumentPrefix, [\n\t\t\t{ value: \"--all \", label: \"--all\", description: \"Quit and keep all in-flight runs resumable\" },\n\t\t]);\n\t}\n\tif (!subcommand) return completeWorkflowToken(argumentPrefix, [...WORKFLOW_ADMIN_COMPLETIONS, ...workflowItems]);\n\n\tconst workflow = BUNDLED_WORKFLOW_COMPLETION_METADATA.find((candidate) => candidate.name === subcommand);\n\tif (!workflow) return null;\n\tconst tokenStart = /\\s$/.test(argumentPrefix)\n\t\t? argumentPrefix.length\n\t\t: Math.max(argumentPrefix.lastIndexOf(\" \"), argumentPrefix.lastIndexOf(\"\\t\")) + 1;\n\tconst token = argumentPrefix.slice(tokenStart);\n\tconst equalsIndex = token.indexOf(\"=\");\n\tif (equalsIndex > 0) {\n\t\tconst inputName = token.slice(0, equalsIndex);\n\t\tconst input = workflow.inputs[inputName];\n\t\tif (input?.kind !== \"boolean\") return null;\n\t\treturn completeWorkflowToken(argumentPrefix, [\n\t\t\t{ value: `${inputName}=true `, label: \"true\", description: inputName },\n\t\t\t{ value: `${inputName}=false `, label: \"false\", description: inputName },\n\t\t]);\n\t}\n\n\treturn completeWorkflowToken(argumentPrefix, [\n\t\t{ value: \"--no-picker \", label: \"--no-picker\", description: \"Skip interactive input picker\" },\n\t\t{ value: \"--help \", label: \"--help\", description: \"Show this workflow's input schema\" },\n\t\t...Object.entries(workflow.inputs).map(([name, input]) => ({\n\t\t\tvalue: `${name}=`,\n\t\t\tlabel: name,\n\t\t\tdescription: input.description,\n\t\t})),\n\t]);\n}\n\nexport const BUILTIN_SLASH_COMMANDS: ReadonlyArray<BuiltinSlashCommand> = [\n\t{ name: \"settings\", description: \"Open settings menu\" },\n\t{ name: \"model\", description: \"Select model (opens selector UI)\" },\n\t{ name: \"scoped-models\", description: \"Enable/disable models for ctrl+p cycling\" },\n\t{ name: \"fast\", description: \"Configure Codex fast mode for chat and workflows\" },\n\t{ name: \"export\", description: \"Export session (HTML default, or specify path: .html/.jsonl)\" },\n\t{ name: \"import\", description: \"Import and resume a session from a JSONL file\" },\n\t{ name: \"share\", description: \"Share session as a secret GitHub gist\" },\n\t{ name: \"copy\", description: \"Copy last agent message to clipboard\" },\n\t{ name: \"name\", description: \"Set session display name\" },\n\t{ name: \"session\", description: \"Show session info and stats\" },\n\t{ name: \"changelog\", description: \"Show changelog entries\" },\n\t{\n\t\tname: ATOMIC_GUIDE_COMMAND_NAME,\n\t\tdescription: ATOMIC_GUIDE_COMMAND_DESCRIPTION,\n\t\tgetArgumentCompletions: getAtomicGuideArgumentCompletions,\n\t},\n\t{ name: \"hotkeys\", description: \"Show all keyboard shortcuts\" },\n\t{ name: \"fork\", description: \"Create a new fork from a previous user message\" },\n\t{ name: \"clone\", description: \"Duplicate the current session at the current position\" },\n\t{ name: \"tree\", description: \"Navigate session tree (switch branches)\" },\n\t{ name: \"trust\", description: \"Save project trust decision for future sessions\" },\n\t{ name: \"login\", description: \"Configure provider authentication\" },\n\t{ name: \"logout\", description: \"Remove provider authentication\" },\n\t{ name: \"new\", description: \"Start a new session\" },\n\t{ name: \"compact\", description: \"Compact older context with verbatim line ranges\" },\n\t{ name: \"resume\", description: \"Resume a different session\" },\n\t{ name: \"reload\", description: \"Reload keybindings, extensions, skills, prompts, and themes\" },\n\t{ name: \"exit\", description: `Exit ${APP_NAME}` },\n\t{ name: \"quit\", description: `Quit ${APP_NAME}` },\n];\n\nexport const BUNDLED_EXTENSION_SLASH_COMMANDS: ReadonlyArray<BuiltinSlashCommand> = [\n\t{\n\t\tname: \"workflow\",\n\t\tdescription: \"Run or inspect Atomic workflows. Usage: /workflow <name> [key=value…] | /workflow [list|status|connect|attach|interrupt|quit|pause|resume|inputs|reload] [args]\",\n\t\tgetArgumentCompletions: getBundledWorkflowArgumentCompletions,\n\t},\n\t{ name: \"run\", description: \"Run a subagent directly: /run agent[output=file] [task] [--bg] [--fork]\" },\n\t{ name: \"chain\", description: \"Run agents in sequence: /chain scout task -> planner [--bg] [--fork]\" },\n\t{ name: \"run-chain\", description: \"Run a saved chain: /run-chain chainName -- task [--bg] [--fork]\" },\n\t{ name: \"parallel\", description: \"Run agents in parallel: /parallel scout task1 -> reviewer task2 [--bg] [--fork]\" },\n\t{ name: \"subagents-doctor\", description: \"Show subagent diagnostics\" },\n\t{ name: \"mcp\", description: \"Show MCP server status\" },\n\t{ name: \"mcp-auth\", description: \"Authenticate with an MCP server (OAuth)\" },\n\t{ name: \"curator\", description: \"Toggle or configure the search curator workflow\" },\n\t{ name: \"google-account\", description: \"Show the active Google account for Gemini Web\" },\n\t{ name: \"search\", description: \"Browse stored web search results\" },\n\t{ name: \"websearch\", description: \"Open web search curator\" },\n\t{ name: \"intercom\", description: \"Open session intercom overlay\" },\n];\n"]}
@@ -1,2 +1,3 @@
1
- export {};
1
+ import type { AuthStatus } from "../../core/auth-storage.ts";
2
+ export declare function formatLogoutStatus(providerName: string, authType: "oauth" | "api_key", authStatus: AuthStatus): string;
2
3
  //# sourceMappingURL=interactive-auth-routing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-auth-routing.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-auth-routing.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"interactive-auth-routing.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-auth-routing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAK7D,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,OAAO,GAAG,SAAS,EAC7B,UAAU,EAAE,UAAU,GACrB,MAAM,CAOR"}
@@ -1,6 +1,14 @@
1
1
  import { InteractiveModeBase } from "./interactive-mode-base.js";
2
2
  import { ExtensionSelectorComponent, OAuthSelectorComponent } from "./interactive-mode-deps.js";
3
3
  import { BEDROCK_PROVIDER_ID, isApiKeyLoginProvider } from "./interactive-mode-helpers.js";
4
+ export function formatLogoutStatus(providerName, authType, authStatus) {
5
+ const action = authType === "oauth"
6
+ ? `Logged out of ${providerName}`
7
+ : `Removed stored API key for ${providerName}`;
8
+ return authStatus.source
9
+ ? `${action}. Authentication remains active through ${authStatus.label ?? authStatus.source}.`
10
+ : action;
11
+ }
4
12
  InteractiveModeBase.prototype.getLoginProviderOptions = function (authType) {
5
13
  const authStorage = this.session.modelRegistry.authStorage;
6
14
  const oauthProviders = authStorage.getOAuthProviders();
@@ -106,13 +114,10 @@ InteractiveModeBase.prototype.showOAuthSelector = async function (mode) {
106
114
  return;
107
115
  }
108
116
  try {
109
- await this.session.modelRegistry.authStorage.logoutAsync(providerOption.id);
110
- await this.session.modelRegistry.refresh();
117
+ const result = await this.runtimeHost.logoutProvider(providerOption.id);
111
118
  await this.updateAvailableProviderCount();
112
119
  this.setupAutocompleteProvider();
113
- const message = providerOption.authType === "oauth"
114
- ? `Logged out of ${providerOption.name}`
115
- : `Removed stored API key for ${providerOption.name}. Environment variables and models.json config are unchanged.`;
120
+ const message = formatLogoutStatus(providerOption.name, providerOption.authType, result.authStatus);
116
121
  this.showStatus(message);
117
122
  }
118
123
  catch (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-auth-routing.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-auth-routing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAA6B,0BAA0B,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAC3H,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAE3F,mBAAmB,CAAC,SAAS,CAAC,uBAAuB,GAAG,UAAoC,QAA8B;IACtH,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC;IAC3D,MAAM,cAAc,GAAG,WAAW,CAAC,iBAAiB,EAAE,CAAC;IACvD,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAC9B,cAAc,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAC9C,CAAC;IACF,MAAM,OAAO,GAA2B,cAAc,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QACxE,EAAE,EAAE,QAAQ,CAAC,EAAE;QACf,IAAI,EAAE,QAAQ,CAAC,UAAU,IAAI,QAAQ,CAAC,IAAI;QAC1C,QAAQ,EAAE,OAAO;KAClB,CAAC,CAAC,CAAC;IAEJ,MAAM,cAAc,GAAG,IAAI,GAAG,CAC5B,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CACnE,CAAC;IACF,KAAK,MAAM,UAAU,IAAI,cAAc,EAAE,CAAC;QACxC,IAAI,CAAC,qBAAqB,CAAC,UAAU,EAAE,gBAAgB,CAAC,EAAE,CAAC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AC;YACJ,CAAC;QACH,CAAC,EACD,GAAG,EAAE;YACH,IAAI,EAAE,CAAC;YACP,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;QAC1B,CAAC,CACF,CAAC;QACF,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type AuthSelectorProvider, ExtensionSelectorComponent, OAuthSelectorComponent } from \"./interactive-mode-deps.ts\";\nimport { BEDROCK_PROVIDER_ID, isApiKeyLoginProvider } from \"./interactive-mode-helpers.ts\";\n\nInteractiveModeBase.prototype.getLoginProviderOptions = function(this: InteractiveModeBase, authType?: \"oauth\" | \"api_key\"): AuthSelectorProvider[] {\n const authStorage = this.session.modelRegistry.authStorage;\n const oauthProviders = authStorage.getOAuthProviders();\n const oauthProviderIds = new Set(\n oauthProviders.map((provider) => provider.id),\n );\n const options: AuthSelectorProvider[] = oauthProviders.map((provider) => ({\n id: provider.id,\n name: provider.loginLabel ?? provider.name,\n authType: \"oauth\",\n }));\n\n const modelProviders = new Set(\n this.session.modelRegistry.getAll().map((model) => model.provider),\n );\n for (const providerId of modelProviders) {\n if (!isApiKeyLoginProvider(providerId, oauthProviderIds)) {\n continue;\n }\n options.push({\n id: providerId,\n name: this.session.modelRegistry.getProviderDisplayName(providerId),\n authType: \"api_key\",\n });\n }\n\n const filteredOptions = authType\n ? options.filter((option) => option.authType === authType)\n : options;\n return filteredOptions.sort((a, b) => a.name.localeCompare(b.name));\n };\n\nInteractiveModeBase.prototype.getLogoutProviderOptions = function(this: InteractiveModeBase): AuthSelectorProvider[] {\n const authStorage = this.session.modelRegistry.authStorage;\n const options: AuthSelectorProvider[] = [];\n\n for (const providerId of authStorage.list()) {\n const credential = authStorage.get(providerId);\n if (!credential) {\n continue;\n }\n options.push({\n id: providerId,\n name: this.session.modelRegistry.getProviderDisplayName(providerId),\n authType: credential.type,\n });\n }\n\n return options.sort((a, b) => a.name.localeCompare(b.name));\n };\n\nInteractiveModeBase.prototype.showLoginAuthTypeSelector = function(this: InteractiveModeBase): void {\n const subscriptionLabel = \"Use a subscription\";\n const apiKeyLabel = \"Use an API key\";\n this.showSelector((done) => {\n const selector = new ExtensionSelectorComponent(\n \"Select authentication method:\",\n [subscriptionLabel, apiKeyLabel],\n (option) => {\n done();\n const authType = option === subscriptionLabel ? \"oauth\" : \"api_key\";\n this.showLoginProviderSelector(authType);\n },\n () => {\n done();\n this.ui.requestRender();\n },\n );\n return { component: selector, focus: selector };\n });\n };\n\nInteractiveModeBase.prototype.showLoginProviderSelector = function(this: InteractiveModeBase, authType: \"oauth\" | \"api_key\"): void {\n const providerOptions = this.getLoginProviderOptions(authType);\n if (providerOptions.length === 0) {\n this.showStatus(\n authType === \"oauth\"\n ? \"No subscription providers available.\"\n : \"No API key providers available.\",\n );\n return;\n }\n\n this.showSelector((done) => {\n const selector = new OAuthSelectorComponent(\n \"login\",\n this.session.modelRegistry.authStorage,\n providerOptions,\n async (providerId: string) => {\n done();\n\n const providerOption = providerOptions.find(\n (provider) => provider.id === providerId,\n );\n if (!providerOption) {\n return;\n }\n\n if (providerOption.authType === \"oauth\") {\n await this.showLoginDialog(providerOption.id, providerOption.name);\n } else if (providerOption.id === BEDROCK_PROVIDER_ID) {\n this.showBedrockSetupDialog(providerOption.id, providerOption.name);\n } else {\n await this.showApiKeyLoginDialog(\n providerOption.id,\n providerOption.name,\n );\n }\n },\n () => {\n done();\n this.showLoginAuthTypeSelector();\n },\n (providerId) =>\n this.session.modelRegistry.getProviderAuthStatus(providerId),\n );\n return { component: selector, focus: selector };\n });\n };\n\nInteractiveModeBase.prototype.showOAuthSelector = async function(this: InteractiveModeBase, mode: \"login\" | \"logout\"): Promise<void> {\n if (mode === \"login\") {\n this.showLoginAuthTypeSelector();\n return;\n }\n\n const providerOptions = this.getLogoutProviderOptions();\n if (providerOptions.length === 0) {\n this.showStatus(\n \"No stored credentials to remove. /logout only removes credentials saved by /login; environment variables and models.json config are unchanged.\",\n );\n return;\n }\n\n this.showSelector((done) => {\n const selector = new OAuthSelectorComponent(\n mode,\n this.session.modelRegistry.authStorage,\n providerOptions,\n async (providerId: string) => {\n done();\n\n const providerOption = providerOptions.find(\n (provider) => provider.id === providerId,\n );\n if (!providerOption) {\n return;\n }\n\n try {\n await this.session.modelRegistry.authStorage.logoutAsync(providerOption.id);\n await this.session.modelRegistry.refresh();\n await this.updateAvailableProviderCount();\n this.setupAutocompleteProvider();\n const message =\n providerOption.authType === \"oauth\"\n ? `Logged out of ${providerOption.name}`\n : `Removed stored API key for ${providerOption.name}. Environment variables and models.json config are unchanged.`;\n this.showStatus(message);\n } catch (error: unknown) {\n this.showError(\n `Logout failed: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n () => {\n done();\n this.ui.requestRender();\n },\n );\n return { component: selector, focus: selector };\n });\n };\n"]}
1
+ {"version":3,"file":"interactive-auth-routing.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-auth-routing.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAA6B,0BAA0B,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAC3H,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAE3F,MAAM,UAAU,kBAAkB,CAChC,YAAoB,EACpB,QAA6B,EAC7B,UAAsB;IAEtB,MAAM,MAAM,GAAG,QAAQ,KAAK,OAAO;QACjC,CAAC,CAAC,iBAAiB,YAAY,EAAE;QACjC,CAAC,CAAC,8BAA8B,YAAY,EAAE,CAAC;IACjD,OAAO,UAAU,CAAC,MAAM;QACtB,CAAC,CAAC,GAAG,MAAM,2CAA2C,UAAU,CAAC,KAAK,IAAI,UAAU,CAAC,MAAM,GAAG;QAC9F,CAAC,CAAC,MAAM,CAAC;A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YAEP,MAAM,cAAc,GAAG,eAAe,CAAC,IAAI,CACzC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,KAAK,UAAU,CACzC,CAAC;YACF,IAAI,CAAC,cAAc,EAAE,CAAC;gBACpB,OAAO;YACT,CAAC;YAED,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;gBACxE,MAAM,IAAI,CAAC,4BAA4B,EAAE,CAAC;gBAC1C,IAAI,CAAC,yBAAyB,EAAE,CAAC;gBACjC,MAAM,OAAO,GAAG,kBAAkB,CAChC,cAAc,CAAC,IAAI,EACnB,cAAc,CAAC,QAAQ,EACvB,MAAM,CAAC,UAAU,CAClB,CAAC;gBACF,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;YAC3B,CAAC;YAAC,OAAO,KAAc,EAAE,CAAC;gBACxB,IAAI,CAAC,SAAS,CACZ,kBAAkB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAC3E,CAAC;YACJ,CAAC;QACH,CAAC,EACD,GAAG,EAAE;YACH,IAAI,EAAE,CAAC;YACP,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;QAC1B,CAAC,CACF,CAAC;QACF,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import type { AuthStatus } from \"../../core/auth-storage.ts\";\nimport { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type AuthSelectorProvider, ExtensionSelectorComponent, OAuthSelectorComponent } from \"./interactive-mode-deps.ts\";\nimport { BEDROCK_PROVIDER_ID, isApiKeyLoginProvider } from \"./interactive-mode-helpers.ts\";\n\nexport function formatLogoutStatus(\n providerName: string,\n authType: \"oauth\" | \"api_key\",\n authStatus: AuthStatus,\n): string {\n const action = authType === \"oauth\"\n ? `Logged out of ${providerName}`\n : `Removed stored API key for ${providerName}`;\n return authStatus.source\n ? `${action}. Authentication remains active through ${authStatus.label ?? authStatus.source}.`\n : action;\n}\n\nInteractiveModeBase.prototype.getLoginProviderOptions = function(this: InteractiveModeBase, authType?: \"oauth\" | \"api_key\"): AuthSelectorProvider[] {\n const authStorage = this.session.modelRegistry.authStorage;\n const oauthProviders = authStorage.getOAuthProviders();\n const oauthProviderIds = new Set(\n oauthProviders.map((provider) => provider.id),\n );\n const options: AuthSelectorProvider[] = oauthProviders.map((provider) => ({\n id: provider.id,\n name: provider.loginLabel ?? provider.name,\n authType: \"oauth\",\n }));\n\n const modelProviders = new Set(\n this.session.modelRegistry.getAll().map((model) => model.provider),\n );\n for (const providerId of modelProviders) {\n if (!isApiKeyLoginProvider(providerId, oauthProviderIds)) {\n continue;\n }\n options.push({\n id: providerId,\n name: this.session.modelRegistry.getProviderDisplayName(providerId),\n authType: \"api_key\",\n });\n }\n\n const filteredOptions = authType\n ? options.filter((option) => option.authType === authType)\n : options;\n return filteredOptions.sort((a, b) => a.name.localeCompare(b.name));\n };\n\nInteractiveModeBase.prototype.getLogoutProviderOptions = function(this: InteractiveModeBase): AuthSelectorProvider[] {\n const authStorage = this.session.modelRegistry.authStorage;\n const options: AuthSelectorProvider[] = [];\n\n for (const providerId of authStorage.list()) {\n const credential = authStorage.get(providerId);\n if (!credential) {\n continue;\n }\n options.push({\n id: providerId,\n name: this.session.modelRegistry.getProviderDisplayName(providerId),\n authType: credential.type,\n });\n }\n\n return options.sort((a, b) => a.name.localeCompare(b.name));\n };\n\nInteractiveModeBase.prototype.showLoginAuthTypeSelector = function(this: InteractiveModeBase): void {\n const subscriptionLabel = \"Use a subscription\";\n const apiKeyLabel = \"Use an API key\";\n this.showSelector((done) => {\n const selector = new ExtensionSelectorComponent(\n \"Select authentication method:\",\n [subscriptionLabel, apiKeyLabel],\n (option) => {\n done();\n const authType = option === subscriptionLabel ? \"oauth\" : \"api_key\";\n this.showLoginProviderSelector(authType);\n },\n () => {\n done();\n this.ui.requestRender();\n },\n );\n return { component: selector, focus: selector };\n });\n };\n\nInteractiveModeBase.prototype.showLoginProviderSelector = function(this: InteractiveModeBase, authType: \"oauth\" | \"api_key\"): void {\n const providerOptions = this.getLoginProviderOptions(authType);\n if (providerOptions.length === 0) {\n this.showStatus(\n authType === \"oauth\"\n ? \"No subscription providers available.\"\n : \"No API key providers available.\",\n );\n return;\n }\n\n this.showSelector((done) => {\n const selector = new OAuthSelectorComponent(\n \"login\",\n this.session.modelRegistry.authStorage,\n providerOptions,\n async (providerId: string) => {\n done();\n\n const providerOption = providerOptions.find(\n (provider) => provider.id === providerId,\n );\n if (!providerOption) {\n return;\n }\n\n if (providerOption.authType === \"oauth\") {\n await this.showLoginDialog(providerOption.id, providerOption.name);\n } else if (providerOption.id === BEDROCK_PROVIDER_ID) {\n this.showBedrockSetupDialog(providerOption.id, providerOption.name);\n } else {\n await this.showApiKeyLoginDialog(\n providerOption.id,\n providerOption.name,\n );\n }\n },\n () => {\n done();\n this.showLoginAuthTypeSelector();\n },\n (providerId) =>\n this.session.modelRegistry.getProviderAuthStatus(providerId),\n );\n return { component: selector, focus: selector };\n });\n };\n\nInteractiveModeBase.prototype.showOAuthSelector = async function(this: InteractiveModeBase, mode: \"login\" | \"logout\"): Promise<void> {\n if (mode === \"login\") {\n this.showLoginAuthTypeSelector();\n return;\n }\n\n const providerOptions = this.getLogoutProviderOptions();\n if (providerOptions.length === 0) {\n this.showStatus(\n \"No stored credentials to remove. /logout only removes credentials saved by /login; environment variables and models.json config are unchanged.\",\n );\n return;\n }\n\n this.showSelector((done) => {\n const selector = new OAuthSelectorComponent(\n mode,\n this.session.modelRegistry.authStorage,\n providerOptions,\n async (providerId: string) => {\n done();\n\n const providerOption = providerOptions.find(\n (provider) => provider.id === providerId,\n );\n if (!providerOption) {\n return;\n }\n\n try {\n const result = await this.runtimeHost.logoutProvider(providerOption.id);\n await this.updateAvailableProviderCount();\n this.setupAutocompleteProvider();\n const message = formatLogoutStatus(\n providerOption.name,\n providerOption.authType,\n result.authStatus,\n );\n this.showStatus(message);\n } catch (error: unknown) {\n this.showError(\n `Logout failed: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n () => {\n done();\n this.ui.requestRender();\n },\n );\n return { component: selector, focus: selector };\n });\n };\n"]}
@@ -1,7 +1,7 @@
1
1
  import { InteractiveModeBase } from "./interactive-mode-base.js";
2
2
  import { CombinedAutocompleteProvider, fuzzyFilter, hasSupportedCodexFastModeModel, BUILTIN_SLASH_COMMANDS, BUNDLED_EXTENSION_SLASH_COMMANDS, parseGitUrl, getModelSearchText } from "./interactive-mode-deps.js";
3
3
  import { BUILTIN_SLASH_COMMAND_NAMES } from "./interactive-mode-helpers.js";
4
- import { getInteractiveEngineRemoteCommands } from "../interactive-engine/extension-ui-bridge.js";
4
+ import { getInteractiveEngineRemoteCommandCompletions, getInteractiveEngineRemoteCommands } from "../interactive-engine/extension-ui-bridge.js";
5
5
  const AT_MENTION_PATH_DELIMITERS = new Set([" ", "\t", '"', "'", "="]);
6
6
  function findLastAtMentionDelimiter(text) {
7
7
  for (let index = text.length - 1; index >= 0; index -= 1) {
@@ -154,7 +154,17 @@ InteractiveModeBase.prototype.buildRemoteSlashCommands = function (localCommands
154
154
  if (takenNames.has(command.name))
155
155
  continue;
156
156
  takenNames.add(command.name);
157
- const getArgumentCompletions = bundledArgumentCompletions.get(command.name);
157
+ const bundledCompletions = bundledArgumentCompletions.get(command.name);
158
+ const getArgumentCompletions = command.hasArgumentCompletions
159
+ ? async (prefix) => {
160
+ try {
161
+ return await getInteractiveEngineRemoteCommandCompletions(this.runtimeHost, command.name, prefix);
162
+ }
163
+ catch {
164
+ return (await bundledCompletions?.(prefix)) ?? null;
165
+ }
166
+ }
167
+ : bundledCompletions;
158
168
  remoteCommands.push({
159
169
  name: command.name,
160
170
  description: this.prefixAutocompleteDescription(command.description, command.sourceInfo),
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-autocomplete.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-autocomplete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAA2L,4BAA4B,EAAE,WAAW,EAAE,8BAA8B,EAAE,sBAAsB,EAAE,gCAAgC,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAC3Y,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,kCAAkC,EAAE,MAAM,8CAA8C,CAAC;AAElG,MAAM,0BAA0B,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAEvE,SAAS,0BAA0B,CAAC,IAAY;IAC9C,KAAK,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACzD,IAAI,0BAA0B,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;YAAE,OAAO,KAAK,CAAC;IACtE,CAAC;IACD,OAAO,CAAC,CAAC,CAAC;AACZ,CAAC;AAED,SAAS,qBAAqB,CAAC,IAAY,EAAE,KAAa;IACxD,OAAO,KAAK,KAAK,CAAC,IAAI,0BAA0B,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,+BAA+B,CAAC,IAAY;IACnD,IAAI,UAAU,GAAG,CAAC,CAAC,CAAC;IACpB,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,C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C3E,6EAA6E;IAC7E,0EAA0E;IAC1E,4EAA4E;IAC5E,yEAAyE;IACzE,yEAAyE;IACzE,qBAAqB;IACrB,MAAM,iBAAiB,GAAG,IAAI,CAAC,wBAAwB,CAAC;QACtD,GAAG,aAAa;QAChB,GAAG,gBAAgB;QACnB,GAAG,iBAAiB;QACpB,GAAG,gBAAgB;KACpB,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG;QACf,GAAG,aAAa;QAChB,GAAG,gBAAgB;QACnB,GAAG,iBAAiB;QACpB,GAAG,gBAAgB;QACnB,GAAG,iBAAiB;KACrB,CAAC;IACF,MAAM,GAAG,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC;IACzC,OAAO,IAAI,qCAAqC,CAC9C,IAAI,4BAA4B,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,EAC5D,IAAI,4BAA4B,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,CAAC,CACtD,CAAC;AACJ,CAAC,CAAC;AAEJ,mBAAmB,CAAC,SAAS,CAAC,yBAAyB,GAAG;IACtD,IAAI,QAAQ,GAAG,IAAI,CAAC,8BAA8B,EAAE,CAAC;IACrD,KAAK,MAAM,YAAY,IAAI,IAAI,CAAC,4BAA4B,EAAE,CAAC;QAC7D,QAAQ,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;IAED,IAAI,CAAC,oBAAoB,GAAG,QAAQ,CAAC;IACrC,IAAI,CAAC,aAAa,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAC;IACrD,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,aAAa,EAAE,CAAC;QACvC,IAAI,CAAC,MAAM,CAAC,uBAAuB,EAAE,CAAC,QAAQ,CAAC,CAAC;IAClD,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type Api, type Model, type AutocompleteItem, type AutocompleteProvider, type AutocompleteSuggestions, type SlashCommand, type ExtensionRunner, type ResourceDiagnostic, type SourceInfo, CombinedAutocompleteProvider, fuzzyFilter, hasSupportedCodexFastModeModel, BUILTIN_SLASH_COMMANDS, BUNDLED_EXTENSION_SLASH_COMMANDS, parseGitUrl, getModelSearchText } from \"./interactive-mode-deps.ts\";\nimport { BUILTIN_SLASH_COMMAND_NAMES } from \"./interactive-mode-helpers.ts\";\nimport { getInteractiveEngineRemoteCommands } from \"../interactive-engine/extension-ui-bridge.ts\";\n\nconst AT_MENTION_PATH_DELIMITERS = new Set([\" \", \"\\t\", '\"', \"'\", \"=\"]);\n\nfunction findLastAtMentionDelimiter(text: string): number {\n for (let index = text.length - 1; index >= 0; index -= 1) {\n if (AT_MENTION_PATH_DELIMITERS.has(text[index] ?? \"\")) return index;\n }\n return -1;\n}\n\nfunction isAtMentionTokenStart(text: string, index: number): boolean {\n return index === 0 || AT_MENTION_PATH_DELIMITERS.has(text[index - 1] ?? \"\");\n}\n\nfunction findUnclosedAtMentionQuoteStart(text: string): number | null {\n let quoteStart = -1;\n let inQuotes = false;\n for (let index = 0; index < text.length; index += 1) {\n if (text[index] === '\"') {\n inQuotes = !inQuotes;\n if (inQuotes) quoteStart = index;\n }\n }\n return inQuotes ? quoteStart : null;\n}\n\nfunction extractAtMentionPrefix(textBeforeCursor: string): string | null {\n const quoteStart = findUnclosedAtMentionQuoteStart(textBeforeCursor);\n if (quoteStart !== null && quoteStart > 0 && textBeforeCursor[quoteStart - 1] === \"@\") {\n return isAtMentionTokenStart(textBeforeCursor, quoteStart - 1)\n ? textBeforeCursor.slice(quoteStart - 1)\n : null;\n }\n const lastDelimiterIndex = findLastAtMentionDelimiter(textBeforeCursor);\n const tokenStart = lastDelimiterIndex === -1 ? 0 : lastDelimiterIndex + 1;\n return textBeforeCursor[tokenStart] === \"@\" ? textBeforeCursor.slice(tokenStart) : null;\n}\n\nfunction atMentionPrefixToPathPrefix(atPrefix: string): string {\n return atPrefix.startsWith('@\"') ? `\"${atPrefix.slice(2)}` : atPrefix.slice(1);\n}\n\nfunction toAtMentionCompletion(item: AutocompleteItem): AutocompleteItem {\n return {\n ...item,\n value: item.value.startsWith(\"@\") ? item.value : `@${item.value}`,\n };\n}\n\nclass AtMentionFallbackAutocompleteProvider implements AutocompleteProvider {\n private readonly primary: AutocompleteProvider;\n private readonly pathFallback: AutocompleteProvider;\n\n constructor(primary: AutocompleteProvider, pathFallback: AutocompleteProvider) {\n this.primary = primary;\n this.pathFallback = pathFallback;\n }\n\n async getSuggestions(\n lines: string[],\n cursorLine: number,\n cursorCol: number,\n options: { signal: AbortSignal; force?: boolean },\n ): Promise<AutocompleteSuggestions | null> {\n const primarySuggestions = await this.primary.getSuggestions(lines, cursorLine, cursorCol, options);\n if (primarySuggestions || options.signal.aborted) return primarySuggestions;\n\n const currentLine = lines[cursorLine] ?? \"\";\n const textBeforeCursor = currentLine.slice(0, cursorCol);\n const atPrefix = extractAtMentionPrefix(textBeforeCursor);\n if (!atPrefix) return null;\n\n const pathPrefix = atMentionPrefixToPathPrefix(atPrefix);\n const prefixStart = cursorCol - atPrefix.length;\n const fallbackLines = [...lines];\n fallbackLines[cursorLine] = `${currentLine.slice(0, prefixStart)}${pathPrefix}${currentLine.slice(cursorCol)}`;\n const fallbackSuggestions = await this.pathFallback.getSuggestions(\n fallbackLines,\n cursorLine,\n prefixStart + pathPrefix.length,\n { ...options, force: true },\n );\n if (!fallbackSuggestions) return null;\n\n return {\n prefix: atPrefix,\n items: fallbackSuggestions.items.map(toAtMentionCompletion),\n };\n }\n\n applyCompletion(\n lines: string[],\n cursorLine: number,\n cursorCol: number,\n item: AutocompleteItem,\n prefix: string,\n ): { lines: string[]; cursorLine: number; cursorCol: number } {\n return this.primary.applyCompletion(lines, cursorLine, cursorCol, item, prefix);\n }\n\n shouldTriggerFileCompletion(lines: string[], cursorLine: number, cursorCol: number): boolean {\n return this.primary.shouldTriggerFileCompletion?.(lines, cursorLine, cursorCol) ?? true;\n }\n}\n\nInteractiveModeBase.prototype.getAutocompleteSourceTag = function(this: InteractiveModeBase, sourceInfo?: SourceInfo): string | undefined {\n if (!sourceInfo) {\n return undefined;\n }\n\n const scopePrefix =\n sourceInfo.scope === \"user\"\n ? \"u\"\n : sourceInfo.scope === \"project\"\n ? \"p\"\n : \"t\";\n const source = sourceInfo.source.trim();\n\n if (source === \"auto\" || source === \"local\" || source === \"cli\") {\n return scopePrefix;\n }\n\n if (source.startsWith(\"npm:\")) {\n return `${scopePrefix}:${source}`;\n }\n\n const gitSource = parseGitUrl(source);\n if (gitSource) {\n const ref = gitSource.ref ? `@${gitSource.ref}` : \"\";\n return `${scopePrefix}:git:${gitSource.host}/${gitSource.path}${ref}`;\n }\n\n return scopePrefix;\n };\n\nInteractiveModeBase.prototype.prefixAutocompleteDescription = function(this: InteractiveModeBase, description: string | undefined, sourceInfo?: SourceInfo): string | undefined {\n const sourceTag = this.getAutocompleteSourceTag(sourceInfo);\n if (!sourceTag) {\n return description;\n }\n return description ? `[${sourceTag}] ${description}` : `[${sourceTag}]`;\n };\n\nInteractiveModeBase.prototype.getBuiltInCommandConflictDiagnostics = function(this: InteractiveModeBase, extensionRunner: ExtensionRunner): ResourceDiagnostic[] {\n return extensionRunner\n .getRegisteredCommands()\n .filter((command) => BUILTIN_SLASH_COMMAND_NAMES.has(command.name))\n .map((command) => ({\n type: \"warning\" as const,\n message:\n command.invocationName === command.name\n ? `Extension command '/${command.name}' conflicts with built-in interactive command. Skipping in autocomplete.`\n : `Extension command '/${command.name}' conflicts with built-in interactive command. Available as '/${command.invocationName}'.`,\n path: command.sourceInfo.path,\n }));\n };\n\nInteractiveModeBase.prototype.getCodexFastModeCandidateModels = function(this: InteractiveModeBase): Model<Api>[] {\n if (this.session.scopedModels.length > 0) {\n return this.session.scopedModels\n .map((scoped) => scoped.model)\n .filter((model) => this.session.modelRegistry.hasConfiguredAuth(model));\n }\n\n return this.session.modelRegistry.getAvailable();\n };\n\nInteractiveModeBase.prototype.hasCodexFastModeSupportedModels = function(this: InteractiveModeBase): boolean {\n return hasSupportedCodexFastModeModel(\n this.getCodexFastModeCandidateModels(),\n );\n };\n\nInteractiveModeBase.prototype.buildRemoteSlashCommands = function(this: InteractiveModeBase, localCommands: SlashCommand[]): SlashCommand[] {\n const remote = getInteractiveEngineRemoteCommands(this.runtimeHost);\n if (remote.length === 0) return [];\n\n // Names already present locally (built-ins, prompt templates, skills) win, so\n // the child catalog only contributes commands the host is genuinely missing.\n const takenNames = new Set<string>(localCommands.map((command) => command.name));\n const skillCommandsEnabled = this.settingsManager.getEnableSkillCommands();\n // Reuse bundled argument-completion providers (e.g. /workflow subcommands and\n // input schemas) for their matching child commands; RPC cannot serialize the\n // completion callbacks themselves.\n const bundledArgumentCompletions = new Map(\n BUNDLED_EXTENSION_SLASH_COMMANDS.map((command) => [command.name, command.getArgumentCompletions] as const),\n );\n\n const remoteCommands: SlashCommand[] = [];\n for (const command of remote) {\n // Built-in interactive command names stay reserved regardless of source.\n if (BUILTIN_SLASH_COMMAND_NAMES.has(command.name)) continue;\n // Honor the skill-commands setting for child-provided skills too.\n if (command.source === \"skill\" && !skillCommandsEnabled) continue;\n if (takenNames.has(command.name)) continue;\n takenNames.add(command.name);\n const getArgumentCompletions = bundledArgumentCompletions.get(command.name);\n remoteCommands.push({\n name: command.name,\n description: this.prefixAutocompleteDescription(command.description, command.sourceInfo),\n ...(getArgumentCompletions ? { getArgumentCompletions } : {}),\n });\n }\n return remoteCommands;\n };\n\nInteractiveModeBase.prototype.createBaseAutocompleteProvider = function(this: InteractiveModeBase): AutocompleteProvider {\n // Define commands for autocomplete\n const slashCommands: SlashCommand[] = BUILTIN_SLASH_COMMANDS.filter(\n (command) => command.name !== \"fast\" || this.hasCodexFastModeSupportedModels(),\n ).map((command) => ({\n name: command.name,\n description: command.description,\n getArgumentCompletions: command.getArgumentCompletions,\n }));\n\n const modelCommand = slashCommands.find(\n (command) => command.name === \"model\",\n );\n if (modelCommand) {\n modelCommand.getArgumentCompletions = (\n prefix: string,\n ): AutocompleteItem[] | null => {\n // Get available models (scoped or from registry)\n const models =\n this.session.scopedModels.length > 0\n ? this.session.scopedModels.map((s) => s.model)\n : this.session.modelRegistry.getAvailable();\n\n if (models.length === 0) return null;\n\n // Create items with provider/id format\n const items = models.map((m) => ({\n id: m.id,\n provider: m.provider,\n name: m.name,\n label: `${m.provider}/${m.id}`,\n }));\n\n // Fuzzy filter by model ID + provider in either order.\n const filtered = fuzzyFilter(items, prefix, getModelSearchText);\n\n if (filtered.length === 0) return null;\n\n return filtered.map((item) => ({\n value: item.label,\n label: item.id,\n description: item.provider,\n }));\n };\n }\n\n // Convert prompt templates to SlashCommand format for autocomplete\n const templateCommands: SlashCommand[] = this.session.promptTemplates.map(\n (cmd) => ({\n name: cmd.name,\n description: this.prefixAutocompleteDescription(\n cmd.description,\n cmd.sourceInfo,\n ),\n ...(cmd.argumentHint && { argumentHint: cmd.argumentHint }),\n }),\n );\n\n // Convert extension commands to SlashCommand format. Built-in command names\n // stay reserved even when a built-in is contextually hidden (for example,\n // /fast without a supported OpenAI model) so extension visibility cannot\n // change as auth/model state changes. While extension loading is deferred,\n // expose lightweight bundled command metadata without importing heavy\n // implementations; the submit path loads the implementation on demand.\n const registeredExtensionCommands = this.session.extensionRunner\n .getRegisteredCommands()\n .filter((cmd) => !BUILTIN_SLASH_COMMAND_NAMES.has(cmd.name));\n const registeredNames = new Set(registeredExtensionCommands.map((cmd) => cmd.invocationName));\n const extensionCommands: SlashCommand[] = [\n ...(this.deferredStartupPending\n ? BUNDLED_EXTENSION_SLASH_COMMANDS.filter(\n (cmd) => !BUILTIN_SLASH_COMMAND_NAMES.has(cmd.name) && !registeredNames.has(cmd.name),\n ).map((cmd) => ({\n name: cmd.name,\n description: cmd.description,\n getArgumentCompletions: cmd.getArgumentCompletions,\n }))\n : []),\n ...registeredExtensionCommands.map((cmd) => ({\n name: cmd.invocationName,\n description: this.prefixAutocompleteDescription(\n cmd.description,\n cmd.sourceInfo,\n ),\n getArgumentCompletions: cmd.getArgumentCompletions,\n })),\n ];\n\n // Build skill commands from session.skills (if enabled)\n this.skillCommands.clear();\n const skillCommandList: SlashCommand[] = [];\n if (this.settingsManager.getEnableSkillCommands()) {\n for (const skill of this.session.resourceLoader.getSkills().skills) {\n const commandName = `skill:${skill.name}`;\n this.skillCommands.set(commandName, skill.filePath);\n skillCommandList.push({\n name: commandName,\n description: this.prefixAutocompleteDescription(\n skill.description,\n skill.sourceInfo,\n ),\n });\n }\n }\n\n // In the isolated interactive host (isolateInteractiveHost) the host session\n // loads no extensions, so extension slash commands (/workflow, /workflows,\n // /run, /mcp, …) exist only in the engine child. Merge the child's command\n // catalog — fetched asynchronously after engine bind — so autocomplete lists\n // them. Built-in names stay reserved and anything already present locally\n // (built-ins, prompt templates, skills the host also loaded) is deduped, so\n // only genuinely engine-only commands are added. Execution keeps routing\n // through the child via the patched session.prompt(); nothing is handled\n // twice on the host.\n const remoteCommandList = this.buildRemoteSlashCommands([\n ...slashCommands,\n ...templateCommands,\n ...extensionCommands,\n ...skillCommandList,\n ]);\n\n const commands = [\n ...slashCommands,\n ...templateCommands,\n ...extensionCommands,\n ...skillCommandList,\n ...remoteCommandList,\n ];\n const cwd = this.sessionManager.getCwd();\n return new AtMentionFallbackAutocompleteProvider(\n new CombinedAutocompleteProvider(commands, cwd, this.fdPath),\n new CombinedAutocompleteProvider(commands, cwd, null),\n );\n };\n\nInteractiveModeBase.prototype.setupAutocompleteProvider = function(this: InteractiveModeBase): void {\n let provider = this.createBaseAutocompleteProvider();\n for (const wrapProvider of this.autocompleteProviderWrappers) {\n provider = wrapProvider(provider);\n }\n\n this.autocompleteProvider = provider;\n this.defaultEditor.setAutocompleteProvider(provider);\n if (this.editor !== this.defaultEditor) {\n this.editor.setAutocompleteProvider?.(provider);\n }\n };\n"]}
1
+ {"version":3,"file":"interactive-autocomplete.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-autocomplete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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,CAAC,MAAM,KAAK,IAAI,CAAC,aAAa,EAAE,CAAC;QACvC,IAAI,CAAC,MAAM,CAAC,uBAAuB,EAAE,CAAC,QAAQ,CAAC,CAAC;IAClD,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type Api, type Model, type AutocompleteItem, type AutocompleteProvider, type AutocompleteSuggestions, type SlashCommand, type ExtensionRunner, type ResourceDiagnostic, type SourceInfo, CombinedAutocompleteProvider, fuzzyFilter, hasSupportedCodexFastModeModel, BUILTIN_SLASH_COMMANDS, BUNDLED_EXTENSION_SLASH_COMMANDS, parseGitUrl, getModelSearchText } from \"./interactive-mode-deps.ts\";\nimport { BUILTIN_SLASH_COMMAND_NAMES } from \"./interactive-mode-helpers.ts\";\nimport { getInteractiveEngineRemoteCommandCompletions, getInteractiveEngineRemoteCommands } from \"../interactive-engine/extension-ui-bridge.ts\";\n\nconst AT_MENTION_PATH_DELIMITERS = new Set([\" \", \"\\t\", '\"', \"'\", \"=\"]);\n\nfunction findLastAtMentionDelimiter(text: string): number {\n for (let index = text.length - 1; index >= 0; index -= 1) {\n if (AT_MENTION_PATH_DELIMITERS.has(text[index] ?? \"\")) return index;\n }\n return -1;\n}\n\nfunction isAtMentionTokenStart(text: string, index: number): boolean {\n return index === 0 || AT_MENTION_PATH_DELIMITERS.has(text[index - 1] ?? \"\");\n}\n\nfunction findUnclosedAtMentionQuoteStart(text: string): number | null {\n let quoteStart = -1;\n let inQuotes = false;\n for (let index = 0; index < text.length; index += 1) {\n if (text[index] === '\"') {\n inQuotes = !inQuotes;\n if (inQuotes) quoteStart = index;\n }\n }\n return inQuotes ? quoteStart : null;\n}\n\nfunction extractAtMentionPrefix(textBeforeCursor: string): string | null {\n const quoteStart = findUnclosedAtMentionQuoteStart(textBeforeCursor);\n if (quoteStart !== null && quoteStart > 0 && textBeforeCursor[quoteStart - 1] === \"@\") {\n return isAtMentionTokenStart(textBeforeCursor, quoteStart - 1)\n ? textBeforeCursor.slice(quoteStart - 1)\n : null;\n }\n const lastDelimiterIndex = findLastAtMentionDelimiter(textBeforeCursor);\n const tokenStart = lastDelimiterIndex === -1 ? 0 : lastDelimiterIndex + 1;\n return textBeforeCursor[tokenStart] === \"@\" ? textBeforeCursor.slice(tokenStart) : null;\n}\n\nfunction atMentionPrefixToPathPrefix(atPrefix: string): string {\n return atPrefix.startsWith('@\"') ? `\"${atPrefix.slice(2)}` : atPrefix.slice(1);\n}\n\nfunction toAtMentionCompletion(item: AutocompleteItem): AutocompleteItem {\n return {\n ...item,\n value: item.value.startsWith(\"@\") ? item.value : `@${item.value}`,\n };\n}\n\nclass AtMentionFallbackAutocompleteProvider implements AutocompleteProvider {\n private readonly primary: AutocompleteProvider;\n private readonly pathFallback: AutocompleteProvider;\n\n constructor(primary: AutocompleteProvider, pathFallback: AutocompleteProvider) {\n this.primary = primary;\n this.pathFallback = pathFallback;\n }\n\n async getSuggestions(\n lines: string[],\n cursorLine: number,\n cursorCol: number,\n options: { signal: AbortSignal; force?: boolean },\n ): Promise<AutocompleteSuggestions | null> {\n const primarySuggestions = await this.primary.getSuggestions(lines, cursorLine, cursorCol, options);\n if (primarySuggestions || options.signal.aborted) return primarySuggestions;\n\n const currentLine = lines[cursorLine] ?? \"\";\n const textBeforeCursor = currentLine.slice(0, cursorCol);\n const atPrefix = extractAtMentionPrefix(textBeforeCursor);\n if (!atPrefix) return null;\n\n const pathPrefix = atMentionPrefixToPathPrefix(atPrefix);\n const prefixStart = cursorCol - atPrefix.length;\n const fallbackLines = [...lines];\n fallbackLines[cursorLine] = `${currentLine.slice(0, prefixStart)}${pathPrefix}${currentLine.slice(cursorCol)}`;\n const fallbackSuggestions = await this.pathFallback.getSuggestions(\n fallbackLines,\n cursorLine,\n prefixStart + pathPrefix.length,\n { ...options, force: true },\n );\n if (!fallbackSuggestions) return null;\n\n return {\n prefix: atPrefix,\n items: fallbackSuggestions.items.map(toAtMentionCompletion),\n };\n }\n\n applyCompletion(\n lines: string[],\n cursorLine: number,\n cursorCol: number,\n item: AutocompleteItem,\n prefix: string,\n ): { lines: string[]; cursorLine: number; cursorCol: number } {\n return this.primary.applyCompletion(lines, cursorLine, cursorCol, item, prefix);\n }\n\n shouldTriggerFileCompletion(lines: string[], cursorLine: number, cursorCol: number): boolean {\n return this.primary.shouldTriggerFileCompletion?.(lines, cursorLine, cursorCol) ?? true;\n }\n}\n\nInteractiveModeBase.prototype.getAutocompleteSourceTag = function(this: InteractiveModeBase, sourceInfo?: SourceInfo): string | undefined {\n if (!sourceInfo) {\n return undefined;\n }\n\n const scopePrefix =\n sourceInfo.scope === \"user\"\n ? \"u\"\n : sourceInfo.scope === \"project\"\n ? \"p\"\n : \"t\";\n const source = sourceInfo.source.trim();\n\n if (source === \"auto\" || source === \"local\" || source === \"cli\") {\n return scopePrefix;\n }\n\n if (source.startsWith(\"npm:\")) {\n return `${scopePrefix}:${source}`;\n }\n\n const gitSource = parseGitUrl(source);\n if (gitSource) {\n const ref = gitSource.ref ? `@${gitSource.ref}` : \"\";\n return `${scopePrefix}:git:${gitSource.host}/${gitSource.path}${ref}`;\n }\n\n return scopePrefix;\n };\n\nInteractiveModeBase.prototype.prefixAutocompleteDescription = function(this: InteractiveModeBase, description: string | undefined, sourceInfo?: SourceInfo): string | undefined {\n const sourceTag = this.getAutocompleteSourceTag(sourceInfo);\n if (!sourceTag) {\n return description;\n }\n return description ? `[${sourceTag}] ${description}` : `[${sourceTag}]`;\n };\n\nInteractiveModeBase.prototype.getBuiltInCommandConflictDiagnostics = function(this: InteractiveModeBase, extensionRunner: ExtensionRunner): ResourceDiagnostic[] {\n return extensionRunner\n .getRegisteredCommands()\n .filter((command) => BUILTIN_SLASH_COMMAND_NAMES.has(command.name))\n .map((command) => ({\n type: \"warning\" as const,\n message:\n command.invocationName === command.name\n ? `Extension command '/${command.name}' conflicts with built-in interactive command. Skipping in autocomplete.`\n : `Extension command '/${command.name}' conflicts with built-in interactive command. Available as '/${command.invocationName}'.`,\n path: command.sourceInfo.path,\n }));\n };\n\nInteractiveModeBase.prototype.getCodexFastModeCandidateModels = function(this: InteractiveModeBase): Model<Api>[] {\n if (this.session.scopedModels.length > 0) {\n return this.session.scopedModels\n .map((scoped) => scoped.model)\n .filter((model) => this.session.modelRegistry.hasConfiguredAuth(model));\n }\n\n return this.session.modelRegistry.getAvailable();\n };\n\nInteractiveModeBase.prototype.hasCodexFastModeSupportedModels = function(this: InteractiveModeBase): boolean {\n return hasSupportedCodexFastModeModel(\n this.getCodexFastModeCandidateModels(),\n );\n };\n\nInteractiveModeBase.prototype.buildRemoteSlashCommands = function(this: InteractiveModeBase, localCommands: SlashCommand[]): SlashCommand[] {\n const remote = getInteractiveEngineRemoteCommands(this.runtimeHost);\n if (remote.length === 0) return [];\n\n // Names already present locally (built-ins, prompt templates, skills) win, so\n // the child catalog only contributes commands the host is genuinely missing.\n const takenNames = new Set<string>(localCommands.map((command) => command.name));\n const skillCommandsEnabled = this.settingsManager.getEnableSkillCommands();\n // Reuse bundled argument-completion providers (e.g. /workflow subcommands and\n // input schemas) for their matching child commands; RPC cannot serialize the\n // completion callbacks themselves.\n const bundledArgumentCompletions = new Map(\n BUNDLED_EXTENSION_SLASH_COMMANDS.map((command) => [command.name, command.getArgumentCompletions] as const),\n );\n\n const remoteCommands: SlashCommand[] = [];\n for (const command of remote) {\n // Built-in interactive command names stay reserved regardless of source.\n if (BUILTIN_SLASH_COMMAND_NAMES.has(command.name)) continue;\n // Honor the skill-commands setting for child-provided skills too.\n if (command.source === \"skill\" && !skillCommandsEnabled) continue;\n if (takenNames.has(command.name)) continue;\n takenNames.add(command.name);\n const bundledCompletions = bundledArgumentCompletions.get(command.name);\n const getArgumentCompletions = command.hasArgumentCompletions\n ? async (prefix: string): Promise<AutocompleteItem[] | null> => {\n try {\n return await getInteractiveEngineRemoteCommandCompletions(this.runtimeHost, command.name, prefix);\n } catch {\n return (await bundledCompletions?.(prefix)) ?? null;\n }\n }\n : bundledCompletions;\n remoteCommands.push({\n name: command.name,\n description: this.prefixAutocompleteDescription(command.description, command.sourceInfo),\n ...(getArgumentCompletions ? { getArgumentCompletions } : {}),\n });\n }\n return remoteCommands;\n };\n\nInteractiveModeBase.prototype.createBaseAutocompleteProvider = function(this: InteractiveModeBase): AutocompleteProvider {\n // Define commands for autocomplete\n const slashCommands: SlashCommand[] = BUILTIN_SLASH_COMMANDS.filter(\n (command) => command.name !== \"fast\" || this.hasCodexFastModeSupportedModels(),\n ).map((command) => ({\n name: command.name,\n description: command.description,\n getArgumentCompletions: command.getArgumentCompletions,\n }));\n\n const modelCommand = slashCommands.find(\n (command) => command.name === \"model\",\n );\n if (modelCommand) {\n modelCommand.getArgumentCompletions = (\n prefix: string,\n ): AutocompleteItem[] | null => {\n // Get available models (scoped or from registry)\n const models =\n this.session.scopedModels.length > 0\n ? this.session.scopedModels.map((s) => s.model)\n : this.session.modelRegistry.getAvailable();\n\n if (models.length === 0) return null;\n\n // Create items with provider/id format\n const items = models.map((m) => ({\n id: m.id,\n provider: m.provider,\n name: m.name,\n label: `${m.provider}/${m.id}`,\n }));\n\n // Fuzzy filter by model ID + provider in either order.\n const filtered = fuzzyFilter(items, prefix, getModelSearchText);\n\n if (filtered.length === 0) return null;\n\n return filtered.map((item) => ({\n value: item.label,\n label: item.id,\n description: item.provider,\n }));\n };\n }\n\n // Convert prompt templates to SlashCommand format for autocomplete\n const templateCommands: SlashCommand[] = this.session.promptTemplates.map(\n (cmd) => ({\n name: cmd.name,\n description: this.prefixAutocompleteDescription(\n cmd.description,\n cmd.sourceInfo,\n ),\n ...(cmd.argumentHint && { argumentHint: cmd.argumentHint }),\n }),\n );\n\n // Convert extension commands to SlashCommand format. Built-in command names\n // stay reserved even when a built-in is contextually hidden (for example,\n // /fast without a supported OpenAI model) so extension visibility cannot\n // change as auth/model state changes. While extension loading is deferred,\n // expose lightweight bundled command metadata without importing heavy\n // implementations; the submit path loads the implementation on demand.\n const registeredExtensionCommands = this.session.extensionRunner\n .getRegisteredCommands()\n .filter((cmd) => !BUILTIN_SLASH_COMMAND_NAMES.has(cmd.name));\n const registeredNames = new Set(registeredExtensionCommands.map((cmd) => cmd.invocationName));\n const extensionCommands: SlashCommand[] = [\n ...(this.deferredStartupPending\n ? BUNDLED_EXTENSION_SLASH_COMMANDS.filter(\n (cmd) => !BUILTIN_SLASH_COMMAND_NAMES.has(cmd.name) && !registeredNames.has(cmd.name),\n ).map((cmd) => ({\n name: cmd.name,\n description: cmd.description,\n getArgumentCompletions: cmd.getArgumentCompletions,\n }))\n : []),\n ...registeredExtensionCommands.map((cmd) => ({\n name: cmd.invocationName,\n description: this.prefixAutocompleteDescription(\n cmd.description,\n cmd.sourceInfo,\n ),\n getArgumentCompletions: cmd.getArgumentCompletions,\n })),\n ];\n\n // Build skill commands from session.skills (if enabled)\n this.skillCommands.clear();\n const skillCommandList: SlashCommand[] = [];\n if (this.settingsManager.getEnableSkillCommands()) {\n for (const skill of this.session.resourceLoader.getSkills().skills) {\n const commandName = `skill:${skill.name}`;\n this.skillCommands.set(commandName, skill.filePath);\n skillCommandList.push({\n name: commandName,\n description: this.prefixAutocompleteDescription(\n skill.description,\n skill.sourceInfo,\n ),\n });\n }\n }\n\n // In the isolated interactive host (isolateInteractiveHost) the host session\n // loads no extensions, so extension slash commands (/workflow, /workflows,\n // /run, /mcp, …) exist only in the engine child. Merge the child's command\n // catalog — fetched asynchronously after engine bind — so autocomplete lists\n // them. Built-in names stay reserved and anything already present locally\n // (built-ins, prompt templates, skills the host also loaded) is deduped, so\n // only genuinely engine-only commands are added. Execution keeps routing\n // through the child via the patched session.prompt(); nothing is handled\n // twice on the host.\n const remoteCommandList = this.buildRemoteSlashCommands([\n ...slashCommands,\n ...templateCommands,\n ...extensionCommands,\n ...skillCommandList,\n ]);\n\n const commands = [\n ...slashCommands,\n ...templateCommands,\n ...extensionCommands,\n ...skillCommandList,\n ...remoteCommandList,\n ];\n const cwd = this.sessionManager.getCwd();\n return new AtMentionFallbackAutocompleteProvider(\n new CombinedAutocompleteProvider(commands, cwd, this.fdPath),\n new CombinedAutocompleteProvider(commands, cwd, null),\n );\n };\n\nInteractiveModeBase.prototype.setupAutocompleteProvider = function(this: InteractiveModeBase): void {\n let provider = this.createBaseAutocompleteProvider();\n for (const wrapProvider of this.autocompleteProviderWrappers) {\n provider = wrapProvider(provider);\n }\n\n this.autocompleteProvider = provider;\n this.defaultEditor.setAutocompleteProvider(provider);\n if (this.editor !== this.defaultEditor) {\n this.editor.setAutocompleteProvider?.(provider);\n }\n };\n"]}
@@ -3,7 +3,7 @@ import type { KeybindingsManager } from "../../core/keybindings.ts";
3
3
  import type { ExtensionUIContext } from "../../core/extensions/index.ts";
4
4
  import type { ActivityWatchdogDiagnostic } from "./activity-watchdog.ts";
5
5
  import type { EngineKeybindingState, InteractiveEngineMessage } from "./protocol.ts";
6
- import type { RpcSlashCommand } from "../rpc/rpc-types.ts";
6
+ import type { RpcAutocompleteItem, RpcSlashCommand } from "../rpc/rpc-types.ts";
7
7
  interface EngineMessageSource {
8
8
  onEngineMessage(listener: (message: InteractiveEngineMessage) => void): () => void;
9
9
  onKeybindingState?(listener: (state: EngineKeybindingState) => void): () => void;
@@ -17,6 +17,8 @@ export declare function interruptBlockedInteractiveEngine(runtime: AgentSessionR
17
17
  * empty list for non-isolated runtimes so callers can merge unconditionally.
18
18
  */
19
19
  export declare function getInteractiveEngineRemoteCommands(runtime: AgentSessionRuntime): readonly RpcSlashCommand[];
20
+ /** Evaluate an engine-child command's live argument completions. */
21
+ export declare function getInteractiveEngineRemoteCommandCompletions(runtime: AgentSessionRuntime, commandName: string, argumentPrefix: string): Promise<RpcAutocompleteItem[] | null>;
20
22
  /** Subscribe to engine-child command catalog changes. No-op when not isolated. */
21
23
  export declare function onInteractiveEngineRemoteCommandsChanged(runtime: AgentSessionRuntime, listener: (commands: readonly RpcSlashCommand[]) => void): () => void;
22
24
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"extension-ui-bridge.d.ts","sourceRoot":"","s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E,EAAE,kBAAkB,EACtB,YAAY,EAAE,CAAC,UAAU,EAAE,0BAA0B,KAAK,IAAI,EAC9D,kBAAkB,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,KAAK,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,EAChF,WAAW,CAAC,EAAE,kBAAkB,GAC9B,MAAM,IAAI,CA2CZ;AAED,wBAAsB,6BAA6B,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAI/F;AAED,wBAAgB,iCAAiC,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAEvF;AAED;;;GAGG;AACH,wBAAgB,kCAAkC,CAAC,OAAO,EAAE,mBAAmB,GAAG,SAAS,eAAe,EAAE,CAE3G;AAED,oEAAoE;AACpE,wBAAgB,4CAA4C,CAC3D,OAAO,EAAE,mBAAmB,EAC5B,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,GACpB,OAAO,CAAC,mBAAmB,EAAE,GAAG,IAAI,CAAC,CAIvC;AAED,kFAAkF;AAClF,wBAAgB,wCAAwC,CACvD,OAAO,EAAE,mBAAmB,EAC5B,QAAQ,EAAE,CAAC,QAAQ,EAAE,SAAS,eAAe,EAAE,KAAK,IAAI,GACtD,MAAM,IAAI,CAEZ"}
@@ -119,6 +119,12 @@ export function interruptBlockedInteractiveEngine(runtime) {
119
119
  export function getInteractiveEngineRemoteCommands(runtime) {
120
120
  return runtime instanceof IsolatedInteractiveRuntime ? runtime.getRemoteCommands() : [];
121
121
  }
122
+ /** Evaluate an engine-child command's live argument completions. */
123
+ export function getInteractiveEngineRemoteCommandCompletions(runtime, commandName, argumentPrefix) {
124
+ return runtime instanceof IsolatedInteractiveRuntime
125
+ ? runtime.getRemoteCommandCompletions(commandName, argumentPrefix)
126
+ : Promise.resolve(null);
127
+ }
122
128
  /** Subscribe to engine-child command catalog changes. No-op when not isolated. */
123
129
  export function onInteractiveEngineRemoteCommandsChanged(runtime, listener) {
124
130
  return runtime instanceof IsolatedInteractiveRuntime ? runtime.onRemoteCommandsChanged(listener) : () => { };