@bastani/atomic 0.9.4-alpha.6 → 0.9.4-alpha.8
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/CHANGELOG.md +20 -0
- package/dist/builtin/cursor/package.json +3 -3
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +2 -2
- package/dist/builtin/subagents/CHANGELOG.md +14 -0
- package/dist/builtin/subagents/agents/code-simplifier.md +1 -1
- package/dist/builtin/subagents/agents/codebase-analyzer.md +1 -1
- package/dist/builtin/subagents/agents/codebase-online-researcher.md +1 -1
- package/dist/builtin/subagents/agents/codebase-research-analyzer.md +1 -1
- package/dist/builtin/subagents/agents/debugger.md +1 -1
- package/dist/builtin/subagents/agents/worker.md +1 -1
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/runs/background/async-execution-chain.ts +11 -1
- package/dist/builtin/subagents/src/runs/background/async-execution-single.ts +11 -1
- package/dist/builtin/subagents/src/runs/background/async-execution-types.ts +2 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-step.ts +27 -4
- package/dist/builtin/subagents/src/runs/background/subagent-runner-streaming.ts +25 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-dynamic-step.ts +1 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-runner.ts +1 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-step.ts +1 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-sequential-step.ts +1 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-types.ts +2 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution.ts +3 -1
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt.ts +22 -0
- package/dist/builtin/subagents/src/runs/foreground/execution-run-sync.ts +15 -5
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-async.ts +5 -1
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts +2 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel.ts +4 -1
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +4 -1
- package/dist/builtin/subagents/src/runs/shared/attempt-watchdog.ts +126 -0
- package/dist/builtin/subagents/src/runs/shared/model-candidate-filter.ts +53 -0
- package/dist/builtin/subagents/src/runs/shared/model-fallback.ts +52 -53
- package/dist/builtin/subagents/src/runs/shared/parallel-utils.ts +2 -0
- package/dist/builtin/subagents/src/shared/model-info.ts +16 -0
- package/dist/builtin/subagents/src/shared/types-config.ts +2 -0
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +16 -0
- package/dist/builtin/workflows/builtin/deep-research-codebase-utils.ts +8 -1
- package/dist/builtin/workflows/builtin/goal-runner.ts +14 -1
- package/dist/builtin/workflows/builtin/open-claude-design-runner.ts +5 -2
- package/dist/builtin/workflows/builtin/ralph-models.ts +44 -9
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/runs/shared/model-fallback-failures.ts +34 -4
- package/dist/core/agent-session-extension-bindings.d.ts +2 -0
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +10 -2
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +2 -1
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/copilot-model-catalog.d.ts +25 -74
- package/dist/core/copilot-model-catalog.d.ts.map +1 -1
- package/dist/core/copilot-model-catalog.js +118 -68
- package/dist/core/copilot-model-catalog.js.map +1 -1
- package/dist/core/copilot-model-synthesis.d.ts +10 -0
- package/dist/core/copilot-model-synthesis.d.ts.map +1 -0
- package/dist/core/copilot-model-synthesis.js +89 -0
- package/dist/core/copilot-model-synthesis.js.map +1 -0
- package/dist/core/model-registry-builtins.d.ts.map +1 -1
- package/dist/core/model-registry-builtins.js +21 -3
- package/dist/core/model-registry-builtins.js.map +1 -1
- package/dist/core/tools/read-selectors.d.ts.map +1 -1
- package/dist/core/tools/read-selectors.js +19 -1
- package/dist/core/tools/read-selectors.js.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.js +1 -0
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
- package/docs/models.md +3 -3
- package/docs/providers.md +1 -1
- package/docs/rpc.md +2 -2
- package/docs/sdk.md +1 -1
- package/docs/settings.md +2 -1
- package/docs/subagents.md +6 -0
- package/docs/workflows.md +3 -1
- package/npm-shrinkwrap.json +27 -27
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session-methods.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-methods.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC3H,OAAO,KAAK,EAAE,GAAG,EAAE,gBAAgB,EAAE,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AACrH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EACX,2BAA2B,EAC3B,uBAAuB,EACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACX,YAAY,EACZ,8BAA8B,EAC9B,sBAAsB,EACtB,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,cAAc,EACd,QAAQ,EACR,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EA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,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,qBAAqB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC7C,iBAAiB,EAAE,MAAM,CAAC;IAC1B,wBAAwB,EAAE,wBAAwB,CAAC;IACnD,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,qBAAqB,EAAE,gBAAgB,GAAG,SAAS,CAAC;CACpD","sourcesContent":["import type { Agent, AgentEvent, AgentMessage, AgentState, AgentTool, ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { Api, AssistantMessage, ImageContent, Message, Model, TextContent } from \"@earendil-works/pi-ai/compat\";\nimport type { BashResult } from \"./bash-executor.ts\";\nimport type {\n\tContextCompactionParameters,\n\tContextCompactionResult,\n} from \"./compaction/index.ts\";\nimport type {\n\tContextUsage,\n\tExtensionCommandContextActions,\n\tExtensionErrorListener,\n\tExtensionMode,\n\tExtensionRunner,\n\tExtensionUIContext,\n\tOrchestrationContext,\n\tReplacedSessionContext,\n\tSessionStartEvent,\n\tToolDefinition,\n\tToolInfo,\n} from \"./extensions/index.ts\";\nimport type { BashExecutionMessage, CustomMessage } from \"./messages.ts\";\nimport type { ModelRegistry } from \"./model-registry.ts\";\nimport type { PromptTemplate } from \"./prompt-templates.ts\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport type { BranchSummaryEntry, SessionManager } from \"./session-manager.ts\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\nimport type { BuildSystemPromptOptions } from \"./system-prompt.ts\";\nimport type { BashOperations } from \"./tools/bash.ts\";\nimport type {\n\tAgentSessionEvent,\n\tAgentSessionEventListener,\n\tContextWindowReplayRequest,\n\tContextWindowReplaySource,\n\tDrainedAgentQueues,\n\tExtensionBindings,\n\tInterruptQueueHold,\n\tModelCycleResult,\n\tPromptOptions,\n\tSessionStats,\n\tToolDefinitionEntry,\n} from \"./agent-session-types.ts\";\nimport type { SendMessageOptions } from \"./extensions/index.ts\";\n\nexport interface ContextCompactionApplyOptions {\n\tresolvePlannerAuth: () => Promise<{ apiKey: string; headers?: Record<string, string> } | undefined>;\n\tabortController: AbortController;\n\tbackupLabel: string;\n\tcompression_ratio?: number;\n\tpreserve_recent?: number;\n\tquery?: string;\n\treason: \"manual\" | \"threshold\" | \"overflow\";\n}\n\nexport interface ExtensionResourcePathEntry {\n\tpath: string;\n\textensionPath: string;\n}\n\nexport interface ExtensionResourcePathResult {\n\tpath: string;\n\tmetadata: { source: string; scope: \"temporary\"; origin: \"top-level\"; baseDir?: string };\n}\n\nexport interface RuntimeBuildOptions {\n\tactiveToolNames?: string[];\n\tflagValues?: Map<string, boolean | string>;\n\tincludeAllExtensionTools?: boolean;\n}\n\nexport interface ContextWindowReplayResult {\n\tmodel: Model<Api>;\n\tcontextWindow: number;\n\twouldWarn: boolean;\n}\n\nexport interface AgentSessionMethodSurface {\n\treadonly orchestrationContext: import(\"./extensions/index.ts\").OrchestrationContext | undefined;\n\treadonly modelRegistry: ModelRegistry;\n\treadonly state: AgentState;\n\treadonly model: Model<Api> | undefined;\n\treadonly thinkingLevel: ThinkingLevel;\n\treadonly isStreaming: boolean;\n\treadonly systemPrompt: string;\n\treadonly retryAttempt: number;\n\treadonly isCompacting: boolean;\n\treadonly messages: AgentMessage[];\n\treadonly steeringMode: \"all\" | \"one-at-a-time\";\n\treadonly followUpMode: \"all\" | \"one-at-a-time\";\n\treadonly sessionFile: string | undefined;\n\treadonly sessionId: string;\n\treadonly sessionName: string | undefined;\n\treadonly scopedModels: ReadonlyArray<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\treadonly promptTemplates: ReadonlyArray<PromptTemplate>;\n\treadonly pendingMessageCount: number;\n\treadonly resourceLoader: ResourceLoader;\n\treadonly autoCompactionEnabled: boolean;\n\treadonly isRetrying: boolean;\n\treadonly autoRetryEnabled: boolean;\n\treadonly isBashRunning: boolean;\n\treadonly hasPendingBashMessages: boolean;\n\treadonly extensionRunner: ExtensionRunner;\n\n\t_handleAgentEvent(event: AgentEvent): void;\n\t_getRequiredRequestAuth(model: Model<Api>): Promise<{ apiKey: string; headers?: Record<string, string> }>;\n\t_installAgentToolHooks(): void;\n\t_installAgentNextTurnRefresh(): void;\n\t_emit(event: AgentSessionEvent): void;\n\t_emitQueueUpdate(): void;\n\t_createRetryPromiseForAgentEnd(event: AgentEvent): void;\n\t_findLastAssistantInMessages(messages: AgentMessage[]): AssistantMessage | undefined;\n\t_processAgentEvent(event: AgentEvent): Promise<void>;\n\t_applyInterruptAbortMessage(event: AgentEvent): void;\n\t_applyProviderErrorGuidance(event: AgentEvent): void;\n\t_resolveRetry(): void;\n\t_getUserMessageText(message: Message): string;\n\t_findLastAssistantMessage(): AssistantMessage | undefined;\n\t_replaceMessageInPlace(target: AgentMessage, replacement: AgentMessage): void;\n\t_emitExtensionEvent(event: AgentEvent): Promise<void>;\n\tsubscribe(listener: AgentSessionEventListener): () => void;\n\t_disconnectFromAgent(): void;\n\t_reconnectToAgent(): void;\n\tdispose(): void;\n\n\tgetActiveToolNames(): string[];\n\tgetAllTools(): ToolInfo[];\n\tgetToolDefinition(name: string): ToolDefinition | undefined;\n\tsetActiveToolsByName(toolNames: string[]): void;\n\tsetScopedModels(scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>): void;\n\t_normalizePromptSnippet(text: string | undefined): string | undefined;\n\t_normalizePromptGuidelines(guidelines: string[] | undefined): string[];\n\t_rebuildSystemPrompt(toolNames: string[]): string;\n\t_refreshBaseSystemPromptFromActiveTools(): void;\n\n\tprompt(text: string, options?: PromptOptions): Promise<void>;\n\t_runAgentPrompt(messages: AgentMessage | AgentMessage[]): Promise<void>;\n\t_runAgentContinue(): Promise<void>;\n\t_continueQueuedAgentMessages(): Promise<void>;\n\t_tryExecuteBuiltinSlashCommand(text: string): Promise<boolean>;\n\t_tryExecuteExtensionCommand(text: string): Promise<boolean>;\n\t_expandSkillCommand(text: string): string;\n\tsteer(text: string, images?: ImageContent[]): Promise<void>;\n\tfollowUp(text: string, images?: ImageContent[]): Promise<void>;\n\tsendUserMessage(\n\t\tcontent: string | (TextContent | ImageContent)[],\n\t\toptions?: { deliverAs?: \"steer\" | \"followUp\" },\n\t): Promise<void>;\n\n\t_queueSteer(text: string, images?: ImageContent[]): Promise<void>;\n\t_queueFollowUp(text: string, images?: ImageContent[]): Promise<void>;\n\t_throwIfExtensionCommand(text: string): void;\n\tsendCustomMessage<T = unknown>(\n\t\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\t\toptions?: SendMessageOptions,\n\t): Promise<void>;\n\t_appendCustomMessage<T>(message: CustomMessage<T>): void;\n\t_enqueueInterruptCustomMessage<T>(message: CustomMessage<T>, options?: SendMessageOptions): Promise<void>;\n\t_sendInterruptCustomMessageNow<T>(message: CustomMessage<T>, options?: SendMessageOptions): Promise<void>;\n\t_ensureActiveInterruptQueueHold(): InterruptQueueHold;\n\t_restoreAndClearActiveInterruptQueueHold(): void;\n\t_queueAgentMessage(message: AgentMessage, delivery: \"steer\" | \"followUp\"): void;\n\t_drainQueuedAgentMessages(): DrainedAgentQueues;\n\t_restoreQueuedAgentMessages(queues: DrainedAgentQueues): void;\n\tclearQueue(): { steering: string[]; followUp: string[] };\n\tgetSteeringMessages(): readonly string[];\n\tgetFollowUpMessages(): readonly string[];\n\tabort(): Promise<void>;\n\tsetSteeringMode(mode: \"all\" | \"one-at-a-time\"): void;\n\tsetFollowUpMode(mode: \"all\" | \"one-at-a-time\"): void;\n\n\t_emitModelChanged(nextModel: Model<Api>, previousModel: Model<Api> | undefined, source: \"set\" | \"cycle\" | \"restore\"): void;\n\t_emitModelSelect(nextModel: Model<Api>, previousModel: Model<Api> | undefined, source: \"set\" | \"cycle\" | \"restore\"): Promise<void>;\n\tsetModel(model: Model<Api>): Promise<void>;\n\tcycleModel(direction?: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined>;\n\t_cycleScopedModel(direction: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined>;\n\t_cycleAvailableModel(direction: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined>;\n\tsetThinkingLevel(level: ThinkingLevel): void;\n\tcycleThinkingLevel(): ThinkingLevel | undefined;\n\tgetAvailableThinkingLevels(): ThinkingLevel[];\n\tsupportsThinking(): boolean;\n\t_getThinkingLevelForModelSwitch(explicitLevel?: ThinkingLevel): ThinkingLevel;\n\t_clampThinkingLevel(level: ThinkingLevel, availableLevels: ThinkingLevel[]): ThinkingLevel;\n\tgetAvailableContextWindows(): number[];\n\tsupportsContextWindowSelection(): boolean;\n\tsetContextWindow(contextWindow: number, options?: { persistDefault?: boolean }): void;\n\t_withContextWindowForModelSwitch(model: Model<Api>): Model<Api>;\n\t_shouldCarryCurrentContextWindowForModelSwitch(currentModel: Model<Api>, settingsDefaultContextWindow: number | undefined): boolean;\n\t_getSettingsContextWindowRequestForModel(model: Model<Api>): ContextWindowReplayRequest | undefined;\n\t_getContextWindowReplayForModel(model: Model<Api>, requestedContextWindow: number | undefined, source: ContextWindowReplaySource | undefined): ContextWindowReplayResult;\n\t_getDefaultContextWindowReplayForModel(model: Model<Api>, wouldWarn: boolean): ContextWindowReplayResult;\n\t_getResumeContextWindowReplayForModel(model: Model<Api>): ContextWindowReplayResult;\n\t_applyContextWindowReplay(contextWindow: number | undefined): void;\n\t_appendContextWindowChangeIfChanged(previousModel: Model<Api> | undefined, nextModel: Model<Api>): void;\n\n\t_applyContextVerbatimCompaction(options: ContextCompactionApplyOptions): Promise<ContextCompactionResult | undefined>;\n\tcompact(options?: Partial<ContextCompactionParameters>): Promise<ContextCompactionResult>;\n\tcontextCompact(): Promise<ContextCompactionResult>;\n\tabortCompaction(): void;\n\tabortBranchSummary(): void;\n\t_checkCompaction(assistantMessage: AssistantMessage, skipAbortedCheck?: boolean): Promise<void>;\n\t_isCopilotServerCapBelowSelectedContextWindow(assistantMessage: AssistantMessage): boolean;\n\t_dropTrailingOverflowAssistantErrorIfPresent(): void;\n\t_schedulePostAutoCompactionContinuationProbe(reason: \"overflow\" | \"threshold\", willRetry: boolean): void;\n\t_resumeAfterAutoCompaction(): void;\n\t_runAutoCompaction(reason: \"overflow\" | \"threshold\", willRetry: boolean): Promise<void>;\n\tsetAutoCompactionEnabled(enabled: boolean): void;\n\n\tbindExtensions(bindings: ExtensionBindings): Promise<void>;\n\textendResourcesFromExtensions(reason: \"startup\" | \"reload\"): Promise<void>;\n\tbuildExtensionResourcePaths(entries: ExtensionResourcePathEntry[]): ExtensionResourcePathResult[];\n\tgetExtensionSourceLabel(extensionPath: string): string;\n\t_applyExtensionBindings(runner: ExtensionRunner): void;\n\t_refreshCurrentModelFromRegistry(): void;\n\t_bindExtensionCore(runner: ExtensionRunner): void;\n\t_refreshToolRegistry(options?: { activeToolNames?: string[]; includeAllExtensionTools?: boolean }): void;\n\t_buildRuntime(options: RuntimeBuildOptions): void;\n\treload(): Promise<void>;\n\n\t_isRetryableError(message: AssistantMessage): boolean;\n\t_normalizePersistedGeminiToolArgs(message: AssistantMessage): void;\n\t_isEmptyCompletion(message: AssistantMessage): boolean;\n\t_handleRetryableError(message: AssistantMessage): Promise<boolean>;\n\tabortRetry(): void;\n\twaitForRetry(): Promise<void>;\n\tsetAutoRetryEnabled(enabled: boolean): void;\n\n\texecuteBash(command: string, onChunk?: (chunk: string) => void, options?: { excludeFromContext?: boolean; operations?: BashOperations }): Promise<BashResult>;\n\trecordBashResult(command: string, result: BashResult, options?: { excludeFromContext?: boolean }): void;\n\tabortBash(): void;\n\t_flushPendingBashMessages(): void;\n\n\tsetSessionName(name: string): void;\n\tnavigateTree(targetId: string, options?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string }): Promise<{ editorText?: string; cancelled: boolean; aborted?: boolean; summaryEntry?: BranchSummaryEntry }>;\n\tgetUserMessagesForForking(): Array<{ entryId: string; text: string }>;\n\t_extractUserMessageText(content: string | Array<{ type: string; text?: string }>): string;\n\n\tgetSessionStats(): SessionStats;\n\tgetContextUsage(): ContextUsage | undefined;\n\texportToHtml(outputPath?: string): Promise<string>;\n\texportToJsonl(outputPath?: string): string;\n\tgetLastAssistantText(): string | undefined;\n\tcreateReplacedSessionContext(): ReplacedSessionContext;\n\thasExtensionHandlers(eventType: string): boolean;\n}\n\nexport interface AgentSessionPublicSurface extends Pick<AgentSessionMethodSurface,\n\t| \"orchestrationContext\"\n\t| \"modelRegistry\"\n\t| \"state\"\n\t| \"model\"\n\t| \"thinkingLevel\"\n\t| \"isStreaming\"\n\t| \"systemPrompt\"\n\t| \"retryAttempt\"\n\t| \"isCompacting\"\n\t| \"messages\"\n\t| \"steeringMode\"\n\t| \"followUpMode\"\n\t| \"sessionFile\"\n\t| \"sessionId\"\n\t| \"sessionName\"\n\t| \"scopedModels\"\n\t| \"promptTemplates\"\n\t| \"pendingMessageCount\"\n\t| \"resourceLoader\"\n\t| \"autoCompactionEnabled\"\n\t| \"isRetrying\"\n\t| \"autoRetryEnabled\"\n\t| \"isBashRunning\"\n\t| \"hasPendingBashMessages\"\n\t| \"extensionRunner\"\n\t| \"subscribe\"\n\t| \"dispose\"\n\t| \"getActiveToolNames\"\n\t| \"getAllTools\"\n\t| \"getToolDefinition\"\n\t| \"setActiveToolsByName\"\n\t| \"setScopedModels\"\n\t| \"prompt\"\n\t| \"steer\"\n\t| \"followUp\"\n\t| \"sendCustomMessage\"\n\t| \"sendUserMessage\"\n\t| \"clearQueue\"\n\t| \"getSteeringMessages\"\n\t| \"getFollowUpMessages\"\n\t| \"abort\"\n\t| \"setModel\"\n\t| \"cycleModel\"\n\t| \"setThinkingLevel\"\n\t| \"cycleThinkingLevel\"\n\t| \"getAvailableThinkingLevels\"\n\t| \"supportsThinking\"\n\t| \"getAvailableContextWindows\"\n\t| \"supportsContextWindowSelection\"\n\t| \"setContextWindow\"\n\t| \"setSteeringMode\"\n\t| \"setFollowUpMode\"\n\t| \"compact\"\n\t| \"contextCompact\"\n\t| \"abortCompaction\"\n\t| \"abortBranchSummary\"\n\t| \"setAutoCompactionEnabled\"\n\t| \"bindExtensions\"\n\t| \"reload\"\n\t| \"abortRetry\"\n\t| \"setAutoRetryEnabled\"\n\t| \"executeBash\"\n\t| \"recordBashResult\"\n\t| \"abortBash\"\n\t| \"setSessionName\"\n\t| \"navigateTree\"\n\t| \"getUserMessagesForForking\"\n\t| \"getSessionStats\"\n\t| \"getContextUsage\"\n\t| \"exportToHtml\"\n\t| \"exportToJsonl\"\n\t| \"getLastAssistantText\"\n\t| \"createReplacedSessionContext\"\n\t| \"hasExtensionHandlers\"\n> {\n\treadonly agent: Agent;\n\treadonly sessionManager: SessionManager;\n\treadonly settingsManager: SettingsManager;\n}\n\nexport interface AgentSessionInternalSurface extends AgentSessionMethodSurface, AgentSessionPublicSurface {\n\t_scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\t_unsubscribeAgent?: () => void;\n\t_eventListeners: AgentSessionEventListener[];\n\t_agentEventQueue: Promise<void>;\n\t_steeringMessages: string[];\n\t_followUpMessages: string[];\n\t_interruptDeliveryQueue: Promise<void>;\n\t_pendingInterruptDeliveries: number;\n\t_activeInterruptQueueHold: InterruptQueueHold | undefined;\n\t_activeInterruptAbortMessage: string | undefined;\n\t_pendingNextTurnMessages: CustomMessage[];\n\t_compactionAbortController: AbortController | undefined;\n\t_autoCompactionAbortController: AbortController | undefined;\n\t_overflowRecoveryAttempted: boolean;\n\t_branchSummaryAbortController: AbortController | undefined;\n\t_retryAbortController: AbortController | undefined;\n\t_retryAttempt: number;\n\t_retryPromise: Promise<void> | undefined;\n\t_retryResolve: (() => void) | undefined;\n\t_bashAbortController: AbortController | undefined;\n\t_pendingBashMessages: BashExecutionMessage[];\n\t_extensionRunner: ExtensionRunner;\n\t_turnIndex: number;\n\t_resourceLoader: ResourceLoader;\n\t_customTools: ToolDefinition[];\n\t_baseToolDefinitions: Map<string, ToolDefinition>;\n\t_cwd: string;\n\t_extensionRunnerRef?: { current?: ExtensionRunner };\n\t_initialActiveToolNames?: string[];\n\t_allowedToolNames?: Set<string>;\n\t_excludedToolNames?: Set<string>;\n\t_baseToolsOverride?: Record<string, AgentTool>;\n\t_sessionStartEvent: SessionStartEvent;\n\t_orchestrationContext?: OrchestrationContext;\n\t_extensionUIContext?: ExtensionUIContext;\n\t_extensionMode: ExtensionMode;\n\t_extensionCommandContextActions?: ExtensionCommandContextActions;\n\t_extensionShutdownHandler?: () => void;\n\t_extensionErrorListener?: ExtensionErrorListener;\n\t_extensionErrorUnsubscriber?: () => void;\n\t_modelRegistry: ModelRegistry;\n\t_toolRegistry: Map<string, AgentTool>;\n\t_toolDefinitions: Map<string, ToolDefinitionEntry>;\n\t_toolPromptSnippets: Map<string, string>;\n\t_toolPromptGuidelines: Map<string, string[]>;\n\t_baseSystemPrompt: string;\n\t_baseSystemPromptOptions: BuildSystemPromptOptions;\n\t_systemPromptOverride?: string;\n\t_lastAssistantMessage: AssistantMessage | undefined;\n}\n\n"]}
|
|
1
|
+
{"version":3,"file":"agent-session-methods.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-methods.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC3H,OAAO,KAAK,EAAE,GAAG,EAAE,gBAAgB,EAAE,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AACrH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EACX,2BAA2B,EAC3B,uBAAuB,EACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACX,YAAY,EACZ,8BAA8B,EAC9B,sBAAsB,EACtB,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,cAAc,EACd,QAAQ,EACR,MAAM,uB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AA2B,CAAC,EAAE,MAAM,IAAI,CAAC;IACzC,cAAc,EAAE,aAAa,CAAC;IAC9B,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACtC,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IACnD,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,qBAAqB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC7C,iBAAiB,EAAE,MAAM,CAAC;IAC1B,wBAAwB,EAAE,wBAAwB,CAAC;IACnD,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,qBAAqB,EAAE,gBAAgB,GAAG,SAAS,CAAC;CACpD","sourcesContent":["import type { Agent, AgentEvent, AgentMessage, AgentState, AgentTool, ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { Api, AssistantMessage, ImageContent, Message, Model, TextContent } from \"@earendil-works/pi-ai/compat\";\nimport type { BashResult } from \"./bash-executor.ts\";\nimport type {\n\tContextCompactionParameters,\n\tContextCompactionResult,\n} from \"./compaction/index.ts\";\nimport type {\n\tContextUsage,\n\tExtensionCommandContextActions,\n\tExtensionErrorListener,\n\tExtensionMode,\n\tExtensionRunner,\n\tExtensionUIContext,\n\tOrchestrationContext,\n\tReplacedSessionContext,\n\tSessionStartEvent,\n\tToolDefinition,\n\tToolInfo,\n} from \"./extensions/index.ts\";\nimport type { BashExecutionMessage, CustomMessage } from \"./messages.ts\";\nimport type { ModelRegistry } from \"./model-registry.ts\";\nimport type { PromptTemplate } from \"./prompt-templates.ts\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport type { BranchSummaryEntry, SessionManager } from \"./session-manager.ts\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\nimport type { BuildSystemPromptOptions } from \"./system-prompt.ts\";\nimport type { BashOperations } from \"./tools/bash.ts\";\nimport type {\n\tAgentSessionEvent,\n\tAgentSessionEventListener,\n\tContextWindowReplayRequest,\n\tContextWindowReplaySource,\n\tDrainedAgentQueues,\n\tExtensionBindings,\n\tInterruptQueueHold,\n\tModelCycleResult,\n\tPromptOptions,\n\tSessionStats,\n\tToolDefinitionEntry,\n} from \"./agent-session-types.ts\";\nimport type { SendMessageOptions } from \"./extensions/index.ts\";\n\nexport interface ContextCompactionApplyOptions {\n\tresolvePlannerAuth: () => Promise<{ apiKey: string; headers?: Record<string, string> } | undefined>;\n\tabortController: AbortController;\n\tbackupLabel: string;\n\tcompression_ratio?: number;\n\tpreserve_recent?: number;\n\tquery?: string;\n\treason: \"manual\" | \"threshold\" | \"overflow\";\n}\n\nexport interface ExtensionResourcePathEntry {\n\tpath: string;\n\textensionPath: string;\n}\n\nexport interface ExtensionResourcePathResult {\n\tpath: string;\n\tmetadata: { source: string; scope: \"temporary\"; origin: \"top-level\"; baseDir?: string };\n}\n\nexport interface RuntimeBuildOptions {\n\tactiveToolNames?: string[];\n\tflagValues?: Map<string, boolean | string>;\n\tincludeAllExtensionTools?: boolean;\n}\n\nexport interface ContextWindowReplayResult {\n\tmodel: Model<Api>;\n\tcontextWindow: number;\n\twouldWarn: boolean;\n}\n\nexport interface AgentSessionMethodSurface {\n\treadonly orchestrationContext: import(\"./extensions/index.ts\").OrchestrationContext | undefined;\n\treadonly modelRegistry: ModelRegistry;\n\treadonly state: AgentState;\n\treadonly model: Model<Api> | undefined;\n\treadonly thinkingLevel: ThinkingLevel;\n\treadonly isStreaming: boolean;\n\treadonly systemPrompt: string;\n\treadonly retryAttempt: number;\n\treadonly isCompacting: boolean;\n\treadonly messages: AgentMessage[];\n\treadonly steeringMode: \"all\" | \"one-at-a-time\";\n\treadonly followUpMode: \"all\" | \"one-at-a-time\";\n\treadonly sessionFile: string | undefined;\n\treadonly sessionId: string;\n\treadonly sessionName: string | undefined;\n\treadonly scopedModels: ReadonlyArray<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\treadonly promptTemplates: ReadonlyArray<PromptTemplate>;\n\treadonly pendingMessageCount: number;\n\treadonly resourceLoader: ResourceLoader;\n\treadonly autoCompactionEnabled: boolean;\n\treadonly isRetrying: boolean;\n\treadonly autoRetryEnabled: boolean;\n\treadonly isBashRunning: boolean;\n\treadonly hasPendingBashMessages: boolean;\n\treadonly extensionRunner: ExtensionRunner;\n\n\t_handleAgentEvent(event: AgentEvent): void;\n\t_getRequiredRequestAuth(model: Model<Api>): Promise<{ apiKey: string; headers?: Record<string, string> }>;\n\t_installAgentToolHooks(): void;\n\t_installAgentNextTurnRefresh(): void;\n\t_emit(event: AgentSessionEvent): void;\n\t_emitQueueUpdate(): void;\n\t_createRetryPromiseForAgentEnd(event: AgentEvent): void;\n\t_findLastAssistantInMessages(messages: AgentMessage[]): AssistantMessage | undefined;\n\t_processAgentEvent(event: AgentEvent): Promise<void>;\n\t_applyInterruptAbortMessage(event: AgentEvent): void;\n\t_applyProviderErrorGuidance(event: AgentEvent): void;\n\t_resolveRetry(): void;\n\t_getUserMessageText(message: Message): string;\n\t_findLastAssistantMessage(): AssistantMessage | undefined;\n\t_replaceMessageInPlace(target: AgentMessage, replacement: AgentMessage): void;\n\t_emitExtensionEvent(event: AgentEvent): Promise<void>;\n\tsubscribe(listener: AgentSessionEventListener): () => void;\n\t_disconnectFromAgent(): void;\n\t_reconnectToAgent(): void;\n\tdispose(): void;\n\n\tgetActiveToolNames(): string[];\n\tgetAllTools(): ToolInfo[];\n\tgetToolDefinition(name: string): ToolDefinition | undefined;\n\tsetActiveToolsByName(toolNames: string[]): void;\n\tsetScopedModels(scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>): void;\n\t_normalizePromptSnippet(text: string | undefined): string | undefined;\n\t_normalizePromptGuidelines(guidelines: string[] | undefined): string[];\n\t_rebuildSystemPrompt(toolNames: string[]): string;\n\t_refreshBaseSystemPromptFromActiveTools(): void;\n\n\tprompt(text: string, options?: PromptOptions): Promise<void>;\n\t_runAgentPrompt(messages: AgentMessage | AgentMessage[]): Promise<void>;\n\t_runAgentContinue(): Promise<void>;\n\t_continueQueuedAgentMessages(): Promise<void>;\n\t_tryExecuteBuiltinSlashCommand(text: string): Promise<boolean>;\n\t_tryExecuteExtensionCommand(text: string): Promise<boolean>;\n\t_expandSkillCommand(text: string): string;\n\tsteer(text: string, images?: ImageContent[]): Promise<void>;\n\tfollowUp(text: string, images?: ImageContent[]): Promise<void>;\n\tsendUserMessage(\n\t\tcontent: string | (TextContent | ImageContent)[],\n\t\toptions?: { deliverAs?: \"steer\" | \"followUp\" },\n\t): Promise<void>;\n\n\t_queueSteer(text: string, images?: ImageContent[]): Promise<void>;\n\t_queueFollowUp(text: string, images?: ImageContent[]): Promise<void>;\n\t_throwIfExtensionCommand(text: string): void;\n\tsendCustomMessage<T = unknown>(\n\t\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\t\toptions?: SendMessageOptions,\n\t): Promise<void>;\n\t_appendCustomMessage<T>(message: CustomMessage<T>): void;\n\t_enqueueInterruptCustomMessage<T>(message: CustomMessage<T>, options?: SendMessageOptions): Promise<void>;\n\t_sendInterruptCustomMessageNow<T>(message: CustomMessage<T>, options?: SendMessageOptions): Promise<void>;\n\t_ensureActiveInterruptQueueHold(): InterruptQueueHold;\n\t_restoreAndClearActiveInterruptQueueHold(): void;\n\t_queueAgentMessage(message: AgentMessage, delivery: \"steer\" | \"followUp\"): void;\n\t_drainQueuedAgentMessages(): DrainedAgentQueues;\n\t_restoreQueuedAgentMessages(queues: DrainedAgentQueues): void;\n\tclearQueue(): { steering: string[]; followUp: string[] };\n\tgetSteeringMessages(): readonly string[];\n\tgetFollowUpMessages(): readonly string[];\n\tabort(): Promise<void>;\n\tsetSteeringMode(mode: \"all\" | \"one-at-a-time\"): void;\n\tsetFollowUpMode(mode: \"all\" | \"one-at-a-time\"): void;\n\n\t_emitModelChanged(nextModel: Model<Api>, previousModel: Model<Api> | undefined, source: \"set\" | \"cycle\" | \"restore\"): void;\n\t_emitModelSelect(nextModel: Model<Api>, previousModel: Model<Api> | undefined, source: \"set\" | \"cycle\" | \"restore\"): Promise<void>;\n\tsetModel(model: Model<Api>): Promise<void>;\n\tcycleModel(direction?: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined>;\n\t_cycleScopedModel(direction: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined>;\n\t_cycleAvailableModel(direction: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined>;\n\tsetThinkingLevel(level: ThinkingLevel): void;\n\tcycleThinkingLevel(): ThinkingLevel | undefined;\n\tgetAvailableThinkingLevels(): ThinkingLevel[];\n\tsupportsThinking(): boolean;\n\t_getThinkingLevelForModelSwitch(explicitLevel?: ThinkingLevel): ThinkingLevel;\n\t_clampThinkingLevel(level: ThinkingLevel, availableLevels: ThinkingLevel[]): ThinkingLevel;\n\tgetAvailableContextWindows(): number[];\n\tsupportsContextWindowSelection(): boolean;\n\tsetContextWindow(contextWindow: number, options?: { persistDefault?: boolean }): void;\n\t_withContextWindowForModelSwitch(model: Model<Api>): Model<Api>;\n\t_shouldCarryCurrentContextWindowForModelSwitch(currentModel: Model<Api>, settingsDefaultContextWindow: number | undefined): boolean;\n\t_getSettingsContextWindowRequestForModel(model: Model<Api>): ContextWindowReplayRequest | undefined;\n\t_getContextWindowReplayForModel(model: Model<Api>, requestedContextWindow: number | undefined, source: ContextWindowReplaySource | undefined): ContextWindowReplayResult;\n\t_getDefaultContextWindowReplayForModel(model: Model<Api>, wouldWarn: boolean): ContextWindowReplayResult;\n\t_getResumeContextWindowReplayForModel(model: Model<Api>): ContextWindowReplayResult;\n\t_applyContextWindowReplay(contextWindow: number | undefined): void;\n\t_appendContextWindowChangeIfChanged(previousModel: Model<Api> | undefined, nextModel: Model<Api>): void;\n\n\t_applyContextVerbatimCompaction(options: ContextCompactionApplyOptions): Promise<ContextCompactionResult | undefined>;\n\tcompact(options?: Partial<ContextCompactionParameters>): Promise<ContextCompactionResult>;\n\tcontextCompact(): Promise<ContextCompactionResult>;\n\tabortCompaction(): void;\n\tabortBranchSummary(): void;\n\t_checkCompaction(assistantMessage: AssistantMessage, skipAbortedCheck?: boolean): Promise<void>;\n\t_isCopilotServerCapBelowSelectedContextWindow(assistantMessage: AssistantMessage): boolean;\n\t_dropTrailingOverflowAssistantErrorIfPresent(): void;\n\t_schedulePostAutoCompactionContinuationProbe(reason: \"overflow\" | \"threshold\", willRetry: boolean): void;\n\t_resumeAfterAutoCompaction(): void;\n\t_runAutoCompaction(reason: \"overflow\" | \"threshold\", willRetry: boolean): Promise<void>;\n\tsetAutoCompactionEnabled(enabled: boolean): void;\n\n\tbindExtensions(bindings: ExtensionBindings): Promise<void>;\n\textendResourcesFromExtensions(reason: \"startup\" | \"reload\"): Promise<void>;\n\tbuildExtensionResourcePaths(entries: ExtensionResourcePathEntry[]): ExtensionResourcePathResult[];\n\tgetExtensionSourceLabel(extensionPath: string): string;\n\t_applyExtensionBindings(runner: ExtensionRunner): void;\n\t_refreshCurrentModelFromRegistry(): void;\n\trefreshCurrentModelFromRegistry(): void;\n\t_bindExtensionCore(runner: ExtensionRunner): void;\n\t_refreshToolRegistry(options?: { activeToolNames?: string[]; includeAllExtensionTools?: boolean }): void;\n\t_buildRuntime(options: RuntimeBuildOptions): void;\n\treload(): Promise<void>;\n\n\t_isRetryableError(message: AssistantMessage): boolean;\n\t_normalizePersistedGeminiToolArgs(message: AssistantMessage): void;\n\t_isEmptyCompletion(message: AssistantMessage): boolean;\n\t_handleRetryableError(message: AssistantMessage): Promise<boolean>;\n\tabortRetry(): void;\n\twaitForRetry(): Promise<void>;\n\tsetAutoRetryEnabled(enabled: boolean): void;\n\n\texecuteBash(command: string, onChunk?: (chunk: string) => void, options?: { excludeFromContext?: boolean; operations?: BashOperations }): Promise<BashResult>;\n\trecordBashResult(command: string, result: BashResult, options?: { excludeFromContext?: boolean }): void;\n\tabortBash(): void;\n\t_flushPendingBashMessages(): void;\n\n\tsetSessionName(name: string): void;\n\tnavigateTree(targetId: string, options?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string }): Promise<{ editorText?: string; cancelled: boolean; aborted?: boolean; summaryEntry?: BranchSummaryEntry }>;\n\tgetUserMessagesForForking(): Array<{ entryId: string; text: string }>;\n\t_extractUserMessageText(content: string | Array<{ type: string; text?: string }>): string;\n\n\tgetSessionStats(): SessionStats;\n\tgetContextUsage(): ContextUsage | undefined;\n\texportToHtml(outputPath?: string): Promise<string>;\n\texportToJsonl(outputPath?: string): string;\n\tgetLastAssistantText(): string | undefined;\n\tcreateReplacedSessionContext(): ReplacedSessionContext;\n\thasExtensionHandlers(eventType: string): boolean;\n}\n\nexport interface AgentSessionPublicSurface extends Pick<AgentSessionMethodSurface,\n\t| \"orchestrationContext\"\n\t| \"modelRegistry\"\n\t| \"state\"\n\t| \"model\"\n\t| \"thinkingLevel\"\n\t| \"isStreaming\"\n\t| \"systemPrompt\"\n\t| \"retryAttempt\"\n\t| \"isCompacting\"\n\t| \"messages\"\n\t| \"steeringMode\"\n\t| \"followUpMode\"\n\t| \"sessionFile\"\n\t| \"sessionId\"\n\t| \"sessionName\"\n\t| \"scopedModels\"\n\t| \"promptTemplates\"\n\t| \"pendingMessageCount\"\n\t| \"resourceLoader\"\n\t| \"autoCompactionEnabled\"\n\t| \"isRetrying\"\n\t| \"autoRetryEnabled\"\n\t| \"isBashRunning\"\n\t| \"hasPendingBashMessages\"\n\t| \"extensionRunner\"\n\t| \"subscribe\"\n\t| \"dispose\"\n\t| \"getActiveToolNames\"\n\t| \"getAllTools\"\n\t| \"getToolDefinition\"\n\t| \"setActiveToolsByName\"\n\t| \"setScopedModels\"\n\t| \"prompt\"\n\t| \"steer\"\n\t| \"followUp\"\n\t| \"sendCustomMessage\"\n\t| \"sendUserMessage\"\n\t| \"clearQueue\"\n\t| \"getSteeringMessages\"\n\t| \"getFollowUpMessages\"\n\t| \"abort\"\n\t| \"setModel\"\n\t| \"cycleModel\"\n\t| \"setThinkingLevel\"\n\t| \"cycleThinkingLevel\"\n\t| \"getAvailableThinkingLevels\"\n\t| \"supportsThinking\"\n\t| \"getAvailableContextWindows\"\n\t| \"supportsContextWindowSelection\"\n\t| \"setContextWindow\"\n\t| \"setSteeringMode\"\n\t| \"setFollowUpMode\"\n\t| \"compact\"\n\t| \"contextCompact\"\n\t| \"abortCompaction\"\n\t| \"abortBranchSummary\"\n\t| \"setAutoCompactionEnabled\"\n\t| \"bindExtensions\"\n\t| \"refreshCurrentModelFromRegistry\"\n\t| \"reload\"\n\t| \"abortRetry\"\n\t| \"setAutoRetryEnabled\"\n\t| \"executeBash\"\n\t| \"recordBashResult\"\n\t| \"abortBash\"\n\t| \"setSessionName\"\n\t| \"navigateTree\"\n\t| \"getUserMessagesForForking\"\n\t| \"getSessionStats\"\n\t| \"getContextUsage\"\n\t| \"exportToHtml\"\n\t| \"exportToJsonl\"\n\t| \"getLastAssistantText\"\n\t| \"createReplacedSessionContext\"\n\t| \"hasExtensionHandlers\"\n> {\n\treadonly agent: Agent;\n\treadonly sessionManager: SessionManager;\n\treadonly settingsManager: SettingsManager;\n}\n\nexport interface AgentSessionInternalSurface extends AgentSessionMethodSurface, AgentSessionPublicSurface {\n\t_scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\t_unsubscribeAgent?: () => void;\n\t_eventListeners: AgentSessionEventListener[];\n\t_agentEventQueue: Promise<void>;\n\t_steeringMessages: string[];\n\t_followUpMessages: string[];\n\t_interruptDeliveryQueue: Promise<void>;\n\t_pendingInterruptDeliveries: number;\n\t_activeInterruptQueueHold: InterruptQueueHold | undefined;\n\t_activeInterruptAbortMessage: string | undefined;\n\t_pendingNextTurnMessages: CustomMessage[];\n\t_compactionAbortController: AbortController | undefined;\n\t_autoCompactionAbortController: AbortController | undefined;\n\t_overflowRecoveryAttempted: boolean;\n\t_branchSummaryAbortController: AbortController | undefined;\n\t_retryAbortController: AbortController | undefined;\n\t_retryAttempt: number;\n\t_retryPromise: Promise<void> | undefined;\n\t_retryResolve: (() => void) | undefined;\n\t_bashAbortController: AbortController | undefined;\n\t_pendingBashMessages: BashExecutionMessage[];\n\t_extensionRunner: ExtensionRunner;\n\t_turnIndex: number;\n\t_resourceLoader: ResourceLoader;\n\t_customTools: ToolDefinition[];\n\t_baseToolDefinitions: Map<string, ToolDefinition>;\n\t_cwd: string;\n\t_extensionRunnerRef?: { current?: ExtensionRunner };\n\t_initialActiveToolNames?: string[];\n\t_allowedToolNames?: Set<string>;\n\t_excludedToolNames?: Set<string>;\n\t_baseToolsOverride?: Record<string, AgentTool>;\n\t_sessionStartEvent: SessionStartEvent;\n\t_orchestrationContext?: OrchestrationContext;\n\t_extensionUIContext?: ExtensionUIContext;\n\t_extensionMode: ExtensionMode;\n\t_extensionCommandContextActions?: ExtensionCommandContextActions;\n\t_extensionShutdownHandler?: () => void;\n\t_extensionErrorListener?: ExtensionErrorListener;\n\t_extensionErrorUnsubscriber?: () => void;\n\t_modelRegistry: ModelRegistry;\n\t_toolRegistry: Map<string, AgentTool>;\n\t_toolDefinitions: Map<string, ToolDefinitionEntry>;\n\t_toolPromptSnippets: Map<string, string>;\n\t_toolPromptGuidelines: Map<string, string[]>;\n\t_baseSystemPrompt: string;\n\t_baseSystemPromptOptions: BuildSystemPromptOptions;\n\t_systemPromptOverride?: string;\n\t_lastAssistantMessage: AssistantMessage | undefined;\n}\n\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session-methods.js","sourceRoot":"","sources":["../../src/core/agent-session-methods.ts"],"names":[],"mappings":"","sourcesContent":["import type { Agent, AgentEvent, AgentMessage, AgentState, AgentTool, ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { Api, AssistantMessage, ImageContent, Message, Model, TextContent } from \"@earendil-works/pi-ai/compat\";\nimport type { BashResult } from \"./bash-executor.ts\";\nimport type {\n\tContextCompactionParameters,\n\tContextCompactionResult,\n} from \"./compaction/index.ts\";\nimport type {\n\tContextUsage,\n\tExtensionCommandContextActions,\n\tExtensionErrorListener,\n\tExtensionMode,\n\tExtensionRunner,\n\tExtensionUIContext,\n\tOrchestrationContext,\n\tReplacedSessionContext,\n\tSessionStartEvent,\n\tToolDefinition,\n\tToolInfo,\n} from \"./extensions/index.ts\";\nimport type { BashExecutionMessage, CustomMessage } from \"./messages.ts\";\nimport type { ModelRegistry } from \"./model-registry.ts\";\nimport type { PromptTemplate } from \"./prompt-templates.ts\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport type { BranchSummaryEntry, SessionManager } from \"./session-manager.ts\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\nimport type { BuildSystemPromptOptions } from \"./system-prompt.ts\";\nimport type { BashOperations } from \"./tools/bash.ts\";\nimport type {\n\tAgentSessionEvent,\n\tAgentSessionEventListener,\n\tContextWindowReplayRequest,\n\tContextWindowReplaySource,\n\tDrainedAgentQueues,\n\tExtensionBindings,\n\tInterruptQueueHold,\n\tModelCycleResult,\n\tPromptOptions,\n\tSessionStats,\n\tToolDefinitionEntry,\n} from \"./agent-session-types.ts\";\nimport type { SendMessageOptions } from \"./extensions/index.ts\";\n\nexport interface ContextCompactionApplyOptions {\n\tresolvePlannerAuth: () => Promise<{ apiKey: string; headers?: Record<string, string> } | undefined>;\n\tabortController: AbortController;\n\tbackupLabel: string;\n\tcompression_ratio?: number;\n\tpreserve_recent?: number;\n\tquery?: string;\n\treason: \"manual\" | \"threshold\" | \"overflow\";\n}\n\nexport interface ExtensionResourcePathEntry {\n\tpath: string;\n\textensionPath: string;\n}\n\nexport interface ExtensionResourcePathResult {\n\tpath: string;\n\tmetadata: { source: string; scope: \"temporary\"; origin: \"top-level\"; baseDir?: string };\n}\n\nexport interface RuntimeBuildOptions {\n\tactiveToolNames?: string[];\n\tflagValues?: Map<string, boolean | string>;\n\tincludeAllExtensionTools?: boolean;\n}\n\nexport interface ContextWindowReplayResult {\n\tmodel: Model<Api>;\n\tcontextWindow: number;\n\twouldWarn: boolean;\n}\n\nexport interface AgentSessionMethodSurface {\n\treadonly orchestrationContext: import(\"./extensions/index.ts\").OrchestrationContext | undefined;\n\treadonly modelRegistry: ModelRegistry;\n\treadonly state: AgentState;\n\treadonly model: Model<Api> | undefined;\n\treadonly thinkingLevel: ThinkingLevel;\n\treadonly isStreaming: boolean;\n\treadonly systemPrompt: string;\n\treadonly retryAttempt: number;\n\treadonly isCompacting: boolean;\n\treadonly messages: AgentMessage[];\n\treadonly steeringMode: \"all\" | \"one-at-a-time\";\n\treadonly followUpMode: \"all\" | \"one-at-a-time\";\n\treadonly sessionFile: string | undefined;\n\treadonly sessionId: string;\n\treadonly sessionName: string | undefined;\n\treadonly scopedModels: ReadonlyArray<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\treadonly promptTemplates: ReadonlyArray<PromptTemplate>;\n\treadonly pendingMessageCount: number;\n\treadonly resourceLoader: ResourceLoader;\n\treadonly autoCompactionEnabled: boolean;\n\treadonly isRetrying: boolean;\n\treadonly autoRetryEnabled: boolean;\n\treadonly isBashRunning: boolean;\n\treadonly hasPendingBashMessages: boolean;\n\treadonly extensionRunner: ExtensionRunner;\n\n\t_handleAgentEvent(event: AgentEvent): void;\n\t_getRequiredRequestAuth(model: Model<Api>): Promise<{ apiKey: string; headers?: Record<string, string> }>;\n\t_installAgentToolHooks(): void;\n\t_installAgentNextTurnRefresh(): void;\n\t_emit(event: AgentSessionEvent): void;\n\t_emitQueueUpdate(): void;\n\t_createRetryPromiseForAgentEnd(event: AgentEvent): void;\n\t_findLastAssistantInMessages(messages: AgentMessage[]): AssistantMessage | undefined;\n\t_processAgentEvent(event: AgentEvent): Promise<void>;\n\t_applyInterruptAbortMessage(event: AgentEvent): void;\n\t_applyProviderErrorGuidance(event: AgentEvent): void;\n\t_resolveRetry(): void;\n\t_getUserMessageText(message: Message): string;\n\t_findLastAssistantMessage(): AssistantMessage | undefined;\n\t_replaceMessageInPlace(target: AgentMessage, replacement: AgentMessage): void;\n\t_emitExtensionEvent(event: AgentEvent): Promise<void>;\n\tsubscribe(listener: AgentSessionEventListener): () => void;\n\t_disconnectFromAgent(): void;\n\t_reconnectToAgent(): void;\n\tdispose(): void;\n\n\tgetActiveToolNames(): string[];\n\tgetAllTools(): ToolInfo[];\n\tgetToolDefinition(name: string): ToolDefinition | undefined;\n\tsetActiveToolsByName(toolNames: string[]): void;\n\tsetScopedModels(scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>): void;\n\t_normalizePromptSnippet(text: string | undefined): string | undefined;\n\t_normalizePromptGuidelines(guidelines: string[] | undefined): string[];\n\t_rebuildSystemPrompt(toolNames: string[]): string;\n\t_refreshBaseSystemPromptFromActiveTools(): void;\n\n\tprompt(text: string, options?: PromptOptions): Promise<void>;\n\t_runAgentPrompt(messages: AgentMessage | AgentMessage[]): Promise<void>;\n\t_runAgentContinue(): Promise<void>;\n\t_continueQueuedAgentMessages(): Promise<void>;\n\t_tryExecuteBuiltinSlashCommand(text: string): Promise<boolean>;\n\t_tryExecuteExtensionCommand(text: string): Promise<boolean>;\n\t_expandSkillCommand(text: string): string;\n\tsteer(text: string, images?: ImageContent[]): Promise<void>;\n\tfollowUp(text: string, images?: ImageContent[]): Promise<void>;\n\tsendUserMessage(\n\t\tcontent: string | (TextContent | ImageContent)[],\n\t\toptions?: { deliverAs?: \"steer\" | \"followUp\" },\n\t): Promise<void>;\n\n\t_queueSteer(text: string, images?: ImageContent[]): Promise<void>;\n\t_queueFollowUp(text: string, images?: ImageContent[]): Promise<void>;\n\t_throwIfExtensionCommand(text: string): void;\n\tsendCustomMessage<T = unknown>(\n\t\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\t\toptions?: SendMessageOptions,\n\t): Promise<void>;\n\t_appendCustomMessage<T>(message: CustomMessage<T>): void;\n\t_enqueueInterruptCustomMessage<T>(message: CustomMessage<T>, options?: SendMessageOptions): Promise<void>;\n\t_sendInterruptCustomMessageNow<T>(message: CustomMessage<T>, options?: SendMessageOptions): Promise<void>;\n\t_ensureActiveInterruptQueueHold(): InterruptQueueHold;\n\t_restoreAndClearActiveInterruptQueueHold(): void;\n\t_queueAgentMessage(message: AgentMessage, delivery: \"steer\" | \"followUp\"): void;\n\t_drainQueuedAgentMessages(): DrainedAgentQueues;\n\t_restoreQueuedAgentMessages(queues: DrainedAgentQueues): void;\n\tclearQueue(): { steering: string[]; followUp: string[] };\n\tgetSteeringMessages(): readonly string[];\n\tgetFollowUpMessages(): readonly string[];\n\tabort(): Promise<void>;\n\tsetSteeringMode(mode: \"all\" | \"one-at-a-time\"): void;\n\tsetFollowUpMode(mode: \"all\" | \"one-at-a-time\"): void;\n\n\t_emitModelChanged(nextModel: Model<Api>, previousModel: Model<Api> | undefined, source: \"set\" | \"cycle\" | \"restore\"): void;\n\t_emitModelSelect(nextModel: Model<Api>, previousModel: Model<Api> | undefined, source: \"set\" | \"cycle\" | \"restore\"): Promise<void>;\n\tsetModel(model: Model<Api>): Promise<void>;\n\tcycleModel(direction?: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined>;\n\t_cycleScopedModel(direction: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined>;\n\t_cycleAvailableModel(direction: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined>;\n\tsetThinkingLevel(level: ThinkingLevel): void;\n\tcycleThinkingLevel(): ThinkingLevel | undefined;\n\tgetAvailableThinkingLevels(): ThinkingLevel[];\n\tsupportsThinking(): boolean;\n\t_getThinkingLevelForModelSwitch(explicitLevel?: ThinkingLevel): ThinkingLevel;\n\t_clampThinkingLevel(level: ThinkingLevel, availableLevels: ThinkingLevel[]): ThinkingLevel;\n\tgetAvailableContextWindows(): number[];\n\tsupportsContextWindowSelection(): boolean;\n\tsetContextWindow(contextWindow: number, options?: { persistDefault?: boolean }): void;\n\t_withContextWindowForModelSwitch(model: Model<Api>): Model<Api>;\n\t_shouldCarryCurrentContextWindowForModelSwitch(currentModel: Model<Api>, settingsDefaultContextWindow: number | undefined): boolean;\n\t_getSettingsContextWindowRequestForModel(model: Model<Api>): ContextWindowReplayRequest | undefined;\n\t_getContextWindowReplayForModel(model: Model<Api>, requestedContextWindow: number | undefined, source: ContextWindowReplaySource | undefined): ContextWindowReplayResult;\n\t_getDefaultContextWindowReplayForModel(model: Model<Api>, wouldWarn: boolean): ContextWindowReplayResult;\n\t_getResumeContextWindowReplayForModel(model: Model<Api>): ContextWindowReplayResult;\n\t_applyContextWindowReplay(contextWindow: number | undefined): void;\n\t_appendContextWindowChangeIfChanged(previousModel: Model<Api> | undefined, nextModel: Model<Api>): void;\n\n\t_applyContextVerbatimCompaction(options: ContextCompactionApplyOptions): Promise<ContextCompactionResult | undefined>;\n\tcompact(options?: Partial<ContextCompactionParameters>): Promise<ContextCompactionResult>;\n\tcontextCompact(): Promise<ContextCompactionResult>;\n\tabortCompaction(): void;\n\tabortBranchSummary(): void;\n\t_checkCompaction(assistantMessage: AssistantMessage, skipAbortedCheck?: boolean): Promise<void>;\n\t_isCopilotServerCapBelowSelectedContextWindow(assistantMessage: AssistantMessage): boolean;\n\t_dropTrailingOverflowAssistantErrorIfPresent(): void;\n\t_schedulePostAutoCompactionContinuationProbe(reason: \"overflow\" | \"threshold\", willRetry: boolean): void;\n\t_resumeAfterAutoCompaction(): void;\n\t_runAutoCompaction(reason: \"overflow\" | \"threshold\", willRetry: boolean): Promise<void>;\n\tsetAutoCompactionEnabled(enabled: boolean): void;\n\n\tbindExtensions(bindings: ExtensionBindings): Promise<void>;\n\textendResourcesFromExtensions(reason: \"startup\" | \"reload\"): Promise<void>;\n\tbuildExtensionResourcePaths(entries: ExtensionResourcePathEntry[]): ExtensionResourcePathResult[];\n\tgetExtensionSourceLabel(extensionPath: string): string;\n\t_applyExtensionBindings(runner: ExtensionRunner): void;\n\t_refreshCurrentModelFromRegistry(): void;\n\t_bindExtensionCore(runner: ExtensionRunner): void;\n\t_refreshToolRegistry(options?: { activeToolNames?: string[]; includeAllExtensionTools?: boolean }): void;\n\t_buildRuntime(options: RuntimeBuildOptions): void;\n\treload(): Promise<void>;\n\n\t_isRetryableError(message: AssistantMessage): boolean;\n\t_normalizePersistedGeminiToolArgs(message: AssistantMessage): void;\n\t_isEmptyCompletion(message: AssistantMessage): boolean;\n\t_handleRetryableError(message: AssistantMessage): Promise<boolean>;\n\tabortRetry(): void;\n\twaitForRetry(): Promise<void>;\n\tsetAutoRetryEnabled(enabled: boolean): void;\n\n\texecuteBash(command: string, onChunk?: (chunk: string) => void, options?: { excludeFromContext?: boolean; operations?: BashOperations }): Promise<BashResult>;\n\trecordBashResult(command: string, result: BashResult, options?: { excludeFromContext?: boolean }): void;\n\tabortBash(): void;\n\t_flushPendingBashMessages(): void;\n\n\tsetSessionName(name: string): void;\n\tnavigateTree(targetId: string, options?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string }): Promise<{ editorText?: string; cancelled: boolean; aborted?: boolean; summaryEntry?: BranchSummaryEntry }>;\n\tgetUserMessagesForForking(): Array<{ entryId: string; text: string }>;\n\t_extractUserMessageText(content: string | Array<{ type: string; text?: string }>): string;\n\n\tgetSessionStats(): SessionStats;\n\tgetContextUsage(): ContextUsage | undefined;\n\texportToHtml(outputPath?: string): Promise<string>;\n\texportToJsonl(outputPath?: string): string;\n\tgetLastAssistantText(): string | undefined;\n\tcreateReplacedSessionContext(): ReplacedSessionContext;\n\thasExtensionHandlers(eventType: string): boolean;\n}\n\nexport interface AgentSessionPublicSurface extends Pick<AgentSessionMethodSurface,\n\t| \"orchestrationContext\"\n\t| \"modelRegistry\"\n\t| \"state\"\n\t| \"model\"\n\t| \"thinkingLevel\"\n\t| \"isStreaming\"\n\t| \"systemPrompt\"\n\t| \"retryAttempt\"\n\t| \"isCompacting\"\n\t| \"messages\"\n\t| \"steeringMode\"\n\t| \"followUpMode\"\n\t| \"sessionFile\"\n\t| \"sessionId\"\n\t| \"sessionName\"\n\t| \"scopedModels\"\n\t| \"promptTemplates\"\n\t| \"pendingMessageCount\"\n\t| \"resourceLoader\"\n\t| \"autoCompactionEnabled\"\n\t| \"isRetrying\"\n\t| \"autoRetryEnabled\"\n\t| \"isBashRunning\"\n\t| \"hasPendingBashMessages\"\n\t| \"extensionRunner\"\n\t| \"subscribe\"\n\t| \"dispose\"\n\t| \"getActiveToolNames\"\n\t| \"getAllTools\"\n\t| \"getToolDefinition\"\n\t| \"setActiveToolsByName\"\n\t| \"setScopedModels\"\n\t| \"prompt\"\n\t| \"steer\"\n\t| \"followUp\"\n\t| \"sendCustomMessage\"\n\t| \"sendUserMessage\"\n\t| \"clearQueue\"\n\t| \"getSteeringMessages\"\n\t| \"getFollowUpMessages\"\n\t| \"abort\"\n\t| \"setModel\"\n\t| \"cycleModel\"\n\t| \"setThinkingLevel\"\n\t| \"cycleThinkingLevel\"\n\t| \"getAvailableThinkingLevels\"\n\t| \"supportsThinking\"\n\t| \"getAvailableContextWindows\"\n\t| \"supportsContextWindowSelection\"\n\t| \"setContextWindow\"\n\t| \"setSteeringMode\"\n\t| \"setFollowUpMode\"\n\t| \"compact\"\n\t| \"contextCompact\"\n\t| \"abortCompaction\"\n\t| \"abortBranchSummary\"\n\t| \"setAutoCompactionEnabled\"\n\t| \"bindExtensions\"\n\t| \"reload\"\n\t| \"abortRetry\"\n\t| \"setAutoRetryEnabled\"\n\t| \"executeBash\"\n\t| \"recordBashResult\"\n\t| \"abortBash\"\n\t| \"setSessionName\"\n\t| \"navigateTree\"\n\t| \"getUserMessagesForForking\"\n\t| \"getSessionStats\"\n\t| \"getContextUsage\"\n\t| \"exportToHtml\"\n\t| \"exportToJsonl\"\n\t| \"getLastAssistantText\"\n\t| \"createReplacedSessionContext\"\n\t| \"hasExtensionHandlers\"\n> {\n\treadonly agent: Agent;\n\treadonly sessionManager: SessionManager;\n\treadonly settingsManager: SettingsManager;\n}\n\nexport interface AgentSessionInternalSurface extends AgentSessionMethodSurface, AgentSessionPublicSurface {\n\t_scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\t_unsubscribeAgent?: () => void;\n\t_eventListeners: AgentSessionEventListener[];\n\t_agentEventQueue: Promise<void>;\n\t_steeringMessages: string[];\n\t_followUpMessages: string[];\n\t_interruptDeliveryQueue: Promise<void>;\n\t_pendingInterruptDeliveries: number;\n\t_activeInterruptQueueHold: InterruptQueueHold | undefined;\n\t_activeInterruptAbortMessage: string | undefined;\n\t_pendingNextTurnMessages: CustomMessage[];\n\t_compactionAbortController: AbortController | undefined;\n\t_autoCompactionAbortController: AbortController | undefined;\n\t_overflowRecoveryAttempted: boolean;\n\t_branchSummaryAbortController: AbortController | undefined;\n\t_retryAbortController: AbortController | undefined;\n\t_retryAttempt: number;\n\t_retryPromise: Promise<void> | undefined;\n\t_retryResolve: (() => void) | undefined;\n\t_bashAbortController: AbortController | undefined;\n\t_pendingBashMessages: BashExecutionMessage[];\n\t_extensionRunner: ExtensionRunner;\n\t_turnIndex: number;\n\t_resourceLoader: ResourceLoader;\n\t_customTools: ToolDefinition[];\n\t_baseToolDefinitions: Map<string, ToolDefinition>;\n\t_cwd: string;\n\t_extensionRunnerRef?: { current?: ExtensionRunner };\n\t_initialActiveToolNames?: string[];\n\t_allowedToolNames?: Set<string>;\n\t_excludedToolNames?: Set<string>;\n\t_baseToolsOverride?: Record<string, AgentTool>;\n\t_sessionStartEvent: SessionStartEvent;\n\t_orchestrationContext?: OrchestrationContext;\n\t_extensionUIContext?: ExtensionUIContext;\n\t_extensionMode: ExtensionMode;\n\t_extensionCommandContextActions?: ExtensionCommandContextActions;\n\t_extensionShutdownHandler?: () => void;\n\t_extensionErrorListener?: ExtensionErrorListener;\n\t_extensionErrorUnsubscriber?: () => void;\n\t_modelRegistry: ModelRegistry;\n\t_toolRegistry: Map<string, AgentTool>;\n\t_toolDefinitions: Map<string, ToolDefinitionEntry>;\n\t_toolPromptSnippets: Map<string, string>;\n\t_toolPromptGuidelines: Map<string, string[]>;\n\t_baseSystemPrompt: string;\n\t_baseSystemPromptOptions: BuildSystemPromptOptions;\n\t_systemPromptOverride?: string;\n\t_lastAssistantMessage: AssistantMessage | undefined;\n}\n\n"]}
|
|
1
|
+
{"version":3,"file":"agent-session-methods.js","sourceRoot":"","sources":["../../src/core/agent-session-methods.ts"],"names":[],"mappings":"","sourcesContent":["import type { Agent, AgentEvent, AgentMessage, AgentState, AgentTool, ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { Api, AssistantMessage, ImageContent, Message, Model, TextContent } from \"@earendil-works/pi-ai/compat\";\nimport type { BashResult } from \"./bash-executor.ts\";\nimport type {\n\tContextCompactionParameters,\n\tContextCompactionResult,\n} from \"./compaction/index.ts\";\nimport type {\n\tContextUsage,\n\tExtensionCommandContextActions,\n\tExtensionErrorListener,\n\tExtensionMode,\n\tExtensionRunner,\n\tExtensionUIContext,\n\tOrchestrationContext,\n\tReplacedSessionContext,\n\tSessionStartEvent,\n\tToolDefinition,\n\tToolInfo,\n} from \"./extensions/index.ts\";\nimport type { BashExecutionMessage, CustomMessage } from \"./messages.ts\";\nimport type { ModelRegistry } from \"./model-registry.ts\";\nimport type { PromptTemplate } from \"./prompt-templates.ts\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport type { BranchSummaryEntry, SessionManager } from \"./session-manager.ts\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\nimport type { BuildSystemPromptOptions } from \"./system-prompt.ts\";\nimport type { BashOperations } from \"./tools/bash.ts\";\nimport type {\n\tAgentSessionEvent,\n\tAgentSessionEventListener,\n\tContextWindowReplayRequest,\n\tContextWindowReplaySource,\n\tDrainedAgentQueues,\n\tExtensionBindings,\n\tInterruptQueueHold,\n\tModelCycleResult,\n\tPromptOptions,\n\tSessionStats,\n\tToolDefinitionEntry,\n} from \"./agent-session-types.ts\";\nimport type { SendMessageOptions } from \"./extensions/index.ts\";\n\nexport interface ContextCompactionApplyOptions {\n\tresolvePlannerAuth: () => Promise<{ apiKey: string; headers?: Record<string, string> } | undefined>;\n\tabortController: AbortController;\n\tbackupLabel: string;\n\tcompression_ratio?: number;\n\tpreserve_recent?: number;\n\tquery?: string;\n\treason: \"manual\" | \"threshold\" | \"overflow\";\n}\n\nexport interface ExtensionResourcePathEntry {\n\tpath: string;\n\textensionPath: string;\n}\n\nexport interface ExtensionResourcePathResult {\n\tpath: string;\n\tmetadata: { source: string; scope: \"temporary\"; origin: \"top-level\"; baseDir?: string };\n}\n\nexport interface RuntimeBuildOptions {\n\tactiveToolNames?: string[];\n\tflagValues?: Map<string, boolean | string>;\n\tincludeAllExtensionTools?: boolean;\n}\n\nexport interface ContextWindowReplayResult {\n\tmodel: Model<Api>;\n\tcontextWindow: number;\n\twouldWarn: boolean;\n}\n\nexport interface AgentSessionMethodSurface {\n\treadonly orchestrationContext: import(\"./extensions/index.ts\").OrchestrationContext | undefined;\n\treadonly modelRegistry: ModelRegistry;\n\treadonly state: AgentState;\n\treadonly model: Model<Api> | undefined;\n\treadonly thinkingLevel: ThinkingLevel;\n\treadonly isStreaming: boolean;\n\treadonly systemPrompt: string;\n\treadonly retryAttempt: number;\n\treadonly isCompacting: boolean;\n\treadonly messages: AgentMessage[];\n\treadonly steeringMode: \"all\" | \"one-at-a-time\";\n\treadonly followUpMode: \"all\" | \"one-at-a-time\";\n\treadonly sessionFile: string | undefined;\n\treadonly sessionId: string;\n\treadonly sessionName: string | undefined;\n\treadonly scopedModels: ReadonlyArray<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\treadonly promptTemplates: ReadonlyArray<PromptTemplate>;\n\treadonly pendingMessageCount: number;\n\treadonly resourceLoader: ResourceLoader;\n\treadonly autoCompactionEnabled: boolean;\n\treadonly isRetrying: boolean;\n\treadonly autoRetryEnabled: boolean;\n\treadonly isBashRunning: boolean;\n\treadonly hasPendingBashMessages: boolean;\n\treadonly extensionRunner: ExtensionRunner;\n\n\t_handleAgentEvent(event: AgentEvent): void;\n\t_getRequiredRequestAuth(model: Model<Api>): Promise<{ apiKey: string; headers?: Record<string, string> }>;\n\t_installAgentToolHooks(): void;\n\t_installAgentNextTurnRefresh(): void;\n\t_emit(event: AgentSessionEvent): void;\n\t_emitQueueUpdate(): void;\n\t_createRetryPromiseForAgentEnd(event: AgentEvent): void;\n\t_findLastAssistantInMessages(messages: AgentMessage[]): AssistantMessage | undefined;\n\t_processAgentEvent(event: AgentEvent): Promise<void>;\n\t_applyInterruptAbortMessage(event: AgentEvent): void;\n\t_applyProviderErrorGuidance(event: AgentEvent): void;\n\t_resolveRetry(): void;\n\t_getUserMessageText(message: Message): string;\n\t_findLastAssistantMessage(): AssistantMessage | undefined;\n\t_replaceMessageInPlace(target: AgentMessage, replacement: AgentMessage): void;\n\t_emitExtensionEvent(event: AgentEvent): Promise<void>;\n\tsubscribe(listener: AgentSessionEventListener): () => void;\n\t_disconnectFromAgent(): void;\n\t_reconnectToAgent(): void;\n\tdispose(): void;\n\n\tgetActiveToolNames(): string[];\n\tgetAllTools(): ToolInfo[];\n\tgetToolDefinition(name: string): ToolDefinition | undefined;\n\tsetActiveToolsByName(toolNames: string[]): void;\n\tsetScopedModels(scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>): void;\n\t_normalizePromptSnippet(text: string | undefined): string | undefined;\n\t_normalizePromptGuidelines(guidelines: string[] | undefined): string[];\n\t_rebuildSystemPrompt(toolNames: string[]): string;\n\t_refreshBaseSystemPromptFromActiveTools(): void;\n\n\tprompt(text: string, options?: PromptOptions): Promise<void>;\n\t_runAgentPrompt(messages: AgentMessage | AgentMessage[]): Promise<void>;\n\t_runAgentContinue(): Promise<void>;\n\t_continueQueuedAgentMessages(): Promise<void>;\n\t_tryExecuteBuiltinSlashCommand(text: string): Promise<boolean>;\n\t_tryExecuteExtensionCommand(text: string): Promise<boolean>;\n\t_expandSkillCommand(text: string): string;\n\tsteer(text: string, images?: ImageContent[]): Promise<void>;\n\tfollowUp(text: string, images?: ImageContent[]): Promise<void>;\n\tsendUserMessage(\n\t\tcontent: string | (TextContent | ImageContent)[],\n\t\toptions?: { deliverAs?: \"steer\" | \"followUp\" },\n\t): Promise<void>;\n\n\t_queueSteer(text: string, images?: ImageContent[]): Promise<void>;\n\t_queueFollowUp(text: string, images?: ImageContent[]): Promise<void>;\n\t_throwIfExtensionCommand(text: string): void;\n\tsendCustomMessage<T = unknown>(\n\t\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\t\toptions?: SendMessageOptions,\n\t): Promise<void>;\n\t_appendCustomMessage<T>(message: CustomMessage<T>): void;\n\t_enqueueInterruptCustomMessage<T>(message: CustomMessage<T>, options?: SendMessageOptions): Promise<void>;\n\t_sendInterruptCustomMessageNow<T>(message: CustomMessage<T>, options?: SendMessageOptions): Promise<void>;\n\t_ensureActiveInterruptQueueHold(): InterruptQueueHold;\n\t_restoreAndClearActiveInterruptQueueHold(): void;\n\t_queueAgentMessage(message: AgentMessage, delivery: \"steer\" | \"followUp\"): void;\n\t_drainQueuedAgentMessages(): DrainedAgentQueues;\n\t_restoreQueuedAgentMessages(queues: DrainedAgentQueues): void;\n\tclearQueue(): { steering: string[]; followUp: string[] };\n\tgetSteeringMessages(): readonly string[];\n\tgetFollowUpMessages(): readonly string[];\n\tabort(): Promise<void>;\n\tsetSteeringMode(mode: \"all\" | \"one-at-a-time\"): void;\n\tsetFollowUpMode(mode: \"all\" | \"one-at-a-time\"): void;\n\n\t_emitModelChanged(nextModel: Model<Api>, previousModel: Model<Api> | undefined, source: \"set\" | \"cycle\" | \"restore\"): void;\n\t_emitModelSelect(nextModel: Model<Api>, previousModel: Model<Api> | undefined, source: \"set\" | \"cycle\" | \"restore\"): Promise<void>;\n\tsetModel(model: Model<Api>): Promise<void>;\n\tcycleModel(direction?: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined>;\n\t_cycleScopedModel(direction: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined>;\n\t_cycleAvailableModel(direction: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined>;\n\tsetThinkingLevel(level: ThinkingLevel): void;\n\tcycleThinkingLevel(): ThinkingLevel | undefined;\n\tgetAvailableThinkingLevels(): ThinkingLevel[];\n\tsupportsThinking(): boolean;\n\t_getThinkingLevelForModelSwitch(explicitLevel?: ThinkingLevel): ThinkingLevel;\n\t_clampThinkingLevel(level: ThinkingLevel, availableLevels: ThinkingLevel[]): ThinkingLevel;\n\tgetAvailableContextWindows(): number[];\n\tsupportsContextWindowSelection(): boolean;\n\tsetContextWindow(contextWindow: number, options?: { persistDefault?: boolean }): void;\n\t_withContextWindowForModelSwitch(model: Model<Api>): Model<Api>;\n\t_shouldCarryCurrentContextWindowForModelSwitch(currentModel: Model<Api>, settingsDefaultContextWindow: number | undefined): boolean;\n\t_getSettingsContextWindowRequestForModel(model: Model<Api>): ContextWindowReplayRequest | undefined;\n\t_getContextWindowReplayForModel(model: Model<Api>, requestedContextWindow: number | undefined, source: ContextWindowReplaySource | undefined): ContextWindowReplayResult;\n\t_getDefaultContextWindowReplayForModel(model: Model<Api>, wouldWarn: boolean): ContextWindowReplayResult;\n\t_getResumeContextWindowReplayForModel(model: Model<Api>): ContextWindowReplayResult;\n\t_applyContextWindowReplay(contextWindow: number | undefined): void;\n\t_appendContextWindowChangeIfChanged(previousModel: Model<Api> | undefined, nextModel: Model<Api>): void;\n\n\t_applyContextVerbatimCompaction(options: ContextCompactionApplyOptions): Promise<ContextCompactionResult | undefined>;\n\tcompact(options?: Partial<ContextCompactionParameters>): Promise<ContextCompactionResult>;\n\tcontextCompact(): Promise<ContextCompactionResult>;\n\tabortCompaction(): void;\n\tabortBranchSummary(): void;\n\t_checkCompaction(assistantMessage: AssistantMessage, skipAbortedCheck?: boolean): Promise<void>;\n\t_isCopilotServerCapBelowSelectedContextWindow(assistantMessage: AssistantMessage): boolean;\n\t_dropTrailingOverflowAssistantErrorIfPresent(): void;\n\t_schedulePostAutoCompactionContinuationProbe(reason: \"overflow\" | \"threshold\", willRetry: boolean): void;\n\t_resumeAfterAutoCompaction(): void;\n\t_runAutoCompaction(reason: \"overflow\" | \"threshold\", willRetry: boolean): Promise<void>;\n\tsetAutoCompactionEnabled(enabled: boolean): void;\n\n\tbindExtensions(bindings: ExtensionBindings): Promise<void>;\n\textendResourcesFromExtensions(reason: \"startup\" | \"reload\"): Promise<void>;\n\tbuildExtensionResourcePaths(entries: ExtensionResourcePathEntry[]): ExtensionResourcePathResult[];\n\tgetExtensionSourceLabel(extensionPath: string): string;\n\t_applyExtensionBindings(runner: ExtensionRunner): void;\n\t_refreshCurrentModelFromRegistry(): void;\n\trefreshCurrentModelFromRegistry(): void;\n\t_bindExtensionCore(runner: ExtensionRunner): void;\n\t_refreshToolRegistry(options?: { activeToolNames?: string[]; includeAllExtensionTools?: boolean }): void;\n\t_buildRuntime(options: RuntimeBuildOptions): void;\n\treload(): Promise<void>;\n\n\t_isRetryableError(message: AssistantMessage): boolean;\n\t_normalizePersistedGeminiToolArgs(message: AssistantMessage): void;\n\t_isEmptyCompletion(message: AssistantMessage): boolean;\n\t_handleRetryableError(message: AssistantMessage): Promise<boolean>;\n\tabortRetry(): void;\n\twaitForRetry(): Promise<void>;\n\tsetAutoRetryEnabled(enabled: boolean): void;\n\n\texecuteBash(command: string, onChunk?: (chunk: string) => void, options?: { excludeFromContext?: boolean; operations?: BashOperations }): Promise<BashResult>;\n\trecordBashResult(command: string, result: BashResult, options?: { excludeFromContext?: boolean }): void;\n\tabortBash(): void;\n\t_flushPendingBashMessages(): void;\n\n\tsetSessionName(name: string): void;\n\tnavigateTree(targetId: string, options?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string }): Promise<{ editorText?: string; cancelled: boolean; aborted?: boolean; summaryEntry?: BranchSummaryEntry }>;\n\tgetUserMessagesForForking(): Array<{ entryId: string; text: string }>;\n\t_extractUserMessageText(content: string | Array<{ type: string; text?: string }>): string;\n\n\tgetSessionStats(): SessionStats;\n\tgetContextUsage(): ContextUsage | undefined;\n\texportToHtml(outputPath?: string): Promise<string>;\n\texportToJsonl(outputPath?: string): string;\n\tgetLastAssistantText(): string | undefined;\n\tcreateReplacedSessionContext(): ReplacedSessionContext;\n\thasExtensionHandlers(eventType: string): boolean;\n}\n\nexport interface AgentSessionPublicSurface extends Pick<AgentSessionMethodSurface,\n\t| \"orchestrationContext\"\n\t| \"modelRegistry\"\n\t| \"state\"\n\t| \"model\"\n\t| \"thinkingLevel\"\n\t| \"isStreaming\"\n\t| \"systemPrompt\"\n\t| \"retryAttempt\"\n\t| \"isCompacting\"\n\t| \"messages\"\n\t| \"steeringMode\"\n\t| \"followUpMode\"\n\t| \"sessionFile\"\n\t| \"sessionId\"\n\t| \"sessionName\"\n\t| \"scopedModels\"\n\t| \"promptTemplates\"\n\t| \"pendingMessageCount\"\n\t| \"resourceLoader\"\n\t| \"autoCompactionEnabled\"\n\t| \"isRetrying\"\n\t| \"autoRetryEnabled\"\n\t| \"isBashRunning\"\n\t| \"hasPendingBashMessages\"\n\t| \"extensionRunner\"\n\t| \"subscribe\"\n\t| \"dispose\"\n\t| \"getActiveToolNames\"\n\t| \"getAllTools\"\n\t| \"getToolDefinition\"\n\t| \"setActiveToolsByName\"\n\t| \"setScopedModels\"\n\t| \"prompt\"\n\t| \"steer\"\n\t| \"followUp\"\n\t| \"sendCustomMessage\"\n\t| \"sendUserMessage\"\n\t| \"clearQueue\"\n\t| \"getSteeringMessages\"\n\t| \"getFollowUpMessages\"\n\t| \"abort\"\n\t| \"setModel\"\n\t| \"cycleModel\"\n\t| \"setThinkingLevel\"\n\t| \"cycleThinkingLevel\"\n\t| \"getAvailableThinkingLevels\"\n\t| \"supportsThinking\"\n\t| \"getAvailableContextWindows\"\n\t| \"supportsContextWindowSelection\"\n\t| \"setContextWindow\"\n\t| \"setSteeringMode\"\n\t| \"setFollowUpMode\"\n\t| \"compact\"\n\t| \"contextCompact\"\n\t| \"abortCompaction\"\n\t| \"abortBranchSummary\"\n\t| \"setAutoCompactionEnabled\"\n\t| \"bindExtensions\"\n\t| \"refreshCurrentModelFromRegistry\"\n\t| \"reload\"\n\t| \"abortRetry\"\n\t| \"setAutoRetryEnabled\"\n\t| \"executeBash\"\n\t| \"recordBashResult\"\n\t| \"abortBash\"\n\t| \"setSessionName\"\n\t| \"navigateTree\"\n\t| \"getUserMessagesForForking\"\n\t| \"getSessionStats\"\n\t| \"getContextUsage\"\n\t| \"exportToHtml\"\n\t| \"exportToJsonl\"\n\t| \"getLastAssistantText\"\n\t| \"createReplacedSessionContext\"\n\t| \"hasExtensionHandlers\"\n> {\n\treadonly agent: Agent;\n\treadonly sessionManager: SessionManager;\n\treadonly settingsManager: SettingsManager;\n}\n\nexport interface AgentSessionInternalSurface extends AgentSessionMethodSurface, AgentSessionPublicSurface {\n\t_scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\t_unsubscribeAgent?: () => void;\n\t_eventListeners: AgentSessionEventListener[];\n\t_agentEventQueue: Promise<void>;\n\t_steeringMessages: string[];\n\t_followUpMessages: string[];\n\t_interruptDeliveryQueue: Promise<void>;\n\t_pendingInterruptDeliveries: number;\n\t_activeInterruptQueueHold: InterruptQueueHold | undefined;\n\t_activeInterruptAbortMessage: string | undefined;\n\t_pendingNextTurnMessages: CustomMessage[];\n\t_compactionAbortController: AbortController | undefined;\n\t_autoCompactionAbortController: AbortController | undefined;\n\t_overflowRecoveryAttempted: boolean;\n\t_branchSummaryAbortController: AbortController | undefined;\n\t_retryAbortController: AbortController | undefined;\n\t_retryAttempt: number;\n\t_retryPromise: Promise<void> | undefined;\n\t_retryResolve: (() => void) | undefined;\n\t_bashAbortController: AbortController | undefined;\n\t_pendingBashMessages: BashExecutionMessage[];\n\t_extensionRunner: ExtensionRunner;\n\t_turnIndex: number;\n\t_resourceLoader: ResourceLoader;\n\t_customTools: ToolDefinition[];\n\t_baseToolDefinitions: Map<string, ToolDefinition>;\n\t_cwd: string;\n\t_extensionRunnerRef?: { current?: ExtensionRunner };\n\t_initialActiveToolNames?: string[];\n\t_allowedToolNames?: Set<string>;\n\t_excludedToolNames?: Set<string>;\n\t_baseToolsOverride?: Record<string, AgentTool>;\n\t_sessionStartEvent: SessionStartEvent;\n\t_orchestrationContext?: OrchestrationContext;\n\t_extensionUIContext?: ExtensionUIContext;\n\t_extensionMode: ExtensionMode;\n\t_extensionCommandContextActions?: ExtensionCommandContextActions;\n\t_extensionShutdownHandler?: () => void;\n\t_extensionErrorListener?: ExtensionErrorListener;\n\t_extensionErrorUnsubscriber?: () => void;\n\t_modelRegistry: ModelRegistry;\n\t_toolRegistry: Map<string, AgentTool>;\n\t_toolDefinitions: Map<string, ToolDefinitionEntry>;\n\t_toolPromptSnippets: Map<string, string>;\n\t_toolPromptGuidelines: Map<string, string[]>;\n\t_baseSystemPrompt: string;\n\t_baseSystemPromptOptions: BuildSystemPromptOptions;\n\t_systemPromptOverride?: string;\n\t_lastAssistantMessage: AssistantMessage | undefined;\n}\n\n"]}
|
|
@@ -1,53 +1,32 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* GitHub's Copilot API (CAPI) exposes distinct model limits via `GET {baseUrl}/models`:
|
|
5
|
-
*
|
|
6
|
-
* - `capabilities.limits.max_context_window_tokens` is the model's total context capacity
|
|
7
|
-
* (prompt + completion reserve).
|
|
8
|
-
* - `capabilities.limits.max_prompt_tokens` is the maximum prompt/input budget Atomic can safely
|
|
9
|
-
* fill before the provider must reserve output tokens.
|
|
10
|
-
* - `billing.token_prices.<tier>.context_max` is a prompt-token billing/selection threshold. The
|
|
11
|
-
* `default` tier is the short prompt budget (e.g. gpt-5.5 272k, Claude 200k); a
|
|
12
|
-
* `long_context` tier adds a selectable larger prompt budget (e.g. gpt-5.5 922k, Claude 936k).
|
|
13
|
-
*
|
|
14
|
-
* Atomic shows the model's full context window for the selectable long tier (the
|
|
15
|
-
* `max_context_window_tokens` total, e.g. 1_000_000/1_050_000), matching how the native `openai/*`
|
|
16
|
-
* and `anthropic/*` providers advertise these models. Because GitHub enforces a lower server-side
|
|
17
|
-
* prompt cap (`max_prompt_tokens`, e.g. 936k/922k) below that total, the prompt cap is retained as
|
|
18
|
-
* an internal effective input budget (`CopilotModelContext.maxInputTokens`) that drives compaction
|
|
19
|
-
* thresholds and the overflow-recovery guard, so the branded total can be displayed without
|
|
20
|
-
* overrunning the server limit. The default (short) tier stays at the `default` billing tier's
|
|
21
|
-
* prompt budget.
|
|
22
|
-
*
|
|
23
|
-
* This data is intentionally NOT baked into a static map: GitHub adds/removes models and retiers
|
|
24
|
-
* windows over time (e.g. a model that disappears from the catalog), so a hardcoded snapshot goes
|
|
25
|
-
* stale. Instead the catalog is fetched live (gated on the user actually having the GitHub Copilot
|
|
26
|
-
* provider) and cached on disk for a short TTL, exactly like the Copilot CLI.
|
|
27
|
-
*/
|
|
28
|
-
/** Resolved input-token context window(s) for a single Copilot model. */
|
|
1
|
+
/** GitHub Copilot CAPI model catalog parsing, active state, and disk cache. */
|
|
2
|
+
/** Resolved input-token context window(s) and optional synthesis metadata for a single Copilot model. */
|
|
29
3
|
export interface CopilotModelContext {
|
|
30
|
-
/**
|
|
31
|
-
* Base/displayed context window — shown in the footer. The default tier's `context_max`, or the
|
|
32
|
-
* model-level `max_prompt_tokens` fallback otherwise.
|
|
33
|
-
*/
|
|
34
4
|
contextWindow: number;
|
|
35
|
-
/**
|
|
36
|
-
* Selectable windows (`[default, long]`) when the model exposes a `long_context` tier larger than
|
|
37
|
-
* its default; absent for single-window models. The long entry is the model's full
|
|
38
|
-
* `max_context_window_tokens` (total capacity) when advertised, matching `openai/*` and
|
|
39
|
-
* `anthropic/*`.
|
|
40
|
-
*/
|
|
41
5
|
contextWindowOptions?: readonly number[];
|
|
42
|
-
/**
|
|
43
|
-
* Hard prompt/input cap (`max_prompt_tokens`) when it sits below the displayed long window. Used
|
|
44
|
-
* as the effective input budget for compaction thresholds and overflow recovery so the branded
|
|
45
|
-
* total can be shown without overrunning GitHub's server-side prompt limit. Absent when the
|
|
46
|
-
* displayed window already equals the input cap.
|
|
47
|
-
*/
|
|
48
6
|
maxInputTokens?: number;
|
|
7
|
+
maxTokens?: number;
|
|
8
|
+
displayName?: string;
|
|
9
|
+
vendor?: string;
|
|
10
|
+
supportedEndpoints?: readonly string[];
|
|
11
|
+
supports?: CopilotModelSupports;
|
|
12
|
+
limits?: CopilotModelLimits;
|
|
13
|
+
modelPickerEnabled?: boolean;
|
|
14
|
+
policyState?: string;
|
|
15
|
+
type?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface CopilotModelSupports {
|
|
18
|
+
adaptiveThinking?: boolean;
|
|
19
|
+
maxThinkingBudget?: boolean;
|
|
20
|
+
minThinkingBudget?: boolean;
|
|
21
|
+
parallelToolCalls?: boolean;
|
|
22
|
+
reasoningEffort?: boolean;
|
|
23
|
+
reasoningEffortLevels?: readonly string[];
|
|
24
|
+
streaming?: boolean;
|
|
25
|
+
structuredOutputs?: boolean;
|
|
26
|
+
toolCalls?: boolean;
|
|
27
|
+
vision?: boolean;
|
|
49
28
|
}
|
|
50
|
-
/** Map of model id → resolved
|
|
29
|
+
/** Map of model id → resolved context window(s) plus optional synthesis metadata. */
|
|
51
30
|
export type CopilotModelCatalog = ReadonlyMap<string, CopilotModelContext>;
|
|
52
31
|
/** Safety fallback when a model reports neither `max_prompt_tokens` nor `max_context_window_tokens`. */
|
|
53
32
|
export declare const COPILOT_CONTEXT_WINDOW_FALLBACK = 128000;
|
|
@@ -72,39 +51,15 @@ export declare function copilotTokenFromEnvironment(env?: CopilotEnvironment): s
|
|
|
72
51
|
/** Disk-cache freshness window, matching the Copilot CLI's list-models cache TTL. */
|
|
73
52
|
export declare const COPILOT_CATALOG_CACHE_TTL_MS: number;
|
|
74
53
|
/** Current on-disk cache schema version. */
|
|
75
|
-
export declare const COPILOT_CATALOG_CACHE_VERSION:
|
|
76
|
-
/**
|
|
77
|
-
* Resolve the Copilot CAPI base URL.
|
|
78
|
-
*
|
|
79
|
-
* Copilot access tokens embed a `proxy-ep=proxy.<host>` segment; the API host is the same host with
|
|
80
|
-
* `proxy.` swapped for `api.`. Env-token routing resolves explicit `COPILOT_API_TARGET` /
|
|
81
|
-
* `GITHUB_COPILOT_BASE_URL` overrides, then `GITHUB_SERVER_URL` (`*.ghe.com` ->
|
|
82
|
-
* `copilot-api.<tenant>.ghe.com`, other non-github.com -> `api.enterprise.githubcopilot.com`),
|
|
83
|
-
* then the public Copilot routing hub `api.githubcopilot.com` for `COPILOT_GITHUB_TOKEN`. Stored
|
|
84
|
-
* OAuth credentials still fall back to the generated individual host when no token route is known.
|
|
85
|
-
*/
|
|
54
|
+
export declare const COPILOT_CATALOG_CACHE_VERSION: 5;
|
|
86
55
|
export declare function copilotApiBaseUrlFromToken(token: string | undefined, enterpriseDomain?: string, env?: CopilotEnvironment): string;
|
|
87
|
-
/** Raw token limits parsed from a CAPI model entry. */
|
|
88
56
|
export interface CopilotModelLimits {
|
|
89
|
-
/** `capabilities.limits.max_prompt_tokens` — maximum prompt/input budget (the hard input cap). */
|
|
90
57
|
maxPromptTokens?: number;
|
|
91
|
-
/** `capabilities.limits.max_context_window_tokens` — total context capacity (the displayed long tier). */
|
|
92
58
|
maxContextWindowTokens?: number;
|
|
93
|
-
/** `capabilities.limits.max_output_tokens` — output reserve; derives the input cap when `max_prompt_tokens` is absent. */
|
|
94
59
|
maxOutputTokens?: number;
|
|
95
|
-
/** `billing.token_prices.default.context_max` — default-tier prompt threshold. */
|
|
96
60
|
defaultContextMax?: number;
|
|
97
|
-
/** `billing.token_prices.long_context.context_max` — long-context prompt threshold. */
|
|
98
61
|
longContextMax?: number;
|
|
99
62
|
}
|
|
100
|
-
/**
|
|
101
|
-
* Resolve a model's input-token context window(s) from its CAPI limits.
|
|
102
|
-
*
|
|
103
|
-
* `contextWindow` is the model's base input budget — the default tier's `context_max` when tiered,
|
|
104
|
-
* otherwise `max_prompt_tokens ?? max_context_window_tokens ?? 128_000`. A `long_context` tier that
|
|
105
|
-
* is larger than the base adds a second selectable window. Returns `undefined` when the entry
|
|
106
|
-
* carries no usable limit signal at all.
|
|
107
|
-
*/
|
|
108
63
|
export declare function resolveCopilotModelContext(limits: CopilotModelLimits): CopilotModelContext | undefined;
|
|
109
64
|
/**
|
|
110
65
|
* Parse a raw CAPI `/models` response body into an input-token context-window catalog.
|
|
@@ -140,13 +95,9 @@ export interface ReadCopilotCatalogCacheOptions {
|
|
|
140
95
|
/** Freshness window; defaults to {@link COPILOT_CATALOG_CACHE_TTL_MS}. */
|
|
141
96
|
ttlMs?: number;
|
|
142
97
|
}
|
|
143
|
-
/** Read a fresh, host-matching catalog from the cache file, or `undefined` if missing/stale/invalid. */
|
|
144
98
|
export declare function readCopilotCatalogCache(path: string, options: ReadCopilotCatalogCacheOptions): CopilotModelCatalog | undefined;
|
|
145
|
-
/** Write the catalog to the cache file (creating parent dirs). Best-effort; never throws. */
|
|
146
99
|
export declare function writeCopilotCatalogCache(path: string, baseUrl: string, catalog: CopilotModelCatalog, now?: number): void;
|
|
147
|
-
/** Host component of a base URL, for matching {@link readCopilotCatalogCache} `host`. */
|
|
148
100
|
export declare function copilotCatalogCacheHost(baseUrl: string): string;
|
|
149
|
-
/** Standard on-disk cache path for the Copilot model catalog under an agent directory. */
|
|
150
101
|
export declare function copilotCatalogCachePath(agentDir: string): string;
|
|
151
102
|
/**
|
|
152
103
|
* Seed the active catalog synchronously from the on-disk cache, gated on a Copilot access token.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copilot-model-catalog.d.ts","sourceRoot":"","sources":["../../src/core/copilot-model-catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAKH,yEAAyE;AACzE,MAAM,WAAW,mBAAmB;IACnC;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,gEAAgE;AAChE,MAAM,MAAM,mBAAmB,GAAG,WAAW,CAAC,MAAM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ED,6FAA6F;AAC7F,wBAAgB,wBAAwB,CACvC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,mBAAmB,EAC5B,GAAG,CAAC,EAAE,MAAM,GACV,IAAI,CAaN;AAED,yFAAyF;AACzF,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED,0FAA0F;AAC1F,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED;;;;;;;;;GASG;AACH,wBAAgB,sCAAsC,CACrD,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,SAAS,EAAE,MAAM,EACjB,GAAG,CAAC,EAAE,MAAM,GACV,OAAO,CAOT","sourcesContent":["/**\n * GitHub Copilot model catalog (CAPI) — dynamic prompt-token budgets.\n *\n * GitHub's Copilot API (CAPI) exposes distinct model limits via `GET {baseUrl}/models`:\n *\n * - `capabilities.limits.max_context_window_tokens` is the model's total context capacity\n * (prompt + completion reserve).\n * - `capabilities.limits.max_prompt_tokens` is the maximum prompt/input budget Atomic can safely\n * fill before the provider must reserve output tokens.\n * - `billing.token_prices.<tier>.context_max` is a prompt-token billing/selection threshold. The\n * `default` tier is the short prompt budget (e.g. gpt-5.5 272k, Claude 200k); a\n * `long_context` tier adds a selectable larger prompt budget (e.g. gpt-5.5 922k, Claude 936k).\n *\n * Atomic shows the model's full context window for the selectable long tier (the\n * `max_context_window_tokens` total, e.g. 1_000_000/1_050_000), matching how the native `openai/*`\n * and `anthropic/*` providers advertise these models. Because GitHub enforces a lower server-side\n * prompt cap (`max_prompt_tokens`, e.g. 936k/922k) below that total, the prompt cap is retained as\n * an internal effective input budget (`CopilotModelContext.maxInputTokens`) that drives compaction\n * thresholds and the overflow-recovery guard, so the branded total can be displayed without\n * overrunning the server limit. The default (short) tier stays at the `default` billing tier's\n * prompt budget.\n *\n * This data is intentionally NOT baked into a static map: GitHub adds/removes models and retiers\n * windows over time (e.g. a model that disappears from the catalog), so a hardcoded snapshot goes\n * stale. Instead the catalog is fetched live (gated on the user actually having the GitHub Copilot\n * provider) and cached on disk for a short TTL, exactly like the Copilot CLI.\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\n\n/** Resolved input-token context window(s) for a single Copilot model. */\nexport interface CopilotModelContext {\n\t/**\n\t * Base/displayed context window — shown in the footer. The default tier's `context_max`, or the\n\t * model-level `max_prompt_tokens` fallback otherwise.\n\t */\n\tcontextWindow: number;\n\t/**\n\t * Selectable windows (`[default, long]`) when the model exposes a `long_context` tier larger than\n\t * its default; absent for single-window models. The long entry is the model's full\n\t * `max_context_window_tokens` (total capacity) when advertised, matching `openai/*` and\n\t * `anthropic/*`.\n\t */\n\tcontextWindowOptions?: readonly number[];\n\t/**\n\t * Hard prompt/input cap (`max_prompt_tokens`) when it sits below the displayed long window. Used\n\t * as the effective input budget for compaction thresholds and overflow recovery so the branded\n\t * total can be shown without overrunning GitHub's server-side prompt limit. Absent when the\n\t * displayed window already equals the input cap.\n\t */\n\tmaxInputTokens?: number;\n}\n\n/** Map of model id → resolved input-token context window(s). */\nexport type CopilotModelCatalog = ReadonlyMap<string, CopilotModelContext>;\n\n/** Safety fallback when a model reports neither `max_prompt_tokens` nor `max_context_window_tokens`. */\nexport const COPILOT_CONTEXT_WINDOW_FALLBACK = 128_000;\n\nexport const COPILOT_CATALOG_API_VERSION = \"2026-06-01\";\n\n/**\n * Headers GitHub's CAPI expects for catalog reads. Mirrors the editor headers pi-ai already sends\n * for Copilot token refresh and model-policy calls, plus the dated API version.\n */\nexport const COPILOT_CATALOG_HEADERS: Readonly<Record<string, string>> = {\n\t\"User-Agent\": \"GitHubCopilotChat/0.35.0\",\n\t\"Editor-Version\": \"vscode/1.107.0\",\n\t\"Editor-Plugin-Version\": \"copilot-chat/0.35.0\",\n\t\"Copilot-Integration-Id\": \"vscode-chat\",\n\t\"X-GitHub-Api-Version\": COPILOT_CATALOG_API_VERSION,\n};\n\n/** Default Copilot CAPI base URL for OAuth tokens when no route can be resolved. */\nexport const DEFAULT_COPILOT_API_BASE_URL = \"https://api.individual.githubcopilot.com\";\n\n/** GitHub Copilot public routing hub for PAT-based `COPILOT_GITHUB_TOKEN` auth. */\nexport const COPILOT_PUBLIC_API_BASE_URL = \"https://api.githubcopilot.com\";\n\n/** Enterprise Copilot CAPI host for GHES/non-github.com server URLs. */\nexport const COPILOT_ENTERPRISE_API_BASE_URL = \"https://api.enterprise.githubcopilot.com\";\n\nexport const COPILOT_GITHUB_TOKEN_ENV = \"COPILOT_GITHUB_TOKEN\";\nexport const COPILOT_API_TARGET_ENV = \"COPILOT_API_TARGET\";\nexport const GITHUB_COPILOT_BASE_URL_ENV = \"GITHUB_COPILOT_BASE_URL\";\nexport const GITHUB_SERVER_URL_ENV = \"GITHUB_SERVER_URL\";\n\ntype CopilotEnvironment = Record<string, string | undefined>;\n\nfunction normalizeCopilotApiBaseUrl(value: string | undefined): string | undefined {\n\tconst trimmed = value?.trim();\n\tif (!trimmed) return undefined;\n\tconst withScheme = /^https?:\\/\\//i.test(trimmed) ? trimmed : `https://${trimmed}`;\n\ttry {\n\t\tnew URL(withScheme);\n\t} catch {\n\t\treturn undefined;\n\t}\n\treturn withScheme.replace(/\\/+$/, \"\");\n}\n\nfunction explicitCopilotApiBaseUrlFromEnvironment(env: CopilotEnvironment): string | undefined {\n\treturn normalizeCopilotApiBaseUrl(env[COPILOT_API_TARGET_ENV]) ?? normalizeCopilotApiBaseUrl(env[GITHUB_COPILOT_BASE_URL_ENV]);\n}\n\nfunction copilotApiBaseUrlFromServerUrl(serverUrl: string | undefined): string | undefined {\n\tconst trimmed = serverUrl?.trim();\n\tif (!trimmed) return undefined;\n\ttry {\n\t\tconst parsed = new URL(trimmed.includes(\"://\") ? trimmed : `https://${trimmed}`);\n\t\tconst host = parsed.hostname.toLowerCase();\n\t\tif (!host || host === \"github.com\") return undefined;\n\t\tif (host.endsWith(\".ghe.com\")) return `https://copilot-api.${host}`;\n\t\treturn COPILOT_ENTERPRISE_API_BASE_URL;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction isCopilotEnvironmentToken(token: string | undefined, env: CopilotEnvironment): boolean {\n\tconst environmentToken = copilotTokenFromEnvironment(env);\n\treturn environmentToken !== undefined && token === environmentToken;\n}\n\nexport function copilotTokenFromEnvironment(env: CopilotEnvironment = process.env): string | undefined {\n\tconst token = env[COPILOT_GITHUB_TOKEN_ENV]?.trim();\n\treturn token ? token : undefined;\n}\n\n/** Disk-cache freshness window, matching the Copilot CLI's list-models cache TTL. */\nexport const COPILOT_CATALOG_CACHE_TTL_MS = 30 * 60 * 1000;\n\n/** Current on-disk cache schema version. */\nexport const COPILOT_CATALOG_CACHE_VERSION = 3 as const;\n\n/**\n * Resolve the Copilot CAPI base URL.\n *\n * Copilot access tokens embed a `proxy-ep=proxy.<host>` segment; the API host is the same host with\n * `proxy.` swapped for `api.`. Env-token routing resolves explicit `COPILOT_API_TARGET` /\n * `GITHUB_COPILOT_BASE_URL` overrides, then `GITHUB_SERVER_URL` (`*.ghe.com` ->\n * `copilot-api.<tenant>.ghe.com`, other non-github.com -> `api.enterprise.githubcopilot.com`),\n * then the public Copilot routing hub `api.githubcopilot.com` for `COPILOT_GITHUB_TOKEN`. Stored\n * OAuth credentials still fall back to the generated individual host when no token route is known.\n */\nexport function copilotApiBaseUrlFromToken(\n\ttoken: string | undefined,\n\tenterpriseDomain?: string,\n\tenv: CopilotEnvironment = process.env,\n): string {\n\tconst explicitOverride = explicitCopilotApiBaseUrlFromEnvironment(env);\n\tif (explicitOverride) return explicitOverride;\n\tif (token) {\n\t\tconst match = token.match(/proxy-ep=([^;]+)/);\n\t\tif (match) {\n\t\t\treturn `https://${match[1].replace(/^proxy\\./, \"api.\")}`;\n\t\t}\n\t}\n\tif (enterpriseDomain) return `https://copilot-api.${enterpriseDomain}`;\n\tconst serverUrlOverride = copilotApiBaseUrlFromServerUrl(env[GITHUB_SERVER_URL_ENV]);\n\tif (serverUrlOverride) return serverUrlOverride;\n\tif (isCopilotEnvironmentToken(token, env)) return COPILOT_PUBLIC_API_BASE_URL;\n\treturn DEFAULT_COPILOT_API_BASE_URL;\n}\n\nfunction trimTrailingSlash(url: string): string {\n\treturn url.replace(/\\/+$/, \"\");\n}\n\nfunction asRecord(value: unknown): Record<string, unknown> | undefined {\n\treturn value && typeof value === \"object\" ? (value as Record<string, unknown>) : undefined;\n}\n\nfunction toPositiveInt(value: unknown): number | undefined {\n\treturn typeof value === \"number\" && Number.isInteger(value) && value > 0 ? value : undefined;\n}\n\n/** Raw token limits parsed from a CAPI model entry. */\nexport interface CopilotModelLimits {\n\t/** `capabilities.limits.max_prompt_tokens` — maximum prompt/input budget (the hard input cap). */\n\tmaxPromptTokens?: number;\n\t/** `capabilities.limits.max_context_window_tokens` — total context capacity (the displayed long tier). */\n\tmaxContextWindowTokens?: number;\n\t/** `capabilities.limits.max_output_tokens` — output reserve; derives the input cap when `max_prompt_tokens` is absent. */\n\tmaxOutputTokens?: number;\n\t/** `billing.token_prices.default.context_max` — default-tier prompt threshold. */\n\tdefaultContextMax?: number;\n\t/** `billing.token_prices.long_context.context_max` — long-context prompt threshold. */\n\tlongContextMax?: number;\n}\n\n/**\n * Resolve a model's input-token context window(s) from its CAPI limits.\n *\n * `contextWindow` is the model's base input budget — the default tier's `context_max` when tiered,\n * otherwise `max_prompt_tokens ?? max_context_window_tokens ?? 128_000`. A `long_context` tier that\n * is larger than the base adds a second selectable window. Returns `undefined` when the entry\n * carries no usable limit signal at all.\n */\nexport function resolveCopilotModelContext(limits: CopilotModelLimits): CopilotModelContext | undefined {\n\tconst hasSignal =\n\t\tlimits.maxPromptTokens !== undefined ||\n\t\tlimits.maxContextWindowTokens !== undefined ||\n\t\tlimits.defaultContextMax !== undefined ||\n\t\tlimits.longContextMax !== undefined;\n\tif (!hasSignal) return undefined;\n\n\tconst maxInput = limits.maxPromptTokens ?? limits.maxContextWindowTokens ?? COPILOT_CONTEXT_WINDOW_FALLBACK;\n\tconst base = limits.defaultContextMax ?? maxInput;\n\tif (limits.longContextMax !== undefined && limits.longContextMax > base) {\n\t\t// Display the model's full context window as the long tier (matching openai/* and anthropic/*)\n\t\t// when CAPI advertises it; otherwise fall back to the long-context prompt threshold for\n\t\t// older/sparse payloads.\n\t\tconst longWindow = limits.maxContextWindowTokens ?? limits.longContextMax;\n\t\t// The hard prompt/input cap GitHub enforces server-side: prefer max_prompt_tokens, else derive\n\t\t// it from total − output reserve, else fall back to the long-context prompt threshold.\n\t\tconst derivedInputCap =\n\t\t\tlimits.maxContextWindowTokens !== undefined && limits.maxOutputTokens !== undefined\n\t\t\t\t? limits.maxContextWindowTokens - limits.maxOutputTokens\n\t\t\t\t: undefined;\n\t\tconst inputCap =\n\t\t\tlimits.maxPromptTokens ??\n\t\t\t(derivedInputCap !== undefined && derivedInputCap > 0 ? derivedInputCap : undefined) ??\n\t\t\tlimits.longContextMax;\n\t\t// Only carry the cap when the displayed long window actually exceeds it (the branded-total\n\t\t// case); when they coincide there is no gap and the input budget is just the window.\n\t\treturn longWindow > inputCap\n\t\t\t? { contextWindow: base, contextWindowOptions: [base, longWindow], maxInputTokens: inputCap }\n\t\t\t: { contextWindow: base, contextWindowOptions: [base, longWindow] };\n\t}\n\treturn { contextWindow: base };\n}\n\n/**\n * Parse a raw CAPI `/models` response body into an input-token context-window catalog.\n */\nexport function parseCopilotModelCatalog(body: unknown): CopilotModelCatalog {\n\tconst catalog = new Map<string, CopilotModelContext>();\n\tconst data = asRecord(body)?.data;\n\tif (!Array.isArray(data)) return catalog;\n\n\tfor (const entry of data) {\n\t\tconst record = asRecord(entry);\n\t\tif (!record) continue;\n\t\tconst id = record.id;\n\t\tif (typeof id !== \"string\" || id.length === 0) continue;\n\n\t\tconst limits = asRecord(asRecord(record.capabilities)?.limits);\n\t\tconst prices = asRecord(asRecord(record.billing)?.token_prices);\n\t\tconst context = resolveCopilotModelContext({\n\t\t\tmaxPromptTokens: toPositiveInt(limits?.max_prompt_tokens),\n\t\t\tmaxContextWindowTokens: toPositiveInt(limits?.max_context_window_tokens),\n\t\t\tmaxOutputTokens: toPositiveInt(limits?.max_output_tokens),\n\t\t\tdefaultContextMax: toPositiveInt(asRecord(prices?.default)?.context_max),\n\t\t\tlongContextMax: toPositiveInt(asRecord(prices?.long_context)?.context_max),\n\t\t});\n\t\tif (context) catalog.set(id, context);\n\t}\n\n\treturn catalog;\n}\n\nexport interface FetchCopilotModelCatalogOptions {\n\t/** Valid Copilot CAPI bearer token (e.g. from `modelRegistry.getApiKeyForProvider`). */\n\ttoken: string;\n\t/** Override the resolved base URL; defaults to one derived from the token. */\n\tbaseUrl?: string;\n\t/** Enterprise domain, used for base-URL resolution when the token lacks a `proxy-ep`. */\n\tenterpriseDomain?: string;\n\t/** Extra/override request headers. */\n\theaders?: Record<string, string>;\n\t/** Injectable `fetch` for testing. */\n\tfetchImpl?: typeof fetch;\n\t/** Abort signal. */\n\tsignal?: AbortSignal;\n}\n\n/** Fetch and parse the live Copilot model catalog from CAPI `GET {baseUrl}/models`. */\nexport async function fetchCopilotModelCatalog(options: FetchCopilotModelCatalogOptions): Promise<CopilotModelCatalog> {\n\tconst fetchImpl = options.fetchImpl ?? fetch;\n\tconst baseUrl = options.baseUrl ?? copilotApiBaseUrlFromToken(options.token, options.enterpriseDomain);\n\tconst response = await fetchImpl(`${trimTrailingSlash(baseUrl)}/models`, {\n\t\tmethod: \"GET\",\n\t\theaders: {\n\t\t\tAccept: \"application/json\",\n\t\t\tAuthorization: `Bearer ${options.token}`,\n\t\t\t...COPILOT_CATALOG_HEADERS,\n\t\t\t...options.headers,\n\t\t},\n\t\t...(options.signal ? { signal: options.signal } : {}),\n\t});\n\tif (!response.ok) {\n\t\tthrow new Error(`GitHub Copilot /models request failed: ${response.status} ${response.statusText}`);\n\t}\n\treturn parseCopilotModelCatalog(await response.json());\n}\n\n// ----------------------------------------------------------------------------\n// Active in-memory catalog (consulted by the model registry).\n//\n// Empty by default, so with no Copilot auth / no successful fetch the registry leaves Copilot\n// model context windows untouched and the picker never appears.\n// ----------------------------------------------------------------------------\n\nlet activeCatalog: CopilotModelCatalog = new Map();\n\n/** Replace the active catalog the registry derives context windows from. */\nexport function setActiveCopilotModelCatalog(catalog: CopilotModelCatalog): void {\n\tactiveCatalog = catalog;\n}\n\n/** The active catalog (empty until a successful auth-gated fetch/cache load). */\nexport function getActiveCopilotModelCatalog(): CopilotModelCatalog {\n\treturn activeCatalog;\n}\n\n/** Reset the active catalog (primarily for tests). */\nexport function clearActiveCopilotModelCatalog(): void {\n\tactiveCatalog = new Map();\n}\n\n// ----------------------------------------------------------------------------\n// Disk cache.\n// ----------------------------------------------------------------------------\n\ninterface CopilotCatalogCacheFile {\n\tversion: typeof COPILOT_CATALOG_CACHE_VERSION;\n\t/** CAPI host the catalog was fetched from; cache misses on host change (e.g. enterprise switch). */\n\thost: string;\n\t/** Epoch ms the catalog was fetched. */\n\tfetchedAt: number;\n\tmodels: Record<string, CopilotModelContext>;\n}\n\nfunction hostFromBaseUrl(baseUrl: string): string {\n\ttry {\n\t\treturn new URL(baseUrl).host;\n\t} catch {\n\t\treturn baseUrl;\n\t}\n}\n\nexport interface ReadCopilotCatalogCacheOptions {\n\t/** Expected CAPI host; a cached file from a different host is ignored. */\n\thost: string;\n\t/** Current epoch ms (injectable for tests). */\n\tnow?: number;\n\t/** Freshness window; defaults to {@link COPILOT_CATALOG_CACHE_TTL_MS}. */\n\tttlMs?: number;\n}\n\nfunction sanitizeCachedContext(value: unknown): CopilotModelContext | undefined {\n\tconst record = asRecord(value);\n\tconst contextWindow = toPositiveInt(record?.contextWindow);\n\tif (contextWindow === undefined) return undefined;\n\tconst maxInputTokens = toPositiveInt(record?.maxInputTokens);\n\tconst rawOptions = record?.contextWindowOptions;\n\tif (Array.isArray(rawOptions)) {\n\t\tconst options = rawOptions.map(toPositiveInt).filter((n): n is number => n !== undefined);\n\t\tif (options.length > 1) {\n\t\t\treturn maxInputTokens !== undefined\n\t\t\t\t? { contextWindow, contextWindowOptions: options, maxInputTokens }\n\t\t\t\t: { contextWindow, contextWindowOptions: options };\n\t\t}\n\t}\n\treturn maxInputTokens !== undefined ? { contextWindow, maxInputTokens } : { contextWindow };\n}\n\n/** Read a fresh, host-matching catalog from the cache file, or `undefined` if missing/stale/invalid. */\nexport function readCopilotCatalogCache(\n\tpath: string,\n\toptions: ReadCopilotCatalogCacheOptions,\n): CopilotModelCatalog | undefined {\n\tlet parsed: CopilotCatalogCacheFile;\n\ttry {\n\t\tif (!existsSync(path)) return undefined;\n\t\tparsed = JSON.parse(readFileSync(path, \"utf8\")) as CopilotCatalogCacheFile;\n\t} catch {\n\t\treturn undefined;\n\t}\n\tif (!parsed || parsed.version !== COPILOT_CATALOG_CACHE_VERSION) return undefined;\n\tif (parsed.host !== options.host) return undefined;\n\tconst now = options.now ?? Date.now();\n\tconst ttlMs = options.ttlMs ?? COPILOT_CATALOG_CACHE_TTL_MS;\n\tif (typeof parsed.fetchedAt !== \"number\" || now - parsed.fetchedAt >= ttlMs) return undefined;\n\tconst models = asRecord(parsed.models);\n\tif (!models) return undefined;\n\n\tconst catalog = new Map<string, CopilotModelContext>();\n\tfor (const [id, value] of Object.entries(models)) {\n\t\tconst context = sanitizeCachedContext(value);\n\t\tif (context) catalog.set(id, context);\n\t}\n\treturn catalog;\n}\n\n/** Write the catalog to the cache file (creating parent dirs). Best-effort; never throws. */\nexport function writeCopilotCatalogCache(\n\tpath: string,\n\tbaseUrl: string,\n\tcatalog: CopilotModelCatalog,\n\tnow?: number,\n): void {\n\tconst payload: CopilotCatalogCacheFile = {\n\t\tversion: COPILOT_CATALOG_CACHE_VERSION,\n\t\thost: hostFromBaseUrl(baseUrl),\n\t\tfetchedAt: now ?? Date.now(),\n\t\tmodels: Object.fromEntries(catalog),\n\t};\n\ttry {\n\t\tmkdirSync(dirname(path), { recursive: true });\n\t\twriteFileSync(path, JSON.stringify(payload), \"utf8\");\n\t} catch {\n\t\t// best-effort cache; ignore write failures\n\t}\n}\n\n/** Host component of a base URL, for matching {@link readCopilotCatalogCache} `host`. */\nexport function copilotCatalogCacheHost(baseUrl: string): string {\n\treturn hostFromBaseUrl(baseUrl);\n}\n\n/** Standard on-disk cache path for the Copilot model catalog under an agent directory. */\nexport function copilotCatalogCachePath(agentDir: string): string {\n\treturn join(agentDir, \"cache\", \"copilot-models.json\");\n}\n\n/**\n * Seed the active catalog synchronously from the on-disk cache, gated on a Copilot access token.\n *\n * Called at model-registry construction so a returning user's previously selected long-context\n * window is recognized before startup validation runs — otherwise the persisted choice would warn\n * (\"context window 936k is not supported…\") and reset until the async refresh completes. The cache\n * TTL is intentionally ignored here: stale-but-present windows are still valid for selection, and\n * the async loader independently refetches on its own freshness window. Returns true when a catalog\n * was applied. No-op (returns false) without a token or a host-matching cached catalog.\n */\nexport function seedActiveCopilotModelCatalogFromCache(\n\taccessToken: string | undefined,\n\tcachePath: string,\n\tnow?: number,\n): boolean {\n\tif (typeof accessToken !== \"string\" || accessToken.length === 0) return false;\n\tconst host = copilotCatalogCacheHost(copilotApiBaseUrlFromToken(accessToken));\n\tconst cached = readCopilotCatalogCache(cachePath, { host, now, ttlMs: Number.POSITIVE_INFINITY });\n\tif (!cached) return false;\n\tsetActiveCopilotModelCatalog(cached);\n\treturn true;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"copilot-model-catalog.d.ts","sourceRoot":"","sources":["../../src/core/copilot-model-catalog.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAK/E,yGAAyG;AACzG,MAAM,WAAW,mBAAmB;IACnC,aAAa,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kBAAkB,CAAC,EAAE,S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BAAsB,wBAAwB,CAAC,OAAO,EAAE,+BAA+B,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAiBrH;AAWD,4EAA4E;AAC5E,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAE/E;AAED,iFAAiF;AACjF,wBAAgB,4BAA4B,IAAI,mBAAmB,CAElE;AAED,sDAAsD;AACtD,wBAAgB,8BAA8B,IAAI,IAAI,CAErD;AAuBD,MAAM,WAAW,8BAA8B;IAC9C,0EAA0E;IAC1E,IAAI,EAAE,MAAM,CAAC;IACb,+CAA+C;IAC/C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AA+DD,wBAAgB,uBAAuB,CACtC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,8BAA8B,GACrC,mBAAmB,GAAG,SAAS,CAsBjC;AAED,wBAAgB,wBAAwB,CACvC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,mBAAmB,EAC5B,GAAG,CAAC,EAAE,MAAM,GACV,IAAI,CAaN;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED;;;;;;;;;GASG;AACH,wBAAgB,sCAAsC,CACrD,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,SAAS,EAAE,MAAM,EACjB,GAAG,CAAC,EAAE,MAAM,GACV,OAAO,CAOT","sourcesContent":["/** GitHub Copilot CAPI model catalog parsing, active state, and disk cache. */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\n\n/** Resolved input-token context window(s) and optional synthesis metadata for a single Copilot model. */\nexport interface CopilotModelContext {\n\tcontextWindow: number;\n\tcontextWindowOptions?: readonly number[];\n\tmaxInputTokens?: number;\n\tmaxTokens?: number;\n\tdisplayName?: string;\n\tvendor?: string;\n\tsupportedEndpoints?: readonly string[];\n\tsupports?: CopilotModelSupports;\n\tlimits?: CopilotModelLimits;\n\tmodelPickerEnabled?: boolean;\n\tpolicyState?: string;\n\ttype?: string;\n}\n\nexport interface CopilotModelSupports {\n\tadaptiveThinking?: boolean;\n\tmaxThinkingBudget?: boolean;\n\tminThinkingBudget?: boolean;\n\tparallelToolCalls?: boolean;\n\treasoningEffort?: boolean;\n\treasoningEffortLevels?: readonly string[];\n\tstreaming?: boolean;\n\tstructuredOutputs?: boolean;\n\ttoolCalls?: boolean;\n\tvision?: boolean;\n}\n\n/** Map of model id → resolved context window(s) plus optional synthesis metadata. */\nexport type CopilotModelCatalog = ReadonlyMap<string, CopilotModelContext>;\n\n/** Safety fallback when a model reports neither `max_prompt_tokens` nor `max_context_window_tokens`. */\nexport const COPILOT_CONTEXT_WINDOW_FALLBACK = 128_000;\n\nexport const COPILOT_CATALOG_API_VERSION = \"2026-06-01\";\n\n/**\n * Headers GitHub's CAPI expects for catalog reads. Mirrors the editor headers pi-ai already sends\n * for Copilot token refresh and model-policy calls, plus the dated API version.\n */\nexport const COPILOT_CATALOG_HEADERS: Readonly<Record<string, string>> = {\n\t\"User-Agent\": \"GitHubCopilotChat/0.35.0\",\n\t\"Editor-Version\": \"vscode/1.107.0\",\n\t\"Editor-Plugin-Version\": \"copilot-chat/0.35.0\",\n\t\"Copilot-Integration-Id\": \"vscode-chat\",\n\t\"X-GitHub-Api-Version\": COPILOT_CATALOG_API_VERSION,\n};\n\n/** Default Copilot CAPI base URL for OAuth tokens when no route can be resolved. */\nexport const DEFAULT_COPILOT_API_BASE_URL = \"https://api.individual.githubcopilot.com\";\n\n/** GitHub Copilot public routing hub for PAT-based `COPILOT_GITHUB_TOKEN` auth. */\nexport const COPILOT_PUBLIC_API_BASE_URL = \"https://api.githubcopilot.com\";\n\n/** Enterprise Copilot CAPI host for GHES/non-github.com server URLs. */\nexport const COPILOT_ENTERPRISE_API_BASE_URL = \"https://api.enterprise.githubcopilot.com\";\n\nexport const COPILOT_GITHUB_TOKEN_ENV = \"COPILOT_GITHUB_TOKEN\";\nexport const COPILOT_API_TARGET_ENV = \"COPILOT_API_TARGET\";\nexport const GITHUB_COPILOT_BASE_URL_ENV = \"GITHUB_COPILOT_BASE_URL\";\nexport const GITHUB_SERVER_URL_ENV = \"GITHUB_SERVER_URL\";\n\ntype CopilotEnvironment = Record<string, string | undefined>;\n\nfunction normalizeCopilotApiBaseUrl(value: string | undefined): string | undefined {\n\tconst trimmed = value?.trim();\n\tif (!trimmed) return undefined;\n\tconst withScheme = /^https?:\\/\\//i.test(trimmed) ? trimmed : `https://${trimmed}`;\n\ttry {\n\t\tnew URL(withScheme);\n\t} catch {\n\t\treturn undefined;\n\t}\n\treturn withScheme.replace(/\\/+$/, \"\");\n}\n\nfunction explicitCopilotApiBaseUrlFromEnvironment(env: CopilotEnvironment): string | undefined {\n\treturn normalizeCopilotApiBaseUrl(env[COPILOT_API_TARGET_ENV]) ?? normalizeCopilotApiBaseUrl(env[GITHUB_COPILOT_BASE_URL_ENV]);\n}\n\nfunction copilotApiBaseUrlFromServerUrl(serverUrl: string | undefined): string | undefined {\n\tconst trimmed = serverUrl?.trim();\n\tif (!trimmed) return undefined;\n\ttry {\n\t\tconst parsed = new URL(trimmed.includes(\"://\") ? trimmed : `https://${trimmed}`);\n\t\tconst host = parsed.hostname.toLowerCase();\n\t\tif (!host || host === \"github.com\") return undefined;\n\t\tif (host.endsWith(\".ghe.com\")) return `https://copilot-api.${host}`;\n\t\treturn COPILOT_ENTERPRISE_API_BASE_URL;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction isCopilotEnvironmentToken(token: string | undefined, env: CopilotEnvironment): boolean {\n\tconst environmentToken = copilotTokenFromEnvironment(env);\n\treturn environmentToken !== undefined && token === environmentToken;\n}\n\nexport function copilotTokenFromEnvironment(env: CopilotEnvironment = process.env): string | undefined {\n\tconst token = env[COPILOT_GITHUB_TOKEN_ENV]?.trim();\n\treturn token ? token : undefined;\n}\n\n/** Disk-cache freshness window, matching the Copilot CLI's list-models cache TTL. */\nexport const COPILOT_CATALOG_CACHE_TTL_MS = 30 * 60 * 1000;\n\n/** Current on-disk cache schema version. */\nexport const COPILOT_CATALOG_CACHE_VERSION = 5 as const;\n\nexport function copilotApiBaseUrlFromToken(\n\ttoken: string | undefined,\n\tenterpriseDomain?: string,\n\tenv: CopilotEnvironment = process.env,\n): string {\n\tconst explicitOverride = explicitCopilotApiBaseUrlFromEnvironment(env);\n\tif (explicitOverride) return explicitOverride;\n\tif (token) {\n\t\tconst match = token.match(/proxy-ep=([^;]+)/);\n\t\tif (match) {\n\t\t\treturn `https://${match[1].replace(/^proxy\\./, \"api.\")}`;\n\t\t}\n\t}\n\tif (enterpriseDomain) return `https://copilot-api.${enterpriseDomain}`;\n\tconst serverUrlOverride = copilotApiBaseUrlFromServerUrl(env[GITHUB_SERVER_URL_ENV]);\n\tif (serverUrlOverride) return serverUrlOverride;\n\tif (isCopilotEnvironmentToken(token, env)) return COPILOT_PUBLIC_API_BASE_URL;\n\treturn DEFAULT_COPILOT_API_BASE_URL;\n}\n\nfunction trimTrailingSlash(url: string): string {\n\treturn url.replace(/\\/+$/, \"\");\n}\n\nfunction asRecord(value: unknown): Record<string, unknown> | undefined {\n\treturn value && typeof value === \"object\" ? (value as Record<string, unknown>) : undefined;\n}\n\nfunction toPositiveInt(value: unknown): number | undefined {\n\treturn typeof value === \"number\" && Number.isInteger(value) && value > 0 ? value : undefined;\n}\n\nexport interface CopilotModelLimits {\n\tmaxPromptTokens?: number;\n\tmaxContextWindowTokens?: number;\n\tmaxOutputTokens?: number;\n\tdefaultContextMax?: number;\n\tlongContextMax?: number;\n}\n\nfunction stringArray(value: unknown): readonly string[] | undefined {\n\tif (!Array.isArray(value)) return undefined;\n\tconst strings = value.filter((item): item is string => typeof item === \"string\" && item.length > 0);\n\treturn strings.length > 0 ? strings : undefined;\n}\n\nfunction supportedFlag(record: Record<string, unknown> | undefined, key: string): boolean | undefined {\n\tconst value = record?.[key];\n\tif (typeof value === \"boolean\") return value;\n\tif (typeof value === \"number\") return Number.isFinite(value) && value > 0;\n\tif (Array.isArray(value)) return value.length > 0;\n\treturn undefined;\n}\n\nfunction parseCopilotSupports(value: unknown): CopilotModelSupports | undefined {\n\tconst record = asRecord(value);\n\tif (!record) return undefined;\n\tconst supports: CopilotModelSupports = {\n\t\tadaptiveThinking: supportedFlag(record, \"adaptive_thinking\"),\n\t\tmaxThinkingBudget: supportedFlag(record, \"max_thinking_budget\"),\n\t\tminThinkingBudget: supportedFlag(record, \"min_thinking_budget\"),\n\t\tparallelToolCalls: supportedFlag(record, \"parallel_tool_calls\"),\n\t\treasoningEffort: supportedFlag(record, \"reasoning_effort\"),\n\t\treasoningEffortLevels: stringArray(record.reasoning_effort),\n\t\tstreaming: supportedFlag(record, \"streaming\"),\n\t\tstructuredOutputs: supportedFlag(record, \"structured_outputs\"),\n\t\ttoolCalls: supportedFlag(record, \"tool_calls\"),\n\t\tvision: supportedFlag(record, \"vision\"),\n\t};\n\treturn Object.values(supports).some((flag) => flag !== undefined) ? supports : undefined;\n}\n\nfunction parseCopilotLimits(limits: Record<string, unknown> | undefined, prices: Record<string, unknown> | undefined): CopilotModelLimits {\n\treturn {\n\t\tmaxPromptTokens: toPositiveInt(limits?.max_prompt_tokens),\n\t\tmaxContextWindowTokens: toPositiveInt(limits?.max_context_window_tokens),\n\t\tmaxOutputTokens: toPositiveInt(limits?.max_output_tokens),\n\t\tdefaultContextMax: toPositiveInt(asRecord(prices?.default)?.context_max),\n\t\tlongContextMax: toPositiveInt(asRecord(prices?.long_context)?.context_max),\n\t};\n}\n\nexport function resolveCopilotModelContext(limits: CopilotModelLimits): CopilotModelContext | undefined {\n\tconst hasSignal =\n\t\tlimits.maxPromptTokens !== undefined ||\n\t\tlimits.maxContextWindowTokens !== undefined ||\n\t\tlimits.defaultContextMax !== undefined ||\n\t\tlimits.longContextMax !== undefined;\n\tif (!hasSignal) return undefined;\n\n\tconst maxInput = limits.maxPromptTokens ?? limits.maxContextWindowTokens ?? COPILOT_CONTEXT_WINDOW_FALLBACK;\n\tconst base = limits.defaultContextMax ?? maxInput;\n\tif (limits.longContextMax !== undefined && limits.longContextMax > base) {\n\t\t// Display the model's full context window as the long tier (matching openai/* and anthropic/*)\n\t\t// when CAPI advertises it; otherwise fall back to the long-context prompt threshold for\n\t\t// older/sparse payloads.\n\t\tconst longWindow = limits.maxContextWindowTokens ?? limits.longContextMax;\n\t\t// The hard prompt/input cap GitHub enforces server-side: prefer max_prompt_tokens, else derive\n\t\t// it from total − output reserve, else fall back to the long-context prompt threshold.\n\t\tconst derivedInputCap =\n\t\t\tlimits.maxContextWindowTokens !== undefined && limits.maxOutputTokens !== undefined\n\t\t\t\t? limits.maxContextWindowTokens - limits.maxOutputTokens\n\t\t\t\t: undefined;\n\t\tconst inputCap =\n\t\t\tlimits.maxPromptTokens ??\n\t\t\t(derivedInputCap !== undefined && derivedInputCap > 0 ? derivedInputCap : undefined) ??\n\t\t\tlimits.longContextMax;\n\t\t// Only carry the cap when the displayed long window actually exceeds it (the branded-total\n\t\t// case); when they coincide there is no gap and the input budget is just the window.\n\t\tconst resolved: CopilotModelContext = longWindow > inputCap\n\t\t\t? { contextWindow: base, contextWindowOptions: [base, longWindow], maxInputTokens: inputCap }\n\t\t\t: { contextWindow: base, contextWindowOptions: [base, longWindow] };\n\t\treturn limits.maxOutputTokens !== undefined ? { ...resolved, maxTokens: limits.maxOutputTokens } : resolved;\n\t}\n\treturn limits.maxOutputTokens !== undefined ? { contextWindow: base, maxTokens: limits.maxOutputTokens } : { contextWindow: base };\n}\n\n/**\n * Parse a raw CAPI `/models` response body into an input-token context-window catalog.\n */\nexport function parseCopilotModelCatalog(body: unknown): CopilotModelCatalog {\n\tconst catalog = new Map<string, CopilotModelContext>();\n\tconst data = asRecord(body)?.data;\n\tif (!Array.isArray(data)) return catalog;\n\n\tfor (const entry of data) {\n\t\tconst record = asRecord(entry);\n\t\tif (!record) continue;\n\t\tconst id = record.id;\n\t\tif (typeof id !== \"string\" || id.length === 0) continue;\n\n\t\tconst capabilities = asRecord(record.capabilities);\n\t\tconst limitsRecord = asRecord(capabilities?.limits);\n\t\tconst prices = asRecord(asRecord(record.billing)?.token_prices);\n\t\tconst limits = parseCopilotLimits(limitsRecord, prices);\n\t\tconst context = resolveCopilotModelContext(limits);\n\t\tif (context) {\n\t\t\tconst policy = asRecord(record.policy);\n\t\t\tcatalog.set(id, {\n\t\t\t\t...context,\n\t\t\t\tdisplayName: typeof record.name === \"string\" && record.name.length > 0 ? record.name : undefined,\n\t\t\t\tvendor: typeof record.vendor === \"string\" && record.vendor.length > 0 ? record.vendor : undefined,\n\t\t\t\tsupportedEndpoints: stringArray(record.supported_endpoints),\n\t\t\t\tsupports: parseCopilotSupports(capabilities?.supports),\n\t\t\t\tlimits,\n\t\t\t\tmodelPickerEnabled: typeof record.model_picker_enabled === \"boolean\" ? record.model_picker_enabled : undefined,\n\t\t\t\tpolicyState: typeof policy?.state === \"string\" ? policy.state : undefined,\n\t\t\t\ttype: typeof capabilities?.type === \"string\" ? capabilities.type : undefined,\n\t\t\t});\n\t\t}\n\t}\n\n\treturn catalog;\n}\n\nexport interface FetchCopilotModelCatalogOptions {\n\t/** Valid Copilot CAPI bearer token (e.g. from `modelRegistry.getApiKeyForProvider`). */\n\ttoken: string;\n\t/** Override the resolved base URL; defaults to one derived from the token. */\n\tbaseUrl?: string;\n\t/** Enterprise domain, used for base-URL resolution when the token lacks a `proxy-ep`. */\n\tenterpriseDomain?: string;\n\t/** Extra/override request headers. */\n\theaders?: Record<string, string>;\n\t/** Injectable `fetch` for testing. */\n\tfetchImpl?: typeof fetch;\n\t/** Abort signal. */\n\tsignal?: AbortSignal;\n}\n\n/** Fetch and parse the live Copilot model catalog from CAPI `GET {baseUrl}/models`. */\nexport async function fetchCopilotModelCatalog(options: FetchCopilotModelCatalogOptions): Promise<CopilotModelCatalog> {\n\tconst fetchImpl = options.fetchImpl ?? fetch;\n\tconst baseUrl = options.baseUrl ?? copilotApiBaseUrlFromToken(options.token, options.enterpriseDomain);\n\tconst response = await fetchImpl(`${trimTrailingSlash(baseUrl)}/models`, {\n\t\tmethod: \"GET\",\n\t\theaders: {\n\t\t\tAccept: \"application/json\",\n\t\t\tAuthorization: `Bearer ${options.token}`,\n\t\t\t...COPILOT_CATALOG_HEADERS,\n\t\t\t...options.headers,\n\t\t},\n\t\t...(options.signal ? { signal: options.signal } : {}),\n\t});\n\tif (!response.ok) {\n\t\tthrow new Error(`GitHub Copilot /models request failed: ${response.status} ${response.statusText}`);\n\t}\n\treturn parseCopilotModelCatalog(await response.json());\n}\n\n// ----------------------------------------------------------------------------\n// Active in-memory catalog (consulted by the model registry).\n//\n// Empty by default, so with no Copilot auth / no successful fetch the registry leaves Copilot\n// model context windows untouched and the picker never appears.\n// ----------------------------------------------------------------------------\n\nlet activeCatalog: CopilotModelCatalog = new Map();\n\n/** Replace the active catalog the registry derives context windows from. */\nexport function setActiveCopilotModelCatalog(catalog: CopilotModelCatalog): void {\n\tactiveCatalog = catalog;\n}\n\n/** The active catalog (empty until a successful auth-gated fetch/cache load). */\nexport function getActiveCopilotModelCatalog(): CopilotModelCatalog {\n\treturn activeCatalog;\n}\n\n/** Reset the active catalog (primarily for tests). */\nexport function clearActiveCopilotModelCatalog(): void {\n\tactiveCatalog = new Map();\n}\n\n// ----------------------------------------------------------------------------\n// Disk cache.\n// ----------------------------------------------------------------------------\n\ninterface CopilotCatalogCacheFile {\n\tversion: typeof COPILOT_CATALOG_CACHE_VERSION;\n\t/** CAPI host the catalog was fetched from; cache misses on host change (e.g. enterprise switch). */\n\thost: string;\n\t/** Epoch ms the catalog was fetched. */\n\tfetchedAt: number;\n\tmodels: Record<string, CopilotModelContext>;\n}\n\nfunction hostFromBaseUrl(baseUrl: string): string {\n\ttry {\n\t\treturn new URL(baseUrl).host;\n\t} catch {\n\t\treturn baseUrl;\n\t}\n}\n\nexport interface ReadCopilotCatalogCacheOptions {\n\t/** Expected CAPI host; a cached file from a different host is ignored. */\n\thost: string;\n\t/** Current epoch ms (injectable for tests). */\n\tnow?: number;\n\t/** Freshness window; defaults to {@link COPILOT_CATALOG_CACHE_TTL_MS}. */\n\tttlMs?: number;\n}\n\nfunction sanitizeCachedSupports(value: unknown): CopilotModelSupports | undefined {\n\tconst record = asRecord(value);\n\tif (!record) return undefined;\n\tconst supports: CopilotModelSupports = {\n\t\tadaptiveThinking: supportedFlag(record, \"adaptiveThinking\"),\n\t\tmaxThinkingBudget: supportedFlag(record, \"maxThinkingBudget\"),\n\t\tminThinkingBudget: supportedFlag(record, \"minThinkingBudget\"),\n\t\tparallelToolCalls: supportedFlag(record, \"parallelToolCalls\"),\n\t\treasoningEffort: supportedFlag(record, \"reasoningEffort\"),\n\t\treasoningEffortLevels: stringArray(record.reasoningEffortLevels),\n\t\tstreaming: supportedFlag(record, \"streaming\"),\n\t\tstructuredOutputs: supportedFlag(record, \"structuredOutputs\"),\n\t\ttoolCalls: supportedFlag(record, \"toolCalls\"),\n\t\tvision: supportedFlag(record, \"vision\"),\n\t};\n\treturn Object.values(supports).some((flag) => flag !== undefined) ? supports : undefined;\n}\n\nfunction sanitizeCachedLimits(value: unknown): CopilotModelLimits | undefined {\n\tconst record = asRecord(value);\n\tif (!record) return undefined;\n\tconst limits: CopilotModelLimits = {\n\t\tmaxPromptTokens: toPositiveInt(record.maxPromptTokens),\n\t\tmaxContextWindowTokens: toPositiveInt(record.maxContextWindowTokens),\n\t\tmaxOutputTokens: toPositiveInt(record.maxOutputTokens),\n\t\tdefaultContextMax: toPositiveInt(record.defaultContextMax),\n\t\tlongContextMax: toPositiveInt(record.longContextMax),\n\t};\n\treturn Object.values(limits).some((limit) => limit !== undefined) ? limits : undefined;\n}\n\nfunction sanitizeCachedContext(value: unknown): CopilotModelContext | undefined {\n\tconst record = asRecord(value);\n\tconst contextWindow = toPositiveInt(record?.contextWindow);\n\tif (contextWindow === undefined) return undefined;\n\tconst maxInputTokens = toPositiveInt(record?.maxInputTokens);\n\tconst maxTokens = toPositiveInt(record?.maxTokens);\n\tconst rawOptions = record?.contextWindowOptions;\n\tconst base: CopilotModelContext = maxInputTokens !== undefined ? { contextWindow, maxInputTokens } : { contextWindow };\n\tif (maxTokens !== undefined) base.maxTokens = maxTokens;\n\tif (Array.isArray(rawOptions)) {\n\t\tconst options = rawOptions.map(toPositiveInt).filter((n): n is number => n !== undefined);\n\t\tif (options.length > 1) base.contextWindowOptions = options;\n\t}\n\tconst displayName = record && typeof record.displayName === \"string\" && record.displayName.length > 0 ? record.displayName : undefined;\n\tconst vendor = record && typeof record.vendor === \"string\" && record.vendor.length > 0 ? record.vendor : undefined;\n\tconst policyState = record && typeof record.policyState === \"string\" ? record.policyState : undefined;\n\tconst type = record && typeof record.type === \"string\" ? record.type : undefined;\n\treturn {\n\t\t...base,\n\t\tdisplayName,\n\t\tvendor,\n\t\tsupportedEndpoints: stringArray(record?.supportedEndpoints),\n\t\tsupports: sanitizeCachedSupports(record?.supports),\n\t\tlimits: sanitizeCachedLimits(record?.limits),\n\t\tmodelPickerEnabled: typeof record?.modelPickerEnabled === \"boolean\" ? record.modelPickerEnabled : undefined,\n\t\tpolicyState,\n\t\ttype,\n\t};\n}\n\nexport function readCopilotCatalogCache(\n\tpath: string,\n\toptions: ReadCopilotCatalogCacheOptions,\n): CopilotModelCatalog | undefined {\n\tlet parsed: CopilotCatalogCacheFile;\n\ttry {\n\t\tif (!existsSync(path)) return undefined;\n\t\tparsed = JSON.parse(readFileSync(path, \"utf8\")) as CopilotCatalogCacheFile;\n\t} catch {\n\t\treturn undefined;\n\t}\n\tif (!parsed || parsed.version !== COPILOT_CATALOG_CACHE_VERSION) return undefined;\n\tif (parsed.host !== options.host) return undefined;\n\tconst now = options.now ?? Date.now();\n\tconst ttlMs = options.ttlMs ?? COPILOT_CATALOG_CACHE_TTL_MS;\n\tif (typeof parsed.fetchedAt !== \"number\" || now - parsed.fetchedAt >= ttlMs) return undefined;\n\tconst models = asRecord(parsed.models);\n\tif (!models) return undefined;\n\n\tconst catalog = new Map<string, CopilotModelContext>();\n\tfor (const [id, value] of Object.entries(models)) {\n\t\tconst context = sanitizeCachedContext(value);\n\t\tif (context) catalog.set(id, context);\n\t}\n\treturn catalog;\n}\n\nexport function writeCopilotCatalogCache(\n\tpath: string,\n\tbaseUrl: string,\n\tcatalog: CopilotModelCatalog,\n\tnow?: number,\n): void {\n\tconst payload: CopilotCatalogCacheFile = {\n\t\tversion: COPILOT_CATALOG_CACHE_VERSION,\n\t\thost: hostFromBaseUrl(baseUrl),\n\t\tfetchedAt: now ?? Date.now(),\n\t\tmodels: Object.fromEntries(catalog),\n\t};\n\ttry {\n\t\tmkdirSync(dirname(path), { recursive: true });\n\t\twriteFileSync(path, JSON.stringify(payload), \"utf8\");\n\t} catch {\n\t\t// best-effort cache; ignore write failures\n\t}\n}\n\nexport function copilotCatalogCacheHost(baseUrl: string): string {\n\treturn hostFromBaseUrl(baseUrl);\n}\n\nexport function copilotCatalogCachePath(agentDir: string): string {\n\treturn join(agentDir, \"cache\", \"copilot-models.json\");\n}\n\n/**\n * Seed the active catalog synchronously from the on-disk cache, gated on a Copilot access token.\n *\n * Called at model-registry construction so a returning user's previously selected long-context\n * window is recognized before startup validation runs — otherwise the persisted choice would warn\n * (\"context window 936k is not supported…\") and reset until the async refresh completes. The cache\n * TTL is intentionally ignored here: stale-but-present windows are still valid for selection, and\n * the async loader independently refetches on its own freshness window. Returns true when a catalog\n * was applied. No-op (returns false) without a token or a host-matching cached catalog.\n */\nexport function seedActiveCopilotModelCatalogFromCache(\n\taccessToken: string | undefined,\n\tcachePath: string,\n\tnow?: number,\n): boolean {\n\tif (typeof accessToken !== \"string\" || accessToken.length === 0) return false;\n\tconst host = copilotCatalogCacheHost(copilotApiBaseUrlFromToken(accessToken));\n\tconst cached = readCopilotCatalogCache(cachePath, { host, now, ttlMs: Number.POSITIVE_INFINITY });\n\tif (!cached) return false;\n\tsetActiveCopilotModelCatalog(cached);\n\treturn true;\n}\n"]}
|