@code-yeongyu/senpi-ai 2026.8.18 → 2026.8.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/dist/api/anthropic-messages.d.ts +7 -1
- package/dist/api/anthropic-messages.d.ts.map +1 -1
- package/dist/api/anthropic-messages.js +21 -4
- package/dist/api/anthropic-messages.js.map +1 -1
- package/dist/api/azure-openai-responses.d.ts +2 -0
- package/dist/api/azure-openai-responses.d.ts.map +1 -1
- package/dist/api/azure-openai-responses.js +7 -1
- package/dist/api/azure-openai-responses.js.map +1 -1
- package/dist/api/bedrock-converse-stream.d.ts.map +1 -1
- package/dist/api/bedrock-converse-stream.js +39 -2
- package/dist/api/bedrock-converse-stream.js.map +1 -1
- package/dist/api/cursor-agent/gen/agent_pb.d.ts +22 -1
- package/dist/api/cursor-agent/gen/agent_pb.d.ts.map +1 -1
- package/dist/api/cursor-agent/gen/agent_pb.js +1 -1
- package/dist/api/cursor-agent/gen/agent_pb.js.map +1 -1
- package/dist/api/cursor-agent/reasoning-params.d.ts +20 -0
- package/dist/api/cursor-agent/reasoning-params.d.ts.map +1 -0
- package/dist/api/cursor-agent/reasoning-params.js +26 -0
- package/dist/api/cursor-agent/reasoning-params.js.map +1 -0
- package/dist/api/cursor-agent/types.d.ts +7 -1
- package/dist/api/cursor-agent/types.d.ts.map +1 -1
- package/dist/api/cursor-agent/types.js.map +1 -1
- package/dist/api/cursor-agent.d.ts +5 -3
- package/dist/api/cursor-agent.d.ts.map +1 -1
- package/dist/api/cursor-agent.js +82 -12
- package/dist/api/cursor-agent.js.map +1 -1
- package/dist/api/google-generative-ai.d.ts +2 -2
- package/dist/api/google-generative-ai.d.ts.map +1 -1
- package/dist/api/google-generative-ai.js +14 -11
- package/dist/api/google-generative-ai.js.map +1 -1
- package/dist/api/google-shared.d.ts +5 -2
- package/dist/api/google-shared.d.ts.map +1 -1
- package/dist/api/google-shared.js +16 -0
- package/dist/api/google-shared.js.map +1 -1
- package/dist/api/google-vertex.d.ts +2 -2
- package/dist/api/google-vertex.d.ts.map +1 -1
- package/dist/api/google-vertex.js +13 -10
- package/dist/api/google-vertex.js.map +1 -1
- package/dist/api/mistral-conversations.d.ts.map +1 -1
- package/dist/api/mistral-conversations.js +4 -1
- package/dist/api/mistral-conversations.js.map +1 -1
- package/dist/api/openai-codex-responses.d.ts.map +1 -1
- package/dist/api/openai-codex-responses.js +4 -1
- package/dist/api/openai-codex-responses.js.map +1 -1
- package/dist/api/openai-completions.d.ts +1 -1
- package/dist/api/openai-completions.d.ts.map +1 -1
- package/dist/api/openai-completions.js +45 -29
- package/dist/api/openai-completions.js.map +1 -1
- package/dist/api/openai-responses.d.ts.map +1 -1
- package/dist/api/openai-responses.js +8 -1
- package/dist/api/openai-responses.js.map +1 -1
- package/dist/api/pi-messages.js +1 -1
- package/dist/api/pi-messages.js.map +1 -1
- package/dist/api/simple-options.d.ts +4 -0
- package/dist/api/simple-options.d.ts.map +1 -1
- package/dist/api/simple-options.js +18 -9
- package/dist/api/simple-options.js.map +1 -1
- package/dist/auth/oauth/device-code.d.ts +1 -0
- package/dist/auth/oauth/device-code.d.ts.map +1 -1
- package/dist/auth/oauth/device-code.js +1 -1
- package/dist/auth/oauth/device-code.js.map +1 -1
- package/dist/auth/oauth/github-copilot.d.ts.map +1 -1
- package/dist/auth/oauth/github-copilot.js +22 -9
- package/dist/auth/oauth/github-copilot.js.map +1 -1
- package/dist/cursor/catalog-grouping.d.ts +25 -0
- package/dist/cursor/catalog-grouping.d.ts.map +1 -0
- package/dist/cursor/catalog-grouping.js +134 -0
- package/dist/cursor/catalog-grouping.js.map +1 -0
- package/dist/cursor/cursor-variant-aliases.json +1893 -0
- package/dist/cursor/model-capabilities.d.ts +47 -0
- package/dist/cursor/model-capabilities.d.ts.map +1 -0
- package/dist/cursor/model-capabilities.js +208 -0
- package/dist/cursor/model-capabilities.js.map +1 -0
- package/dist/cursor/selection-descriptor.d.ts +21 -0
- package/dist/cursor/selection-descriptor.d.ts.map +1 -0
- package/dist/cursor/selection-descriptor.js +83 -0
- package/dist/cursor/selection-descriptor.js.map +1 -0
- package/dist/cursor/store-migration.d.ts +8 -0
- package/dist/cursor/store-migration.d.ts.map +1 -0
- package/dist/cursor/store-migration.js +76 -0
- package/dist/cursor/store-migration.js.map +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/model.d.ts +13 -0
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js.map +1 -1
- package/dist/models.d.ts +6 -0
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +9 -1
- package/dist/models.js.map +1 -1
- package/dist/providers/cursor.d.ts.map +1 -1
- package/dist/providers/cursor.js +40 -11
- package/dist/providers/cursor.js.map +1 -1
- package/dist/providers/data/.manifest.json +1 -1
- package/dist/providers/data/anthropic.json +1 -1
- package/dist/providers/data/baseten.json +1 -1
- package/dist/providers/data/github-copilot.json +1 -1
- package/dist/providers/data/openai-codex.json +1 -1
- package/dist/providers/data/openai.json +1 -1
- package/dist/providers/data/opencode-go.json +1 -1
- package/dist/providers/data/opencode.json +1 -1
- package/dist/providers/data/openrouter.json +1 -1
- package/dist/providers/data/qwen-token-plan-individual.json +1 -1
- package/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/dist/providers/data/xai.json +1 -1
- package/dist/providers/data/xiaomi-token-plan-ams.json +1 -1
- package/dist/providers/data/xiaomi-token-plan-cn.json +1 -1
- package/dist/providers/data/xiaomi-token-plan-sgp.json +1 -1
- package/dist/providers/data/xiaomi.json +1 -1
- package/dist/providers/data/zai-coding-cn.json +1 -1
- package/dist/providers/data/zai.json +1 -1
- package/dist/providers/xai.d.ts +1 -1
- package/dist/providers/xai.d.ts.map +1 -1
- package/dist/providers/xai.js +1 -5
- package/dist/providers/xai.js.map +1 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/tool-resolver.d.ts.map +1 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/tool-resolver.js +21 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/tool-resolver.js.map +1 -1
- package/dist/tool-call-middleware/recovery-message-snapshot.d.ts.map +1 -1
- package/dist/tool-call-middleware/recovery-message-snapshot.js +2 -1
- package/dist/tool-call-middleware/recovery-message-snapshot.js.map +1 -1
- package/dist/types.d.ts +45 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/overflow.d.ts.map +1 -1
- package/dist/utils/overflow.js +15 -0
- package/dist/utils/overflow.js.map +1 -1
- package/dist/utils/pi-user-agent.d.ts +2 -0
- package/dist/utils/pi-user-agent.d.ts.map +1 -1
- package/dist/utils/pi-user-agent.js +7 -0
- package/dist/utils/pi-user-agent.js.map +1 -1
- package/dist/utils/prompt-cache-ttl.d.ts +2 -1
- package/dist/utils/prompt-cache-ttl.d.ts.map +1 -1
- package/dist/utils/prompt-cache-ttl.js +2 -0
- package/dist/utils/prompt-cache-ttl.js.map +1 -1
- package/package.json +2 -3
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAO/B,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAG3E,OAAO,EACN,mBAAmB,IAAI,yBAAyB,EAChD,iBAAiB,IAAI,uBAAuB,EAC5C,OAAO,IAAI,aAAa,EACxB,QAAQ,IAAI,cAAc,EAC1B,UAAU,IAAI,gBAAgB,EAC9B,SAAS,IAAI,eAAe,GAC5B,MAAM,+BAA+B,CAAC;AAcvC,cAAc,eAAe,CAAC;AAK9B,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAE5E,OAAO,EAIN,eAAe,GACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,E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AM,EAAE,MAAM,iBAAiB,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["export type { Static, TSchema } from \"typebox\";\nexport { Type } from \"typebox\";\n// Core only, side-effect free: no generated catalogs, no provider factories,\n// no api-registry, no OAuth implementations, no compat. Provider factories\n// live under \"@earendil-works/pi-ai/providers/*\", API implementations under\n// \"@earendil-works/pi-ai/api/*\", the old global API under\n// \"@earendil-works/pi-ai/compat\".\nexport type { AnthropicEffort, AnthropicOptions, AnthropicThinkingDisplay } from \"./api/anthropic-messages.ts\";\nexport { sanitizeAnthropicToolPairs } from \"./api/anthropic-tool-pairs.ts\";\nexport type { AzureOpenAIResponsesOptions } from \"./api/azure-openai-responses.ts\";\nexport type { BedrockOptions, BedrockThinkingDisplay } from \"./api/bedrock-converse-stream.ts\";\nexport {\n\tcomposeShellCommand as composeCursorShellCommand,\n\tomitUndefinedArgs as omitUndefinedCursorArgs,\n\tpiLimit as cursorPiLimit,\n\tpiLsPath as cursorPiLsPath,\n\tpiReadArgs as cursorPiReadArgs,\n\tpiTimeout as cursorPiTimeout,\n} from \"./api/cursor-agent/pi-args.ts\";\nexport type {\n\tCursorAgentOptions,\n\tCursorExecHandlerResult,\n\tCursorExecHandlers,\n\tCursorExecPairing,\n\tCursorMcpCall,\n\tCursorPiCall,\n\tCursorShellStreamCallbacks,\n\tCursorToolResultHandler,\n} from \"./api/cursor-agent/types.ts\";\nexport type { GoogleOptions } from \"./api/google-generative-ai.ts\";\nexport type {
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAO/B,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAG3E,OAAO,EACN,mBAAmB,IAAI,yBAAyB,EAChD,iBAAiB,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mB,GACnB,MAAM,0BAA0B,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAC3E,cAAc,qBAAqB,CAAC;AACpC,OAAO,EACN,qBAAqB,EACrB,6BAA6B,EAC7B,8BAA8B,EAC9B,4BAA4B,GAC5B,MAAM,6BAA6B,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oCAAoC,CAAC;AACnD,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["export type { Static, TSchema } from \"typebox\";\nexport { Type } from \"typebox\";\n// Core only, side-effect free: no generated catalogs, no provider factories,\n// no api-registry, no OAuth implementations, no compat. Provider factories\n// live under \"@earendil-works/pi-ai/providers/*\", API implementations under\n// \"@earendil-works/pi-ai/api/*\", the old global API under\n// \"@earendil-works/pi-ai/compat\".\nexport type { AnthropicEffort, AnthropicOptions, AnthropicThinkingDisplay } from \"./api/anthropic-messages.ts\";\nexport { sanitizeAnthropicToolPairs } from \"./api/anthropic-tool-pairs.ts\";\nexport type { AzureOpenAIResponsesOptions } from \"./api/azure-openai-responses.ts\";\nexport type { BedrockOptions, BedrockThinkingDisplay } from \"./api/bedrock-converse-stream.ts\";\nexport {\n\tcomposeShellCommand as composeCursorShellCommand,\n\tomitUndefinedArgs as omitUndefinedCursorArgs,\n\tpiLimit as cursorPiLimit,\n\tpiLsPath as cursorPiLsPath,\n\tpiReadArgs as cursorPiReadArgs,\n\tpiTimeout as cursorPiTimeout,\n} from \"./api/cursor-agent/pi-args.ts\";\nexport type {\n\tCursorAgentOptions,\n\tCursorExecHandlerResult,\n\tCursorExecHandlers,\n\tCursorExecPairing,\n\tCursorMcpCall,\n\tCursorPiCall,\n\tCursorShellStreamCallbacks,\n\tCursorToolResultHandler,\n} from \"./api/cursor-agent/types.ts\";\nexport type { GoogleOptions } from \"./api/google-generative-ai.ts\";\nexport type { GoogleApiThinkingLevel, ResolvedGoogleThinkingLevel } from \"./api/google-shared.ts\";\nexport type { GoogleVertexOptions } from \"./api/google-vertex.ts\";\nexport * from \"./api/lazy.ts\";\nexport type { MistralOptions } from \"./api/mistral-conversations.ts\";\nexport type { OpenAICodexResponsesOptions, OpenAICodexWebSocketDebugStats } from \"./api/openai-codex-responses.ts\";\nexport type { OpenAICompletionsOptions } from \"./api/openai-completions.ts\";\nexport type { OpenAIResponsesOptions } from \"./api/openai-responses.ts\";\nexport { convertResponsesMessages } from \"./api/openai-responses-shared.ts\";\nexport type { PiMessagesEvent, PiMessagesOptions, PiMessagesRewriteImpact } from \"./api/pi-messages.ts\";\nexport {\n\ttype WarmPromptCacheOptions,\n\ttype WarmPromptCacheResult,\n\ttype WarmPromptCacheUsage,\n\twarmPromptCache,\n} from \"./api/warm-prompt-cache.ts\";\nexport { getApiProvider } from \"./api-registry.ts\";\nexport * from \"./auth/context.ts\";\nexport * from \"./auth/credential-store.ts\";\nexport * from \"./auth/headers.ts\";\nexport * from \"./auth/helpers.ts\";\nexport * from \"./auth/types.ts\";\nexport type {\n\tOAuthAuthInfo,\n\tOAuthDeviceCodeInfo,\n\tOAuthLoginCallbacks,\n\tOAuthPrompt,\n\tOAuthProviderId,\n\tOAuthSelectOption,\n\tOAuthSelectPrompt,\n} from \"./compat/extension-oauth-types.ts\";\nexport {\n\tCONTEXT_PROVENANCE_FIELD,\n\ttype ContextProvenance,\n\tcontextProvenanceFingerprint,\n\tcopyContextProvenance,\n\tgetContextProvenance,\n} from \"./context-provenance.ts\";\nexport * from \"./cursor/catalog-grouping.ts\";\nexport {\n\tCURSOR_MODEL_CAPABILITIES,\n\ttype CursorCapabilityEvidence,\n\ttype CursorLevelEncoding,\n\ttype CursorLevelSpec,\n\ttype CursorModelCapability,\n\ttype CursorParameterId,\n\ttype CursorVariantAlias,\n\ttype CursorVariantParse,\n\tgetCursorBaseIdForVariant,\n\tgetCursorCapabilityForBase,\n\tgetCursorVariantAlias,\n} from \"./cursor/model-capabilities.ts\";\nexport {\n\ttype CursorResolvedSelection,\n\trenderCursorCliModelString,\n\tresolveCursorSelectionDescriptor,\n} from \"./cursor/selection-descriptor.ts\";\nexport * from \"./env-api-keys.ts\";\nexport * from \"./images-models.ts\";\nexport * from \"./models.ts\";\nexport * from \"./models-store.ts\";\nexport * from \"./providers/faux.ts\";\nexport * from \"./session-resources.ts\";\nexport {\n\tgetProtocol,\n\tgetToolCallFormat,\n\thasKimiTextToolCallRecovery,\n\tshouldRecoverTextToolCalls,\n\ttransformContext,\n\twrapStreamWithModelRecovery,\n\twrapStreamWithToolCallMiddleware,\n} from \"./tool-call-middleware/index.ts\";\nexport { createXtmlRecoveryStreamParser } from \"./tool-call-middleware/protocols/kimi-xtml/recovery-stream.ts\";\nexport { wrapStreamWithInvokeRecovery } from \"./tool-call-middleware/recovery-stream-wrapper.ts\";\nexport * from \"./types.ts\";\nexport {\n\ttype CursorExecResolvedCarrier,\n\tcopyCursorExecResolved,\n\tisCursorExecResolved,\n\tkCursorExecResolved,\n} from \"./utils/block-symbols.ts\";\nexport * from \"./utils/diagnostics.ts\";\nexport { estimateContextTokens } from \"./utils/estimate.ts\";\nexport * from \"./utils/event-stream.ts\";\nexport * from \"./utils/json-parse.ts\";\nexport { extractOpenAiCodexAccountId } from \"./utils/openai-codex-auth.ts\";\nexport * from \"./utils/overflow.ts\";\nexport {\n\tisAnthropicApiBaseUrl,\n\tPROMPT_CACHE_TTL_LONG_SECONDS,\n\tPROMPT_CACHE_TTL_SHORT_SECONDS,\n\tresolvePromptCacheTtlSeconds,\n} from \"./utils/prompt-cache-ttl.ts\";\nexport * from \"./utils/retry.ts\";\nexport * from \"./utils/server-fallback-receipt.ts\";\nexport * from \"./utils/stop-details.ts\";\nexport { contentText } from \"./utils/text.ts\";\nexport * from \"./utils/tool-pair-repair.ts\";\nexport * from \"./utils/typebox-helpers.ts\";\nexport { uuidv7 } from \"./utils/uuid.ts\";\nexport * from \"./utils/validation.ts\";\nexport * from \"./utils/visible-text.ts\";\nexport { getWireIdentity, setWireIdentity } from \"./wire-identity.ts\";\n"]}
|
package/dist/model.d.ts
CHANGED
|
@@ -38,5 +38,18 @@ export interface Model<TApi extends Api> {
|
|
|
38
38
|
export interface CursorAgentCompat {
|
|
39
39
|
/** Request Cursor's max-mode (1M-context) variant of the model. */
|
|
40
40
|
cursorMaxMode?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Wire-reasoning capability for grouped Cursor catalog identities.
|
|
43
|
+
* Presence is the capability gate: models without it never emit reasoning
|
|
44
|
+
* parameters on the wire.
|
|
45
|
+
*/
|
|
46
|
+
cursorReasoning?: {
|
|
47
|
+
/** Base id into the static cursor capability table. */
|
|
48
|
+
capabilityId: string;
|
|
49
|
+
/** Fixed Claude thinking boolean for this selectable identity. */
|
|
50
|
+
thinkingMode?: boolean;
|
|
51
|
+
/** Exact catalog variant sent when no explicit selection exists. */
|
|
52
|
+
representativeVariantId: string;
|
|
53
|
+
};
|
|
41
54
|
}
|
|
42
55
|
//# sourceMappingURL=model.d.ts.map
|
package/dist/model.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,uBAAuB,EACvB,GAAG,EACH,aAAa,EACb,cAAc,EACd,SAAS,EACT,uBAAuB,EACvB,qBAAqB,EACrB,UAAU,EACV,gBAAg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S,oBAAoB,GAChC,uBAAuB,GACvB,IAAI,SAAS,yBAAyB,GACrC,aAAa,GACb,IAAI,SAAS,cAAc,GAC1B,iBAAiB,GACjB,KAAK,CAAC;CACb;AAED,4CAA4C;AAC5C,MAAM,WAAW,iBAAiB;IACjC,mEAAmE;IACnE,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;OAIG;IACH,eAAe,CAAC,EAAE;QACjB,uDAAuD;QACvD,YAAY,EAAE,MAAM,CAAC;QACrB,kEAAkE;QAClE,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,oEAAoE;QACpE,uBAAuB,EAAE,MAAM,CAAC;KAChC,CAAC;CACF"}
|
package/dist/model.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n\tAnthropicMessagesCompat,\n\tApi,\n\tBedrockCompat,\n\tCacheRetention,\n\tModelCost,\n\tOpenAICompletionsCompat,\n\tOpenAIResponsesCompat,\n\tProviderId,\n\tThinkingLevelMap,\n} from \"./types.ts\";\n\n/** Model interface for the unified model system. */\nexport interface Model<TApi extends Api> {\n\tid: string;\n\tname: string;\n\tapi: TApi;\n\tprovider: ProviderId;\n\tbaseUrl: string;\n\treasoning: boolean;\n\t/**\n\t * Maps pi thinking levels to provider/model-specific values.\n\t * In a present map, omitting `xhigh` or `max` disables that extended tier; ordinary missing levels\n\t * use provider defaults. null marks any level as unsupported.\n\t */\n\tthinkingLevelMap?: ThinkingLevelMap;\n\tinput: (\"text\" | \"image\" | \"video\")[];\n\tcost: ModelCost;\n\tcontextWindow: number;\n\tmaxTokens: number;\n\t/** Default sampling parameters; per-request values override these by key. */\n\tsamplingParams?: Record<string, unknown>;\n\theaders?: Record<string, string>;\n\t/** Default prompt-cache retention preference when the request omits one. */\n\tcacheRetention?: CacheRetention;\n\t/**\n\t * Upstream model id sent on the wire when it differs from the catalog id\n\t * (for example `-fast` priority-tier variants aliasing their base model).\n\t */\n\tupstreamModelId?: string;\n\t/** Service tier requested by default for this model (for example `-fast` variants). */\n\tserviceTier?: \"auto\" | \"flex\" | \"priority\";\n\t/** Whether to recover supported text-encoded tool calls from assistant text. */\n\trecoverTextToolCalls?: boolean;\n\t/** Compatibility overrides for OpenAI-compatible APIs. If not set, auto-detected from baseUrl. */\n\tcompat?: TApi extends \"openai-completions\"\n\t\t? OpenAICompletionsCompat\n\t\t: TApi extends \"openai-responses\" | \"openai-codex-responses\" | \"azure-openai-responses\"\n\t\t\t? OpenAIResponsesCompat\n\t\t\t: TApi extends \"anthropic-messages\"\n\t\t\t\t? AnthropicMessagesCompat\n\t\t\t\t: TApi extends \"bedrock-converse-stream\"\n\t\t\t\t\t? BedrockCompat\n\t\t\t\t\t: TApi extends \"cursor-agent\"\n\t\t\t\t\t\t? CursorAgentCompat\n\t\t\t\t\t\t: never;\n}\n\n/** Cursor agent protocol model metadata. */\nexport interface CursorAgentCompat {\n\t/** Request Cursor's max-mode (1M-context) variant of the model. */\n\tcursorMaxMode?: boolean;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n\tAnthropicMessagesCompat,\n\tApi,\n\tBedrockCompat,\n\tCacheRetention,\n\tModelCost,\n\tOpenAICompletionsCompat,\n\tOpenAIResponsesCompat,\n\tProviderId,\n\tThinkingLevelMap,\n} from \"./types.ts\";\n\n/** Model interface for the unified model system. */\nexport interface Model<TApi extends Api> {\n\tid: string;\n\tname: string;\n\tapi: TApi;\n\tprovider: ProviderId;\n\tbaseUrl: string;\n\treasoning: boolean;\n\t/**\n\t * Maps pi thinking levels to provider/model-specific values.\n\t * In a present map, omitting `xhigh` or `max` disables that extended tier; ordinary missing levels\n\t * use provider defaults. null marks any level as unsupported.\n\t */\n\tthinkingLevelMap?: ThinkingLevelMap;\n\tinput: (\"text\" | \"image\" | \"video\")[];\n\tcost: ModelCost;\n\tcontextWindow: number;\n\tmaxTokens: number;\n\t/** Default sampling parameters; per-request values override these by key. */\n\tsamplingParams?: Record<string, unknown>;\n\theaders?: Record<string, string>;\n\t/** Default prompt-cache retention preference when the request omits one. */\n\tcacheRetention?: CacheRetention;\n\t/**\n\t * Upstream model id sent on the wire when it differs from the catalog id\n\t * (for example `-fast` priority-tier variants aliasing their base model).\n\t */\n\tupstreamModelId?: string;\n\t/** Service tier requested by default for this model (for example `-fast` variants). */\n\tserviceTier?: \"auto\" | \"flex\" | \"priority\";\n\t/** Whether to recover supported text-encoded tool calls from assistant text. */\n\trecoverTextToolCalls?: boolean;\n\t/** Compatibility overrides for OpenAI-compatible APIs. If not set, auto-detected from baseUrl. */\n\tcompat?: TApi extends \"openai-completions\"\n\t\t? OpenAICompletionsCompat\n\t\t: TApi extends \"openai-responses\" | \"openai-codex-responses\" | \"azure-openai-responses\"\n\t\t\t? OpenAIResponsesCompat\n\t\t\t: TApi extends \"anthropic-messages\"\n\t\t\t\t? AnthropicMessagesCompat\n\t\t\t\t: TApi extends \"bedrock-converse-stream\"\n\t\t\t\t\t? BedrockCompat\n\t\t\t\t\t: TApi extends \"cursor-agent\"\n\t\t\t\t\t\t? CursorAgentCompat\n\t\t\t\t\t\t: never;\n}\n\n/** Cursor agent protocol model metadata. */\nexport interface CursorAgentCompat {\n\t/** Request Cursor's max-mode (1M-context) variant of the model. */\n\tcursorMaxMode?: boolean;\n\t/**\n\t * Wire-reasoning capability for grouped Cursor catalog identities.\n\t * Presence is the capability gate: models without it never emit reasoning\n\t * parameters on the wire.\n\t */\n\tcursorReasoning?: {\n\t\t/** Base id into the static cursor capability table. */\n\t\tcapabilityId: string;\n\t\t/** Fixed Claude thinking boolean for this selectable identity. */\n\t\tthinkingMode?: boolean;\n\t\t/** Exact catalog variant sent when no explicit selection exists. */\n\t\trepresentativeVariantId: string;\n\t};\n}\n"]}
|
package/dist/models.d.ts
CHANGED
|
@@ -167,6 +167,12 @@ export interface CreateProviderOptions<TApi extends Api = Api> {
|
|
|
167
167
|
models: readonly Model<TApi>[];
|
|
168
168
|
/** Fetch a dynamic model overlay. createProvider restores and publishes it transactionally. */
|
|
169
169
|
fetchModels?: (context: RefreshModelsContext) => Promise<readonly Model<TApi>[]>;
|
|
170
|
+
/**
|
|
171
|
+
* Optional transform applied to restored stored models before publication,
|
|
172
|
+
* letting a provider migrate an old catalog shape without a network refresh.
|
|
173
|
+
* A throwing transform publishes the stored list unchanged.
|
|
174
|
+
*/
|
|
175
|
+
restoreModels?: (models: readonly Model<TApi>[]) => readonly Model<TApi>[];
|
|
170
176
|
filterModels?: (models: readonly Model<TApi>[], credential: Credential | undefined) => readonly Model<TApi>[];
|
|
171
177
|
/** Single implementation, or map keyed by `model.api` for mixed-API providers. */
|
|
172
178
|
api: ProviderStreams | Partial<Record<TApi, ProviderStreams>>;
|
package/dist/models.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,uBAAuB,EAAoC,MAAM,mBAAmB,CAAC;AACnG,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,EAClB,eAAe,EAEf,eAAe,EACf,mBAAmB,EACnB,KAAK,EACL,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEtE,MAAM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AAgB,kBAAkB,CAAC,IAAI,SAAS,GAAG,EAClD,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,EAClB,KAAK,EAAE,kBAAkB,GACvB,kBAAkB,CAgBpB;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,IAAI,SAAS,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,OAAO,CAM3E;AAwCD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,SAAS,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,OAAO,CAMzE;AA+BD;;;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
|
@@ -482,9 +482,17 @@ export function createProvider(input) {
|
|
|
482
482
|
refreshModels: fetchModels
|
|
483
483
|
? async (context) => {
|
|
484
484
|
if (context.stored) {
|
|
485
|
-
|
|
485
|
+
let restored = context.stored.models
|
|
486
486
|
.filter((model) => model.provider === input.id)
|
|
487
487
|
.map((model) => model);
|
|
488
|
+
if (input.restoreModels) {
|
|
489
|
+
try {
|
|
490
|
+
restored = [...input.restoreModels(restored)];
|
|
491
|
+
}
|
|
492
|
+
catch {
|
|
493
|
+
// The stored list is the last usable catalog; publish it unchanged.
|
|
494
|
+
}
|
|
495
|
+
}
|
|
488
496
|
if (!(await context.publish({
|
|
489
497
|
update: () => {
|
|
490
498
|
dynamicModels = restored;
|
package/dist/models.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.js","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE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,CAAC,QAAQ,CAAC;AACnD,CAAC","sourcesContent":["import { lazyStream } from \"./api/lazy.ts\";\nimport { defaultProviderAuthContext as defaultAuthContext } from \"./auth/context.ts\";\nimport { InMemoryCredentialStore } from \"./auth/credential-store.ts\";\nimport { type AuthResolutionOverrides, ModelsError, resolveProviderAuth } from \"./auth/resolve.ts\";\nimport type {\n\tAuthCheck,\n\tAuthContext,\n\tAuthInteraction,\n\tAuthOperationOptions,\n\tAuthResult,\n\tAuthType,\n\tCredential,\n\tCredentialStore,\n\tProviderAuth,\n} from \"./auth/types.ts\";\nimport { InMemoryModelsStore, type ModelsStore, type ModelsStoreEntry } from \"./models-store.ts\";\nimport type {\n\tApi,\n\tApiStreamOptions,\n\tAssistantMessage,\n\tAssistantMessageEventStream,\n\tContext,\n\tDeferredCancelOptions,\n\tDeferredFetchOptions,\n\tDeferredHandle,\n\tModel,\n\tModelCostRates,\n\tModelThinkingLevel,\n\tProviderHeaders,\n\tProviderRequestOptions,\n\tProviderStreams,\n\tSimpleStreamOptions,\n\tUsage,\n} from \"./types.ts\";\nimport { operationSignal, raceWithAbortSignal } from \"./utils/abort.ts\";\n\nexport { ModelsError, type ModelsErrorCode } from \"./auth/resolve.ts\";\n\nexport interface ModelsPublication {\n\t/** Provider-selected persisted catalog. Omit to leave storage unchanged; null deletes it. */\n\tpersist?: ModelsStoreEntry | null;\n\t/** Optional synchronous update of provider-private in-memory catalog state. */\n\tupdate?: () => void;\n}\n\nexport interface RefreshModelsContext {\n\t/** Effective configured credential. OAuth credentials are refreshed before network access. */\n\tcredential?: Credential;\n\t/** Immutable provider-scoped catalog snapshot captured before this refresh phase. */\n\tstored?: Readonly<ModelsStoreEntry>;\n\t/**\n\t * Generation-checked publication. Persistence policy remains provider-owned;\n\t * the update runs synchronously only after the selected persistence mutation.\n\t */\n\tpublish(publication: ModelsPublication): Promise<boolean>;\n\t/** False during offline/cache-only initialization. */\n\tallowNetwork: boolean;\n\t/** Bypass provider freshness checks and fetch immediately when network access is allowed. */\n\tforce?: boolean;\n\t/** Always present, including when the public refresh caller omits its optional signal. */\n\tsignal: AbortSignal;\n}\n\nexport interface ModelsRefreshOptions {\n\tallowNetwork?: boolean;\n\t/** Restrict refresh to these provider IDs. Unknown and static providers are ignored. */\n\tproviders?: readonly string[];\n\t/** Bypass provider freshness checks and fetch immediately when network access is allowed. */\n\tforce?: boolean;\n\tsignal?: AbortSignal;\n}\n\nexport interface ModelsRefreshResult {\n\taborted: boolean;\n\terrors: ReadonlyMap<string, Error>;\n}\n\nexport interface ModelsRequestTransforms {\n\t/** Transform fully assembled model/auth/request headers before provider dispatch. */\n\ttransformHeaders?: (headers: ProviderHeaders) => ProviderHeaders | Promise<ProviderHeaders>;\n}\n\nexport type ModelsApiStreamOptions<TApi extends Api> = ApiStreamOptions<TApi> & ModelsRequestTransforms;\nexport type ModelsSimpleStreamOptions = SimpleStreamOptions & ModelsRequestTransforms;\nexport type ModelsDeferredFetchOptions = DeferredFetchOptions & ModelsRequestTransforms;\nexport type ModelsDeferredCancelOptions = DeferredCancelOptions & ModelsRequestTransforms;\n\n/**\n * A provider is the concrete runtime unit. It owns id/name/base metadata,\n * auth methods, model listing, and stream behavior.\n *\n * `TApi` lets concrete provider factories declare which APIs their models\n * use (e.g. `openaiProvider(): Provider<\"openai-responses\" | \"openai-completions\">`),\n * giving typed model lists to direct factory users. Inside a `Models`\n * collection providers are held as `Provider<Api>`.\n */\nexport interface Provider<TApi extends Api = Api> {\n\treadonly id: string;\n\treadonly name: string;\n\n\treadonly baseUrl?: string;\n\treadonly headers?: ProviderHeaders;\n\n\t/**\n\t * Required: at least one of `apiKey`/`oauth`. Every provider has auth\n\t * semantics — even providers with only ambient credentials (env vars, AWS\n\t * profiles, ADC files) and keyless local servers provide `apiKey` auth\n\t * whose `resolve()` reports whether the provider is configured.\n\t * `Models.getAuth()` returns undefined when the provider is unconfigured.\n\t */\n\treadonly auth: ProviderAuth;\n\n\t/**\n\t * Current known models, sync. Static providers return their catalog;\n\t * dynamic providers return the list as of the last `refreshModels()`\n\t * (empty before the first). Must not throw; `Models` treats a throwing\n\t * implementation as having no models.\n\t */\n\tgetModels(): readonly Model<TApi>[];\n\n\t/**\n\t * Dynamic providers only: restore `context.stored` and optionally fetch a newer list using\n\t * the effective credential. Implementations retain their previous list on failure, publish\n\t * persistence and synchronous state changes through `context.publish()`, and honor the\n\t * shared abort signal for blocking work.\n\t */\n\trefreshModels?(context: RefreshModelsContext): Promise<void>;\n\n\t/**\n\t * Optional provider policy for credential-specific model availability.\n\t * `getModels()` remains the complete synchronous catalog; `Models.getAvailable()`\n\t * applies this filter after confirming that provider auth is configured.\n\t */\n\tfilterModels?(models: readonly Model<TApi>[], credential: Credential | undefined): readonly Model<TApi>[];\n\n\tstream<T extends TApi>(\n\t\tmodel: Model<T>,\n\t\tcontext: Context,\n\t\toptions?: ApiStreamOptions<T>,\n\t): AssistantMessageEventStream;\n\n\tstreamSimple(model: Model<TApi>, context: Context, options?: SimpleStreamOptions): AssistantMessageEventStream;\n\tfetchDeferred?(\n\t\tmodel: Model<TApi>,\n\t\thandle: DeferredHandle,\n\t\toptions?: DeferredFetchOptions,\n\t): AssistantMessageEventStream;\n\tcancelDeferred?(model: Model<TApi>, handle: DeferredHandle, options?: DeferredCancelOptions): Promise<void>;\n}\n\n/**\n * Runtime collection of providers plus auth application and stream\n * convenience. Providers own stream behavior; `Models` resolves auth and\n * delegates each request to the provider that owns the model.\n */\nexport interface Models {\n\tgetProviders(): readonly Provider[];\n\tgetProvider(id: string): Provider | undefined;\n\n\t/**\n\t * Sync read of last-known models from one provider or all providers.\n\t * Best-effort: a provider whose `getModels()` throws yields no models.\n\t */\n\tgetModels(provider?: string): readonly Model<Api>[];\n\n\t/**\n\t * Sync runtime model lookup against last-known lists. Dynamic model lists\n\t * are typed as `Model<Api>`; narrow with the `hasApi()` type guard.\n\t */\n\tgetModel(provider: string, id: string): Model<Api> | undefined;\n\n\t/**\n\t * Refresh selected configured dynamic providers concurrently (all when `providers` is omitted).\n\t * Provider errors and cancellation are returned without rejecting; static, unknown, and\n\t * unconfigured providers are skipped.\n\t */\n\trefresh(options?: ModelsRefreshOptions): Promise<ModelsRefreshResult>;\n\n\t/** Check whether a provider has complete auth configuration without refreshing OAuth. */\n\tcheckAuth(providerId: string, options?: AuthOperationOptions): Promise<AuthCheck | undefined>;\n\n\t/** Return models whose providers have complete auth configuration. */\n\tgetAvailable(providerId?: string, options?: AuthOperationOptions): Promise<readonly Model<Api>[]>;\n\n\t/**\n\t * Resolve provider-scoped auth by provider id, or provider auth plus static\n\t * model headers when passed a model. Includes a source label for status UI.\n\t * Resolves `undefined` when the provider is unknown or unconfigured.\n\t * Rejects with `ModelsError`: code \"oauth\" when a token refresh fails (the\n\t * stored credential is preserved for retry; re-login fixes it), code \"auth\"\n\t * when api-key resolution or the credential store fails. Request paths\n\t * surface rejections as stream errors.\n\t */\n\tgetAuth(providerId: string, overrides?: AuthResolutionOverrides): Promise<AuthResult | undefined>;\n\tgetAuth(model: Model<Api>, overrides?: AuthResolutionOverrides): Promise<AuthResult | undefined>;\n\n\t/** Run a provider-owned login flow and persist its returned credential. */\n\tlogin(providerId: string, type: AuthType, interaction: AuthInteraction): Promise<Credential>;\n\n\t/** Remove the stored credential for a provider. */\n\tlogout(providerId: string, options?: AuthOperationOptions): Promise<void>;\n\n\tstream<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): AssistantMessageEventStream;\n\n\tcomplete<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): Promise<AssistantMessage>;\n\n\tstreamSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): AssistantMessageEventStream;\n\tcompleteSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): Promise<AssistantMessage>;\n\tfetchDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredFetchOptions,\n\t): Promise<AssistantMessage>;\n\tcancelDeferred(model: Model<Api>, handle: DeferredHandle, options?: ModelsDeferredCancelOptions): Promise<void>;\n}\n\nexport interface MutableModels extends Models {\n\t/** Upsert/replace by provider.id. Provider ids are unique. */\n\tsetProvider(provider: Provider): void;\n\tdeleteProvider(id: string): void;\n\tclearProviders(): void;\n}\n\nexport interface CreateModelsOptions {\n\tcredentials?: CredentialStore;\n\tmodelsStore?: ModelsStore;\n\tauthContext?: AuthContext;\n}\n\nfunction mergeHeaders(\n\tbase: ProviderHeaders | undefined,\n\toverride: ProviderHeaders | undefined,\n): ProviderHeaders | undefined {\n\tif (!base && !override) return undefined;\n\tconst merged = { ...base };\n\tfor (const [name, value] of Object.entries(override ?? {})) {\n\t\tconst lowerName = name.toLowerCase();\n\t\tfor (const existingName of Object.keys(merged)) {\n\t\t\tif (existingName.toLowerCase() === lowerName) delete merged[existingName];\n\t\t}\n\t\tmerged[name] = value;\n\t}\n\treturn merged;\n}\n\nclass ModelsImpl implements MutableModels {\n\tprivate providers = new Map<string, Provider>();\n\tprivate credentials: CredentialStore;\n\tprivate modelsStore: ModelsStore;\n\tprivate authContext: AuthContext;\n\tprivate refreshGenerations = new Map<string, number>();\n\tprivate refreshControllers = new Map<string, AbortController>();\n\tprivate publicationChains = new Map<string, Promise<unknown>>();\n\n\tconstructor(options?: CreateModelsOptions) {\n\t\tthis.credentials = options?.credentials ?? new InMemoryCredentialStore();\n\t\tthis.modelsStore = options?.modelsStore ?? new InMemoryModelsStore();\n\t\tthis.authContext = options?.authContext ?? defaultAuthContext();\n\t}\n\n\tsetProvider(provider: Provider): void {\n\t\tthis.supersedeProviderRefresh(provider.id);\n\t\tthis.providers.set(provider.id, provider);\n\t}\n\n\tdeleteProvider(id: string): void {\n\t\tthis.supersedeProviderRefresh(id);\n\t\tthis.providers.delete(id);\n\t}\n\n\tclearProviders(): void {\n\t\tfor (const id of new Set([...this.providers.keys(), ...this.refreshControllers.keys()])) {\n\t\t\tthis.supersedeProviderRefresh(id);\n\t\t}\n\t\tthis.providers.clear();\n\t}\n\n\tgetProviders(): readonly Provider[] {\n\t\treturn Array.from(this.providers.values());\n\t}\n\n\tgetProvider(id: string): Provider | undefined {\n\t\treturn this.providers.get(id);\n\t}\n\n\tgetModels(provider?: string): readonly Model<Api>[] {\n\t\tif (provider !== undefined) {\n\t\t\tconst entry = this.providers.get(provider);\n\t\t\tif (!entry) return [];\n\t\t\ttry {\n\t\t\t\treturn entry.getModels();\n\t\t\t} catch {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t}\n\n\t\tconst models: Model<Api>[] = [];\n\t\tfor (const entry of this.providers.values()) {\n\t\t\ttry {\n\t\t\t\tmodels.push(...entry.getModels());\n\t\t\t} catch {\n\t\t\t\t// Best-effort: ill-behaved providers yield no models.\n\t\t\t}\n\t\t}\n\t\treturn models;\n\t}\n\n\tgetModel(provider: string, id: string): Model<Api> | undefined {\n\t\treturn this.getModels(provider).find((model) => model.id === id);\n\t}\n\n\tprivate supersedeProviderRefresh(providerId: string): number {\n\t\tconst generation = (this.refreshGenerations.get(providerId) ?? 0) + 1;\n\t\tthis.refreshGenerations.set(providerId, generation);\n\t\tconst previous = this.refreshControllers.get(providerId);\n\t\tif (previous) {\n\t\t\tthis.refreshControllers.delete(providerId);\n\t\t\tprevious.abort();\n\t\t}\n\t\treturn generation;\n\t}\n\n\tprivate beginProviderRefresh(providerId: string): { generation: number; controller: AbortController } {\n\t\tconst generation = this.supersedeProviderRefresh(providerId);\n\t\tconst controller = new AbortController();\n\t\tthis.refreshControllers.set(providerId, controller);\n\t\treturn { generation, controller };\n\t}\n\n\tprivate publishProviderModels(\n\t\tproviderId: string,\n\t\tgeneration: number,\n\t\tsignal: AbortSignal,\n\t\tpublication: ModelsPublication,\n\t): Promise<boolean> {\n\t\tconst previous = this.publicationChains.get(providerId) ?? Promise.resolve();\n\t\tconst queued = (async () => {\n\t\t\tawait previous.catch(() => {});\n\t\t\tif (signal.aborted || this.refreshGenerations.get(providerId) !== generation) return false;\n\n\t\t\tif (publication.persist === null) {\n\t\t\t\tawait this.modelsStore.delete(providerId, { signal });\n\t\t\t} else if (publication.persist !== undefined) {\n\t\t\t\tawait this.modelsStore.write(providerId, structuredClone(publication.persist), { signal });\n\t\t\t}\n\n\t\t\tif (signal.aborted || this.refreshGenerations.get(providerId) !== generation) return false;\n\t\t\tpublication.update?.();\n\t\t\treturn true;\n\t\t})();\n\t\tconst tail = queued.catch(() => {});\n\t\tthis.publicationChains.set(providerId, tail);\n\t\tvoid tail.then(() => {\n\t\t\tif (this.publicationChains.get(providerId) === tail) this.publicationChains.delete(providerId);\n\t\t});\n\t\treturn raceWithAbortSignal(queued, signal);\n\t}\n\n\tprivate async runProviderRefreshPhase(\n\t\tprovider: Provider & Required<Pick<Provider, \"refreshModels\">>,\n\t\tcredential: Credential | undefined,\n\t\tallowNetwork: boolean,\n\t\tforce: boolean | undefined,\n\t\tgeneration: number,\n\t\tsignal: AbortSignal,\n\t): Promise<void> {\n\t\tconst stored = await this.modelsStore.read(provider.id, { signal });\n\t\tawait provider.refreshModels({\n\t\t\tcredential,\n\t\t\tstored: stored ? structuredClone(stored) : undefined,\n\t\t\tpublish: (publication) => this.publishProviderModels(provider.id, generation, signal, publication),\n\t\t\tallowNetwork,\n\t\t\tforce: allowNetwork ? force : undefined,\n\t\t\tsignal,\n\t\t});\n\t}\n\n\tasync refresh(options: ModelsRefreshOptions = {}): Promise<ModelsRefreshResult> {\n\t\tconst allowNetwork = options.allowNetwork ?? true;\n\t\tconst callerSignal = operationSignal(options.signal);\n\t\tconst errors = new Map<string, Error>();\n\t\tif (callerSignal.aborted) return { aborted: true, errors };\n\t\tconst selected = options.providers ? new Set(options.providers) : undefined;\n\t\tconst refreshable = Array.from(this.providers.values()).filter(\n\t\t\t(provider): provider is Provider & Required<Pick<Provider, \"refreshModels\">> =>\n\t\t\t\tprovider.refreshModels !== undefined && (!selected || selected.has(provider.id)),\n\t\t);\n\n\t\tconst refresh = Promise.all(\n\t\t\trefreshable.map(async (provider) => {\n\t\t\t\tconst { generation, controller } = this.beginProviderRefresh(provider.id);\n\t\t\t\tconst signal = AbortSignal.any([callerSignal, controller.signal]);\n\t\t\t\tconst operation = (async () => {\n\t\t\t\t\tlet storedCredential: Credential | undefined;\n\t\t\t\t\tlet credentialError: unknown;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tstoredCredential = await this.readCredential(provider.id, signal);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tcredentialError = error;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Restore cached provider state before auth resolution or network access.\n\t\t\t\t\tawait this.runProviderRefreshPhase(provider, storedCredential, false, undefined, generation, signal);\n\t\t\t\t\tif (credentialError !== undefined) throw credentialError;\n\t\t\t\t\tif (!allowNetwork || signal.aborted) return;\n\n\t\t\t\t\tconst credential = await this.resolveRefreshCredential(provider, storedCredential, signal);\n\t\t\t\t\tif (!credential) return;\n\t\t\t\t\tawait this.runProviderRefreshPhase(provider, credential, true, options.force, generation, signal);\n\t\t\t\t})();\n\n\t\t\t\ttry {\n\t\t\t\t\tawait raceWithAbortSignal(operation, signal);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (!signal.aborted) {\n\t\t\t\t\t\terrors.set(\n\t\t\t\t\t\t\tprovider.id,\n\t\t\t\t\t\t\terror instanceof Error\n\t\t\t\t\t\t\t\t? error\n\t\t\t\t\t\t\t\t: new ModelsError(\"model_source\", `Model refresh failed for ${provider.id}`, { cause: error }),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} finally {\n\t\t\t\t\tif (this.refreshControllers.get(provider.id) === controller) {\n\t\t\t\t\t\tthis.refreshControllers.delete(provider.id);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\n\t\ttry {\n\t\t\tawait raceWithAbortSignal(refresh, callerSignal);\n\t\t} catch (error) {\n\t\t\tif (!callerSignal.aborted) throw error;\n\t\t}\n\n\t\treturn { aborted: callerSignal.aborted, errors: new Map(errors) };\n\t}\n\n\tprivate async resolveRefreshCredential(\n\t\tprovider: Provider,\n\t\tstored: Credential | undefined,\n\t\tsignal: AbortSignal,\n\t): Promise<Credential | undefined> {\n\t\tif (stored?.type === \"oauth\") {\n\t\t\tconst oauth = provider.auth.oauth;\n\t\t\tif (!oauth) return undefined;\n\t\t\tif (Date.now() < stored.expires) return stored;\n\t\t\tif (signal.aborted) return undefined;\n\t\t\tconst post = await this.credentials.modify(\n\t\t\t\tprovider.id,\n\t\t\t\tasync (current) => {\n\t\t\t\t\tif (current?.type !== \"oauth\" || Date.now() < current.expires) return undefined;\n\t\t\t\t\treturn oauth.refresh(current, signal);\n\t\t\t\t},\n\t\t\t\t{ signal },\n\t\t\t);\n\t\t\treturn post?.type === \"oauth\" ? post : undefined;\n\t\t}\n\n\t\tconst apiKey = provider.auth.apiKey;\n\t\tif (!apiKey) return undefined;\n\t\tconst credential = stored?.type === \"api_key\" ? stored : undefined;\n\t\tconst result = await apiKey.resolve({ ctx: this.authContext, credential, signal });\n\t\tif (!result) return undefined;\n\t\treturn { type: \"api_key\", key: result.auth.apiKey, env: result.env };\n\t}\n\n\tprivate async readCredential(providerId: string, signal: AbortSignal): Promise<Credential | undefined> {\n\t\ttry {\n\t\t\treturn await this.credentials.read(providerId, { signal });\n\t\t} catch (error) {\n\t\t\tthrow new ModelsError(\"auth\", `Credential store read failed for ${providerId}`, { cause: error });\n\t\t}\n\t}\n\n\tprivate async checkProviderAuth(\n\t\tprovider: Provider,\n\t\tcredential: Credential | undefined,\n\t\tsignal: AbortSignal,\n\t): Promise<AuthCheck | undefined> {\n\t\tconst oauth = provider.auth.oauth;\n\t\tif (credential?.type === \"oauth\") {\n\t\t\tif (!oauth) return undefined;\n\t\t\tif (!oauth.check) return { source: \"OAuth\", type: \"oauth\" };\n\t\t\ttry {\n\t\t\t\treturn await oauth.check({ ctx: this.authContext, credential, signal });\n\t\t\t} catch (error) {\n\t\t\t\tthrow new ModelsError(\"auth\", `OAuth auth check failed for provider ${provider.id}`, { cause: error });\n\t\t\t}\n\t\t}\n\t\tconst apiKey = provider.auth.apiKey;\n\t\tif (apiKey) {\n\t\t\tif (apiKey.check) {\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await apiKey.check({\n\t\t\t\t\t\tctx: this.authContext,\n\t\t\t\t\t\tcredential: credential?.type === \"api_key\" ? credential : undefined,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t});\n\t\t\t\t\tif (result) return result;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new ModelsError(\"auth\", `API key auth check failed for provider ${provider.id}`, { cause: error });\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst resolution = await resolveProviderAuth(provider, this.credentials, this.authContext, { signal });\n\t\t\t\tif (resolution) return { source: resolution.source, type: \"api_key\" };\n\t\t\t}\n\t\t}\n\t\tif (!oauth?.check) return undefined;\n\t\ttry {\n\t\t\treturn await oauth.check({ ctx: this.authContext, signal });\n\t\t} catch (error) {\n\t\t\tthrow new ModelsError(\"auth\", `OAuth auth check failed for provider ${provider.id}`, { cause: error });\n\t\t}\n\t}\n\n\tcheckAuth(providerId: string, options?: AuthOperationOptions): Promise<AuthCheck | undefined> {\n\t\tconst signal = operationSignal(options?.signal);\n\t\tconst check = (async () => {\n\t\t\tsignal.throwIfAborted();\n\t\t\tconst provider = this.providers.get(providerId);\n\t\t\tif (!provider) return undefined;\n\t\t\treturn this.checkProviderAuth(provider, await this.readCredential(providerId, signal), signal);\n\t\t})();\n\t\treturn raceWithAbortSignal(check, signal);\n\t}\n\n\tgetAvailable(providerId?: string, options?: AuthOperationOptions): Promise<readonly Model<Api>[]> {\n\t\tconst signal = operationSignal(options?.signal);\n\t\tconst available = (async () => {\n\t\t\tsignal.throwIfAborted();\n\t\t\tconst providers = providerId\n\t\t\t\t? [this.providers.get(providerId)].filter((entry) => entry !== undefined)\n\t\t\t\t: this.getProviders();\n\t\t\tconst checks = await Promise.all(\n\t\t\t\tproviders.map(async (provider) => {\n\t\t\t\t\tconst credential = await this.readCredential(provider.id, signal);\n\t\t\t\t\treturn { provider, credential, auth: await this.checkProviderAuth(provider, credential, signal) };\n\t\t\t\t}),\n\t\t\t);\n\t\t\treturn checks.flatMap(({ provider, credential, auth }) => {\n\t\t\t\tif (!auth) return [];\n\t\t\t\tconst models = provider.getModels();\n\t\t\t\treturn provider.filterModels?.(models, credential) ?? models;\n\t\t\t});\n\t\t})();\n\t\treturn raceWithAbortSignal(available, signal);\n\t}\n\n\tgetAuth(providerId: string, overrides?: AuthResolutionOverrides): Promise<AuthResult | undefined>;\n\tgetAuth(model: Model<Api>, overrides?: AuthResolutionOverrides): Promise<AuthResult | undefined>;\n\tasync getAuth(\n\t\tproviderOrModel: string | Model<Api>,\n\t\toverrides?: AuthResolutionOverrides,\n\t): Promise<AuthResult | undefined> {\n\t\tconst signal = operationSignal(overrides?.signal);\n\t\tconst providerId = typeof providerOrModel === \"string\" ? providerOrModel : providerOrModel.provider;\n\t\tconst provider = this.providers.get(providerId);\n\t\tif (!provider) return undefined;\n\t\tconst result = await resolveProviderAuth(provider, this.credentials, this.authContext, { ...overrides, signal });\n\t\tif (!result || typeof providerOrModel === \"string\" || !providerOrModel.headers) return result;\n\t\treturn {\n\t\t\t...result,\n\t\t\tauth: {\n\t\t\t\t...result.auth,\n\t\t\t\theaders: mergeHeaders(result.auth.headers, providerOrModel.headers),\n\t\t\t},\n\t\t};\n\t}\n\n\tasync login(providerId: string, type: AuthType, interaction: AuthInteraction): Promise<Credential> {\n\t\tconst signal = operationSignal(interaction.signal);\n\t\tsignal.throwIfAborted();\n\t\tconst provider = this.providers.get(providerId);\n\t\tif (!provider) throw new ModelsError(\"provider\", `Unknown provider: ${providerId}`);\n\t\tconst method = type === \"oauth\" ? provider.auth.oauth : provider.auth.apiKey;\n\t\tif (!method?.login) {\n\t\t\tthrow new ModelsError(\"auth\", `${provider.name} does not support ${type} login`);\n\t\t}\n\t\tconst loginOperation: Promise<Credential> = method.login({ ...interaction, signal });\n\t\tconst credential = await raceWithAbortSignal(loginOperation, signal);\n\t\tlet mutationStarted = false;\n\t\tlet markMutationStarted: (() => void) | undefined;\n\t\tconst started = new Promise<void>((resolve) => {\n\t\t\tmarkMutationStarted = resolve;\n\t\t});\n\t\tconst mutation = this.credentials.modify(\n\t\t\tproviderId,\n\t\t\tasync () => {\n\t\t\t\tmutationStarted = true;\n\t\t\t\tmarkMutationStarted?.();\n\t\t\t\treturn credential;\n\t\t\t},\n\t\t\t{ signal },\n\t\t);\n\t\tvoid mutation.catch(() => {});\n\t\ttry {\n\t\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\t\tconst onAbort = () => {\n\t\t\t\t\tif (!mutationStarted) reject(signal.reason);\n\t\t\t\t};\n\t\t\t\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\tvoid Promise.race([started, mutation]).then(\n\t\t\t\t\t() => {\n\t\t\t\t\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t},\n\t\t\t\t\t(error: unknown) => {\n\t\t\t\t\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\treject(error);\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tif (signal.aborted) onAbort();\n\t\t\t});\n\t\t\tawait mutation;\n\t\t} catch (error) {\n\t\t\tsignal.throwIfAborted();\n\t\t\tthrow new ModelsError(\"auth\", `Credential store modify failed for ${providerId}`, { cause: error });\n\t\t}\n\t\treturn credential;\n\t}\n\n\tasync logout(providerId: string, options?: AuthOperationOptions): Promise<void> {\n\t\tconst signal = operationSignal(options?.signal);\n\t\tsignal.throwIfAborted();\n\t\ttry {\n\t\t\tawait this.credentials.delete(providerId, { signal });\n\t\t} catch (error) {\n\t\t\tsignal.throwIfAborted();\n\t\t\tthrow new ModelsError(\"auth\", `Credential store delete failed for ${providerId}`, { cause: error });\n\t\t}\n\t}\n\n\tprivate requireProvider(model: Model<Api>): Provider {\n\t\tconst provider = this.providers.get(model.provider);\n\t\tif (!provider) {\n\t\t\tthrow new ModelsError(\"provider\", `Unknown provider: ${model.provider}`);\n\t\t}\n\t\treturn provider;\n\t}\n\n\tprivate async applyAuth<TOptions extends ProviderRequestOptions & ModelsRequestTransforms>(\n\t\tmodel: Model<Api>,\n\t\toptions: TOptions | undefined,\n\t): Promise<{\n\t\trequestModel: Model<Api>;\n\t\trequestOptions: Omit<TOptions, \"transformHeaders\"> & ProviderRequestOptions;\n\t}> {\n\t\tthis.requireProvider(model);\n\t\tconst resolution = await this.getAuth(model, {\n\t\t\tapiKey: options?.apiKey,\n\t\t\tenv: options?.env,\n\t\t\tsignal: options?.signal,\n\t\t});\n\t\tif (!resolution) {\n\t\t\tthrow new ModelsError(\"auth\", `Provider is not configured: ${model.provider}`);\n\t\t}\n\t\tconst auth = resolution.auth;\n\n\t\t// Explicit request options win per-field; the Models-only transform runs last.\n\t\tconst apiKey = options?.apiKey ?? auth.apiKey;\n\t\tlet headers = mergeHeaders(auth.headers, options?.headers);\n\t\tif (options?.transformHeaders) headers = await options.transformHeaders(headers ?? {});\n\t\tconst env = resolution.env || options?.env ? { ...(resolution.env ?? {}), ...(options?.env ?? {}) } : undefined;\n\t\tconst requestModel = auth.baseUrl ? { ...model, baseUrl: auth.baseUrl } : model;\n\t\tconst { transformHeaders: _transformHeaders, ...providerOptions } = options ?? {};\n\t\tconst requestOptions = { ...providerOptions, apiKey, headers, env } as Omit<TOptions, \"transformHeaders\"> &\n\t\t\tProviderRequestOptions;\n\n\t\treturn { requestModel, requestOptions };\n\t}\n\n\tstream<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): AssistantMessageEventStream {\n\t\treturn lazyStream(model, async () => {\n\t\t\tconst provider = this.requireProvider(model);\n\t\t\tconst { requestModel, requestOptions } = await this.applyAuth(\n\t\t\t\tmodel,\n\t\t\t\toptions as ModelsApiStreamOptions<Api> | undefined,\n\t\t\t);\n\t\t\treturn provider.stream(requestModel as Model<TApi>, context, requestOptions as ApiStreamOptions<TApi>);\n\t\t});\n\t}\n\n\tasync complete<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): Promise<AssistantMessage> {\n\t\treturn this.stream(model, context, options).result();\n\t}\n\n\tstreamSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): AssistantMessageEventStream {\n\t\treturn lazyStream(model, async () => {\n\t\t\tconst provider = this.requireProvider(model);\n\t\t\tconst { requestModel, requestOptions } = await this.applyAuth(model, options);\n\t\t\treturn provider.streamSimple(requestModel, context, requestOptions as SimpleStreamOptions);\n\t\t});\n\t}\n\n\tasync completeSimple(\n\t\tmodel: Model<Api>,\n\t\tcontext: Context,\n\t\toptions?: ModelsSimpleStreamOptions,\n\t): Promise<AssistantMessage> {\n\t\treturn this.streamSimple(model, context, options).result();\n\t}\n\n\tasync fetchDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredFetchOptions,\n\t): Promise<AssistantMessage> {\n\t\treturn lazyStream(model, async () => {\n\t\t\tconst provider = this.requireProvider(model);\n\t\t\tif (!provider.fetchDeferred) {\n\t\t\t\tthrow new ModelsError(\"provider\", `Provider ${model.provider} does not support deferred responses`);\n\t\t\t}\n\t\t\tconst { requestModel, requestOptions } = await this.applyAuth(model, options);\n\t\t\treturn provider.fetchDeferred(requestModel, handle, requestOptions as DeferredFetchOptions);\n\t\t}).result();\n\t}\n\n\tasync cancelDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredCancelOptions,\n\t): Promise<void> {\n\t\tconst provider = this.requireProvider(model);\n\t\tif (!provider.cancelDeferred) {\n\t\t\tthrow new ModelsError(\"provider\", `Provider ${model.provider} does not support deferred responses`);\n\t\t}\n\t\tconst { requestModel, requestOptions } = await this.applyAuth(model, options);\n\t\tawait provider.cancelDeferred(requestModel, handle, requestOptions);\n\t}\n}\n\nexport function createModels(options?: CreateModelsOptions): MutableModels {\n\treturn new ModelsImpl(options);\n}\n\nexport interface CreateProviderOptions<TApi extends Api = Api> {\n\tid: string;\n\t/** Display name. Default: `id`. */\n\tname?: string;\n\tbaseUrl?: string;\n\theaders?: ProviderHeaders;\n\t/** Required — every provider has auth semantics, even ambient/keyless ones. */\n\tauth: ProviderAuth;\n\t/** Static baseline model list (empty for purely dynamic providers). */\n\tmodels: readonly Model<TApi>[];\n\t/** Fetch a dynamic model overlay. createProvider restores and publishes it transactionally. */\n\tfetchModels?: (context: RefreshModelsContext) => Promise<readonly Model<TApi>[]>;\n\tfilterModels?: (models: readonly Model<TApi>[], credential: Credential | undefined) => readonly Model<TApi>[];\n\t/** Single implementation, or map keyed by `model.api` for mixed-API providers. */\n\tapi: ProviderStreams | Partial<Record<TApi, ProviderStreams>>;\n}\n\n/**\n * Builds a provider from parts. Built-in provider factories and models.json\n * custom providers both go through this. A single `api` streams all models;\n * an `api` map dispatches on `model.api`, and a model whose api has no entry\n * produces a stream error.\n */\nexport function createProvider<TApi extends Api = Api>(input: CreateProviderOptions<TApi>): Provider<TApi> {\n\tconst baselineModels = input.models;\n\tlet dynamicModels: readonly Model<TApi>[] = [];\n\tconst fetchModels = input.fetchModels;\n\tconst currentModels = (): readonly Model<TApi>[] => {\n\t\tconst merged = [...baselineModels];\n\t\tfor (const model of dynamicModels) {\n\t\t\tconst index = merged.findIndex((entry) => entry.id === model.id);\n\t\t\tif (index >= 0) merged[index] = model;\n\t\t\telse merged.push(model);\n\t\t}\n\t\treturn merged;\n\t};\n\tconst single =\n\t\ttypeof (input.api as ProviderStreams).stream === \"function\" ? (input.api as ProviderStreams) : undefined;\n\tconst byApi = single ? undefined : (input.api as Partial<Record<string, ProviderStreams>>);\n\n\tconst apiFor = (model: Model<Api>): ProviderStreams | undefined => single ?? byApi?.[model.api];\n\n\tconst dispatch = (\n\t\tmodel: Model<Api>,\n\t\trun: (streams: ProviderStreams) => AssistantMessageEventStream,\n\t): AssistantMessageEventStream => {\n\t\tconst streams = apiFor(model);\n\t\tif (!streams) {\n\t\t\treturn lazyStream(model, async () => {\n\t\t\t\tthrow new ModelsError(\"stream\", `Provider ${input.id} has no API implementation for \"${model.api}\"`);\n\t\t\t});\n\t\t}\n\t\treturn run(streams);\n\t};\n\n\tconst provider: Provider<TApi> = {\n\t\tid: input.id,\n\t\tname: input.name ?? input.id,\n\t\tbaseUrl: input.baseUrl,\n\t\theaders: input.headers,\n\t\tauth: input.auth,\n\t\tgetModels: currentModels,\n\t\trefreshModels: fetchModels\n\t\t\t? async (context) => {\n\t\t\t\t\tif (context.stored) {\n\t\t\t\t\t\tconst restored = context.stored.models\n\t\t\t\t\t\t\t.filter((model) => model.provider === input.id)\n\t\t\t\t\t\t\t.map((model) => model as Model<TApi>);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t!(await context.publish({\n\t\t\t\t\t\t\t\tupdate: () => {\n\t\t\t\t\t\t\t\t\tdynamicModels = restored;\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}))\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (!context.allowNetwork || context.signal.aborted) return;\n\t\t\t\t\tconst refreshed = await fetchModels(context);\n\t\t\t\t\tif (context.signal.aborted || refreshed.length === 0) return;\n\t\t\t\t\tawait context.publish({\n\t\t\t\t\t\tpersist: { models: refreshed, checkedAt: Date.now() },\n\t\t\t\t\t\tupdate: () => {\n\t\t\t\t\t\t\tdynamicModels = refreshed;\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t: undefined,\n\t\tfilterModels: input.filterModels,\n\t\tstream: (model, context, options) => dispatch(model, (streams) => streams.stream(model, context, options)),\n\t\tstreamSimple: (model, context, options) =>\n\t\t\tdispatch(model, (streams) => streams.streamSimple(model, context, options)),\n\t};\n\n\tconst streams = single ? [single] : Object.values(byApi ?? {}).filter((entry) => entry !== undefined);\n\tif (streams.some((entry) => entry.fetchDeferred !== undefined)) {\n\t\tprovider.fetchDeferred = (model, handle, options) =>\n\t\t\tlazyStream(model, async () => {\n\t\t\t\tconst implementation = apiFor(model);\n\t\t\t\tif (!implementation?.fetchDeferred) {\n\t\t\t\t\tthrow new ModelsError(\n\t\t\t\t\t\t\"provider\",\n\t\t\t\t\t\t`Provider ${input.id} does not support deferred responses for \"${model.api}\"`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn implementation.fetchDeferred(model, handle, options);\n\t\t\t});\n\t}\n\tif (streams.some((entry) => entry.cancelDeferred !== undefined)) {\n\t\tprovider.cancelDeferred = async (model, handle, options) => {\n\t\t\tconst implementation = apiFor(model);\n\t\t\tif (!implementation?.cancelDeferred) {\n\t\t\t\tthrow new ModelsError(\n\t\t\t\t\t\"provider\",\n\t\t\t\t\t`Provider ${input.id} cannot cancel deferred responses for \"${model.api}\"`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait implementation.cancelDeferred(model, handle, options);\n\t\t};\n\t}\n\n\treturn provider;\n}\n\n/**\n * Runtime-checked narrowing for dynamically looked-up models:\n *\n * ```ts\n * const model = models.getModel(\"anthropic\", \"claude-opus-4-7\");\n * if (model && hasApi(model, \"anthropic-messages\")) {\n * // model: Model<\"anthropic-messages\">, stream options fully typed\n * }\n * ```\n */\nexport function hasApi<TApi extends Api>(model: Model<Api>, api: TApi): model is Model<TApi> {\n\treturn model.api === api;\n}\n\nexport function calculateCost<TApi extends Api>(model: Model<TApi>, usage: Usage): Usage[\"cost\"] {\n\tconst inputTokens = usage.input + usage.cacheRead + usage.cacheWrite;\n\tlet rates: ModelCostRates = model.cost;\n\tlet matchedThreshold = -1;\n\tfor (const tier of model.cost.tiers ?? []) {\n\t\tif (inputTokens > tier.inputTokensAbove && tier.inputTokensAbove > matchedThreshold) {\n\t\t\trates = tier;\n\t\t\tmatchedThreshold = tier.inputTokensAbove;\n\t\t}\n\t}\n\n\t// Anthropic charges 2x base input for 1h cache writes.\n\tconst longWrite = usage.cacheWrite1h ?? 0;\n\tconst shortWrite = usage.cacheWrite - longWrite;\n\tusage.cost.input = (rates.input / 1000000) * usage.input;\n\tusage.cost.output = (rates.output / 1000000) * usage.output;\n\tusage.cost.cacheRead = (rates.cacheRead / 1000000) * usage.cacheRead;\n\tusage.cost.cacheWrite = (rates.cacheWrite * shortWrite + rates.input * 2 * longWrite) / 1000000;\n\tusage.cost.total = usage.cost.input + usage.cost.output + usage.cost.cacheRead + usage.cost.cacheWrite;\n\treturn usage.cost;\n}\n\nconst EXTENDED_THINKING_LEVELS: ModelThinkingLevel[] = [\"off\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\", \"max\"];\n\nexport function getSupportedThinkingLevels<TApi extends Api>(model: Model<TApi>): ModelThinkingLevel[] {\n\tif (!model.reasoning) return [\"off\"];\n\n\treturn EXTENDED_THINKING_LEVELS.filter((level) => {\n\t\tconst mapped = model.thinkingLevelMap?.[level];\n\t\tif (mapped === null) return false;\n\t\tif (level === \"xhigh\") return supportsXhigh(model);\n\t\tif (level === \"max\") return supportsMax(model);\n\t\treturn true;\n\t});\n}\n\nexport function clampThinkingLevel<TApi extends Api>(\n\tmodel: Model<TApi>,\n\tlevel: ModelThinkingLevel,\n): ModelThinkingLevel {\n\tconst availableLevels = getSupportedThinkingLevels(model);\n\tif (availableLevels.includes(level)) return level;\n\n\tconst requestedIndex = EXTENDED_THINKING_LEVELS.indexOf(level);\n\tif (requestedIndex === -1) return availableLevels[0] ?? \"off\";\n\n\tfor (let i = requestedIndex; i < EXTENDED_THINKING_LEVELS.length; i++) {\n\t\tconst candidate = EXTENDED_THINKING_LEVELS[i];\n\t\tif (availableLevels.includes(candidate)) return candidate;\n\t}\n\tfor (let i = requestedIndex - 1; i >= 0; i--) {\n\t\tconst candidate = EXTENDED_THINKING_LEVELS[i];\n\t\tif (availableLevels.includes(candidate)) return candidate;\n\t}\n\treturn availableLevels[0] ?? \"off\";\n}\n\n/**\n * Whether the model exposes the `xhigh` tier.\n *\n * An explicit `thinkingLevelMap` is authoritative: `null` vetoes the tier and a map that omits\n * `xhigh` disables it. Only map-less models fall back to id-based inference, so custom providers\n * that ship a reasoning model without generated catalog metadata still surface the tier.\n */\nexport function supportsXhigh<TApi extends Api>(model: Model<TApi>): boolean {\n\tconst mapped = model.thinkingLevelMap?.xhigh;\n\tif (mapped === null) return false;\n\tif (mapped !== undefined) return true;\n\tif (model.thinkingLevelMap !== undefined) return false;\n\treturn model.reasoning && supportsXhighModelId(model.id);\n}\n\nconst XHIGH_MODEL_IDS = [\n\t\"gpt-5.2\",\n\t\"gpt-5.3\",\n\t\"gpt-5.4\",\n\t\"gpt-5.5\",\n\t\"gpt-5.6-luna\",\n\t\"gpt-5.6-sol\",\n\t\"gpt-5.6-terra\",\n\t\"deepseek-v4-pro\",\n\t\"deepseek-v4-flash\",\n\t\"opus-4-6\",\n\t\"opus-4.6\",\n\t\"opus-4-7\",\n\t\"opus-4.7\",\n\t\"opus-4-8\",\n\t\"opus-4.8\",\n\t\"opus-5\",\n\t\"sonnet-5\",\n\t\"fable-5\",\n];\n\nfunction escapeRegex(value: string): string {\n\treturn value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\n/** Match a complete model family marker, not an alphanumeric substring of another id. */\nfunction matchesModelFamily(modelId: string, family: string): boolean {\n\tconst normalizedId = modelId.toLowerCase();\n\tconst escapedFamily = escapeRegex(family.toLowerCase());\n\t// GPT aliases use a complete id or provider namespace; a hyphenated word prefix is not a provider namespace.\n\tconst leadingBoundary = family.startsWith(\"gpt-\") ? \"(?:^|[/.:_])\" : \"(?:^|[/.:_-])\";\n\treturn new RegExp(`${leadingBoundary}${escapedFamily}(?=$|[^a-z0-9])`).test(normalizedId);\n}\n\nfunction supportsXhighModelId(modelId: string): boolean {\n\treturn XHIGH_MODEL_IDS.some((id) => matchesModelFamily(modelId, id));\n}\n\n/**\n * Whether the model exposes the `max` tier.\n *\n * Mirrors {@link supportsXhigh}: an explicit `thinkingLevelMap` wins, and only map-less models\n * are inferred from the id.\n */\nexport function supportsMax<TApi extends Api>(model: Model<TApi>): boolean {\n\tconst mapped = model.thinkingLevelMap?.max;\n\tif (mapped === null) return false;\n\tif (mapped !== undefined) return true;\n\tif (model.thinkingLevelMap !== undefined) return false;\n\treturn supportsMaxModel(model);\n}\n\n/** OpenAI-compatible APIs that accept a native `max` reasoning effort on the wire. */\nconst OPENAI_MAX_APIS: Api[] = [\n\t\"openai-responses\",\n\t\"azure-openai-responses\",\n\t\"openai-codex-responses\",\n\t\"openai-completions\",\n];\n\n/** Model family that accepts native `max` effort on OpenAI-compatible APIs. */\nconst GPT_56_SOL_ID = \"gpt-5.6-sol\";\n\nconst MAX_MODEL_IDS = [\n\t\"opus-4-6\",\n\t\"opus-4.6\",\n\t\"opus-4-7\",\n\t\"opus-4.7\",\n\t\"opus-4-8\",\n\t\"opus-4.8\",\n\t\"opus-5\",\n\t\"sonnet-5\",\n\t\"fable-5\",\n];\n\nfunction supportsMaxModel<TApi extends Api>(model: Model<TApi>): boolean {\n\tif (!model.reasoning) return false;\n\tif (OPENAI_MAX_APIS.includes(model.api) && matchesModelFamily(model.id, GPT_56_SOL_ID)) return true;\n\treturn MAX_MODEL_IDS.some((id) => matchesModelFamily(model.id, id));\n}\n\n/**\n * Check if two models are equal by comparing both their id and provider.\n * Returns false if either model is null or undefined.\n */\nexport function modelsAreEqual<TApi extends Api>(\n\ta: Model<TApi> | null | undefined,\n\tb: Model<TApi> | null | undefined,\n): boolean {\n\tif (!a || !b) return false;\n\treturn a.id === b.id && a.provider === b.provider;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAA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C,CAAC;AACrE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAC7B,CAAiC,EACjC,CAAiC;IAEjC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IAC3B,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,QAAQ,CAAC;AACnD,CAAC","sourcesContent":["import { lazyStream } from \"./api/lazy.ts\";\nimport { defaultProviderAuthContext as defaultAuthContext } from \"./auth/context.ts\";\nimport { InMemoryCredentialStore } from \"./auth/credential-store.ts\";\nimport { type AuthResolutionOverrides, ModelsError, resolveProviderAuth } from \"./auth/resolve.ts\";\nimport type {\n\tAuthCheck,\n\tAuthContext,\n\tAuthInteraction,\n\tAuthOperationOptions,\n\tAuthResult,\n\tAuthType,\n\tCredential,\n\tCredentialStore,\n\tProviderAuth,\n} from \"./auth/types.ts\";\nimport { InMemoryModelsStore, type ModelsStore, type ModelsStoreEntry } from \"./models-store.ts\";\nimport type {\n\tApi,\n\tApiStreamOptions,\n\tAssistantMessage,\n\tAssistantMessageEventStream,\n\tContext,\n\tDeferredCancelOptions,\n\tDeferredFetchOptions,\n\tDeferredHandle,\n\tModel,\n\tModelCostRates,\n\tModelThinkingLevel,\n\tProviderHeaders,\n\tProviderRequestOptions,\n\tProviderStreams,\n\tSimpleStreamOptions,\n\tUsage,\n} from \"./types.ts\";\nimport { operationSignal, raceWithAbortSignal } from \"./utils/abort.ts\";\n\nexport { ModelsError, type ModelsErrorCode } from \"./auth/resolve.ts\";\n\nexport interface ModelsPublication {\n\t/** Provider-selected persisted catalog. Omit to leave storage unchanged; null deletes it. */\n\tpersist?: ModelsStoreEntry | null;\n\t/** Optional synchronous update of provider-private in-memory catalog state. */\n\tupdate?: () => void;\n}\n\nexport interface RefreshModelsContext {\n\t/** Effective configured credential. OAuth credentials are refreshed before network access. */\n\tcredential?: Credential;\n\t/** Immutable provider-scoped catalog snapshot captured before this refresh phase. */\n\tstored?: Readonly<ModelsStoreEntry>;\n\t/**\n\t * Generation-checked publication. Persistence policy remains provider-owned;\n\t * the update runs synchronously only after the selected persistence mutation.\n\t */\n\tpublish(publication: ModelsPublication): Promise<boolean>;\n\t/** False during offline/cache-only initialization. */\n\tallowNetwork: boolean;\n\t/** Bypass provider freshness checks and fetch immediately when network access is allowed. */\n\tforce?: boolean;\n\t/** Always present, including when the public refresh caller omits its optional signal. */\n\tsignal: AbortSignal;\n}\n\nexport interface ModelsRefreshOptions {\n\tallowNetwork?: boolean;\n\t/** Restrict refresh to these provider IDs. Unknown and static providers are ignored. */\n\tproviders?: readonly string[];\n\t/** Bypass provider freshness checks and fetch immediately when network access is allowed. */\n\tforce?: boolean;\n\tsignal?: AbortSignal;\n}\n\nexport interface ModelsRefreshResult {\n\taborted: boolean;\n\terrors: ReadonlyMap<string, Error>;\n}\n\nexport interface ModelsRequestTransforms {\n\t/** Transform fully assembled model/auth/request headers before provider dispatch. */\n\ttransformHeaders?: (headers: ProviderHeaders) => ProviderHeaders | Promise<ProviderHeaders>;\n}\n\nexport type ModelsApiStreamOptions<TApi extends Api> = ApiStreamOptions<TApi> & ModelsRequestTransforms;\nexport type ModelsSimpleStreamOptions = SimpleStreamOptions & ModelsRequestTransforms;\nexport type ModelsDeferredFetchOptions = DeferredFetchOptions & ModelsRequestTransforms;\nexport type ModelsDeferredCancelOptions = DeferredCancelOptions & ModelsRequestTransforms;\n\n/**\n * A provider is the concrete runtime unit. It owns id/name/base metadata,\n * auth methods, model listing, and stream behavior.\n *\n * `TApi` lets concrete provider factories declare which APIs their models\n * use (e.g. `openaiProvider(): Provider<\"openai-responses\" | \"openai-completions\">`),\n * giving typed model lists to direct factory users. Inside a `Models`\n * collection providers are held as `Provider<Api>`.\n */\nexport interface Provider<TApi extends Api = Api> {\n\treadonly id: string;\n\treadonly name: string;\n\n\treadonly baseUrl?: string;\n\treadonly headers?: ProviderHeaders;\n\n\t/**\n\t * Required: at least one of `apiKey`/`oauth`. Every provider has auth\n\t * semantics — even providers with only ambient credentials (env vars, AWS\n\t * profiles, ADC files) and keyless local servers provide `apiKey` auth\n\t * whose `resolve()` reports whether the provider is configured.\n\t * `Models.getAuth()` returns undefined when the provider is unconfigured.\n\t */\n\treadonly auth: ProviderAuth;\n\n\t/**\n\t * Current known models, sync. Static providers return their catalog;\n\t * dynamic providers return the list as of the last `refreshModels()`\n\t * (empty before the first). Must not throw; `Models` treats a throwing\n\t * implementation as having no models.\n\t */\n\tgetModels(): readonly Model<TApi>[];\n\n\t/**\n\t * Dynamic providers only: restore `context.stored` and optionally fetch a newer list using\n\t * the effective credential. Implementations retain their previous list on failure, publish\n\t * persistence and synchronous state changes through `context.publish()`, and honor the\n\t * shared abort signal for blocking work.\n\t */\n\trefreshModels?(context: RefreshModelsContext): Promise<void>;\n\n\t/**\n\t * Optional provider policy for credential-specific model availability.\n\t * `getModels()` remains the complete synchronous catalog; `Models.getAvailable()`\n\t * applies this filter after confirming that provider auth is configured.\n\t */\n\tfilterModels?(models: readonly Model<TApi>[], credential: Credential | undefined): readonly Model<TApi>[];\n\n\tstream<T extends TApi>(\n\t\tmodel: Model<T>,\n\t\tcontext: Context,\n\t\toptions?: ApiStreamOptions<T>,\n\t): AssistantMessageEventStream;\n\n\tstreamSimple(model: Model<TApi>, context: Context, options?: SimpleStreamOptions): AssistantMessageEventStream;\n\tfetchDeferred?(\n\t\tmodel: Model<TApi>,\n\t\thandle: DeferredHandle,\n\t\toptions?: DeferredFetchOptions,\n\t): AssistantMessageEventStream;\n\tcancelDeferred?(model: Model<TApi>, handle: DeferredHandle, options?: DeferredCancelOptions): Promise<void>;\n}\n\n/**\n * Runtime collection of providers plus auth application and stream\n * convenience. Providers own stream behavior; `Models` resolves auth and\n * delegates each request to the provider that owns the model.\n */\nexport interface Models {\n\tgetProviders(): readonly Provider[];\n\tgetProvider(id: string): Provider | undefined;\n\n\t/**\n\t * Sync read of last-known models from one provider or all providers.\n\t * Best-effort: a provider whose `getModels()` throws yields no models.\n\t */\n\tgetModels(provider?: string): readonly Model<Api>[];\n\n\t/**\n\t * Sync runtime model lookup against last-known lists. Dynamic model lists\n\t * are typed as `Model<Api>`; narrow with the `hasApi()` type guard.\n\t */\n\tgetModel(provider: string, id: string): Model<Api> | undefined;\n\n\t/**\n\t * Refresh selected configured dynamic providers concurrently (all when `providers` is omitted).\n\t * Provider errors and cancellation are returned without rejecting; static, unknown, and\n\t * unconfigured providers are skipped.\n\t */\n\trefresh(options?: ModelsRefreshOptions): Promise<ModelsRefreshResult>;\n\n\t/** Check whether a provider has complete auth configuration without refreshing OAuth. */\n\tcheckAuth(providerId: string, options?: AuthOperationOptions): Promise<AuthCheck | undefined>;\n\n\t/** Return models whose providers have complete auth configuration. */\n\tgetAvailable(providerId?: string, options?: AuthOperationOptions): Promise<readonly Model<Api>[]>;\n\n\t/**\n\t * Resolve provider-scoped auth by provider id, or provider auth plus static\n\t * model headers when passed a model. Includes a source label for status UI.\n\t * Resolves `undefined` when the provider is unknown or unconfigured.\n\t * Rejects with `ModelsError`: code \"oauth\" when a token refresh fails (the\n\t * stored credential is preserved for retry; re-login fixes it), code \"auth\"\n\t * when api-key resolution or the credential store fails. Request paths\n\t * surface rejections as stream errors.\n\t */\n\tgetAuth(providerId: string, overrides?: AuthResolutionOverrides): Promise<AuthResult | undefined>;\n\tgetAuth(model: Model<Api>, overrides?: AuthResolutionOverrides): Promise<AuthResult | undefined>;\n\n\t/** Run a provider-owned login flow and persist its returned credential. */\n\tlogin(providerId: string, type: AuthType, interaction: AuthInteraction): Promise<Credential>;\n\n\t/** Remove the stored credential for a provider. */\n\tlogout(providerId: string, options?: AuthOperationOptions): Promise<void>;\n\n\tstream<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): AssistantMessageEventStream;\n\n\tcomplete<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): Promise<AssistantMessage>;\n\n\tstreamSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): AssistantMessageEventStream;\n\tcompleteSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): Promise<AssistantMessage>;\n\tfetchDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredFetchOptions,\n\t): Promise<AssistantMessage>;\n\tcancelDeferred(model: Model<Api>, handle: DeferredHandle, options?: ModelsDeferredCancelOptions): Promise<void>;\n}\n\nexport interface MutableModels extends Models {\n\t/** Upsert/replace by provider.id. Provider ids are unique. */\n\tsetProvider(provider: Provider): void;\n\tdeleteProvider(id: string): void;\n\tclearProviders(): void;\n}\n\nexport interface CreateModelsOptions {\n\tcredentials?: CredentialStore;\n\tmodelsStore?: ModelsStore;\n\tauthContext?: AuthContext;\n}\n\nfunction mergeHeaders(\n\tbase: ProviderHeaders | undefined,\n\toverride: ProviderHeaders | undefined,\n): ProviderHeaders | undefined {\n\tif (!base && !override) return undefined;\n\tconst merged = { ...base };\n\tfor (const [name, value] of Object.entries(override ?? {})) {\n\t\tconst lowerName = name.toLowerCase();\n\t\tfor (const existingName of Object.keys(merged)) {\n\t\t\tif (existingName.toLowerCase() === lowerName) delete merged[existingName];\n\t\t}\n\t\tmerged[name] = value;\n\t}\n\treturn merged;\n}\n\nclass ModelsImpl implements MutableModels {\n\tprivate providers = new Map<string, Provider>();\n\tprivate credentials: CredentialStore;\n\tprivate modelsStore: ModelsStore;\n\tprivate authContext: AuthContext;\n\tprivate refreshGenerations = new Map<string, number>();\n\tprivate refreshControllers = new Map<string, AbortController>();\n\tprivate publicationChains = new Map<string, Promise<unknown>>();\n\n\tconstructor(options?: CreateModelsOptions) {\n\t\tthis.credentials = options?.credentials ?? new InMemoryCredentialStore();\n\t\tthis.modelsStore = options?.modelsStore ?? new InMemoryModelsStore();\n\t\tthis.authContext = options?.authContext ?? defaultAuthContext();\n\t}\n\n\tsetProvider(provider: Provider): void {\n\t\tthis.supersedeProviderRefresh(provider.id);\n\t\tthis.providers.set(provider.id, provider);\n\t}\n\n\tdeleteProvider(id: string): void {\n\t\tthis.supersedeProviderRefresh(id);\n\t\tthis.providers.delete(id);\n\t}\n\n\tclearProviders(): void {\n\t\tfor (const id of new Set([...this.providers.keys(), ...this.refreshControllers.keys()])) {\n\t\t\tthis.supersedeProviderRefresh(id);\n\t\t}\n\t\tthis.providers.clear();\n\t}\n\n\tgetProviders(): readonly Provider[] {\n\t\treturn Array.from(this.providers.values());\n\t}\n\n\tgetProvider(id: string): Provider | undefined {\n\t\treturn this.providers.get(id);\n\t}\n\n\tgetModels(provider?: string): readonly Model<Api>[] {\n\t\tif (provider !== undefined) {\n\t\t\tconst entry = this.providers.get(provider);\n\t\t\tif (!entry) return [];\n\t\t\ttry {\n\t\t\t\treturn entry.getModels();\n\t\t\t} catch {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t}\n\n\t\tconst models: Model<Api>[] = [];\n\t\tfor (const entry of this.providers.values()) {\n\t\t\ttry {\n\t\t\t\tmodels.push(...entry.getModels());\n\t\t\t} catch {\n\t\t\t\t// Best-effort: ill-behaved providers yield no models.\n\t\t\t}\n\t\t}\n\t\treturn models;\n\t}\n\n\tgetModel(provider: string, id: string): Model<Api> | undefined {\n\t\treturn this.getModels(provider).find((model) => model.id === id);\n\t}\n\n\tprivate supersedeProviderRefresh(providerId: string): number {\n\t\tconst generation = (this.refreshGenerations.get(providerId) ?? 0) + 1;\n\t\tthis.refreshGenerations.set(providerId, generation);\n\t\tconst previous = this.refreshControllers.get(providerId);\n\t\tif (previous) {\n\t\t\tthis.refreshControllers.delete(providerId);\n\t\t\tprevious.abort();\n\t\t}\n\t\treturn generation;\n\t}\n\n\tprivate beginProviderRefresh(providerId: string): { generation: number; controller: AbortController } {\n\t\tconst generation = this.supersedeProviderRefresh(providerId);\n\t\tconst controller = new AbortController();\n\t\tthis.refreshControllers.set(providerId, controller);\n\t\treturn { generation, controller };\n\t}\n\n\tprivate publishProviderModels(\n\t\tproviderId: string,\n\t\tgeneration: number,\n\t\tsignal: AbortSignal,\n\t\tpublication: ModelsPublication,\n\t): Promise<boolean> {\n\t\tconst previous = this.publicationChains.get(providerId) ?? Promise.resolve();\n\t\tconst queued = (async () => {\n\t\t\tawait previous.catch(() => {});\n\t\t\tif (signal.aborted || this.refreshGenerations.get(providerId) !== generation) return false;\n\n\t\t\tif (publication.persist === null) {\n\t\t\t\tawait this.modelsStore.delete(providerId, { signal });\n\t\t\t} else if (publication.persist !== undefined) {\n\t\t\t\tawait this.modelsStore.write(providerId, structuredClone(publication.persist), { signal });\n\t\t\t}\n\n\t\t\tif (signal.aborted || this.refreshGenerations.get(providerId) !== generation) return false;\n\t\t\tpublication.update?.();\n\t\t\treturn true;\n\t\t})();\n\t\tconst tail = queued.catch(() => {});\n\t\tthis.publicationChains.set(providerId, tail);\n\t\tvoid tail.then(() => {\n\t\t\tif (this.publicationChains.get(providerId) === tail) this.publicationChains.delete(providerId);\n\t\t});\n\t\treturn raceWithAbortSignal(queued, signal);\n\t}\n\n\tprivate async runProviderRefreshPhase(\n\t\tprovider: Provider & Required<Pick<Provider, \"refreshModels\">>,\n\t\tcredential: Credential | undefined,\n\t\tallowNetwork: boolean,\n\t\tforce: boolean | undefined,\n\t\tgeneration: number,\n\t\tsignal: AbortSignal,\n\t): Promise<void> {\n\t\tconst stored = await this.modelsStore.read(provider.id, { signal });\n\t\tawait provider.refreshModels({\n\t\t\tcredential,\n\t\t\tstored: stored ? structuredClone(stored) : undefined,\n\t\t\tpublish: (publication) => this.publishProviderModels(provider.id, generation, signal, publication),\n\t\t\tallowNetwork,\n\t\t\tforce: allowNetwork ? force : undefined,\n\t\t\tsignal,\n\t\t});\n\t}\n\n\tasync refresh(options: ModelsRefreshOptions = {}): Promise<ModelsRefreshResult> {\n\t\tconst allowNetwork = options.allowNetwork ?? true;\n\t\tconst callerSignal = operationSignal(options.signal);\n\t\tconst errors = new Map<string, Error>();\n\t\tif (callerSignal.aborted) return { aborted: true, errors };\n\t\tconst selected = options.providers ? new Set(options.providers) : undefined;\n\t\tconst refreshable = Array.from(this.providers.values()).filter(\n\t\t\t(provider): provider is Provider & Required<Pick<Provider, \"refreshModels\">> =>\n\t\t\t\tprovider.refreshModels !== undefined && (!selected || selected.has(provider.id)),\n\t\t);\n\n\t\tconst refresh = Promise.all(\n\t\t\trefreshable.map(async (provider) => {\n\t\t\t\tconst { generation, controller } = this.beginProviderRefresh(provider.id);\n\t\t\t\tconst signal = AbortSignal.any([callerSignal, controller.signal]);\n\t\t\t\tconst operation = (async () => {\n\t\t\t\t\tlet storedCredential: Credential | undefined;\n\t\t\t\t\tlet credentialError: unknown;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tstoredCredential = await this.readCredential(provider.id, signal);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tcredentialError = error;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Restore cached provider state before auth resolution or network access.\n\t\t\t\t\tawait this.runProviderRefreshPhase(provider, storedCredential, false, undefined, generation, signal);\n\t\t\t\t\tif (credentialError !== undefined) throw credentialError;\n\t\t\t\t\tif (!allowNetwork || signal.aborted) return;\n\n\t\t\t\t\tconst credential = await this.resolveRefreshCredential(provider, storedCredential, signal);\n\t\t\t\t\tif (!credential) return;\n\t\t\t\t\tawait this.runProviderRefreshPhase(provider, credential, true, options.force, generation, signal);\n\t\t\t\t})();\n\n\t\t\t\ttry {\n\t\t\t\t\tawait raceWithAbortSignal(operation, signal);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (!signal.aborted) {\n\t\t\t\t\t\terrors.set(\n\t\t\t\t\t\t\tprovider.id,\n\t\t\t\t\t\t\terror instanceof Error\n\t\t\t\t\t\t\t\t? error\n\t\t\t\t\t\t\t\t: new ModelsError(\"model_source\", `Model refresh failed for ${provider.id}`, { cause: error }),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} finally {\n\t\t\t\t\tif (this.refreshControllers.get(provider.id) === controller) {\n\t\t\t\t\t\tthis.refreshControllers.delete(provider.id);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\n\t\ttry {\n\t\t\tawait raceWithAbortSignal(refresh, callerSignal);\n\t\t} catch (error) {\n\t\t\tif (!callerSignal.aborted) throw error;\n\t\t}\n\n\t\treturn { aborted: callerSignal.aborted, errors: new Map(errors) };\n\t}\n\n\tprivate async resolveRefreshCredential(\n\t\tprovider: Provider,\n\t\tstored: Credential | undefined,\n\t\tsignal: AbortSignal,\n\t): Promise<Credential | undefined> {\n\t\tif (stored?.type === \"oauth\") {\n\t\t\tconst oauth = provider.auth.oauth;\n\t\t\tif (!oauth) return undefined;\n\t\t\tif (Date.now() < stored.expires) return stored;\n\t\t\tif (signal.aborted) return undefined;\n\t\t\tconst post = await this.credentials.modify(\n\t\t\t\tprovider.id,\n\t\t\t\tasync (current) => {\n\t\t\t\t\tif (current?.type !== \"oauth\" || Date.now() < current.expires) return undefined;\n\t\t\t\t\treturn oauth.refresh(current, signal);\n\t\t\t\t},\n\t\t\t\t{ signal },\n\t\t\t);\n\t\t\treturn post?.type === \"oauth\" ? post : undefined;\n\t\t}\n\n\t\tconst apiKey = provider.auth.apiKey;\n\t\tif (!apiKey) return undefined;\n\t\tconst credential = stored?.type === \"api_key\" ? stored : undefined;\n\t\tconst result = await apiKey.resolve({ ctx: this.authContext, credential, signal });\n\t\tif (!result) return undefined;\n\t\treturn { type: \"api_key\", key: result.auth.apiKey, env: result.env };\n\t}\n\n\tprivate async readCredential(providerId: string, signal: AbortSignal): Promise<Credential | undefined> {\n\t\ttry {\n\t\t\treturn await this.credentials.read(providerId, { signal });\n\t\t} catch (error) {\n\t\t\tthrow new ModelsError(\"auth\", `Credential store read failed for ${providerId}`, { cause: error });\n\t\t}\n\t}\n\n\tprivate async checkProviderAuth(\n\t\tprovider: Provider,\n\t\tcredential: Credential | undefined,\n\t\tsignal: AbortSignal,\n\t): Promise<AuthCheck | undefined> {\n\t\tconst oauth = provider.auth.oauth;\n\t\tif (credential?.type === \"oauth\") {\n\t\t\tif (!oauth) return undefined;\n\t\t\tif (!oauth.check) return { source: \"OAuth\", type: \"oauth\" };\n\t\t\ttry {\n\t\t\t\treturn await oauth.check({ ctx: this.authContext, credential, signal });\n\t\t\t} catch (error) {\n\t\t\t\tthrow new ModelsError(\"auth\", `OAuth auth check failed for provider ${provider.id}`, { cause: error });\n\t\t\t}\n\t\t}\n\t\tconst apiKey = provider.auth.apiKey;\n\t\tif (apiKey) {\n\t\t\tif (apiKey.check) {\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await apiKey.check({\n\t\t\t\t\t\tctx: this.authContext,\n\t\t\t\t\t\tcredential: credential?.type === \"api_key\" ? credential : undefined,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t});\n\t\t\t\t\tif (result) return result;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new ModelsError(\"auth\", `API key auth check failed for provider ${provider.id}`, { cause: error });\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst resolution = await resolveProviderAuth(provider, this.credentials, this.authContext, { signal });\n\t\t\t\tif (resolution) return { source: resolution.source, type: \"api_key\" };\n\t\t\t}\n\t\t}\n\t\tif (!oauth?.check) return undefined;\n\t\ttry {\n\t\t\treturn await oauth.check({ ctx: this.authContext, signal });\n\t\t} catch (error) {\n\t\t\tthrow new ModelsError(\"auth\", `OAuth auth check failed for provider ${provider.id}`, { cause: error });\n\t\t}\n\t}\n\n\tcheckAuth(providerId: string, options?: AuthOperationOptions): Promise<AuthCheck | undefined> {\n\t\tconst signal = operationSignal(options?.signal);\n\t\tconst check = (async () => {\n\t\t\tsignal.throwIfAborted();\n\t\t\tconst provider = this.providers.get(providerId);\n\t\t\tif (!provider) return undefined;\n\t\t\treturn this.checkProviderAuth(provider, await this.readCredential(providerId, signal), signal);\n\t\t})();\n\t\treturn raceWithAbortSignal(check, signal);\n\t}\n\n\tgetAvailable(providerId?: string, options?: AuthOperationOptions): Promise<readonly Model<Api>[]> {\n\t\tconst signal = operationSignal(options?.signal);\n\t\tconst available = (async () => {\n\t\t\tsignal.throwIfAborted();\n\t\t\tconst providers = providerId\n\t\t\t\t? [this.providers.get(providerId)].filter((entry) => entry !== undefined)\n\t\t\t\t: this.getProviders();\n\t\t\tconst checks = await Promise.all(\n\t\t\t\tproviders.map(async (provider) => {\n\t\t\t\t\tconst credential = await this.readCredential(provider.id, signal);\n\t\t\t\t\treturn { provider, credential, auth: await this.checkProviderAuth(provider, credential, signal) };\n\t\t\t\t}),\n\t\t\t);\n\t\t\treturn checks.flatMap(({ provider, credential, auth }) => {\n\t\t\t\tif (!auth) return [];\n\t\t\t\tconst models = provider.getModels();\n\t\t\t\treturn provider.filterModels?.(models, credential) ?? models;\n\t\t\t});\n\t\t})();\n\t\treturn raceWithAbortSignal(available, signal);\n\t}\n\n\tgetAuth(providerId: string, overrides?: AuthResolutionOverrides): Promise<AuthResult | undefined>;\n\tgetAuth(model: Model<Api>, overrides?: AuthResolutionOverrides): Promise<AuthResult | undefined>;\n\tasync getAuth(\n\t\tproviderOrModel: string | Model<Api>,\n\t\toverrides?: AuthResolutionOverrides,\n\t): Promise<AuthResult | undefined> {\n\t\tconst signal = operationSignal(overrides?.signal);\n\t\tconst providerId = typeof providerOrModel === \"string\" ? providerOrModel : providerOrModel.provider;\n\t\tconst provider = this.providers.get(providerId);\n\t\tif (!provider) return undefined;\n\t\tconst result = await resolveProviderAuth(provider, this.credentials, this.authContext, { ...overrides, signal });\n\t\tif (!result || typeof providerOrModel === \"string\" || !providerOrModel.headers) return result;\n\t\treturn {\n\t\t\t...result,\n\t\t\tauth: {\n\t\t\t\t...result.auth,\n\t\t\t\theaders: mergeHeaders(result.auth.headers, providerOrModel.headers),\n\t\t\t},\n\t\t};\n\t}\n\n\tasync login(providerId: string, type: AuthType, interaction: AuthInteraction): Promise<Credential> {\n\t\tconst signal = operationSignal(interaction.signal);\n\t\tsignal.throwIfAborted();\n\t\tconst provider = this.providers.get(providerId);\n\t\tif (!provider) throw new ModelsError(\"provider\", `Unknown provider: ${providerId}`);\n\t\tconst method = type === \"oauth\" ? provider.auth.oauth : provider.auth.apiKey;\n\t\tif (!method?.login) {\n\t\t\tthrow new ModelsError(\"auth\", `${provider.name} does not support ${type} login`);\n\t\t}\n\t\tconst loginOperation: Promise<Credential> = method.login({ ...interaction, signal });\n\t\tconst credential = await raceWithAbortSignal(loginOperation, signal);\n\t\tlet mutationStarted = false;\n\t\tlet markMutationStarted: (() => void) | undefined;\n\t\tconst started = new Promise<void>((resolve) => {\n\t\t\tmarkMutationStarted = resolve;\n\t\t});\n\t\tconst mutation = this.credentials.modify(\n\t\t\tproviderId,\n\t\t\tasync () => {\n\t\t\t\tmutationStarted = true;\n\t\t\t\tmarkMutationStarted?.();\n\t\t\t\treturn credential;\n\t\t\t},\n\t\t\t{ signal },\n\t\t);\n\t\tvoid mutation.catch(() => {});\n\t\ttry {\n\t\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\t\tconst onAbort = () => {\n\t\t\t\t\tif (!mutationStarted) reject(signal.reason);\n\t\t\t\t};\n\t\t\t\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\tvoid Promise.race([started, mutation]).then(\n\t\t\t\t\t() => {\n\t\t\t\t\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t},\n\t\t\t\t\t(error: unknown) => {\n\t\t\t\t\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\treject(error);\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tif (signal.aborted) onAbort();\n\t\t\t});\n\t\t\tawait mutation;\n\t\t} catch (error) {\n\t\t\tsignal.throwIfAborted();\n\t\t\tthrow new ModelsError(\"auth\", `Credential store modify failed for ${providerId}`, { cause: error });\n\t\t}\n\t\treturn credential;\n\t}\n\n\tasync logout(providerId: string, options?: AuthOperationOptions): Promise<void> {\n\t\tconst signal = operationSignal(options?.signal);\n\t\tsignal.throwIfAborted();\n\t\ttry {\n\t\t\tawait this.credentials.delete(providerId, { signal });\n\t\t} catch (error) {\n\t\t\tsignal.throwIfAborted();\n\t\t\tthrow new ModelsError(\"auth\", `Credential store delete failed for ${providerId}`, { cause: error });\n\t\t}\n\t}\n\n\tprivate requireProvider(model: Model<Api>): Provider {\n\t\tconst provider = this.providers.get(model.provider);\n\t\tif (!provider) {\n\t\t\tthrow new ModelsError(\"provider\", `Unknown provider: ${model.provider}`);\n\t\t}\n\t\treturn provider;\n\t}\n\n\tprivate async applyAuth<TOptions extends ProviderRequestOptions & ModelsRequestTransforms>(\n\t\tmodel: Model<Api>,\n\t\toptions: TOptions | undefined,\n\t): Promise<{\n\t\trequestModel: Model<Api>;\n\t\trequestOptions: Omit<TOptions, \"transformHeaders\"> & ProviderRequestOptions;\n\t}> {\n\t\tthis.requireProvider(model);\n\t\tconst resolution = await this.getAuth(model, {\n\t\t\tapiKey: options?.apiKey,\n\t\t\tenv: options?.env,\n\t\t\tsignal: options?.signal,\n\t\t});\n\t\tif (!resolution) {\n\t\t\tthrow new ModelsError(\"auth\", `Provider is not configured: ${model.provider}`);\n\t\t}\n\t\tconst auth = resolution.auth;\n\n\t\t// Explicit request options win per-field; the Models-only transform runs last.\n\t\tconst apiKey = options?.apiKey ?? auth.apiKey;\n\t\tlet headers = mergeHeaders(auth.headers, options?.headers);\n\t\tif (options?.transformHeaders) headers = await options.transformHeaders(headers ?? {});\n\t\tconst env = resolution.env || options?.env ? { ...(resolution.env ?? {}), ...(options?.env ?? {}) } : undefined;\n\t\tconst requestModel = auth.baseUrl ? { ...model, baseUrl: auth.baseUrl } : model;\n\t\tconst { transformHeaders: _transformHeaders, ...providerOptions } = options ?? {};\n\t\tconst requestOptions = { ...providerOptions, apiKey, headers, env } as Omit<TOptions, \"transformHeaders\"> &\n\t\t\tProviderRequestOptions;\n\n\t\treturn { requestModel, requestOptions };\n\t}\n\n\tstream<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): AssistantMessageEventStream {\n\t\treturn lazyStream(model, async () => {\n\t\t\tconst provider = this.requireProvider(model);\n\t\t\tconst { requestModel, requestOptions } = await this.applyAuth(\n\t\t\t\tmodel,\n\t\t\t\toptions as ModelsApiStreamOptions<Api> | undefined,\n\t\t\t);\n\t\t\treturn provider.stream(requestModel as Model<TApi>, context, requestOptions as ApiStreamOptions<TApi>);\n\t\t});\n\t}\n\n\tasync complete<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): Promise<AssistantMessage> {\n\t\treturn this.stream(model, context, options).result();\n\t}\n\n\tstreamSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): AssistantMessageEventStream {\n\t\treturn lazyStream(model, async () => {\n\t\t\tconst provider = this.requireProvider(model);\n\t\t\tconst { requestModel, requestOptions } = await this.applyAuth(model, options);\n\t\t\treturn provider.streamSimple(requestModel, context, requestOptions as SimpleStreamOptions);\n\t\t});\n\t}\n\n\tasync completeSimple(\n\t\tmodel: Model<Api>,\n\t\tcontext: Context,\n\t\toptions?: ModelsSimpleStreamOptions,\n\t): Promise<AssistantMessage> {\n\t\treturn this.streamSimple(model, context, options).result();\n\t}\n\n\tasync fetchDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredFetchOptions,\n\t): Promise<AssistantMessage> {\n\t\treturn lazyStream(model, async () => {\n\t\t\tconst provider = this.requireProvider(model);\n\t\t\tif (!provider.fetchDeferred) {\n\t\t\t\tthrow new ModelsError(\"provider\", `Provider ${model.provider} does not support deferred responses`);\n\t\t\t}\n\t\t\tconst { requestModel, requestOptions } = await this.applyAuth(model, options);\n\t\t\treturn provider.fetchDeferred(requestModel, handle, requestOptions as DeferredFetchOptions);\n\t\t}).result();\n\t}\n\n\tasync cancelDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredCancelOptions,\n\t): Promise<void> {\n\t\tconst provider = this.requireProvider(model);\n\t\tif (!provider.cancelDeferred) {\n\t\t\tthrow new ModelsError(\"provider\", `Provider ${model.provider} does not support deferred responses`);\n\t\t}\n\t\tconst { requestModel, requestOptions } = await this.applyAuth(model, options);\n\t\tawait provider.cancelDeferred(requestModel, handle, requestOptions);\n\t}\n}\n\nexport function createModels(options?: CreateModelsOptions): MutableModels {\n\treturn new ModelsImpl(options);\n}\n\nexport interface CreateProviderOptions<TApi extends Api = Api> {\n\tid: string;\n\t/** Display name. Default: `id`. */\n\tname?: string;\n\tbaseUrl?: string;\n\theaders?: ProviderHeaders;\n\t/** Required — every provider has auth semantics, even ambient/keyless ones. */\n\tauth: ProviderAuth;\n\t/** Static baseline model list (empty for purely dynamic providers). */\n\tmodels: readonly Model<TApi>[];\n\t/** Fetch a dynamic model overlay. createProvider restores and publishes it transactionally. */\n\tfetchModels?: (context: RefreshModelsContext) => Promise<readonly Model<TApi>[]>;\n\t/**\n\t * Optional transform applied to restored stored models before publication,\n\t * letting a provider migrate an old catalog shape without a network refresh.\n\t * A throwing transform publishes the stored list unchanged.\n\t */\n\trestoreModels?: (models: readonly Model<TApi>[]) => readonly Model<TApi>[];\n\tfilterModels?: (models: readonly Model<TApi>[], credential: Credential | undefined) => readonly Model<TApi>[];\n\t/** Single implementation, or map keyed by `model.api` for mixed-API providers. */\n\tapi: ProviderStreams | Partial<Record<TApi, ProviderStreams>>;\n}\n\n/**\n * Builds a provider from parts. Built-in provider factories and models.json\n * custom providers both go through this. A single `api` streams all models;\n * an `api` map dispatches on `model.api`, and a model whose api has no entry\n * produces a stream error.\n */\nexport function createProvider<TApi extends Api = Api>(input: CreateProviderOptions<TApi>): Provider<TApi> {\n\tconst baselineModels = input.models;\n\tlet dynamicModels: readonly Model<TApi>[] = [];\n\tconst fetchModels = input.fetchModels;\n\tconst currentModels = (): readonly Model<TApi>[] => {\n\t\tconst merged = [...baselineModels];\n\t\tfor (const model of dynamicModels) {\n\t\t\tconst index = merged.findIndex((entry) => entry.id === model.id);\n\t\t\tif (index >= 0) merged[index] = model;\n\t\t\telse merged.push(model);\n\t\t}\n\t\treturn merged;\n\t};\n\tconst single =\n\t\ttypeof (input.api as ProviderStreams).stream === \"function\" ? (input.api as ProviderStreams) : undefined;\n\tconst byApi = single ? undefined : (input.api as Partial<Record<string, ProviderStreams>>);\n\n\tconst apiFor = (model: Model<Api>): ProviderStreams | undefined => single ?? byApi?.[model.api];\n\n\tconst dispatch = (\n\t\tmodel: Model<Api>,\n\t\trun: (streams: ProviderStreams) => AssistantMessageEventStream,\n\t): AssistantMessageEventStream => {\n\t\tconst streams = apiFor(model);\n\t\tif (!streams) {\n\t\t\treturn lazyStream(model, async () => {\n\t\t\t\tthrow new ModelsError(\"stream\", `Provider ${input.id} has no API implementation for \"${model.api}\"`);\n\t\t\t});\n\t\t}\n\t\treturn run(streams);\n\t};\n\n\tconst provider: Provider<TApi> = {\n\t\tid: input.id,\n\t\tname: input.name ?? input.id,\n\t\tbaseUrl: input.baseUrl,\n\t\theaders: input.headers,\n\t\tauth: input.auth,\n\t\tgetModels: currentModels,\n\t\trefreshModels: fetchModels\n\t\t\t? async (context) => {\n\t\t\t\t\tif (context.stored) {\n\t\t\t\t\t\tlet restored = context.stored.models\n\t\t\t\t\t\t\t.filter((model) => model.provider === input.id)\n\t\t\t\t\t\t\t.map((model) => model as Model<TApi>);\n\t\t\t\t\t\tif (input.restoreModels) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\trestored = [...input.restoreModels(restored)];\n\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t// The stored list is the last usable catalog; publish it unchanged.\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t!(await context.publish({\n\t\t\t\t\t\t\t\tupdate: () => {\n\t\t\t\t\t\t\t\t\tdynamicModels = restored;\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}))\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (!context.allowNetwork || context.signal.aborted) return;\n\t\t\t\t\tconst refreshed = await fetchModels(context);\n\t\t\t\t\tif (context.signal.aborted || refreshed.length === 0) return;\n\t\t\t\t\tawait context.publish({\n\t\t\t\t\t\tpersist: { models: refreshed, checkedAt: Date.now() },\n\t\t\t\t\t\tupdate: () => {\n\t\t\t\t\t\t\tdynamicModels = refreshed;\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t: undefined,\n\t\tfilterModels: input.filterModels,\n\t\tstream: (model, context, options) => dispatch(model, (streams) => streams.stream(model, context, options)),\n\t\tstreamSimple: (model, context, options) =>\n\t\t\tdispatch(model, (streams) => streams.streamSimple(model, context, options)),\n\t};\n\n\tconst streams = single ? [single] : Object.values(byApi ?? {}).filter((entry) => entry !== undefined);\n\tif (streams.some((entry) => entry.fetchDeferred !== undefined)) {\n\t\tprovider.fetchDeferred = (model, handle, options) =>\n\t\t\tlazyStream(model, async () => {\n\t\t\t\tconst implementation = apiFor(model);\n\t\t\t\tif (!implementation?.fetchDeferred) {\n\t\t\t\t\tthrow new ModelsError(\n\t\t\t\t\t\t\"provider\",\n\t\t\t\t\t\t`Provider ${input.id} does not support deferred responses for \"${model.api}\"`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn implementation.fetchDeferred(model, handle, options);\n\t\t\t});\n\t}\n\tif (streams.some((entry) => entry.cancelDeferred !== undefined)) {\n\t\tprovider.cancelDeferred = async (model, handle, options) => {\n\t\t\tconst implementation = apiFor(model);\n\t\t\tif (!implementation?.cancelDeferred) {\n\t\t\t\tthrow new ModelsError(\n\t\t\t\t\t\"provider\",\n\t\t\t\t\t`Provider ${input.id} cannot cancel deferred responses for \"${model.api}\"`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait implementation.cancelDeferred(model, handle, options);\n\t\t};\n\t}\n\n\treturn provider;\n}\n\n/**\n * Runtime-checked narrowing for dynamically looked-up models:\n *\n * ```ts\n * const model = models.getModel(\"anthropic\", \"claude-opus-4-7\");\n * if (model && hasApi(model, \"anthropic-messages\")) {\n * // model: Model<\"anthropic-messages\">, stream options fully typed\n * }\n * ```\n */\nexport function hasApi<TApi extends Api>(model: Model<Api>, api: TApi): model is Model<TApi> {\n\treturn model.api === api;\n}\n\nexport function calculateCost<TApi extends Api>(model: Model<TApi>, usage: Usage): Usage[\"cost\"] {\n\tconst inputTokens = usage.input + usage.cacheRead + usage.cacheWrite;\n\tlet rates: ModelCostRates = model.cost;\n\tlet matchedThreshold = -1;\n\tfor (const tier of model.cost.tiers ?? []) {\n\t\tif (inputTokens > tier.inputTokensAbove && tier.inputTokensAbove > matchedThreshold) {\n\t\t\trates = tier;\n\t\t\tmatchedThreshold = tier.inputTokensAbove;\n\t\t}\n\t}\n\n\t// Anthropic charges 2x base input for 1h cache writes.\n\tconst longWrite = usage.cacheWrite1h ?? 0;\n\tconst shortWrite = usage.cacheWrite - longWrite;\n\tusage.cost.input = (rates.input / 1000000) * usage.input;\n\tusage.cost.output = (rates.output / 1000000) * usage.output;\n\tusage.cost.cacheRead = (rates.cacheRead / 1000000) * usage.cacheRead;\n\tusage.cost.cacheWrite = (rates.cacheWrite * shortWrite + rates.input * 2 * longWrite) / 1000000;\n\tusage.cost.total = usage.cost.input + usage.cost.output + usage.cost.cacheRead + usage.cost.cacheWrite;\n\treturn usage.cost;\n}\n\nconst EXTENDED_THINKING_LEVELS: ModelThinkingLevel[] = [\"off\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\", \"max\"];\n\nexport function getSupportedThinkingLevels<TApi extends Api>(model: Model<TApi>): ModelThinkingLevel[] {\n\tif (!model.reasoning) return [\"off\"];\n\n\treturn EXTENDED_THINKING_LEVELS.filter((level) => {\n\t\tconst mapped = model.thinkingLevelMap?.[level];\n\t\tif (mapped === null) return false;\n\t\tif (level === \"xhigh\") return supportsXhigh(model);\n\t\tif (level === \"max\") return supportsMax(model);\n\t\treturn true;\n\t});\n}\n\nexport function clampThinkingLevel<TApi extends Api>(\n\tmodel: Model<TApi>,\n\tlevel: ModelThinkingLevel,\n): ModelThinkingLevel {\n\tconst availableLevels = getSupportedThinkingLevels(model);\n\tif (availableLevels.includes(level)) return level;\n\n\tconst requestedIndex = EXTENDED_THINKING_LEVELS.indexOf(level);\n\tif (requestedIndex === -1) return availableLevels[0] ?? \"off\";\n\n\tfor (let i = requestedIndex; i < EXTENDED_THINKING_LEVELS.length; i++) {\n\t\tconst candidate = EXTENDED_THINKING_LEVELS[i];\n\t\tif (availableLevels.includes(candidate)) return candidate;\n\t}\n\tfor (let i = requestedIndex - 1; i >= 0; i--) {\n\t\tconst candidate = EXTENDED_THINKING_LEVELS[i];\n\t\tif (availableLevels.includes(candidate)) return candidate;\n\t}\n\treturn availableLevels[0] ?? \"off\";\n}\n\n/**\n * Whether the model exposes the `xhigh` tier.\n *\n * An explicit `thinkingLevelMap` is authoritative: `null` vetoes the tier and a map that omits\n * `xhigh` disables it. Only map-less models fall back to id-based inference, so custom providers\n * that ship a reasoning model without generated catalog metadata still surface the tier.\n */\nexport function supportsXhigh<TApi extends Api>(model: Model<TApi>): boolean {\n\tconst mapped = model.thinkingLevelMap?.xhigh;\n\tif (mapped === null) return false;\n\tif (mapped !== undefined) return true;\n\tif (model.thinkingLevelMap !== undefined) return false;\n\treturn model.reasoning && supportsXhighModelId(model.id);\n}\n\nconst XHIGH_MODEL_IDS = [\n\t\"gpt-5.2\",\n\t\"gpt-5.3\",\n\t\"gpt-5.4\",\n\t\"gpt-5.5\",\n\t\"gpt-5.6-luna\",\n\t\"gpt-5.6-sol\",\n\t\"gpt-5.6-terra\",\n\t\"deepseek-v4-pro\",\n\t\"deepseek-v4-flash\",\n\t\"opus-4-6\",\n\t\"opus-4.6\",\n\t\"opus-4-7\",\n\t\"opus-4.7\",\n\t\"opus-4-8\",\n\t\"opus-4.8\",\n\t\"opus-5\",\n\t\"sonnet-5\",\n\t\"fable-5\",\n];\n\nfunction escapeRegex(value: string): string {\n\treturn value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\n/** Match a complete model family marker, not an alphanumeric substring of another id. */\nfunction matchesModelFamily(modelId: string, family: string): boolean {\n\tconst normalizedId = modelId.toLowerCase();\n\tconst escapedFamily = escapeRegex(family.toLowerCase());\n\t// GPT aliases use a complete id or provider namespace; a hyphenated word prefix is not a provider namespace.\n\tconst leadingBoundary = family.startsWith(\"gpt-\") ? \"(?:^|[/.:_])\" : \"(?:^|[/.:_-])\";\n\treturn new RegExp(`${leadingBoundary}${escapedFamily}(?=$|[^a-z0-9])`).test(normalizedId);\n}\n\nfunction supportsXhighModelId(modelId: string): boolean {\n\treturn XHIGH_MODEL_IDS.some((id) => matchesModelFamily(modelId, id));\n}\n\n/**\n * Whether the model exposes the `max` tier.\n *\n * Mirrors {@link supportsXhigh}: an explicit `thinkingLevelMap` wins, and only map-less models\n * are inferred from the id.\n */\nexport function supportsMax<TApi extends Api>(model: Model<TApi>): boolean {\n\tconst mapped = model.thinkingLevelMap?.max;\n\tif (mapped === null) return false;\n\tif (mapped !== undefined) return true;\n\tif (model.thinkingLevelMap !== undefined) return false;\n\treturn supportsMaxModel(model);\n}\n\n/** OpenAI-compatible APIs that accept a native `max` reasoning effort on the wire. */\nconst OPENAI_MAX_APIS: Api[] = [\n\t\"openai-responses\",\n\t\"azure-openai-responses\",\n\t\"openai-codex-responses\",\n\t\"openai-completions\",\n];\n\n/** Model family that accepts native `max` effort on OpenAI-compatible APIs. */\nconst GPT_56_SOL_ID = \"gpt-5.6-sol\";\n\nconst MAX_MODEL_IDS = [\n\t\"opus-4-6\",\n\t\"opus-4.6\",\n\t\"opus-4-7\",\n\t\"opus-4.7\",\n\t\"opus-4-8\",\n\t\"opus-4.8\",\n\t\"opus-5\",\n\t\"sonnet-5\",\n\t\"fable-5\",\n];\n\nfunction supportsMaxModel<TApi extends Api>(model: Model<TApi>): boolean {\n\tif (!model.reasoning) return false;\n\tif (OPENAI_MAX_APIS.includes(model.api) && matchesModelFamily(model.id, GPT_56_SOL_ID)) return true;\n\treturn MAX_MODEL_IDS.some((id) => matchesModelFamily(model.id, id));\n}\n\n/**\n * Check if two models are equal by comparing both their id and provider.\n * Returns false if either model is null or undefined.\n */\nexport function modelsAreEqual<TApi extends Api>(\n\ta: Model<TApi> | null | undefined,\n\tb: Model<TApi> | null | undefined,\n): boolean {\n\tif (!a || !b) return false;\n\treturn a.id === b.id && a.provider === b.provider;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cursor.d.ts","sourceRoot":"","sources":["../../src/providers/cursor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cursor.d.ts","sourceRoot":"","sources":["../../src/providers/cursor.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkB,KAAK,QAAQ,EAA6B,MAAM,cAAc,CAAC;AAiExF;;;;;;;;GAQG;AACH,wBAAgB,cAAc,IAAI,QAAQ,CAAC,cAAc,CAAC,CAkBzD"}
|
package/dist/providers/cursor.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { cursorAgentApi, loadCursorAgentModule } from "../api/cursor-agent.lazy.js";
|
|
2
2
|
import { lazyOAuth } from "../auth/helpers.js";
|
|
3
3
|
import { loadCursorOAuth } from "../auth/oauth/load.js";
|
|
4
|
+
import { normalizeCursorCatalog } from "../cursor/catalog-grouping.js";
|
|
5
|
+
import { regroupStoredCursorModels } from "../cursor/store-migration.js";
|
|
4
6
|
import { createProvider } from "../models.js";
|
|
5
7
|
const CURSOR_BASE_URL = "https://api2.cursor.sh";
|
|
6
8
|
/**
|
|
@@ -20,20 +22,46 @@ async function fetchCursorModels(context) {
|
|
|
20
22
|
if (discovered === null) {
|
|
21
23
|
throw new Error("Could not load Cursor model catalog from GetUsableModels");
|
|
22
24
|
}
|
|
23
|
-
|
|
25
|
+
const normalized = normalizeCursorCatalog(discovered.map((model) => ({
|
|
24
26
|
id: model.id,
|
|
25
27
|
name: model.name,
|
|
26
|
-
api: "cursor-agent",
|
|
27
|
-
provider: "cursor",
|
|
28
|
-
baseUrl: CURSOR_BASE_URL,
|
|
29
|
-
reasoning: model.reasoning,
|
|
30
28
|
input: model.input,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
cursorMaxMode: model.cursorMaxMode,
|
|
30
|
+
})));
|
|
31
|
+
const maxTokensByVariant = new Map(discovered.map((model) => [model.id, model.maxTokens]));
|
|
32
|
+
return normalized.map((entry) => {
|
|
33
|
+
const representative = entry.representativeVariantId ?? entry.legacyAliases[0] ?? entry.id;
|
|
34
|
+
const maxTokens = maxTokensByVariant.get(representative) ?? maxTokensByVariant.get(entry.id) ?? 64000;
|
|
35
|
+
return {
|
|
36
|
+
id: entry.id,
|
|
37
|
+
name: entry.name,
|
|
38
|
+
api: "cursor-agent",
|
|
39
|
+
provider: "cursor",
|
|
40
|
+
baseUrl: CURSOR_BASE_URL,
|
|
41
|
+
reasoning: entry.reasoning,
|
|
42
|
+
...(entry.thinkingLevelMap ? { thinkingLevelMap: entry.thinkingLevelMap } : {}),
|
|
43
|
+
input: entry.input,
|
|
44
|
+
// Subscription-billed: Cursor reports no per-token pricing here.
|
|
45
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
46
|
+
contextWindow: entry.window,
|
|
47
|
+
maxTokens,
|
|
48
|
+
...(entry.representativeVariantId !== undefined && entry.representativeVariantId !== entry.id
|
|
49
|
+
? { upstreamModelId: entry.representativeVariantId }
|
|
50
|
+
: {}),
|
|
51
|
+
compat: {
|
|
52
|
+
...(entry.cursorMaxMode ? { cursorMaxMode: true } : {}),
|
|
53
|
+
...(entry.capabilityId !== undefined && entry.representativeVariantId !== undefined
|
|
54
|
+
? {
|
|
55
|
+
cursorReasoning: {
|
|
56
|
+
capabilityId: entry.capabilityId,
|
|
57
|
+
...(entry.thinkingMode !== undefined ? { thinkingMode: entry.thinkingMode } : {}),
|
|
58
|
+
representativeVariantId: entry.representativeVariantId,
|
|
59
|
+
},
|
|
60
|
+
}
|
|
61
|
+
: {}),
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
});
|
|
37
65
|
}
|
|
38
66
|
/**
|
|
39
67
|
* Cursor subscription provider (OAuth only).
|
|
@@ -49,6 +77,7 @@ export function cursorProvider() {
|
|
|
49
77
|
id: "cursor",
|
|
50
78
|
name: "Cursor",
|
|
51
79
|
baseUrl: CURSOR_BASE_URL,
|
|
80
|
+
restoreModels: (models) => regroupStoredCursorModels(models),
|
|
52
81
|
auth: {
|
|
53
82
|
oauth: lazyOAuth({
|
|
54
83
|
name: "Cursor (Pro/Ultra/Teams)",
|