@code-yeongyu/senpi-ai 2026.9.28 → 2026.9.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/dist/api/anthropic-messages.d.ts.map +1 -1
  2. package/dist/api/anthropic-messages.js +76 -24
  3. package/dist/api/anthropic-messages.js.map +1 -1
  4. package/dist/api/bedrock-converse-stream.js +6 -1
  5. package/dist/api/bedrock-converse-stream.js.map +1 -1
  6. package/dist/api/github-copilot-endpoint.d.ts +19 -0
  7. package/dist/api/github-copilot-endpoint.d.ts.map +1 -0
  8. package/dist/api/github-copilot-endpoint.js +48 -0
  9. package/dist/api/github-copilot-endpoint.js.map +1 -0
  10. package/dist/api/github-copilot-errors.d.ts +9 -0
  11. package/dist/api/github-copilot-errors.d.ts.map +1 -0
  12. package/dist/api/github-copilot-errors.js +78 -0
  13. package/dist/api/github-copilot-errors.js.map +1 -0
  14. package/dist/api/github-copilot-headers.d.ts +1 -0
  15. package/dist/api/github-copilot-headers.d.ts.map +1 -1
  16. package/dist/api/github-copilot-headers.js +3 -0
  17. package/dist/api/github-copilot-headers.js.map +1 -1
  18. package/dist/api/openai-completions.d.ts.map +1 -1
  19. package/dist/api/openai-completions.js +18 -12
  20. package/dist/api/openai-completions.js.map +1 -1
  21. package/dist/api/openai-responses.d.ts.map +1 -1
  22. package/dist/api/openai-responses.js +38 -2
  23. package/dist/api/openai-responses.js.map +1 -1
  24. package/dist/auth/helpers.d.ts +1 -0
  25. package/dist/auth/helpers.d.ts.map +1 -1
  26. package/dist/auth/helpers.js +1 -0
  27. package/dist/auth/helpers.js.map +1 -1
  28. package/dist/auth/oauth/github-copilot-model-catalog.d.ts +7 -0
  29. package/dist/auth/oauth/github-copilot-model-catalog.d.ts.map +1 -0
  30. package/dist/auth/oauth/github-copilot-model-catalog.js +46 -0
  31. package/dist/auth/oauth/github-copilot-model-catalog.js.map +1 -0
  32. package/dist/auth/oauth/github-copilot.d.ts.map +1 -1
  33. package/dist/auth/oauth/github-copilot.js +24 -77
  34. package/dist/auth/oauth/github-copilot.js.map +1 -1
  35. package/dist/auth/pool/slots.d.ts.map +1 -1
  36. package/dist/auth/pool/slots.js +21 -3
  37. package/dist/auth/pool/slots.js.map +1 -1
  38. package/dist/auth/resolve.d.ts +6 -0
  39. package/dist/auth/resolve.d.ts.map +1 -1
  40. package/dist/auth/resolve.js +6 -5
  41. package/dist/auth/resolve.js.map +1 -1
  42. package/dist/auth/types.d.ts +14 -0
  43. package/dist/auth/types.d.ts.map +1 -1
  44. package/dist/auth/types.js.map +1 -1
  45. package/dist/cursor/context-limit-store.d.ts.map +1 -1
  46. package/dist/cursor/context-limit-store.js +23 -18
  47. package/dist/cursor/context-limit-store.js.map +1 -1
  48. package/dist/models.d.ts.map +1 -1
  49. package/dist/models.js +3 -2
  50. package/dist/models.js.map +1 -1
  51. package/dist/openai-responses-compat.d.ts +6 -0
  52. package/dist/openai-responses-compat.d.ts.map +1 -1
  53. package/dist/openai-responses-compat.js.map +1 -1
  54. package/dist/providers/amazon-bedrock.js +13 -13
  55. package/dist/providers/amazon-bedrock.js.map +1 -1
  56. package/dist/providers/data/.manifest.json +1 -1
  57. package/dist/providers/data/amazon-bedrock.json +1 -1
  58. package/dist/providers/data/anthropic.json +1 -1
  59. package/dist/providers/data/azure-openai-responses.json +1 -1
  60. package/dist/providers/data/cloudflare-ai-gateway.json +1 -1
  61. package/dist/providers/data/cloudflare-workers-ai.json +1 -1
  62. package/dist/providers/data/mistral.json +1 -1
  63. package/dist/providers/data/openai.json +1 -1
  64. package/dist/providers/data/opencode-go.json +1 -1
  65. package/dist/providers/data/opencode.json +1 -1
  66. package/dist/providers/data/opengateway.json +1 -1
  67. package/dist/providers/data/openrouter.json +1 -1
  68. package/dist/providers/data/together.json +1 -1
  69. package/dist/providers/data/venice.json +1 -1
  70. package/dist/providers/data/vercel-ai-gateway.json +1 -1
  71. package/dist/providers/devin.models.d.ts +5 -3
  72. package/dist/providers/devin.models.d.ts.map +1 -1
  73. package/dist/providers/devin.models.js +6 -5
  74. package/dist/providers/devin.models.js.map +1 -1
  75. package/dist/providers/github-copilot-limits.d.ts +11 -0
  76. package/dist/providers/github-copilot-limits.d.ts.map +1 -0
  77. package/dist/providers/github-copilot-limits.js +65 -0
  78. package/dist/providers/github-copilot-limits.js.map +1 -0
  79. package/dist/providers/github-copilot.d.ts.map +1 -1
  80. package/dist/providers/github-copilot.js +24 -3
  81. package/dist/providers/github-copilot.js.map +1 -1
  82. package/dist/providers/google-vertex.d.ts.map +1 -1
  83. package/dist/providers/google-vertex.js +3 -5
  84. package/dist/providers/google-vertex.js.map +1 -1
  85. package/dist/session-resources.d.ts.map +1 -1
  86. package/dist/session-resources.js +2 -1
  87. package/dist/session-resources.js.map +1 -1
  88. package/dist/types.d.ts +6 -0
  89. package/dist/types.d.ts.map +1 -1
  90. package/dist/types.js.map +1 -1
  91. package/dist/utils/block-symbols.d.ts +4 -0
  92. package/dist/utils/block-symbols.d.ts.map +1 -1
  93. package/dist/utils/block-symbols.js +10 -6
  94. package/dist/utils/block-symbols.js.map +1 -1
  95. package/dist/utils/claude-code-version-cache.d.ts +12 -0
  96. package/dist/utils/claude-code-version-cache.d.ts.map +1 -0
  97. package/dist/utils/claude-code-version-cache.js +60 -0
  98. package/dist/utils/claude-code-version-cache.js.map +1 -0
  99. package/dist/utils/claude-code-version.d.ts +78 -0
  100. package/dist/utils/claude-code-version.d.ts.map +1 -0
  101. package/dist/utils/claude-code-version.js +203 -0
  102. package/dist/utils/claude-code-version.js.map +1 -0
  103. package/dist/utils/cursor-context-limit.d.ts.map +1 -1
  104. package/dist/utils/cursor-context-limit.js +51 -45
  105. package/dist/utils/cursor-context-limit.js.map +1 -1
  106. package/dist/utils/github-copilot-tool-limit.d.ts +10 -0
  107. package/dist/utils/github-copilot-tool-limit.d.ts.map +1 -0
  108. package/dist/utils/github-copilot-tool-limit.js +75 -0
  109. package/dist/utils/github-copilot-tool-limit.js.map +1 -0
  110. package/dist/utils/overflow.d.ts.map +1 -1
  111. package/dist/utils/overflow.js +3 -1
  112. package/dist/utils/overflow.js.map +1 -1
  113. package/dist/utils/process-singleton.d.ts +10 -0
  114. package/dist/utils/process-singleton.d.ts.map +1 -0
  115. package/dist/utils/process-singleton.js +18 -0
  116. package/dist/utils/process-singleton.js.map +1 -0
  117. package/dist/utils/prompt-cache-ttl.d.ts +3 -1
  118. package/dist/utils/prompt-cache-ttl.d.ts.map +1 -1
  119. package/dist/utils/prompt-cache-ttl.js +4 -2
  120. package/dist/utils/prompt-cache-ttl.js.map +1 -1
  121. package/dist/utils/retry.d.ts +3 -0
  122. package/dist/utils/retry.d.ts.map +1 -1
  123. package/dist/utils/retry.js +15 -3
  124. package/dist/utils/retry.js.map +1 -1
  125. package/dist/utils/tool-choice-fallback.d.ts +29 -0
  126. package/dist/utils/tool-choice-fallback.d.ts.map +1 -1
  127. package/dist/utils/tool-choice-fallback.js +50 -2
  128. package/dist/utils/tool-choice-fallback.js.map +1 -1
  129. package/package.json +2 -2
