@humain/humain-code 0.5.0 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +47 -1
- package/README.md +5 -3
- package/dist/agent-monitor/client.d.ts +2 -2
- package/dist/agent-monitor/client.d.ts.map +1 -1
- package/dist/agent-monitor/client.js +3 -2
- package/dist/agent-monitor/client.js.map +1 -1
- package/dist/bundle/chunks/anthropic.js +10 -9
- package/dist/bundle/chunks/{chunk-DR37WKFZ.js → chunk-AO6FF5JL.js} +1 -1
- package/dist/bundle/chunks/{chunk-Q3SFYT2X.js → chunk-EY3LZOUP.js} +1356 -1358
- package/dist/bundle/chunks/{chunk-T3HXWZG4.js → chunk-L2VKM23Q.js} +76 -2
- package/dist/bundle/chunks/{chunk-5C4VL2AR.js → chunk-ODJUBJK2.js} +2 -2
- package/dist/bundle/chunks/{chunk-A6YBWW4T.js → chunk-UJLCKIMZ.js} +646 -495
- package/dist/bundle/chunks/{chunk-476XBL3W.js → chunk-Y3OPKKDR.js} +3 -77
- package/dist/bundle/chunks/{cli-VXU7OWFU.js → cli-ENEFJH2B.js} +1 -1
- package/dist/bundle/chunks/{compat-S2IBVV6V.js → compat-CJBWWYHE.js} +1 -1
- package/dist/bundle/chunks/{dist-645GFIWH.js → dist-RKNCFFGM.js} +2 -2
- package/dist/bundle/chunks/github-copilot.js +28 -26
- package/dist/bundle/chunks/openai-chatgpt.js +2 -2
- package/dist/bundle/chunks/openai-codex.js +10 -9
- package/dist/bundle/chunks/openrouter.js +10 -9
- package/dist/bundle/chunks/radius.js +9 -8
- package/dist/bundle/chunks/{runtime-5VFZTMWL.js → runtime-K3F2QDQP.js} +1 -1
- package/dist/bundle/chunks/{virtual-modules-GU6AW5ZK.js → virtual-modules-5D6QIJPN.js} +2 -2
- package/dist/bundle/cli-runtime.js +1 -1
- package/dist/bundle/index.js +4 -4
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +19 -1
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +24 -2
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/safe-credential-error.d.ts +11 -0
- package/dist/core/safe-credential-error.d.ts.map +1 -0
- package/dist/core/safe-credential-error.js +14 -0
- package/dist/core/safe-credential-error.js.map +1 -0
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +4 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/settings-schema.d.ts +3 -0
- package/dist/core/settings-schema.d.ts.map +1 -1
- package/dist/core/settings-schema.js +6 -0
- package/dist/core/settings-schema.js.map +1 -1
- package/dist/humain/gateway/catalog.d.ts +36 -0
- package/dist/humain/gateway/catalog.d.ts.map +1 -0
- package/dist/humain/gateway/catalog.js +74 -0
- package/dist/humain/gateway/catalog.js.map +1 -0
- package/dist/humain/gateway/client.d.ts +58 -0
- package/dist/humain/gateway/client.d.ts.map +1 -0
- package/dist/humain/gateway/client.js +212 -0
- package/dist/humain/gateway/client.js.map +1 -0
- package/dist/humain/gateway/constants.d.ts +23 -0
- package/dist/humain/gateway/constants.d.ts.map +1 -0
- package/dist/humain/gateway/constants.js +32 -0
- package/dist/humain/gateway/constants.js.map +1 -0
- package/dist/humain/gateway/http.d.ts +18 -0
- package/dist/humain/gateway/http.d.ts.map +1 -0
- package/dist/humain/gateway/http.js +274 -0
- package/dist/humain/gateway/http.js.map +1 -0
- package/dist/humain/gateway/login.d.ts +13 -0
- package/dist/humain/gateway/login.d.ts.map +1 -0
- package/dist/humain/gateway/login.js +121 -0
- package/dist/humain/gateway/login.js.map +1 -0
- package/dist/humain/gateway/provider.d.ts +34 -0
- package/dist/humain/gateway/provider.d.ts.map +1 -0
- package/dist/humain/gateway/provider.js +253 -0
- package/dist/humain/gateway/provider.js.map +1 -0
- package/dist/humain/gateway/secret-store.d.ts +19 -0
- package/dist/humain/gateway/secret-store.d.ts.map +1 -0
- package/dist/humain/gateway/secret-store.js +252 -0
- package/dist/humain/gateway/secret-store.js.map +1 -0
- package/dist/humain/gateway/session-store.d.ts +42 -0
- package/dist/humain/gateway/session-store.d.ts.map +1 -0
- package/dist/humain/gateway/session-store.js +175 -0
- package/dist/humain/gateway/session-store.js.map +1 -0
- package/dist/humain/index.d.ts.map +1 -1
- package/dist/humain/index.js +2 -0
- package/dist/humain/index.js.map +1 -1
- package/dist/humain/login-menu.d.ts +14 -0
- package/dist/humain/login-menu.d.ts.map +1 -0
- package/dist/humain/login-menu.js +21 -0
- package/dist/humain/login-menu.js.map +1 -0
- package/dist/humain/node-http.d.ts.map +1 -1
- package/dist/humain/node-http.js +6 -31
- package/dist/humain/node-http.js.map +1 -1
- package/dist/humain/redact-assistant-message.d.ts +4 -0
- package/dist/humain/redact-assistant-message.d.ts.map +1 -0
- package/dist/humain/redact-assistant-message.js +34 -0
- package/dist/humain/redact-assistant-message.js.map +1 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +17 -4
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +3 -2
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +11 -0
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +16 -3
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/radius-login-selector.d.ts +5 -4
- package/dist/modes/interactive/components/radius-login-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/radius-login-selector.js +11 -9
- package/dist/modes/interactive/components/radius-login-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +2 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +53 -36
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/utils/sleep.d.ts +1 -1
- package/dist/utils/sleep.d.ts.map +1 -1
- package/dist/utils/sleep.js +10 -6
- package/dist/utils/sleep.js.map +1 -1
- package/docs/assets/humain-code-logo.svg +8 -0
- package/docs/humain-code.md +13 -1
- package/docs/index.md +1 -1
- package/docs/models.md +3 -1
- package/docs/providers.md +58 -2
- package/docs/quickstart.md +8 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/schemas/settings.schema.json +19 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
2
|
-
import{FileAuthStorageBackend,JSON_RPC_ERROR_CODES,LATEST_PROTOCOL_VERSION,McpAuthRequiredError,McpClient,McpError,McpHttpError,McpSessionExpiredError,StdioTransport,StreamableHttpTransport,isObject,mcpNamespace,require_proper_lockfile,resolveConfigValueOrThrow,resolveHeadersOrThrow}from"./chunk-
|
|
2
|
+
import{FileAuthStorageBackend,JSON_RPC_ERROR_CODES,LATEST_PROTOCOL_VERSION,McpAuthRequiredError,McpClient,McpError,McpHttpError,McpSessionExpiredError,StdioTransport,StreamableHttpTransport,isObject,mcpNamespace,oauthErrorHtml,oauthSuccessHtml,require_proper_lockfile,resolveConfigValueOrThrow,resolveHeadersOrThrow}from"./chunk-L2VKM23Q.js";import{APP_TITLE,ENV_MCP_CLIENT_METADATA_URL,VERSION,getAgentDir}from"./chunk-ZI7TK7HM.js";import{__toESM}from"./chunk-JXWJOIH4.js";import{homedir}from"node:os";import{basename,join as join2,resolve}from"node:path";import{setTimeout as sleep}from"node:timers/promises";import{pathToFileURL}from"node:url";import{createServer}from"node:http";var ALLOWED_ERROR_CODES=new Set(["invalid_request","invalid_client","invalid_grant","unauthorized_client","unsupported_grant_type","invalid_scope","access_denied","unsupported_response_type","server_error","temporarily_unavailable","invalid_token","insufficient_scope","authorization_pending","slow_down","expired_token","invalid_redirect_uri","invalid_client_metadata","invalid_software_statement","unapproved_software_statement"]);function isAllowedOAuthErrorCode(value){return ALLOWED_ERROR_CODES.
|
|
3
3
|
has(value)}function sanitizeOAuthErrorCode(value,fallback="server_error"){return value&&ALLOWED_ERROR_CODES.has(value)?value:fallback}var OAuthError=class extends Error{code;errorUri;constructor(code,message,errorUri){super(message||code),this.name="OAuthError",this.code=code,this.errorUri=errorUri}},OAuthIssuerMismatchError=class extends Error{expected;received;constructor(expected,received){let format=issuer=>issuer===void 0?"none":JSON.stringify(issuer);super(`OAuth issuer mismatch: expected ${format(
|
|
4
4
|
expected)}, received ${format(received)}`),this.name="OAuthIssuerMismatchError",this.expected=expected,this.received=received}},OAuthInsecureEndpointError=class extends Error{endpoint;constructor(endpoint){super(`Refusing to send OAuth credentials to non-HTTPS endpoint ${endpoint}`),this.name="OAuthInsecureEndpointError",this.endpoint=endpoint}},OAuthRedirectError=class extends Error{constructor(){super("OAuth endpoint redirected; refusing to follow the redirect"),this.name="OAuthRedirectError"}},
|
|
5
5
|
OAuthRegistrationError=class extends Error{status;code;constructor(status,code){super(`OAuth dynamic client registration failed with status ${status}${code?`: ${code}`:""}`),this.name="OAuthRegistrationError",this.status=status,this.code=code}},McpOAuthAuthorizationRequiredError=class extends Error{constructor(){super("MCP OAuth authorization requires user interaction"),this.name="McpOAuthAuthorizationRequiredError"}};function plainText(page){return page.ok?"Authorization complete. You may close this window.":page.details?`${page.message}
|
|
6
6
|
|
|
7
|
-
${page.details}`:page.message}var OAuthCallbackServer=class _OAuthCallbackServer{redirectUrl;server;paths;timeoutMs;renderPage;pending=new Map;constructor(server,redirectUrl,paths,timeoutMs,
|
|
7
|
+
${page.details}`:page.message}var OAuthCallbackServer=class _OAuthCallbackServer{redirectUrl;server;paths;timeoutMs;renderPage;pending=new Map;constructor(server,redirectUrl,paths,timeoutMs,renderPage){this.server=server,this.redirectUrl=redirectUrl,this.paths=paths,this.timeoutMs=timeoutMs,this.renderPage=renderPage}static async listen(options={}){let host=options.host??"127.0.0.1",redirectHost=options.redirectHost??host,path=options.path??"/callback",instance,server=createServer((request,response)=>instance?.
|
|
8
8
|
handle(request.url??"/",response));await new Promise((resolve2,reject)=>{server.once("error",reject),server.listen(options.port??0,host,()=>{server.off("error",reject),resolve2()})});let address=server.address();if(!address||typeof address=="string")throw new Error("OAuth callback server did not bind to TCP");return instance=new _OAuthCallbackServer(server,`http://${redirectHost.includes(":")?`[${redirectHost}]`:redirectHost}:${address.port}${path}`,[path,...options.extraPaths??[]],options.timeoutMs??
|
|
9
9
|
5*6e4,options.renderPage),instance}waitForCallback(state,path){if(this.pending.has(state))throw new Error("OAuth state is already pending");return new Promise((resolve2,reject)=>{let timer=setTimeout(()=>{this.pending.delete(state),reject(new Error("OAuth callback timed out"))},this.timeoutMs);this.pending.set(state,{resolve:resolve2,reject,timer,path})})}async close(){for(let pending of this.pending.values())clearTimeout(pending.timer),pending.reject(new Error("OAuth callback server closed"));this.
|
|
10
10
|
pending.clear(),await new Promise((resolve2,reject)=>{this.server.close(error=>error?reject(error):resolve2())})}reply(response,status,page){this.renderPage?(response.writeHead(status,{"content-type":"text/html; charset=utf-8","cache-control":"no-store"}),response.end(this.renderPage(page))):response.writeHead(status,{"content-type":"text/plain; charset=utf-8"}).end(plainText(page))}handle(rawUrl,response){let url=new URL(rawUrl,this.redirectUrl);if(!this.paths.includes(url.pathname)){this.reply(
|
|
@@ -52,81 +52,7 @@ horized_client"].includes(error.code))return await provider.invalidateCredential
|
|
|
52
52
|
store=options.store??new MemoryOAuthStateStore,this.onRedirect=options.onRedirect}async state(){let existing=(await this.load()).oauthState;if(existing)return existing;let state=Buffer.from(crypto.getRandomValues(new Uint8Array(32))).toString("hex");return await this.update(value=>({...value,oauthState:state})),state}async clientInformation(){return this.configuredClient??(await this.load()).clientInformation}async saveClientInformation(information){this.configuredClient||await this.update(value=>({
|
|
53
53
|
...value,clientInformation:information}))}async tokens(){return(await this.load()).tokens}async saveTokens(tokens){let expiresAt=tokens.expires_in===void 0?void 0:Date.now()+tokens.expires_in*1e3;await this.update(value=>{let next={...value,tokens};return expiresAt===void 0?delete next.tokensExpireAt:next.tokensExpireAt=expiresAt,next})}async redirectToAuthorization(url){await this.onRedirect(url)}async saveCodeVerifier(verifier){await this.update(value=>({...value,codeVerifier:verifier}))}async codeVerifier(){
|
|
54
54
|
let verifier=(await this.load()).codeVerifier;if(!verifier)throw new Error("No OAuth PKCE code verifier is stored");return verifier}async invalidateCredentials(kind){await this.update(value=>{let next={...value};return(kind==="all"||kind==="client")&&delete next.clientInformation,(kind==="all"||kind==="tokens")&&(delete next.tokens,delete next.tokensExpireAt),(kind==="all"||kind==="verifier")&&delete next.codeVerifier,(kind==="all"||kind==="discovery")&&delete next.discovery,kind==="all"&&delete next.
|
|
55
|
-
oauthState,next})}async saveDiscoveryState(discovery){await this.update(value=>({...value,discovery}))}async discoveryState(){return(await this.load()).discovery}async load(){return await this.writes,this.own(await this.store.load())}async update(update){this.writes=this.writes.then(async()=>{await this.store.save(update(this.own(await this.store.load())))}),await this.writes}own(state){return state?.serverUrl===this.serverUrl?state:{serverUrl:this.serverUrl}}};import{createHash}from"node:crypto";import{mkdirSync}from"node:fs";import{join}from"node:path";var
|
|
56
|
-
details?escapeHtml(options.details):void 0;return`<!doctype html>
|
|
57
|
-
<html lang="en">
|
|
58
|
-
<head>
|
|
59
|
-
<meta charset="utf-8" />
|
|
60
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
61
|
-
<title>${title}</title>
|
|
62
|
-
<style>
|
|
63
|
-
:root {
|
|
64
|
-
--text: #fafafa;
|
|
65
|
-
--text-dim: #a1a1aa;
|
|
66
|
-
--page-bg: #09090b;
|
|
67
|
-
--font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
|
68
|
-
--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
|
69
|
-
}
|
|
70
|
-
* { box-sizing: border-box; }
|
|
71
|
-
html { color-scheme: dark; }
|
|
72
|
-
body {
|
|
73
|
-
margin: 0;
|
|
74
|
-
min-height: 100vh;
|
|
75
|
-
display: flex;
|
|
76
|
-
align-items: center;
|
|
77
|
-
justify-content: center;
|
|
78
|
-
padding: 24px;
|
|
79
|
-
background: var(--page-bg);
|
|
80
|
-
color: var(--text);
|
|
81
|
-
font-family: var(--font-sans);
|
|
82
|
-
text-align: center;
|
|
83
|
-
}
|
|
84
|
-
main {
|
|
85
|
-
width: 100%;
|
|
86
|
-
max-width: 560px;
|
|
87
|
-
display: flex;
|
|
88
|
-
flex-direction: column;
|
|
89
|
-
align-items: center;
|
|
90
|
-
justify-content: center;
|
|
91
|
-
}
|
|
92
|
-
.logo {
|
|
93
|
-
width: 72px;
|
|
94
|
-
height: 72px;
|
|
95
|
-
display: block;
|
|
96
|
-
margin-bottom: 24px;
|
|
97
|
-
}
|
|
98
|
-
h1 {
|
|
99
|
-
margin: 0 0 10px;
|
|
100
|
-
font-size: 28px;
|
|
101
|
-
line-height: 1.15;
|
|
102
|
-
font-weight: 650;
|
|
103
|
-
color: var(--text);
|
|
104
|
-
}
|
|
105
|
-
p {
|
|
106
|
-
margin: 0;
|
|
107
|
-
line-height: 1.7;
|
|
108
|
-
color: var(--text-dim);
|
|
109
|
-
font-size: 15px;
|
|
110
|
-
}
|
|
111
|
-
.details {
|
|
112
|
-
margin-top: 16px;
|
|
113
|
-
font-family: var(--font-mono);
|
|
114
|
-
font-size: 13px;
|
|
115
|
-
color: var(--text-dim);
|
|
116
|
-
white-space: pre-wrap;
|
|
117
|
-
word-break: break-word;
|
|
118
|
-
}
|
|
119
|
-
</style>
|
|
120
|
-
</head>
|
|
121
|
-
<body>
|
|
122
|
-
<main>
|
|
123
|
-
<div class="logo">${LOGO_SVG}</div>
|
|
124
|
-
<h1>${heading}</h1>
|
|
125
|
-
<p>${message}</p>
|
|
126
|
-
${details?`<div class="details">${details}</div>`:""}
|
|
127
|
-
</main>
|
|
128
|
-
</body>
|
|
129
|
-
</html>`}function oauthSuccessHtml(message){return renderPage({title:"Authentication successful",heading:"Authentication successful",message})}function oauthErrorHtml(message,details){return renderPage({title:"Authentication failed",heading:"Authentication failed",message,details})}var import_proper_lockfile=__toESM(require_proper_lockfile(),1);var CALLBACK_HOST="127.0.0.1",CALLBACK_PATH="/callback",FALLBACK_REDIRECT_URL=`http://${CALLBACK_HOST}${CALLBACK_PATH}`,REFRESH_SKEW_MS=3e4,OAUTH_REQUEST_TIMEOUT_MS=15e3,REFRESH_LOCK_STALE_MS=2e4,REFRESH_LOCK_WAIT_MS=25e3,REFRESH_LOCK_RETRY_MS=100;function callbackSettings(settings){let url=new URL(settings.callbackUrl??`http://${CALLBACK_HOST}${CALLBACK_PATH}`),address=url.hostname.replace(/^\[|\]$/g,""),port=url.port?Number(url.port):settings.callbackPort,fixedRedirectUrl;return url.port?fixedRedirectUrl=
|
|
55
|
+
oauthState,next})}async saveDiscoveryState(discovery){await this.update(value=>({...value,discovery}))}async discoveryState(){return(await this.load()).discovery}async load(){return await this.writes,this.own(await this.store.load())}async update(update){this.writes=this.writes.then(async()=>{await this.store.save(update(this.own(await this.store.load())))}),await this.writes}own(state){return state?.serverUrl===this.serverUrl?state:{serverUrl:this.serverUrl}}};import{createHash}from"node:crypto";import{mkdirSync}from"node:fs";import{join}from"node:path";var import_proper_lockfile=__toESM(require_proper_lockfile(),1);var CALLBACK_HOST="127.0.0.1",CALLBACK_PATH="/callback",FALLBACK_REDIRECT_URL=`http://${CALLBACK_HOST}${CALLBACK_PATH}`,REFRESH_SKEW_MS=3e4,OAUTH_REQUEST_TIMEOUT_MS=15e3,REFRESH_LOCK_STALE_MS=2e4,REFRESH_LOCK_WAIT_MS=25e3,REFRESH_LOCK_RETRY_MS=100;function callbackSettings(settings){let url=new URL(settings.callbackUrl??`http://${CALLBACK_HOST}${CALLBACK_PATH}`),address=url.hostname.replace(/^\[|\]$/g,""),port=url.port?Number(url.port):settings.callbackPort,fixedRedirectUrl;return url.port?fixedRedirectUrl=
|
|
130
56
|
settings.callbackUrl:port!==void 0&&(url.port=String(port),fixedRedirectUrl=url.href),{host:address==="localhost"?CALLBACK_HOST:address,redirectHost:address,port,path:url.pathname,fixedRedirectUrl}}function mergeScopes(...scopes){let merged=[...new Set(scopes.flatMap(scope=>scope?.split(/\s+/).filter(Boolean)??[]))];return merged.length>0?merged.join(" "):void 0}function parseStates(content){if(!content?.trim())return{};let parsed=JSON.parse(content);return typeof parsed=="object"&&parsed!==null&&
|
|
131
57
|
!Array.isArray(parsed)?parsed:{}}function serializeStates(states){return`${JSON.stringify(states,null,2)}
|
|
132
58
|
`}function storeKeys(name,serverUrl){let legacyKey=String(new URL(serverUrl));return{key:`${mcpNamespace(name)}|${legacyKey}`,legacyKey}}var McpOAuthCredentialStore=class{backend;lockDir;constructor(backend,lockDir){this.backend=backend??new FileAuthStorageBackend(join(getAgentDir(),"mcp-auth.json")),this.lockDir=backend?lockDir:getAgentDir()}forServer(name,serverUrl){let{key,legacyKey}=storeKeys(name,serverUrl);return{load:()=>this.backend.withLock(current=>{let states=parseStates(current);return states[key]||
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
2
|
-
import{McpOAuthCredentialStore,McpServerConnection,McpServerLog,McpSignInCancelledError,createDefaultTransport,signInMcpServer}from"./chunk-
|
|
2
|
+
import{McpOAuthCredentialStore,McpServerConnection,McpServerLog,McpSignInCancelledError,createDefaultTransport,signInMcpServer}from"./chunk-Y3OPKKDR.js";import{ProjectTrustStore,addMcpServerConfig,loadMcpConfig,openBrowser,removeMcpServerConfig}from"./chunk-AO6FF5JL.js";import{source_default}from"./chunk-XQRYOCHA.js";import{getMcpToolExposure,validateMcpServerConfig}from"./chunk-L2VKM23Q.js";import"./chunk-YFOLLX5D.js";import{APP_COMMAND,CONFIG_DIR_NAME}from"./chunk-ZI7TK7HM.js";
|
|
3
3
|
import"./chunk-JXWJOIH4.js";import{existsSync}from"node:fs";import{join}from"node:path";import{createInterface}from"node:readline/promises";var HELP=`${source_default.bold("Usage:")}
|
|
4
4
|
${APP_COMMAND} mcp add <server> [options] -- <command> [args...]
|
|
5
5
|
${APP_COMMAND} mcp add <server> [options] --url <url>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
2
2
|
import{anthropicMessagesApi,azureOpenAIResponsesApi,bedrockConverseStreamApi,complete,completeSimple,generateImages,generateImagesOpenRouter,getApiProvider,getApiProviders,getImageModel,getImageModels,getImageProviders,getImagesApiProvider,getModel,getModels,getProviders,googleGenerativeAIApi,googleVertexApi,mistralConversationsApi,openAICodexResponsesApi,openAICompletionsApi,openAIResponsesApi,piMessagesApi,registerApiProvider,registerBuiltInApiProviders,registerBuiltInImagesApiProviders,registerFauxProvider,
|
|
3
|
-
registerImagesApiProvider,resetApiProviders,setBedrockProviderModule,stream,streamAnthropic,streamAzureOpenAIResponses,streamGoogle,streamGoogleVertex,streamMistral,streamOpenAICodexResponses,streamOpenAICompletions,streamOpenAIResponses,streamSimple,streamSimpleAnthropic,streamSimpleAzureOpenAIResponses,streamSimpleGoogle,streamSimpleGoogleVertex,streamSimpleMistral,streamSimpleOpenAICodexResponses,streamSimpleOpenAICompletions,streamSimpleOpenAIResponses,unregisterApiProviders}from"./chunk-
|
|
3
|
+
registerImagesApiProvider,resetApiProviders,setBedrockProviderModule,stream,streamAnthropic,streamAzureOpenAIResponses,streamGoogle,streamGoogleVertex,streamMistral,streamOpenAICodexResponses,streamOpenAICompletions,streamOpenAIResponses,streamSimple,streamSimpleAnthropic,streamSimpleAzureOpenAIResponses,streamSimpleGoogle,streamSimpleGoogleVertex,streamSimpleMistral,streamSimpleOpenAICodexResponses,streamSimpleOpenAICompletions,streamSimpleOpenAIResponses,unregisterApiProviders}from"./chunk-EY3LZOUP.js";
|
|
4
4
|
import{ANTHROPIC_API_KEY_ENV,ANTHROPIC_AUTH_TOKEN_ENV,ANTHROPIC_FEDERATION_RULE_ID_ENV,ANTHROPIC_IDENTITY_TOKEN_FILE_ENV,ANTHROPIC_OAUTH_TOKEN_ENV,ANTHROPIC_ORGANIZATION_ID_ENV,ANTHROPIC_SERVICE_ACCOUNT_ID_ENV,ANTHROPIC_WORKSPACE_ID_ENV,findEnvKeys,getEnvApiKey}from"./chunk-KQM7ZGL6.js";import"./chunk-CIA6V3BP.js";import"./chunk-FACBDLFU.js";import{AssistantMessageFrameEncoder,StringEnum,createFauxCore,envApiKeyAuth,fauxAssistantMessage,fauxProvider,fauxText,fauxThinking,fauxToolCall,
|
|
5
5
|
getOverflowPatterns,isContextOverflow,isRecoverableLength,lazyOAuth,reduceAssistantMessageFrames,validateToolArguments,validateToolCall}from"./chunk-N7CQ3UV3.js";import{DEFAULT_MAX_AGENT_RETRY_DELAY_MS,getAssistantRetryDelayMs,isRetryableAssistantError,retryAssistantCall,retryDelayMs}from"./chunk-QW6PTCAB.js";import{cleanupSessionResources,getOpenAICodexTokenIdentity,registerSessionResourceCleanup}from"./chunk-DBL35X7L.js";import{parseJsonWithRepair,parseStreamingJson,parseStreamingJsonWhileStreaming,
|
|
6
6
|
parseToolCallArguments,repairJson}from"./chunk-YDBNMIA3.js";import{AI_TELEMETRY_SCHEMA,InMemoryCredentialStore,InMemoryModelsStore,ModelsError,calculateCost,clampThinkingLevel,collapseSystemMessages,commitLoginCredential,contentText,createInitialSystemMessage,createModels,createProvider,declarationsEqual,defaultProviderAuthContext,getCurrentSystemMessage,getCurrentSystemPrompt,getCurrentTools,getDeclaredTools,getInitialSystemMessage,getModelType,getSupportedThinkingLevels,getSystemMessageText,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
2
|
-
import"./chunk-
|
|
3
|
-
import"./chunk-RTXDU3AA.js";import"./chunk-A6B2QMA7.js";import"./chunk-PS7DGA7B.js";import"./chunk-
|
|
2
|
+
import"./chunk-ODJUBJK2.js";import{FLOW_ACCOUNT_PERSISTENCE_NOTICE,FLOW_MESSAGE_MAX_LENGTH,FLOW_SETUP_TERMINAL_ONLY,assertDhRetryAdmission,assessNodeFallback,checkDhControlFence,dhCanonicalText,discoverAgents,flowBuildUnavailable,getFlowAccountsHost,getFlowChildLaunchHost,getFlowControlHost,getFlowTraceProducer,parseDhControlDelivery,parseFlowCommand,parseFlowControlCommandV1,parseFlowControlReceiptV1,parseFlowMessageReceiptV1,parseFlowStatusV1,renderFlowHelp,renderTaskWithContext,resolveDhEffectiveTerminals}from"./chunk-UJLCKIMZ.js";
|
|
3
|
+
import"./chunk-RTXDU3AA.js";import"./chunk-A6B2QMA7.js";import"./chunk-PS7DGA7B.js";import"./chunk-AO6FF5JL.js";import"./chunk-M74U5X4S.js";import"./chunk-EY3LZOUP.js";import"./chunk-XA7CJAYH.js";import{ScrollView,matchesKey,mixColors,styleText,truncateToWidth,visibleWidth,wrapTextWithAnsi}from"./chunk-CN3Q5UNB.js";import"./chunk-XQRYOCHA.js";import"./chunk-DNGJMRJW.js";import"./chunk-L2VKM23Q.js";import"./chunk-YFOLLX5D.js";
|
|
4
4
|
import"./chunk-KKCMWB63.js";import"./chunk-V62QBESW.js";import"./chunk-KQM7ZGL6.js";import"./chunk-CIA6V3BP.js";import"./chunk-O4DO5RWS.js";import"./chunk-FACBDLFU.js";import{FLOW_DIGEST_PATTERN,FLOW_ID_PATTERN,FLOW_MODEL_ID_PATTERN,FLOW_ROLES,FlowContractError,FlowCountSchema,FlowDigestSchema,FlowFailureClassSchema,FlowIdSchema,FlowMicrousdSchema,FlowModelRefSchema,FlowPositiveIntSchema,FlowProfileRefSchema,FlowReasonClassSchema,FlowRoleSchema,FlowSizeSchema,
|
|
5
5
|
FlowTimestampSchema,StrictObject,canonicalFlowJson,canonicalWithout,compileFlow,hasDuplicateModels,lit,parseFlowData,partialByRole,verifyFlowDigest}from"./chunk-ROZV2IYD.js";import{getAgentDir}from"./chunk-ZI7TK7HM.js";import"./chunk-2GCMACT4.js";import"./chunk-N7CQ3UV3.js";import"./chunk-QW6PTCAB.js";import"./chunk-DBL35X7L.js";import"./chunk-YDBNMIA3.js";import"./chunk-UTNHGOFS.js";import"./chunk-IJYVMOB4.js";import"./chunk-IDU5BNNI.js";
|
|
6
6
|
import"./chunk-MIJHJNNQ.js";import{typebox_exports}from"./chunk-HIZWUSPN.js";import"./chunk-JXWJOIH4.js";import{resolve}from"node:path";var FlowProfileError=class extends Error{code;path;constructor(code2,message,path){super(message),this.name="FlowProfileError",this.code=code2,path!==void 0&&(this.path=path)}};import{stripVTControlCharacters}from"node:util";var FlowEffortSchema=typebox_exports.Union([typebox_exports.Literal("low"),typebox_exports.Literal("medium"),typebox_exports.Literal("high")]),FlowRoleBindingSchema=StrictObject({primary:FlowModelRefSchema,backups:typebox_exports.Array(FlowModelRefSchema,{maxItems:8}),effort:FlowEffortSchema}),FLOW_MODEL_SELECTION_TIERS=["cheap","mid","premium","frontier"],FLOW_MODEL_SELECTION_CAPABILITIES=["scout","scope_scout","worker","implementation_fast","analysis_mid","technical_lead","lead_small","lead","\
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
2
2
|
function lazyModelCatalog(provider,chatNames,load){let byType,names,built=()=>{if(byType)return byType;let entries={chat:[],image:[],classifier:[]};for(let models of Object.values(load()))for(let model of Object.values(models)){let type=model.type;(type==="chat"||type==="image"||type==="classifier")&&entries[type].push([model.id,model])}return byType={chat:Object.fromEntries(entries.chat),image:Object.fromEntries(entries.image),classifier:Object.fromEntries(entries.classifier)},byType};return{provider,
|
|
3
3
|
chat:()=>built().chat,image:()=>built().image,classifier:()=>built().classifier,chatNames:()=>(names??=chatNames(),names),isBuilt:()=>byType!==void 0}}var GITHUB_COPILOT_MODEL_CATALOG=lazyModelCatalog("github-copilot",()=>["claude-fable-5","Claude Fable 5","claude-fable-5.1","Claude Fable 5.1","claude-haiku-4.5","Claude Haiku 4.5 (latest)","claude-haiku-5.5","Claude Haiku 5.5","claude-opus-4.8","Claude Opus 4.8","claude-opus-5","Claude Opus 5","claude-opus-5.5","Claude Opus 5.5","claude-sonnet-4.6","Claude Sonnet 4.6","claude-sonnet-5","Claude Sonnet 5","claude-sonnet-5.5","Claude Sonnet 5.5","gemini-3.8-flash","Gemini 3.8 Flash","gemini-4-arg\
|
|
4
|
-
on","Gemini 4 Argon","kimi-k3","Kimi K3","gpt-5.3-codex","GPT-5.3 Codex","gpt-5.4-nano","GPT-5.4 nano","gpt-5.6-luna","GPT-5.6 Luna","gpt-5.6-sol","GPT-5.6 Sol","gpt-5.6-terra","GPT-5.6 Terra","gpt-6-astra","GPT-6 Astra","gpt-6-luna","GPT-6 Luna","gpt-6-sol","GPT-6 Sol","gpt-6.1-sol","GPT-6.1 Sol","grok-4.5","Grok 4.5","grok-4.6","Grok 4.6","grok-4.7","Grok 4.7","mai-code-1.1-flash","MAI-Code-1.1-Flash"],()=>({"anthropic-messages":{"chat:claude-fable-5":{id:"
|
|
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:{
|
|
6
|
-
|
|
7
|
-
"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.
|
|
8
|
-
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:"
|
|
9
|
-
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:{
|
|
10
|
-
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,
|
|
11
|
-
|
|
12
|
-
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:"
|
|
13
|
-
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
|
|
14
|
-
|
|
15
|
-
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,
|
|
16
|
-
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:{
|
|
17
|
-
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":"
|
|
18
|
-
.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:"
|
|
19
|
-
|
|
20
|
-
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-
|
|
21
|
-
|
|
22
|
-
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-
|
|
23
|
-
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},
|
|
4
|
+
on","Gemini 4 Argon","kimi-k3","Kimi K3","gpt-5.3-codex","GPT-5.3 Codex","gpt-5.4-nano","GPT-5.4 nano","gpt-5.6-luna","GPT-5.6 Luna","gpt-5.6-sol","GPT-5.6 Sol","gpt-5.6-terra","GPT-5.6 Terra","gpt-6-astra","GPT-6 Astra","gpt-6-luna","GPT-6 Luna","gpt-6-sol","GPT-6 Sol","gpt-6.1-sol","GPT-6.1 Sol","gpt-6.1-terra","GPT-6.1 Terra","grok-4.5","Grok 4.5","grok-4.6","Grok 4.6","grok-4.7","Grok 4.7","mai-code-1.1-flash","MAI-Code-1.1-Flash"],()=>({"anthropic-messages":{"chat:claude-fable-5":{id:"claud\
|
|
5
|
+
e-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:{
|
|
6
|
+
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-Versio\
|
|
7
|
+
n":"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.githubc\
|
|
8
|
+
opilot.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:"\
|
|
9
|
+
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:{
|
|
10
|
+
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,
|
|
11
|
+
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:"\
|
|
12
|
+
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:"\
|
|
13
|
+
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\
|
|
14
|
+
/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:"\
|
|
15
|
+
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,
|
|
16
|
+
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:{
|
|
17
|
+
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":"GitHubCopilotCh\
|
|
18
|
+
at/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:"gi\
|
|
19
|
+
thub-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,
|
|
20
|
+
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-Integrat\
|
|
21
|
+
ion-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:{
|
|
22
|
+
"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-respons\
|
|
23
|
+
es",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},
|
|
24
24
|
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":"copi\
|
|
25
25
|
lot-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:{
|
|
26
26
|
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,
|
|
@@ -34,12 +34,14 @@ tChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot
|
|
|
34
34
|
enai-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,
|
|
35
35
|
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,
|
|
36
36
|
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:{
|
|
37
|
-
resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:
|
|
38
|
-
107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:
|
|
39
|
-
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:
|
|
40
|
-
chat"},"chat:grok-4.
|
|
41
|
-
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:
|
|
42
|
-
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:
|
|
37
|
+
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",
|
|
38
|
+
"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.gith\
|
|
39
|
+
ubcopilot.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:{
|
|
40
|
+
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","\
|
|
41
|
+
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,
|
|
42
|
+
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"},"ch\
|
|
43
|
+
at: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,
|
|
44
|
+
low:"low",medium:"medium",high:"high",xhigh:null,max:null},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"}}}));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.
|
|
43
45
|
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);
|
|
44
46
|
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{
|
|
45
47
|
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?`http\
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
2
|
-
var __require=(x=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(x,{get:(a,b)=>(typeof require<"u"?require:a)[b]}):x)(function(x){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+x+'" is not supported')});import{randomBytes}from"node:crypto";import{createServer}from"node:http";var LOGO_SVG='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0
|
|
3
|
-
details?escapeHtml(options.details):void 0;return`<!doctype html>
|
|
2
|
+
var __require=(x=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(x,{get:(a,b)=>(typeof require<"u"?require:a)[b]}):x)(function(x){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+x+'" is not supported')});import{randomBytes}from"node:crypto";import{createServer}from"node:http";var LOGO_SVG='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 15 14" role="img" aria-label="HUMAIN Code"><path fill="#f5f7f7" d="M0 0h6v2H2v10h4v2H0Zm9 0h6v14H9v-2h4V2H9Z"/><path fill="#00b89c" d="M3 4h9v2H3Zm0 4h9v2H3Z"/></svg>';function escapeHtml(value){return value.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function renderPage(options){let title=escapeHtml(options.title),heading=escapeHtml(options.heading),message=escapeHtml(
|
|
3
|
+
options.message),details=options.details?escapeHtml(options.details):void 0;return`<!doctype html>
|
|
4
4
|
<html lang="en">
|
|
5
5
|
<head>
|
|
6
6
|
<meta charset="utf-8" />
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
2
2
|
var __require=(x=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(x,{get:(a,b)=>(typeof require<"u"?require:a)[b]}):x)(function(x){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+x+'" is not supported')});var OPENAI_CODEX_AUTH_CLAIM="https://api.openai.com/auth",OPENAI_CODEX_PROFILE_CLAIM="https://api.openai.com/profile";function decodeJwtPayload(token){let parts=token.split(".");if(parts.length!==3)return;let payload=(parts[1]??"").replace(/-/g,"+").replace(/_/g,"/"),parsed=JSON.parse(atob(payload));return typeof parsed=="object"&&parsed!==null&&!Array.isArray(parsed)?parsed:void 0}function readStringClaim(container,key){if(typeof container!="object"||container===null)return;let value=container[key];
|
|
3
3
|
return typeof value=="string"&&value.length>0?value:void 0}function getOpenAICodexTokenIdentity(accessToken){let payload;try{payload=decodeJwtPayload(accessToken)}catch{return}if(!payload)return;let accountId=readStringClaim(payload[OPENAI_CODEX_AUTH_CLAIM],"chatgpt_account_id");if(!accountId)return;let email=readStringClaim(payload,"email")??readStringClaim(payload[OPENAI_CODEX_PROFILE_CLAIM],"email");return email?{accountId,email}:{accountId}}var procEnvCache=null;function getBunSandboxEnvValue(name){if(!(typeof process>"u"||!process.versions?.bun||Object.keys(process.env).length>0)){if(procEnvCache===null){procEnvCache=new Map;try{let{readFileSync}=__require("node:fs"),data=readFileSync("/proc/self/environ","utf-8");for(let entry of data.split("\0")){let idx=entry.indexOf("=");idx>0&&procEnvCache.set(entry.slice(0,idx),entry.slice(idx+1))}}catch{}}return procEnvCache.get(name)}}function getProviderEnvValue(name,env){return env?.[name]||
|
|
4
|
-
(typeof process<"u"?process.env[name]:void 0)||getBunSandboxEnvValue(name)||void 0}import{createServer}from"node:http";var LOGO_SVG='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0
|
|
5
|
-
details?escapeHtml(options.details):void 0;return`<!doctype html>
|
|
4
|
+
(typeof process<"u"?process.env[name]:void 0)||getBunSandboxEnvValue(name)||void 0}import{timingSafeEqual}from"node:crypto";import{createServer}from"node:http";var LOGO_SVG='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 15 14" role="img" aria-label="HUMAIN Code"><path fill="#f5f7f7" d="M0 0h6v2H2v10h4v2H0Zm9 0h6v14H9v-2h4V2H9Z"/><path fill="#00b89c" d="M3 4h9v2H3Zm0 4h9v2H3Z"/></svg>';function escapeHtml(value){return value.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function renderPage(options){let title=escapeHtml(options.title),heading=escapeHtml(options.heading),message=escapeHtml(
|
|
5
|
+
options.message),details=options.details?escapeHtml(options.details):void 0;return`<!doctype html>
|
|
6
6
|
<html lang="en">
|
|
7
7
|
<head>
|
|
8
8
|
<meta charset="utf-8" />
|
|
@@ -76,13 +76,14 @@ details?escapeHtml(options.details):void 0;return`<!doctype html>
|
|
|
76
76
|
</main>
|
|
77
77
|
</body>
|
|
78
78
|
</html>`}function oauthSuccessHtml(message){return renderPage({title:"Authentication successful",heading:"Authentication successful",message})}function oauthErrorHtml(message,details){return renderPage({title:"Authentication failed",heading:"Authentication failed",message,details})}var ALLOWED_ERROR_CODES=new Set(["invalid_request","invalid_client","invalid_grant","unauthorized_client","unsupported_grant_type","invalid_scope","access_denied","unsupported_response_type","server_error","temporarily_unavailable","invalid_token","insufficient_scope","authorization_pending","slow_down","expired_token","invalid_redirect_uri","invalid_client_metadata","invalid_software_statement","unapproved_software_statement","deviceauth_authorization_pending","invalid_request_error","rate_limi\
|
|
79
|
-
t_exceeded","usage_limit_reached","previous_response_not_found","websocket_connection_limit_reached"]);function safeOAuthErrorCode(body){let json;try{json=JSON.parse(body)}catch{return}if(typeof json!="object"||json===null)return;let error=json.error,candidate=typeof error=="object"&&error!==null?error.code??error.type:error;return typeof candidate=="string"&&ALLOWED_ERROR_CODES.has(candidate)?candidate:void 0}function sendPage(response,status,html){response.writeHead(status,{"content-type":"text/html; charset=utf-8","cache-control":"no-store"}),response.end(html)}async function startOAuthCallbackServer(options){let{providerName,signal}=options;if(signal?.aborted)throw new Error("Login cancelled");let resolveWait=()=>{},rejectWait=()=>{},
|
|
80
|
-
"Login cancelled")}),finish=result=>{settled||(settled=!0,timer&&clearTimeout(timer),signal?.removeEventListener("abort",onAbort),"error"in result?rejectWait(result.error):resolveWait(result.value))},server=createServer((request,response)=>{(async()=>{let url=new URL(request.url??"/","http://localhost");if(request.method!==
|
|
81
|
-
|
|
82
|
-
searchParams.get("
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
79
|
+
t_exceeded","usage_limit_reached","previous_response_not_found","websocket_connection_limit_reached"]);function safeOAuthErrorCode(body){let json;try{json=JSON.parse(body)}catch{return}if(typeof json!="object"||json===null)return;let error=json.error,candidate=typeof error=="object"&&error!==null?error.code??error.type:error;return typeof candidate=="string"&&ALLOWED_ERROR_CODES.has(candidate)?candidate:void 0}function stateMatches(received,expected){if(received===null)return!1;let a=Buffer.from(received),b=Buffer.from(expected);return a.length===b.length&&timingSafeEqual(a,b)}function sendPage(response,status,html){response.writeHead(status,{"content-type":"text/html; charset=utf-8","cache-control":"no-store"}),response.end(html)}async function startOAuthCallbackServer(options){let{providerName,signal}=options;if(signal?.aborted)throw new Error("Login cancelled");let resolveWait=()=>{},rejectWait=()=>{},
|
|
80
|
+
waitPromise=new Promise((resolve,reject)=>{resolveWait=resolve,rejectWait=reject});waitPromise.catch(()=>{});let claimed=!1,settled=!1,timer,onAbort=()=>finish({error:new Error("Login cancelled")}),finish=result=>{settled||(settled=!0,timer&&clearTimeout(timer),signal?.removeEventListener("abort",onAbort),"error"in result?rejectWait(result.error):resolveWait(result.value))},server=createServer((request,response)=>{(async()=>{let url=new URL(request.url??"/","http://localhost");if(request.method!==
|
|
81
|
+
"GET"||url.pathname!==options.path){sendPage(response,404,oauthErrorHtml("Callback route not found."));return}if(url.searchParams.getAll("state").length>1||url.searchParams.getAll("code").length>1){sendPage(response,400,oauthErrorHtml("Repeated callback parameters."));return}if(options.state!==void 0&&!stateMatches(url.searchParams.get("state"),options.state)){sendPage(response,400,oauthErrorHtml("State mismatch."));return}if(claimed||settled){sendPage(response,409,oauthErrorHtml("This sign-in h\
|
|
82
|
+
as already been handled."));return}let error=url.searchParams.get("error");if(error){let safeErrorCode=safeOAuthErrorCode(JSON.stringify({error}));sendPage(response,400,oauthErrorHtml(`${providerName} authorization failed.`,safeErrorCode)),finish({error:new Error(`${providerName} authorization failed${safeErrorCode?`: ${safeErrorCode}`:""}`)});return}let code=url.searchParams.get("code");if(!code){sendPage(response,400,oauthErrorHtml("Missing authorization code."));return}claimed=!0;try{let value=await options.
|
|
83
|
+
complete(code);sendPage(response,200,oauthSuccessHtml(`Signed in to ${providerName}. You may now close this page.`)),finish({value})}catch(error2){let failure=error2 instanceof Error?error2:new Error(String(error2));sendPage(response,502,oauthErrorHtml(`${providerName} sign-in failed.`,"Return to the terminal for details.")),finish({error:failure})}})()});await new Promise((resolve,reject)=>{server.once("error",reject),server.listen(options.port,options.host,()=>{server.off("error",reject),resolve()})});
|
|
84
|
+
let address=server.address();if(!address||typeof address=="string")throw server.close(),new Error("OAuth callback server did not bind to TCP");server.on("error",error=>finish({error})),signal?.addEventListener("abort",onAbort,{once:!0}),options.timeoutMs!==void 0&&(timer=setTimeout(()=>finish({error:new Error(`${providerName} sign-in timed out`)}),options.timeoutMs));let redirectHost=options.redirectHost??options.host;return{redirectUri:`http://${redirectHost.includes(":")?`[${redirectHost}]`:redirectHost}\
|
|
85
|
+
:${address.port}${options.path}`,wait:()=>waitPromise,cancel:()=>{claimed||finish({value:void 0})},close:()=>{finish({error:new Error("OAuth callback server closed")}),server.close()}}}async function waitForCallbackOrManualInput(interaction,callback,prompt){let manualAbort=new AbortController,manualError,manual=interaction.prompt({type:"manual_code",...prompt,signal:manualAbort.signal}).then(input=>(callback?.cancel(),input)).catch(error=>{manualError=error instanceof Error?error:new Error(String(
|
|
86
|
+
error)),callback?.cancel()});try{let value=await callback?.wait();if(manualError)throw manualError;if(value!==void 0)return{type:"callback",value};let input=await manual;if(manualError)throw manualError;return{type:"manual",input:input??""}}finally{manualAbort.abort()}}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.
|
|
86
87
|
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);
|
|
87
88
|
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)}function base64urlEncode(bytes){let binary="";for(let byte of bytes)binary+=String.fromCharCode(byte);return btoa(binary).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}async function generatePKCE(){let verifierBytes=new Uint8Array(32);crypto.getRandomValues(verifierBytes);let verifier=base64urlEncode(verifierBytes),data=new TextEncoder().encode(verifier),hashBuffer=await crypto.subtle.digest("SHA-256",data),challenge=base64urlEncode(new Uint8Array(hashBuffer));return{verifier,challenge}}var _randomBytes=null;typeof process<"u"&&(process.versions?.node||process.versions?.bun)&&import("node:crypto").then(m=>{_randomBytes=m.randomBytes});var CLIENT_ID="app_EMoamEEZ73f0CkXaXp7hrann",AUTH_BASE_URL="https://auth.openai.com",AUTHORIZE_URL=`${AUTH_BASE_URL}/oauth/authorize`,TOKEN_URL=`${AUTH_BASE_URL}/oauth/token`,REDIRECT_URI="http://localhost:1455/auth/callback",DEVICE_USER_CODE_URL=`${AUTH_BASE_URL}/api/accounts/deviceauth/usercode`,DEVICE_TOKEN_URL=`${AUTH_BASE_URL}/api/accounts/de\
|
|
88
89
|
viceauth/token`,DEVICE_VERIFICATION_URI=`${AUTH_BASE_URL}/codex/device`,DEVICE_REDIRECT_URI=`${AUTH_BASE_URL}/deviceauth/callback`,DEVICE_CODE_TIMEOUT_SECONDS=900,OPENAI_CODEX_BROWSER_LOGIN_METHOD="browser",OPENAI_CODEX_DEVICE_CODE_LOGIN_METHOD="device_code",SCOPE="openid profile email offline_access";function getCallbackHost(){return getProviderEnvValue("PI_OAUTH_CALLBACK_HOST")||"127.0.0.1"}function createState(){if(!_randomBytes)throw new Error("OpenAI Codex OAuth is only available in Node.js\
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
2
2
|
var __require=(x=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(x,{get:(a,b)=>(typeof require<"u"?require:a)[b]}):x)(function(x){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+x+'" is not supported')});var procEnvCache=null;function getBunSandboxEnvValue(name){if(!(typeof process>"u"||!process.versions?.bun||Object.keys(process.env).length>0)){if(procEnvCache===null){procEnvCache=new Map;try{let{readFileSync}=__require("node:fs"),data=readFileSync("/proc/self/environ","utf-8");for(let entry of data.split("\0")){let idx=entry.indexOf("=");idx>0&&procEnvCache.set(entry.slice(0,idx),entry.slice(idx+1))}}catch{}}return procEnvCache.get(name)}}function getProviderEnvValue(name,env){return env?.[name]||
|
|
3
|
-
(typeof process<"u"?process.env[name]:void 0)||getBunSandboxEnvValue(name)||void 0}import{createServer}from"node:http";var LOGO_SVG='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0
|
|
4
|
-
details?escapeHtml(options.details):void 0;return`<!doctype html>
|
|
3
|
+
(typeof process<"u"?process.env[name]:void 0)||getBunSandboxEnvValue(name)||void 0}import{timingSafeEqual}from"node:crypto";import{createServer}from"node:http";var LOGO_SVG='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 15 14" role="img" aria-label="HUMAIN Code"><path fill="#f5f7f7" d="M0 0h6v2H2v10h4v2H0Zm9 0h6v14H9v-2h4V2H9Z"/><path fill="#00b89c" d="M3 4h9v2H3Zm0 4h9v2H3Z"/></svg>';function escapeHtml(value){return value.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function renderPage(options){let title=escapeHtml(options.title),heading=escapeHtml(options.heading),message=escapeHtml(
|
|
4
|
+
options.message),details=options.details?escapeHtml(options.details):void 0;return`<!doctype html>
|
|
5
5
|
<html lang="en">
|
|
6
6
|
<head>
|
|
7
7
|
<meta charset="utf-8" />
|
|
@@ -75,13 +75,14 @@ details?escapeHtml(options.details):void 0;return`<!doctype html>
|
|
|
75
75
|
</main>
|
|
76
76
|
</body>
|
|
77
77
|
</html>`}function oauthSuccessHtml(message){return renderPage({title:"Authentication successful",heading:"Authentication successful",message})}function oauthErrorHtml(message,details){return renderPage({title:"Authentication failed",heading:"Authentication failed",message,details})}var ALLOWED_ERROR_CODES=new Set(["invalid_request","invalid_client","invalid_grant","unauthorized_client","unsupported_grant_type","invalid_scope","access_denied","unsupported_response_type","server_error","temporarily_unavailable","invalid_token","insufficient_scope","authorization_pending","slow_down","expired_token","invalid_redirect_uri","invalid_client_metadata","invalid_software_statement","unapproved_software_statement","deviceauth_authorization_pending","invalid_request_error","rate_limi\
|
|
78
|
-
t_exceeded","usage_limit_reached","previous_response_not_found","websocket_connection_limit_reached"]);function safeOAuthErrorCode(body){let json;try{json=JSON.parse(body)}catch{return}if(typeof json!="object"||json===null)return;let error=json.error,candidate=typeof error=="object"&&error!==null?error.code??error.type:error;return typeof candidate=="string"&&ALLOWED_ERROR_CODES.has(candidate)?candidate:void 0}function sendPage(response,status,html){response.writeHead(status,{"content-type":"text/html; charset=utf-8","cache-control":"no-store"}),response.end(html)}async function startOAuthCallbackServer(options){let{providerName,signal}=options;if(signal?.aborted)throw new Error("Login cancelled");let resolveWait=()=>{},rejectWait=()=>{},
|
|
79
|
-
"Login cancelled")}),finish=result=>{settled||(settled=!0,timer&&clearTimeout(timer),signal?.removeEventListener("abort",onAbort),"error"in result?rejectWait(result.error):resolveWait(result.value))},server=createServer((request,response)=>{(async()=>{let url=new URL(request.url??"/","http://localhost");if(request.method!==
|
|
80
|
-
|
|
81
|
-
searchParams.get("
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
78
|
+
t_exceeded","usage_limit_reached","previous_response_not_found","websocket_connection_limit_reached"]);function safeOAuthErrorCode(body){let json;try{json=JSON.parse(body)}catch{return}if(typeof json!="object"||json===null)return;let error=json.error,candidate=typeof error=="object"&&error!==null?error.code??error.type:error;return typeof candidate=="string"&&ALLOWED_ERROR_CODES.has(candidate)?candidate:void 0}function stateMatches(received,expected){if(received===null)return!1;let a=Buffer.from(received),b=Buffer.from(expected);return a.length===b.length&&timingSafeEqual(a,b)}function sendPage(response,status,html){response.writeHead(status,{"content-type":"text/html; charset=utf-8","cache-control":"no-store"}),response.end(html)}async function startOAuthCallbackServer(options){let{providerName,signal}=options;if(signal?.aborted)throw new Error("Login cancelled");let resolveWait=()=>{},rejectWait=()=>{},
|
|
79
|
+
waitPromise=new Promise((resolve,reject)=>{resolveWait=resolve,rejectWait=reject});waitPromise.catch(()=>{});let claimed=!1,settled=!1,timer,onAbort=()=>finish({error:new Error("Login cancelled")}),finish=result=>{settled||(settled=!0,timer&&clearTimeout(timer),signal?.removeEventListener("abort",onAbort),"error"in result?rejectWait(result.error):resolveWait(result.value))},server=createServer((request,response)=>{(async()=>{let url=new URL(request.url??"/","http://localhost");if(request.method!==
|
|
80
|
+
"GET"||url.pathname!==options.path){sendPage(response,404,oauthErrorHtml("Callback route not found."));return}if(url.searchParams.getAll("state").length>1||url.searchParams.getAll("code").length>1){sendPage(response,400,oauthErrorHtml("Repeated callback parameters."));return}if(options.state!==void 0&&!stateMatches(url.searchParams.get("state"),options.state)){sendPage(response,400,oauthErrorHtml("State mismatch."));return}if(claimed||settled){sendPage(response,409,oauthErrorHtml("This sign-in h\
|
|
81
|
+
as already been handled."));return}let error=url.searchParams.get("error");if(error){let safeErrorCode=safeOAuthErrorCode(JSON.stringify({error}));sendPage(response,400,oauthErrorHtml(`${providerName} authorization failed.`,safeErrorCode)),finish({error:new Error(`${providerName} authorization failed${safeErrorCode?`: ${safeErrorCode}`:""}`)});return}let code=url.searchParams.get("code");if(!code){sendPage(response,400,oauthErrorHtml("Missing authorization code."));return}claimed=!0;try{let value=await options.
|
|
82
|
+
complete(code);sendPage(response,200,oauthSuccessHtml(`Signed in to ${providerName}. You may now close this page.`)),finish({value})}catch(error2){let failure=error2 instanceof Error?error2:new Error(String(error2));sendPage(response,502,oauthErrorHtml(`${providerName} sign-in failed.`,"Return to the terminal for details.")),finish({error:failure})}})()});await new Promise((resolve,reject)=>{server.once("error",reject),server.listen(options.port,options.host,()=>{server.off("error",reject),resolve()})});
|
|
83
|
+
let address=server.address();if(!address||typeof address=="string")throw server.close(),new Error("OAuth callback server did not bind to TCP");server.on("error",error=>finish({error})),signal?.addEventListener("abort",onAbort,{once:!0}),options.timeoutMs!==void 0&&(timer=setTimeout(()=>finish({error:new Error(`${providerName} sign-in timed out`)}),options.timeoutMs));let redirectHost=options.redirectHost??options.host;return{redirectUri:`http://${redirectHost.includes(":")?`[${redirectHost}]`:redirectHost}\
|
|
84
|
+
:${address.port}${options.path}`,wait:()=>waitPromise,cancel:()=>{claimed||finish({value:void 0})},close:()=>{finish({error:new Error("OAuth callback server closed")}),server.close()}}}async function waitForCallbackOrManualInput(interaction,callback,prompt){let manualAbort=new AbortController,manualError,manual=interaction.prompt({type:"manual_code",...prompt,signal:manualAbort.signal}).then(input=>(callback?.cancel(),input)).catch(error=>{manualError=error instanceof Error?error:new Error(String(
|
|
85
|
+
error)),callback?.cancel()});try{let value=await callback?.wait();if(manualError)throw manualError;if(value!==void 0)return{type:"callback",value};let input=await manual;if(manualError)throw manualError;return{type:"manual",input:input??""}}finally{manualAbort.abort()}}function base64urlEncode(bytes){let binary="";for(let byte of bytes)binary+=String.fromCharCode(byte);return btoa(binary).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}async function generatePKCE(){let verifierBytes=new Uint8Array(32);crypto.getRandomValues(verifierBytes);let verifier=base64urlEncode(verifierBytes),data=new TextEncoder().encode(verifier),hashBuffer=await crypto.subtle.digest("SHA-256",data),challenge=base64urlEncode(new Uint8Array(hashBuffer));return{verifier,challenge}}var AUTHORIZE_URL="https://openrouter.ai/auth",TOKEN_URL="https://openrouter.ai/api/v1/auth/keys",LOGIN_TIMEOUT_MS=300*1e3,TOKEN_EXCHANGE_TIMEOUT_MS=3e4;function getCallbackHost(){return getProviderEnvValue("PI_OAUTH_CALLBACK_HOST")||"127.0.0.1"}function parseAuthorizationInput(input){let value=input.trim();if(value){try{return new URL(value).searchParams.get("code")??void 0}catch{}return value.includes("code=")?new URLSearchParams(value).get("code")??void 0:value}}function errorDetail(body){if(typeof body.
|
|
85
86
|
error_description=="string")return body.error_description;if(typeof body.message=="string")return body.message;if(typeof body.error=="string")return body.error;if(body.error&&typeof body.error=="object"&&!Array.isArray(body.error)){let message=body.error.message;if(typeof message=="string")return message}}async function exchangeAuthorizationCode(code,verifier,signal){if(signal.aborted)throw new Error("Login cancelled");let controller=new AbortController,onAbort=()=>controller.abort(signal.reason);
|
|
86
87
|
signal.addEventListener("abort",onAbort,{once:!0});let timeout=setTimeout(()=>controller.abort(new Error("OpenRouter OAuth token exchange timed out")),TOKEN_EXCHANGE_TIMEOUT_MS),response,body={};try{response=await fetch(TOKEN_URL,{method:"POST",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify({code,code_verifier:verifier,code_challenge_method:"S256"}),signal:controller.signal});try{let parsed=await response.json();parsed&&typeof parsed=="object"&&!Array.isArray(
|
|
87
88
|
parsed)&&(body=parsed)}catch{if(response.ok)throw new Error("OpenRouter OAuth returned invalid JSON")}}catch(error){throw signal.aborted?new Error("Login cancelled"):controller.signal.aborted?new Error("OpenRouter OAuth token exchange timed out"):error}finally{clearTimeout(timeout),signal.removeEventListener("abort",onAbort)}if(!response.ok){let detail=errorDetail(body);throw new Error(`OpenRouter OAuth key exchange failed (HTTP ${response.status})${detail?`: ${detail}`:""}`)}if(typeof body.key!=
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
2
|
-
function normalizeRadiusGatewayUrl(value){return(/^https?:\/\//iu.test(value)?value:`https://${value}`).replace(/\/+$/u,"")}import{createServer}from"node:http";var LOGO_SVG='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0
|
|
3
|
-
details?escapeHtml(options.details):void 0;return`<!doctype html>
|
|
2
|
+
function normalizeRadiusGatewayUrl(value){return(/^https?:\/\//iu.test(value)?value:`https://${value}`).replace(/\/+$/u,"")}import{timingSafeEqual}from"node:crypto";import{createServer}from"node:http";var LOGO_SVG='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 15 14" role="img" aria-label="HUMAIN Code"><path fill="#f5f7f7" d="M0 0h6v2H2v10h4v2H0Zm9 0h6v14H9v-2h4V2H9Z"/><path fill="#00b89c" d="M3 4h9v2H3Zm0 4h9v2H3Z"/></svg>';function escapeHtml(value){return value.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function renderPage(options){let title=escapeHtml(options.title),heading=escapeHtml(options.heading),message=escapeHtml(
|
|
3
|
+
options.message),details=options.details?escapeHtml(options.details):void 0;return`<!doctype html>
|
|
4
4
|
<html lang="en">
|
|
5
5
|
<head>
|
|
6
6
|
<meta charset="utf-8" />
|
|
@@ -74,12 +74,13 @@ details?escapeHtml(options.details):void 0;return`<!doctype html>
|
|
|
74
74
|
</main>
|
|
75
75
|
</body>
|
|
76
76
|
</html>`}function oauthSuccessHtml(message){return renderPage({title:"Authentication successful",heading:"Authentication successful",message})}function oauthErrorHtml(message,details){return renderPage({title:"Authentication failed",heading:"Authentication failed",message,details})}var ALLOWED_ERROR_CODES=new Set(["invalid_request","invalid_client","invalid_grant","unauthorized_client","unsupported_grant_type","invalid_scope","access_denied","unsupported_response_type","server_error","temporarily_unavailable","invalid_token","insufficient_scope","authorization_pending","slow_down","expired_token","invalid_redirect_uri","invalid_client_metadata","invalid_software_statement","unapproved_software_statement","deviceauth_authorization_pending","invalid_request_error","rate_limi\
|
|
77
|
-
t_exceeded","usage_limit_reached","previous_response_not_found","websocket_connection_limit_reached"]);function safeOAuthErrorCode(body){let json;try{json=JSON.parse(body)}catch{return}if(typeof json!="object"||json===null)return;let error=json.error,candidate=typeof error=="object"&&error!==null?error.code??error.type:error;return typeof candidate=="string"&&ALLOWED_ERROR_CODES.has(candidate)?candidate:void 0}function sendPage(response,status,html){response.writeHead(status,{"content-type":"text/html; charset=utf-8","cache-control":"no-store"}),response.end(html)}async function startOAuthCallbackServer(options){let{providerName,signal}=options;if(signal?.aborted)throw new Error("Login cancelled");let resolveWait=()=>{},rejectWait=()=>{},
|
|
78
|
-
"Login cancelled")}),finish=result=>{settled||(settled=!0,timer&&clearTimeout(timer),signal?.removeEventListener("abort",onAbort),"error"in result?rejectWait(result.error):resolveWait(result.value))},server=createServer((request,response)=>{(async()=>{let url=new URL(request.url??"/","http://localhost");if(request.method!==
|
|
79
|
-
|
|
80
|
-
searchParams.get("
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
t_exceeded","usage_limit_reached","previous_response_not_found","websocket_connection_limit_reached"]);function safeOAuthErrorCode(body){let json;try{json=JSON.parse(body)}catch{return}if(typeof json!="object"||json===null)return;let error=json.error,candidate=typeof error=="object"&&error!==null?error.code??error.type:error;return typeof candidate=="string"&&ALLOWED_ERROR_CODES.has(candidate)?candidate:void 0}function stateMatches(received,expected){if(received===null)return!1;let a=Buffer.from(received),b=Buffer.from(expected);return a.length===b.length&&timingSafeEqual(a,b)}function sendPage(response,status,html){response.writeHead(status,{"content-type":"text/html; charset=utf-8","cache-control":"no-store"}),response.end(html)}async function startOAuthCallbackServer(options){let{providerName,signal}=options;if(signal?.aborted)throw new Error("Login cancelled");let resolveWait=()=>{},rejectWait=()=>{},
|
|
78
|
+
waitPromise=new Promise((resolve,reject)=>{resolveWait=resolve,rejectWait=reject});waitPromise.catch(()=>{});let claimed=!1,settled=!1,timer,onAbort=()=>finish({error:new Error("Login cancelled")}),finish=result=>{settled||(settled=!0,timer&&clearTimeout(timer),signal?.removeEventListener("abort",onAbort),"error"in result?rejectWait(result.error):resolveWait(result.value))},server=createServer((request,response)=>{(async()=>{let url=new URL(request.url??"/","http://localhost");if(request.method!==
|
|
79
|
+
"GET"||url.pathname!==options.path){sendPage(response,404,oauthErrorHtml("Callback route not found."));return}if(url.searchParams.getAll("state").length>1||url.searchParams.getAll("code").length>1){sendPage(response,400,oauthErrorHtml("Repeated callback parameters."));return}if(options.state!==void 0&&!stateMatches(url.searchParams.get("state"),options.state)){sendPage(response,400,oauthErrorHtml("State mismatch."));return}if(claimed||settled){sendPage(response,409,oauthErrorHtml("This sign-in h\
|
|
80
|
+
as already been handled."));return}let error=url.searchParams.get("error");if(error){let safeErrorCode=safeOAuthErrorCode(JSON.stringify({error}));sendPage(response,400,oauthErrorHtml(`${providerName} authorization failed.`,safeErrorCode)),finish({error:new Error(`${providerName} authorization failed${safeErrorCode?`: ${safeErrorCode}`:""}`)});return}let code=url.searchParams.get("code");if(!code){sendPage(response,400,oauthErrorHtml("Missing authorization code."));return}claimed=!0;try{let value=await options.
|
|
81
|
+
complete(code);sendPage(response,200,oauthSuccessHtml(`Signed in to ${providerName}. You may now close this page.`)),finish({value})}catch(error2){let failure=error2 instanceof Error?error2:new Error(String(error2));sendPage(response,502,oauthErrorHtml(`${providerName} sign-in failed.`,"Return to the terminal for details.")),finish({error:failure})}})()});await new Promise((resolve,reject)=>{server.once("error",reject),server.listen(options.port,options.host,()=>{server.off("error",reject),resolve()})});
|
|
82
|
+
let address=server.address();if(!address||typeof address=="string")throw server.close(),new Error("OAuth callback server did not bind to TCP");server.on("error",error=>finish({error})),signal?.addEventListener("abort",onAbort,{once:!0}),options.timeoutMs!==void 0&&(timer=setTimeout(()=>finish({error:new Error(`${providerName} sign-in timed out`)}),options.timeoutMs));let redirectHost=options.redirectHost??options.host;return{redirectUri:`http://${redirectHost.includes(":")?`[${redirectHost}]`:redirectHost}\
|
|
83
|
+
:${address.port}${options.path}`,wait:()=>waitPromise,cancel:()=>{claimed||finish({value:void 0})},close:()=>{finish({error:new Error("OAuth callback server closed")}),server.close()}}}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.
|
|
83
84
|
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);
|
|
84
85
|
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)}function base64urlEncode(bytes){let binary="";for(let byte of bytes)binary+=String.fromCharCode(byte);return btoa(binary).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}async function generatePKCE(){let verifierBytes=new Uint8Array(32);crypto.getRandomValues(verifierBytes);let verifier=base64urlEncode(verifierBytes),data=new TextEncoder().encode(verifier),hashBuffer=await crypto.subtle.digest("SHA-256",data),challenge=base64urlEncode(new Uint8Array(hashBuffer));return{verifier,challenge}}var CALLBACK_HOST="127.0.0.1",CALLBACK_PORT=1456,CALLBACK_PATH="/oauth/callback",REDIRECT_URI=`http://${CALLBACK_HOST}:${CALLBACK_PORT}${CALLBACK_PATH}`,TOKEN_EXPIRY_SKEW_MS=6e4,LOGIN_METHOD_BROWSER="browser",LOGIN_METHOD_DEVICE_CODE="device-code",OAUTH_CLIENT_ID="pi-gateway",OAUTH_SCOPE="gateway offline_access",OAUTH_DEVICE_CODE_GRANT_TYPE="urn:ietf:params:oauth:grant-type:device_code";async function loadRadiusOAuthDiscovery(gateway,signal){let response=await fetch(new URL("/v1/oauth",gateway),
|
|
85
86
|
{headers:{accept:"application/json"},signal});if(!response.ok)throw new Error(`Could not load Radius OAuth config from ${gateway}: ${response.status} ${await response.text()}`);let discovery=await response.json();if(typeof discovery.authorizationEndpoint!="string")throw new Error(`Invalid Radius OAuth config from ${gateway}`);return{authorizationEndpoint:discovery.authorizationEndpoint}}var OAuthResponseError=class extends Error{status;oauthError;constructor(status,oauthError,description,message){
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
2
|
-
import{McpOAuthCredentialStore,McpServerConnection,McpServerLog,McpSignInCancelledError,createDefaultTransport,signInMcpServer}from"./chunk-
|
|
2
|
+
import{McpOAuthCredentialStore,McpServerConnection,McpServerLog,McpSignInCancelledError,createDefaultTransport,signInMcpServer}from"./chunk-Y3OPKKDR.js";import"./chunk-L2VKM23Q.js";import"./chunk-YFOLLX5D.js";import"./chunk-ZI7TK7HM.js";import"./chunk-JXWJOIH4.js";export{McpOAuthCredentialStore,McpServerConnection,McpServerLog,McpSignInCancelledError,createDefaultTransport,signInMcpServer};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
2
|
-
import{dist_exports as dist_exports3}from"./chunk-
|
|
3
|
-
import"./chunk-
|
|
2
|
+
import{dist_exports as dist_exports3}from"./chunk-ODJUBJK2.js";import{dist_exports as dist_exports2}from"./chunk-UJLCKIMZ.js";import"./chunk-RTXDU3AA.js";import"./chunk-A6B2QMA7.js";import"./chunk-PS7DGA7B.js";import"./chunk-AO6FF5JL.js";import"./chunk-M74U5X4S.js";import{all_exports,compat_exports}from"./chunk-EY3LZOUP.js";import"./chunk-XA7CJAYH.js";import{dist_exports}from"./chunk-CN3Q5UNB.js";import"./chunk-XQRYOCHA.js";import"./chunk-DNGJMRJW.js";
|
|
3
|
+
import"./chunk-L2VKM23Q.js";import"./chunk-YFOLLX5D.js";import"./chunk-KKCMWB63.js";import"./chunk-V62QBESW.js";import"./chunk-KQM7ZGL6.js";import"./chunk-CIA6V3BP.js";import"./chunk-O4DO5RWS.js";import"./chunk-FACBDLFU.js";import"./chunk-ROZV2IYD.js";import"./chunk-ZI7TK7HM.js";import"./chunk-2GCMACT4.js";import"./chunk-N7CQ3UV3.js";import"./chunk-QW6PTCAB.js";import"./chunk-DBL35X7L.js";import"./chunk-YDBNMIA3.js";
|
|
4
4
|
import{models_exports}from"./chunk-UTNHGOFS.js";import"./chunk-IJYVMOB4.js";import"./chunk-IDU5BNNI.js";import{compile_exports,value_exports2 as value_exports}from"./chunk-MIJHJNNQ.js";import{build_exports}from"./chunk-HIZWUSPN.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\
|
|
5
5
|
/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};
|