@asm-agent/coding-agent 0.9.2 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/asm-agent-runtime/src/rlm/__pycache__/__init__.cpython-313.pyc +0 -0
- package/dist/asm-agent-runtime/src/rlm/__pycache__/bash.cpython-313.pyc +0 -0
- package/dist/asm-agent-runtime/src/rlm/__pycache__/repl.cpython-313.pyc +0 -0
- package/dist/bundle/{anthropic-2VRH36LG.js → anthropic-MHZBPOI3.js} +1 -1
- package/dist/bundle/{azure-openai-responses-COYWHJPT.js → azure-openai-responses-STVL56NS.js} +1 -1
- package/dist/bundle/{bundled-modules-N3FE2F3V.js → bundled-modules-ZKJOKVMT.js} +3 -3
- package/dist/bundle/{chunk-6GUVYK6P.js → chunk-EBIKTZ7C.js} +1 -0
- package/dist/bundle/{chunk-ZFAQZSZL.js → chunk-IP6ZYRWR.js} +477 -43
- package/dist/bundle/{chunk-LRHUL5TM.js → chunk-YWSYGTH7.js} +10 -10
- package/dist/bundle/{cli-main-PA7BZMDO.js → cli-main-YZ2VGIP6.js} +3 -3
- package/dist/bundle/cli.js +1 -1
- package/dist/bundle/{google-CSTXROSV.js → google-GMTMUI2A.js} +12 -3
- package/dist/bundle/{main-Y475CMOX.js → main-JTKNY7OB.js} +3 -3
- package/dist/bundle/{mistral-VAF7JADB.js → mistral-UCXDQPIP.js} +1 -1
- package/dist/bundle/{openai-codex-responses-RWZ6P4I3.js → openai-codex-responses-EGZH34H4.js} +1 -1
- package/dist/bundle/{openai-completions-CFB3BOTU.js → openai-completions-N3OFURZC.js} +1 -1
- package/dist/bundle/{openai-responses-4OPGGCBI.js → openai-responses-DTSHMHFQ.js} +1 -1
- package/dist/core/auth-storage.d.ts +2 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +71 -5
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +10 -1
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/provider-display-names.d.ts.map +1 -1
- package/dist/core/provider-display-names.js +1 -0
- package/dist/core/provider-display-names.js.map +1 -1
- package/dist/modes/interactive/auth-flows.d.ts.map +1 -1
- package/dist/modes/interactive/auth-flows.js +1 -1
- package/dist/modes/interactive/auth-flows.js.map +1 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-flows.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/auth-flows.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAiB,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAelE,OAAO,EACN,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EAGzB,MAAM,gCAAgC,CAAC;AAIxC,MAAM,MAAM,oBAAoB,GAC7B;IACA,MAAM,EAAE,SAAS,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,4EAA4E;IAC5E,IAAI,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;CAC7B,GACD;IAAE,MAAM,EAAE,WAAW,CAAA;CAAE,GACvB;IAAE,MAAM,EAAE,QAAQ,CAAA;CAAE,CAAC;AAExB,eAAO,MAAM,mBAAmB,mBAAmB,CAAC;AACpD,eAAO,MAAM,4BAA4B,aAAyC,CAAC;AAEnF,eAAO,MAAM,mCAAmC,0MACwJ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AC,CAqC1E;IAED,aAAa,CAAC,cAAc,EAAE,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAYjF;IAED,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA8ClC;IAED,uBAAuB,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,oBAAoB,EAAE,CAe9E;IAED,OAAO,CAAC,wBAAwB;YAuClB,8BAA8B;YAyB9B,6BAA6B;YAe7B,0BAA0B;YAK1B,sBAAsB;IAgCpC,OAAO,CAAC,qBAAqB;IA2B7B,OAAO,CAAC,kCAAkC;YA6B5B,wBAAwB;YAmCxB,2BAA2B;IAmBnC,sBAAsB,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAmH5D;YAEa,qBAAqB;IAmCnC,OAAO,CAAC,oBAAoB;YA4Bd,eAAe;CAkF7B","sourcesContent":["import * as path from \"node:path\";\nimport { getProviders, type OAuthProviderId, type OAuthSelectPrompt } from \"@asm-agent/ai\";\nimport type { OverlayHandle, TUI } from \"@asm-agent/tui\";\nimport { getAuthPath, getDocsPath } from \"../../config.js\";\nimport type { ModelRegistry } from \"../../core/model-registry.js\";\nimport {\n\tcheckPrimeInferenceAccess,\n\tfetchPrimeTeams,\n\tloadPrimeCliConfig,\n\tloginPrimeInference,\n\tPRIME_INFERENCE_PROVIDER_ID,\n\tPRIME_INFERENCE_PROVIDER_NAME,\n\ttype PrimeTeam,\n} from \"../../core/prime-inference-auth.js\";\nimport { BUILT_IN_PROVIDER_DISPLAY_NAMES } from \"../../core/provider-display-names.js\";\nimport { SERPER_CREDENTIAL_ID, SERPER_CREDENTIAL_NAME } from \"../../core/websearch-credential.js\";\nimport { showFullPaneOverlay } from \"./components/centered-overlay.js\";\nimport { ExtensionSelectorComponent } from \"./components/extension-selector.js\";\nimport { LoginDialogComponent } from \"./components/login-dialog.js\";\nimport {\n\ttype AuthSelectorCategory,\n\ttype AuthSelectorProvider,\n\tcompareAuthSelectorProviders,\n\tOAuthSelectorComponent,\n} from \"./components/oauth-selector.js\";\nimport { PrimeTeamSelectorComponent } from \"./components/prime-team-selector.js\";\nimport { theme } from \"./theme/theme.js\";\n\nexport type AuthenticationResult =\n\t| {\n\t\t\tstatus: \"success\";\n\t\t\tproviderId: string;\n\t\t\tproviderName: string;\n\t\t\tauthType: \"oauth\" | \"api_key\";\n\t\t\t/** \"service\" credentials (e.g. web search) don't affect model selection. */\n\t\t\tkind?: \"provider\" | \"service\";\n\t }\n\t| { status: \"cancelled\" }\n\t| { status: \"failed\" };\n\nexport const BEDROCK_PROVIDER_ID = \"amazon-bedrock\";\nexport const ASM_AGENT_LOGIN_PROVIDER_IDS = new Set([\"openai-codex\", \"anthropic\"]);\n\nexport const ANTHROPIC_SUBSCRIPTION_AUTH_WARNING =\n\t\"Anthropic subscription auth is active. Third-party harness usage draws from extra usage and is billed per token, not your Claude plan limits. Manage extra usage at https://claude.ai/settings/usage.\";\n\nfunction isAnthropicSubscriptionAuthKey(apiKey: string | undefined): boolean {\n\treturn typeof apiKey === \"string\" && apiKey.startsWith(\"sk-ant-oat\");\n}\n\nexport async function getAnthropicSubscriptionAuthWarning(\n\tmodelRegistry: ModelRegistry,\n\tmodel: { provider: string } | undefined,\n): Promise<string | undefined> {\n\tif (!model || model.provider !== \"anthropic\") {\n\t\treturn undefined;\n\t}\n\n\tconst storedCredential = modelRegistry.authStorage.get(\"anthropic\");\n\tif (storedCredential?.type === \"oauth\") {\n\t\treturn ANTHROPIC_SUBSCRIPTION_AUTH_WARNING;\n\t}\n\n\ttry {\n\t\tconst apiKey = await modelRegistry.getApiKeyForProvider(model.provider);\n\t\tif (isAnthropicSubscriptionAuthKey(apiKey)) {\n\t\t\treturn ANTHROPIC_SUBSCRIPTION_AUTH_WARNING;\n\t\t}\n\t} catch {\n\t\t// Ignore auth lookup failures for warning-only checks.\n\t}\n\treturn undefined;\n}\n\nconst BUILT_IN_MODEL_PROVIDERS = new Set<string>(getProviders());\n\nexport function isApiKeyLoginProvider(\n\tproviderId: string,\n\toauthProviderIds: ReadonlySet<string>,\n\tbuiltInProviderIds: ReadonlySet<string> = BUILT_IN_MODEL_PROVIDERS,\n): boolean {\n\tif (BUILT_IN_PROVIDER_DISPLAY_NAMES[providerId]) {\n\t\treturn true;\n\t}\n\tif (builtInProviderIds.has(providerId)) {\n\t\treturn false;\n\t}\n\treturn !oauthProviderIds.has(providerId);\n}\n\nexport interface ProviderAuthFlowsHost {\n\treadonly ui: TUI;\n\treadonly modelRegistry: ModelRegistry;\n\tshowStatus(message: string): void;\n\tshowError(message: string): void;\n\t/** Models currently visible to the host; used to detect providers configured via external credentials. */\n\tgetAvailableModels(): Promise<ReadonlyArray<{ provider: string }>>;\n\t/** Invoked after stored credentials change so the host can refresh dependent UI. */\n\tonAuthChanged?(): void | Promise<void>;\n\t/** Invoked after a successful login (e.g. to surface billing warnings). */\n\tonLoginCompleted?(): void;\n}\n\nexport interface ProviderLoginOptions {\n\tauthType?: \"oauth\" | \"api_key\";\n\tinitialCategory?: AuthSelectorCategory;\n}\n\n/** Shared auth dialogs: host-specific refresh and billing effects remain outside the flow. */\nexport class ProviderAuthFlows {\n\tconstructor(private readonly host: ProviderAuthFlowsHost) {}\n\n\t/**\n\t * Run the OAuth login flow for an MCP integration server.\n\t *\n\t * The provider must already be registered (the McpManager does this as\n\t * `mcp:<server>`). On success the credentials land in auth.json and the\n\t * caller should reload resources so the integration's skill enables.\n\t */\n\trunMcpLogin(server: string, label?: string): Promise<AuthenticationResult> {\n\t\tconst providerId = `mcp:${server}`;\n\t\tconst provider = this.host.modelRegistry.authStorage.getOAuthProviders().find((p) => p.id === providerId);\n\t\tif (!provider) {\n\t\t\tthis.host.showError(`Unknown MCP integration: ${server}`);\n\t\t\treturn Promise.resolve({ status: \"failed\" });\n\t\t}\n\t\treturn this.showLoginDialog(providerId, label ?? provider.name, \"service\");\n\t}\n\n\trunLogin(options: ProviderLoginOptions = {}): Promise<AuthenticationResult> {\n\t\tconst { authType, initialCategory } = options;\n\t\tconst providerOptions = this.getLoginProviderOptions(authType);\n\t\tif (providerOptions.length === 0) {\n\t\t\tthis.host.showStatus(\n\t\t\t\tauthType === \"oauth\"\n\t\t\t\t\t? \"No subscription providers available.\"\n\t\t\t\t\t: authType === \"api_key\"\n\t\t\t\t\t\t? \"No API key providers available.\"\n\t\t\t\t\t\t: \"No providers available.\",\n\t\t\t);\n\t\t\treturn Promise.resolve({ status: \"failed\" });\n\t\t}\n\n\t\treturn new Promise((resolve) => {\n\t\t\tlet handle: OverlayHandle | undefined;\n\t\t\tconst close = () => {\n\t\t\t\thandle?.hide();\n\t\t\t\tthis.host.ui.requestRender();\n\t\t\t};\n\t\t\tconst selector = new OAuthSelectorComponent(\n\t\t\t\t\"login\",\n\t\t\t\tthis.host.modelRegistry.authStorage,\n\t\t\t\tproviderOptions,\n\t\t\t\tasync (providerOption: AuthSelectorProvider) => {\n\t\t\t\t\tclose();\n\t\t\t\t\tresolve(await this.loginProvider(providerOption));\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tclose();\n\t\t\t\t\tresolve({ status: \"cancelled\" });\n\t\t\t\t},\n\t\t\t\t(providerId) => this.host.modelRegistry.getProviderAuthStatus(providerId),\n\t\t\t\t{ getRows: () => this.host.ui.terminal.rows, initialCategory },\n\t\t\t);\n\t\t\thandle = showFullPaneOverlay(this.host.ui, selector, 78);\n\t\t});\n\t}\n\n\tloginProvider(providerOption: AuthSelectorProvider): Promise<AuthenticationResult> {\n\t\tconst kind = providerOption.category === \"service\" ? \"service\" : \"provider\";\n\t\tif (providerOption.authType === \"oauth\") {\n\t\t\treturn this.showLoginDialog(providerOption.id, providerOption.name, kind);\n\t\t}\n\t\tif (providerOption.id === PRIME_INFERENCE_PROVIDER_ID) {\n\t\t\treturn this.runPrimeInferenceLogin();\n\t\t}\n\t\tif (providerOption.id === BEDROCK_PROVIDER_ID) {\n\t\t\treturn this.showBedrockSetupDialog(providerOption.id, providerOption.name);\n\t\t}\n\t\treturn this.showApiKeyLoginDialog(providerOption.id, providerOption.name, kind);\n\t}\n\n\trunLogout(): Promise<string | null> {\n\t\tconst providerOptions = this.getLogoutProviderOptions();\n\t\tif (providerOptions.length === 0) {\n\t\t\tthis.host.showStatus(\n\t\t\t\t\"No stored credentials to remove. /logout only removes credentials saved by /login; environment variables and models.json config are unchanged.\",\n\t\t\t);\n\t\t\treturn Promise.resolve(null);\n\t\t}\n\n\t\treturn new Promise((resolve) => {\n\t\t\tlet handle: OverlayHandle | undefined;\n\t\t\tconst close = () => {\n\t\t\t\thandle?.hide();\n\t\t\t\tthis.host.ui.requestRender();\n\t\t\t};\n\t\t\tconst selector = new OAuthSelectorComponent(\n\t\t\t\t\"logout\",\n\t\t\t\tthis.host.modelRegistry.authStorage,\n\t\t\t\tproviderOptions,\n\t\t\t\tasync (providerOption: AuthSelectorProvider) => {\n\t\t\t\t\tclose();\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tthis.host.modelRegistry.authStorage.logout(providerOption.id);\n\t\t\t\t\t\tthis.host.modelRegistry.refresh();\n\t\t\t\t\t\tawait this.host.onAuthChanged?.();\n\t\t\t\t\t\tconst message =\n\t\t\t\t\t\t\tproviderOption.authType === \"oauth\"\n\t\t\t\t\t\t\t\t? `Logged out of ${providerOption.name}`\n\t\t\t\t\t\t\t\t: `Removed stored API key for ${providerOption.name}. Environment variables and models.json config are unchanged.`;\n\t\t\t\t\t\tthis.host.showStatus(message);\n\t\t\t\t\t\tresolve(providerOption.id);\n\t\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\t\tthis.host.showError(`Logout failed: ${error instanceof Error ? error.message : String(error)}`);\n\t\t\t\t\t\tresolve(null);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tclose();\n\t\t\t\t\tresolve(null);\n\t\t\t\t},\n\t\t\t\tundefined,\n\t\t\t\t{ getRows: () => this.host.ui.terminal.rows },\n\t\t\t);\n\t\t\thandle = showFullPaneOverlay(this.host.ui, selector, 78);\n\t\t});\n\t}\n\n\tgetLoginProviderOptions(authType?: \"oauth\" | \"api_key\"): AuthSelectorProvider[] {\n\t\tconst authStorage = this.host.modelRegistry.authStorage;\n\t\tif (authType === \"api_key\") {\n\t\t\treturn [];\n\t\t}\n\t\tconst oauthProviders = authStorage\n\t\t\t.getOAuthProviders()\n\t\t\t.filter((provider) => ASM_AGENT_LOGIN_PROVIDER_IDS.has(provider.id));\n\t\tconst options: AuthSelectorProvider[] = oauthProviders.map((provider) => ({\n\t\t\tid: provider.id,\n\t\t\tname: provider.name,\n\t\t\tauthType: \"oauth\",\n\t\t}));\n\n\t\treturn options.sort(compareAuthSelectorProviders);\n\t}\n\n\tprivate getLogoutProviderOptions(): AuthSelectorProvider[] {\n\t\tconst authStorage = this.host.modelRegistry.authStorage;\n\t\tconst options: AuthSelectorProvider[] = [];\n\n\t\tconst oauthProvidersById = new Map(authStorage.getOAuthProviders().map((p) => [p.id, p]));\n\t\tfor (const providerId of authStorage.list()) {\n\t\t\tconst credential = authStorage.get(providerId);\n\t\t\tif (!credential) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst isSerper = providerId === SERPER_CREDENTIAL_ID;\n\t\t\tconst isMcp = providerId.startsWith(\"mcp:\");\n\t\t\tconst name = isSerper\n\t\t\t\t? SERPER_CREDENTIAL_NAME\n\t\t\t\t: isMcp\n\t\t\t\t\t? (oauthProvidersById.get(providerId)?.name ?? providerId.slice(\"mcp:\".length))\n\t\t\t\t\t: this.host.modelRegistry.getProviderDisplayName(providerId);\n\t\t\toptions.push({\n\t\t\t\tid: providerId,\n\t\t\t\tname,\n\t\t\t\tauthType: credential.type,\n\t\t\t\tcategory: isSerper || isMcp ? \"service\" : \"provider\",\n\t\t\t});\n\t\t}\n\n\t\tif (!options.some((option) => option.id === PRIME_INFERENCE_PROVIDER_ID)) {\n\t\t\tconst primeInferenceStatus = authStorage.getAuthStatus(PRIME_INFERENCE_PROVIDER_ID);\n\t\t\tif (primeInferenceStatus.source === \"prime_cli\") {\n\t\t\t\toptions.push({\n\t\t\t\t\tid: PRIME_INFERENCE_PROVIDER_ID,\n\t\t\t\t\tname: PRIME_INFERENCE_PROVIDER_NAME,\n\t\t\t\t\tauthType: \"api_key\",\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn options.sort((a, b) => a.name.localeCompare(b.name));\n\t}\n\n\tprivate async completeProviderAuthentication(\n\t\tproviderId: string,\n\t\tproviderName: string,\n\t\tauthType: \"oauth\" | \"api_key\",\n\t\tstatusSuffix?: string,\n\t\tkind: \"provider\" | \"service\" = \"provider\",\n\t\tcredentialPath: string = getAuthPath(),\n\t): Promise<AuthenticationResult> {\n\t\tthis.host.modelRegistry.refresh();\n\n\t\tconst actionLabel = authType === \"oauth\" ? `Logged in to ${providerName}` : `Saved API key for ${providerName}`;\n\t\tawait this.host.onAuthChanged?.();\n\t\tthis.host.showStatus(\n\t\t\t`${actionLabel}. Credentials saved to ${credentialPath}${statusSuffix ? `. ${statusSuffix}` : \"\"}`,\n\t\t);\n\t\tthis.host.onLoginCompleted?.();\n\t\treturn {\n\t\t\tstatus: \"success\",\n\t\t\tproviderId,\n\t\t\tproviderName,\n\t\t\tauthType,\n\t\t\tkind,\n\t\t};\n\t}\n\n\tprivate async completeExternalProviderSetup(\n\t\tproviderId: string,\n\t\tproviderName: string,\n\t): Promise<AuthenticationResult> {\n\t\tthis.host.modelRegistry.refresh();\n\t\tawait this.host.onAuthChanged?.();\n\t\tthis.host.showStatus(`${providerName} uses external credentials. Select a model after configuring them.`);\n\t\treturn {\n\t\t\tstatus: \"success\",\n\t\t\tproviderId,\n\t\t\tproviderName,\n\t\t\tauthType: \"api_key\",\n\t\t};\n\t}\n\n\tprivate async hasAvailableProviderModels(providerId: string): Promise<boolean> {\n\t\tconst models = await this.host.getAvailableModels();\n\t\treturn models.some((model) => model.provider === providerId);\n\t}\n\n\tprivate async showBedrockSetupDialog(providerId: string, providerName: string): Promise<AuthenticationResult> {\n\t\tconst dialog = new LoginDialogComponent(this.host.ui, providerId, () => {}, providerName, \"Amazon Bedrock setup\");\n\t\tconst handle = showFullPaneOverlay(this.host.ui, dialog, 88);\n\t\tconst closeDialog = () => {\n\t\t\thandle.hide();\n\t\t\tthis.host.ui.requestRender();\n\t\t};\n\n\t\ttry {\n\t\t\tawait dialog.showContinueInfo([\n\t\t\t\ttheme.fg(\"text\", \"Amazon Bedrock uses AWS credentials instead of a single API key.\"),\n\t\t\t\ttheme.fg(\"text\", \"Configure an AWS profile, IAM keys, bearer token, or role-based credentials.\"),\n\t\t\t\ttheme.fg(\"muted\", \"See:\"),\n\t\t\t\ttheme.fg(\"accent\", ` ${path.join(getDocsPath(), \"providers.md\")}`),\n\t\t\t]);\n\t\t\tcloseDialog();\n\t\t\tif (!(await this.hasAvailableProviderModels(providerId))) {\n\t\t\t\tthis.host.showStatus(`${providerName} credentials were not detected. Configure them, then reopen /model.`);\n\t\t\t\treturn { status: \"cancelled\" };\n\t\t\t}\n\t\t\treturn await this.completeExternalProviderSetup(providerId, providerName);\n\t\t} catch (error: unknown) {\n\t\t\tcloseDialog();\n\t\t\tconst errorMsg = error instanceof Error ? error.message : String(error);\n\t\t\tif (errorMsg !== \"Login cancelled\") {\n\t\t\t\tthis.host.showError(`Failed to set up ${providerName}: ${errorMsg}`);\n\t\t\t\treturn { status: \"failed\" };\n\t\t\t}\n\t\t\treturn { status: \"cancelled\" };\n\t\t}\n\t}\n\n\tprivate showPrimeTeamSelector(\n\t\tteams: PrimeTeam[],\n\t\tcurrentTeamId: string | undefined,\n\t): Promise<PrimeTeam | null | undefined> {\n\t\treturn new Promise((resolve) => {\n\t\t\tlet handle: OverlayHandle | undefined;\n\t\t\tconst close = () => {\n\t\t\t\thandle?.hide();\n\t\t\t\tthis.host.ui.requestRender();\n\t\t\t};\n\t\t\tconst selector = new PrimeTeamSelectorComponent(\n\t\t\t\tteams,\n\t\t\t\tcurrentTeamId,\n\t\t\t\t(team) => {\n\t\t\t\t\tclose();\n\t\t\t\t\tresolve(team);\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tclose();\n\t\t\t\t\tresolve(undefined);\n\t\t\t\t},\n\t\t\t\t{ getRows: () => this.host.ui.terminal.rows },\n\t\t\t);\n\t\t\thandle = showFullPaneOverlay(this.host.ui, selector, 78);\n\t\t});\n\t}\n\n\tprivate getPrimeInferenceDefaultTeamStatus(): string {\n\t\tconst configPath = this.host.modelRegistry.authStorage.getPrimeCliConfigPath();\n\t\tif (configPath) {\n\t\t\tlet config: ReturnType<typeof loadPrimeCliConfig>;\n\t\t\ttry {\n\t\t\t\tconfig = loadPrimeCliConfig(configPath);\n\t\t\t} catch {\n\t\t\t\treturn \"Using personal account.\";\n\t\t\t}\n\t\t\tif (config.teamIdFromEnv) {\n\t\t\t\treturn \"Using team from PRIME_TEAM_ID.\";\n\t\t\t}\n\t\t\tif (config.teamName) {\n\t\t\t\treturn `Using team \"${config.teamName}\".`;\n\t\t\t}\n\t\t\tif (config.teamId) {\n\t\t\t\treturn \"Using Prime CLI team.\";\n\t\t\t}\n\t\t}\n\t\tconst storedTeam = this.host.modelRegistry.authStorage.getPrimeInferenceTeamSelection();\n\t\tif (storedTeam) {\n\t\t\treturn `Using team \"${storedTeam.name}\".`;\n\t\t}\n\t\tif (storedTeam === null) {\n\t\t\treturn \"Using personal account.\";\n\t\t}\n\t\treturn \"Using personal account.\";\n\t}\n\n\tprivate async selectPrimeInferenceTeam(apiKey: string, dialog: LoginDialogComponent): Promise<string | undefined> {\n\t\ttry {\n\t\t\tconst config = loadPrimeCliConfig(this.host.modelRegistry.authStorage.getPrimeCliConfigPath());\n\t\t\tif (config.teamIdFromEnv) {\n\t\t\t\tthis.host.modelRegistry.authStorage.reload();\n\t\t\t\treturn \"Using team from PRIME_TEAM_ID.\";\n\t\t\t}\n\n\t\t\tdialog.showProgress(\"Loading Prime teams...\");\n\t\t\tconst teams = await fetchPrimeTeams(apiKey, config.baseUrl, { signal: dialog.signal });\n\t\t\tif (dialog.signal.aborted) {\n\t\t\t\treturn this.getPrimeInferenceDefaultTeamStatus();\n\t\t\t}\n\t\t\tif (teams.length === 0) {\n\t\t\t\tthis.host.modelRegistry.authStorage.setPrimeInferenceTeamSelection(null);\n\t\t\t\treturn \"Using personal account.\";\n\t\t\t}\n\n\t\t\tconst storedTeam = this.host.modelRegistry.authStorage.getPrimeInferenceTeamSelection();\n\t\t\tconst currentTeamId = storedTeam === null ? undefined : (storedTeam?.teamId ?? config.teamId);\n\t\t\tconst selectedTeam = await this.showPrimeTeamSelector(teams, currentTeamId);\n\t\t\tif (selectedTeam !== undefined) {\n\t\t\t\tthis.host.modelRegistry.authStorage.setPrimeInferenceTeamSelection(selectedTeam);\n\t\t\t}\n\t\t\treturn selectedTeam\n\t\t\t\t? `Using team \"${selectedTeam.name}\".`\n\t\t\t\t: selectedTeam === null\n\t\t\t\t\t? \"Using personal account.\"\n\t\t\t\t\t: this.getPrimeInferenceDefaultTeamStatus();\n\t\t} catch {\n\t\t\tthis.host.modelRegistry.authStorage.reload();\n\t\t\treturn this.getPrimeInferenceDefaultTeamStatus();\n\t\t}\n\t}\n\n\tprivate async completePrimeInferenceLogin(\n\t\tapiKey: string,\n\t\tdialog: LoginDialogComponent,\n\t\tcloseDialog: () => void,\n\t): Promise<AuthenticationResult> {\n\t\tthis.host.modelRegistry.authStorage.setPrimeInferenceApiKey(apiKey);\n\t\tconst teamStatus = await this.selectPrimeInferenceTeam(apiKey, dialog);\n\n\t\tcloseDialog();\n\t\treturn await this.completeProviderAuthentication(\n\t\t\tPRIME_INFERENCE_PROVIDER_ID,\n\t\t\tPRIME_INFERENCE_PROVIDER_NAME,\n\t\t\t\"api_key\",\n\t\t\tteamStatus,\n\t\t\t\"provider\",\n\t\t\tthis.host.modelRegistry.authStorage.getPrimeCliConfigPath() ?? getAuthPath(),\n\t\t);\n\t}\n\n\tasync runPrimeInferenceLogin(): Promise<AuthenticationResult> {\n\t\tconst dialog = new LoginDialogComponent(\n\t\t\tthis.host.ui,\n\t\t\tPRIME_INFERENCE_PROVIDER_ID,\n\t\t\t(_success, _message) => {},\n\t\t\tPRIME_INFERENCE_PROVIDER_NAME,\n\t\t);\n\n\t\tconst handle = showFullPaneOverlay(this.host.ui, dialog, {\n\t\t\tmaxContentWidth: 88,\n\t\t\tsuspendFullscreenMouse: true,\n\t\t});\n\n\t\tconst closeDialog = () => {\n\t\t\thandle.hide();\n\t\t\tthis.host.ui.requestRender();\n\t\t};\n\n\t\t// The browser challenge gets its own controller so a manually pasted key\n\t\t// can stop the polling without tearing down the dialog.\n\t\tconst browserAbort = new AbortController();\n\t\tconst onDialogAbort = () => browserAbort.abort();\n\t\tdialog.signal.addEventListener(\"abort\", onDialogAbort, { once: true });\n\n\t\tlet manualInputArmed = false;\n\t\tlet resolveManualKey: (entry: { apiKey: string; source: \"manual\" }) => void = () => {};\n\t\tconst manualKeyEntry = new Promise<{ apiKey: string; source: \"manual\" }>((resolve) => {\n\t\t\tresolveManualKey = resolve;\n\t\t});\n\t\tconst armManualInput = (prompt: string): void => {\n\t\t\tmanualInputArmed = true;\n\t\t\tvoid (async () => {\n\t\t\t\tlet value = (await dialog.showManualInput(prompt)).trim();\n\t\t\t\twhile (!value) {\n\t\t\t\t\tvalue = (await dialog.waitForInput()).trim();\n\t\t\t\t}\n\t\t\t\tresolveManualKey({ apiKey: value, source: \"manual\" });\n\t\t\t})().catch(() => {\n\t\t\t\t// Cancellation surfaces through the dialog signal.\n\t\t\t});\n\t\t};\n\n\t\ttry {\n\t\t\tconst browserLogin = loginPrimeInference(\n\t\t\t\t{\n\t\t\t\t\tonAuth: (info) => {\n\t\t\t\t\t\tdialog.showAuth(info.url, info.instructions);\n\t\t\t\t\t\tarmManualInput(\"Complete the sign-in in your browser, or paste an API key below:\");\n\t\t\t\t\t},\n\t\t\t\t\tonProgress: (message) => {\n\t\t\t\t\t\tdialog.showProgress(message);\n\t\t\t\t\t},\n\t\t\t\t\tsignal: browserAbort.signal,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tconfigPath: this.host.modelRegistry.authStorage.getPrimeCliConfigPath(),\n\t\t\t\t},\n\t\t\t);\n\t\t\t// When the browser challenge cannot start or breaks down, keep the dialog\n\t\t\t// open and fall back to plain API key entry instead of failing outright.\n\t\t\tconst browserLoginOrFallback = browserLogin.catch((error: unknown) => {\n\t\t\t\tif (browserAbort.signal.aborted) {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t\tconst errorMsg = error instanceof Error ? error.message : String(error);\n\t\t\t\tdialog.showProgress(`Browser sign-in unavailable (${errorMsg}).`);\n\t\t\t\tif (!manualInputArmed) {\n\t\t\t\t\tarmManualInput(\"Paste a Prime API key below:\");\n\t\t\t\t}\n\t\t\t\treturn manualKeyEntry;\n\t\t\t});\n\t\t\t// Once the browser flow has settled into manual fallback, nothing above\n\t\t\t// rejects on cancel anymore, so the dialog signal must end the race too.\n\t\t\tconst dialogCancelled = new Promise<never>((_, reject) => {\n\t\t\t\tdialog.signal.addEventListener(\"abort\", () => reject(new Error(\"Login cancelled\")), { once: true });\n\t\t\t});\n\t\t\t// Promise.race observes the rejections below, but keep dedicated handlers\n\t\t\t// so neither an aborted browser flow nor a cancelled dialog can surface\n\t\t\t// as an unhandled rejection.\n\t\t\tbrowserLoginOrFallback.catch(() => {});\n\t\t\tdialogCancelled.catch(() => {});\n\n\t\t\tconst result = await Promise.race([browserLoginOrFallback, manualKeyEntry, dialogCancelled]);\n\t\t\tif (dialog.signal.aborted) {\n\t\t\t\tcloseDialog();\n\t\t\t\treturn { status: \"cancelled\" };\n\t\t\t}\n\n\t\t\tif (result.source === \"manual\") {\n\t\t\t\tbrowserAbort.abort();\n\t\t\t\tdialog.showProgress(\"Checking Prime Inference access...\");\n\t\t\t\tconst config = loadPrimeCliConfig(this.host.modelRegistry.authStorage.getPrimeCliConfigPath());\n\t\t\t\tconst access = await checkPrimeInferenceAccess(result.apiKey, config.baseUrl, { signal: dialog.signal });\n\t\t\t\tif (dialog.signal.aborted) {\n\t\t\t\t\tcloseDialog();\n\t\t\t\t\treturn { status: \"cancelled\" };\n\t\t\t\t}\n\t\t\t\tif (!access.ok) {\n\t\t\t\t\tconst status = access.status === undefined ? \"\" : `HTTP ${access.status}: `;\n\t\t\t\t\tthrow new Error(`Prime API key does not have Prime Inference access (${status}${access.message})`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn await this.completePrimeInferenceLogin(result.apiKey, dialog, closeDialog);\n\t\t} catch (error: unknown) {\n\t\t\tcloseDialog();\n\t\t\tconst errorMsg = error instanceof Error ? error.message : String(error);\n\t\t\tif (!dialog.signal.aborted && errorMsg !== \"Login cancelled\") {\n\t\t\t\tthis.host.showError(`Failed to login to ${PRIME_INFERENCE_PROVIDER_NAME}: ${errorMsg}`);\n\t\t\t\treturn { status: \"failed\" };\n\t\t\t}\n\t\t\treturn { status: \"cancelled\" };\n\t\t} finally {\n\t\t\tdialog.signal.removeEventListener(\"abort\", onDialogAbort);\n\t\t}\n\t}\n\n\tprivate async showApiKeyLoginDialog(\n\t\tproviderId: string,\n\t\tproviderName: string,\n\t\tkind: \"provider\" | \"service\" = \"provider\",\n\t): Promise<AuthenticationResult> {\n\t\tconst dialog = new LoginDialogComponent(this.host.ui, providerId, (_success, _message) => {}, providerName);\n\n\t\tconst handle = showFullPaneOverlay(this.host.ui, dialog, 88);\n\n\t\tconst closeDialog = () => {\n\t\t\thandle.hide();\n\t\t\tthis.host.ui.requestRender();\n\t\t};\n\n\t\ttry {\n\t\t\tconst apiKey = (await dialog.showPrompt(\"Enter API key:\")).trim();\n\t\t\tif (!apiKey) {\n\t\t\t\tthrow new Error(\"API key cannot be empty.\");\n\t\t\t}\n\n\t\t\tthis.host.modelRegistry.authStorage.set(providerId, { type: \"api_key\", key: apiKey });\n\n\t\t\tcloseDialog();\n\t\t\treturn await this.completeProviderAuthentication(providerId, providerName, \"api_key\", undefined, kind);\n\t\t} catch (error: unknown) {\n\t\t\tcloseDialog();\n\t\t\tconst errorMsg = error instanceof Error ? error.message : String(error);\n\t\t\tif (errorMsg !== \"Login cancelled\") {\n\t\t\t\tthis.host.showError(`Failed to save API key for ${providerName}: ${errorMsg}`);\n\t\t\t\treturn { status: \"failed\" };\n\t\t\t}\n\t\t\treturn { status: \"cancelled\" };\n\t\t}\n\t}\n\n\tprivate showOAuthLoginSelect(dialogHandle: OverlayHandle, prompt: OAuthSelectPrompt): Promise<string | undefined> {\n\t\treturn new Promise((resolve) => {\n\t\t\tdialogHandle.setHidden(true);\n\t\t\tlet selectorHandle: OverlayHandle | undefined;\n\t\t\tconst restoreDialog = () => {\n\t\t\t\tselectorHandle?.hide();\n\t\t\t\tdialogHandle.setHidden(false);\n\t\t\t\tdialogHandle.focus();\n\t\t\t\tthis.host.ui.requestRender();\n\t\t\t};\n\t\t\tconst labels = prompt.options.map((option) => option.label);\n\t\t\tconst selector = new ExtensionSelectorComponent(\n\t\t\t\tprompt.message,\n\t\t\t\tlabels,\n\t\t\t\t(optionLabel) => {\n\t\t\t\t\trestoreDialog();\n\t\t\t\t\tresolve(prompt.options.find((option) => option.label === optionLabel)?.id);\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\trestoreDialog();\n\t\t\t\t\tresolve(undefined);\n\t\t\t\t},\n\t\t\t\t{ getRows: () => this.host.ui.terminal.rows },\n\t\t\t);\n\t\t\tselectorHandle = showFullPaneOverlay(this.host.ui, selector, 76);\n\t\t});\n\t}\n\n\tprivate async showLoginDialog(\n\t\tproviderId: string,\n\t\tproviderName: string,\n\t\tkind: \"provider\" | \"service\" = \"provider\",\n\t): Promise<AuthenticationResult> {\n\t\tconst providerInfo = this.host.modelRegistry.authStorage\n\t\t\t.getOAuthProviders()\n\t\t\t.find((provider) => provider.id === providerId);\n\n\t\tconst usesCallbackServer = providerInfo?.usesCallbackServer ?? false;\n\n\t\tconst dialog = new LoginDialogComponent(this.host.ui, providerId, (_success, _message) => {}, providerName);\n\n\t\tconst dialogHandle = showFullPaneOverlay(this.host.ui, dialog, {\n\t\t\tmaxContentWidth: 88,\n\t\t\tsuspendFullscreenMouse: true,\n\t\t});\n\n\t\tlet manualCodeResolve: ((code: string) => void) | undefined;\n\t\tlet manualCodeReject: ((err: Error) => void) | undefined;\n\t\tconst manualCodePromise = new Promise<string>((resolve, reject) => {\n\t\t\tmanualCodeResolve = resolve;\n\t\t\tmanualCodeReject = reject;\n\t\t});\n\n\t\tconst closeDialog = () => {\n\t\t\tdialogHandle.hide();\n\t\t\tthis.host.ui.requestRender();\n\t\t};\n\n\t\ttry {\n\t\t\tawait this.host.modelRegistry.authStorage.login(providerId as OAuthProviderId, {\n\t\t\t\tonAuth: (info: { url: string; instructions?: string }) => {\n\t\t\t\t\tdialog.showAuth(info.url, info.instructions);\n\n\t\t\t\t\tif (usesCallbackServer) {\n\t\t\t\t\t\tdialog\n\t\t\t\t\t\t\t.showManualInput(\"Paste redirect URL below, or complete login in browser:\")\n\t\t\t\t\t\t\t.then((value) => {\n\t\t\t\t\t\t\t\tif (value && manualCodeResolve) {\n\t\t\t\t\t\t\t\t\tmanualCodeResolve(value);\n\t\t\t\t\t\t\t\t\tmanualCodeResolve = undefined;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.catch(() => {\n\t\t\t\t\t\t\t\tif (manualCodeReject) {\n\t\t\t\t\t\t\t\t\tmanualCodeReject(new Error(\"Login cancelled\"));\n\t\t\t\t\t\t\t\t\tmanualCodeReject = undefined;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t} else if (providerId === \"github-copilot\") {\n\t\t\t\t\t\tdialog.showWaiting(\"Waiting for browser authentication...\");\n\t\t\t\t\t}\n\t\t\t\t},\n\n\t\t\t\tonPrompt: async (prompt: { message: string; placeholder?: string }) => {\n\t\t\t\t\treturn dialog.showPrompt(prompt.message, prompt.placeholder);\n\t\t\t\t},\n\n\t\t\t\tonProgress: (message: string) => {\n\t\t\t\t\tdialog.showProgress(message);\n\t\t\t\t},\n\n\t\t\t\tonSelect: (prompt: OAuthSelectPrompt) => this.showOAuthLoginSelect(dialogHandle, prompt),\n\n\t\t\t\tonManualCodeInput: () => manualCodePromise,\n\n\t\t\t\tsignal: dialog.signal,\n\t\t\t});\n\n\t\t\tcloseDialog();\n\t\t\treturn await this.completeProviderAuthentication(providerId, providerName, \"oauth\", undefined, kind);\n\t\t} catch (error: unknown) {\n\t\t\tcloseDialog();\n\t\t\tconst errorMsg = error instanceof Error ? error.message : String(error);\n\t\t\tif (errorMsg !== \"Login cancelled\") {\n\t\t\t\tthis.host.showError(`Failed to login to ${providerName}: ${errorMsg}`);\n\t\t\t\treturn { status: \"failed\" };\n\t\t\t}\n\t\t\treturn { status: \"cancelled\" };\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"auth-flows.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/auth-flows.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAiB,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAelE,OAAO,EACN,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EAGzB,MAAM,gCAAgC,CAAC;AAIxC,MAAM,MAAM,oBAAoB,GAC7B;IACA,MAAM,EAAE,SAAS,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,4EAA4E;IAC5E,IAAI,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;CAC7B,GACD;IAAE,MAAM,EAAE,WAAW,CAAA;CAAE,GACvB;IAAE,MAAM,EAAE,QAAQ,CAAA;CAAE,CAAC;AAExB,eAAO,MAAM,mBAAmB,mBAAmB,CAAC;AACpD,eAAO,MAAM,4BAA4B,aAA6D,CAAC;AAEvG,eAAO,MAAM,mCAAmC,0MACwJ,CAAC;AAMzM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AED,aAAa,CAAC,cAAc,EAAE,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAYjF;IAED,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA8ClC;IAED,uBAAuB,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,oBAAoB,EAAE,CAe9E;IAED,OAAO,CAAC,wBAAwB;YAuClB,8BAA8B;YAyB9B,6BAA6B;YAe7B,0BAA0B;YAK1B,sBAAsB;IAgCpC,OAAO,CAAC,qBAAqB;IA2B7B,OAAO,CAAC,kCAAkC;YA6B5B,wBAAwB;YAmCxB,2BAA2B;IAmBnC,sBAAsB,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAmH5D;YAEa,qBAAqB;IAmCnC,OAAO,CAAC,oBAAoB;YA4Bd,eAAe;CAkF7B","sourcesContent":["import * as path from \"node:path\";\nimport { getProviders, type OAuthProviderId, type OAuthSelectPrompt } from \"@asm-agent/ai\";\nimport type { OverlayHandle, TUI } from \"@asm-agent/tui\";\nimport { getAuthPath, getDocsPath } from \"../../config.js\";\nimport type { ModelRegistry } from \"../../core/model-registry.js\";\nimport {\n\tcheckPrimeInferenceAccess,\n\tfetchPrimeTeams,\n\tloadPrimeCliConfig,\n\tloginPrimeInference,\n\tPRIME_INFERENCE_PROVIDER_ID,\n\tPRIME_INFERENCE_PROVIDER_NAME,\n\ttype PrimeTeam,\n} from \"../../core/prime-inference-auth.js\";\nimport { BUILT_IN_PROVIDER_DISPLAY_NAMES } from \"../../core/provider-display-names.js\";\nimport { SERPER_CREDENTIAL_ID, SERPER_CREDENTIAL_NAME } from \"../../core/websearch-credential.js\";\nimport { showFullPaneOverlay } from \"./components/centered-overlay.js\";\nimport { ExtensionSelectorComponent } from \"./components/extension-selector.js\";\nimport { LoginDialogComponent } from \"./components/login-dialog.js\";\nimport {\n\ttype AuthSelectorCategory,\n\ttype AuthSelectorProvider,\n\tcompareAuthSelectorProviders,\n\tOAuthSelectorComponent,\n} from \"./components/oauth-selector.js\";\nimport { PrimeTeamSelectorComponent } from \"./components/prime-team-selector.js\";\nimport { theme } from \"./theme/theme.js\";\n\nexport type AuthenticationResult =\n\t| {\n\t\t\tstatus: \"success\";\n\t\t\tproviderId: string;\n\t\t\tproviderName: string;\n\t\t\tauthType: \"oauth\" | \"api_key\";\n\t\t\t/** \"service\" credentials (e.g. web search) don't affect model selection. */\n\t\t\tkind?: \"provider\" | \"service\";\n\t }\n\t| { status: \"cancelled\" }\n\t| { status: \"failed\" };\n\nexport const BEDROCK_PROVIDER_ID = \"amazon-bedrock\";\nexport const ASM_AGENT_LOGIN_PROVIDER_IDS = new Set([\"openai-codex\", \"anthropic\", \"google\", \"gemini\"]);\n\nexport const ANTHROPIC_SUBSCRIPTION_AUTH_WARNING =\n\t\"Anthropic subscription auth is active. Third-party harness usage draws from extra usage and is billed per token, not your Claude plan limits. Manage extra usage at https://claude.ai/settings/usage.\";\n\nfunction isAnthropicSubscriptionAuthKey(apiKey: string | undefined): boolean {\n\treturn typeof apiKey === \"string\" && apiKey.startsWith(\"sk-ant-oat\");\n}\n\nexport async function getAnthropicSubscriptionAuthWarning(\n\tmodelRegistry: ModelRegistry,\n\tmodel: { provider: string } | undefined,\n): Promise<string | undefined> {\n\tif (!model || model.provider !== \"anthropic\") {\n\t\treturn undefined;\n\t}\n\n\tconst storedCredential = modelRegistry.authStorage.get(\"anthropic\");\n\tif (storedCredential?.type === \"oauth\") {\n\t\treturn ANTHROPIC_SUBSCRIPTION_AUTH_WARNING;\n\t}\n\n\ttry {\n\t\tconst apiKey = await modelRegistry.getApiKeyForProvider(model.provider);\n\t\tif (isAnthropicSubscriptionAuthKey(apiKey)) {\n\t\t\treturn ANTHROPIC_SUBSCRIPTION_AUTH_WARNING;\n\t\t}\n\t} catch {\n\t\t// Ignore auth lookup failures for warning-only checks.\n\t}\n\treturn undefined;\n}\n\nconst BUILT_IN_MODEL_PROVIDERS = new Set<string>(getProviders());\n\nexport function isApiKeyLoginProvider(\n\tproviderId: string,\n\toauthProviderIds: ReadonlySet<string>,\n\tbuiltInProviderIds: ReadonlySet<string> = BUILT_IN_MODEL_PROVIDERS,\n): boolean {\n\tif (BUILT_IN_PROVIDER_DISPLAY_NAMES[providerId]) {\n\t\treturn true;\n\t}\n\tif (builtInProviderIds.has(providerId)) {\n\t\treturn false;\n\t}\n\treturn !oauthProviderIds.has(providerId);\n}\n\nexport interface ProviderAuthFlowsHost {\n\treadonly ui: TUI;\n\treadonly modelRegistry: ModelRegistry;\n\tshowStatus(message: string): void;\n\tshowError(message: string): void;\n\t/** Models currently visible to the host; used to detect providers configured via external credentials. */\n\tgetAvailableModels(): Promise<ReadonlyArray<{ provider: string }>>;\n\t/** Invoked after stored credentials change so the host can refresh dependent UI. */\n\tonAuthChanged?(): void | Promise<void>;\n\t/** Invoked after a successful login (e.g. to surface billing warnings). */\n\tonLoginCompleted?(): void;\n}\n\nexport interface ProviderLoginOptions {\n\tauthType?: \"oauth\" | \"api_key\";\n\tinitialCategory?: AuthSelectorCategory;\n}\n\n/** Shared auth dialogs: host-specific refresh and billing effects remain outside the flow. */\nexport class ProviderAuthFlows {\n\tconstructor(private readonly host: ProviderAuthFlowsHost) {}\n\n\t/**\n\t * Run the OAuth login flow for an MCP integration server.\n\t *\n\t * The provider must already be registered (the McpManager does this as\n\t * `mcp:<server>`). On success the credentials land in auth.json and the\n\t * caller should reload resources so the integration's skill enables.\n\t */\n\trunMcpLogin(server: string, label?: string): Promise<AuthenticationResult> {\n\t\tconst providerId = `mcp:${server}`;\n\t\tconst provider = this.host.modelRegistry.authStorage.getOAuthProviders().find((p) => p.id === providerId);\n\t\tif (!provider) {\n\t\t\tthis.host.showError(`Unknown MCP integration: ${server}`);\n\t\t\treturn Promise.resolve({ status: \"failed\" });\n\t\t}\n\t\treturn this.showLoginDialog(providerId, label ?? provider.name, \"service\");\n\t}\n\n\trunLogin(options: ProviderLoginOptions = {}): Promise<AuthenticationResult> {\n\t\tconst { authType, initialCategory } = options;\n\t\tconst providerOptions = this.getLoginProviderOptions(authType);\n\t\tif (providerOptions.length === 0) {\n\t\t\tthis.host.showStatus(\n\t\t\t\tauthType === \"oauth\"\n\t\t\t\t\t? \"No subscription providers available.\"\n\t\t\t\t\t: authType === \"api_key\"\n\t\t\t\t\t\t? \"No API key providers available.\"\n\t\t\t\t\t\t: \"No providers available.\",\n\t\t\t);\n\t\t\treturn Promise.resolve({ status: \"failed\" });\n\t\t}\n\n\t\treturn new Promise((resolve) => {\n\t\t\tlet handle: OverlayHandle | undefined;\n\t\t\tconst close = () => {\n\t\t\t\thandle?.hide();\n\t\t\t\tthis.host.ui.requestRender();\n\t\t\t};\n\t\t\tconst selector = new OAuthSelectorComponent(\n\t\t\t\t\"login\",\n\t\t\t\tthis.host.modelRegistry.authStorage,\n\t\t\t\tproviderOptions,\n\t\t\t\tasync (providerOption: AuthSelectorProvider) => {\n\t\t\t\t\tclose();\n\t\t\t\t\tresolve(await this.loginProvider(providerOption));\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tclose();\n\t\t\t\t\tresolve({ status: \"cancelled\" });\n\t\t\t\t},\n\t\t\t\t(providerId) => this.host.modelRegistry.getProviderAuthStatus(providerId),\n\t\t\t\t{ getRows: () => this.host.ui.terminal.rows, initialCategory },\n\t\t\t);\n\t\t\thandle = showFullPaneOverlay(this.host.ui, selector, 78);\n\t\t});\n\t}\n\n\tloginProvider(providerOption: AuthSelectorProvider): Promise<AuthenticationResult> {\n\t\tconst kind = providerOption.category === \"service\" ? \"service\" : \"provider\";\n\t\tif (providerOption.authType === \"oauth\") {\n\t\t\treturn this.showLoginDialog(providerOption.id, providerOption.name, kind);\n\t\t}\n\t\tif (providerOption.id === PRIME_INFERENCE_PROVIDER_ID) {\n\t\t\treturn this.runPrimeInferenceLogin();\n\t\t}\n\t\tif (providerOption.id === BEDROCK_PROVIDER_ID) {\n\t\t\treturn this.showBedrockSetupDialog(providerOption.id, providerOption.name);\n\t\t}\n\t\treturn this.showApiKeyLoginDialog(providerOption.id, providerOption.name, kind);\n\t}\n\n\trunLogout(): Promise<string | null> {\n\t\tconst providerOptions = this.getLogoutProviderOptions();\n\t\tif (providerOptions.length === 0) {\n\t\t\tthis.host.showStatus(\n\t\t\t\t\"No stored credentials to remove. /logout only removes credentials saved by /login; environment variables and models.json config are unchanged.\",\n\t\t\t);\n\t\t\treturn Promise.resolve(null);\n\t\t}\n\n\t\treturn new Promise((resolve) => {\n\t\t\tlet handle: OverlayHandle | undefined;\n\t\t\tconst close = () => {\n\t\t\t\thandle?.hide();\n\t\t\t\tthis.host.ui.requestRender();\n\t\t\t};\n\t\t\tconst selector = new OAuthSelectorComponent(\n\t\t\t\t\"logout\",\n\t\t\t\tthis.host.modelRegistry.authStorage,\n\t\t\t\tproviderOptions,\n\t\t\t\tasync (providerOption: AuthSelectorProvider) => {\n\t\t\t\t\tclose();\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tthis.host.modelRegistry.authStorage.logout(providerOption.id);\n\t\t\t\t\t\tthis.host.modelRegistry.refresh();\n\t\t\t\t\t\tawait this.host.onAuthChanged?.();\n\t\t\t\t\t\tconst message =\n\t\t\t\t\t\t\tproviderOption.authType === \"oauth\"\n\t\t\t\t\t\t\t\t? `Logged out of ${providerOption.name}`\n\t\t\t\t\t\t\t\t: `Removed stored API key for ${providerOption.name}. Environment variables and models.json config are unchanged.`;\n\t\t\t\t\t\tthis.host.showStatus(message);\n\t\t\t\t\t\tresolve(providerOption.id);\n\t\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\t\tthis.host.showError(`Logout failed: ${error instanceof Error ? error.message : String(error)}`);\n\t\t\t\t\t\tresolve(null);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tclose();\n\t\t\t\t\tresolve(null);\n\t\t\t\t},\n\t\t\t\tundefined,\n\t\t\t\t{ getRows: () => this.host.ui.terminal.rows },\n\t\t\t);\n\t\t\thandle = showFullPaneOverlay(this.host.ui, selector, 78);\n\t\t});\n\t}\n\n\tgetLoginProviderOptions(authType?: \"oauth\" | \"api_key\"): AuthSelectorProvider[] {\n\t\tconst authStorage = this.host.modelRegistry.authStorage;\n\t\tif (authType === \"api_key\") {\n\t\t\treturn [];\n\t\t}\n\t\tconst oauthProviders = authStorage\n\t\t\t.getOAuthProviders()\n\t\t\t.filter((provider) => ASM_AGENT_LOGIN_PROVIDER_IDS.has(provider.id));\n\t\tconst options: AuthSelectorProvider[] = oauthProviders.map((provider) => ({\n\t\t\tid: provider.id,\n\t\t\tname: provider.name,\n\t\t\tauthType: \"oauth\",\n\t\t}));\n\n\t\treturn options.sort(compareAuthSelectorProviders);\n\t}\n\n\tprivate getLogoutProviderOptions(): AuthSelectorProvider[] {\n\t\tconst authStorage = this.host.modelRegistry.authStorage;\n\t\tconst options: AuthSelectorProvider[] = [];\n\n\t\tconst oauthProvidersById = new Map(authStorage.getOAuthProviders().map((p) => [p.id, p]));\n\t\tfor (const providerId of authStorage.list()) {\n\t\t\tconst credential = authStorage.get(providerId);\n\t\t\tif (!credential) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst isSerper = providerId === SERPER_CREDENTIAL_ID;\n\t\t\tconst isMcp = providerId.startsWith(\"mcp:\");\n\t\t\tconst name = isSerper\n\t\t\t\t? SERPER_CREDENTIAL_NAME\n\t\t\t\t: isMcp\n\t\t\t\t\t? (oauthProvidersById.get(providerId)?.name ?? providerId.slice(\"mcp:\".length))\n\t\t\t\t\t: this.host.modelRegistry.getProviderDisplayName(providerId);\n\t\t\toptions.push({\n\t\t\t\tid: providerId,\n\t\t\t\tname,\n\t\t\t\tauthType: credential.type,\n\t\t\t\tcategory: isSerper || isMcp ? \"service\" : \"provider\",\n\t\t\t});\n\t\t}\n\n\t\tif (!options.some((option) => option.id === PRIME_INFERENCE_PROVIDER_ID)) {\n\t\t\tconst primeInferenceStatus = authStorage.getAuthStatus(PRIME_INFERENCE_PROVIDER_ID);\n\t\t\tif (primeInferenceStatus.source === \"prime_cli\") {\n\t\t\t\toptions.push({\n\t\t\t\t\tid: PRIME_INFERENCE_PROVIDER_ID,\n\t\t\t\t\tname: PRIME_INFERENCE_PROVIDER_NAME,\n\t\t\t\t\tauthType: \"api_key\",\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn options.sort((a, b) => a.name.localeCompare(b.name));\n\t}\n\n\tprivate async completeProviderAuthentication(\n\t\tproviderId: string,\n\t\tproviderName: string,\n\t\tauthType: \"oauth\" | \"api_key\",\n\t\tstatusSuffix?: string,\n\t\tkind: \"provider\" | \"service\" = \"provider\",\n\t\tcredentialPath: string = getAuthPath(),\n\t): Promise<AuthenticationResult> {\n\t\tthis.host.modelRegistry.refresh();\n\n\t\tconst actionLabel = authType === \"oauth\" ? `Logged in to ${providerName}` : `Saved API key for ${providerName}`;\n\t\tawait this.host.onAuthChanged?.();\n\t\tthis.host.showStatus(\n\t\t\t`${actionLabel}. Credentials saved to ${credentialPath}${statusSuffix ? `. ${statusSuffix}` : \"\"}`,\n\t\t);\n\t\tthis.host.onLoginCompleted?.();\n\t\treturn {\n\t\t\tstatus: \"success\",\n\t\t\tproviderId,\n\t\t\tproviderName,\n\t\t\tauthType,\n\t\t\tkind,\n\t\t};\n\t}\n\n\tprivate async completeExternalProviderSetup(\n\t\tproviderId: string,\n\t\tproviderName: string,\n\t): Promise<AuthenticationResult> {\n\t\tthis.host.modelRegistry.refresh();\n\t\tawait this.host.onAuthChanged?.();\n\t\tthis.host.showStatus(`${providerName} uses external credentials. Select a model after configuring them.`);\n\t\treturn {\n\t\t\tstatus: \"success\",\n\t\t\tproviderId,\n\t\t\tproviderName,\n\t\t\tauthType: \"api_key\",\n\t\t};\n\t}\n\n\tprivate async hasAvailableProviderModels(providerId: string): Promise<boolean> {\n\t\tconst models = await this.host.getAvailableModels();\n\t\treturn models.some((model) => model.provider === providerId);\n\t}\n\n\tprivate async showBedrockSetupDialog(providerId: string, providerName: string): Promise<AuthenticationResult> {\n\t\tconst dialog = new LoginDialogComponent(this.host.ui, providerId, () => {}, providerName, \"Amazon Bedrock setup\");\n\t\tconst handle = showFullPaneOverlay(this.host.ui, dialog, 88);\n\t\tconst closeDialog = () => {\n\t\t\thandle.hide();\n\t\t\tthis.host.ui.requestRender();\n\t\t};\n\n\t\ttry {\n\t\t\tawait dialog.showContinueInfo([\n\t\t\t\ttheme.fg(\"text\", \"Amazon Bedrock uses AWS credentials instead of a single API key.\"),\n\t\t\t\ttheme.fg(\"text\", \"Configure an AWS profile, IAM keys, bearer token, or role-based credentials.\"),\n\t\t\t\ttheme.fg(\"muted\", \"See:\"),\n\t\t\t\ttheme.fg(\"accent\", ` ${path.join(getDocsPath(), \"providers.md\")}`),\n\t\t\t]);\n\t\t\tcloseDialog();\n\t\t\tif (!(await this.hasAvailableProviderModels(providerId))) {\n\t\t\t\tthis.host.showStatus(`${providerName} credentials were not detected. Configure them, then reopen /model.`);\n\t\t\t\treturn { status: \"cancelled\" };\n\t\t\t}\n\t\t\treturn await this.completeExternalProviderSetup(providerId, providerName);\n\t\t} catch (error: unknown) {\n\t\t\tcloseDialog();\n\t\t\tconst errorMsg = error instanceof Error ? error.message : String(error);\n\t\t\tif (errorMsg !== \"Login cancelled\") {\n\t\t\t\tthis.host.showError(`Failed to set up ${providerName}: ${errorMsg}`);\n\t\t\t\treturn { status: \"failed\" };\n\t\t\t}\n\t\t\treturn { status: \"cancelled\" };\n\t\t}\n\t}\n\n\tprivate showPrimeTeamSelector(\n\t\tteams: PrimeTeam[],\n\t\tcurrentTeamId: string | undefined,\n\t): Promise<PrimeTeam | null | undefined> {\n\t\treturn new Promise((resolve) => {\n\t\t\tlet handle: OverlayHandle | undefined;\n\t\t\tconst close = () => {\n\t\t\t\thandle?.hide();\n\t\t\t\tthis.host.ui.requestRender();\n\t\t\t};\n\t\t\tconst selector = new PrimeTeamSelectorComponent(\n\t\t\t\tteams,\n\t\t\t\tcurrentTeamId,\n\t\t\t\t(team) => {\n\t\t\t\t\tclose();\n\t\t\t\t\tresolve(team);\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tclose();\n\t\t\t\t\tresolve(undefined);\n\t\t\t\t},\n\t\t\t\t{ getRows: () => this.host.ui.terminal.rows },\n\t\t\t);\n\t\t\thandle = showFullPaneOverlay(this.host.ui, selector, 78);\n\t\t});\n\t}\n\n\tprivate getPrimeInferenceDefaultTeamStatus(): string {\n\t\tconst configPath = this.host.modelRegistry.authStorage.getPrimeCliConfigPath();\n\t\tif (configPath) {\n\t\t\tlet config: ReturnType<typeof loadPrimeCliConfig>;\n\t\t\ttry {\n\t\t\t\tconfig = loadPrimeCliConfig(configPath);\n\t\t\t} catch {\n\t\t\t\treturn \"Using personal account.\";\n\t\t\t}\n\t\t\tif (config.teamIdFromEnv) {\n\t\t\t\treturn \"Using team from PRIME_TEAM_ID.\";\n\t\t\t}\n\t\t\tif (config.teamName) {\n\t\t\t\treturn `Using team \"${config.teamName}\".`;\n\t\t\t}\n\t\t\tif (config.teamId) {\n\t\t\t\treturn \"Using Prime CLI team.\";\n\t\t\t}\n\t\t}\n\t\tconst storedTeam = this.host.modelRegistry.authStorage.getPrimeInferenceTeamSelection();\n\t\tif (storedTeam) {\n\t\t\treturn `Using team \"${storedTeam.name}\".`;\n\t\t}\n\t\tif (storedTeam === null) {\n\t\t\treturn \"Using personal account.\";\n\t\t}\n\t\treturn \"Using personal account.\";\n\t}\n\n\tprivate async selectPrimeInferenceTeam(apiKey: string, dialog: LoginDialogComponent): Promise<string | undefined> {\n\t\ttry {\n\t\t\tconst config = loadPrimeCliConfig(this.host.modelRegistry.authStorage.getPrimeCliConfigPath());\n\t\t\tif (config.teamIdFromEnv) {\n\t\t\t\tthis.host.modelRegistry.authStorage.reload();\n\t\t\t\treturn \"Using team from PRIME_TEAM_ID.\";\n\t\t\t}\n\n\t\t\tdialog.showProgress(\"Loading Prime teams...\");\n\t\t\tconst teams = await fetchPrimeTeams(apiKey, config.baseUrl, { signal: dialog.signal });\n\t\t\tif (dialog.signal.aborted) {\n\t\t\t\treturn this.getPrimeInferenceDefaultTeamStatus();\n\t\t\t}\n\t\t\tif (teams.length === 0) {\n\t\t\t\tthis.host.modelRegistry.authStorage.setPrimeInferenceTeamSelection(null);\n\t\t\t\treturn \"Using personal account.\";\n\t\t\t}\n\n\t\t\tconst storedTeam = this.host.modelRegistry.authStorage.getPrimeInferenceTeamSelection();\n\t\t\tconst currentTeamId = storedTeam === null ? undefined : (storedTeam?.teamId ?? config.teamId);\n\t\t\tconst selectedTeam = await this.showPrimeTeamSelector(teams, currentTeamId);\n\t\t\tif (selectedTeam !== undefined) {\n\t\t\t\tthis.host.modelRegistry.authStorage.setPrimeInferenceTeamSelection(selectedTeam);\n\t\t\t}\n\t\t\treturn selectedTeam\n\t\t\t\t? `Using team \"${selectedTeam.name}\".`\n\t\t\t\t: selectedTeam === null\n\t\t\t\t\t? \"Using personal account.\"\n\t\t\t\t\t: this.getPrimeInferenceDefaultTeamStatus();\n\t\t} catch {\n\t\t\tthis.host.modelRegistry.authStorage.reload();\n\t\t\treturn this.getPrimeInferenceDefaultTeamStatus();\n\t\t}\n\t}\n\n\tprivate async completePrimeInferenceLogin(\n\t\tapiKey: string,\n\t\tdialog: LoginDialogComponent,\n\t\tcloseDialog: () => void,\n\t): Promise<AuthenticationResult> {\n\t\tthis.host.modelRegistry.authStorage.setPrimeInferenceApiKey(apiKey);\n\t\tconst teamStatus = await this.selectPrimeInferenceTeam(apiKey, dialog);\n\n\t\tcloseDialog();\n\t\treturn await this.completeProviderAuthentication(\n\t\t\tPRIME_INFERENCE_PROVIDER_ID,\n\t\t\tPRIME_INFERENCE_PROVIDER_NAME,\n\t\t\t\"api_key\",\n\t\t\tteamStatus,\n\t\t\t\"provider\",\n\t\t\tthis.host.modelRegistry.authStorage.getPrimeCliConfigPath() ?? getAuthPath(),\n\t\t);\n\t}\n\n\tasync runPrimeInferenceLogin(): Promise<AuthenticationResult> {\n\t\tconst dialog = new LoginDialogComponent(\n\t\t\tthis.host.ui,\n\t\t\tPRIME_INFERENCE_PROVIDER_ID,\n\t\t\t(_success, _message) => {},\n\t\t\tPRIME_INFERENCE_PROVIDER_NAME,\n\t\t);\n\n\t\tconst handle = showFullPaneOverlay(this.host.ui, dialog, {\n\t\t\tmaxContentWidth: 88,\n\t\t\tsuspendFullscreenMouse: true,\n\t\t});\n\n\t\tconst closeDialog = () => {\n\t\t\thandle.hide();\n\t\t\tthis.host.ui.requestRender();\n\t\t};\n\n\t\t// The browser challenge gets its own controller so a manually pasted key\n\t\t// can stop the polling without tearing down the dialog.\n\t\tconst browserAbort = new AbortController();\n\t\tconst onDialogAbort = () => browserAbort.abort();\n\t\tdialog.signal.addEventListener(\"abort\", onDialogAbort, { once: true });\n\n\t\tlet manualInputArmed = false;\n\t\tlet resolveManualKey: (entry: { apiKey: string; source: \"manual\" }) => void = () => {};\n\t\tconst manualKeyEntry = new Promise<{ apiKey: string; source: \"manual\" }>((resolve) => {\n\t\t\tresolveManualKey = resolve;\n\t\t});\n\t\tconst armManualInput = (prompt: string): void => {\n\t\t\tmanualInputArmed = true;\n\t\t\tvoid (async () => {\n\t\t\t\tlet value = (await dialog.showManualInput(prompt)).trim();\n\t\t\t\twhile (!value) {\n\t\t\t\t\tvalue = (await dialog.waitForInput()).trim();\n\t\t\t\t}\n\t\t\t\tresolveManualKey({ apiKey: value, source: \"manual\" });\n\t\t\t})().catch(() => {\n\t\t\t\t// Cancellation surfaces through the dialog signal.\n\t\t\t});\n\t\t};\n\n\t\ttry {\n\t\t\tconst browserLogin = loginPrimeInference(\n\t\t\t\t{\n\t\t\t\t\tonAuth: (info) => {\n\t\t\t\t\t\tdialog.showAuth(info.url, info.instructions);\n\t\t\t\t\t\tarmManualInput(\"Complete the sign-in in your browser, or paste an API key below:\");\n\t\t\t\t\t},\n\t\t\t\t\tonProgress: (message) => {\n\t\t\t\t\t\tdialog.showProgress(message);\n\t\t\t\t\t},\n\t\t\t\t\tsignal: browserAbort.signal,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tconfigPath: this.host.modelRegistry.authStorage.getPrimeCliConfigPath(),\n\t\t\t\t},\n\t\t\t);\n\t\t\t// When the browser challenge cannot start or breaks down, keep the dialog\n\t\t\t// open and fall back to plain API key entry instead of failing outright.\n\t\t\tconst browserLoginOrFallback = browserLogin.catch((error: unknown) => {\n\t\t\t\tif (browserAbort.signal.aborted) {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t\tconst errorMsg = error instanceof Error ? error.message : String(error);\n\t\t\t\tdialog.showProgress(`Browser sign-in unavailable (${errorMsg}).`);\n\t\t\t\tif (!manualInputArmed) {\n\t\t\t\t\tarmManualInput(\"Paste a Prime API key below:\");\n\t\t\t\t}\n\t\t\t\treturn manualKeyEntry;\n\t\t\t});\n\t\t\t// Once the browser flow has settled into manual fallback, nothing above\n\t\t\t// rejects on cancel anymore, so the dialog signal must end the race too.\n\t\t\tconst dialogCancelled = new Promise<never>((_, reject) => {\n\t\t\t\tdialog.signal.addEventListener(\"abort\", () => reject(new Error(\"Login cancelled\")), { once: true });\n\t\t\t});\n\t\t\t// Promise.race observes the rejections below, but keep dedicated handlers\n\t\t\t// so neither an aborted browser flow nor a cancelled dialog can surface\n\t\t\t// as an unhandled rejection.\n\t\t\tbrowserLoginOrFallback.catch(() => {});\n\t\t\tdialogCancelled.catch(() => {});\n\n\t\t\tconst result = await Promise.race([browserLoginOrFallback, manualKeyEntry, dialogCancelled]);\n\t\t\tif (dialog.signal.aborted) {\n\t\t\t\tcloseDialog();\n\t\t\t\treturn { status: \"cancelled\" };\n\t\t\t}\n\n\t\t\tif (result.source === \"manual\") {\n\t\t\t\tbrowserAbort.abort();\n\t\t\t\tdialog.showProgress(\"Checking Prime Inference access...\");\n\t\t\t\tconst config = loadPrimeCliConfig(this.host.modelRegistry.authStorage.getPrimeCliConfigPath());\n\t\t\t\tconst access = await checkPrimeInferenceAccess(result.apiKey, config.baseUrl, { signal: dialog.signal });\n\t\t\t\tif (dialog.signal.aborted) {\n\t\t\t\t\tcloseDialog();\n\t\t\t\t\treturn { status: \"cancelled\" };\n\t\t\t\t}\n\t\t\t\tif (!access.ok) {\n\t\t\t\t\tconst status = access.status === undefined ? \"\" : `HTTP ${access.status}: `;\n\t\t\t\t\tthrow new Error(`Prime API key does not have Prime Inference access (${status}${access.message})`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn await this.completePrimeInferenceLogin(result.apiKey, dialog, closeDialog);\n\t\t} catch (error: unknown) {\n\t\t\tcloseDialog();\n\t\t\tconst errorMsg = error instanceof Error ? error.message : String(error);\n\t\t\tif (!dialog.signal.aborted && errorMsg !== \"Login cancelled\") {\n\t\t\t\tthis.host.showError(`Failed to login to ${PRIME_INFERENCE_PROVIDER_NAME}: ${errorMsg}`);\n\t\t\t\treturn { status: \"failed\" };\n\t\t\t}\n\t\t\treturn { status: \"cancelled\" };\n\t\t} finally {\n\t\t\tdialog.signal.removeEventListener(\"abort\", onDialogAbort);\n\t\t}\n\t}\n\n\tprivate async showApiKeyLoginDialog(\n\t\tproviderId: string,\n\t\tproviderName: string,\n\t\tkind: \"provider\" | \"service\" = \"provider\",\n\t): Promise<AuthenticationResult> {\n\t\tconst dialog = new LoginDialogComponent(this.host.ui, providerId, (_success, _message) => {}, providerName);\n\n\t\tconst handle = showFullPaneOverlay(this.host.ui, dialog, 88);\n\n\t\tconst closeDialog = () => {\n\t\t\thandle.hide();\n\t\t\tthis.host.ui.requestRender();\n\t\t};\n\n\t\ttry {\n\t\t\tconst apiKey = (await dialog.showPrompt(\"Enter API key:\")).trim();\n\t\t\tif (!apiKey) {\n\t\t\t\tthrow new Error(\"API key cannot be empty.\");\n\t\t\t}\n\n\t\t\tthis.host.modelRegistry.authStorage.set(providerId, { type: \"api_key\", key: apiKey });\n\n\t\t\tcloseDialog();\n\t\t\treturn await this.completeProviderAuthentication(providerId, providerName, \"api_key\", undefined, kind);\n\t\t} catch (error: unknown) {\n\t\t\tcloseDialog();\n\t\t\tconst errorMsg = error instanceof Error ? error.message : String(error);\n\t\t\tif (errorMsg !== \"Login cancelled\") {\n\t\t\t\tthis.host.showError(`Failed to save API key for ${providerName}: ${errorMsg}`);\n\t\t\t\treturn { status: \"failed\" };\n\t\t\t}\n\t\t\treturn { status: \"cancelled\" };\n\t\t}\n\t}\n\n\tprivate showOAuthLoginSelect(dialogHandle: OverlayHandle, prompt: OAuthSelectPrompt): Promise<string | undefined> {\n\t\treturn new Promise((resolve) => {\n\t\t\tdialogHandle.setHidden(true);\n\t\t\tlet selectorHandle: OverlayHandle | undefined;\n\t\t\tconst restoreDialog = () => {\n\t\t\t\tselectorHandle?.hide();\n\t\t\t\tdialogHandle.setHidden(false);\n\t\t\t\tdialogHandle.focus();\n\t\t\t\tthis.host.ui.requestRender();\n\t\t\t};\n\t\t\tconst labels = prompt.options.map((option) => option.label);\n\t\t\tconst selector = new ExtensionSelectorComponent(\n\t\t\t\tprompt.message,\n\t\t\t\tlabels,\n\t\t\t\t(optionLabel) => {\n\t\t\t\t\trestoreDialog();\n\t\t\t\t\tresolve(prompt.options.find((option) => option.label === optionLabel)?.id);\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\trestoreDialog();\n\t\t\t\t\tresolve(undefined);\n\t\t\t\t},\n\t\t\t\t{ getRows: () => this.host.ui.terminal.rows },\n\t\t\t);\n\t\t\tselectorHandle = showFullPaneOverlay(this.host.ui, selector, 76);\n\t\t});\n\t}\n\n\tprivate async showLoginDialog(\n\t\tproviderId: string,\n\t\tproviderName: string,\n\t\tkind: \"provider\" | \"service\" = \"provider\",\n\t): Promise<AuthenticationResult> {\n\t\tconst providerInfo = this.host.modelRegistry.authStorage\n\t\t\t.getOAuthProviders()\n\t\t\t.find((provider) => provider.id === providerId);\n\n\t\tconst usesCallbackServer = providerInfo?.usesCallbackServer ?? false;\n\n\t\tconst dialog = new LoginDialogComponent(this.host.ui, providerId, (_success, _message) => {}, providerName);\n\n\t\tconst dialogHandle = showFullPaneOverlay(this.host.ui, dialog, {\n\t\t\tmaxContentWidth: 88,\n\t\t\tsuspendFullscreenMouse: true,\n\t\t});\n\n\t\tlet manualCodeResolve: ((code: string) => void) | undefined;\n\t\tlet manualCodeReject: ((err: Error) => void) | undefined;\n\t\tconst manualCodePromise = new Promise<string>((resolve, reject) => {\n\t\t\tmanualCodeResolve = resolve;\n\t\t\tmanualCodeReject = reject;\n\t\t});\n\n\t\tconst closeDialog = () => {\n\t\t\tdialogHandle.hide();\n\t\t\tthis.host.ui.requestRender();\n\t\t};\n\n\t\ttry {\n\t\t\tawait this.host.modelRegistry.authStorage.login(providerId as OAuthProviderId, {\n\t\t\t\tonAuth: (info: { url: string; instructions?: string }) => {\n\t\t\t\t\tdialog.showAuth(info.url, info.instructions);\n\n\t\t\t\t\tif (usesCallbackServer) {\n\t\t\t\t\t\tdialog\n\t\t\t\t\t\t\t.showManualInput(\"Paste redirect URL below, or complete login in browser:\")\n\t\t\t\t\t\t\t.then((value) => {\n\t\t\t\t\t\t\t\tif (value && manualCodeResolve) {\n\t\t\t\t\t\t\t\t\tmanualCodeResolve(value);\n\t\t\t\t\t\t\t\t\tmanualCodeResolve = undefined;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.catch(() => {\n\t\t\t\t\t\t\t\tif (manualCodeReject) {\n\t\t\t\t\t\t\t\t\tmanualCodeReject(new Error(\"Login cancelled\"));\n\t\t\t\t\t\t\t\t\tmanualCodeReject = undefined;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t} else if (providerId === \"github-copilot\") {\n\t\t\t\t\t\tdialog.showWaiting(\"Waiting for browser authentication...\");\n\t\t\t\t\t}\n\t\t\t\t},\n\n\t\t\t\tonPrompt: async (prompt: { message: string; placeholder?: string }) => {\n\t\t\t\t\treturn dialog.showPrompt(prompt.message, prompt.placeholder);\n\t\t\t\t},\n\n\t\t\t\tonProgress: (message: string) => {\n\t\t\t\t\tdialog.showProgress(message);\n\t\t\t\t},\n\n\t\t\t\tonSelect: (prompt: OAuthSelectPrompt) => this.showOAuthLoginSelect(dialogHandle, prompt),\n\n\t\t\t\tonManualCodeInput: () => manualCodePromise,\n\n\t\t\t\tsignal: dialog.signal,\n\t\t\t});\n\n\t\t\tcloseDialog();\n\t\t\treturn await this.completeProviderAuthentication(providerId, providerName, \"oauth\", undefined, kind);\n\t\t} catch (error: unknown) {\n\t\t\tcloseDialog();\n\t\t\tconst errorMsg = error instanceof Error ? error.message : String(error);\n\t\t\tif (errorMsg !== \"Login cancelled\") {\n\t\t\t\tthis.host.showError(`Failed to login to ${providerName}: ${errorMsg}`);\n\t\t\t\treturn { status: \"failed\" };\n\t\t\t}\n\t\t\treturn { status: \"cancelled\" };\n\t\t}\n\t}\n}\n"]}
|
|
@@ -11,7 +11,7 @@ import { compareAuthSelectorProviders, OAuthSelectorComponent, } from "./compone
|
|
|
11
11
|
import { PrimeTeamSelectorComponent } from "./components/prime-team-selector.js";
|
|
12
12
|
import { theme } from "./theme/theme.js";
|
|
13
13
|
export const BEDROCK_PROVIDER_ID = "amazon-bedrock";
|
|
14
|
-
export const ASM_AGENT_LOGIN_PROVIDER_IDS = new Set(["openai-codex", "anthropic"]);
|
|
14
|
+
export const ASM_AGENT_LOGIN_PROVIDER_IDS = new Set(["openai-codex", "anthropic", "google", "gemini"]);
|
|
15
15
|
export const ANTHROPIC_SUBSCRIPTION_AUTH_WARNING = "Anthropic subscription auth is active. Third-party harness usage draws from extra usage and is billed per token, not your Claude plan limits. Manage extra usage at https://claude.ai/settings/usage.";
|
|
16
16
|
function isAnthropicSubscriptionAuthKey(apiKey) {
|
|
17
17
|
return typeof apiKey === "string" && apiKey.startsWith("sk-ant-oat");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-flows.js","sourceRoot":"","sources":["../../../src/modes/interactive/auth-flows.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,E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M,CAAC;gBAExF,iBAAiB,EAAE,GAAG,EAAE,CAAC,iBAAiB;gBAE1C,MAAM,EAAE,MAAM,CAAC,MAAM;aACrB,CAAC,CAAC;YAEH,WAAW,EAAE,CAAC;YACd,OAAO,MAAM,IAAI,CAAC,8BAA8B,CAAC,UAAU,EAAE,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;QACtG,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACzB,WAAW,EAAE,CAAC;YACd,MAAM,QAAQ,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACxE,IAAI,QAAQ,KAAK,iBAAiB,EAAE,CAAC;gBACpC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,sBAAsB,YAAY,KAAK,QAAQ,EAAE,CAAC,CAAC;gBACvE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;YAC7B,CAAC;YACD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;QAChC,CAAC;IAAA,CACD;CACD","sourcesContent":["import * as path from \"node:path\";\nimport { getProviders, type OAuthProviderId, type OAuthSelectPrompt } from \"@asm-agent/ai\";\nimport type { OverlayHandle, TUI } from \"@asm-agent/tui\";\nimport { getAuthPath, getDocsPath } from \"../../config.js\";\nimport type { ModelRegistry } from \"../../core/model-registry.js\";\nimport {\n\tcheckPrimeInferenceAccess,\n\tfetchPrimeTeams,\n\tloadPrimeCliConfig,\n\tloginPrimeInference,\n\tPRIME_INFERENCE_PROVIDER_ID,\n\tPRIME_INFERENCE_PROVIDER_NAME,\n\ttype PrimeTeam,\n} from \"../../core/prime-inference-auth.js\";\nimport { BUILT_IN_PROVIDER_DISPLAY_NAMES } from \"../../core/provider-display-names.js\";\nimport { SERPER_CREDENTIAL_ID, SERPER_CREDENTIAL_NAME } from \"../../core/websearch-credential.js\";\nimport { showFullPaneOverlay } from \"./components/centered-overlay.js\";\nimport { ExtensionSelectorComponent } from \"./components/extension-selector.js\";\nimport { LoginDialogComponent } from \"./components/login-dialog.js\";\nimport {\n\ttype AuthSelectorCategory,\n\ttype AuthSelectorProvider,\n\tcompareAuthSelectorProviders,\n\tOAuthSelectorComponent,\n} from \"./components/oauth-selector.js\";\nimport { PrimeTeamSelectorComponent } from \"./components/prime-team-selector.js\";\nimport { theme } from \"./theme/theme.js\";\n\nexport type AuthenticationResult =\n\t| {\n\t\t\tstatus: \"success\";\n\t\t\tproviderId: string;\n\t\t\tproviderName: string;\n\t\t\tauthType: \"oauth\" | \"api_key\";\n\t\t\t/** \"service\" credentials (e.g. web search) don't affect model selection. */\n\t\t\tkind?: \"provider\" | \"service\";\n\t }\n\t| { status: \"cancelled\" }\n\t| { status: \"failed\" };\n\nexport const BEDROCK_PROVIDER_ID = \"amazon-bedrock\";\nexport const ASM_AGENT_LOGIN_PROVIDER_IDS = new Set([\"openai-codex\", \"anthropic\"]);\n\nexport const ANTHROPIC_SUBSCRIPTION_AUTH_WARNING =\n\t\"Anthropic subscription auth is active. Third-party harness usage draws from extra usage and is billed per token, not your Claude plan limits. Manage extra usage at https://claude.ai/settings/usage.\";\n\nfunction isAnthropicSubscriptionAuthKey(apiKey: string | undefined): boolean {\n\treturn typeof apiKey === \"string\" && apiKey.startsWith(\"sk-ant-oat\");\n}\n\nexport async function getAnthropicSubscriptionAuthWarning(\n\tmodelRegistry: ModelRegistry,\n\tmodel: { provider: string } | undefined,\n): Promise<string | undefined> {\n\tif (!model || model.provider !== \"anthropic\") {\n\t\treturn undefined;\n\t}\n\n\tconst storedCredential = modelRegistry.authStorage.get(\"anthropic\");\n\tif (storedCredential?.type === \"oauth\") {\n\t\treturn ANTHROPIC_SUBSCRIPTION_AUTH_WARNING;\n\t}\n\n\ttry {\n\t\tconst apiKey = await modelRegistry.getApiKeyForProvider(model.provider);\n\t\tif (isAnthropicSubscriptionAuthKey(apiKey)) {\n\t\t\treturn ANTHROPIC_SUBSCRIPTION_AUTH_WARNING;\n\t\t}\n\t} catch {\n\t\t// Ignore auth lookup failures for warning-only checks.\n\t}\n\treturn undefined;\n}\n\nconst BUILT_IN_MODEL_PROVIDERS = new Set<string>(getProviders());\n\nexport function isApiKeyLoginProvider(\n\tproviderId: string,\n\toauthProviderIds: ReadonlySet<string>,\n\tbuiltInProviderIds: ReadonlySet<string> = BUILT_IN_MODEL_PROVIDERS,\n): boolean {\n\tif (BUILT_IN_PROVIDER_DISPLAY_NAMES[providerId]) {\n\t\treturn true;\n\t}\n\tif (builtInProviderIds.has(providerId)) {\n\t\treturn false;\n\t}\n\treturn !oauthProviderIds.has(providerId);\n}\n\nexport interface ProviderAuthFlowsHost {\n\treadonly ui: TUI;\n\treadonly modelRegistry: ModelRegistry;\n\tshowStatus(message: string): void;\n\tshowError(message: string): void;\n\t/** Models currently visible to the host; used to detect providers configured via external credentials. */\n\tgetAvailableModels(): Promise<ReadonlyArray<{ provider: string }>>;\n\t/** Invoked after stored credentials change so the host can refresh dependent UI. */\n\tonAuthChanged?(): void | Promise<void>;\n\t/** Invoked after a successful login (e.g. to surface billing warnings). */\n\tonLoginCompleted?(): void;\n}\n\nexport interface ProviderLoginOptions {\n\tauthType?: \"oauth\" | \"api_key\";\n\tinitialCategory?: AuthSelectorCategory;\n}\n\n/** Shared auth dialogs: host-specific refresh and billing effects remain outside the flow. */\nexport class ProviderAuthFlows {\n\tconstructor(private readonly host: ProviderAuthFlowsHost) {}\n\n\t/**\n\t * Run the OAuth login flow for an MCP integration server.\n\t *\n\t * The provider must already be registered (the McpManager does this as\n\t * `mcp:<server>`). On success the credentials land in auth.json and the\n\t * caller should reload resources so the integration's skill enables.\n\t */\n\trunMcpLogin(server: string, label?: string): Promise<AuthenticationResult> {\n\t\tconst providerId = `mcp:${server}`;\n\t\tconst provider = this.host.modelRegistry.authStorage.getOAuthProviders().find((p) => p.id === providerId);\n\t\tif (!provider) {\n\t\t\tthis.host.showError(`Unknown MCP integration: ${server}`);\n\t\t\treturn Promise.resolve({ status: \"failed\" });\n\t\t}\n\t\treturn this.showLoginDialog(providerId, label ?? provider.name, \"service\");\n\t}\n\n\trunLogin(options: ProviderLoginOptions = {}): Promise<AuthenticationResult> {\n\t\tconst { authType, initialCategory } = options;\n\t\tconst providerOptions = this.getLoginProviderOptions(authType);\n\t\tif (providerOptions.length === 0) {\n\t\t\tthis.host.showStatus(\n\t\t\t\tauthType === \"oauth\"\n\t\t\t\t\t? \"No subscription providers available.\"\n\t\t\t\t\t: authType === \"api_key\"\n\t\t\t\t\t\t? \"No API key providers available.\"\n\t\t\t\t\t\t: \"No providers available.\",\n\t\t\t);\n\t\t\treturn Promise.resolve({ status: \"failed\" });\n\t\t}\n\n\t\treturn new Promise((resolve) => {\n\t\t\tlet handle: OverlayHandle | undefined;\n\t\t\tconst close = () => {\n\t\t\t\thandle?.hide();\n\t\t\t\tthis.host.ui.requestRender();\n\t\t\t};\n\t\t\tconst selector = new OAuthSelectorComponent(\n\t\t\t\t\"login\",\n\t\t\t\tthis.host.modelRegistry.authStorage,\n\t\t\t\tproviderOptions,\n\t\t\t\tasync (providerOption: AuthSelectorProvider) => {\n\t\t\t\t\tclose();\n\t\t\t\t\tresolve(await this.loginProvider(providerOption));\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tclose();\n\t\t\t\t\tresolve({ status: \"cancelled\" });\n\t\t\t\t},\n\t\t\t\t(providerId) => this.host.modelRegistry.getProviderAuthStatus(providerId),\n\t\t\t\t{ getRows: () => this.host.ui.terminal.rows, initialCategory },\n\t\t\t);\n\t\t\thandle = showFullPaneOverlay(this.host.ui, selector, 78);\n\t\t});\n\t}\n\n\tloginProvider(providerOption: AuthSelectorProvider): Promise<AuthenticationResult> {\n\t\tconst kind = providerOption.category === \"service\" ? \"service\" : \"provider\";\n\t\tif (providerOption.authType === \"oauth\") {\n\t\t\treturn this.showLoginDialog(providerOption.id, providerOption.name, kind);\n\t\t}\n\t\tif (providerOption.id === PRIME_INFERENCE_PROVIDER_ID) {\n\t\t\treturn this.runPrimeInferenceLogin();\n\t\t}\n\t\tif (providerOption.id === BEDROCK_PROVIDER_ID) {\n\t\t\treturn this.showBedrockSetupDialog(providerOption.id, providerOption.name);\n\t\t}\n\t\treturn this.showApiKeyLoginDialog(providerOption.id, providerOption.name, kind);\n\t}\n\n\trunLogout(): Promise<string | null> {\n\t\tconst providerOptions = this.getLogoutProviderOptions();\n\t\tif (providerOptions.length === 0) {\n\t\t\tthis.host.showStatus(\n\t\t\t\t\"No stored credentials to remove. /logout only removes credentials saved by /login; environment variables and models.json config are unchanged.\",\n\t\t\t);\n\t\t\treturn Promise.resolve(null);\n\t\t}\n\n\t\treturn new Promise((resolve) => {\n\t\t\tlet handle: OverlayHandle | undefined;\n\t\t\tconst close = () => {\n\t\t\t\thandle?.hide();\n\t\t\t\tthis.host.ui.requestRender();\n\t\t\t};\n\t\t\tconst selector = new OAuthSelectorComponent(\n\t\t\t\t\"logout\",\n\t\t\t\tthis.host.modelRegistry.authStorage,\n\t\t\t\tproviderOptions,\n\t\t\t\tasync (providerOption: AuthSelectorProvider) => {\n\t\t\t\t\tclose();\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tthis.host.modelRegistry.authStorage.logout(providerOption.id);\n\t\t\t\t\t\tthis.host.modelRegistry.refresh();\n\t\t\t\t\t\tawait this.host.onAuthChanged?.();\n\t\t\t\t\t\tconst message =\n\t\t\t\t\t\t\tproviderOption.authType === \"oauth\"\n\t\t\t\t\t\t\t\t? `Logged out of ${providerOption.name}`\n\t\t\t\t\t\t\t\t: `Removed stored API key for ${providerOption.name}. Environment variables and models.json config are unchanged.`;\n\t\t\t\t\t\tthis.host.showStatus(message);\n\t\t\t\t\t\tresolve(providerOption.id);\n\t\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\t\tthis.host.showError(`Logout failed: ${error instanceof Error ? error.message : String(error)}`);\n\t\t\t\t\t\tresolve(null);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tclose();\n\t\t\t\t\tresolve(null);\n\t\t\t\t},\n\t\t\t\tundefined,\n\t\t\t\t{ getRows: () => this.host.ui.terminal.rows },\n\t\t\t);\n\t\t\thandle = showFullPaneOverlay(this.host.ui, selector, 78);\n\t\t});\n\t}\n\n\tgetLoginProviderOptions(authType?: \"oauth\" | \"api_key\"): AuthSelectorProvider[] {\n\t\tconst authStorage = this.host.modelRegistry.authStorage;\n\t\tif (authType === \"api_key\") {\n\t\t\treturn [];\n\t\t}\n\t\tconst oauthProviders = authStorage\n\t\t\t.getOAuthProviders()\n\t\t\t.filter((provider) => ASM_AGENT_LOGIN_PROVIDER_IDS.has(provider.id));\n\t\tconst options: AuthSelectorProvider[] = oauthProviders.map((provider) => ({\n\t\t\tid: provider.id,\n\t\t\tname: provider.name,\n\t\t\tauthType: \"oauth\",\n\t\t}));\n\n\t\treturn options.sort(compareAuthSelectorProviders);\n\t}\n\n\tprivate getLogoutProviderOptions(): AuthSelectorProvider[] {\n\t\tconst authStorage = this.host.modelRegistry.authStorage;\n\t\tconst options: AuthSelectorProvider[] = [];\n\n\t\tconst oauthProvidersById = new Map(authStorage.getOAuthProviders().map((p) => [p.id, p]));\n\t\tfor (const providerId of authStorage.list()) {\n\t\t\tconst credential = authStorage.get(providerId);\n\t\t\tif (!credential) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst isSerper = providerId === SERPER_CREDENTIAL_ID;\n\t\t\tconst isMcp = providerId.startsWith(\"mcp:\");\n\t\t\tconst name = isSerper\n\t\t\t\t? SERPER_CREDENTIAL_NAME\n\t\t\t\t: isMcp\n\t\t\t\t\t? (oauthProvidersById.get(providerId)?.name ?? providerId.slice(\"mcp:\".length))\n\t\t\t\t\t: this.host.modelRegistry.getProviderDisplayName(providerId);\n\t\t\toptions.push({\n\t\t\t\tid: providerId,\n\t\t\t\tname,\n\t\t\t\tauthType: credential.type,\n\t\t\t\tcategory: isSerper || isMcp ? \"service\" : \"provider\",\n\t\t\t});\n\t\t}\n\n\t\tif (!options.some((option) => option.id === PRIME_INFERENCE_PROVIDER_ID)) {\n\t\t\tconst primeInferenceStatus = authStorage.getAuthStatus(PRIME_INFERENCE_PROVIDER_ID);\n\t\t\tif (primeInferenceStatus.source === \"prime_cli\") {\n\t\t\t\toptions.push({\n\t\t\t\t\tid: PRIME_INFERENCE_PROVIDER_ID,\n\t\t\t\t\tname: PRIME_INFERENCE_PROVIDER_NAME,\n\t\t\t\t\tauthType: \"api_key\",\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn options.sort((a, b) => a.name.localeCompare(b.name));\n\t}\n\n\tprivate async completeProviderAuthentication(\n\t\tproviderId: string,\n\t\tproviderName: string,\n\t\tauthType: \"oauth\" | \"api_key\",\n\t\tstatusSuffix?: string,\n\t\tkind: \"provider\" | \"service\" = \"provider\",\n\t\tcredentialPath: string = getAuthPath(),\n\t): Promise<AuthenticationResult> {\n\t\tthis.host.modelRegistry.refresh();\n\n\t\tconst actionLabel = authType === \"oauth\" ? `Logged in to ${providerName}` : `Saved API key for ${providerName}`;\n\t\tawait this.host.onAuthChanged?.();\n\t\tthis.host.showStatus(\n\t\t\t`${actionLabel}. Credentials saved to ${credentialPath}${statusSuffix ? `. ${statusSuffix}` : \"\"}`,\n\t\t);\n\t\tthis.host.onLoginCompleted?.();\n\t\treturn {\n\t\t\tstatus: \"success\",\n\t\t\tproviderId,\n\t\t\tproviderName,\n\t\t\tauthType,\n\t\t\tkind,\n\t\t};\n\t}\n\n\tprivate async completeExternalProviderSetup(\n\t\tproviderId: string,\n\t\tproviderName: string,\n\t): Promise<AuthenticationResult> {\n\t\tthis.host.modelRegistry.refresh();\n\t\tawait this.host.onAuthChanged?.();\n\t\tthis.host.showStatus(`${providerName} uses external credentials. Select a model after configuring them.`);\n\t\treturn {\n\t\t\tstatus: \"success\",\n\t\t\tproviderId,\n\t\t\tproviderName,\n\t\t\tauthType: \"api_key\",\n\t\t};\n\t}\n\n\tprivate async hasAvailableProviderModels(providerId: string): Promise<boolean> {\n\t\tconst models = await this.host.getAvailableModels();\n\t\treturn models.some((model) => model.provider === providerId);\n\t}\n\n\tprivate async showBedrockSetupDialog(providerId: string, providerName: string): Promise<AuthenticationResult> {\n\t\tconst dialog = new LoginDialogComponent(this.host.ui, providerId, () => {}, providerName, \"Amazon Bedrock setup\");\n\t\tconst handle = showFullPaneOverlay(this.host.ui, dialog, 88);\n\t\tconst closeDialog = () => {\n\t\t\thandle.hide();\n\t\t\tthis.host.ui.requestRender();\n\t\t};\n\n\t\ttry {\n\t\t\tawait dialog.showContinueInfo([\n\t\t\t\ttheme.fg(\"text\", \"Amazon Bedrock uses AWS credentials instead of a single API key.\"),\n\t\t\t\ttheme.fg(\"text\", \"Configure an AWS profile, IAM keys, bearer token, or role-based credentials.\"),\n\t\t\t\ttheme.fg(\"muted\", \"See:\"),\n\t\t\t\ttheme.fg(\"accent\", ` ${path.join(getDocsPath(), \"providers.md\")}`),\n\t\t\t]);\n\t\t\tcloseDialog();\n\t\t\tif (!(await this.hasAvailableProviderModels(providerId))) {\n\t\t\t\tthis.host.showStatus(`${providerName} credentials were not detected. Configure them, then reopen /model.`);\n\t\t\t\treturn { status: \"cancelled\" };\n\t\t\t}\n\t\t\treturn await this.completeExternalProviderSetup(providerId, providerName);\n\t\t} catch (error: unknown) {\n\t\t\tcloseDialog();\n\t\t\tconst errorMsg = error instanceof Error ? error.message : String(error);\n\t\t\tif (errorMsg !== \"Login cancelled\") {\n\t\t\t\tthis.host.showError(`Failed to set up ${providerName}: ${errorMsg}`);\n\t\t\t\treturn { status: \"failed\" };\n\t\t\t}\n\t\t\treturn { status: \"cancelled\" };\n\t\t}\n\t}\n\n\tprivate showPrimeTeamSelector(\n\t\tteams: PrimeTeam[],\n\t\tcurrentTeamId: string | undefined,\n\t): Promise<PrimeTeam | null | undefined> {\n\t\treturn new Promise((resolve) => {\n\t\t\tlet handle: OverlayHandle | undefined;\n\t\t\tconst close = () => {\n\t\t\t\thandle?.hide();\n\t\t\t\tthis.host.ui.requestRender();\n\t\t\t};\n\t\t\tconst selector = new PrimeTeamSelectorComponent(\n\t\t\t\tteams,\n\t\t\t\tcurrentTeamId,\n\t\t\t\t(team) => {\n\t\t\t\t\tclose();\n\t\t\t\t\tresolve(team);\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tclose();\n\t\t\t\t\tresolve(undefined);\n\t\t\t\t},\n\t\t\t\t{ getRows: () => this.host.ui.terminal.rows },\n\t\t\t);\n\t\t\thandle = showFullPaneOverlay(this.host.ui, selector, 78);\n\t\t});\n\t}\n\n\tprivate getPrimeInferenceDefaultTeamStatus(): string {\n\t\tconst configPath = this.host.modelRegistry.authStorage.getPrimeCliConfigPath();\n\t\tif (configPath) {\n\t\t\tlet config: ReturnType<typeof loadPrimeCliConfig>;\n\t\t\ttry {\n\t\t\t\tconfig = loadPrimeCliConfig(configPath);\n\t\t\t} catch {\n\t\t\t\treturn \"Using personal account.\";\n\t\t\t}\n\t\t\tif (config.teamIdFromEnv) {\n\t\t\t\treturn \"Using team from PRIME_TEAM_ID.\";\n\t\t\t}\n\t\t\tif (config.teamName) {\n\t\t\t\treturn `Using team \"${config.teamName}\".`;\n\t\t\t}\n\t\t\tif (config.teamId) {\n\t\t\t\treturn \"Using Prime CLI team.\";\n\t\t\t}\n\t\t}\n\t\tconst storedTeam = this.host.modelRegistry.authStorage.getPrimeInferenceTeamSelection();\n\t\tif (storedTeam) {\n\t\t\treturn `Using team \"${storedTeam.name}\".`;\n\t\t}\n\t\tif (storedTeam === null) {\n\t\t\treturn \"Using personal account.\";\n\t\t}\n\t\treturn \"Using personal account.\";\n\t}\n\n\tprivate async selectPrimeInferenceTeam(apiKey: string, dialog: LoginDialogComponent): Promise<string | undefined> {\n\t\ttry {\n\t\t\tconst config = loadPrimeCliConfig(this.host.modelRegistry.authStorage.getPrimeCliConfigPath());\n\t\t\tif (config.teamIdFromEnv) {\n\t\t\t\tthis.host.modelRegistry.authStorage.reload();\n\t\t\t\treturn \"Using team from PRIME_TEAM_ID.\";\n\t\t\t}\n\n\t\t\tdialog.showProgress(\"Loading Prime teams...\");\n\t\t\tconst teams = await fetchPrimeTeams(apiKey, config.baseUrl, { signal: dialog.signal });\n\t\t\tif (dialog.signal.aborted) {\n\t\t\t\treturn this.getPrimeInferenceDefaultTeamStatus();\n\t\t\t}\n\t\t\tif (teams.length === 0) {\n\t\t\t\tthis.host.modelRegistry.authStorage.setPrimeInferenceTeamSelection(null);\n\t\t\t\treturn \"Using personal account.\";\n\t\t\t}\n\n\t\t\tconst storedTeam = this.host.modelRegistry.authStorage.getPrimeInferenceTeamSelection();\n\t\t\tconst currentTeamId = storedTeam === null ? undefined : (storedTeam?.teamId ?? config.teamId);\n\t\t\tconst selectedTeam = await this.showPrimeTeamSelector(teams, currentTeamId);\n\t\t\tif (selectedTeam !== undefined) {\n\t\t\t\tthis.host.modelRegistry.authStorage.setPrimeInferenceTeamSelection(selectedTeam);\n\t\t\t}\n\t\t\treturn selectedTeam\n\t\t\t\t? `Using team \"${selectedTeam.name}\".`\n\t\t\t\t: selectedTeam === null\n\t\t\t\t\t? \"Using personal account.\"\n\t\t\t\t\t: this.getPrimeInferenceDefaultTeamStatus();\n\t\t} catch {\n\t\t\tthis.host.modelRegistry.authStorage.reload();\n\t\t\treturn this.getPrimeInferenceDefaultTeamStatus();\n\t\t}\n\t}\n\n\tprivate async completePrimeInferenceLogin(\n\t\tapiKey: string,\n\t\tdialog: LoginDialogComponent,\n\t\tcloseDialog: () => void,\n\t): Promise<AuthenticationResult> {\n\t\tthis.host.modelRegistry.authStorage.setPrimeInferenceApiKey(apiKey);\n\t\tconst teamStatus = await this.selectPrimeInferenceTeam(apiKey, dialog);\n\n\t\tcloseDialog();\n\t\treturn await this.completeProviderAuthentication(\n\t\t\tPRIME_INFERENCE_PROVIDER_ID,\n\t\t\tPRIME_INFERENCE_PROVIDER_NAME,\n\t\t\t\"api_key\",\n\t\t\tteamStatus,\n\t\t\t\"provider\",\n\t\t\tthis.host.modelRegistry.authStorage.getPrimeCliConfigPath() ?? getAuthPath(),\n\t\t);\n\t}\n\n\tasync runPrimeInferenceLogin(): Promise<AuthenticationResult> {\n\t\tconst dialog = new LoginDialogComponent(\n\t\t\tthis.host.ui,\n\t\t\tPRIME_INFERENCE_PROVIDER_ID,\n\t\t\t(_success, _message) => {},\n\t\t\tPRIME_INFERENCE_PROVIDER_NAME,\n\t\t);\n\n\t\tconst handle = showFullPaneOverlay(this.host.ui, dialog, {\n\t\t\tmaxContentWidth: 88,\n\t\t\tsuspendFullscreenMouse: true,\n\t\t});\n\n\t\tconst closeDialog = () => {\n\t\t\thandle.hide();\n\t\t\tthis.host.ui.requestRender();\n\t\t};\n\n\t\t// The browser challenge gets its own controller so a manually pasted key\n\t\t// can stop the polling without tearing down the dialog.\n\t\tconst browserAbort = new AbortController();\n\t\tconst onDialogAbort = () => browserAbort.abort();\n\t\tdialog.signal.addEventListener(\"abort\", onDialogAbort, { once: true });\n\n\t\tlet manualInputArmed = false;\n\t\tlet resolveManualKey: (entry: { apiKey: string; source: \"manual\" }) => void = () => {};\n\t\tconst manualKeyEntry = new Promise<{ apiKey: string; source: \"manual\" }>((resolve) => {\n\t\t\tresolveManualKey = resolve;\n\t\t});\n\t\tconst armManualInput = (prompt: string): void => {\n\t\t\tmanualInputArmed = true;\n\t\t\tvoid (async () => {\n\t\t\t\tlet value = (await dialog.showManualInput(prompt)).trim();\n\t\t\t\twhile (!value) {\n\t\t\t\t\tvalue = (await dialog.waitForInput()).trim();\n\t\t\t\t}\n\t\t\t\tresolveManualKey({ apiKey: value, source: \"manual\" });\n\t\t\t})().catch(() => {\n\t\t\t\t// Cancellation surfaces through the dialog signal.\n\t\t\t});\n\t\t};\n\n\t\ttry {\n\t\t\tconst browserLogin = loginPrimeInference(\n\t\t\t\t{\n\t\t\t\t\tonAuth: (info) => {\n\t\t\t\t\t\tdialog.showAuth(info.url, info.instructions);\n\t\t\t\t\t\tarmManualInput(\"Complete the sign-in in your browser, or paste an API key below:\");\n\t\t\t\t\t},\n\t\t\t\t\tonProgress: (message) => {\n\t\t\t\t\t\tdialog.showProgress(message);\n\t\t\t\t\t},\n\t\t\t\t\tsignal: browserAbort.signal,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tconfigPath: this.host.modelRegistry.authStorage.getPrimeCliConfigPath(),\n\t\t\t\t},\n\t\t\t);\n\t\t\t// When the browser challenge cannot start or breaks down, keep the dialog\n\t\t\t// open and fall back to plain API key entry instead of failing outright.\n\t\t\tconst browserLoginOrFallback = browserLogin.catch((error: unknown) => {\n\t\t\t\tif (browserAbort.signal.aborted) {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t\tconst errorMsg = error instanceof Error ? error.message : String(error);\n\t\t\t\tdialog.showProgress(`Browser sign-in unavailable (${errorMsg}).`);\n\t\t\t\tif (!manualInputArmed) {\n\t\t\t\t\tarmManualInput(\"Paste a Prime API key below:\");\n\t\t\t\t}\n\t\t\t\treturn manualKeyEntry;\n\t\t\t});\n\t\t\t// Once the browser flow has settled into manual fallback, nothing above\n\t\t\t// rejects on cancel anymore, so the dialog signal must end the race too.\n\t\t\tconst dialogCancelled = new Promise<never>((_, reject) => {\n\t\t\t\tdialog.signal.addEventListener(\"abort\", () => reject(new Error(\"Login cancelled\")), { once: true });\n\t\t\t});\n\t\t\t// Promise.race observes the rejections below, but keep dedicated handlers\n\t\t\t// so neither an aborted browser flow nor a cancelled dialog can surface\n\t\t\t// as an unhandled rejection.\n\t\t\tbrowserLoginOrFallback.catch(() => {});\n\t\t\tdialogCancelled.catch(() => {});\n\n\t\t\tconst result = await Promise.race([browserLoginOrFallback, manualKeyEntry, dialogCancelled]);\n\t\t\tif (dialog.signal.aborted) {\n\t\t\t\tcloseDialog();\n\t\t\t\treturn { status: \"cancelled\" };\n\t\t\t}\n\n\t\t\tif (result.source === \"manual\") {\n\t\t\t\tbrowserAbort.abort();\n\t\t\t\tdialog.showProgress(\"Checking Prime Inference access...\");\n\t\t\t\tconst config = loadPrimeCliConfig(this.host.modelRegistry.authStorage.getPrimeCliConfigPath());\n\t\t\t\tconst access = await checkPrimeInferenceAccess(result.apiKey, config.baseUrl, { signal: dialog.signal });\n\t\t\t\tif (dialog.signal.aborted) {\n\t\t\t\t\tcloseDialog();\n\t\t\t\t\treturn { status: \"cancelled\" };\n\t\t\t\t}\n\t\t\t\tif (!access.ok) {\n\t\t\t\t\tconst status = access.status === undefined ? \"\" : `HTTP ${access.status}: `;\n\t\t\t\t\tthrow new Error(`Prime API key does not have Prime Inference access (${status}${access.message})`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn await this.completePrimeInferenceLogin(result.apiKey, dialog, closeDialog);\n\t\t} catch (error: unknown) {\n\t\t\tcloseDialog();\n\t\t\tconst errorMsg = error instanceof Error ? error.message : String(error);\n\t\t\tif (!dialog.signal.aborted && errorMsg !== \"Login cancelled\") {\n\t\t\t\tthis.host.showError(`Failed to login to ${PRIME_INFERENCE_PROVIDER_NAME}: ${errorMsg}`);\n\t\t\t\treturn { status: \"failed\" };\n\t\t\t}\n\t\t\treturn { status: \"cancelled\" };\n\t\t} finally {\n\t\t\tdialog.signal.removeEventListener(\"abort\", onDialogAbort);\n\t\t}\n\t}\n\n\tprivate async showApiKeyLoginDialog(\n\t\tproviderId: string,\n\t\tproviderName: string,\n\t\tkind: \"provider\" | \"service\" = \"provider\",\n\t): Promise<AuthenticationResult> {\n\t\tconst dialog = new LoginDialogComponent(this.host.ui, providerId, (_success, _message) => {}, providerName);\n\n\t\tconst handle = showFullPaneOverlay(this.host.ui, dialog, 88);\n\n\t\tconst closeDialog = () => {\n\t\t\thandle.hide();\n\t\t\tthis.host.ui.requestRender();\n\t\t};\n\n\t\ttry {\n\t\t\tconst apiKey = (await dialog.showPrompt(\"Enter API key:\")).trim();\n\t\t\tif (!apiKey) {\n\t\t\t\tthrow new Error(\"API key cannot be empty.\");\n\t\t\t}\n\n\t\t\tthis.host.modelRegistry.authStorage.set(providerId, { type: \"api_key\", key: apiKey });\n\n\t\t\tcloseDialog();\n\t\t\treturn await this.completeProviderAuthentication(providerId, providerName, \"api_key\", undefined, kind);\n\t\t} catch (error: unknown) {\n\t\t\tcloseDialog();\n\t\t\tconst errorMsg = error instanceof Error ? error.message : String(error);\n\t\t\tif (errorMsg !== \"Login cancelled\") {\n\t\t\t\tthis.host.showError(`Failed to save API key for ${providerName}: ${errorMsg}`);\n\t\t\t\treturn { status: \"failed\" };\n\t\t\t}\n\t\t\treturn { status: \"cancelled\" };\n\t\t}\n\t}\n\n\tprivate showOAuthLoginSelect(dialogHandle: OverlayHandle, prompt: OAuthSelectPrompt): Promise<string | undefined> {\n\t\treturn new Promise((resolve) => {\n\t\t\tdialogHandle.setHidden(true);\n\t\t\tlet selectorHandle: OverlayHandle | undefined;\n\t\t\tconst restoreDialog = () => {\n\t\t\t\tselectorHandle?.hide();\n\t\t\t\tdialogHandle.setHidden(false);\n\t\t\t\tdialogHandle.focus();\n\t\t\t\tthis.host.ui.requestRender();\n\t\t\t};\n\t\t\tconst labels = prompt.options.map((option) => option.label);\n\t\t\tconst selector = new ExtensionSelectorComponent(\n\t\t\t\tprompt.message,\n\t\t\t\tlabels,\n\t\t\t\t(optionLabel) => {\n\t\t\t\t\trestoreDialog();\n\t\t\t\t\tresolve(prompt.options.find((option) => option.label === optionLabel)?.id);\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\trestoreDialog();\n\t\t\t\t\tresolve(undefined);\n\t\t\t\t},\n\t\t\t\t{ getRows: () => this.host.ui.terminal.rows },\n\t\t\t);\n\t\t\tselectorHandle = showFullPaneOverlay(this.host.ui, selector, 76);\n\t\t});\n\t}\n\n\tprivate async showLoginDialog(\n\t\tproviderId: string,\n\t\tproviderName: string,\n\t\tkind: \"provider\" | \"service\" = \"provider\",\n\t): Promise<AuthenticationResult> {\n\t\tconst providerInfo = this.host.modelRegistry.authStorage\n\t\t\t.getOAuthProviders()\n\t\t\t.find((provider) => provider.id === providerId);\n\n\t\tconst usesCallbackServer = providerInfo?.usesCallbackServer ?? false;\n\n\t\tconst dialog = new LoginDialogComponent(this.host.ui, providerId, (_success, _message) => {}, providerName);\n\n\t\tconst dialogHandle = showFullPaneOverlay(this.host.ui, dialog, {\n\t\t\tmaxContentWidth: 88,\n\t\t\tsuspendFullscreenMouse: true,\n\t\t});\n\n\t\tlet manualCodeResolve: ((code: string) => void) | undefined;\n\t\tlet manualCodeReject: ((err: Error) => void) | undefined;\n\t\tconst manualCodePromise = new Promise<string>((resolve, reject) => {\n\t\t\tmanualCodeResolve = resolve;\n\t\t\tmanualCodeReject = reject;\n\t\t});\n\n\t\tconst closeDialog = () => {\n\t\t\tdialogHandle.hide();\n\t\t\tthis.host.ui.requestRender();\n\t\t};\n\n\t\ttry {\n\t\t\tawait this.host.modelRegistry.authStorage.login(providerId as OAuthProviderId, {\n\t\t\t\tonAuth: (info: { url: string; instructions?: string }) => {\n\t\t\t\t\tdialog.showAuth(info.url, info.instructions);\n\n\t\t\t\t\tif (usesCallbackServer) {\n\t\t\t\t\t\tdialog\n\t\t\t\t\t\t\t.showManualInput(\"Paste redirect URL below, or complete login in browser:\")\n\t\t\t\t\t\t\t.then((value) => {\n\t\t\t\t\t\t\t\tif (value && manualCodeResolve) {\n\t\t\t\t\t\t\t\t\tmanualCodeResolve(value);\n\t\t\t\t\t\t\t\t\tmanualCodeResolve = undefined;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.catch(() => {\n\t\t\t\t\t\t\t\tif (manualCodeReject) {\n\t\t\t\t\t\t\t\t\tmanualCodeReject(new Error(\"Login cancelled\"));\n\t\t\t\t\t\t\t\t\tmanualCodeReject = undefined;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t} else if (providerId === \"github-copilot\") {\n\t\t\t\t\t\tdialog.showWaiting(\"Waiting for browser authentication...\");\n\t\t\t\t\t}\n\t\t\t\t},\n\n\t\t\t\tonPrompt: async (prompt: { message: string; placeholder?: string }) => {\n\t\t\t\t\treturn dialog.showPrompt(prompt.message, prompt.placeholder);\n\t\t\t\t},\n\n\t\t\t\tonProgress: (message: string) => {\n\t\t\t\t\tdialog.showProgress(message);\n\t\t\t\t},\n\n\t\t\t\tonSelect: (prompt: OAuthSelectPrompt) => this.showOAuthLoginSelect(dialogHandle, prompt),\n\n\t\t\t\tonManualCodeInput: () => manualCodePromise,\n\n\t\t\t\tsignal: dialog.signal,\n\t\t\t});\n\n\t\t\tcloseDialog();\n\t\t\treturn await this.completeProviderAuthentication(providerId, providerName, \"oauth\", undefined, kind);\n\t\t} catch (error: unknown) {\n\t\t\tcloseDialog();\n\t\t\tconst errorMsg = error instanceof Error ? error.message : String(error);\n\t\t\tif (errorMsg !== \"Login cancelled\") {\n\t\t\t\tthis.host.showError(`Failed to login to ${providerName}: ${errorMsg}`);\n\t\t\t\treturn { status: \"failed\" };\n\t\t\t}\n\t\t\treturn { status: \"cancelled\" };\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"auth-flows.js","sourceRoot":"","sources":["../../../src/modes/interactive/auth-flows.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,YAAY,EAAgD,MAAM,eAAe,CAAC;AAE3F,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE3D,OAAO,EACN,yBAAyB,EACzB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,2BAA2B,EAC3B,6BAA6B,GAE7B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AACvF,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAClG,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,0BAA0B,EAA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,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACxE,IAAI,QAAQ,KAAK,iBAAiB,EAAE,CAAC;gBACpC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,sBAAsB,YAAY,KAAK,QAAQ,EAAE,CAAC,CAAC;gBACvE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;YAC7B,CAAC;YACD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;QAChC,CAAC;IAAA,CACD;CACD","sourcesContent":["import * as path from \"node:path\";\nimport { getProviders, type OAuthProviderId, type OAuthSelectPrompt } from \"@asm-agent/ai\";\nimport type { OverlayHandle, TUI } from \"@asm-agent/tui\";\nimport { getAuthPath, getDocsPath } from \"../../config.js\";\nimport type { ModelRegistry } from \"../../core/model-registry.js\";\nimport {\n\tcheckPrimeInferenceAccess,\n\tfetchPrimeTeams,\n\tloadPrimeCliConfig,\n\tloginPrimeInference,\n\tPRIME_INFERENCE_PROVIDER_ID,\n\tPRIME_INFERENCE_PROVIDER_NAME,\n\ttype PrimeTeam,\n} from \"../../core/prime-inference-auth.js\";\nimport { BUILT_IN_PROVIDER_DISPLAY_NAMES } from \"../../core/provider-display-names.js\";\nimport { SERPER_CREDENTIAL_ID, SERPER_CREDENTIAL_NAME } from \"../../core/websearch-credential.js\";\nimport { showFullPaneOverlay } from \"./components/centered-overlay.js\";\nimport { ExtensionSelectorComponent } from \"./components/extension-selector.js\";\nimport { LoginDialogComponent } from \"./components/login-dialog.js\";\nimport {\n\ttype AuthSelectorCategory,\n\ttype AuthSelectorProvider,\n\tcompareAuthSelectorProviders,\n\tOAuthSelectorComponent,\n} from \"./components/oauth-selector.js\";\nimport { PrimeTeamSelectorComponent } from \"./components/prime-team-selector.js\";\nimport { theme } from \"./theme/theme.js\";\n\nexport type AuthenticationResult =\n\t| {\n\t\t\tstatus: \"success\";\n\t\t\tproviderId: string;\n\t\t\tproviderName: string;\n\t\t\tauthType: \"oauth\" | \"api_key\";\n\t\t\t/** \"service\" credentials (e.g. web search) don't affect model selection. */\n\t\t\tkind?: \"provider\" | \"service\";\n\t }\n\t| { status: \"cancelled\" }\n\t| { status: \"failed\" };\n\nexport const BEDROCK_PROVIDER_ID = \"amazon-bedrock\";\nexport const ASM_AGENT_LOGIN_PROVIDER_IDS = new Set([\"openai-codex\", \"anthropic\", \"google\", \"gemini\"]);\n\nexport const ANTHROPIC_SUBSCRIPTION_AUTH_WARNING =\n\t\"Anthropic subscription auth is active. Third-party harness usage draws from extra usage and is billed per token, not your Claude plan limits. Manage extra usage at https://claude.ai/settings/usage.\";\n\nfunction isAnthropicSubscriptionAuthKey(apiKey: string | undefined): boolean {\n\treturn typeof apiKey === \"string\" && apiKey.startsWith(\"sk-ant-oat\");\n}\n\nexport async function getAnthropicSubscriptionAuthWarning(\n\tmodelRegistry: ModelRegistry,\n\tmodel: { provider: string } | undefined,\n): Promise<string | undefined> {\n\tif (!model || model.provider !== \"anthropic\") {\n\t\treturn undefined;\n\t}\n\n\tconst storedCredential = modelRegistry.authStorage.get(\"anthropic\");\n\tif (storedCredential?.type === \"oauth\") {\n\t\treturn ANTHROPIC_SUBSCRIPTION_AUTH_WARNING;\n\t}\n\n\ttry {\n\t\tconst apiKey = await modelRegistry.getApiKeyForProvider(model.provider);\n\t\tif (isAnthropicSubscriptionAuthKey(apiKey)) {\n\t\t\treturn ANTHROPIC_SUBSCRIPTION_AUTH_WARNING;\n\t\t}\n\t} catch {\n\t\t// Ignore auth lookup failures for warning-only checks.\n\t}\n\treturn undefined;\n}\n\nconst BUILT_IN_MODEL_PROVIDERS = new Set<string>(getProviders());\n\nexport function isApiKeyLoginProvider(\n\tproviderId: string,\n\toauthProviderIds: ReadonlySet<string>,\n\tbuiltInProviderIds: ReadonlySet<string> = BUILT_IN_MODEL_PROVIDERS,\n): boolean {\n\tif (BUILT_IN_PROVIDER_DISPLAY_NAMES[providerId]) {\n\t\treturn true;\n\t}\n\tif (builtInProviderIds.has(providerId)) {\n\t\treturn false;\n\t}\n\treturn !oauthProviderIds.has(providerId);\n}\n\nexport interface ProviderAuthFlowsHost {\n\treadonly ui: TUI;\n\treadonly modelRegistry: ModelRegistry;\n\tshowStatus(message: string): void;\n\tshowError(message: string): void;\n\t/** Models currently visible to the host; used to detect providers configured via external credentials. */\n\tgetAvailableModels(): Promise<ReadonlyArray<{ provider: string }>>;\n\t/** Invoked after stored credentials change so the host can refresh dependent UI. */\n\tonAuthChanged?(): void | Promise<void>;\n\t/** Invoked after a successful login (e.g. to surface billing warnings). */\n\tonLoginCompleted?(): void;\n}\n\nexport interface ProviderLoginOptions {\n\tauthType?: \"oauth\" | \"api_key\";\n\tinitialCategory?: AuthSelectorCategory;\n}\n\n/** Shared auth dialogs: host-specific refresh and billing effects remain outside the flow. */\nexport class ProviderAuthFlows {\n\tconstructor(private readonly host: ProviderAuthFlowsHost) {}\n\n\t/**\n\t * Run the OAuth login flow for an MCP integration server.\n\t *\n\t * The provider must already be registered (the McpManager does this as\n\t * `mcp:<server>`). On success the credentials land in auth.json and the\n\t * caller should reload resources so the integration's skill enables.\n\t */\n\trunMcpLogin(server: string, label?: string): Promise<AuthenticationResult> {\n\t\tconst providerId = `mcp:${server}`;\n\t\tconst provider = this.host.modelRegistry.authStorage.getOAuthProviders().find((p) => p.id === providerId);\n\t\tif (!provider) {\n\t\t\tthis.host.showError(`Unknown MCP integration: ${server}`);\n\t\t\treturn Promise.resolve({ status: \"failed\" });\n\t\t}\n\t\treturn this.showLoginDialog(providerId, label ?? provider.name, \"service\");\n\t}\n\n\trunLogin(options: ProviderLoginOptions = {}): Promise<AuthenticationResult> {\n\t\tconst { authType, initialCategory } = options;\n\t\tconst providerOptions = this.getLoginProviderOptions(authType);\n\t\tif (providerOptions.length === 0) {\n\t\t\tthis.host.showStatus(\n\t\t\t\tauthType === \"oauth\"\n\t\t\t\t\t? \"No subscription providers available.\"\n\t\t\t\t\t: authType === \"api_key\"\n\t\t\t\t\t\t? \"No API key providers available.\"\n\t\t\t\t\t\t: \"No providers available.\",\n\t\t\t);\n\t\t\treturn Promise.resolve({ status: \"failed\" });\n\t\t}\n\n\t\treturn new Promise((resolve) => {\n\t\t\tlet handle: OverlayHandle | undefined;\n\t\t\tconst close = () => {\n\t\t\t\thandle?.hide();\n\t\t\t\tthis.host.ui.requestRender();\n\t\t\t};\n\t\t\tconst selector = new OAuthSelectorComponent(\n\t\t\t\t\"login\",\n\t\t\t\tthis.host.modelRegistry.authStorage,\n\t\t\t\tproviderOptions,\n\t\t\t\tasync (providerOption: AuthSelectorProvider) => {\n\t\t\t\t\tclose();\n\t\t\t\t\tresolve(await this.loginProvider(providerOption));\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tclose();\n\t\t\t\t\tresolve({ status: \"cancelled\" });\n\t\t\t\t},\n\t\t\t\t(providerId) => this.host.modelRegistry.getProviderAuthStatus(providerId),\n\t\t\t\t{ getRows: () => this.host.ui.terminal.rows, initialCategory },\n\t\t\t);\n\t\t\thandle = showFullPaneOverlay(this.host.ui, selector, 78);\n\t\t});\n\t}\n\n\tloginProvider(providerOption: AuthSelectorProvider): Promise<AuthenticationResult> {\n\t\tconst kind = providerOption.category === \"service\" ? \"service\" : \"provider\";\n\t\tif (providerOption.authType === \"oauth\") {\n\t\t\treturn this.showLoginDialog(providerOption.id, providerOption.name, kind);\n\t\t}\n\t\tif (providerOption.id === PRIME_INFERENCE_PROVIDER_ID) {\n\t\t\treturn this.runPrimeInferenceLogin();\n\t\t}\n\t\tif (providerOption.id === BEDROCK_PROVIDER_ID) {\n\t\t\treturn this.showBedrockSetupDialog(providerOption.id, providerOption.name);\n\t\t}\n\t\treturn this.showApiKeyLoginDialog(providerOption.id, providerOption.name, kind);\n\t}\n\n\trunLogout(): Promise<string | null> {\n\t\tconst providerOptions = this.getLogoutProviderOptions();\n\t\tif (providerOptions.length === 0) {\n\t\t\tthis.host.showStatus(\n\t\t\t\t\"No stored credentials to remove. /logout only removes credentials saved by /login; environment variables and models.json config are unchanged.\",\n\t\t\t);\n\t\t\treturn Promise.resolve(null);\n\t\t}\n\n\t\treturn new Promise((resolve) => {\n\t\t\tlet handle: OverlayHandle | undefined;\n\t\t\tconst close = () => {\n\t\t\t\thandle?.hide();\n\t\t\t\tthis.host.ui.requestRender();\n\t\t\t};\n\t\t\tconst selector = new OAuthSelectorComponent(\n\t\t\t\t\"logout\",\n\t\t\t\tthis.host.modelRegistry.authStorage,\n\t\t\t\tproviderOptions,\n\t\t\t\tasync (providerOption: AuthSelectorProvider) => {\n\t\t\t\t\tclose();\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tthis.host.modelRegistry.authStorage.logout(providerOption.id);\n\t\t\t\t\t\tthis.host.modelRegistry.refresh();\n\t\t\t\t\t\tawait this.host.onAuthChanged?.();\n\t\t\t\t\t\tconst message =\n\t\t\t\t\t\t\tproviderOption.authType === \"oauth\"\n\t\t\t\t\t\t\t\t? `Logged out of ${providerOption.name}`\n\t\t\t\t\t\t\t\t: `Removed stored API key for ${providerOption.name}. Environment variables and models.json config are unchanged.`;\n\t\t\t\t\t\tthis.host.showStatus(message);\n\t\t\t\t\t\tresolve(providerOption.id);\n\t\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\t\tthis.host.showError(`Logout failed: ${error instanceof Error ? error.message : String(error)}`);\n\t\t\t\t\t\tresolve(null);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tclose();\n\t\t\t\t\tresolve(null);\n\t\t\t\t},\n\t\t\t\tundefined,\n\t\t\t\t{ getRows: () => this.host.ui.terminal.rows },\n\t\t\t);\n\t\t\thandle = showFullPaneOverlay(this.host.ui, selector, 78);\n\t\t});\n\t}\n\n\tgetLoginProviderOptions(authType?: \"oauth\" | \"api_key\"): AuthSelectorProvider[] {\n\t\tconst authStorage = this.host.modelRegistry.authStorage;\n\t\tif (authType === \"api_key\") {\n\t\t\treturn [];\n\t\t}\n\t\tconst oauthProviders = authStorage\n\t\t\t.getOAuthProviders()\n\t\t\t.filter((provider) => ASM_AGENT_LOGIN_PROVIDER_IDS.has(provider.id));\n\t\tconst options: AuthSelectorProvider[] = oauthProviders.map((provider) => ({\n\t\t\tid: provider.id,\n\t\t\tname: provider.name,\n\t\t\tauthType: \"oauth\",\n\t\t}));\n\n\t\treturn options.sort(compareAuthSelectorProviders);\n\t}\n\n\tprivate getLogoutProviderOptions(): AuthSelectorProvider[] {\n\t\tconst authStorage = this.host.modelRegistry.authStorage;\n\t\tconst options: AuthSelectorProvider[] = [];\n\n\t\tconst oauthProvidersById = new Map(authStorage.getOAuthProviders().map((p) => [p.id, p]));\n\t\tfor (const providerId of authStorage.list()) {\n\t\t\tconst credential = authStorage.get(providerId);\n\t\t\tif (!credential) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst isSerper = providerId === SERPER_CREDENTIAL_ID;\n\t\t\tconst isMcp = providerId.startsWith(\"mcp:\");\n\t\t\tconst name = isSerper\n\t\t\t\t? SERPER_CREDENTIAL_NAME\n\t\t\t\t: isMcp\n\t\t\t\t\t? (oauthProvidersById.get(providerId)?.name ?? providerId.slice(\"mcp:\".length))\n\t\t\t\t\t: this.host.modelRegistry.getProviderDisplayName(providerId);\n\t\t\toptions.push({\n\t\t\t\tid: providerId,\n\t\t\t\tname,\n\t\t\t\tauthType: credential.type,\n\t\t\t\tcategory: isSerper || isMcp ? \"service\" : \"provider\",\n\t\t\t});\n\t\t}\n\n\t\tif (!options.some((option) => option.id === PRIME_INFERENCE_PROVIDER_ID)) {\n\t\t\tconst primeInferenceStatus = authStorage.getAuthStatus(PRIME_INFERENCE_PROVIDER_ID);\n\t\t\tif (primeInferenceStatus.source === \"prime_cli\") {\n\t\t\t\toptions.push({\n\t\t\t\t\tid: PRIME_INFERENCE_PROVIDER_ID,\n\t\t\t\t\tname: PRIME_INFERENCE_PROVIDER_NAME,\n\t\t\t\t\tauthType: \"api_key\",\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn options.sort((a, b) => a.name.localeCompare(b.name));\n\t}\n\n\tprivate async completeProviderAuthentication(\n\t\tproviderId: string,\n\t\tproviderName: string,\n\t\tauthType: \"oauth\" | \"api_key\",\n\t\tstatusSuffix?: string,\n\t\tkind: \"provider\" | \"service\" = \"provider\",\n\t\tcredentialPath: string = getAuthPath(),\n\t): Promise<AuthenticationResult> {\n\t\tthis.host.modelRegistry.refresh();\n\n\t\tconst actionLabel = authType === \"oauth\" ? `Logged in to ${providerName}` : `Saved API key for ${providerName}`;\n\t\tawait this.host.onAuthChanged?.();\n\t\tthis.host.showStatus(\n\t\t\t`${actionLabel}. Credentials saved to ${credentialPath}${statusSuffix ? `. ${statusSuffix}` : \"\"}`,\n\t\t);\n\t\tthis.host.onLoginCompleted?.();\n\t\treturn {\n\t\t\tstatus: \"success\",\n\t\t\tproviderId,\n\t\t\tproviderName,\n\t\t\tauthType,\n\t\t\tkind,\n\t\t};\n\t}\n\n\tprivate async completeExternalProviderSetup(\n\t\tproviderId: string,\n\t\tproviderName: string,\n\t): Promise<AuthenticationResult> {\n\t\tthis.host.modelRegistry.refresh();\n\t\tawait this.host.onAuthChanged?.();\n\t\tthis.host.showStatus(`${providerName} uses external credentials. Select a model after configuring them.`);\n\t\treturn {\n\t\t\tstatus: \"success\",\n\t\t\tproviderId,\n\t\t\tproviderName,\n\t\t\tauthType: \"api_key\",\n\t\t};\n\t}\n\n\tprivate async hasAvailableProviderModels(providerId: string): Promise<boolean> {\n\t\tconst models = await this.host.getAvailableModels();\n\t\treturn models.some((model) => model.provider === providerId);\n\t}\n\n\tprivate async showBedrockSetupDialog(providerId: string, providerName: string): Promise<AuthenticationResult> {\n\t\tconst dialog = new LoginDialogComponent(this.host.ui, providerId, () => {}, providerName, \"Amazon Bedrock setup\");\n\t\tconst handle = showFullPaneOverlay(this.host.ui, dialog, 88);\n\t\tconst closeDialog = () => {\n\t\t\thandle.hide();\n\t\t\tthis.host.ui.requestRender();\n\t\t};\n\n\t\ttry {\n\t\t\tawait dialog.showContinueInfo([\n\t\t\t\ttheme.fg(\"text\", \"Amazon Bedrock uses AWS credentials instead of a single API key.\"),\n\t\t\t\ttheme.fg(\"text\", \"Configure an AWS profile, IAM keys, bearer token, or role-based credentials.\"),\n\t\t\t\ttheme.fg(\"muted\", \"See:\"),\n\t\t\t\ttheme.fg(\"accent\", ` ${path.join(getDocsPath(), \"providers.md\")}`),\n\t\t\t]);\n\t\t\tcloseDialog();\n\t\t\tif (!(await this.hasAvailableProviderModels(providerId))) {\n\t\t\t\tthis.host.showStatus(`${providerName} credentials were not detected. Configure them, then reopen /model.`);\n\t\t\t\treturn { status: \"cancelled\" };\n\t\t\t}\n\t\t\treturn await this.completeExternalProviderSetup(providerId, providerName);\n\t\t} catch (error: unknown) {\n\t\t\tcloseDialog();\n\t\t\tconst errorMsg = error instanceof Error ? error.message : String(error);\n\t\t\tif (errorMsg !== \"Login cancelled\") {\n\t\t\t\tthis.host.showError(`Failed to set up ${providerName}: ${errorMsg}`);\n\t\t\t\treturn { status: \"failed\" };\n\t\t\t}\n\t\t\treturn { status: \"cancelled\" };\n\t\t}\n\t}\n\n\tprivate showPrimeTeamSelector(\n\t\tteams: PrimeTeam[],\n\t\tcurrentTeamId: string | undefined,\n\t): Promise<PrimeTeam | null | undefined> {\n\t\treturn new Promise((resolve) => {\n\t\t\tlet handle: OverlayHandle | undefined;\n\t\t\tconst close = () => {\n\t\t\t\thandle?.hide();\n\t\t\t\tthis.host.ui.requestRender();\n\t\t\t};\n\t\t\tconst selector = new PrimeTeamSelectorComponent(\n\t\t\t\tteams,\n\t\t\t\tcurrentTeamId,\n\t\t\t\t(team) => {\n\t\t\t\t\tclose();\n\t\t\t\t\tresolve(team);\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tclose();\n\t\t\t\t\tresolve(undefined);\n\t\t\t\t},\n\t\t\t\t{ getRows: () => this.host.ui.terminal.rows },\n\t\t\t);\n\t\t\thandle = showFullPaneOverlay(this.host.ui, selector, 78);\n\t\t});\n\t}\n\n\tprivate getPrimeInferenceDefaultTeamStatus(): string {\n\t\tconst configPath = this.host.modelRegistry.authStorage.getPrimeCliConfigPath();\n\t\tif (configPath) {\n\t\t\tlet config: ReturnType<typeof loadPrimeCliConfig>;\n\t\t\ttry {\n\t\t\t\tconfig = loadPrimeCliConfig(configPath);\n\t\t\t} catch {\n\t\t\t\treturn \"Using personal account.\";\n\t\t\t}\n\t\t\tif (config.teamIdFromEnv) {\n\t\t\t\treturn \"Using team from PRIME_TEAM_ID.\";\n\t\t\t}\n\t\t\tif (config.teamName) {\n\t\t\t\treturn `Using team \"${config.teamName}\".`;\n\t\t\t}\n\t\t\tif (config.teamId) {\n\t\t\t\treturn \"Using Prime CLI team.\";\n\t\t\t}\n\t\t}\n\t\tconst storedTeam = this.host.modelRegistry.authStorage.getPrimeInferenceTeamSelection();\n\t\tif (storedTeam) {\n\t\t\treturn `Using team \"${storedTeam.name}\".`;\n\t\t}\n\t\tif (storedTeam === null) {\n\t\t\treturn \"Using personal account.\";\n\t\t}\n\t\treturn \"Using personal account.\";\n\t}\n\n\tprivate async selectPrimeInferenceTeam(apiKey: string, dialog: LoginDialogComponent): Promise<string | undefined> {\n\t\ttry {\n\t\t\tconst config = loadPrimeCliConfig(this.host.modelRegistry.authStorage.getPrimeCliConfigPath());\n\t\t\tif (config.teamIdFromEnv) {\n\t\t\t\tthis.host.modelRegistry.authStorage.reload();\n\t\t\t\treturn \"Using team from PRIME_TEAM_ID.\";\n\t\t\t}\n\n\t\t\tdialog.showProgress(\"Loading Prime teams...\");\n\t\t\tconst teams = await fetchPrimeTeams(apiKey, config.baseUrl, { signal: dialog.signal });\n\t\t\tif (dialog.signal.aborted) {\n\t\t\t\treturn this.getPrimeInferenceDefaultTeamStatus();\n\t\t\t}\n\t\t\tif (teams.length === 0) {\n\t\t\t\tthis.host.modelRegistry.authStorage.setPrimeInferenceTeamSelection(null);\n\t\t\t\treturn \"Using personal account.\";\n\t\t\t}\n\n\t\t\tconst storedTeam = this.host.modelRegistry.authStorage.getPrimeInferenceTeamSelection();\n\t\t\tconst currentTeamId = storedTeam === null ? undefined : (storedTeam?.teamId ?? config.teamId);\n\t\t\tconst selectedTeam = await this.showPrimeTeamSelector(teams, currentTeamId);\n\t\t\tif (selectedTeam !== undefined) {\n\t\t\t\tthis.host.modelRegistry.authStorage.setPrimeInferenceTeamSelection(selectedTeam);\n\t\t\t}\n\t\t\treturn selectedTeam\n\t\t\t\t? `Using team \"${selectedTeam.name}\".`\n\t\t\t\t: selectedTeam === null\n\t\t\t\t\t? \"Using personal account.\"\n\t\t\t\t\t: this.getPrimeInferenceDefaultTeamStatus();\n\t\t} catch {\n\t\t\tthis.host.modelRegistry.authStorage.reload();\n\t\t\treturn this.getPrimeInferenceDefaultTeamStatus();\n\t\t}\n\t}\n\n\tprivate async completePrimeInferenceLogin(\n\t\tapiKey: string,\n\t\tdialog: LoginDialogComponent,\n\t\tcloseDialog: () => void,\n\t): Promise<AuthenticationResult> {\n\t\tthis.host.modelRegistry.authStorage.setPrimeInferenceApiKey(apiKey);\n\t\tconst teamStatus = await this.selectPrimeInferenceTeam(apiKey, dialog);\n\n\t\tcloseDialog();\n\t\treturn await this.completeProviderAuthentication(\n\t\t\tPRIME_INFERENCE_PROVIDER_ID,\n\t\t\tPRIME_INFERENCE_PROVIDER_NAME,\n\t\t\t\"api_key\",\n\t\t\tteamStatus,\n\t\t\t\"provider\",\n\t\t\tthis.host.modelRegistry.authStorage.getPrimeCliConfigPath() ?? getAuthPath(),\n\t\t);\n\t}\n\n\tasync runPrimeInferenceLogin(): Promise<AuthenticationResult> {\n\t\tconst dialog = new LoginDialogComponent(\n\t\t\tthis.host.ui,\n\t\t\tPRIME_INFERENCE_PROVIDER_ID,\n\t\t\t(_success, _message) => {},\n\t\t\tPRIME_INFERENCE_PROVIDER_NAME,\n\t\t);\n\n\t\tconst handle = showFullPaneOverlay(this.host.ui, dialog, {\n\t\t\tmaxContentWidth: 88,\n\t\t\tsuspendFullscreenMouse: true,\n\t\t});\n\n\t\tconst closeDialog = () => {\n\t\t\thandle.hide();\n\t\t\tthis.host.ui.requestRender();\n\t\t};\n\n\t\t// The browser challenge gets its own controller so a manually pasted key\n\t\t// can stop the polling without tearing down the dialog.\n\t\tconst browserAbort = new AbortController();\n\t\tconst onDialogAbort = () => browserAbort.abort();\n\t\tdialog.signal.addEventListener(\"abort\", onDialogAbort, { once: true });\n\n\t\tlet manualInputArmed = false;\n\t\tlet resolveManualKey: (entry: { apiKey: string; source: \"manual\" }) => void = () => {};\n\t\tconst manualKeyEntry = new Promise<{ apiKey: string; source: \"manual\" }>((resolve) => {\n\t\t\tresolveManualKey = resolve;\n\t\t});\n\t\tconst armManualInput = (prompt: string): void => {\n\t\t\tmanualInputArmed = true;\n\t\t\tvoid (async () => {\n\t\t\t\tlet value = (await dialog.showManualInput(prompt)).trim();\n\t\t\t\twhile (!value) {\n\t\t\t\t\tvalue = (await dialog.waitForInput()).trim();\n\t\t\t\t}\n\t\t\t\tresolveManualKey({ apiKey: value, source: \"manual\" });\n\t\t\t})().catch(() => {\n\t\t\t\t// Cancellation surfaces through the dialog signal.\n\t\t\t});\n\t\t};\n\n\t\ttry {\n\t\t\tconst browserLogin = loginPrimeInference(\n\t\t\t\t{\n\t\t\t\t\tonAuth: (info) => {\n\t\t\t\t\t\tdialog.showAuth(info.url, info.instructions);\n\t\t\t\t\t\tarmManualInput(\"Complete the sign-in in your browser, or paste an API key below:\");\n\t\t\t\t\t},\n\t\t\t\t\tonProgress: (message) => {\n\t\t\t\t\t\tdialog.showProgress(message);\n\t\t\t\t\t},\n\t\t\t\t\tsignal: browserAbort.signal,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tconfigPath: this.host.modelRegistry.authStorage.getPrimeCliConfigPath(),\n\t\t\t\t},\n\t\t\t);\n\t\t\t// When the browser challenge cannot start or breaks down, keep the dialog\n\t\t\t// open and fall back to plain API key entry instead of failing outright.\n\t\t\tconst browserLoginOrFallback = browserLogin.catch((error: unknown) => {\n\t\t\t\tif (browserAbort.signal.aborted) {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t\tconst errorMsg = error instanceof Error ? error.message : String(error);\n\t\t\t\tdialog.showProgress(`Browser sign-in unavailable (${errorMsg}).`);\n\t\t\t\tif (!manualInputArmed) {\n\t\t\t\t\tarmManualInput(\"Paste a Prime API key below:\");\n\t\t\t\t}\n\t\t\t\treturn manualKeyEntry;\n\t\t\t});\n\t\t\t// Once the browser flow has settled into manual fallback, nothing above\n\t\t\t// rejects on cancel anymore, so the dialog signal must end the race too.\n\t\t\tconst dialogCancelled = new Promise<never>((_, reject) => {\n\t\t\t\tdialog.signal.addEventListener(\"abort\", () => reject(new Error(\"Login cancelled\")), { once: true });\n\t\t\t});\n\t\t\t// Promise.race observes the rejections below, but keep dedicated handlers\n\t\t\t// so neither an aborted browser flow nor a cancelled dialog can surface\n\t\t\t// as an unhandled rejection.\n\t\t\tbrowserLoginOrFallback.catch(() => {});\n\t\t\tdialogCancelled.catch(() => {});\n\n\t\t\tconst result = await Promise.race([browserLoginOrFallback, manualKeyEntry, dialogCancelled]);\n\t\t\tif (dialog.signal.aborted) {\n\t\t\t\tcloseDialog();\n\t\t\t\treturn { status: \"cancelled\" };\n\t\t\t}\n\n\t\t\tif (result.source === \"manual\") {\n\t\t\t\tbrowserAbort.abort();\n\t\t\t\tdialog.showProgress(\"Checking Prime Inference access...\");\n\t\t\t\tconst config = loadPrimeCliConfig(this.host.modelRegistry.authStorage.getPrimeCliConfigPath());\n\t\t\t\tconst access = await checkPrimeInferenceAccess(result.apiKey, config.baseUrl, { signal: dialog.signal });\n\t\t\t\tif (dialog.signal.aborted) {\n\t\t\t\t\tcloseDialog();\n\t\t\t\t\treturn { status: \"cancelled\" };\n\t\t\t\t}\n\t\t\t\tif (!access.ok) {\n\t\t\t\t\tconst status = access.status === undefined ? \"\" : `HTTP ${access.status}: `;\n\t\t\t\t\tthrow new Error(`Prime API key does not have Prime Inference access (${status}${access.message})`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn await this.completePrimeInferenceLogin(result.apiKey, dialog, closeDialog);\n\t\t} catch (error: unknown) {\n\t\t\tcloseDialog();\n\t\t\tconst errorMsg = error instanceof Error ? error.message : String(error);\n\t\t\tif (!dialog.signal.aborted && errorMsg !== \"Login cancelled\") {\n\t\t\t\tthis.host.showError(`Failed to login to ${PRIME_INFERENCE_PROVIDER_NAME}: ${errorMsg}`);\n\t\t\t\treturn { status: \"failed\" };\n\t\t\t}\n\t\t\treturn { status: \"cancelled\" };\n\t\t} finally {\n\t\t\tdialog.signal.removeEventListener(\"abort\", onDialogAbort);\n\t\t}\n\t}\n\n\tprivate async showApiKeyLoginDialog(\n\t\tproviderId: string,\n\t\tproviderName: string,\n\t\tkind: \"provider\" | \"service\" = \"provider\",\n\t): Promise<AuthenticationResult> {\n\t\tconst dialog = new LoginDialogComponent(this.host.ui, providerId, (_success, _message) => {}, providerName);\n\n\t\tconst handle = showFullPaneOverlay(this.host.ui, dialog, 88);\n\n\t\tconst closeDialog = () => {\n\t\t\thandle.hide();\n\t\t\tthis.host.ui.requestRender();\n\t\t};\n\n\t\ttry {\n\t\t\tconst apiKey = (await dialog.showPrompt(\"Enter API key:\")).trim();\n\t\t\tif (!apiKey) {\n\t\t\t\tthrow new Error(\"API key cannot be empty.\");\n\t\t\t}\n\n\t\t\tthis.host.modelRegistry.authStorage.set(providerId, { type: \"api_key\", key: apiKey });\n\n\t\t\tcloseDialog();\n\t\t\treturn await this.completeProviderAuthentication(providerId, providerName, \"api_key\", undefined, kind);\n\t\t} catch (error: unknown) {\n\t\t\tcloseDialog();\n\t\t\tconst errorMsg = error instanceof Error ? error.message : String(error);\n\t\t\tif (errorMsg !== \"Login cancelled\") {\n\t\t\t\tthis.host.showError(`Failed to save API key for ${providerName}: ${errorMsg}`);\n\t\t\t\treturn { status: \"failed\" };\n\t\t\t}\n\t\t\treturn { status: \"cancelled\" };\n\t\t}\n\t}\n\n\tprivate showOAuthLoginSelect(dialogHandle: OverlayHandle, prompt: OAuthSelectPrompt): Promise<string | undefined> {\n\t\treturn new Promise((resolve) => {\n\t\t\tdialogHandle.setHidden(true);\n\t\t\tlet selectorHandle: OverlayHandle | undefined;\n\t\t\tconst restoreDialog = () => {\n\t\t\t\tselectorHandle?.hide();\n\t\t\t\tdialogHandle.setHidden(false);\n\t\t\t\tdialogHandle.focus();\n\t\t\t\tthis.host.ui.requestRender();\n\t\t\t};\n\t\t\tconst labels = prompt.options.map((option) => option.label);\n\t\t\tconst selector = new ExtensionSelectorComponent(\n\t\t\t\tprompt.message,\n\t\t\t\tlabels,\n\t\t\t\t(optionLabel) => {\n\t\t\t\t\trestoreDialog();\n\t\t\t\t\tresolve(prompt.options.find((option) => option.label === optionLabel)?.id);\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\trestoreDialog();\n\t\t\t\t\tresolve(undefined);\n\t\t\t\t},\n\t\t\t\t{ getRows: () => this.host.ui.terminal.rows },\n\t\t\t);\n\t\t\tselectorHandle = showFullPaneOverlay(this.host.ui, selector, 76);\n\t\t});\n\t}\n\n\tprivate async showLoginDialog(\n\t\tproviderId: string,\n\t\tproviderName: string,\n\t\tkind: \"provider\" | \"service\" = \"provider\",\n\t): Promise<AuthenticationResult> {\n\t\tconst providerInfo = this.host.modelRegistry.authStorage\n\t\t\t.getOAuthProviders()\n\t\t\t.find((provider) => provider.id === providerId);\n\n\t\tconst usesCallbackServer = providerInfo?.usesCallbackServer ?? false;\n\n\t\tconst dialog = new LoginDialogComponent(this.host.ui, providerId, (_success, _message) => {}, providerName);\n\n\t\tconst dialogHandle = showFullPaneOverlay(this.host.ui, dialog, {\n\t\t\tmaxContentWidth: 88,\n\t\t\tsuspendFullscreenMouse: true,\n\t\t});\n\n\t\tlet manualCodeResolve: ((code: string) => void) | undefined;\n\t\tlet manualCodeReject: ((err: Error) => void) | undefined;\n\t\tconst manualCodePromise = new Promise<string>((resolve, reject) => {\n\t\t\tmanualCodeResolve = resolve;\n\t\t\tmanualCodeReject = reject;\n\t\t});\n\n\t\tconst closeDialog = () => {\n\t\t\tdialogHandle.hide();\n\t\t\tthis.host.ui.requestRender();\n\t\t};\n\n\t\ttry {\n\t\t\tawait this.host.modelRegistry.authStorage.login(providerId as OAuthProviderId, {\n\t\t\t\tonAuth: (info: { url: string; instructions?: string }) => {\n\t\t\t\t\tdialog.showAuth(info.url, info.instructions);\n\n\t\t\t\t\tif (usesCallbackServer) {\n\t\t\t\t\t\tdialog\n\t\t\t\t\t\t\t.showManualInput(\"Paste redirect URL below, or complete login in browser:\")\n\t\t\t\t\t\t\t.then((value) => {\n\t\t\t\t\t\t\t\tif (value && manualCodeResolve) {\n\t\t\t\t\t\t\t\t\tmanualCodeResolve(value);\n\t\t\t\t\t\t\t\t\tmanualCodeResolve = undefined;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.catch(() => {\n\t\t\t\t\t\t\t\tif (manualCodeReject) {\n\t\t\t\t\t\t\t\t\tmanualCodeReject(new Error(\"Login cancelled\"));\n\t\t\t\t\t\t\t\t\tmanualCodeReject = undefined;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t} else if (providerId === \"github-copilot\") {\n\t\t\t\t\t\tdialog.showWaiting(\"Waiting for browser authentication...\");\n\t\t\t\t\t}\n\t\t\t\t},\n\n\t\t\t\tonPrompt: async (prompt: { message: string; placeholder?: string }) => {\n\t\t\t\t\treturn dialog.showPrompt(prompt.message, prompt.placeholder);\n\t\t\t\t},\n\n\t\t\t\tonProgress: (message: string) => {\n\t\t\t\t\tdialog.showProgress(message);\n\t\t\t\t},\n\n\t\t\t\tonSelect: (prompt: OAuthSelectPrompt) => this.showOAuthLoginSelect(dialogHandle, prompt),\n\n\t\t\t\tonManualCodeInput: () => manualCodePromise,\n\n\t\t\t\tsignal: dialog.signal,\n\t\t\t});\n\n\t\t\tcloseDialog();\n\t\t\treturn await this.completeProviderAuthentication(providerId, providerName, \"oauth\", undefined, kind);\n\t\t} catch (error: unknown) {\n\t\t\tcloseDialog();\n\t\t\tconst errorMsg = error instanceof Error ? error.message : String(error);\n\t\t\tif (errorMsg !== \"Login cancelled\") {\n\t\t\t\tthis.host.showError(`Failed to login to ${providerName}: ${errorMsg}`);\n\t\t\t\treturn { status: \"failed\" };\n\t\t\t}\n\t\t\treturn { status: \"cancelled\" };\n\t\t}\n\t}\n}\n"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-custom-provider",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.3",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-custom-provider",
|
|
9
|
-
"version": "0.9.
|
|
9
|
+
"version": "0.9.3",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sdk": "^0.52.0"
|
|
12
12
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-sandbox",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.3",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-sandbox",
|
|
9
|
-
"version": "0.9.
|
|
9
|
+
"version": "0.9.3",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sandbox-runtime": "^0.0.55"
|
|
12
12
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-with-deps",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.3",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-with-deps",
|
|
9
|
-
"version": "0.9.
|
|
9
|
+
"version": "0.9.3",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"ms": "^2.1.3"
|
|
12
12
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asm-agent/coding-agent",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.3",
|
|
4
4
|
"description": "Coding agent CLI with a persistent Python REPL kernel and session management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"asmAgentConfig": {
|
|
@@ -48,10 +48,10 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@agentclientprotocol/sdk": "^1.3.0",
|
|
51
|
-
"@asm-agent/agent": "^0.9.
|
|
52
|
-
"@asm-agent/ai": "^0.9.
|
|
53
|
-
"@asm-agent/postgres": "^0.9.
|
|
54
|
-
"@asm-agent/tui": "^0.9.
|
|
51
|
+
"@asm-agent/agent": "^0.9.3",
|
|
52
|
+
"@asm-agent/ai": "^0.9.3",
|
|
53
|
+
"@asm-agent/postgres": "^0.9.3",
|
|
54
|
+
"@asm-agent/tui": "^0.9.3",
|
|
55
55
|
"@silvia-odwyer/photon-node": "^0.3.4",
|
|
56
56
|
"chalk": "^5.5.0",
|
|
57
57
|
"cli-highlight": "^2.1.11",
|