@@ -56,7 +56,7 @@ async function resolveProviderAuthWithSignal(provider, credentials, authContext,
56
56
  if (!projected)
57
57
  return undefined;
58
58
  if (projected.type === "oauth" && provider.auth.oauth) {
59
- return resolveStoredOAuth(credentials, provider.id, provider.auth.oauth, projected, requestAuthContext, overrides?.env, signal, overrides?.minOAuthValidityMs, slotName);
59
+ return resolveStoredOAuth(credentials, provider.id, provider.auth.oauth, projected, requestAuthContext, overrides?.env, signal, overrides?.minOAuthValidityMs, slotName, overrides?.rejectedAccess);
60
60
  }
61
61
  if (projected.type === "api_key" && provider.auth.apiKey) {
62
62
  const credential = overrides?.env ? { ...projected, env: { ...projected.env, ...overrides.env } } : projected;
@@ -66,7 +66,7 @@ async function resolveProviderAuthWithSignal(provider, credentials, authContext,
66
66
  }
67
67
  if (stored) {
68
68
  if (stored.type === "oauth" && provider.auth.oauth) {
69
- return resolveStoredOAuth(credentials, provider.id, provider.auth.oauth, stored, requestAuthContext, overrides?.env, signal, overrides?.minOAuthValidityMs);
69
+ return resolveStoredOAuth(credentials, provider.id, provider.auth.oauth, stored, requestAuthContext, overrides?.env, signal, overrides?.minOAuthValidityMs, undefined, overrides?.rejectedAccess);
70
70
  }
71
71
  if (stored.type === "api_key" && provider.auth.apiKey) {
72
72
  const credential = overrides?.env ? { ...stored, env: { ...stored.env, ...overrides.env } } : stored;
@@ -107,11 +107,12 @@ export function oauthRefreshModelsError(error, providerId) {
107
107
  * through `refreshOAuthCredential`, which re-checks the stored value, runs the
108
108
  * exchange outside the store lock, and compare-and-swaps the rotated slot.
109
109
  */
110
- async function resolveStoredOAuth(credentials, providerId, oauth, stored, authContext, requestEnv, signal, minOAuthValidityMs, slotName) {
110
+ async function resolveStoredOAuth(credentials, providerId, oauth, stored, authContext, requestEnv, signal, minOAuthValidityMs, slotName, rejectedAccess) {
111
111
  const minimumValidityMs = Math.max(DEFAULT_OAUTH_MINIMUM_VALIDITY_MS, minOAuthValidityMs ?? 0);
112
112
  const expiresSoon = (credential) => Date.now() + minimumValidityMs >= credential.expires;
113
+ const isStale = (credential) => expiresSoon(credential) || (rejectedAccess !== undefined && credential.access === rejectedAccess);
113
114
  let credential = stored;
114
- if (expiresSoon(credential)) {
115
+ if (isStale(credential)) {
115
116
  let post;
116
117
  try {
117
118
  post = await refreshOAuthCredential({
@@ -120,7 +121,7 @@ async function resolveStoredOAuth(credentials, providerId, oauth, stored, authCo
120
121
  oauth,
121
122
  stale: credential,
122
123
  slotName,
123
- isStale: expiresSoon,
124
+ isStale,
124
125
  signal,
125
126
  owning: true,
126
127
  });
@@ -1 +1 @@
1
- {"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/auth/resolve.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EACN,yBAAyB,EACzB,sBAAsB,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E,CAAC;QAChB,MAAM,IAAI,WAAW,CAAC,MAAM,EAAE,oCAAoC,UAAU,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACnG,CAAC;AACF,CAAC;AAED,KAAK,UAAU,cAAc,CAC5B,WAA4B,EAC5B,UAAkB,EAClB,MAAmB;IAEnB,IAAI,CAAC;QACJ,OAAO,MAAM,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IACvD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,IAAI,WAAW,CAAC,MAAM,EAAE,oCAAoC,UAAU,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACnG,CAAC;AACF,CAAC","sourcesContent":["import type { ProviderEnv } from \"../types.ts\";\nimport { operationSignal, raceWithAbortSignal } from \"../utils/abort.ts\";\nimport { formatThrownValue } from \"../utils/diagnostics.ts\";\nimport {\n\tOAuthRefreshExchangeError,\n\tOAuthRefreshStoreError,\n\tprojectOAuthSlot,\n\trefreshOAuthCredential,\n} from \"./oauth-refresh.ts\";\nimport { projectSlot } from \"./pool/slots.ts\";\nimport type {\n\tApiKeyAuth,\n\tApiKeyCredential,\n\tAuthContext,\n\tAuthResult,\n\tCredential,\n\tCredentialStore,\n\tOAuthAuth,\n\tOAuthCredential,\n\tProviderAuth,\n} from \"./types.ts\";\n\nexport type ModelsErrorCode = \"model_source\" | \"model_validation\" | \"provider\" | \"stream\" | \"auth\" | \"oauth\";\n\nexport interface AuthResolutionOverrides {\n\tapiKey?: string;\n\tenv?: ProviderEnv;\n\t/** Require this much remaining OAuth-token validity; defaults to five minutes. */\n\tminOAuthValidityMs?: number;\n\t/**\n\t * Resolve against one named slot of a pooled credential. A missing entry or\n\t * slot resolves to undefined rather than falling back to another account or\n\t * ambient env, so a slot-scoped request can never silently switch identities.\n\t */\n\tslotName?: string;\n\tsignal?: AbortSignal;\n}\n\n/**\n * Prefix of the auth-miss every resolution site raises when a provider has no\n * usable credential. Consumers key recovery decisions off this exact wording,\n * so it is a shared constant instead of a literal repeated at each throw site:\n * rewording one copy would silently disable the other's behavior.\n */\nexport const PROVIDER_NOT_CONFIGURED_PREFIX = \"Provider is not configured: \";\n\nexport function providerNotConfiguredMessage(providerId: string): string {\n\treturn `${PROVIDER_NOT_CONFIGURED_PREFIX}${providerId}`;\n}\n\nexport class ModelsError extends Error {\n\treadonly code: ModelsErrorCode;\n\n\tconstructor(code: ModelsErrorCode, message: string, options?: { cause?: unknown }) {\n\t\tsuper(withCauseDetail(message, options?.cause), options);\n\t\tthis.name = \"ModelsError\";\n\t\tthis.code = code;\n\t}\n}\n\n/** Callers surface `error.message` only, so keep the underlying reason in it. */\nfunction withCauseDetail(message: string, cause: unknown): string {\n\tif (cause === undefined || cause === null) return message;\n\tconst detail = formatThrownValue(cause).trim();\n\tif (!detail || message.includes(detail)) return message;\n\treturn `${message}: ${detail}`;\n}\n\n/**\n * Auth resolution shared by the `Models` and `ImagesModels` collections.\n * A stored credential owns the provider: ambient/env is consulted only when\n * nothing is stored. No silent env fallback after a failed refresh or for a\n * credential type without a matching handler.\n */\nexport function resolveProviderAuth(\n\tprovider: { id: string; auth: ProviderAuth },\n\tcredentials: CredentialStore,\n\tauthContext: AuthContext,\n\toverrides?: AuthResolutionOverrides,\n): Promise<AuthResult | undefined> {\n\tconst signal = operationSignal(overrides?.signal);\n\treturn raceWithAbortSignal(\n\t\tresolveProviderAuthWithSignal(provider, credentials, authContext, overrides, signal),\n\t\tsignal,\n\t);\n}\n\nasync function resolveProviderAuthWithSignal(\n\tprovider: { id: string; auth: ProviderAuth },\n\tcredentials: CredentialStore,\n\tauthContext: AuthContext,\n\toverrides: AuthResolutionOverrides | undefined,\n\tsignal: AbortSignal,\n): Promise<AuthResult | undefined> {\n\tsignal.throwIfAborted();\n\tconst requestAuthContext = overrides?.env ? overlayEnvAuthContext(authContext, overrides.env) : authContext;\n\tconst apiKey = provider.auth.apiKey;\n\n\tif (overrides?.apiKey !== undefined && apiKey && !apiKey.ambientOnly) {\n\t\treturn resolveApiKey(\n\t\t\trequestAuthContext,\n\t\t\tapiKey,\n\t\t\tprovider.id,\n\t\t\t{\n\t\t\t\ttype: \"api_key\",\n\t\t\t\tkey: overrides.apiKey,\n\t\t\t\tenv: overrides.env,\n\t\t\t},\n\t\t\tsignal,\n\t\t);\n\t}\n\n\tconst stored = await readCredential(credentials, provider.id, signal);\n\tconst slotName = overrides?.slotName;\n\tif (slotName !== undefined) {\n\t\tconst projected = stored === undefined ? undefined : projectSlot(stored, slotName);\n\t\tif (!projected) return undefined;\n\t\tif (projected.type === \"oauth\" && provider.auth.oauth) {\n\t\t\treturn resolveStoredOAuth(\n\t\t\t\tcredentials,\n\t\t\t\tprovider.id,\n\t\t\t\tprovider.auth.oauth,\n\t\t\t\tprojected,\n\t\t\t\trequestAuthContext,\n\t\t\t\toverrides?.env,\n\t\t\t\tsignal,\n\t\t\t\toverrides?.minOAuthValidityMs,\n\t\t\t\tslotName,\n\t\t\t);\n\t\t}\n\t\tif (projected.type === \"api_key\" && provider.auth.apiKey) {\n\t\t\tconst credential = overrides?.env ? { ...projected, env: { ...projected.env, ...overrides.env } } : projected;\n\t\t\treturn resolveApiKey(requestAuthContext, provider.auth.apiKey, provider.id, credential, signal);\n\t\t}\n\t\treturn undefined;\n\t}\n\tif (stored) {\n\t\tif (stored.type === \"oauth\" && provider.auth.oauth) {\n\t\t\treturn resolveStoredOAuth(\n\t\t\t\tcredentials,\n\t\t\t\tprovider.id,\n\t\t\t\tprovider.auth.oauth,\n\t\t\t\tstored,\n\t\t\t\trequestAuthContext,\n\t\t\t\toverrides?.env,\n\t\t\t\tsignal,\n\t\t\t\toverrides?.minOAuthValidityMs,\n\t\t\t);\n\t\t}\n\t\tif (stored.type === \"api_key\" && provider.auth.apiKey) {\n\t\t\tconst credential = overrides?.env ? { ...stored, env: { ...stored.env, ...overrides.env } } : stored;\n\t\t\treturn resolveApiKey(requestAuthContext, provider.auth.apiKey, provider.id, credential, signal);\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tif (overrides?.apiKey !== undefined && apiKey) {\n\t\treturn resolveApiKey(\n\t\t\trequestAuthContext,\n\t\t\tapiKey,\n\t\t\tprovider.id,\n\t\t\t{\n\t\t\t\ttype: \"api_key\",\n\t\t\t\tkey: overrides.apiKey,\n\t\t\t\tenv: overrides.env,\n\t\t\t},\n\t\t\tsignal,\n\t\t);\n\t}\n\n\t// Ambient (env vars, AWS profiles, ADC files).\n\tconst ambientCredential =\n\t\tapiKey?.ambientOnly && overrides?.env ? { type: \"api_key\" as const, key: \"\", env: overrides.env } : undefined;\n\treturn apiKey ? resolveApiKey(requestAuthContext, apiKey, provider.id, ambientCredential, signal) : undefined;\n}\n\nfunction overlayEnvAuthContext(base: AuthContext, env: ProviderEnv): AuthContext {\n\treturn {\n\t\tenv: async (name) => (env[name] !== undefined ? env[name] : await base.env(name)),\n\t\tfileExists: (path) => base.fileExists(path),\n\t};\n}\n\nconst DEFAULT_OAUTH_MINIMUM_VALIDITY_MS = 5 * 60 * 1000;\n\n/** Maps a shared-refresh failure onto the `ModelsError` codes callers match on. */\nexport function oauthRefreshModelsError(error: unknown, providerId: string): ModelsError {\n\tif (error instanceof ModelsError) return error;\n\tif (error instanceof OAuthRefreshExchangeError) {\n\t\treturn new ModelsError(\"oauth\", `OAuth refresh failed for ${providerId}`, { cause: error.cause });\n\t}\n\tconst cause = error instanceof OAuthRefreshStoreError ? error.cause : error;\n\treturn new ModelsError(\"auth\", `Credential store modify failed for ${providerId}`, { cause });\n}\n\n/**\n * OAuth resolution: a token with less than five minutes remaining is refreshed\n * through `refreshOAuthCredential`, which re-checks the stored value, runs the\n * exchange outside the store lock, and compare-and-swaps the rotated slot.\n */\nasync function resolveStoredOAuth(\n\tcredentials: CredentialStore,\n\tproviderId: string,\n\toauth: OAuthAuth,\n\tstored: OAuthCredential,\n\tauthContext: AuthContext,\n\trequestEnv: ProviderEnv | undefined,\n\tsignal: AbortSignal,\n\tminOAuthValidityMs?: number,\n\tslotName?: string,\n): Promise<AuthResult | undefined> {\n\tconst minimumValidityMs = Math.max(DEFAULT_OAUTH_MINIMUM_VALIDITY_MS, minOAuthValidityMs ?? 0);\n\tconst expiresSoon = (credential: OAuthCredential) => Date.now() + minimumValidityMs >= credential.expires;\n\tlet credential = stored;\n\n\tif (expiresSoon(credential)) {\n\t\tlet post: Credential | undefined;\n\t\ttry {\n\t\t\tpost = await refreshOAuthCredential({\n\t\t\t\tcredentials,\n\t\t\t\tproviderId,\n\t\t\t\toauth,\n\t\t\t\tstale: credential,\n\t\t\t\tslotName,\n\t\t\t\tisStale: expiresSoon,\n\t\t\t\tsignal,\n\t\t\t\towning: true,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tthrow oauthRefreshModelsError(error, providerId);\n\t\t}\n\t\tif (post?.type !== \"oauth\") return undefined; // logged out meanwhile\n\t\tconst postView = slotName === undefined ? post : projectOAuthSlot(post, slotName);\n\t\tif (!postView) return undefined; // slot removed meanwhile\n\t\tcredential = postView;\n\t\t// The normal five-minute window triggers a refresh but does not impose a\n\t\t// provider contract. Explicit callers (such as bearer-token export) do\n\t\t// require the requested minimum after the refresh.\n\t\tif (minOAuthValidityMs !== undefined && expiresSoon(credential)) {\n\t\t\tthrow new ModelsError(\"oauth\", `OAuth refresh returned a token that expires too soon for ${providerId}`);\n\t\t}\n\t}\n\n\tconst storedEnv = credentialEnvironment(credential);\n\tconst effectiveEnv = requestEnv ? { ...storedEnv, ...requestEnv } : storedEnv;\n\tconst effectiveCredential = effectiveEnv ? { ...credential, env: effectiveEnv } : credential;\n\n\tif (oauth.check) {\n\t\ttry {\n\t\t\tif (!(await oauth.check({ ctx: authContext, credential: effectiveCredential, signal }))) return undefined;\n\t\t} catch (error) {\n\t\t\tthrow new ModelsError(\"auth\", `OAuth auth check failed for provider ${providerId}`, { cause: error });\n\t\t}\n\t}\n\n\ttry {\n\t\treturn {\n\t\t\tauth: await oauth.toAuth(effectiveCredential),\n\t\t\t...(effectiveEnv ? { env: effectiveEnv } : {}),\n\t\t\tsource: \"OAuth\",\n\t\t};\n\t} catch (error) {\n\t\tthrow new ModelsError(\"oauth\", `OAuth auth derivation failed for ${providerId}`, { cause: error });\n\t}\n}\n\nfunction credentialEnvironment(credential: OAuthCredential): ProviderEnv | undefined {\n\tconst value = credential.env;\n\tif (typeof value !== \"object\" || value === null || Array.isArray(value)) return undefined;\n\tconst environment: ProviderEnv = {};\n\tfor (const [name, entry] of Object.entries(value)) {\n\t\tif (typeof entry !== \"string\") return undefined;\n\t\tenvironment[name] = entry;\n\t}\n\treturn environment;\n}\n\nasync function resolveApiKey(\n\tauthContext: AuthContext,\n\tapiKey: ApiKeyAuth,\n\tproviderId: string,\n\tcredential: ApiKeyCredential | undefined,\n\tsignal: AbortSignal,\n): Promise<AuthResult | undefined> {\n\ttry {\n\t\treturn await apiKey.resolve({ ctx: authContext, credential, signal });\n\t} catch (error) {\n\t\tthrow new ModelsError(\"auth\", `API key auth failed for provider ${providerId}`, { cause: error });\n\t}\n}\n\nasync function readCredential(\n\tcredentials: CredentialStore,\n\tproviderId: string,\n\tsignal: AbortSignal,\n): Promise<Credential | undefined> {\n\ttry {\n\t\treturn await credentials.read(providerId, { signal });\n\t} catch (error) {\n\t\tthrow new ModelsError(\"auth\", `Credential store read failed for ${providerId}`, { cause: error });\n\t}\n}\n"]}
1
+ {"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/auth/resolve.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EACN,yBAAyB,EACzB,sBAAsB,EACtB,gBAAgB,EAChB,sBAAsB,GACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAmC9C;;;;;GAK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AAG,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC;IACvE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,IAAI,WAAW,CAAC,MAAM,EAAE,oCAAoC,UAAU,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACnG,CAAC;AACF,CAAC;AAED,KAAK,UAAU,cAAc,CAC5B,WAA4B,EAC5B,UAAkB,EAClB,MAAmB;IAEnB,IAAI,CAAC;QACJ,OAAO,MAAM,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IACvD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,IAAI,WAAW,CAAC,MAAM,EAAE,oCAAoC,UAAU,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACnG,CAAC;AACF,CAAC","sourcesContent":["import type { ProviderEnv } from \"../types.ts\";\nimport { operationSignal, raceWithAbortSignal } from \"../utils/abort.ts\";\nimport { formatThrownValue } from \"../utils/diagnostics.ts\";\nimport {\n\tOAuthRefreshExchangeError,\n\tOAuthRefreshStoreError,\n\tprojectOAuthSlot,\n\trefreshOAuthCredential,\n} from \"./oauth-refresh.ts\";\nimport { projectSlot } from \"./pool/slots.ts\";\nimport type {\n\tApiKeyAuth,\n\tApiKeyCredential,\n\tAuthContext,\n\tAuthResult,\n\tCredential,\n\tCredentialStore,\n\tOAuthAuth,\n\tOAuthCredential,\n\tProviderAuth,\n} from \"./types.ts\";\n\nexport type ModelsErrorCode = \"model_source\" | \"model_validation\" | \"provider\" | \"stream\" | \"auth\" | \"oauth\";\n\nexport interface AuthResolutionOverrides {\n\tapiKey?: string;\n\tenv?: ProviderEnv;\n\t/** Require this much remaining OAuth-token validity; defaults to five minutes. */\n\tminOAuthValidityMs?: number;\n\t/**\n\t * Resolve against one named slot of a pooled credential. A missing entry or\n\t * slot resolves to undefined rather than falling back to another account or\n\t * ambient env, so a slot-scoped request can never silently switch identities.\n\t */\n\tslotName?: string;\n\t/**\n\t * An access token the provider just refused with one of its\n\t * `OAuthAuth.rejectedTokenStatuses`. A stored OAuth credential still carrying it\n\t * is re-exchanged regardless of its expiry; one already rotated is used as is.\n\t */\n\trejectedAccess?: string;\n\tsignal?: AbortSignal;\n}\n\n/**\n * Prefix of the auth-miss every resolution site raises when a provider has no\n * usable credential. Consumers key recovery decisions off this exact wording,\n * so it is a shared constant instead of a literal repeated at each throw site:\n * rewording one copy would silently disable the other's behavior.\n */\nexport const PROVIDER_NOT_CONFIGURED_PREFIX = \"Provider is not configured: \";\n\nexport function providerNotConfiguredMessage(providerId: string): string {\n\treturn `${PROVIDER_NOT_CONFIGURED_PREFIX}${providerId}`;\n}\n\nexport class ModelsError extends Error {\n\treadonly code: ModelsErrorCode;\n\n\tconstructor(code: ModelsErrorCode, message: string, options?: { cause?: unknown }) {\n\t\tsuper(withCauseDetail(message, options?.cause), options);\n\t\tthis.name = \"ModelsError\";\n\t\tthis.code = code;\n\t}\n}\n\n/** Callers surface `error.message` only, so keep the underlying reason in it. */\nfunction withCauseDetail(message: string, cause: unknown): string {\n\tif (cause === undefined || cause === null) return message;\n\tconst detail = formatThrownValue(cause).trim();\n\tif (!detail || message.includes(detail)) return message;\n\treturn `${message}: ${detail}`;\n}\n\n/**\n * Auth resolution shared by the `Models` and `ImagesModels` collections.\n * A stored credential owns the provider: ambient/env is consulted only when\n * nothing is stored. No silent env fallback after a failed refresh or for a\n * credential type without a matching handler.\n */\nexport function resolveProviderAuth(\n\tprovider: { id: string; auth: ProviderAuth },\n\tcredentials: CredentialStore,\n\tauthContext: AuthContext,\n\toverrides?: AuthResolutionOverrides,\n): Promise<AuthResult | undefined> {\n\tconst signal = operationSignal(overrides?.signal);\n\treturn raceWithAbortSignal(\n\t\tresolveProviderAuthWithSignal(provider, credentials, authContext, overrides, signal),\n\t\tsignal,\n\t);\n}\n\nasync function resolveProviderAuthWithSignal(\n\tprovider: { id: string; auth: ProviderAuth },\n\tcredentials: CredentialStore,\n\tauthContext: AuthContext,\n\toverrides: AuthResolutionOverrides | undefined,\n\tsignal: AbortSignal,\n): Promise<AuthResult | undefined> {\n\tsignal.throwIfAborted();\n\tconst requestAuthContext = overrides?.env ? overlayEnvAuthContext(authContext, overrides.env) : authContext;\n\tconst apiKey = provider.auth.apiKey;\n\n\tif (overrides?.apiKey !== undefined && apiKey && !apiKey.ambientOnly) {\n\t\treturn resolveApiKey(\n\t\t\trequestAuthContext,\n\t\t\tapiKey,\n\t\t\tprovider.id,\n\t\t\t{\n\t\t\t\ttype: \"api_key\",\n\t\t\t\tkey: overrides.apiKey,\n\t\t\t\tenv: overrides.env,\n\t\t\t},\n\t\t\tsignal,\n\t\t);\n\t}\n\n\tconst stored = await readCredential(credentials, provider.id, signal);\n\tconst slotName = overrides?.slotName;\n\tif (slotName !== undefined) {\n\t\tconst projected = stored === undefined ? undefined : projectSlot(stored, slotName);\n\t\tif (!projected) return undefined;\n\t\tif (projected.type === \"oauth\" && provider.auth.oauth) {\n\t\t\treturn resolveStoredOAuth(\n\t\t\t\tcredentials,\n\t\t\t\tprovider.id,\n\t\t\t\tprovider.auth.oauth,\n\t\t\t\tprojected,\n\t\t\t\trequestAuthContext,\n\t\t\t\toverrides?.env,\n\t\t\t\tsignal,\n\t\t\t\toverrides?.minOAuthValidityMs,\n\t\t\t\tslotName,\n\t\t\t\toverrides?.rejectedAccess,\n\t\t\t);\n\t\t}\n\t\tif (projected.type === \"api_key\" && provider.auth.apiKey) {\n\t\t\tconst credential = overrides?.env ? { ...projected, env: { ...projected.env, ...overrides.env } } : projected;\n\t\t\treturn resolveApiKey(requestAuthContext, provider.auth.apiKey, provider.id, credential, signal);\n\t\t}\n\t\treturn undefined;\n\t}\n\tif (stored) {\n\t\tif (stored.type === \"oauth\" && provider.auth.oauth) {\n\t\t\treturn resolveStoredOAuth(\n\t\t\t\tcredentials,\n\t\t\t\tprovider.id,\n\t\t\t\tprovider.auth.oauth,\n\t\t\t\tstored,\n\t\t\t\trequestAuthContext,\n\t\t\t\toverrides?.env,\n\t\t\t\tsignal,\n\t\t\t\toverrides?.minOAuthValidityMs,\n\t\t\t\tundefined,\n\t\t\t\toverrides?.rejectedAccess,\n\t\t\t);\n\t\t}\n\t\tif (stored.type === \"api_key\" && provider.auth.apiKey) {\n\t\t\tconst credential = overrides?.env ? { ...stored, env: { ...stored.env, ...overrides.env } } : stored;\n\t\t\treturn resolveApiKey(requestAuthContext, provider.auth.apiKey, provider.id, credential, signal);\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tif (overrides?.apiKey !== undefined && apiKey) {\n\t\treturn resolveApiKey(\n\t\t\trequestAuthContext,\n\t\t\tapiKey,\n\t\t\tprovider.id,\n\t\t\t{\n\t\t\t\ttype: \"api_key\",\n\t\t\t\tkey: overrides.apiKey,\n\t\t\t\tenv: overrides.env,\n\t\t\t},\n\t\t\tsignal,\n\t\t);\n\t}\n\n\t// Ambient (env vars, AWS profiles, ADC files).\n\tconst ambientCredential =\n\t\tapiKey?.ambientOnly && overrides?.env ? { type: \"api_key\" as const, key: \"\", env: overrides.env } : undefined;\n\treturn apiKey ? resolveApiKey(requestAuthContext, apiKey, provider.id, ambientCredential, signal) : undefined;\n}\n\nfunction overlayEnvAuthContext(base: AuthContext, env: ProviderEnv): AuthContext {\n\treturn {\n\t\tenv: async (name) => (env[name] !== undefined ? env[name] : await base.env(name)),\n\t\tfileExists: (path) => base.fileExists(path),\n\t};\n}\n\nconst DEFAULT_OAUTH_MINIMUM_VALIDITY_MS = 5 * 60 * 1000;\n\n/** Maps a shared-refresh failure onto the `ModelsError` codes callers match on. */\nexport function oauthRefreshModelsError(error: unknown, providerId: string): ModelsError {\n\tif (error instanceof ModelsError) return error;\n\tif (error instanceof OAuthRefreshExchangeError) {\n\t\treturn new ModelsError(\"oauth\", `OAuth refresh failed for ${providerId}`, { cause: error.cause });\n\t}\n\tconst cause = error instanceof OAuthRefreshStoreError ? error.cause : error;\n\treturn new ModelsError(\"auth\", `Credential store modify failed for ${providerId}`, { cause });\n}\n\n/**\n * OAuth resolution: a token with less than five minutes remaining is refreshed\n * through `refreshOAuthCredential`, which re-checks the stored value, runs the\n * exchange outside the store lock, and compare-and-swaps the rotated slot.\n */\nasync function resolveStoredOAuth(\n\tcredentials: CredentialStore,\n\tproviderId: string,\n\toauth: OAuthAuth,\n\tstored: OAuthCredential,\n\tauthContext: AuthContext,\n\trequestEnv: ProviderEnv | undefined,\n\tsignal: AbortSignal,\n\tminOAuthValidityMs?: number,\n\tslotName?: string,\n\trejectedAccess?: string,\n): Promise<AuthResult | undefined> {\n\tconst minimumValidityMs = Math.max(DEFAULT_OAUTH_MINIMUM_VALIDITY_MS, minOAuthValidityMs ?? 0);\n\tconst expiresSoon = (credential: OAuthCredential) => Date.now() + minimumValidityMs >= credential.expires;\n\tconst isStale = (credential: OAuthCredential) =>\n\t\texpiresSoon(credential) || (rejectedAccess !== undefined && credential.access === rejectedAccess);\n\tlet credential = stored;\n\n\tif (isStale(credential)) {\n\t\tlet post: Credential | undefined;\n\t\ttry {\n\t\t\tpost = await refreshOAuthCredential({\n\t\t\t\tcredentials,\n\t\t\t\tproviderId,\n\t\t\t\toauth,\n\t\t\t\tstale: credential,\n\t\t\t\tslotName,\n\t\t\t\tisStale,\n\t\t\t\tsignal,\n\t\t\t\towning: true,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tthrow oauthRefreshModelsError(error, providerId);\n\t\t}\n\t\tif (post?.type !== \"oauth\") return undefined; // logged out meanwhile\n\t\tconst postView = slotName === undefined ? post : projectOAuthSlot(post, slotName);\n\t\tif (!postView) return undefined; // slot removed meanwhile\n\t\tcredential = postView;\n\t\t// The normal five-minute window triggers a refresh but does not impose a\n\t\t// provider contract. Explicit callers (such as bearer-token export) do\n\t\t// require the requested minimum after the refresh.\n\t\tif (minOAuthValidityMs !== undefined && expiresSoon(credential)) {\n\t\t\tthrow new ModelsError(\"oauth\", `OAuth refresh returned a token that expires too soon for ${providerId}`);\n\t\t}\n\t}\n\n\tconst storedEnv = credentialEnvironment(credential);\n\tconst effectiveEnv = requestEnv ? { ...storedEnv, ...requestEnv } : storedEnv;\n\tconst effectiveCredential = effectiveEnv ? { ...credential, env: effectiveEnv } : credential;\n\n\tif (oauth.check) {\n\t\ttry {\n\t\t\tif (!(await oauth.check({ ctx: authContext, credential: effectiveCredential, signal }))) return undefined;\n\t\t} catch (error) {\n\t\t\tthrow new ModelsError(\"auth\", `OAuth auth check failed for provider ${providerId}`, { cause: error });\n\t\t}\n\t}\n\n\ttry {\n\t\treturn {\n\t\t\tauth: await oauth.toAuth(effectiveCredential),\n\t\t\t...(effectiveEnv ? { env: effectiveEnv } : {}),\n\t\t\tsource: \"OAuth\",\n\t\t};\n\t} catch (error) {\n\t\tthrow new ModelsError(\"oauth\", `OAuth auth derivation failed for ${providerId}`, { cause: error });\n\t}\n}\n\nfunction credentialEnvironment(credential: OAuthCredential): ProviderEnv | undefined {\n\tconst value = credential.env;\n\tif (typeof value !== \"object\" || value === null || Array.isArray(value)) return undefined;\n\tconst environment: ProviderEnv = {};\n\tfor (const [name, entry] of Object.entries(value)) {\n\t\tif (typeof entry !== \"string\") return undefined;\n\t\tenvironment[name] = entry;\n\t}\n\treturn environment;\n}\n\nasync function resolveApiKey(\n\tauthContext: AuthContext,\n\tapiKey: ApiKeyAuth,\n\tproviderId: string,\n\tcredential: ApiKeyCredential | undefined,\n\tsignal: AbortSignal,\n): Promise<AuthResult | undefined> {\n\ttry {\n\t\treturn await apiKey.resolve({ ctx: authContext, credential, signal });\n\t} catch (error) {\n\t\tthrow new ModelsError(\"auth\", `API key auth failed for provider ${providerId}`, { cause: error });\n\t}\n}\n\nasync function readCredential(\n\tcredentials: CredentialStore,\n\tproviderId: string,\n\tsignal: AbortSignal,\n): Promise<Credential | undefined> {\n\ttry {\n\t\treturn await credentials.read(providerId, { signal });\n\t} catch (error) {\n\t\tthrow new ModelsError(\"auth\", `Credential store read failed for ${providerId}`, { cause: error });\n\t}\n}\n"]}
@@ -91,10 +91,17 @@ export interface AuthResult {
91
91
  env?: ProviderEnv;
92
92
  /** Human-readable label for status UI: "ANTHROPIC_API_KEY", "OAuth", "~/.aws/credentials". */
93
93
  source?: string;
94
+ /**
95
+ * Resolved only from a shared cloud credential chain (AWS profile/keys/roles, Google ADC)
96
+ * that exists for other tools too, not from a credential configured for this provider.
97
+ */
98
+ ambient?: true;
94
99
  }
95
100
  export interface AuthCheck {
96
101
  source?: string;
97
102
  type: "api_key" | "oauth";
103
+ /** Same meaning as `AuthResult.ambient`. */
104
+ ambient?: true;
98
105
  }
99
106
  export type AuthType = "api_key" | "oauth";
100
107
  /**
@@ -217,6 +224,13 @@ export interface OAuthAuth {
217
224
  isSubscription?: boolean;
218
225
  /** Selector label for the OAuth login option, e.g. "Sign in with SuperGrok or X Premium". */
219
226
  loginLabel?: string;
227
+ /**
228
+ * HTTP statuses with which the provider refuses a stored access token before its
229
+ * own expiry says so (GitHub Copilot revokes its short-lived token server-side and
230
+ * answers 401/403). The runtime re-exchanges that exact token once and retries the
231
+ * request before surfacing the failure.
232
+ */
233
+ rejectedTokenStatuses?: readonly number[];
220
234
  login(interaction: ProviderAuthInteraction): Promise<OAuthCredential>;
221
235
  /**
222
236
  * Exchange the refresh token. Network call; throws on failure
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/auth/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEhE;;;GAGG;AACH,MAAM,WAAW,SAAS;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,SAAS,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IAC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,UAAU,GAAG,SAAS,CAAC,CAAC;CACpC;AAED;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACzB,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;IAEb,oFAAoF;IACpF,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB,6FAA6F;IAC7F,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;;OAKG;IACH,qBAAqB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAE1C,KAAK,CAAC,WAAW,EAAE,uBAAuB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAEtE;;;OAGG;IACH,OAAO,CAAC,UAAU,EAAE,eAAe,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAEpF;;;;;OAKG;IACH,KAAK,CAAC,CAAC,KAAK,EAAE;QACb,GAAG,EAAE,WAAW,CAAC;QACjB,UAAU,CAAC,EAAE,eAAe,CAAC;QAC7B,MAAM,EAAE,WAAW,CAAC;KACpB,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC;IAEnC;;;;OAIG;IACH,MAAM,CAAC,UAAU,EAAE,eAAe,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;CACxD;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC5B,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC;CAClB"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/auth/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ProviderEnv, ProviderHeaders } from \"../types.ts\";\n\n/**\n * Request auth for a single model request. If a value cannot be expressed as\n * `apiKey`, `headers`, or `baseUrl`, it is provider config, not auth.\n */\nexport interface ModelAuth {\n\tapiKey?: string;\n\theaders?: ProviderHeaders;\n\tbaseUrl?: string;\n}\n\n/**\n * Stored api-key credential. `env` holds provider-scoped environment/config\n * values such as Cloudflare account/gateway ids.\n */\nexport interface ApiKeyCredential {\n\ttype: \"api_key\";\n\tkey?: string;\n\tenv?: ProviderEnv;\n}\n\n/** OAuth token data returned by extension compatibility flows. */\nexport interface OAuthCredentials {\n\trefresh: string;\n\taccess: string;\n\texpires: number;\n\t[key: string]: unknown;\n}\n\n/** Stored canonical OAuth credential. */\nexport interface OAuthCredential extends OAuthCredentials {\n\ttype: \"oauth\";\n}\n\n/** One type-tagged credential per provider — the shape of today's auth.json. */\nexport type Credential = ApiKeyCredential | OAuthCredential;\n\n/** Non-secret credential metadata for account/status enumeration. */\nexport interface CredentialInfo {\n\tproviderId: string;\n\ttype: Credential[\"type\"];\n}\n\n/** Optional cancellation for public auth and credential operations. */\nexport interface AuthOperationOptions {\n\tsignal?: AbortSignal;\n}\n\n/**\n * App-owned credential storage, keyed by `Provider.id`, one entry per\n * provider; an entry may pool sibling slots under `accounts` while its flat\n * fields remain a valid credential. `modify` is the only write path, so every mutation is a\n * serialized read-modify-write; `Models.getAuth()` runs OAuth refresh inside\n * `modify` so concurrent requests cannot double-refresh a rotated token. The\n * app persists a credential after login via\n * `modify(provider.id, async () => credential)`. Login/logout orchestration\n * is app-owned.\n *\n * Error semantics: `read` resolves `undefined` for missing entries. Methods\n * reject only on storage failure; `Models` wraps such rejections in\n * `ModelsError` with code \"auth\". Best-effort stores that serve an in-memory\n * view and record persistence errors internally (like coding-agent's\n * AuthStorage) are valid implementations.\n */\nexport interface CredentialStore {\n\t/**\n\t * Read the stored credential, possibly expired. Display/status use;\n\t * resolved request auth comes from `Models.getAuth()`.\n\t */\n\tread(providerId: string, options?: AuthOperationOptions): Promise<Credential | undefined>;\n\n\t/**\n\t * List stored credential metadata without resolving or exposing secrets.\n\t * Implementations must not execute configured API-key commands while listing.\n\t */\n\tlist(options?: AuthOperationOptions): Promise<readonly CredentialInfo[]>;\n\n\t/**\n\t * Serialized write — the only write path. `fn` sees the current credential\n\t * because correct writes (refresh, login-during-refresh) depend on it;\n\t * return the new credential, or undefined to leave the entry unchanged.\n\t * Mutual exclusion per provider id, cross-process too where the backing\n\t * store supports it (e.g. a file lock). Resolves with the post-write\n\t * credential. Rejections from `fn` propagate.\n\t */\n\tmodify(\n\t\tproviderId: string,\n\t\tfn: (current: Credential | undefined) => Promise<Credential | undefined>,\n\t\toptions?: AuthOperationOptions,\n\t): Promise<Credential | undefined>;\n\n\t/** Remove a credential (logout). Implementations serialize this against `modify`. */\n\tdelete(providerId: string, options?: AuthOperationOptions): Promise<void>;\n}\n\n/** Environment access for auth resolution. Injectable for tests and browsers. */\nexport interface AuthContext {\n\tenv(name: string): Promise<string | undefined>;\n\t/** Check whether a file exists. Supports a leading `~`. Always false in browsers. */\n\tfileExists(path: string): Promise<boolean>;\n}\n\n/** Result of resolving auth for a model. */\nexport interface AuthResult {\n\tauth: ModelAuth;\n\t/** Provider-scoped environment/config values resolved from credentials and ambient context. */\n\tenv?: ProviderEnv;\n\t/** Human-readable label for status UI: \"ANTHROPIC_API_KEY\", \"OAuth\", \"~/.aws/credentials\". */\n\tsource?: string;\n}\n\nexport interface AuthCheck {\n\tsource?: string;\n\ttype: \"api_key\" | \"oauth\";\n}\n\nexport type AuthType = \"api_key\" | \"oauth\";\n\n/**\n * Prompt shown to the user during login. `signal` lets the flow cancel a\n * pending prompt when an out-of-band event resolves the step, e.g. a\n * `manual_code` prompt raced against a callback server, aborted when the\n * callback wins.\n */\nexport type AuthPrompt = { signal?: AbortSignal } & (\n\t| { type: \"text\"; message: string; placeholder?: string }\n\t| { type: \"secret\"; message: string; placeholder?: string }\n\t| { type: \"select\"; message: string; options: readonly { id: string; label: string; description?: string }[] }\n\t| { type: \"manual_code\"; message: string; placeholder?: string }\n);\n\nexport interface AuthInfoLink {\n\turl: string;\n\tlabel?: string;\n}\n\nexport type AuthEvent =\n\t| { type: \"info\"; message: string; links?: readonly AuthInfoLink[] }\n\t| { type: \"auth_url\"; url: string; instructions?: string }\n\t| {\n\t\t\ttype: \"device_code\";\n\t\t\tuserCode: string;\n\t\t\tverificationUri: string;\n\t\t\tintervalSeconds?: number;\n\t\t\texpiresInSeconds?: number;\n\t }\n\t| { type: \"progress\"; message: string };\n\n/** Secret-free receipt emitted only after the account write succeeds. */\nexport interface AccountLoginReceipt {\n\treadonly providerId: string;\n\treadonly name: string;\n\treadonly origin: \"generated\" | \"provider\";\n}\n\n/**\n * Login interaction callbacks serving both api-key and OAuth flows.\n *\n * `prompt()` returns the entered/selected string (`select` returns the option\n * id). Rejects on cancel/abort. `signal` aborts the whole login flow;\n * per-prompt cancellation uses `AuthPrompt.signal`.\n */\nexport interface AuthInteraction {\n\tsignal?: AbortSignal;\n\t/** Absent for provider-owned envelopes without one unambiguous new slot ID. */\n\tonAccountCommitted?(receipt: AccountLoginReceipt): void;\n\n\tprompt(prompt: AuthPrompt): Promise<string>;\n\tnotify(event: AuthEvent): void;\n}\n\n/** Normalized interaction passed to provider login implementations. */\nexport type ProviderAuthInteraction = Omit<AuthInteraction, \"onAccountCommitted\"> & { signal: AbortSignal };\n\n/**\n * Api-key auth: stored key/provider env plus ambient sources (env vars, AWS\n * profiles, ADC files). Ambient-only providers omit `login`.\n */\nexport interface ApiKeyAuth {\n\t/** Display name, e.g. \"Anthropic API key\". */\n\tname: string;\n\n\t/** Ambient compatibility adapter that must not outrank a stored OAuth credential. */\n\tambientOnly?: boolean;\n\n\t/** Interactive setup (prompt for key/provider env). Absent = ambient-only. */\n\tlogin?(interaction: ProviderAuthInteraction): Promise<ApiKeyCredential>;\n\n\t/**\n\t * Optional side-effect-free availability check. Use this when `resolve()` may\n\t * execute commands or perform other request-time work. Missing means Models\n\t * checks availability by resolving auth.\n\t */\n\tcheck?(input: {\n\t\tctx: AuthContext;\n\t\tcredential?: ApiKeyCredential;\n\t\tsignal: AbortSignal;\n\t}): Promise<AuthCheck | undefined>;\n\n\t/**\n\t * Resolve auth from the stored credential and/or ambient sources, merging\n\t * per field (`credential.key ?? env(\"...\")`, `credential.env?.NAME ?? env(\"...\")`).\n\t * undefined = not configured. Resolution is provider-scoped; model-specific\n\t * endpoint preparation happens after auth has been resolved.\n\t */\n\tresolve(input: {\n\t\tctx: AuthContext;\n\t\tcredential?: ApiKeyCredential;\n\t\tsignal: AbortSignal;\n\t}): Promise<AuthResult | undefined>;\n}\n\n/**\n * OAuth auth. The `refresh`/`toAuth` split lets `Models` own the locked\n * refresh pattern: `refresh` produces a credential, `toAuth` derives request\n * auth from whatever credential ends up stored.\n */\nexport interface OAuthAuth {\n\t/** Display name, e.g. \"Anthropic (Claude Pro/Max)\". */\n\tname: string;\n\n\t/** Whether access through this auth method is backed by a provider subscription. */\n\tisSubscription?: boolean;\n\n\t/** Selector label for the OAuth login option, e.g. \"Sign in with SuperGrok or X Premium\". */\n\tloginLabel?: string;\n\n\tlogin(interaction: ProviderAuthInteraction): Promise<OAuthCredential>;\n\n\t/**\n\t * Exchange the refresh token. Network call; throws on failure\n\t * (invalid_grant etc.). `Models` runs this under the store lock.\n\t */\n\trefresh(credential: OAuthCredential, signal: AbortSignal): Promise<OAuthCredential>;\n\n\t/**\n\t * Optional side-effect-free availability check, mirroring `ApiKeyAuth.check`.\n\t * Supply this when a stored OAuth credential does not by itself imply the\n\t * provider is usable — for example a sentinel envelope that carries zero\n\t * accounts. When absent, any stored OAuth credential counts as configured.\n\t */\n\tcheck?(input: {\n\t\tctx: AuthContext;\n\t\tcredential?: OAuthCredential;\n\t\tsignal: AbortSignal;\n\t}): Promise<AuthCheck | undefined>;\n\n\t/**\n\t * Side-effect-free derivation of request auth from a valid credential.\n\t * Covers per-credential baseUrl (GitHub Copilot). Async so lazy wrappers\n\t * can load the implementation on first use.\n\t */\n\ttoAuth(credential: OAuthCredential): Promise<ModelAuth>;\n}\n\n/**\n * Provider auth. At least one of `apiKey`/`oauth` must be present: even\n * ambient-credential providers and keyless local servers provide `apiKey`\n * auth whose `resolve()` reports whether the provider is configured.\n */\nexport interface ProviderAuth {\n\tapiKey?: ApiKeyAuth;\n\toauth?: OAuthAuth;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/auth/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ProviderEnv, ProviderHeaders } from \"../types.ts\";\n\n/**\n * Request auth for a single model request. If a value cannot be expressed as\n * `apiKey`, `headers`, or `baseUrl`, it is provider config, not auth.\n */\nexport interface ModelAuth {\n\tapiKey?: string;\n\theaders?: ProviderHeaders;\n\tbaseUrl?: string;\n}\n\n/**\n * Stored api-key credential. `env` holds provider-scoped environment/config\n * values such as Cloudflare account/gateway ids.\n */\nexport interface ApiKeyCredential {\n\ttype: \"api_key\";\n\tkey?: string;\n\tenv?: ProviderEnv;\n}\n\n/** OAuth token data returned by extension compatibility flows. */\nexport interface OAuthCredentials {\n\trefresh: string;\n\taccess: string;\n\texpires: number;\n\t[key: string]: unknown;\n}\n\n/** Stored canonical OAuth credential. */\nexport interface OAuthCredential extends OAuthCredentials {\n\ttype: \"oauth\";\n}\n\n/** One type-tagged credential per provider — the shape of today's auth.json. */\nexport type Credential = ApiKeyCredential | OAuthCredential;\n\n/** Non-secret credential metadata for account/status enumeration. */\nexport interface CredentialInfo {\n\tproviderId: string;\n\ttype: Credential[\"type\"];\n}\n\n/** Optional cancellation for public auth and credential operations. */\nexport interface AuthOperationOptions {\n\tsignal?: AbortSignal;\n}\n\n/**\n * App-owned credential storage, keyed by `Provider.id`, one entry per\n * provider; an entry may pool sibling slots under `accounts` while its flat\n * fields remain a valid credential. `modify` is the only write path, so every mutation is a\n * serialized read-modify-write; `Models.getAuth()` runs OAuth refresh inside\n * `modify` so concurrent requests cannot double-refresh a rotated token. The\n * app persists a credential after login via\n * `modify(provider.id, async () => credential)`. Login/logout orchestration\n * is app-owned.\n *\n * Error semantics: `read` resolves `undefined` for missing entries. Methods\n * reject only on storage failure; `Models` wraps such rejections in\n * `ModelsError` with code \"auth\". Best-effort stores that serve an in-memory\n * view and record persistence errors internally (like coding-agent's\n * AuthStorage) are valid implementations.\n */\nexport interface CredentialStore {\n\t/**\n\t * Read the stored credential, possibly expired. Display/status use;\n\t * resolved request auth comes from `Models.getAuth()`.\n\t */\n\tread(providerId: string, options?: AuthOperationOptions): Promise<Credential | undefined>;\n\n\t/**\n\t * List stored credential metadata without resolving or exposing secrets.\n\t * Implementations must not execute configured API-key commands while listing.\n\t */\n\tlist(options?: AuthOperationOptions): Promise<readonly CredentialInfo[]>;\n\n\t/**\n\t * Serialized write — the only write path. `fn` sees the current credential\n\t * because correct writes (refresh, login-during-refresh) depend on it;\n\t * return the new credential, or undefined to leave the entry unchanged.\n\t * Mutual exclusion per provider id, cross-process too where the backing\n\t * store supports it (e.g. a file lock). Resolves with the post-write\n\t * credential. Rejections from `fn` propagate.\n\t */\n\tmodify(\n\t\tproviderId: string,\n\t\tfn: (current: Credential | undefined) => Promise<Credential | undefined>,\n\t\toptions?: AuthOperationOptions,\n\t): Promise<Credential | undefined>;\n\n\t/** Remove a credential (logout). Implementations serialize this against `modify`. */\n\tdelete(providerId: string, options?: AuthOperationOptions): Promise<void>;\n}\n\n/** Environment access for auth resolution. Injectable for tests and browsers. */\nexport interface AuthContext {\n\tenv(name: string): Promise<string | undefined>;\n\t/** Check whether a file exists. Supports a leading `~`. Always false in browsers. */\n\tfileExists(path: string): Promise<boolean>;\n}\n\n/** Result of resolving auth for a model. */\nexport interface AuthResult {\n\tauth: ModelAuth;\n\t/** Provider-scoped environment/config values resolved from credentials and ambient context. */\n\tenv?: ProviderEnv;\n\t/** Human-readable label for status UI: \"ANTHROPIC_API_KEY\", \"OAuth\", \"~/.aws/credentials\". */\n\tsource?: string;\n\t/**\n\t * Resolved only from a shared cloud credential chain (AWS profile/keys/roles, Google ADC)\n\t * that exists for other tools too, not from a credential configured for this provider.\n\t */\n\tambient?: true;\n}\n\nexport interface AuthCheck {\n\tsource?: string;\n\ttype: \"api_key\" | \"oauth\";\n\t/** Same meaning as `AuthResult.ambient`. */\n\tambient?: true;\n}\n\nexport type AuthType = \"api_key\" | \"oauth\";\n\n/**\n * Prompt shown to the user during login. `signal` lets the flow cancel a\n * pending prompt when an out-of-band event resolves the step, e.g. a\n * `manual_code` prompt raced against a callback server, aborted when the\n * callback wins.\n */\nexport type AuthPrompt = { signal?: AbortSignal } & (\n\t| { type: \"text\"; message: string; placeholder?: string }\n\t| { type: \"secret\"; message: string; placeholder?: string }\n\t| { type: \"select\"; message: string; options: readonly { id: string; label: string; description?: string }[] }\n\t| { type: \"manual_code\"; message: string; placeholder?: string }\n);\n\nexport interface AuthInfoLink {\n\turl: string;\n\tlabel?: string;\n}\n\nexport type AuthEvent =\n\t| { type: \"info\"; message: string; links?: readonly AuthInfoLink[] }\n\t| { type: \"auth_url\"; url: string; instructions?: string }\n\t| {\n\t\t\ttype: \"device_code\";\n\t\t\tuserCode: string;\n\t\t\tverificationUri: string;\n\t\t\tintervalSeconds?: number;\n\t\t\texpiresInSeconds?: number;\n\t }\n\t| { type: \"progress\"; message: string };\n\n/** Secret-free receipt emitted only after the account write succeeds. */\nexport interface AccountLoginReceipt {\n\treadonly providerId: string;\n\treadonly name: string;\n\treadonly origin: \"generated\" | \"provider\";\n}\n\n/**\n * Login interaction callbacks serving both api-key and OAuth flows.\n *\n * `prompt()` returns the entered/selected string (`select` returns the option\n * id). Rejects on cancel/abort. `signal` aborts the whole login flow;\n * per-prompt cancellation uses `AuthPrompt.signal`.\n */\nexport interface AuthInteraction {\n\tsignal?: AbortSignal;\n\t/** Absent for provider-owned envelopes without one unambiguous new slot ID. */\n\tonAccountCommitted?(receipt: AccountLoginReceipt): void;\n\n\tprompt(prompt: AuthPrompt): Promise<string>;\n\tnotify(event: AuthEvent): void;\n}\n\n/** Normalized interaction passed to provider login implementations. */\nexport type ProviderAuthInteraction = Omit<AuthInteraction, \"onAccountCommitted\"> & { signal: AbortSignal };\n\n/**\n * Api-key auth: stored key/provider env plus ambient sources (env vars, AWS\n * profiles, ADC files). Ambient-only providers omit `login`.\n */\nexport interface ApiKeyAuth {\n\t/** Display name, e.g. \"Anthropic API key\". */\n\tname: string;\n\n\t/** Ambient compatibility adapter that must not outrank a stored OAuth credential. */\n\tambientOnly?: boolean;\n\n\t/** Interactive setup (prompt for key/provider env). Absent = ambient-only. */\n\tlogin?(interaction: ProviderAuthInteraction): Promise<ApiKeyCredential>;\n\n\t/**\n\t * Optional side-effect-free availability check. Use this when `resolve()` may\n\t * execute commands or perform other request-time work. Missing means Models\n\t * checks availability by resolving auth.\n\t */\n\tcheck?(input: {\n\t\tctx: AuthContext;\n\t\tcredential?: ApiKeyCredential;\n\t\tsignal: AbortSignal;\n\t}): Promise<AuthCheck | undefined>;\n\n\t/**\n\t * Resolve auth from the stored credential and/or ambient sources, merging\n\t * per field (`credential.key ?? env(\"...\")`, `credential.env?.NAME ?? env(\"...\")`).\n\t * undefined = not configured. Resolution is provider-scoped; model-specific\n\t * endpoint preparation happens after auth has been resolved.\n\t */\n\tresolve(input: {\n\t\tctx: AuthContext;\n\t\tcredential?: ApiKeyCredential;\n\t\tsignal: AbortSignal;\n\t}): Promise<AuthResult | undefined>;\n}\n\n/**\n * OAuth auth. The `refresh`/`toAuth` split lets `Models` own the locked\n * refresh pattern: `refresh` produces a credential, `toAuth` derives request\n * auth from whatever credential ends up stored.\n */\nexport interface OAuthAuth {\n\t/** Display name, e.g. \"Anthropic (Claude Pro/Max)\". */\n\tname: string;\n\n\t/** Whether access through this auth method is backed by a provider subscription. */\n\tisSubscription?: boolean;\n\n\t/** Selector label for the OAuth login option, e.g. \"Sign in with SuperGrok or X Premium\". */\n\tloginLabel?: string;\n\n\t/**\n\t * HTTP statuses with which the provider refuses a stored access token before its\n\t * own expiry says so (GitHub Copilot revokes its short-lived token server-side and\n\t * answers 401/403). The runtime re-exchanges that exact token once and retries the\n\t * request before surfacing the failure.\n\t */\n\trejectedTokenStatuses?: readonly number[];\n\n\tlogin(interaction: ProviderAuthInteraction): Promise<OAuthCredential>;\n\n\t/**\n\t * Exchange the refresh token. Network call; throws on failure\n\t * (invalid_grant etc.). `Models` runs this under the store lock.\n\t */\n\trefresh(credential: OAuthCredential, signal: AbortSignal): Promise<OAuthCredential>;\n\n\t/**\n\t * Optional side-effect-free availability check, mirroring `ApiKeyAuth.check`.\n\t * Supply this when a stored OAuth credential does not by itself imply the\n\t * provider is usable — for example a sentinel envelope that carries zero\n\t * accounts. When absent, any stored OAuth credential counts as configured.\n\t */\n\tcheck?(input: {\n\t\tctx: AuthContext;\n\t\tcredential?: OAuthCredential;\n\t\tsignal: AbortSignal;\n\t}): Promise<AuthCheck | undefined>;\n\n\t/**\n\t * Side-effect-free derivation of request auth from a valid credential.\n\t * Covers per-credential baseUrl (GitHub Copilot). Async so lazy wrappers\n\t * can load the implementation on first use.\n\t */\n\ttoAuth(credential: OAuthCredential): Promise<ModelAuth>;\n}\n\n/**\n * Provider auth. At least one of `apiKey`/`oauth` must be present: even\n * ambient-credential providers and keyless local servers provide `apiKey`\n * auth whose `resolve()` reports whether the provider is configured.\n */\nexport interface ProviderAuth {\n\tapiKey?: ApiKeyAuth;\n\toauth?: OAuthAuth;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"context-limit-store.d.ts","sourceRoot":"","sources":["../../src/cursor/context-limit-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,MAAM,6BAA6B,GAAG;IAC3C,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,EAAE,MAAM,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjD,oEAAoE;IACpE,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;CAC7D,CAAC;AAMF,gFAAgF;AAChF,wBAAgB,oCAAoC,CAAC,IAAI,EAAE,6BAA6B,GAAG,IAAI,CAI9F;AAYD;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAM7F;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGzE;AAED,qFAAqF;AACrF,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAEzF;AAED,kFAAkF;AAClF,wBAAgB,mCAAmC,IAAI,IAAI,CAG1D"}
1
+ {"version":3,"file":"context-limit-store.d.ts","sourceRoot":"","sources":["../../src/cursor/context-limit-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,MAAM,MAAM,6BAA6B,GAAG;IAC3C,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,EAAE,MAAM,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjD,oEAAoE;IACpE,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;CAC7D,CAAC;AAgBF,gFAAgF;AAChF,wBAAgB,oCAAoC,CAAC,IAAI,EAAE,6BAA6B,GAAG,IAAI,CAI9F;AAYD;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAM7F;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGzE;AAED,qFAAqF;AACrF,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAEzF;AAED,kFAAkF;AAClF,wBAAgB,mCAAmC,IAAI,IAAI,CAG1D"}
@@ -11,26 +11,31 @@
11
11
  * the browser. Node processes install file persistence through
12
12
  * `installCursorContextLimitPersistence` - see `utils/cursor-context-limit.ts`.
13
13
  */
14
- const observedLimits = new Map();
15
- let persistence;
16
- let hydrated = false;
14
+ import { processSingleton } from "../utils/process-singleton.js";
15
+ // The Cursor stream records into this store and the coding agent reads it; the release bundle
16
+ // gives each of them its own copy of this module, so the state is process-wide.
17
+ const store = processSingleton("@earendil-works/pi-ai:cursor-context-limits", () => ({
18
+ limits: new Map(),
19
+ persistence: undefined,
20
+ hydrated: false,
21
+ }));
17
22
  /** Installs the process-wide persistence port. Idempotent per port identity. */
18
23
  export function installCursorContextLimitPersistence(port) {
19
- if (persistence === port)
24
+ if (store.persistence === port)
20
25
  return;
21
- persistence = port;
22
- hydrated = false;
26
+ store.persistence = port;
27
+ store.hydrated = false;
23
28
  }
24
29
  function hydrate() {
25
- if (hydrated)
30
+ if (store.hydrated)
26
31
  return;
27
32
  // Set before loading: a load that observes nothing must not retry per read.
28
- hydrated = true;
29
- if (!persistence)
33
+ store.hydrated = true;
34
+ if (!store.persistence)
30
35
  return;
31
- for (const [modelId, maxTokens] of persistence.load()) {
32
- if (!observedLimits.has(modelId))
33
- observedLimits.set(modelId, maxTokens);
36
+ for (const [modelId, maxTokens] of store.persistence.load()) {
37
+ if (!store.limits.has(modelId))
38
+ store.limits.set(modelId, maxTokens);
34
39
  }
35
40
  }
36
41
  /**
@@ -41,14 +46,14 @@ export function recordCursorContextLimit(modelId, maxTokens) {
41
46
  if (maxTokens === undefined || !Number.isFinite(maxTokens) || maxTokens <= 0)
42
47
  return;
43
48
  hydrate();
44
- if (observedLimits.get(modelId) === maxTokens)
49
+ if (store.limits.get(modelId) === maxTokens)
45
50
  return;
46
- observedLimits.set(modelId, maxTokens);
47
- persistence?.save(observedLimits);
51
+ store.limits.set(modelId, maxTokens);
52
+ store.persistence?.save(store.limits);
48
53
  }
49
54
  export function getCursorContextLimit(modelId) {
50
55
  hydrate();
51
- return observedLimits.get(modelId);
56
+ return store.limits.get(modelId);
52
57
  }
53
58
  /** The window to trust for `modelId`: what the server reported, else the catalog. */
54
59
  export function resolveCursorContextWindow(modelId, catalogWindow) {
@@ -56,7 +61,7 @@ export function resolveCursorContextWindow(modelId, catalogWindow) {
56
61
  }
57
62
  /** Drops in-memory state so the next read re-hydrates from the installed port. */
58
63
  export function resetCursorContextLimitStoreForTest() {
59
- observedLimits.clear();
60
- hydrated = false;
64
+ store.limits.clear();
65
+ store.hydrated = false;
61
66
  }
62
67
  //# sourceMappingURL=context-limit-store.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-limit-store.js","sourceRoot":"","sources":["../../src/cursor/context-limit-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AASH,MAAM,cAAc,GAAG,IAAI,GAAG,EAAkB,CAAC;AACjD,IAAI,WAAsD,CAAC;AAC3D,IAAI,QAAQ,GAAG,KAAK,CAAC;AAErB,gFAAgF;AAChF,MAAM,UAAU,oCAAoC,CAAC,IAAmC;IACvF,IAAI,WAAW,KAAK,IAAI;QAAE,OAAO;IACjC,WAAW,GAAG,IAAI,CAAC;IACnB,QAAQ,GAAG,KAAK,CAAC;AAClB,CAAC;AAED,SAAS,OAAO;IACf,IAAI,QAAQ;QAAE,OAAO;IACrB,4EAA4E;IAC5E,QAAQ,GAAG,IAAI,CAAC;IAChB,IAAI,CAAC,WAAW;QAAE,OAAO;IACzB,KAAK,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,IAAI,WAAW,CAAC,IAAI,EAAE,EAAE,CAAC;QACvD,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC;YAAE,cAAc,CAAC,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAC1E,CAAC;AACF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,OAAe,EAAE,SAA6B;IACtF,IAAI,SAAS,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,SAAS,IAAI,CAAC;QAAE,OAAO;IACrF,OAAO,EAAE,CAAC;IACV,IAAI,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,SAAS;QAAE,OAAO;IACtD,cAAc,CAAC,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACvC,WAAW,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,OAAe;IACpD,OAAO,EAAE,CAAC;IACV,OAAO,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AACpC,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,0BAA0B,CAAC,OAAe,EAAE,aAAqB;IAChF,OAAO,qBAAqB,CAAC,OAAO,CAAC,IAAI,aAAa,CAAC;AACxD,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,mCAAmC;IAClD,cAAc,CAAC,KAAK,EAAE,CAAC;IACvB,QAAQ,GAAG,KAAK,CAAC;AAClB,CAAC","sourcesContent":["/**\n * Context ceilings Cursor itself reported, keyed by model id.\n *\n * `GetUsableModels` carries no window, so `CURSOR_MODEL_CAPABILITIES` is a\n * committed guess at what each family accepts. The server states the truth on\n * every conversation checkpoint (`tokenDetails.maxTokens`), so once a model has\n * been observed, that value outranks the catalog for every later request.\n *\n * This module stays browser-safe: `providers/cursor.ts` and\n * `cursor/store-migration.ts` materialize catalog windows and are bundled for\n * the browser. Node processes install file persistence through\n * `installCursorContextLimitPersistence` - see `utils/cursor-context-limit.ts`.\n */\n\nexport type CursorContextLimitPersistence = {\n\t/** Limits observed by earlier processes. Called at most once per install. */\n\treadonly load: () => ReadonlyMap<string, number>;\n\t/** Called only when a recorded limit actually changed the store. */\n\treadonly save: (limits: ReadonlyMap<string, number>) => void;\n};\n\nconst observedLimits = new Map<string, number>();\nlet persistence: CursorContextLimitPersistence | undefined;\nlet hydrated = false;\n\n/** Installs the process-wide persistence port. Idempotent per port identity. */\nexport function installCursorContextLimitPersistence(port: CursorContextLimitPersistence): void {\n\tif (persistence === port) return;\n\tpersistence = port;\n\thydrated = false;\n}\n\nfunction hydrate(): void {\n\tif (hydrated) return;\n\t// Set before loading: a load that observes nothing must not retry per read.\n\thydrated = true;\n\tif (!persistence) return;\n\tfor (const [modelId, maxTokens] of persistence.load()) {\n\t\tif (!observedLimits.has(modelId)) observedLimits.set(modelId, maxTokens);\n\t}\n}\n\n/**\n * Records the server-reported ceiling for `modelId`. The first checkpoint of a\n * conversation reports 0, so non-positive and non-finite values are ignored.\n */\nexport function recordCursorContextLimit(modelId: string, maxTokens: number | undefined): void {\n\tif (maxTokens === undefined || !Number.isFinite(maxTokens) || maxTokens <= 0) return;\n\thydrate();\n\tif (observedLimits.get(modelId) === maxTokens) return;\n\tobservedLimits.set(modelId, maxTokens);\n\tpersistence?.save(observedLimits);\n}\n\nexport function getCursorContextLimit(modelId: string): number | undefined {\n\thydrate();\n\treturn observedLimits.get(modelId);\n}\n\n/** The window to trust for `modelId`: what the server reported, else the catalog. */\nexport function resolveCursorContextWindow(modelId: string, catalogWindow: number): number {\n\treturn getCursorContextLimit(modelId) ?? catalogWindow;\n}\n\n/** Drops in-memory state so the next read re-hydrates from the installed port. */\nexport function resetCursorContextLimitStoreForTest(): void {\n\tobservedLimits.clear();\n\thydrated = false;\n}\n"]}
1
+ {"version":3,"file":"context-limit-store.js","sourceRoot":"","sources":["../../src/cursor/context-limit-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAejE,8FAA8F;AAC9F,gFAAgF;AAChF,MAAM,KAAK,GAAG,gBAAgB,CAAsB,6CAA6C,EAAE,GAAG,EAAE,CAAC,CAAC;IACzG,MAAM,EAAE,IAAI,GAAG,EAAE;IACjB,WAAW,EAAE,SAAS;IACtB,QAAQ,EAAE,KAAK;CACf,CAAC,CAAC,CAAC;AAEJ,gFAAgF;AAChF,MAAM,UAAU,oCAAoC,CAAC,IAAmC;IACvF,IAAI,KAAK,CAAC,WAAW,KAAK,IAAI;QAAE,OAAO;IACvC,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;IACzB,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC;AACxB,CAAC;AAED,SAAS,OAAO;IACf,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QAAQ,GAAG,KAAK,CAAC;AACxB,CAAC","sourcesContent":["/**\n * Context ceilings Cursor itself reported, keyed by model id.\n *\n * `GetUsableModels` carries no window, so `CURSOR_MODEL_CAPABILITIES` is a\n * committed guess at what each family accepts. The server states the truth on\n * every conversation checkpoint (`tokenDetails.maxTokens`), so once a model has\n * been observed, that value outranks the catalog for every later request.\n *\n * This module stays browser-safe: `providers/cursor.ts` and\n * `cursor/store-migration.ts` materialize catalog windows and are bundled for\n * the browser. Node processes install file persistence through\n * `installCursorContextLimitPersistence` - see `utils/cursor-context-limit.ts`.\n */\n\nimport { processSingleton } from \"../utils/process-singleton.ts\";\n\nexport type CursorContextLimitPersistence = {\n\t/** Limits observed by earlier processes. Called at most once per install. */\n\treadonly load: () => ReadonlyMap<string, number>;\n\t/** Called only when a recorded limit actually changed the store. */\n\treadonly save: (limits: ReadonlyMap<string, number>) => void;\n};\n\ntype ObservedLimitsStore = {\n\treadonly limits: Map<string, number>;\n\tpersistence: CursorContextLimitPersistence | undefined;\n\thydrated: boolean;\n};\n\n// The Cursor stream records into this store and the coding agent reads it; the release bundle\n// gives each of them its own copy of this module, so the state is process-wide.\nconst store = processSingleton<ObservedLimitsStore>(\"@earendil-works/pi-ai:cursor-context-limits\", () => ({\n\tlimits: new Map(),\n\tpersistence: undefined,\n\thydrated: false,\n}));\n\n/** Installs the process-wide persistence port. Idempotent per port identity. */\nexport function installCursorContextLimitPersistence(port: CursorContextLimitPersistence): void {\n\tif (store.persistence === port) return;\n\tstore.persistence = port;\n\tstore.hydrated = false;\n}\n\nfunction hydrate(): void {\n\tif (store.hydrated) return;\n\t// Set before loading: a load that observes nothing must not retry per read.\n\tstore.hydrated = true;\n\tif (!store.persistence) return;\n\tfor (const [modelId, maxTokens] of store.persistence.load()) {\n\t\tif (!store.limits.has(modelId)) store.limits.set(modelId, maxTokens);\n\t}\n}\n\n/**\n * Records the server-reported ceiling for `modelId`. The first checkpoint of a\n * conversation reports 0, so non-positive and non-finite values are ignored.\n */\nexport function recordCursorContextLimit(modelId: string, maxTokens: number | undefined): void {\n\tif (maxTokens === undefined || !Number.isFinite(maxTokens) || maxTokens <= 0) return;\n\thydrate();\n\tif (store.limits.get(modelId) === maxTokens) return;\n\tstore.limits.set(modelId, maxTokens);\n\tstore.persistence?.save(store.limits);\n}\n\nexport function getCursorContextLimit(modelId: string): number | undefined {\n\thydrate();\n\treturn store.limits.get(modelId);\n}\n\n/** The window to trust for `modelId`: what the server reported, else the catalog. */\nexport function resolveCursorContextWindow(modelId: string, catalogWindow: number): number {\n\treturn getCursorContextLimit(modelId) ?? catalogWindow;\n}\n\n/** Drops in-memory state so the next read re-hydrates from the installed port. */\nexport function resetCursorContextLimitStoreForTest(): void {\n\tstore.limits.clear();\n\tstore.hydrated = false;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAKA,OAAO,EACN,KAAK,uBAAuB,EAI5B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EACX,SAAS,EACT,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,UAAU,EACV,QAAQ,EACR,UAAU,EACV,eAAe,EACf,YAAY,EACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAuB,KAAK,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACjG,OAAO,KAAK,EACX,GAAG,EACH,gBAAgB,EAChB,gBAAgB,EAChB,2BAA2B,EAC3B,OAAO,EACP,qBAAqB,EACrB,oBAAoB,EACpB,cAAc,EACd,KAAK,EAEL,kBAAkB,EAElB,eAAe,EAEf,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,KAAK,EACL,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,OAAO,EACN,WAAW,EACX,KAAK,eAAe,EACpB,8BAA8B,EAC9B,4BAA4B,GAC5B,MAAM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B,aAAa,CAAC,IAAI,SAAS,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,OAAO,CAM3E;AA2CD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,SAAS,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,OAAO,CAMzE;AAQD;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,SAAS,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,OAAO,CAGzF;AAgCD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,SAAS,GAAG,EAC9C,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,EACjC,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,GAC/B,OAAO,CAGT"}
package/dist/models.js CHANGED
@@ -225,8 +225,9 @@ class ModelsImpl {
225
225
  }
226
226
  else {
227
227
  const resolution = await resolveProviderAuth(provider, this.credentials, this.authContext, { signal });
228
- if (resolution)
229
- return { source: resolution.source, type: "api_key" };
228
+ if (resolution) {
229
+ return { source: resolution.source, type: "api_key", ...(resolution.ambient ? { ambient: true } : {}) };
230
+ }
230
231
  }
231
232
  }
232
233
  if (!oauth?.check)