@averyyy/pi-coding-agent 1.4.0-piclient.10 → 1.4.0-piclient.11

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.
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
- var github_copilot_default={"anthropic-messages":{"chat:claude-fable-5":{id:"claude-fable-5",name:"Claude Fable 5",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsMidConvoSystemMessages:!0,forceAdaptiveThinking:!0},thinkingLevelMap:{off:null,xhigh:"xhigh",max:"max"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:claude-fable-5.1":{id:"claude-fable-5.1",name:"Claude Fable 5.1",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:10,output:50,cacheRead:.25,cacheWrite:12.5},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsMidConvoSystemMessages:!0,forceAdaptiveThinking:!0},thinkingLevelMap:{off:null,xhigh:"xhigh",max:"max"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:claude-haiku-4.5":{id:"claude-haiku-4.5",name:"Claude Haiku 4.5 (latest)",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsEagerToolInputStreaming:!1},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:claude-haiku-5.5":{id:"claude-haiku-5.5",name:"Claude Haiku 5.5",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:.1,output:.5,cacheRead:.01,cacheWrite:.125,tiers:[{inputTokensAbove:1e5,input:.5,output:2.5,cacheRead:.05,cacheWrite:.625}]},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsMidConvoSystemMessages:!0,forceAdaptiveThinking:!0,supportsTemperature:!1},thinkingLevelMap:{xhigh:"xhigh",max:"max"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:claude-opus-4.8":{id:"claude-opus-4.8",name:"Claude Opus 4.8",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:64e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsMidConvoSystemMessages:!0,forceAdaptiveThinking:!0,supportsTemperature:!1},thinkingLevelMap:{xhigh:"xhigh",max:"max",minimal:"low"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:claude-opus-5":{id:"claude-opus-5",name:"Claude Opus 5",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:64e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsMidConvoSystemMessages:!0,forceAdaptiveThinking:!0,supportsTemperature:!1},thinkingLevelMap:{xhigh:"xhigh",max:"max",minimal:"low"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:claude-opus-5.5":{id:"claude-opus-5.5",name:"Claude Opus 5.5",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:4,output:20,cacheRead:.2,cacheWrite:5},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsMidConvoSystemMessages:!0,forceAdaptiveThinking:!0,supportsTemperature:!1},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:claude-sonnet-4.6":{id:"claude-sonnet-4.6",name:"Claude Sonnet 4.6",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:32e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{max:"max",minimal:"low"},compat:{forceAdaptiveThinking:!0},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:claude-sonnet-5":{id:"claude-sonnet-5",name:"Claude Sonnet 5",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:2,output:10,cacheRead:.2,cacheWrite:2.5},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{xhigh:"xhigh",max:"max"},compat:{forceAdaptiveThinking:!0},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:claude-sonnet-5.5":{id:"claude-sonnet-5.5",name:"Claude Sonnet 5.5",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:2,output:10,cacheRead:.1,cacheWrite:2.5},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsMidConvoSystemMessages:!0,forceAdaptiveThinking:!0,supportsTemperature:!1},thinkingLevelMap:{xhigh:"xhigh",max:"max"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"}},"openai-completions":{"chat:gemini-3.8-flash":{id:"gemini-3.8-flash",name:"Gemini 3.8 Flash",api:"openai-completions",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:.75,output:3.75,cacheRead:.075,cacheWrite:0},contextWindow:1e6,maxTokens:64e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictMode:!0,supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gemini-4-argon":{id:"gemini-4-argon",name:"Gemini 4 Argon",api:"openai-completions",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:2,output:10,cacheRead:.1,cacheWrite:0},contextWindow:1048576,maxTokens:65536,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictMode:!0,supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:kimi-k3":{id:"kimi-k3",name:"Kimi K3",api:"openai-completions",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:0},contextWindow:1048576,maxTokens:131072,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictMode:!0,supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,supportsMidConvoSystemMessages:!0},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"}},"openai-responses":{"chat:gpt-5.3-codex":{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:"low",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null},compat:{supportsOpenAIGrammarTools:!0},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-5.4-nano":{id:"gpt-5.4-nano",name:"GPT-5.4 nano",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:.2,output:1.25,cacheRead:.02,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:"low",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null},compat:{supportsOpenAIGrammarTools:!0},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-5.6-luna":{id:"gpt-5.6-luna",name:"GPT-5.6 Luna",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:.2,output:1.2,cacheRead:.02,cacheWrite:.25,tiers:[{inputTokensAbove:2e5,input:.4,output:1.8,cacheRead:.04,cacheWrite:.5}]},contextWindow:105e4,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:"low",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{supportsOpenAIGrammarTools:!0,supportsMidConvoSystemMessages:!0,supportsAdditionalTools:!0},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-5.6-sol":{id:"gpt-5.6-sol",name:"GPT-5.6 Sol",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:4,output:20,cacheRead:.4,cacheWrite:5,tiers:[{inputTokensAbove:272e3,input:8,output:30,cacheRead:.8,cacheWrite:10}]},contextWindow:105e4,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:"low",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{supportsOpenAIGrammarTools:!0,supportsMidConvoSystemMessages:!0,supportsAdditionalTools:!0},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-5.6-terra":{id:"gpt-5.6-terra",name:"GPT-5.6 Terra",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:2.5,tiers:[{inputTokensAbove:272e3,input:4,output:18,cacheRead:.4,cacheWrite:5}]},contextWindow:105e4,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:"low",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{supportsOpenAIGrammarTools:!0,supportsMidConvoSystemMessages:!0,supportsAdditionalTools:!0},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-6-astra":{id:"gpt-6-astra",name:"GPT-6 Astra",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5,tiers:[{inputTokensAbove:272e3,input:20,output:75,cacheRead:2,cacheWrite:25}]},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{supportsOpenAIGrammarTools:!0,supportsMidConvoSystemMessages:!0,supportsAdditionalTools:!0},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-6-luna":{id:"gpt-6-luna",name:"GPT-6 Luna",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:.1,output:.5,cacheRead:.01,cacheWrite:.125,tiers:[{inputTokensAbove:272e3,input:.2,output:.75,cacheRead:.02,cacheWrite:.25}]},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{supportsOpenAIGrammarTools:!0,supportsMidConvoSystemMessages:!0,supportsAdditionalTools:!0},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-6-sol":{id:"gpt-6-sol",name:"GPT-6 Sol",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:2,output:10,cacheRead:.2,cacheWrite:2.5,tiers:[{inputTokensAbove:272e3,input:4,output:15,cacheRead:.4,cacheWrite:5}]},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{supportsOpenAIGrammarTools:!0,supportsMidConvoSystemMessages:!0,supportsAdditionalTools:!0},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-6.1-sol":{id:"gpt-6.1-sol",name:"GPT-6.1 Sol",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:2,output:10,cacheRead:.1,cacheWrite:2.5,tiers:[{inputTokensAbove:272e3,input:4,output:15,cacheRead:.2,cacheWrite:5}]},contextWindow:105e4,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{supportsOpenAIGrammarTools:!0,supportsMidConvoSystemMessages:!0,supportsAdditionalTools:!0},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:grok-4.5":{id:"grok-4.5",name:"Grok 4.5",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:2,output:6,cacheRead:.5,cacheWrite:0,tiers:[{inputTokensAbove:2e5,input:4,output:12,cacheRead:1,cacheWrite:0}]},contextWindow:5e5,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:grok-4.6":{id:"grok-4.6",name:"Grok 4.6",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:2,output:6,cacheRead:.5,cacheWrite:0,tiers:[{inputTokensAbove:2e5,input:4,output:12,cacheRead:1,cacheWrite:0}]},contextWindow:5e5,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:grok-4.7":{id:"grok-4.7",name:"Grok 4.7",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:2,output:6,cacheRead:.5,cacheWrite:0,tiers:[{inputTokensAbove:2e5,input:4,output:12,cacheRead:1,cacheWrite:0}]},contextWindow:5e5,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:mai-code-1.1-flash":{id:"mai-code-1.1-flash",name:"MAI-Code-1.1-Flash",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:.2,output:1.2,cacheRead:.02,cacheWrite:0},contextWindow:256e3,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"}}};function flattenModelCatalog(groups,type){return Object.fromEntries(Object.values(groups).flatMap(models=>Object.values(models)).filter(model=>model.type===type).map(model=>[model.id,model]))}function flattenChatModelCatalog(_provider,groups){return flattenModelCatalog(groups,"chat")}function flattenImageModelCatalog(_provider,groups){return flattenModelCatalog(groups,"image")}function flattenClassifierModelCatalog(_provider,groups){return flattenModelCatalog(groups,"classifier")}var GITHUB_COPILOT_MODELS=flattenChatModelCatalog("github-copilot",github_copilot_default),GITHUB_COPILOT_IMAGE_MODELS=flattenImageModelCatalog("github-copilot",github_copilot_default),GITHUB_COPILOT_CLASSIFIER_MODELS=flattenClassifierModelCatalog("github-copilot",github_copilot_default);function sleep(ms,signal){return new Promise((resolve,reject)=>{signal.throwIfAborted();let onAbort=()=>{clearTimeout(timeout),reject(signal.reason)},timeout=setTimeout(()=>{signal.removeEventListener("abort",onAbort),resolve()},ms);signal.addEventListener("abort",onAbort,{once:!0})})}var CANCEL_MESSAGE="Login cancelled",TIMEOUT_MESSAGE="Device flow timed out",SLOW_DOWN_TIMEOUT_MESSAGE="Device flow timed out after one or more slow_down responses. This is often caused by clock drift in WSL or VM environments. Please sync or restart the VM clock and try again.";function abortableSleep(ms,signal,cancelMessage){return new Promise((resolve,reject)=>{if(signal.aborted){reject(new Error(cancelMessage));return}let onAbort=()=>{clearTimeout(timeout),reject(new Error(cancelMessage))},timeout=setTimeout(()=>{signal.removeEventListener("abort",onAbort),resolve()},ms);signal.addEventListener("abort",onAbort,{once:!0})})}async function pollOAuthDeviceCodeFlow(options){let deadline=typeof options.expiresInSeconds=="number"?Date.now()+options.expiresInSeconds*1e3:Number.POSITIVE_INFINITY,intervalMs=Math.max(1e3,Math.floor((options.intervalSeconds??5)*1e3)),slowDownResponses=0;if(options.waitBeforeFirstPoll){let remainingMs=deadline-Date.now();remainingMs>0&&await abortableSleep(Math.min(intervalMs,remainingMs),options.signal,CANCEL_MESSAGE)}for(;Date.now()<deadline;){if(options.signal.aborted)throw new Error(CANCEL_MESSAGE);let result=await options.poll();if(result.status==="complete")return result.value;if(result.status==="failed")throw new Error(result.message);result.status==="slow_down"&&(slowDownResponses+=1,intervalMs=typeof result.intervalSeconds=="number"&&Number.isFinite(result.intervalSeconds)&&result.intervalSeconds>0?Math.max(1e3,Math.floor(result.intervalSeconds*1e3)):Math.max(1e3,intervalMs+5e3));let remainingMs=deadline-Date.now();if(remainingMs<=0)break;await abortableSleep(Math.min(intervalMs,remainingMs),options.signal,CANCEL_MESSAGE)}throw new Error(slowDownResponses>0?SLOW_DOWN_TIMEOUT_MESSAGE:TIMEOUT_MESSAGE)}var decode=s=>atob(s),CLIENT_ID=decode("SXYxLmI1MDdhMDhjODdlY2ZlOTg="),COPILOT_HEADERS={"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},COPILOT_API_VERSION="2026-06-01";function normalizeDomain(input){let trimmed=input.trim();if(!trimmed)return null;try{return(trimmed.includes("://")?new URL(trimmed):new URL(`https://${trimmed}`)).hostname}catch{return null}}function getUrls(domain){return{deviceCodeUrl:`https://${domain}/login/device/code`,accessTokenUrl:`https://${domain}/login/oauth/access_token`,copilotTokenUrl:`https://api.${domain}/copilot_internal/v2/token`}}function getBaseUrlFromToken(token){let match=token.match(/proxy-ep=([^;]+)/);return match?`https://${match[1].replace(/^proxy\./,"api.")}`:null}function getGitHubCopilotBaseUrl(token,enterpriseDomain){if(token){let urlFromToken=getBaseUrlFromToken(token);if(urlFromToken)return urlFromToken}return enterpriseDomain?`https://copilot-api.${enterpriseDomain}`:"https://api.individual.githubcopilot.com"}function asRecord(value){return value&&typeof value=="object"?value:void 0}function parseGitHubCopilotModelCatalog(raw,allowPolicyFallback){let data=asRecord(raw)?.data;if(!Array.isArray(data))throw new Error("Invalid Copilot models response");let accountModels=data.flatMap(rawItem=>{let item=asRecord(rawItem),id=item?.id;if(!item||typeof id!="string")return[];let capabilities=asRecord(item.capabilities);return asRecord(capabilities?.supports)?.tool_calls===!1?[]:[{id,pickerEnabled:item.model_picker_enabled===!0,policyState:asRecord(item.policy)?.state}]}),pickerModelIds=accountModels.filter(model=>model.pickerEnabled&&model.policyState!=="disabled").map(model=>model.id),usePolicyFallback=allowPolicyFallback&&pickerModelIds.length===0,availableModelIds=pickerModelIds.length>0||!allowPolicyFallback?pickerModelIds:accountModels.filter(model=>model.policyState==="enabled").map(model=>model.id),policyModelIds=accountModels.filter(model=>model.policyState==="unconfigured"&&Object.hasOwn(GITHUB_COPILOT_MODELS,model.id)&&(model.pickerEnabled||usePolicyFallback)).map(model=>model.id);return{availableModelIds,policyModelIds}}async function fetchWithRateLimitRetry(url,init,signal,retryPolicy){let retryBudgetSignal=retryPolicy.maxRetries>0&&retryPolicy.maxElapsedMs>0?AbortSignal.timeout(retryPolicy.maxElapsedMs):void 0,requestSignal=retryBudgetSignal?AbortSignal.any([signal,retryBudgetSignal]):signal,retryDeadline=retryBudgetSignal?Date.now()+retryPolicy.maxElapsedMs:void 0;for(let retry=0;;retry++){let response=await fetch(url,{...init,signal:AbortSignal.any([requestSignal,AbortSignal.timeout(5e3)])});if(response.status!==429||retry===retryPolicy.maxRetries)return response;let retryAfter=response.headers.get("retry-after"),delayMs=500*2**retry;if(retryAfter){let seconds=Number.parseFloat(retryAfter);if(delayMs=Number.isNaN(seconds)?Date.parse(retryAfter)-Date.now():seconds*1e3,!Number.isFinite(delayMs))return response}if(delayMs=Math.max(0,delayMs),retryDeadline!==void 0&&delayMs>=retryDeadline-Date.now())return response;await response.body?.cancel(),await sleep(delayMs,requestSignal)}}async function fetchGitHubCopilotModels(copilotToken,enterpriseDomain,signal,retryPolicy){let baseUrl=getGitHubCopilotBaseUrl(copilotToken,enterpriseDomain),allowPolicyFallback=baseUrl==="https://api.individual.githubcopilot.com",response=await fetchWithRateLimitRetry(`${baseUrl}/models`,{headers:{Accept:"application/json",Authorization:`Bearer ${copilotToken}`,...COPILOT_HEADERS,"X-GitHub-Api-Version":COPILOT_API_VERSION}},signal,retryPolicy);if(!response.ok)throw new Error(`${response.status} ${response.statusText}: ${await response.text()}`);return parseGitHubCopilotModelCatalog(await response.json(),allowPolicyFallback)}async function fetchJson(url,init){let response=await fetch(url,init);if(!response.ok){let text=await response.text();throw new Error(`${response.status} ${response.statusText}: ${text}`)}return response.json()}async function startDeviceFlow(domain,signal){let urls=getUrls(domain),data=await fetchJson(urls.deviceCodeUrl,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded","User-Agent":"GitHubCopilotChat/0.35.0"},body:new URLSearchParams({client_id:CLIENT_ID,scope:"read:user"}),signal});if(!data||typeof data!="object")throw new Error("Invalid device code response");let deviceCode=data.device_code,userCode=data.user_code,verificationUri=data.verification_uri,interval=data.interval,expiresIn=data.expires_in;if(typeof deviceCode!="string"||typeof userCode!="string"||typeof verificationUri!="string"||interval!==void 0&&typeof interval!="number"||typeof expiresIn!="number")throw new Error("Invalid device code response fields");let parsedUri;try{parsedUri=new URL(verificationUri)}catch{throw new Error("Untrusted verification_uri in device code response")}if(parsedUri.protocol!=="https:"&&parsedUri.protocol!=="http:")throw new Error("Untrusted verification_uri in device code response");return{device_code:deviceCode,user_code:userCode,verification_uri:parsedUri.href,interval,expires_in:expiresIn}}async function pollForGitHubAccessToken(domain,device,signal){let urls=getUrls(domain);return pollOAuthDeviceCodeFlow({intervalSeconds:device.interval,expiresInSeconds:device.expires_in,waitBeforeFirstPoll:!0,signal,poll:async()=>{let raw=await fetchJson(urls.accessTokenUrl,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded","User-Agent":"GitHubCopilotChat/0.35.0"},body:new URLSearchParams({client_id:CLIENT_ID,device_code:device.device_code,grant_type:"urn:ietf:params:oauth:grant-type:device_code"}),signal});if(raw&&typeof raw=="object"&&typeof raw.access_token=="string")return{status:"complete",value:raw.access_token};if(raw&&typeof raw=="object"&&typeof raw.error=="string"){let{error,error_description:description,interval}=raw;if(error==="authorization_pending")return{status:"pending"};if(error==="slow_down")return{status:"slow_down",intervalSeconds:typeof interval=="number"?interval:void 0};let descriptionSuffix=description?`: ${description}`:"";return{status:"failed",message:`Device flow failed: ${error}${descriptionSuffix}`}}return{status:"failed",message:"Invalid device token response"}}})}async function refreshGitHubCopilotAccessToken(refreshToken,enterpriseDomain,signal){let urls=getUrls(enterpriseDomain||"github.com"),raw=await fetchJson(urls.copilotTokenUrl,{headers:{Accept:"application/json",Authorization:`Bearer ${refreshToken}`,...COPILOT_HEADERS},signal});if(!raw||typeof raw!="object")throw new Error("Invalid Copilot token response");let token=raw.token,expiresAt=raw.expires_at;if(typeof token!="string"||typeof expiresAt!="number")throw new Error("Invalid Copilot token response fields");return{type:"oauth",refresh:refreshToken,access:token,expires:expiresAt*1e3-300*1e3,enterpriseUrl:enterpriseDomain}}async function refreshGitHubCopilotToken(refreshToken,enterpriseDomain,signal){let credentials=await refreshGitHubCopilotAccessToken(refreshToken,enterpriseDomain,signal),{availableModelIds}=await fetchGitHubCopilotModels(credentials.access,enterpriseDomain,signal,{maxRetries:0,maxElapsedMs:0});return{...credentials,availableModelIds}}async function enableGitHubCopilotModel(token,modelId,enterpriseDomain,signal){let url=`${getGitHubCopilotBaseUrl(token,enterpriseDomain)}/models/${modelId}/policy`,response;try{response=await fetchWithRateLimitRetry(url,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${token}`,...COPILOT_HEADERS,"openai-intent":"chat-policy","x-interaction-type":"chat-policy"},body:JSON.stringify({state:"enabled"})},signal,{maxRetries:2,maxElapsedMs:5e3})}catch(error){if(signal.aborted)throw error;return!1}if(response.status===429)throw new Error(`${response.status} ${response.statusText}: ${await response.text()}`);return response.ok}async function enableGitHubCopilotModels(token,modelIds,enterpriseDomain,signal){let enabledModelIds=[];for(let modelId of modelIds)try{await enableGitHubCopilotModel(token,modelId,enterpriseDomain,signal)&&enabledModelIds.push(modelId)}catch(error){if(signal.aborted)throw error;break}return enabledModelIds}async function loginGitHubCopilot(interaction){let input=await interaction.prompt({type:"text",message:"GitHub Enterprise URL/domain (blank for github.com)",placeholder:"company.ghe.com"});if(interaction.signal.aborted)throw new Error("Login cancelled");let trimmed=input.trim(),enterpriseDomain=normalizeDomain(input);if(trimmed&&!enterpriseDomain)throw new Error("Invalid GitHub Enterprise URL/domain");let domain=enterpriseDomain||"github.com",device=await startDeviceFlow(domain,interaction.signal);interaction.notify({type:"device_code",userCode:device.user_code,verificationUri:device.verification_uri,intervalSeconds:device.interval,expiresInSeconds:device.expires_in});let githubAccessToken=await pollForGitHubAccessToken(domain,device,interaction.signal),credentials=await refreshGitHubCopilotAccessToken(githubAccessToken,enterpriseDomain??void 0,interaction.signal),models=await fetchGitHubCopilotModels(credentials.access,enterpriseDomain??void 0,interaction.signal,{maxRetries:2,maxElapsedMs:5e3}),enabledModelIds=[];return models.policyModelIds.length>0&&(interaction.notify({type:"progress",message:"Enabling models..."}),enabledModelIds=await enableGitHubCopilotModels(credentials.access,models.policyModelIds,enterpriseDomain??void 0,interaction.signal)),{...credentials,availableModelIds:[...new Set([...models.availableModelIds,...enabledModelIds])]}}function copilotEnterpriseDomain(credential){let enterpriseUrl=credential.enterpriseUrl;if(!(typeof enterpriseUrl!="string"||!enterpriseUrl))return normalizeDomain(enterpriseUrl)??void 0}var githubCopilotOAuth={name:"GitHub Copilot",isSubscription:!0,login:loginGitHubCopilot,refresh:(credential,signal)=>refreshGitHubCopilotToken(credential.refresh,copilotEnterpriseDomain(credential),signal),async toAuth(credential){return{apiKey:credential.access,baseUrl:getGitHubCopilotBaseUrl(credential.access,copilotEnterpriseDomain(credential))}}};export{githubCopilotOAuth};
2
+ var github_copilot_default={"anthropic-messages":{"chat:claude-fable-5":{id:"claude-fable-5",name:"Claude Fable 5",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsMidConvoSystemMessages:!0,forceAdaptiveThinking:!0},thinkingLevelMap:{off:null,xhigh:"xhigh",max:"max"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:claude-fable-5.1":{id:"claude-fable-5.1",name:"Claude Fable 5.1",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:10,output:50,cacheRead:.25,cacheWrite:12.5},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsMidConvoSystemMessages:!0,forceAdaptiveThinking:!0},thinkingLevelMap:{off:null,xhigh:"xhigh",max:"max"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:claude-haiku-4.5":{id:"claude-haiku-4.5",name:"Claude Haiku 4.5 (latest)",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsEagerToolInputStreaming:!1},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:claude-haiku-5.5":{id:"claude-haiku-5.5",name:"Claude Haiku 5.5",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:.1,output:.5,cacheRead:.01,cacheWrite:.125,tiers:[{inputTokensAbove:1e5,input:.5,output:2.5,cacheRead:.05,cacheWrite:.625}]},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsMidConvoSystemMessages:!0,forceAdaptiveThinking:!0,supportsTemperature:!1},thinkingLevelMap:{xhigh:"xhigh",max:"max"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:claude-opus-4.8":{id:"claude-opus-4.8",name:"Claude Opus 4.8",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:64e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsMidConvoSystemMessages:!0,forceAdaptiveThinking:!0,supportsTemperature:!1},thinkingLevelMap:{xhigh:"xhigh",max:"max",minimal:"low"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:claude-opus-5":{id:"claude-opus-5",name:"Claude Opus 5",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:64e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsMidConvoSystemMessages:!0,forceAdaptiveThinking:!0,supportsTemperature:!1},thinkingLevelMap:{xhigh:"xhigh",max:"max",minimal:"low"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:claude-opus-5.5":{id:"claude-opus-5.5",name:"Claude Opus 5.5",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:4,output:20,cacheRead:.2,cacheWrite:5},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsMidConvoSystemMessages:!0,forceAdaptiveThinking:!0,supportsTemperature:!1},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:claude-sonnet-4.6":{id:"claude-sonnet-4.6",name:"Claude Sonnet 4.6",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:32e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{max:"max",minimal:"low"},compat:{forceAdaptiveThinking:!0},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:claude-sonnet-5":{id:"claude-sonnet-5",name:"Claude Sonnet 5",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:2,output:10,cacheRead:.2,cacheWrite:2.5},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{xhigh:"xhigh",max:"max"},compat:{forceAdaptiveThinking:!0},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:claude-sonnet-5.5":{id:"claude-sonnet-5.5",name:"Claude Sonnet 5.5",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:2,output:10,cacheRead:.1,cacheWrite:2.5},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsMidConvoSystemMessages:!0,forceAdaptiveThinking:!0,supportsTemperature:!1},thinkingLevelMap:{xhigh:"xhigh",max:"max"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"}},"openai-completions":{"chat:gemini-3.8-flash":{id:"gemini-3.8-flash",name:"Gemini 3.8 Flash",api:"openai-completions",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:.75,output:3.75,cacheRead:.075,cacheWrite:0},contextWindow:1e6,maxTokens:64e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictMode:!0,supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gemini-4-argon":{id:"gemini-4-argon",name:"Gemini 4 Argon",api:"openai-completions",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:2,output:10,cacheRead:.1,cacheWrite:0},contextWindow:1048576,maxTokens:65536,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictMode:!0,supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:kimi-k3":{id:"kimi-k3",name:"Kimi K3",api:"openai-completions",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:0},contextWindow:1048576,maxTokens:131072,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictMode:!0,supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,supportsMidConvoSystemMessages:!0},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"}},"openai-responses":{"chat:gpt-5.3-codex":{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:"low",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null},compat:{supportsOpenAIGrammarTools:!0},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-5.4-nano":{id:"gpt-5.4-nano",name:"GPT-5.4 nano",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:.2,output:1.25,cacheRead:.02,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:"low",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null},compat:{supportsOpenAIGrammarTools:!0},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-5.6-luna":{id:"gpt-5.6-luna",name:"GPT-5.6 Luna",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:.2,output:1.2,cacheRead:.02,cacheWrite:.25,tiers:[{inputTokensAbove:2e5,input:.4,output:1.8,cacheRead:.04,cacheWrite:.5}]},contextWindow:105e4,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:"low",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{supportsOpenAIGrammarTools:!0,supportsMidConvoSystemMessages:!0,supportsAdditionalTools:!0},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-5.6-sol":{id:"gpt-5.6-sol",name:"GPT-5.6 Sol",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:4,output:20,cacheRead:.4,cacheWrite:5,tiers:[{inputTokensAbove:272e3,input:8,output:30,cacheRead:.8,cacheWrite:10}]},contextWindow:105e4,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:"low",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{supportsOpenAIGrammarTools:!0,supportsMidConvoSystemMessages:!0,supportsAdditionalTools:!0},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-5.6-terra":{id:"gpt-5.6-terra",name:"GPT-5.6 Terra",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:2.5,tiers:[{inputTokensAbove:272e3,input:4,output:18,cacheRead:.4,cacheWrite:5}]},contextWindow:105e4,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:"low",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{supportsOpenAIGrammarTools:!0,supportsMidConvoSystemMessages:!0,supportsAdditionalTools:!0},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-6-astra":{id:"gpt-6-astra",name:"GPT-6 Astra",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5,tiers:[{inputTokensAbove:272e3,input:20,output:75,cacheRead:2,cacheWrite:25}]},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{supportsOpenAIGrammarTools:!0,supportsMidConvoSystemMessages:!0,supportsAdditionalTools:!0},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-6-luna":{id:"gpt-6-luna",name:"GPT-6 Luna",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:.1,output:.5,cacheRead:.01,cacheWrite:.125,tiers:[{inputTokensAbove:272e3,input:.2,output:.75,cacheRead:.02,cacheWrite:.25}]},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{supportsOpenAIGrammarTools:!0,supportsMidConvoSystemMessages:!0,supportsAdditionalTools:!0},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-6-sol":{id:"gpt-6-sol",name:"GPT-6 Sol",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:2,output:10,cacheRead:.2,cacheWrite:2.5,tiers:[{inputTokensAbove:272e3,input:4,output:15,cacheRead:.4,cacheWrite:5}]},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{supportsOpenAIGrammarTools:!0,supportsMidConvoSystemMessages:!0,supportsAdditionalTools:!0},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-6.1-sol":{id:"gpt-6.1-sol",name:"GPT-6.1 Sol",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:2,output:10,cacheRead:.1,cacheWrite:2.5,tiers:[{inputTokensAbove:272e3,input:4,output:15,cacheRead:.2,cacheWrite:5}]},contextWindow:105e4,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{supportsOpenAIGrammarTools:!0,supportsMidConvoSystemMessages:!0,supportsAdditionalTools:!0},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-6.1-terra":{id:"gpt-6.1-terra",name:"GPT-6.1 Terra",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.05,cacheWrite:1.25,tiers:[{inputTokensAbove:272e3,input:2,output:7.5,cacheRead:.1,cacheWrite:2.5}]},contextWindow:105e4,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{supportsOpenAIGrammarTools:!0},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:grok-4.5":{id:"grok-4.5",name:"Grok 4.5",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:2,output:6,cacheRead:.5,cacheWrite:0,tiers:[{inputTokensAbove:2e5,input:4,output:12,cacheRead:1,cacheWrite:0}]},contextWindow:5e5,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:grok-4.6":{id:"grok-4.6",name:"Grok 4.6",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:2,output:6,cacheRead:.5,cacheWrite:0,tiers:[{inputTokensAbove:2e5,input:4,output:12,cacheRead:1,cacheWrite:0}]},contextWindow:5e5,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:grok-4.7":{id:"grok-4.7",name:"Grok 4.7",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:2,output:6,cacheRead:.5,cacheWrite:0,tiers:[{inputTokensAbove:2e5,input:4,output:12,cacheRead:1,cacheWrite:0}]},contextWindow:5e5,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:mai-code-1.1-flash":{id:"mai-code-1.1-flash",name:"MAI-Code-1.1-Flash",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:.2,output:1.2,cacheRead:.02,cacheWrite:0},contextWindow:256e3,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"}}};function flattenModelCatalog(groups,type){return Object.fromEntries(Object.values(groups).flatMap(models=>Object.values(models)).filter(model=>model.type===type).map(model=>[model.id,model]))}function flattenChatModelCatalog(_provider,groups){return flattenModelCatalog(groups,"chat")}function flattenImageModelCatalog(_provider,groups){return flattenModelCatalog(groups,"image")}function flattenClassifierModelCatalog(_provider,groups){return flattenModelCatalog(groups,"classifier")}var GITHUB_COPILOT_MODELS=flattenChatModelCatalog("github-copilot",github_copilot_default),GITHUB_COPILOT_IMAGE_MODELS=flattenImageModelCatalog("github-copilot",github_copilot_default),GITHUB_COPILOT_CLASSIFIER_MODELS=flattenClassifierModelCatalog("github-copilot",github_copilot_default);function sleep(ms,signal){return new Promise((resolve,reject)=>{signal.throwIfAborted();let onAbort=()=>{clearTimeout(timeout),reject(signal.reason)},timeout=setTimeout(()=>{signal.removeEventListener("abort",onAbort),resolve()},ms);signal.addEventListener("abort",onAbort,{once:!0})})}var CANCEL_MESSAGE="Login cancelled",TIMEOUT_MESSAGE="Device flow timed out",SLOW_DOWN_TIMEOUT_MESSAGE="Device flow timed out after one or more slow_down responses. This is often caused by clock drift in WSL or VM environments. Please sync or restart the VM clock and try again.";function abortableSleep(ms,signal,cancelMessage){return new Promise((resolve,reject)=>{if(signal.aborted){reject(new Error(cancelMessage));return}let onAbort=()=>{clearTimeout(timeout),reject(new Error(cancelMessage))},timeout=setTimeout(()=>{signal.removeEventListener("abort",onAbort),resolve()},ms);signal.addEventListener("abort",onAbort,{once:!0})})}async function pollOAuthDeviceCodeFlow(options){let deadline=typeof options.expiresInSeconds=="number"?Date.now()+options.expiresInSeconds*1e3:Number.POSITIVE_INFINITY,intervalMs=Math.max(1e3,Math.floor((options.intervalSeconds??5)*1e3)),slowDownResponses=0;if(options.waitBeforeFirstPoll){let remainingMs=deadline-Date.now();remainingMs>0&&await abortableSleep(Math.min(intervalMs,remainingMs),options.signal,CANCEL_MESSAGE)}for(;Date.now()<deadline;){if(options.signal.aborted)throw new Error(CANCEL_MESSAGE);let result=await options.poll();if(result.status==="complete")return result.value;if(result.status==="failed")throw new Error(result.message);result.status==="slow_down"&&(slowDownResponses+=1,intervalMs=typeof result.intervalSeconds=="number"&&Number.isFinite(result.intervalSeconds)&&result.intervalSeconds>0?Math.max(1e3,Math.floor(result.intervalSeconds*1e3)):Math.max(1e3,intervalMs+5e3));let remainingMs=deadline-Date.now();if(remainingMs<=0)break;await abortableSleep(Math.min(intervalMs,remainingMs),options.signal,CANCEL_MESSAGE)}throw new Error(slowDownResponses>0?SLOW_DOWN_TIMEOUT_MESSAGE:TIMEOUT_MESSAGE)}var decode=s=>atob(s),CLIENT_ID=decode("SXYxLmI1MDdhMDhjODdlY2ZlOTg="),COPILOT_HEADERS={"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},COPILOT_API_VERSION="2026-06-01";function normalizeDomain(input){let trimmed=input.trim();if(!trimmed)return null;try{return(trimmed.includes("://")?new URL(trimmed):new URL(`https://${trimmed}`)).hostname}catch{return null}}function getUrls(domain){return{deviceCodeUrl:`https://${domain}/login/device/code`,accessTokenUrl:`https://${domain}/login/oauth/access_token`,copilotTokenUrl:`https://api.${domain}/copilot_internal/v2/token`}}function getBaseUrlFromToken(token){let match=token.match(/proxy-ep=([^;]+)/);return match?`https://${match[1].replace(/^proxy\./,"api.")}`:null}function getGitHubCopilotBaseUrl(token,enterpriseDomain){if(token){let urlFromToken=getBaseUrlFromToken(token);if(urlFromToken)return urlFromToken}return enterpriseDomain?`https://copilot-api.${enterpriseDomain}`:"https://api.individual.githubcopilot.com"}function asRecord(value){return value&&typeof value=="object"?value:void 0}function parseGitHubCopilotModelCatalog(raw,allowPolicyFallback){let data=asRecord(raw)?.data;if(!Array.isArray(data))throw new Error("Invalid Copilot models response");let accountModels=data.flatMap(rawItem=>{let item=asRecord(rawItem),id=item?.id;if(!item||typeof id!="string")return[];let capabilities=asRecord(item.capabilities);return asRecord(capabilities?.supports)?.tool_calls===!1?[]:[{id,pickerEnabled:item.model_picker_enabled===!0,policyState:asRecord(item.policy)?.state}]}),pickerModelIds=accountModels.filter(model=>model.pickerEnabled&&model.policyState!=="disabled").map(model=>model.id),usePolicyFallback=allowPolicyFallback&&pickerModelIds.length===0,availableModelIds=pickerModelIds.length>0||!allowPolicyFallback?pickerModelIds:accountModels.filter(model=>model.policyState==="enabled").map(model=>model.id),policyModelIds=accountModels.filter(model=>model.policyState==="unconfigured"&&Object.hasOwn(GITHUB_COPILOT_MODELS,model.id)&&(model.pickerEnabled||usePolicyFallback)).map(model=>model.id);return{availableModelIds,policyModelIds}}async function fetchWithRateLimitRetry(url,init,signal,retryPolicy){let retryBudgetSignal=retryPolicy.maxRetries>0&&retryPolicy.maxElapsedMs>0?AbortSignal.timeout(retryPolicy.maxElapsedMs):void 0,requestSignal=retryBudgetSignal?AbortSignal.any([signal,retryBudgetSignal]):signal,retryDeadline=retryBudgetSignal?Date.now()+retryPolicy.maxElapsedMs:void 0;for(let retry=0;;retry++){let response=await fetch(url,{...init,signal:AbortSignal.any([requestSignal,AbortSignal.timeout(5e3)])});if(response.status!==429||retry===retryPolicy.maxRetries)return response;let retryAfter=response.headers.get("retry-after"),delayMs=500*2**retry;if(retryAfter){let seconds=Number.parseFloat(retryAfter);if(delayMs=Number.isNaN(seconds)?Date.parse(retryAfter)-Date.now():seconds*1e3,!Number.isFinite(delayMs))return response}if(delayMs=Math.max(0,delayMs),retryDeadline!==void 0&&delayMs>=retryDeadline-Date.now())return response;await response.body?.cancel(),await sleep(delayMs,requestSignal)}}async function fetchGitHubCopilotModels(copilotToken,enterpriseDomain,signal,retryPolicy){let baseUrl=getGitHubCopilotBaseUrl(copilotToken,enterpriseDomain),allowPolicyFallback=baseUrl==="https://api.individual.githubcopilot.com",response=await fetchWithRateLimitRetry(`${baseUrl}/models`,{headers:{Accept:"application/json",Authorization:`Bearer ${copilotToken}`,...COPILOT_HEADERS,"X-GitHub-Api-Version":COPILOT_API_VERSION}},signal,retryPolicy);if(!response.ok)throw new Error(`${response.status} ${response.statusText}: ${await response.text()}`);return parseGitHubCopilotModelCatalog(await response.json(),allowPolicyFallback)}async function fetchJson(url,init){let response=await fetch(url,init);if(!response.ok){let text=await response.text();throw new Error(`${response.status} ${response.statusText}: ${text}`)}return response.json()}async function startDeviceFlow(domain,signal){let urls=getUrls(domain),data=await fetchJson(urls.deviceCodeUrl,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded","User-Agent":"GitHubCopilotChat/0.35.0"},body:new URLSearchParams({client_id:CLIENT_ID,scope:"read:user"}),signal});if(!data||typeof data!="object")throw new Error("Invalid device code response");let deviceCode=data.device_code,userCode=data.user_code,verificationUri=data.verification_uri,interval=data.interval,expiresIn=data.expires_in;if(typeof deviceCode!="string"||typeof userCode!="string"||typeof verificationUri!="string"||interval!==void 0&&typeof interval!="number"||typeof expiresIn!="number")throw new Error("Invalid device code response fields");let parsedUri;try{parsedUri=new URL(verificationUri)}catch{throw new Error("Untrusted verification_uri in device code response")}if(parsedUri.protocol!=="https:"&&parsedUri.protocol!=="http:")throw new Error("Untrusted verification_uri in device code response");return{device_code:deviceCode,user_code:userCode,verification_uri:parsedUri.href,interval,expires_in:expiresIn}}async function pollForGitHubAccessToken(domain,device,signal){let urls=getUrls(domain);return pollOAuthDeviceCodeFlow({intervalSeconds:device.interval,expiresInSeconds:device.expires_in,waitBeforeFirstPoll:!0,signal,poll:async()=>{let raw=await fetchJson(urls.accessTokenUrl,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded","User-Agent":"GitHubCopilotChat/0.35.0"},body:new URLSearchParams({client_id:CLIENT_ID,device_code:device.device_code,grant_type:"urn:ietf:params:oauth:grant-type:device_code"}),signal});if(raw&&typeof raw=="object"&&typeof raw.access_token=="string")return{status:"complete",value:raw.access_token};if(raw&&typeof raw=="object"&&typeof raw.error=="string"){let{error,error_description:description,interval}=raw;if(error==="authorization_pending")return{status:"pending"};if(error==="slow_down")return{status:"slow_down",intervalSeconds:typeof interval=="number"?interval:void 0};let descriptionSuffix=description?`: ${description}`:"";return{status:"failed",message:`Device flow failed: ${error}${descriptionSuffix}`}}return{status:"failed",message:"Invalid device token response"}}})}async function refreshGitHubCopilotAccessToken(refreshToken,enterpriseDomain,signal){let urls=getUrls(enterpriseDomain||"github.com"),raw=await fetchJson(urls.copilotTokenUrl,{headers:{Accept:"application/json",Authorization:`Bearer ${refreshToken}`,...COPILOT_HEADERS},signal});if(!raw||typeof raw!="object")throw new Error("Invalid Copilot token response");let token=raw.token,expiresAt=raw.expires_at;if(typeof token!="string"||typeof expiresAt!="number")throw new Error("Invalid Copilot token response fields");return{type:"oauth",refresh:refreshToken,access:token,expires:expiresAt*1e3-300*1e3,enterpriseUrl:enterpriseDomain}}async function refreshGitHubCopilotToken(refreshToken,enterpriseDomain,signal){let credentials=await refreshGitHubCopilotAccessToken(refreshToken,enterpriseDomain,signal),{availableModelIds}=await fetchGitHubCopilotModels(credentials.access,enterpriseDomain,signal,{maxRetries:0,maxElapsedMs:0});return{...credentials,availableModelIds}}async function enableGitHubCopilotModel(token,modelId,enterpriseDomain,signal){let url=`${getGitHubCopilotBaseUrl(token,enterpriseDomain)}/models/${modelId}/policy`,response;try{response=await fetchWithRateLimitRetry(url,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${token}`,...COPILOT_HEADERS,"openai-intent":"chat-policy","x-interaction-type":"chat-policy"},body:JSON.stringify({state:"enabled"})},signal,{maxRetries:2,maxElapsedMs:5e3})}catch(error){if(signal.aborted)throw error;return!1}if(response.status===429)throw new Error(`${response.status} ${response.statusText}: ${await response.text()}`);return response.ok}async function enableGitHubCopilotModels(token,modelIds,enterpriseDomain,signal){let enabledModelIds=[];for(let modelId of modelIds)try{await enableGitHubCopilotModel(token,modelId,enterpriseDomain,signal)&&enabledModelIds.push(modelId)}catch(error){if(signal.aborted)throw error;break}return enabledModelIds}async function loginGitHubCopilot(interaction){let input=await interaction.prompt({type:"text",message:"GitHub Enterprise URL/domain (blank for github.com)",placeholder:"company.ghe.com"});if(interaction.signal.aborted)throw new Error("Login cancelled");let trimmed=input.trim(),enterpriseDomain=normalizeDomain(input);if(trimmed&&!enterpriseDomain)throw new Error("Invalid GitHub Enterprise URL/domain");let domain=enterpriseDomain||"github.com",device=await startDeviceFlow(domain,interaction.signal);interaction.notify({type:"device_code",userCode:device.user_code,verificationUri:device.verification_uri,intervalSeconds:device.interval,expiresInSeconds:device.expires_in});let githubAccessToken=await pollForGitHubAccessToken(domain,device,interaction.signal),credentials=await refreshGitHubCopilotAccessToken(githubAccessToken,enterpriseDomain??void 0,interaction.signal),models=await fetchGitHubCopilotModels(credentials.access,enterpriseDomain??void 0,interaction.signal,{maxRetries:2,maxElapsedMs:5e3}),enabledModelIds=[];return models.policyModelIds.length>0&&(interaction.notify({type:"progress",message:"Enabling models..."}),enabledModelIds=await enableGitHubCopilotModels(credentials.access,models.policyModelIds,enterpriseDomain??void 0,interaction.signal)),{...credentials,availableModelIds:[...new Set([...models.availableModelIds,...enabledModelIds])]}}function copilotEnterpriseDomain(credential){let enterpriseUrl=credential.enterpriseUrl;if(!(typeof enterpriseUrl!="string"||!enterpriseUrl))return normalizeDomain(enterpriseUrl)??void 0}var githubCopilotOAuth={name:"GitHub Copilot",isSubscription:!0,login:loginGitHubCopilot,refresh:(credential,signal)=>refreshGitHubCopilotToken(credential.refresh,copilotEnterpriseDomain(credential),signal),async toAuth(credential){return{apiKey:credential.access,baseUrl:getGitHubCopilotBaseUrl(credential.access,copilotEnterpriseDomain(credential))}}};export{githubCopilotOAuth};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
- import{dist_exports as dist_exports3}from"./chunk-J5XSJ6CW.js";import{all_exports,compat_exports,compile_exports,dist_exports as dist_exports2,value_exports}from"./chunk-UZLVOWHH.js";import{build_exports}from"./chunk-BRYV63PL.js";import"./chunk-3EGEEHMN.js";import{dist_exports}from"./chunk-H2UJDH5M.js";import"./chunk-PG7P2LUM.js";import"./chunk-VYYRESZJ.js";import"./chunk-H2AI7MFJ.js";import"./chunk-6QGV3IWD.js";import"./chunk-3LTMO2WY.js";import"./chunk-USJZMAIR.js";import"./chunk-5AGIVGSV.js";import"./chunk-UKVNB6C4.js";import"./chunk-TMTOQ7H7.js";import"./chunk-7DDKXS2Q.js";import"./chunk-3V45WARH.js";import{models_exports}from"./chunk-D3OXAPLU.js";import"./chunk-LPXNMA2W.js";import"./chunk-H76KZMOI.js";import"./chunk-JXWJOIH4.js";var oauth_exports={};var VIRTUAL_MODULES={typebox:build_exports,"typebox/compile":compile_exports,"typebox/value":value_exports,"@sinclair/typebox":build_exports,"@sinclair/typebox/compile":compile_exports,"@sinclair/typebox/value":value_exports,"@earendil-works/pi-agent-core":dist_exports2,"@earendil-works/pi-tui":dist_exports,"@earendil-works/pi-ai":compat_exports,"@earendil-works/pi-ai/compat":compat_exports,"@earendil-works/pi-ai/models":models_exports,"@earendil-works/pi-ai/oauth":oauth_exports,"@earendil-works/pi-ai/providers/all":all_exports,"@earendil-works/pi-coding-agent":dist_exports3,"@mariozechner/pi-agent-core":dist_exports2,"@mariozechner/pi-tui":dist_exports,"@mariozechner/pi-ai":compat_exports,"@mariozechner/pi-ai/compat":compat_exports,"@mariozechner/pi-ai/models":models_exports,"@mariozechner/pi-ai/oauth":oauth_exports,"@mariozechner/pi-ai/providers/all":all_exports,"@mariozechner/pi-coding-agent":dist_exports3};export{VIRTUAL_MODULES};
2
+ import{dist_exports as dist_exports3}from"./chunk-4BTSL3N2.js";import{all_exports,compat_exports,compile_exports,dist_exports as dist_exports2,value_exports}from"./chunk-RQGKKZQM.js";import{build_exports}from"./chunk-BRYV63PL.js";import"./chunk-3EGEEHMN.js";import{dist_exports}from"./chunk-H2UJDH5M.js";import"./chunk-PG7P2LUM.js";import"./chunk-VYYRESZJ.js";import"./chunk-H2AI7MFJ.js";import"./chunk-6QGV3IWD.js";import"./chunk-3LTMO2WY.js";import"./chunk-USJZMAIR.js";import"./chunk-5AGIVGSV.js";import"./chunk-UKVNB6C4.js";import"./chunk-TMTOQ7H7.js";import"./chunk-7DDKXS2Q.js";import"./chunk-3V45WARH.js";import{models_exports}from"./chunk-D3OXAPLU.js";import"./chunk-LPXNMA2W.js";import"./chunk-H76KZMOI.js";import"./chunk-JXWJOIH4.js";var oauth_exports={};var VIRTUAL_MODULES={typebox:build_exports,"typebox/compile":compile_exports,"typebox/value":value_exports,"@sinclair/typebox":build_exports,"@sinclair/typebox/compile":compile_exports,"@sinclair/typebox/value":value_exports,"@earendil-works/pi-agent-core":dist_exports2,"@earendil-works/pi-tui":dist_exports,"@earendil-works/pi-ai":compat_exports,"@earendil-works/pi-ai/compat":compat_exports,"@earendil-works/pi-ai/models":models_exports,"@earendil-works/pi-ai/oauth":oauth_exports,"@earendil-works/pi-ai/providers/all":all_exports,"@earendil-works/pi-coding-agent":dist_exports3,"@mariozechner/pi-agent-core":dist_exports2,"@mariozechner/pi-tui":dist_exports,"@mariozechner/pi-ai":compat_exports,"@mariozechner/pi-ai/compat":compat_exports,"@mariozechner/pi-ai/models":models_exports,"@mariozechner/pi-ai/oauth":oauth_exports,"@mariozechner/pi-ai/providers/all":all_exports,"@mariozechner/pi-coding-agent":dist_exports3};export{VIRTUAL_MODULES};
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
3
- import{configureHttpDispatcher,main}from"./chunks/chunk-UZLVOWHH.js";import"./chunks/chunk-BRYV63PL.js";import"./chunks/chunk-3EGEEHMN.js";import"./chunks/chunk-H2UJDH5M.js";import"./chunks/chunk-PG7P2LUM.js";import"./chunks/chunk-VYYRESZJ.js";import"./chunks/chunk-H2AI7MFJ.js";import"./chunks/chunk-6QGV3IWD.js";import{APP_NAME}from"./chunks/chunk-3LTMO2WY.js";import"./chunks/chunk-USJZMAIR.js";import"./chunks/chunk-5AGIVGSV.js";import"./chunks/chunk-UKVNB6C4.js";import"./chunks/chunk-TMTOQ7H7.js";import"./chunks/chunk-7DDKXS2Q.js";import"./chunks/chunk-3V45WARH.js";import"./chunks/chunk-D3OXAPLU.js";import"./chunks/chunk-LPXNMA2W.js";import"./chunks/chunk-H76KZMOI.js";import"./chunks/chunk-JXWJOIH4.js";function setupCli(){process.title=APP_NAME,process.env.PI_CODING_AGENT="true",process.env.AI_AGENT="pi",process.emitWarning=(()=>{}),configureHttpDispatcher()}setupCli();main(process.argv.slice(2));
3
+ import{configureHttpDispatcher,main}from"./chunks/chunk-RQGKKZQM.js";import"./chunks/chunk-BRYV63PL.js";import"./chunks/chunk-3EGEEHMN.js";import"./chunks/chunk-H2UJDH5M.js";import"./chunks/chunk-PG7P2LUM.js";import"./chunks/chunk-VYYRESZJ.js";import"./chunks/chunk-H2AI7MFJ.js";import"./chunks/chunk-6QGV3IWD.js";import{APP_NAME}from"./chunks/chunk-3LTMO2WY.js";import"./chunks/chunk-USJZMAIR.js";import"./chunks/chunk-5AGIVGSV.js";import"./chunks/chunk-UKVNB6C4.js";import"./chunks/chunk-TMTOQ7H7.js";import"./chunks/chunk-7DDKXS2Q.js";import"./chunks/chunk-3V45WARH.js";import"./chunks/chunk-D3OXAPLU.js";import"./chunks/chunk-LPXNMA2W.js";import"./chunks/chunk-H76KZMOI.js";import"./chunks/chunk-JXWJOIH4.js";function setupCli(){process.title=APP_NAME,process.env.PI_CODING_AGENT="true",process.env.AI_AGENT="pi",process.emitWarning=(()=>{}),configureHttpDispatcher()}setupCli();main(process.argv.slice(2));
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
- import{ShowImagesSelectorComponent,ThemeSelectorComponent}from"./chunks/chunk-J5XSJ6CW.js";import{AgentSession,AgentSessionRuntime,AssistantMessageComponent,BashExecutionComponent,BorderedLoader,BranchSummaryMessageComponent,CURRENT_SESSION_VERSION,CompactionSummaryMessageComponent,CredentialSynchronizationError,CustomEditor,CustomMessageComponent,DEFAULT_COMPACTION_SETTINGS,DefaultPackageManager,DefaultResourceLoader,DynamicBorder,ExtensionEditorComponent,ExtensionInputComponent,ExtensionRunner,ExtensionSelectorComponent,FooterComponent,InteractiveMode,LoginDialogComponent,ModelRegistry,ModelRuntime,ModelSelectorComponent,OAuthSelectorComponent,RpcClient,SessionManager,SessionSelectorComponent,SettingsManager,SettingsSelectorComponent,SkillInvocationMessageComponent,ThinkingSelectorComponent,ToolExecutionComponent,TreeSelectorComponent,UserMessageComponent,UserMessageSelectorComponent,VIRTUAL_MODEL_STATE_ENTRY,buildContextEntries,buildSessionContext,buildSessionProjection,calculateContextTokens,collectEntriesForBranchSummary,compact,convertToLlm,convertToPng,copyToClipboard,createAgentSession,createAgentSessionFromServices,createAgentSessionRuntime,createAgentSessionServices,createBashTool,createBashToolDefinition,createCodemodeExtension,createCodingToolDefinitions,createCodingTools,createEditTool,createEditToolDefinition,createEventBus,createExtensionRuntime,createFindTool,createFindToolDefinition,createGrepTool,createGrepToolDefinition,createLocalBashOperations,createLsTool,createLsToolDefinition,createMcpExtension,createReadOnlyToolDefinitions,createReadOnlyTools,createReadTool,createReadToolDefinition,createSyntheticSourceInfo,createToolSearchExtension,createWriteTool,createWriteToolDefinition,defineTool,detectSupportedImageMimeTypeFromFile,discoverAndLoadExtensions,estimateTokens,findCutPoint,findTurnStartIndex,formatDimensionNote,formatSkillsForPrompt,generateBranchSummary,generateDiffString,generateSummary,generateSummaryWithUsage,generateUnifiedPatch,getLastAssistantUsage,getLatestCompactionEntry,isBashToolResult,isEditToolResult,isFindToolResult,isGrepToolResult,isLsToolResult,isReadToolResult,isToolCallEventType,isWriteToolResult,loadProjectContextFiles,loadSkills,loadSkillsFromDir,main,migrateSessionEntries,parseArgs,parseFrontmatter,parseSessionEntries,parseSkillBlock,prepareBranchEntries,renderDiff,resizeImage,resolveCliModel,resolveModelScopeWithDiagnostics,runPrintMode,runRpcMode,serializeConversation,sessionEntryToContextMessages,shouldCompact,stripFrontmatter,withFileMutationQueue,wrapRegisteredTool,wrapRegisteredTools}from"./chunks/chunk-UZLVOWHH.js";import{DEFAULT_MAX_BYTES,DEFAULT_MAX_LINES,formatReadLineRange,formatSize,truncateHead,truncateLine,truncateTail,truncateToVisualLines}from"./chunks/chunk-BRYV63PL.js";import{ArminComponent}from"./chunks/chunk-3EGEEHMN.js";import{Theme,getLanguageFromPath,getMarkdownTheme,getSelectListTheme,getSettingsListTheme,highlightCode,initTheme,keyHint,keyText,rawKeyHint}from"./chunks/chunk-H2UJDH5M.js";import{ProjectTrustStore,hasTrustRequiringProjectResources}from"./chunks/chunk-PG7P2LUM.js";import{readStoredCredential}from"./chunks/chunk-VYYRESZJ.js";import{getShellConfig}from"./chunks/chunk-H2AI7MFJ.js";import"./chunks/chunk-6QGV3IWD.js";import{CONFIG_DIR_NAME,VERSION,getAgentDir,getDocsPath,getExamplesPath,getPackageDir,getReadmePath}from"./chunks/chunk-3LTMO2WY.js";import"./chunks/chunk-USJZMAIR.js";import"./chunks/chunk-5AGIVGSV.js";import"./chunks/chunk-UKVNB6C4.js";import"./chunks/chunk-TMTOQ7H7.js";import"./chunks/chunk-7DDKXS2Q.js";import"./chunks/chunk-3V45WARH.js";import"./chunks/chunk-D3OXAPLU.js";import"./chunks/chunk-LPXNMA2W.js";import"./chunks/chunk-H76KZMOI.js";import"./chunks/chunk-JXWJOIH4.js";export{AgentSession,AgentSessionRuntime,ArminComponent,AssistantMessageComponent,BashExecutionComponent,BorderedLoader,BranchSummaryMessageComponent,CONFIG_DIR_NAME,CURRENT_SESSION_VERSION,CompactionSummaryMessageComponent,CredentialSynchronizationError,CustomEditor,CustomMessageComponent,DEFAULT_COMPACTION_SETTINGS,DEFAULT_MAX_BYTES,DEFAULT_MAX_LINES,DefaultPackageManager,DefaultResourceLoader,DynamicBorder,ExtensionEditorComponent,ExtensionInputComponent,ExtensionRunner,ExtensionSelectorComponent,FooterComponent,InteractiveMode,LoginDialogComponent,ModelRegistry,ModelRuntime,ModelSelectorComponent,OAuthSelectorComponent,ProjectTrustStore,RpcClient,SessionManager,SessionSelectorComponent,SettingsManager,SettingsSelectorComponent,ShowImagesSelectorComponent,SkillInvocationMessageComponent,Theme,ThemeSelectorComponent,ThinkingSelectorComponent,ToolExecutionComponent,TreeSelectorComponent,UserMessageComponent,UserMessageSelectorComponent,VERSION,VIRTUAL_MODEL_STATE_ENTRY,buildContextEntries,buildSessionContext,buildSessionProjection,calculateContextTokens,collectEntriesForBranchSummary,compact,convertToLlm,convertToPng,copyToClipboard,createAgentSession,createAgentSessionFromServices,createAgentSessionRuntime,createAgentSessionServices,createBashTool,createBashToolDefinition,createCodemodeExtension,createCodingToolDefinitions,createCodingTools,createEditTool,createEditToolDefinition,createEventBus,createExtensionRuntime,createFindTool,createFindToolDefinition,createGrepTool,createGrepToolDefinition,createLocalBashOperations,createLsTool,createLsToolDefinition,createMcpExtension,createReadOnlyToolDefinitions,createReadOnlyTools,createReadTool,createReadToolDefinition,createSyntheticSourceInfo,createToolSearchExtension,createWriteTool,createWriteToolDefinition,defineTool,detectSupportedImageMimeTypeFromFile,discoverAndLoadExtensions,estimateTokens,findCutPoint,findTurnStartIndex,formatDimensionNote,formatReadLineRange,formatSize,formatSkillsForPrompt,generateBranchSummary,generateDiffString,generateSummary,generateSummaryWithUsage,generateUnifiedPatch,getAgentDir,getDocsPath,getExamplesPath,getLanguageFromPath,getLastAssistantUsage,getLatestCompactionEntry,getMarkdownTheme,getPackageDir,getReadmePath,getSelectListTheme,getSettingsListTheme,getShellConfig,hasTrustRequiringProjectResources,highlightCode,initTheme,isBashToolResult,isEditToolResult,isFindToolResult,isGrepToolResult,isLsToolResult,isReadToolResult,isToolCallEventType,isWriteToolResult,keyHint,keyText,loadProjectContextFiles,loadSkills,loadSkillsFromDir,main,migrateSessionEntries,parseArgs,parseFrontmatter,parseSessionEntries,parseSkillBlock,prepareBranchEntries,rawKeyHint,readStoredCredential,renderDiff,resizeImage,resolveCliModel,resolveModelScopeWithDiagnostics,runPrintMode,runRpcMode,serializeConversation,sessionEntryToContextMessages,shouldCompact,stripFrontmatter,truncateHead,truncateLine,truncateTail,truncateToVisualLines,withFileMutationQueue,wrapRegisteredTool,wrapRegisteredTools};
2
+ import{ShowImagesSelectorComponent,ThemeSelectorComponent}from"./chunks/chunk-4BTSL3N2.js";import{AgentSession,AgentSessionRuntime,AssistantMessageComponent,BashExecutionComponent,BorderedLoader,BranchSummaryMessageComponent,CURRENT_SESSION_VERSION,CompactionSummaryMessageComponent,CredentialSynchronizationError,CustomEditor,CustomMessageComponent,DEFAULT_COMPACTION_SETTINGS,DefaultPackageManager,DefaultResourceLoader,DynamicBorder,ExtensionEditorComponent,ExtensionInputComponent,ExtensionRunner,ExtensionSelectorComponent,FooterComponent,InteractiveMode,LoginDialogComponent,ModelRegistry,ModelRuntime,ModelSelectorComponent,OAuthSelectorComponent,RpcClient,SessionManager,SessionSelectorComponent,SettingsManager,SettingsSelectorComponent,SkillInvocationMessageComponent,ThinkingSelectorComponent,ToolExecutionComponent,TreeSelectorComponent,UserMessageComponent,UserMessageSelectorComponent,VIRTUAL_MODEL_STATE_ENTRY,buildContextEntries,buildSessionContext,buildSessionProjection,calculateContextTokens,collectEntriesForBranchSummary,compact,convertToLlm,convertToPng,copyToClipboard,createAgentSession,createAgentSessionFromServices,createAgentSessionRuntime,createAgentSessionServices,createBashTool,createBashToolDefinition,createCodemodeExtension,createCodingToolDefinitions,createCodingTools,createEditTool,createEditToolDefinition,createEventBus,createExtensionRuntime,createFindTool,createFindToolDefinition,createGrepTool,createGrepToolDefinition,createLocalBashOperations,createLsTool,createLsToolDefinition,createMcpExtension,createReadOnlyToolDefinitions,createReadOnlyTools,createReadTool,createReadToolDefinition,createSyntheticSourceInfo,createToolSearchExtension,createWriteTool,createWriteToolDefinition,defineTool,detectSupportedImageMimeTypeFromFile,discoverAndLoadExtensions,estimateTokens,findCutPoint,findTurnStartIndex,formatDimensionNote,formatSkillsForPrompt,generateBranchSummary,generateDiffString,generateSummary,generateSummaryWithUsage,generateUnifiedPatch,getLastAssistantUsage,getLatestCompactionEntry,isBashToolResult,isEditToolResult,isFindToolResult,isGrepToolResult,isLsToolResult,isReadToolResult,isToolCallEventType,isWriteToolResult,loadProjectContextFiles,loadSkills,loadSkillsFromDir,main,migrateSessionEntries,parseArgs,parseFrontmatter,parseSessionEntries,parseSkillBlock,prepareBranchEntries,renderDiff,resizeImage,resolveCliModel,resolveModelScopeWithDiagnostics,runPrintMode,runRpcMode,serializeConversation,sessionEntryToContextMessages,shouldCompact,stripFrontmatter,withFileMutationQueue,wrapRegisteredTool,wrapRegisteredTools}from"./chunks/chunk-RQGKKZQM.js";import{DEFAULT_MAX_BYTES,DEFAULT_MAX_LINES,formatReadLineRange,formatSize,truncateHead,truncateLine,truncateTail,truncateToVisualLines}from"./chunks/chunk-BRYV63PL.js";import{ArminComponent}from"./chunks/chunk-3EGEEHMN.js";import{Theme,getLanguageFromPath,getMarkdownTheme,getSelectListTheme,getSettingsListTheme,highlightCode,initTheme,keyHint,keyText,rawKeyHint}from"./chunks/chunk-H2UJDH5M.js";import{ProjectTrustStore,hasTrustRequiringProjectResources}from"./chunks/chunk-PG7P2LUM.js";import{readStoredCredential}from"./chunks/chunk-VYYRESZJ.js";import{getShellConfig}from"./chunks/chunk-H2AI7MFJ.js";import"./chunks/chunk-6QGV3IWD.js";import{CONFIG_DIR_NAME,VERSION,getAgentDir,getDocsPath,getExamplesPath,getPackageDir,getReadmePath}from"./chunks/chunk-3LTMO2WY.js";import"./chunks/chunk-USJZMAIR.js";import"./chunks/chunk-5AGIVGSV.js";import"./chunks/chunk-UKVNB6C4.js";import"./chunks/chunk-TMTOQ7H7.js";import"./chunks/chunk-7DDKXS2Q.js";import"./chunks/chunk-3V45WARH.js";import"./chunks/chunk-D3OXAPLU.js";import"./chunks/chunk-LPXNMA2W.js";import"./chunks/chunk-H76KZMOI.js";import"./chunks/chunk-JXWJOIH4.js";export{AgentSession,AgentSessionRuntime,ArminComponent,AssistantMessageComponent,BashExecutionComponent,BorderedLoader,BranchSummaryMessageComponent,CONFIG_DIR_NAME,CURRENT_SESSION_VERSION,CompactionSummaryMessageComponent,CredentialSynchronizationError,CustomEditor,CustomMessageComponent,DEFAULT_COMPACTION_SETTINGS,DEFAULT_MAX_BYTES,DEFAULT_MAX_LINES,DefaultPackageManager,DefaultResourceLoader,DynamicBorder,ExtensionEditorComponent,ExtensionInputComponent,ExtensionRunner,ExtensionSelectorComponent,FooterComponent,InteractiveMode,LoginDialogComponent,ModelRegistry,ModelRuntime,ModelSelectorComponent,OAuthSelectorComponent,ProjectTrustStore,RpcClient,SessionManager,SessionSelectorComponent,SettingsManager,SettingsSelectorComponent,ShowImagesSelectorComponent,SkillInvocationMessageComponent,Theme,ThemeSelectorComponent,ThinkingSelectorComponent,ToolExecutionComponent,TreeSelectorComponent,UserMessageComponent,UserMessageSelectorComponent,VERSION,VIRTUAL_MODEL_STATE_ENTRY,buildContextEntries,buildSessionContext,buildSessionProjection,calculateContextTokens,collectEntriesForBranchSummary,compact,convertToLlm,convertToPng,copyToClipboard,createAgentSession,createAgentSessionFromServices,createAgentSessionRuntime,createAgentSessionServices,createBashTool,createBashToolDefinition,createCodemodeExtension,createCodingToolDefinitions,createCodingTools,createEditTool,createEditToolDefinition,createEventBus,createExtensionRuntime,createFindTool,createFindToolDefinition,createGrepTool,createGrepToolDefinition,createLocalBashOperations,createLsTool,createLsToolDefinition,createMcpExtension,createReadOnlyToolDefinitions,createReadOnlyTools,createReadTool,createReadToolDefinition,createSyntheticSourceInfo,createToolSearchExtension,createWriteTool,createWriteToolDefinition,defineTool,detectSupportedImageMimeTypeFromFile,discoverAndLoadExtensions,estimateTokens,findCutPoint,findTurnStartIndex,formatDimensionNote,formatReadLineRange,formatSize,formatSkillsForPrompt,generateBranchSummary,generateDiffString,generateSummary,generateSummaryWithUsage,generateUnifiedPatch,getAgentDir,getDocsPath,getExamplesPath,getLanguageFromPath,getLastAssistantUsage,getLatestCompactionEntry,getMarkdownTheme,getPackageDir,getReadmePath,getSelectListTheme,getSettingsListTheme,getShellConfig,hasTrustRequiringProjectResources,highlightCode,initTheme,isBashToolResult,isEditToolResult,isFindToolResult,isGrepToolResult,isLsToolResult,isReadToolResult,isToolCallEventType,isWriteToolResult,keyHint,keyText,loadProjectContextFiles,loadSkills,loadSkillsFromDir,main,migrateSessionEntries,parseArgs,parseFrontmatter,parseSessionEntries,parseSkillBlock,prepareBranchEntries,rawKeyHint,readStoredCredential,renderDiff,resizeImage,resolveCliModel,resolveModelScopeWithDiagnostics,runPrintMode,runRpcMode,serializeConversation,sessionEntryToContextMessages,shouldCompact,stripFrontmatter,truncateHead,truncateLine,truncateTail,truncateToVisualLines,withFileMutationQueue,wrapRegisteredTool,wrapRegisteredTools};
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
3
- import{configureHttpDispatcher,main}from"./chunks/chunk-UZLVOWHH.js";import"./chunks/chunk-BRYV63PL.js";import"./chunks/chunk-3EGEEHMN.js";import"./chunks/chunk-H2UJDH5M.js";import"./chunks/chunk-PG7P2LUM.js";import"./chunks/chunk-VYYRESZJ.js";import"./chunks/chunk-H2AI7MFJ.js";import"./chunks/chunk-6QGV3IWD.js";import{APP_NAME}from"./chunks/chunk-3LTMO2WY.js";import"./chunks/chunk-USJZMAIR.js";import"./chunks/chunk-5AGIVGSV.js";import"./chunks/chunk-UKVNB6C4.js";import"./chunks/chunk-TMTOQ7H7.js";import"./chunks/chunk-7DDKXS2Q.js";import"./chunks/chunk-3V45WARH.js";import"./chunks/chunk-D3OXAPLU.js";import"./chunks/chunk-LPXNMA2W.js";import"./chunks/chunk-H76KZMOI.js";import"./chunks/chunk-JXWJOIH4.js";process.title=`${APP_NAME}-rpc`;process.env.PI_CODING_AGENT="true";process.env.AI_AGENT="pi";process.emitWarning=(()=>{});configureHttpDispatcher();main(["--mode","rpc",...process.argv.slice(2)]);
3
+ import{configureHttpDispatcher,main}from"./chunks/chunk-RQGKKZQM.js";import"./chunks/chunk-BRYV63PL.js";import"./chunks/chunk-3EGEEHMN.js";import"./chunks/chunk-H2UJDH5M.js";import"./chunks/chunk-PG7P2LUM.js";import"./chunks/chunk-VYYRESZJ.js";import"./chunks/chunk-H2AI7MFJ.js";import"./chunks/chunk-6QGV3IWD.js";import{APP_NAME}from"./chunks/chunk-3LTMO2WY.js";import"./chunks/chunk-USJZMAIR.js";import"./chunks/chunk-5AGIVGSV.js";import"./chunks/chunk-UKVNB6C4.js";import"./chunks/chunk-TMTOQ7H7.js";import"./chunks/chunk-7DDKXS2Q.js";import"./chunks/chunk-3V45WARH.js";import"./chunks/chunk-D3OXAPLU.js";import"./chunks/chunk-LPXNMA2W.js";import"./chunks/chunk-H76KZMOI.js";import"./chunks/chunk-JXWJOIH4.js";process.title=`${APP_NAME}-rpc`;process.env.PI_CODING_AGENT="true";process.env.AI_AGENT="pi";process.emitWarning=(()=>{});configureHttpDispatcher();main(["--mode","rpc",...process.argv.slice(2)]);
@@ -1 +1 @@
1
- {"version":3,"file":"pi-server-observer.d.ts","sourceRoot":"","sources":["../../src/core/pi-server-observer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAA6B,eAAe,EAA6B,MAAM,uBAAuB,CAAC;AAEnH,OAAO,KAAK,EAAE,YAAY,EAAqB,MAAM,oBAAoB,CAAC;AAG1E,OAAO,EAAE,KAAK,gBAAgB,EAA+C,MAAM,0BAA0B,CAAC;AAC9G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIzD,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAEhF;AAED,KAAK,aAAa,GACf;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EA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O,CAAC,YAAY,CAAC,CAAgB;IACrC,OAAO,CAAC,eAAe,CAAC,CAAgB;IACxC,OAAO,CAAC,gBAAgB,CAAC,CAAS;IAClC,OAAO,CAAC,YAAY,CAAC,CAAS;IAC9B,OAAO,CAAC,kBAAkB,CAAC,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,YAAY,CAAC,CAAgB;IACrC,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,YAAY,CAAQ;IAC5B,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,WAAW,CAAC,CAAS;IAC7B,OAAO,CAAC,cAAc,CAAsB;IAC5C,OAAO,CAAC,cAAc,CAAM;IAC5B,OAAO,CAAC,WAAW,CAA6B;IAChD,OAAO,CAAC,aAAa,CAAM;IAC3B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAmC;IACzD,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,iBAAiB,CAAC,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAoB;IAC9C,OAAO,CAAC,mBAAmB,CAAM;IAEjC,YAAY,OAAO,EAAE,YAAY,EAiBhC;IAED,OAAO,CAAC,WAAW;IAsFnB,OAAO,CAAC,WAAW;IAYnB,OAAO,CAAC,QAAQ;IAkBhB,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,kBAAkB;IAe1B,OAAO,CAAC,OAAO;YAQD,OAAO;IAyFrB,OAAO,CAAC,KAAK;YAUC,UAAU;IA+ExB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAGrB;YAEa,aAAa;IA2B3B,OAAO,IAAI,IAAI,CAQd;CACD"}
@@ -333,6 +333,12 @@ export class PiServerObserver {
333
333
  }
334
334
  }
335
335
  catch (error) {
336
+ if (error instanceof TypeError &&
337
+ error.message === "terminated" &&
338
+ error.cause instanceof Error &&
339
+ "code" in error.cause &&
340
+ error.cause.code === "UND_ERR_SOCKET")
341
+ return;
336
342
  if (sessionId === this.session.sessionId && this.deletedSessionId !== sessionId)
337
343
  this.reportError(error);
338
344
  }
@@ -1 +1 @@
1
- {"version":3,"file":"pi-server-observer.js","sourceRoot":"","sources":["../../src/core/pi-server-observer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAyB,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAG9G,MAAM,SAAS,GAAG,IAAI,OAAO,EAAkC,CAAC;AAEhE,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,OAAqB;IAChE,MAAM,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC;AACvC,CAAC;AAuCD,SAAS,SAAS,CAAC,SAA6B;IAC/C,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,SAAS,CAAC;IAClD,IAAI,CAAC;QACJ,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAA6B,CAAC;QACjE,IACC,MAAM,CAAC,CAAC,KAAK,CAAC;YACd,OAAO,MAAM,CAAC,EAAE,KAAK,QAAQ;YAC7B,CAAC,MAAM,CAAC,KAAK,KAAK,YAAY,IAAI,MAAM,CAAC,KAAK,KAAK,cAAc,CAAC;YAElE,OAAO,MAAM,CAAC,KAAK,CAAC;IACtB,CAAC;IAAC,MAAM,CAAC;QACR,qEAAqE;IACtE,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC;AAED,SAAS,cAAc,CACtB,OAA6E;IAE7E,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,OAAO,C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AI,IAAI,CAAC,gBAAgB,KAAK,IAAI,CAAC,OAAO,CAAC,SAAS;oBACtF,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;YAChF,CAAC,CAAC,EAAE,EACJ,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,CAC1B,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,CAAC,KAAK,CAAC,uCAAuC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAChH,CAAC;gBAAS,CAAC;YACV,IAAI,CAAC,OAAO,EAAE,CAAC;QAChB,CAAC;IACF,CAAC;IAED,OAAO;QACN,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QACzB,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzB,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAClC,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC;QACzB,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;CACD","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport type { ImageContent, TextContent, TextSignatureV1, ThinkingContent, ToolCall } from \"@earendil-works/pi-ai\";\nimport { raceWithAbortSignal } from \"../utils/abort.ts\";\nimport type { AgentSession, AgentSessionEvent } from \"./agent-session.ts\";\nimport { bashExecutionToText } from \"./messages.ts\";\nimport { ChunkRequest } from \"./pi-server-request.ts\";\nimport { type ObserverSubagent, PiServerSubagents, resolvePiServerSubagents } from \"./pi-server-subagents.ts\";\nimport type { SessionEntry } from \"./session-manager.ts\";\n\nconst observers = new WeakMap<AgentSession, PiServerObserver>();\n\nexport async function closePiServerObserver(session: AgentSession): Promise<void> {\n\tawait observers.get(session)?.close();\n}\n\ntype ViewerContent =\n\t| { type: \"text\"; text: string; phase?: TextSignatureV1[\"phase\"] }\n\t| { type: \"thinking\"; thinking: string }\n\t| { type: \"toolCall\"; id: string; name: string; arguments: unknown }\n\t| { type: \"attachment\"; label: string };\n\nexport interface ObserverMessage {\n\tid: string;\n\trole: string;\n\tcontent: string | ViewerContent[];\n\ttimestamp: number;\n\tstopReason?: string;\n\tphase?: string;\n\terrorMessage?: string;\n}\n\ninterface ObserverTool {\n\tid: string;\n\tname: string;\n\targuments: unknown;\n\tresult?: unknown;\n\tstatus: \"running\" | \"completed\" | \"error\";\n}\n\nexport interface ObserverUpdate {\n\tsessionId: string;\n\tconnectionId: string;\n\tsequence: number;\n\tcwd: string;\n\ttitle: string;\n\tsubagents?: ObserverSubagent[];\n\treplace?: ObserverMessage[];\n\tappend?: ObserverMessage[];\n\tstatus: \"running\" | \"idle\";\n\tlive: { message: ObserverMessage | null; tools: ObserverTool[] };\n}\n\nfunction textPhase(signature: string | undefined): TextSignatureV1[\"phase\"] {\n\tif (!signature?.startsWith(\"{\")) return undefined;\n\ttry {\n\t\tconst parsed = JSON.parse(signature) as Partial<TextSignatureV1>;\n\t\tif (\n\t\t\tparsed.v === 1 &&\n\t\t\ttypeof parsed.id === \"string\" &&\n\t\t\t(parsed.phase === \"commentary\" || parsed.phase === \"final_answer\")\n\t\t)\n\t\t\treturn parsed.phase;\n\t} catch {\n\t\t// Provider signatures outside TextSignatureV1 have no display phase.\n\t}\n\treturn undefined;\n}\n\nfunction projectContent(\n\tcontent: string | (TextContent | ThinkingContent | ImageContent | ToolCall)[],\n): ObserverMessage[\"content\"] {\n\tif (typeof content === \"string\") return content;\n\treturn content.map((part): ViewerContent => {\n\t\tif (part.type === \"text\") return { type: \"text\", text: part.text, phase: textPhase(part.textSignature) };\n\t\tif (part.type === \"thinking\") return { type: \"thinking\", thinking: part.thinking };\n\t\tif (part.type === \"toolCall\")\n\t\t\treturn { type: \"toolCall\", id: part.id, name: part.name, arguments: part.arguments };\n\t\treturn { type: \"attachment\", label: part.mimeType };\n\t});\n}\n\nfunction projectMessage(id: string, message: AgentMessage, timestamp = message.timestamp): ObserverMessage | undefined {\n\tif (message.role === \"system\" || (message.role === \"custom\" && !message.display)) return undefined;\n\tlet content: ObserverMessage[\"content\"];\n\tif (message.role === \"bashExecution\") content = bashExecutionToText(message);\n\telse if (message.role === \"compactionSummary\" || message.role === \"branchSummary\") content = message.summary;\n\telse content = projectContent(message.content);\n\tconst projected: ObserverMessage = { id, role: message.role, content, timestamp };\n\tif (message.role === \"assistant\") {\n\t\tprojected.stopReason = message.stopReason;\n\t\tprojected.errorMessage = message.errorMessage;\n\t\tfor (const part of message.content) {\n\t\t\tconst phase = part.type === \"text\" ? textPhase(part.textSignature) : undefined;\n\t\t\tif (phase) projected.phase = phase;\n\t\t}\n\t}\n\treturn projected;\n}\n\nexport function projectObserverEntries(entries: SessionEntry[]): ObserverMessage[] {\n\tconst messages: ObserverMessage[] = [];\n\tfor (const entry of entries) {\n\t\tlet message: ObserverMessage | undefined;\n\t\tif (entry.type === \"message\") message = projectMessage(entry.id, entry.message, Date.parse(entry.timestamp));\n\t\telse if (entry.type === \"custom_message\" && entry.display) {\n\t\t\tmessage = {\n\t\t\t\tid: entry.id,\n\t\t\t\trole: \"custom\",\n\t\t\t\tcontent: projectContent(entry.content),\n\t\t\t\ttimestamp: Date.parse(entry.timestamp),\n\t\t\t};\n\t\t} else if (entry.type === \"compaction\" || entry.type === \"branch_summary\") {\n\t\t\tmessage = { id: entry.id, role: entry.type, content: entry.summary, timestamp: Date.parse(entry.timestamp) };\n\t\t}\n\t\tif (message) messages.push(message);\n\t}\n\treturn messages;\n}\n\n/** Publishes transcript updates independently of provider requests and durable server trees. */\nexport class PiServerObserver {\n\tprivate readonly session: AgentSession;\n\tprivate readonly unsubscribe: () => void;\n\tprivate controller?: AbortController;\n\tprivate timer?: ReturnType<typeof setTimeout>;\n\tprivate reconnectTimer?: ReturnType<typeof setTimeout>;\n\tprivate disposed = false;\n\tprivate closing = false;\n\tprivate closePromise?: Promise<void>;\n\tprivate connectionReady?: Promise<void>;\n\tprivate deletedSessionId?: string;\n\tprivate connectionId?: string;\n\tprivate connectedSessionId?: string;\n\tprivate sequence = 0;\n\tprivate sending = false;\n\tprivate flushPromise?: Promise<void>;\n\tprivate dirty = true;\n\tprivate historyDirty = true;\n\tprivate replace = true;\n\tprivate sentEntryId?: string;\n\tprivate pendingEntries: SessionEntry[] = [];\n\tprivate firstUserTitle = \"\";\n\tprivate liveMessage: AgentMessage | null = null;\n\tprivate liveMessageId = \"\";\n\tprivate readonly tools = new Map<string, ObserverTool>();\n\tprivate disconnected = false;\n\tprivate observedSessionId?: string;\n\tprivate readonly subagents: PiServerSubagents;\n\tprivate sentSubagentVersion = -1;\n\n\tconstructor(session: AgentSession) {\n\t\tthis.session = session;\n\t\tthis.subagents = new PiServerSubagents(session, () => {\n\t\t\tthis.dirty = true;\n\t\t\tthis.historyDirty = true;\n\t\t\tthis.schedule(0);\n\t\t});\n\t\tthis.syncSession();\n\t\tobservers.set(session, this);\n\t\tthis.unsubscribe = session.subscribe((event) => {\n\t\t\ttry {\n\t\t\t\tthis.handleEvent(event);\n\t\t\t} catch (error) {\n\t\t\t\tthis.reportError(error);\n\t\t\t}\n\t\t});\n\t\tvoid this.connect();\n\t}\n\n\tprivate handleEvent(event: AgentSessionEvent): void {\n\t\tthis.syncSession();\n\t\tswitch (event.type) {\n\t\t\tcase \"session_disposed\":\n\t\t\t\tthis.dispose();\n\t\t\t\treturn;\n\t\t\tcase \"run_state_changed\":\n\t\t\t\tresolvePiServerSubagents();\n\t\t\t\tif (!event.running) {\n\t\t\t\t\tthis.liveMessage = null;\n\t\t\t\t\tthis.tools.clear();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"message_start\":\n\t\t\t\tif (event.message.role !== \"assistant\") return;\n\t\t\t\tthis.tools.clear();\n\t\t\t\tthis.liveMessageId = randomUUID();\n\t\t\t\tthis.liveMessage = event.message;\n\t\t\t\tbreak;\n\t\t\tcase \"message_update\":\n\t\t\t\tthis.liveMessage = event.message;\n\t\t\t\tbreak;\n\t\t\tcase \"entry_appended\":\n\t\t\tcase \"message_committed\":\n\t\t\t\tif (this.connectionId && !this.historyDirty) {\n\t\t\t\t\tthis.pendingEntries.push(event.entry);\n\t\t\t\t\tif (this.pendingEntries.length > 64) {\n\t\t\t\t\t\tthis.pendingEntries = [];\n\t\t\t\t\t\tthis.historyDirty = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (event.entry.type === \"message\" && event.entry.message.role === \"assistant\") this.liveMessage = null;\n\t\t\t\tbreak;\n\t\t\tcase \"history_reconciled\":\n\t\t\tcase \"session_tree_changed\":\n\t\t\t\tthis.subagents.restore();\n\t\t\t\tif (this.deletedSessionId && this.deletedSessionId !== this.session.sessionId) {\n\t\t\t\t\tthis.deletedSessionId = undefined;\n\t\t\t\t\tvoid this.connect();\n\t\t\t\t}\n\t\t\t\tif (this.connectedSessionId && this.connectedSessionId !== this.session.sessionId) {\n\t\t\t\t\tthis.connectionId = undefined;\n\t\t\t\t\tthis.controller?.abort();\n\t\t\t\t}\n\t\t\t\tthis.replace = true;\n\t\t\t\tthis.historyDirty = true;\n\t\t\t\tbreak;\n\t\t\tcase \"compaction_end\":\n\t\t\t\tthis.historyDirty = true;\n\t\t\t\tbreak;\n\t\t\tcase \"compaction_start\":\n\t\t\t\tbreak;\n\t\t\tcase \"session_info_changed\":\n\t\t\t\tbreak;\n\t\t\tcase \"tool_execution_start\":\n\t\t\t\tthis.tools.set(event.toolCallId, {\n\t\t\t\t\tid: event.toolCallId,\n\t\t\t\t\tname: event.toolName,\n\t\t\t\t\targuments: event.args,\n\t\t\t\t\tstatus: \"running\",\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tcase \"tool_execution_update\": {\n\t\t\t\tconst tool = this.tools.get(event.toolCallId);\n\t\t\t\tif (tool) tool.result = { content: projectContent(event.partialResult.content) };\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"tool_execution_end\": {\n\t\t\t\tconst tool = this.tools.get(event.toolCallId);\n\t\t\t\tif (tool) {\n\t\t\t\t\ttool.result = { content: projectContent(event.result.content), isError: event.isError };\n\t\t\t\t\ttool.status = event.isError ? \"error\" : \"completed\";\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\treturn;\n\t\t}\n\t\tthis.dirty = true;\n\t\tthis.schedule(\n\t\t\tevent.type === \"run_state_changed\" || event.type === \"compaction_start\" || event.type === \"compaction_end\"\n\t\t\t\t? 0\n\t\t\t\t: 80,\n\t\t);\n\t}\n\n\tprivate syncSession(): void {\n\t\tif (this.observedSessionId === this.session.sessionId) return;\n\t\tthis.observedSessionId = this.session.sessionId;\n\t\tthis.subagents.syncSession();\n\t\tthis.sentSubagentVersion = -1;\n\t\tthis.sentEntryId = undefined;\n\t\tthis.pendingEntries = [];\n\t\tthis.firstUserTitle = \"\";\n\t\tthis.liveMessage = null;\n\t\tthis.tools.clear();\n\t}\n\n\tprivate schedule(delay: number): void {\n\t\tif (\n\t\t\tthis.disposed ||\n\t\t\tthis.closing ||\n\t\t\tthis.deletedSessionId === this.session.sessionId ||\n\t\t\t!this.dirty ||\n\t\t\t!this.connectionId ||\n\t\t\tthis.sending ||\n\t\t\tthis.timer\n\t\t)\n\t\t\treturn;\n\t\tthis.timer = setTimeout(() => {\n\t\t\tthis.timer = undefined;\n\t\t\tvoid this.flush();\n\t\t}, delay);\n\t\tthis.timer.unref();\n\t}\n\n\tprivate reportError(error: unknown): void {\n\t\tif (this.disposed || this.disconnected) return;\n\t\tthis.disconnected = true;\n\t\tconsole.error(`pi-server observer disconnected: ${error instanceof Error ? error.message : String(error)}`);\n\t}\n\n\tprivate stopDeletedSession(sessionId: string, controller: AbortController): void {\n\t\tif (sessionId === this.session.sessionId) {\n\t\t\tthis.deletedSessionId = sessionId;\n\t\t\tthis.connectionId = undefined;\n\t\t\tthis.pendingEntries = [];\n\t\t\tthis.liveMessage = null;\n\t\t\tthis.tools.clear();\n\t\t\tclearTimeout(this.timer);\n\t\t\tthis.timer = undefined;\n\t\t\tclearTimeout(this.reconnectTimer);\n\t\t\tthis.reconnectTimer = undefined;\n\t\t}\n\t\tcontroller.abort();\n\t}\n\n\tprivate request(signal: AbortSignal): ChunkRequest {\n\t\treturn new ChunkRequest({\n\t\t\tserverUrl: process.env.PI_SERVER_URL ?? \"http://127.0.0.1:4217\",\n\t\t\tauthToken: process.env.PI_SERVER_AUTH_TOKEN ?? \"\",\n\t\t\tsignal,\n\t\t});\n\t}\n\n\tprivate async connect(): Promise<void> {\n\t\tif (this.disposed || this.deletedSessionId === this.session.sessionId) return;\n\t\tthis.syncSession();\n\t\tconst controller = new AbortController();\n\t\tthis.controller = controller;\n\t\tconst sessionId = this.session.sessionId;\n\t\tthis.connectedSessionId = sessionId;\n\t\tlet resolveConnection: (() => void) | undefined;\n\t\tthis.connectionReady = new Promise<void>((resolve) => {\n\t\t\tresolveConnection = resolve;\n\t\t});\n\t\tconst timeout = setTimeout(() => controller.abort(new Error(\"connection timed out\")), 10000);\n\t\ttimeout.unref();\n\t\ttry {\n\t\t\tconst response = await this.request(controller.signal).getJson(\n\t\t\t\t`/api/observer/connect?sessionId=${encodeURIComponent(sessionId)}`,\n\t\t\t);\n\t\t\tif (response.status === 410) {\n\t\t\t\tthis.stopDeletedSession(sessionId, controller);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!response.ok || !response.headers.get(\"content-type\")?.includes(\"text/event-stream\") || !response.body) {\n\t\t\t\tthrow new Error(`connection failed (HTTP ${response.status})`);\n\t\t\t}\n\t\t\tconst reader = response.body.getReader();\n\t\t\tconst decoder = new TextDecoder();\n\t\t\tlet buffer = \"\";\n\t\t\tlet event = \"\";\n\t\t\ttry {\n\t\t\t\twhile (!this.disposed) {\n\t\t\t\t\tconst { done, value } = await reader.read();\n\t\t\t\t\tif (done) throw new Error(\"connection closed\");\n\t\t\t\t\tbuffer += decoder.decode(value, { stream: true });\n\t\t\t\t\tlet newline = buffer.indexOf(\"\\n\");\n\t\t\t\t\twhile (newline !== -1) {\n\t\t\t\t\t\tconst line = buffer.slice(0, newline).replace(/\\r$/, \"\");\n\t\t\t\t\t\tbuffer = buffer.slice(newline + 1);\n\t\t\t\t\t\tif (line.startsWith(\"event:\")) event = line.slice(6).trim();\n\t\t\t\t\t\tif (event === \"deleted\" && line.startsWith(\"data:\")) {\n\t\t\t\t\t\t\tthis.stopDeletedSession(sessionId, controller);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (event === \"connected\" && !this.connectionId && line.startsWith(\"data:\")) {\n\t\t\t\t\t\t\tconst connected = JSON.parse(line.slice(5)) as { connectionId: string };\n\t\t\t\t\t\t\tthis.connectionId = connected.connectionId;\n\t\t\t\t\t\t\tthis.sequence = 0;\n\t\t\t\t\t\t\tthis.sentSubagentVersion = -1;\n\t\t\t\t\t\t\tclearTimeout(timeout);\n\t\t\t\t\t\t\tthis.replace = true;\n\t\t\t\t\t\t\tthis.historyDirty = true;\n\t\t\t\t\t\t\tthis.dirty = true;\n\t\t\t\t\t\t\tthis.schedule(0);\n\t\t\t\t\t\t\tresolveConnection?.();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnewline = buffer.indexOf(\"\\n\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tawait reader.cancel();\n\t\t\t\treader.releaseLock();\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (sessionId === this.session.sessionId && this.deletedSessionId !== sessionId) this.reportError(error);\n\t\t} finally {\n\t\t\tresolveConnection?.();\n\t\t\tclearTimeout(timeout);\n\t\t\tcontroller.abort();\n\t\t\tif (this.controller === controller) this.connectionId = undefined;\n\t\t\tif (this.controller === controller && !this.disposed && !this.closing && this.deletedSessionId !== sessionId) {\n\t\t\t\tthis.reconnectTimer = setTimeout(\n\t\t\t\t\t() => {\n\t\t\t\t\t\tthis.reconnectTimer = undefined;\n\t\t\t\t\t\tvoid this.connect();\n\t\t\t\t\t},\n\t\t\t\t\tsessionId === this.session.sessionId ? 2000 : 0,\n\t\t\t\t);\n\t\t\t\tthis.reconnectTimer.unref();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate flush(): Promise<void> {\n\t\tif (this.flushPromise) return this.flushPromise;\n\t\tconst promise = this.sendUpdate();\n\t\tthis.flushPromise = promise;\n\t\tvoid promise.finally(() => {\n\t\t\tthis.flushPromise = undefined;\n\t\t});\n\t\treturn promise;\n\t}\n\n\tprivate async sendUpdate(): Promise<void> {\n\t\tthis.subagents.resolve();\n\t\tconst connectionId = this.connectionId;\n\t\tconst sessionId = this.connectedSessionId;\n\t\tconst controller = this.controller;\n\t\tif (\n\t\t\t!connectionId ||\n\t\t\t!sessionId ||\n\t\t\tsessionId !== this.session.sessionId ||\n\t\t\t!controller ||\n\t\t\tthis.disposed ||\n\t\t\tthis.deletedSessionId === sessionId ||\n\t\t\tthis.sending ||\n\t\t\t!this.dirty\n\t\t)\n\t\t\treturn;\n\t\tthis.sending = true;\n\t\tthis.dirty = false;\n\t\ttry {\n\t\t\tconst branch = this.historyDirty ? this.session.sessionManager.getBranch() : undefined;\n\t\t\tconst sentIndex = branch && this.sentEntryId ? branch.findIndex((entry) => entry.id === this.sentEntryId) : -1;\n\t\t\tconst replace = this.replace || (branch !== undefined && this.sentEntryId !== undefined && sentIndex === -1);\n\t\t\tthis.historyDirty = false;\n\t\t\tthis.replace = false;\n\t\t\tconst entries = branch ? (replace ? branch : branch.slice(sentIndex + 1)) : this.pendingEntries;\n\t\t\tthis.pendingEntries = [];\n\t\t\tconst messages = projectObserverEntries(entries);\n\t\t\tif (replace) this.firstUserTitle = \"\";\n\t\t\tif (!this.firstUserTitle) {\n\t\t\t\tconst firstUserContent = messages.find((message) => message.role === \"user\")?.content;\n\t\t\t\tthis.firstUserTitle = (\n\t\t\t\t\ttypeof firstUserContent === \"string\"\n\t\t\t\t\t\t? firstUserContent\n\t\t\t\t\t\t: (firstUserContent\n\t\t\t\t\t\t\t\t?.filter((part) => part.type === \"text\")\n\t\t\t\t\t\t\t\t.map((part) => part.text)\n\t\t\t\t\t\t\t\t.join(\"\") ?? \"\")\n\t\t\t\t).slice(0, 120);\n\t\t\t}\n\t\t\tconst subagentVersion = this.subagents.version;\n\t\t\tconst update: ObserverUpdate = {\n\t\t\t\tsessionId,\n\t\t\t\tconnectionId,\n\t\t\t\tsequence: ++this.sequence,\n\t\t\t\tcwd: this.session.sessionManager.getCwd(),\n\t\t\t\ttitle: this.session.sessionManager.getSessionName() ?? this.firstUserTitle,\n\t\t\t\t...(subagentVersion !== this.sentSubagentVersion ? { subagents: this.subagents.snapshot() } : {}),\n\t\t\t\t...(replace ? { replace: messages } : messages.length ? { append: messages } : {}),\n\t\t\t\tstatus: this.session.isIdle ? \"idle\" : \"running\",\n\t\t\t\tlive: {\n\t\t\t\t\tmessage: this.liveMessage ? (projectMessage(this.liveMessageId, this.liveMessage) ?? null) : null,\n\t\t\t\t\ttools: [...this.tools.values()],\n\t\t\t\t},\n\t\t\t};\n\t\t\tconst response = await this.request(controller.signal).postJson(\"/api/observer\", update);\n\t\t\tif (response.status === 410) {\n\t\t\t\tthis.stopDeletedSession(sessionId, controller);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!response.ok) throw new Error(`update failed (HTTP ${response.status})`);\n\t\t\tconst result = (await response.json()) as { accepted: boolean };\n\t\t\tif (!result.accepted) throw new Error(\"update was not accepted\");\n\t\t\tif (sessionId !== this.session.sessionId) return;\n\t\t\tthis.sentSubagentVersion = subagentVersion;\n\t\t\tif (entries.length > 0) this.sentEntryId = entries.at(-1)?.id;\n\t\t\telse if (replace) this.sentEntryId = undefined;\n\t\t\tif (this.disconnected) {\n\t\t\t\tthis.disconnected = false;\n\t\t\t\tconsole.error(\"pi-server observer connected\");\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (sessionId === this.session.sessionId && this.deletedSessionId !== sessionId) this.reportError(error);\n\t\t\tcontroller.abort();\n\t\t} finally {\n\t\t\tthis.sending = false;\n\t\t\tthis.schedule(80);\n\t\t}\n\t}\n\n\tclose(): Promise<void> {\n\t\tthis.closePromise ??= this.drainAndClose();\n\t\treturn this.closePromise;\n\t}\n\n\tprivate async drainAndClose(): Promise<void> {\n\t\tif (this.disposed) return;\n\t\tthis.closing = true;\n\t\tclearTimeout(this.timer);\n\t\tthis.timer = undefined;\n\t\tclearTimeout(this.reconnectTimer);\n\t\ttry {\n\t\t\tawait raceWithAbortSignal(\n\t\t\t\t(async () => {\n\t\t\t\t\tif (this.deletedSessionId === this.session.sessionId) return;\n\t\t\t\t\tif (!this.connectionId && this.controller?.signal.aborted) void this.connect();\n\t\t\t\t\tawait this.connectionReady;\n\t\t\t\t\tawait this.flushPromise;\n\t\t\t\t\tif (!this.connectionId) throw new Error(\"final transcript was not delivered: observer is disconnected\");\n\t\t\t\t\twhile (this.dirty && this.connectionId && !this.disposed) await this.flush();\n\t\t\t\t\tif (this.controller?.signal.aborted && this.deletedSessionId !== this.session.sessionId)\n\t\t\t\t\t\tthrow new Error(\"final transcript was not delivered: observer update failed\");\n\t\t\t\t})(),\n\t\t\t\tAbortSignal.timeout(10000),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tconsole.error(`pi-server observer shutdown failed: ${error instanceof Error ? error.message : String(error)}`);\n\t\t} finally {\n\t\t\tthis.dispose();\n\t\t}\n\t}\n\n\tdispose(): void {\n\t\tthis.disposed = true;\n\t\tthis.unsubscribe();\n\t\tthis.subagents.dispose();\n\t\tclearTimeout(this.timer);\n\t\tclearTimeout(this.reconnectTimer);\n\t\tthis.controller?.abort();\n\t\tobservers.delete(this.session);\n\t}\n}\n"]}
1
+ {"version":3,"file":"pi-server-observer.js","sourceRoot":"","sources":["../../src/core/pi-server-observer.ts"],"names":[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AE,MAAM,CAAC,OAAO,IAAI,IAAI,CAAC,gBAAgB,KAAK,IAAI,CAAC,OAAO,CAAC,SAAS;oBACtF,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;YAChF,CAAC,CAAC,EAAE,EACJ,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,CAC1B,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,CAAC,KAAK,CAAC,uCAAuC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAChH,CAAC;gBAAS,CAAC;YACV,IAAI,CAAC,OAAO,EAAE,CAAC;QAChB,CAAC;IACF,CAAC;IAED,OAAO;QACN,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QACzB,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzB,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAClC,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC;QACzB,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;CACD","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport type { ImageContent, TextContent, TextSignatureV1, ThinkingContent, ToolCall } from \"@earendil-works/pi-ai\";\nimport { raceWithAbortSignal } from \"../utils/abort.ts\";\nimport type { AgentSession, AgentSessionEvent } from \"./agent-session.ts\";\nimport { bashExecutionToText } from \"./messages.ts\";\nimport { ChunkRequest } from \"./pi-server-request.ts\";\nimport { type ObserverSubagent, PiServerSubagents, resolvePiServerSubagents } from \"./pi-server-subagents.ts\";\nimport type { SessionEntry } from \"./session-manager.ts\";\n\nconst observers = new WeakMap<AgentSession, PiServerObserver>();\n\nexport async function closePiServerObserver(session: AgentSession): Promise<void> {\n\tawait observers.get(session)?.close();\n}\n\ntype ViewerContent =\n\t| { type: \"text\"; text: string; phase?: TextSignatureV1[\"phase\"] }\n\t| { type: \"thinking\"; thinking: string }\n\t| { type: \"toolCall\"; id: string; name: string; arguments: unknown }\n\t| { type: \"attachment\"; label: string };\n\nexport interface ObserverMessage {\n\tid: string;\n\trole: string;\n\tcontent: string | ViewerContent[];\n\ttimestamp: number;\n\tstopReason?: string;\n\tphase?: string;\n\terrorMessage?: string;\n}\n\ninterface ObserverTool {\n\tid: string;\n\tname: string;\n\targuments: unknown;\n\tresult?: unknown;\n\tstatus: \"running\" | \"completed\" | \"error\";\n}\n\nexport interface ObserverUpdate {\n\tsessionId: string;\n\tconnectionId: string;\n\tsequence: number;\n\tcwd: string;\n\ttitle: string;\n\tsubagents?: ObserverSubagent[];\n\treplace?: ObserverMessage[];\n\tappend?: ObserverMessage[];\n\tstatus: \"running\" | \"idle\";\n\tlive: { message: ObserverMessage | null; tools: ObserverTool[] };\n}\n\nfunction textPhase(signature: string | undefined): TextSignatureV1[\"phase\"] {\n\tif (!signature?.startsWith(\"{\")) return undefined;\n\ttry {\n\t\tconst parsed = JSON.parse(signature) as Partial<TextSignatureV1>;\n\t\tif (\n\t\t\tparsed.v === 1 &&\n\t\t\ttypeof parsed.id === \"string\" &&\n\t\t\t(parsed.phase === \"commentary\" || parsed.phase === \"final_answer\")\n\t\t)\n\t\t\treturn parsed.phase;\n\t} catch {\n\t\t// Provider signatures outside TextSignatureV1 have no display phase.\n\t}\n\treturn undefined;\n}\n\nfunction projectContent(\n\tcontent: string | (TextContent | ThinkingContent | ImageContent | ToolCall)[],\n): ObserverMessage[\"content\"] {\n\tif (typeof content === \"string\") return content;\n\treturn content.map((part): ViewerContent => {\n\t\tif (part.type === \"text\") return { type: \"text\", text: part.text, phase: textPhase(part.textSignature) };\n\t\tif (part.type === \"thinking\") return { type: \"thinking\", thinking: part.thinking };\n\t\tif (part.type === \"toolCall\")\n\t\t\treturn { type: \"toolCall\", id: part.id, name: part.name, arguments: part.arguments };\n\t\treturn { type: \"attachment\", label: part.mimeType };\n\t});\n}\n\nfunction projectMessage(id: string, message: AgentMessage, timestamp = message.timestamp): ObserverMessage | undefined {\n\tif (message.role === \"system\" || (message.role === \"custom\" && !message.display)) return undefined;\n\tlet content: ObserverMessage[\"content\"];\n\tif (message.role === \"bashExecution\") content = bashExecutionToText(message);\n\telse if (message.role === \"compactionSummary\" || message.role === \"branchSummary\") content = message.summary;\n\telse content = projectContent(message.content);\n\tconst projected: ObserverMessage = { id, role: message.role, content, timestamp };\n\tif (message.role === \"assistant\") {\n\t\tprojected.stopReason = message.stopReason;\n\t\tprojected.errorMessage = message.errorMessage;\n\t\tfor (const part of message.content) {\n\t\t\tconst phase = part.type === \"text\" ? textPhase(part.textSignature) : undefined;\n\t\t\tif (phase) projected.phase = phase;\n\t\t}\n\t}\n\treturn projected;\n}\n\nexport function projectObserverEntries(entries: SessionEntry[]): ObserverMessage[] {\n\tconst messages: ObserverMessage[] = [];\n\tfor (const entry of entries) {\n\t\tlet message: ObserverMessage | undefined;\n\t\tif (entry.type === \"message\") message = projectMessage(entry.id, entry.message, Date.parse(entry.timestamp));\n\t\telse if (entry.type === \"custom_message\" && entry.display) {\n\t\t\tmessage = {\n\t\t\t\tid: entry.id,\n\t\t\t\trole: \"custom\",\n\t\t\t\tcontent: projectContent(entry.content),\n\t\t\t\ttimestamp: Date.parse(entry.timestamp),\n\t\t\t};\n\t\t} else if (entry.type === \"compaction\" || entry.type === \"branch_summary\") {\n\t\t\tmessage = { id: entry.id, role: entry.type, content: entry.summary, timestamp: Date.parse(entry.timestamp) };\n\t\t}\n\t\tif (message) messages.push(message);\n\t}\n\treturn messages;\n}\n\n/** Publishes transcript updates independently of provider requests and durable server trees. */\nexport class PiServerObserver {\n\tprivate readonly session: AgentSession;\n\tprivate readonly unsubscribe: () => void;\n\tprivate controller?: AbortController;\n\tprivate timer?: ReturnType<typeof setTimeout>;\n\tprivate reconnectTimer?: ReturnType<typeof setTimeout>;\n\tprivate disposed = false;\n\tprivate closing = false;\n\tprivate closePromise?: Promise<void>;\n\tprivate connectionReady?: Promise<void>;\n\tprivate deletedSessionId?: string;\n\tprivate connectionId?: string;\n\tprivate connectedSessionId?: string;\n\tprivate sequence = 0;\n\tprivate sending = false;\n\tprivate flushPromise?: Promise<void>;\n\tprivate dirty = true;\n\tprivate historyDirty = true;\n\tprivate replace = true;\n\tprivate sentEntryId?: string;\n\tprivate pendingEntries: SessionEntry[] = [];\n\tprivate firstUserTitle = \"\";\n\tprivate liveMessage: AgentMessage | null = null;\n\tprivate liveMessageId = \"\";\n\tprivate readonly tools = new Map<string, ObserverTool>();\n\tprivate disconnected = false;\n\tprivate observedSessionId?: string;\n\tprivate readonly subagents: PiServerSubagents;\n\tprivate sentSubagentVersion = -1;\n\n\tconstructor(session: AgentSession) {\n\t\tthis.session = session;\n\t\tthis.subagents = new PiServerSubagents(session, () => {\n\t\t\tthis.dirty = true;\n\t\t\tthis.historyDirty = true;\n\t\t\tthis.schedule(0);\n\t\t});\n\t\tthis.syncSession();\n\t\tobservers.set(session, this);\n\t\tthis.unsubscribe = session.subscribe((event) => {\n\t\t\ttry {\n\t\t\t\tthis.handleEvent(event);\n\t\t\t} catch (error) {\n\t\t\t\tthis.reportError(error);\n\t\t\t}\n\t\t});\n\t\tvoid this.connect();\n\t}\n\n\tprivate handleEvent(event: AgentSessionEvent): void {\n\t\tthis.syncSession();\n\t\tswitch (event.type) {\n\t\t\tcase \"session_disposed\":\n\t\t\t\tthis.dispose();\n\t\t\t\treturn;\n\t\t\tcase \"run_state_changed\":\n\t\t\t\tresolvePiServerSubagents();\n\t\t\t\tif (!event.running) {\n\t\t\t\t\tthis.liveMessage = null;\n\t\t\t\t\tthis.tools.clear();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"message_start\":\n\t\t\t\tif (event.message.role !== \"assistant\") return;\n\t\t\t\tthis.tools.clear();\n\t\t\t\tthis.liveMessageId = randomUUID();\n\t\t\t\tthis.liveMessage = event.message;\n\t\t\t\tbreak;\n\t\t\tcase \"message_update\":\n\t\t\t\tthis.liveMessage = event.message;\n\t\t\t\tbreak;\n\t\t\tcase \"entry_appended\":\n\t\t\tcase \"message_committed\":\n\t\t\t\tif (this.connectionId && !this.historyDirty) {\n\t\t\t\t\tthis.pendingEntries.push(event.entry);\n\t\t\t\t\tif (this.pendingEntries.length > 64) {\n\t\t\t\t\t\tthis.pendingEntries = [];\n\t\t\t\t\t\tthis.historyDirty = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (event.entry.type === \"message\" && event.entry.message.role === \"assistant\") this.liveMessage = null;\n\t\t\t\tbreak;\n\t\t\tcase \"history_reconciled\":\n\t\t\tcase \"session_tree_changed\":\n\t\t\t\tthis.subagents.restore();\n\t\t\t\tif (this.deletedSessionId && this.deletedSessionId !== this.session.sessionId) {\n\t\t\t\t\tthis.deletedSessionId = undefined;\n\t\t\t\t\tvoid this.connect();\n\t\t\t\t}\n\t\t\t\tif (this.connectedSessionId && this.connectedSessionId !== this.session.sessionId) {\n\t\t\t\t\tthis.connectionId = undefined;\n\t\t\t\t\tthis.controller?.abort();\n\t\t\t\t}\n\t\t\t\tthis.replace = true;\n\t\t\t\tthis.historyDirty = true;\n\t\t\t\tbreak;\n\t\t\tcase \"compaction_end\":\n\t\t\t\tthis.historyDirty = true;\n\t\t\t\tbreak;\n\t\t\tcase \"compaction_start\":\n\t\t\t\tbreak;\n\t\t\tcase \"session_info_changed\":\n\t\t\t\tbreak;\n\t\t\tcase \"tool_execution_start\":\n\t\t\t\tthis.tools.set(event.toolCallId, {\n\t\t\t\t\tid: event.toolCallId,\n\t\t\t\t\tname: event.toolName,\n\t\t\t\t\targuments: event.args,\n\t\t\t\t\tstatus: \"running\",\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tcase \"tool_execution_update\": {\n\t\t\t\tconst tool = this.tools.get(event.toolCallId);\n\t\t\t\tif (tool) tool.result = { content: projectContent(event.partialResult.content) };\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"tool_execution_end\": {\n\t\t\t\tconst tool = this.tools.get(event.toolCallId);\n\t\t\t\tif (tool) {\n\t\t\t\t\ttool.result = { content: projectContent(event.result.content), isError: event.isError };\n\t\t\t\t\ttool.status = event.isError ? \"error\" : \"completed\";\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\treturn;\n\t\t}\n\t\tthis.dirty = true;\n\t\tthis.schedule(\n\t\t\tevent.type === \"run_state_changed\" || event.type === \"compaction_start\" || event.type === \"compaction_end\"\n\t\t\t\t? 0\n\t\t\t\t: 80,\n\t\t);\n\t}\n\n\tprivate syncSession(): void {\n\t\tif (this.observedSessionId === this.session.sessionId) return;\n\t\tthis.observedSessionId = this.session.sessionId;\n\t\tthis.subagents.syncSession();\n\t\tthis.sentSubagentVersion = -1;\n\t\tthis.sentEntryId = undefined;\n\t\tthis.pendingEntries = [];\n\t\tthis.firstUserTitle = \"\";\n\t\tthis.liveMessage = null;\n\t\tthis.tools.clear();\n\t}\n\n\tprivate schedule(delay: number): void {\n\t\tif (\n\t\t\tthis.disposed ||\n\t\t\tthis.closing ||\n\t\t\tthis.deletedSessionId === this.session.sessionId ||\n\t\t\t!this.dirty ||\n\t\t\t!this.connectionId ||\n\t\t\tthis.sending ||\n\t\t\tthis.timer\n\t\t)\n\t\t\treturn;\n\t\tthis.timer = setTimeout(() => {\n\t\t\tthis.timer = undefined;\n\t\t\tvoid this.flush();\n\t\t}, delay);\n\t\tthis.timer.unref();\n\t}\n\n\tprivate reportError(error: unknown): void {\n\t\tif (this.disposed || this.disconnected) return;\n\t\tthis.disconnected = true;\n\t\tconsole.error(`pi-server observer disconnected: ${error instanceof Error ? error.message : String(error)}`);\n\t}\n\n\tprivate stopDeletedSession(sessionId: string, controller: AbortController): void {\n\t\tif (sessionId === this.session.sessionId) {\n\t\t\tthis.deletedSessionId = sessionId;\n\t\t\tthis.connectionId = undefined;\n\t\t\tthis.pendingEntries = [];\n\t\t\tthis.liveMessage = null;\n\t\t\tthis.tools.clear();\n\t\t\tclearTimeout(this.timer);\n\t\t\tthis.timer = undefined;\n\t\t\tclearTimeout(this.reconnectTimer);\n\t\t\tthis.reconnectTimer = undefined;\n\t\t}\n\t\tcontroller.abort();\n\t}\n\n\tprivate request(signal: AbortSignal): ChunkRequest {\n\t\treturn new ChunkRequest({\n\t\t\tserverUrl: process.env.PI_SERVER_URL ?? \"http://127.0.0.1:4217\",\n\t\t\tauthToken: process.env.PI_SERVER_AUTH_TOKEN ?? \"\",\n\t\t\tsignal,\n\t\t});\n\t}\n\n\tprivate async connect(): Promise<void> {\n\t\tif (this.disposed || this.deletedSessionId === this.session.sessionId) return;\n\t\tthis.syncSession();\n\t\tconst controller = new AbortController();\n\t\tthis.controller = controller;\n\t\tconst sessionId = this.session.sessionId;\n\t\tthis.connectedSessionId = sessionId;\n\t\tlet resolveConnection: (() => void) | undefined;\n\t\tthis.connectionReady = new Promise<void>((resolve) => {\n\t\t\tresolveConnection = resolve;\n\t\t});\n\t\tconst timeout = setTimeout(() => controller.abort(new Error(\"connection timed out\")), 10000);\n\t\ttimeout.unref();\n\t\ttry {\n\t\t\tconst response = await this.request(controller.signal).getJson(\n\t\t\t\t`/api/observer/connect?sessionId=${encodeURIComponent(sessionId)}`,\n\t\t\t);\n\t\t\tif (response.status === 410) {\n\t\t\t\tthis.stopDeletedSession(sessionId, controller);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!response.ok || !response.headers.get(\"content-type\")?.includes(\"text/event-stream\") || !response.body) {\n\t\t\t\tthrow new Error(`connection failed (HTTP ${response.status})`);\n\t\t\t}\n\t\t\tconst reader = response.body.getReader();\n\t\t\tconst decoder = new TextDecoder();\n\t\t\tlet buffer = \"\";\n\t\t\tlet event = \"\";\n\t\t\ttry {\n\t\t\t\twhile (!this.disposed) {\n\t\t\t\t\tconst { done, value } = await reader.read();\n\t\t\t\t\tif (done) throw new Error(\"connection closed\");\n\t\t\t\t\tbuffer += decoder.decode(value, { stream: true });\n\t\t\t\t\tlet newline = buffer.indexOf(\"\\n\");\n\t\t\t\t\twhile (newline !== -1) {\n\t\t\t\t\t\tconst line = buffer.slice(0, newline).replace(/\\r$/, \"\");\n\t\t\t\t\t\tbuffer = buffer.slice(newline + 1);\n\t\t\t\t\t\tif (line.startsWith(\"event:\")) event = line.slice(6).trim();\n\t\t\t\t\t\tif (event === \"deleted\" && line.startsWith(\"data:\")) {\n\t\t\t\t\t\t\tthis.stopDeletedSession(sessionId, controller);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (event === \"connected\" && !this.connectionId && line.startsWith(\"data:\")) {\n\t\t\t\t\t\t\tconst connected = JSON.parse(line.slice(5)) as { connectionId: string };\n\t\t\t\t\t\t\tthis.connectionId = connected.connectionId;\n\t\t\t\t\t\t\tthis.sequence = 0;\n\t\t\t\t\t\t\tthis.sentSubagentVersion = -1;\n\t\t\t\t\t\t\tclearTimeout(timeout);\n\t\t\t\t\t\t\tthis.replace = true;\n\t\t\t\t\t\t\tthis.historyDirty = true;\n\t\t\t\t\t\t\tthis.dirty = true;\n\t\t\t\t\t\t\tthis.schedule(0);\n\t\t\t\t\t\t\tresolveConnection?.();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnewline = buffer.indexOf(\"\\n\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tawait reader.cancel();\n\t\t\t\treader.releaseLock();\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (\n\t\t\t\terror instanceof TypeError &&\n\t\t\t\terror.message === \"terminated\" &&\n\t\t\t\terror.cause instanceof Error &&\n\t\t\t\t\"code\" in error.cause &&\n\t\t\t\terror.cause.code === \"UND_ERR_SOCKET\"\n\t\t\t)\n\t\t\t\treturn;\n\t\t\tif (sessionId === this.session.sessionId && this.deletedSessionId !== sessionId) this.reportError(error);\n\t\t} finally {\n\t\t\tresolveConnection?.();\n\t\t\tclearTimeout(timeout);\n\t\t\tcontroller.abort();\n\t\t\tif (this.controller === controller) this.connectionId = undefined;\n\t\t\tif (this.controller === controller && !this.disposed && !this.closing && this.deletedSessionId !== sessionId) {\n\t\t\t\tthis.reconnectTimer = setTimeout(\n\t\t\t\t\t() => {\n\t\t\t\t\t\tthis.reconnectTimer = undefined;\n\t\t\t\t\t\tvoid this.connect();\n\t\t\t\t\t},\n\t\t\t\t\tsessionId === this.session.sessionId ? 2000 : 0,\n\t\t\t\t);\n\t\t\t\tthis.reconnectTimer.unref();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate flush(): Promise<void> {\n\t\tif (this.flushPromise) return this.flushPromise;\n\t\tconst promise = this.sendUpdate();\n\t\tthis.flushPromise = promise;\n\t\tvoid promise.finally(() => {\n\t\t\tthis.flushPromise = undefined;\n\t\t});\n\t\treturn promise;\n\t}\n\n\tprivate async sendUpdate(): Promise<void> {\n\t\tthis.subagents.resolve();\n\t\tconst connectionId = this.connectionId;\n\t\tconst sessionId = this.connectedSessionId;\n\t\tconst controller = this.controller;\n\t\tif (\n\t\t\t!connectionId ||\n\t\t\t!sessionId ||\n\t\t\tsessionId !== this.session.sessionId ||\n\t\t\t!controller ||\n\t\t\tthis.disposed ||\n\t\t\tthis.deletedSessionId === sessionId ||\n\t\t\tthis.sending ||\n\t\t\t!this.dirty\n\t\t)\n\t\t\treturn;\n\t\tthis.sending = true;\n\t\tthis.dirty = false;\n\t\ttry {\n\t\t\tconst branch = this.historyDirty ? this.session.sessionManager.getBranch() : undefined;\n\t\t\tconst sentIndex = branch && this.sentEntryId ? branch.findIndex((entry) => entry.id === this.sentEntryId) : -1;\n\t\t\tconst replace = this.replace || (branch !== undefined && this.sentEntryId !== undefined && sentIndex === -1);\n\t\t\tthis.historyDirty = false;\n\t\t\tthis.replace = false;\n\t\t\tconst entries = branch ? (replace ? branch : branch.slice(sentIndex + 1)) : this.pendingEntries;\n\t\t\tthis.pendingEntries = [];\n\t\t\tconst messages = projectObserverEntries(entries);\n\t\t\tif (replace) this.firstUserTitle = \"\";\n\t\t\tif (!this.firstUserTitle) {\n\t\t\t\tconst firstUserContent = messages.find((message) => message.role === \"user\")?.content;\n\t\t\t\tthis.firstUserTitle = (\n\t\t\t\t\ttypeof firstUserContent === \"string\"\n\t\t\t\t\t\t? firstUserContent\n\t\t\t\t\t\t: (firstUserContent\n\t\t\t\t\t\t\t\t?.filter((part) => part.type === \"text\")\n\t\t\t\t\t\t\t\t.map((part) => part.text)\n\t\t\t\t\t\t\t\t.join(\"\") ?? \"\")\n\t\t\t\t).slice(0, 120);\n\t\t\t}\n\t\t\tconst subagentVersion = this.subagents.version;\n\t\t\tconst update: ObserverUpdate = {\n\t\t\t\tsessionId,\n\t\t\t\tconnectionId,\n\t\t\t\tsequence: ++this.sequence,\n\t\t\t\tcwd: this.session.sessionManager.getCwd(),\n\t\t\t\ttitle: this.session.sessionManager.getSessionName() ?? this.firstUserTitle,\n\t\t\t\t...(subagentVersion !== this.sentSubagentVersion ? { subagents: this.subagents.snapshot() } : {}),\n\t\t\t\t...(replace ? { replace: messages } : messages.length ? { append: messages } : {}),\n\t\t\t\tstatus: this.session.isIdle ? \"idle\" : \"running\",\n\t\t\t\tlive: {\n\t\t\t\t\tmessage: this.liveMessage ? (projectMessage(this.liveMessageId, this.liveMessage) ?? null) : null,\n\t\t\t\t\ttools: [...this.tools.values()],\n\t\t\t\t},\n\t\t\t};\n\t\t\tconst response = await this.request(controller.signal).postJson(\"/api/observer\", update);\n\t\t\tif (response.status === 410) {\n\t\t\t\tthis.stopDeletedSession(sessionId, controller);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!response.ok) throw new Error(`update failed (HTTP ${response.status})`);\n\t\t\tconst result = (await response.json()) as { accepted: boolean };\n\t\t\tif (!result.accepted) throw new Error(\"update was not accepted\");\n\t\t\tif (sessionId !== this.session.sessionId) return;\n\t\t\tthis.sentSubagentVersion = subagentVersion;\n\t\t\tif (entries.length > 0) this.sentEntryId = entries.at(-1)?.id;\n\t\t\telse if (replace) this.sentEntryId = undefined;\n\t\t\tif (this.disconnected) {\n\t\t\t\tthis.disconnected = false;\n\t\t\t\tconsole.error(\"pi-server observer connected\");\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (sessionId === this.session.sessionId && this.deletedSessionId !== sessionId) this.reportError(error);\n\t\t\tcontroller.abort();\n\t\t} finally {\n\t\t\tthis.sending = false;\n\t\t\tthis.schedule(80);\n\t\t}\n\t}\n\n\tclose(): Promise<void> {\n\t\tthis.closePromise ??= this.drainAndClose();\n\t\treturn this.closePromise;\n\t}\n\n\tprivate async drainAndClose(): Promise<void> {\n\t\tif (this.disposed) return;\n\t\tthis.closing = true;\n\t\tclearTimeout(this.timer);\n\t\tthis.timer = undefined;\n\t\tclearTimeout(this.reconnectTimer);\n\t\ttry {\n\t\t\tawait raceWithAbortSignal(\n\t\t\t\t(async () => {\n\t\t\t\t\tif (this.deletedSessionId === this.session.sessionId) return;\n\t\t\t\t\tif (!this.connectionId && this.controller?.signal.aborted) void this.connect();\n\t\t\t\t\tawait this.connectionReady;\n\t\t\t\t\tawait this.flushPromise;\n\t\t\t\t\tif (!this.connectionId) throw new Error(\"final transcript was not delivered: observer is disconnected\");\n\t\t\t\t\twhile (this.dirty && this.connectionId && !this.disposed) await this.flush();\n\t\t\t\t\tif (this.controller?.signal.aborted && this.deletedSessionId !== this.session.sessionId)\n\t\t\t\t\t\tthrow new Error(\"final transcript was not delivered: observer update failed\");\n\t\t\t\t})(),\n\t\t\t\tAbortSignal.timeout(10000),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tconsole.error(`pi-server observer shutdown failed: ${error instanceof Error ? error.message : String(error)}`);\n\t\t} finally {\n\t\t\tthis.dispose();\n\t\t}\n\t}\n\n\tdispose(): void {\n\t\tthis.disposed = true;\n\t\tthis.unsubscribe();\n\t\tthis.subagents.dispose();\n\t\tclearTimeout(this.timer);\n\t\tclearTimeout(this.reconnectTimer);\n\t\tthis.controller?.abort();\n\t\tobservers.delete(this.session);\n\t}\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@averyyy/pi-coding-agent",
3
- "version": "1.4.0-piclient.10",
3
+ "version": "1.4.0-piclient.11",
4
4
  "description": "Coding agent CLI with read, bash, edit, write tools and session management",
5
5
  "type": "module",
6
6
  "piConfig": {
@@ -48,11 +48,11 @@
48
48
  "prepublishOnly": "npm run clean && npm run build"
49
49
  },
50
50
  "dependencies": {
51
- "@earendil-works/pi-agent-core": "npm:@averyyy/pi-agent-core@1.4.0-piclient.10",
52
- "@earendil-works/pi-ai": "npm:@averyyy/pi-ai@1.4.0-piclient.10",
51
+ "@earendil-works/pi-agent-core": "npm:@averyyy/pi-agent-core@1.4.0-piclient.11",
52
+ "@earendil-works/pi-ai": "npm:@averyyy/pi-ai@1.4.0-piclient.11",
53
53
  "@earendil-works/pi-codemode": "1.4.0",
54
54
  "@earendil-works/pi-mcp": "1.4.0",
55
- "@earendil-works/pi-tui": "npm:@averyyy/pi-tui@1.4.0-piclient.10",
55
+ "@earendil-works/pi-tui": "npm:@averyyy/pi-tui@1.4.0-piclient.11",
56
56
  "@silvia-odwyer/photon-node": "0.3.4",
57
57
  "brace-expansion": "5.0.12",
58
58
  "chalk": "6.0.0",
@@ -68,7 +68,7 @@
68
68
  "quickjs-wasi": "3.6.2",
69
69
  "semver": "7.8.5",
70
70
  "typebox": "1.3.27",
71
- "undici": "8.10.2",
71
+ "undici": "8.12.2",
72
72
  "yaml": "2.9.0"
73
73
  },
74
74
  "overrides": {