gsd-pi 2.75.0-dev.063e5a3 → 2.75.0
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/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +13 -13
- package/dist/web/standalone/.next/build-manifest.json +3 -3
- package/dist/web/standalone/.next/prerender-manifest.json +3 -3
- package/dist/web/standalone/.next/required-server-files.json +3 -3
- package/dist/web/standalone/.next/server/app/_global-error/page.js +3 -3
- package/dist/web/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found/page.js +2 -2
- package/dist/web/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.rsc +3 -3
- package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
- package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +3 -3
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/api/boot/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/boot/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/input/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/input/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/resize/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/resize/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/stream/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/stream/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/browse-directories/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/browse-directories/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/captures/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/captures/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/cleanup/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/cleanup/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/dev-mode/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/dev-mode/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/doctor/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/doctor/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/experimental/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/experimental/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/export-data/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/export-data/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/files/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/files/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/forensics/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/forensics/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/git/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/git/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/history/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/history/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/hooks/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/hooks/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/inspect/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/inspect/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/knowledge/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/knowledge/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/live-state/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/live-state/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/notifications/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/notifications/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/onboarding/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/onboarding/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/preferences/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/preferences/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/projects/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/projects/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/recovery/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/recovery/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/remote-questions/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/remote-questions/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/browser/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/browser/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/command/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/command/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/events/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/session/events/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/manage/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/manage/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/settings-data/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/settings-data/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/shutdown/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/shutdown/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/skill-health/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/skill-health/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/steer/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/steer/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/switch-root/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/switch-root/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/input/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/terminal/input/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/resize/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/terminal/resize/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/sessions/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/terminal/sessions/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/stream/route.js +4 -4
- package/dist/web/standalone/.next/server/app/api/terminal/stream/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/upload/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/upload/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/undo/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/undo/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/update/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/visualizer/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/visualizer/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/index.html +1 -1
- package/dist/web/standalone/.next/server/app/index.rsc +4 -4
- package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +4 -4
- package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +3 -3
- package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/page.js +2 -2
- package/dist/web/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app-paths-manifest.json +13 -13
- package/dist/web/standalone/.next/server/chunks/63.js +3 -3
- package/dist/web/standalone/.next/server/chunks/6897.js +1 -1
- package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/dist/web/standalone/.next/server/middleware-manifest.json +5 -5
- package/dist/web/standalone/.next/server/middleware.js +2 -2
- package/dist/web/standalone/.next/server/next-font-manifest.js +1 -1
- package/dist/web/standalone/.next/server/next-font-manifest.json +1 -1
- package/dist/web/standalone/.next/server/pages/404.html +1 -1
- package/dist/web/standalone/.next/server/pages/500.html +1 -1
- package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
- package/dist/web/standalone/.next/static/chunks/app/_not-found/{page-f2a7482d42a5614b.js → page-2f24283c162b6ab3.js} +1 -1
- package/dist/web/standalone/.next/static/chunks/app/{layout-a16c7a7ecdf0c2cf.js → layout-9ecfd95f343793f0.js} +1 -1
- package/dist/web/standalone/.next/static/chunks/app/page-7115e62689b5fd84.js +1 -0
- package/dist/web/standalone/.next/static/chunks/main-app-d3d4c336195465f9.js +1 -0
- package/dist/web/standalone/.next/static/chunks/next/dist/client/components/builtin/global-error-ab5a8926e07ec673.js +1 -0
- package/dist/web/standalone/node_modules/node-pty/build/Makefile +2 -2
- package/dist/web/standalone/node_modules/node-pty/build/Release/pty.node +0 -0
- package/dist/web/standalone/node_modules/node-pty/build/pty.target.mk +14 -14
- package/dist/web/standalone/node_modules/node-pty/node-addon-api/node_addon_api.target.mk +14 -14
- package/dist/web/standalone/node_modules/node-pty/node-addon-api/node_addon_api_except.target.mk +14 -14
- package/dist/web/standalone/node_modules/node-pty/node-addon-api/node_addon_api_maybe.target.mk +14 -14
- package/dist/web/standalone/server.js +1 -1
- package/package.json +1 -1
- package/dist/web/standalone/.next/static/chunks/app/page-f1e30ab6bb269149.js +0 -1
- package/dist/web/standalone/.next/static/chunks/main-app-fdab67f7802d7832.js +0 -1
- package/dist/web/standalone/.next/static/chunks/next/dist/client/components/builtin/global-error-459824ffb8c323dd.js +0 -1
- /package/dist/web/standalone/.next/static/{j7IBD35UgrL2b298GLK3V → prkokVQFxWtUVIku57_0z}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{j7IBD35UgrL2b298GLK3V → prkokVQFxWtUVIku57_0z}/_ssgManifest.js +0 -0
|
@@ -9,4 +9,4 @@ exports.id=6897,exports.ids=[6897],exports.modules={2280:(a,b,c)=>{"use strict";
|
|
|
9
9
|
<p>Authentication successful. Return to your terminal to continue.</p>
|
|
10
10
|
</body>
|
|
11
11
|
</html>`;function af(a){let b=a.trim();if(!b)return{};try{let a=new URL(b);return{code:a.searchParams.get("code")??void 0,state:a.searchParams.get("state")??void 0}}catch{}if(b.includes("#")){let[a,c]=b.split("#",2);return{code:a,state:c}}if(b.includes("code=")){let a=new URLSearchParams(b);return{code:a.get("code")??void 0,state:a.get("state")??void 0}}return{code:b}}async function ag(a,b,c=ad){let d=await fetch(ac,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"authorization_code",client_id:ab,code:a,code_verifier:b,redirect_uri:c}),signal:AbortSignal.timeout(3e4)});if(!d.ok){let a=await d.text().catch(()=>"");return console.error("[openai-codex] code->token failed:",d.status,a),{type:"failed"}}let e=await d.json();return e.access_token&&e.refresh_token&&"number"==typeof e.expires_in?{type:"success",access:e.access_token,refresh:e.refresh_token,expires:Date.now()+1e3*e.expires_in}:(console.error("[openai-codex] token response missing fields:",e),{type:"failed"})}async function ah(a){try{let b=await fetch(ac,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",refresh_token:a,client_id:ab}),signal:AbortSignal.timeout(3e4)});if(!b.ok){let a=await b.text().catch(()=>"");return console.error("[openai-codex] Token refresh failed:",b.status,a),{type:"failed"}}let c=await b.json();if(!c.access_token||!c.refresh_token||"number"!=typeof c.expires_in)return console.error("[openai-codex] Token refresh response missing fields:",c),{type:"failed"};return{type:"success",access:c.access_token,refresh:c.refresh_token,expires:Date.now()+1e3*c.expires_in}}catch(a){return console.error("[openai-codex] Token refresh error:",a),{type:"failed"}}}async function ai(a="pi"){let{verifier:b,challenge:c}=await I(),d=function(){if(!_)throw Error("OpenAI Codex OAuth is only available in Node.js environments");return _(16).toString("hex")}(),e=new URL("https://auth.openai.com/oauth/authorize");return e.searchParams.set("response_type","code"),e.searchParams.set("client_id",ab),e.searchParams.set("redirect_uri",ad),e.searchParams.set("scope","openid profile email offline_access"),e.searchParams.set("code_challenge",c),e.searchParams.set("code_challenge_method","S256"),e.searchParams.set("state",d),e.searchParams.set("id_token_add_organizations","true"),e.searchParams.set("codex_cli_simplified_flow","true"),e.searchParams.set("originator",a),{verifier:b,state:d,url:e.toString()}}function aj(a){let b=function(a){try{let b=a.split(".");if(3!==b.length)return null;let c=b[1]??"",d=atob(c);return JSON.parse(d)}catch{return null}}(a),c=b?.["https://api.openai.com/auth"],d=c?.chatgpt_account_id;return"string"==typeof d&&d.length>0?d:null}async function ak(a){let b,{verifier:c,state:d,url:e}=await ai(a.originator),f=await function(a){if(!aa)throw Error("OpenAI Codex OAuth is only available in Node.js environments");let b=null,c=!1,d=aa.createServer((c,d)=>{try{let e=new URL(c.url||"","http://localhost");if("/auth/callback"!==e.pathname){d.statusCode=404,d.end("Not found");return}if(e.searchParams.get("state")!==a){d.statusCode=400,d.end("State mismatch");return}let f=e.searchParams.get("code");if(!f){d.statusCode=400,d.end("Missing authorization code");return}d.statusCode=200,d.setHeader("Content-Type","text/html; charset=utf-8"),d.end(ae),b=f}catch{d.statusCode=500,d.end("Internal error")}});return new Promise(a=>{d.listen(1455,"127.0.0.1",()=>{a({close:()=>d.close(),cancelWait:()=>{c=!0},waitForCode:async()=>{let a=()=>new Promise(a=>setTimeout(a,100));for(let d=0;d<600;d+=1){if(b)return{code:b};if(c)break;await a()}return null}})}).on("error",b=>{console.error("[openai-codex] Failed to bind http://127.0.0.1:1455 (",b.code,") Falling back to manual paste."),a({close:()=>{try{d.close()}catch{}},cancelWait:()=>{},waitForCode:async()=>null})})})}(d);a.onAuth({url:e,instructions:"A browser window should open. Complete login to finish."});try{if(a.onManualCodeInput){let c,e,g=a.onManualCodeInput().then(a=>{c=a,f.cancelWait()}).catch(a=>{e=a instanceof Error?a:Error(String(a)),f.cancelWait()}),h=await f.waitForCode();if(e)throw e;if(h?.code)b=h.code;else if(c){let a=af(c);if(a.state&&a.state!==d)throw Error("State mismatch");b=a.code}if(!b){if(await g,e)throw e;if(c){let a=af(c);if(a.state&&a.state!==d)throw Error("State mismatch");b=a.code}}}else{let a=await f.waitForCode();a?.code&&(b=a.code)}if(!b){let c=await a.onPrompt({message:"Paste the authorization code (or full redirect URL):"}),e=af(c);if(e.state&&e.state!==d)throw Error("State mismatch");b=e.code}if(!b)throw Error("Missing authorization code");let e=await ag(b,c);if("success"!==e.type)throw Error("Token exchange failed");let g=aj(e.access);if(!g)throw Error("Failed to extract accountId from token");return{access:e.access,refresh:e.refresh,expires:e.expires,accountId:g}}finally{f.close()}}async function al(a){let b=await ah(a);if("success"!==b.type)throw Error("Failed to refresh OpenAI Codex token");let c=aj(b.access);if(!c)throw Error("Failed to extract accountId from token");return{access:b.access,refresh:b.refresh,expires:b.expires,accountId:c}}let am=new Map([{id:"github-copilot",name:"GitHub Copilot",login:async a=>z({onAuth:(b,c)=>a.onAuth({url:b,instructions:c}),onPrompt:a.onPrompt,onProgress:a.onProgress,signal:a.signal}),async refreshToken(a){let b=await v(a.refresh,a.enterpriseUrl);try{let c=await y(b.access,a.enterpriseUrl);Object.keys(c).length>0&&(b.modelLimits=c)}catch{}return b},getApiKey:a=>a.access,modifyModels(a,b){let c=b.enterpriseUrl?o(b.enterpriseUrl)??void 0:void 0,d=q(b.access,c),e=b.modelLimits,f=e?new Set(Object.keys(e)):null,g=!!f&&f.size>0;return a.flatMap(a=>{if("github-copilot"!==a.provider)return a;if(g&&!f.has(a.id))return[];let b=e?.[a.id];return{...a,baseUrl:d,...b&&{contextWindow:b.contextWindow,maxTokens:b.maxTokens}}})}},{id:"google-gemini-cli",name:"Google Cloud Code Assist (Gemini CLI)",usesCallbackServer:!0,login:async a=>$(a.onAuth,a.onProgress,a.onManualCodeInput),async refreshToken(a){if(!a.projectId)throw Error("Google Cloud credentials missing projectId");return Z(a.refresh,a.projectId)},getApiKey:a=>JSON.stringify({token:a.access,projectId:a.projectId})},{id:"google-antigravity",name:"Antigravity (Gemini 3, Claude, GPT-OSS)",usesCallbackServer:!0,login:async a=>P(a.onAuth,a.onProgress,a.onManualCodeInput),async refreshToken(a){if(!a.projectId)throw Error("Antigravity credentials missing projectId");return O(a.refresh,a.projectId)},getApiKey:a=>JSON.stringify({token:a.access,projectId:a.projectId})},{id:"openai-codex",name:"ChatGPT Plus/Pro (Codex Subscription)",usesCallbackServer:!0,login:async a=>ak({onAuth:a.onAuth,onPrompt:a.onPrompt,onProgress:a.onProgress,onManualCodeInput:a.onManualCodeInput}),refreshToken:async a=>al(a.refresh),getApiKey:a=>a.access}].map(a=>[a.id,a]));class an{constructor(a){this.data={},this.authPath=a,this.reload()}reload(){var a;let b;a=this.authPath,b=(0,g.dirname)(a),(0,e.existsSync)(b)||(0,e.mkdirSync)(b,{recursive:!0,mode:448}),(0,e.existsSync)(a)||((0,e.writeFileSync)(a,"{}","utf-8"),(0,e.chmodSync)(a,384)),this.data=function(a){if(!a||!a.trim())return{};try{let b=JSON.parse(a);return"object"==typeof b&&null!==b?b:{}}catch{return{}}}((0,e.readFileSync)(this.authPath,"utf-8"))}getCredentialsForProvider(a){let b=this.data[a];return b?Array.isArray(b)?b:[b]:[]}set(a,b){let c=this.getCredentialsForProvider(a),d="api_key"===b.type?this.mergeApiKeyCredentials(c,b):this.mergeOAuthCredential(c,b);this.data[a]=1===d.length?d[0]:d,(0,e.writeFileSync)(this.authPath,JSON.stringify(this.data,null,2),"utf-8"),(0,e.chmodSync)(this.authPath,384)}hasAuth(a){return this.getCredentialsForProvider(a).length>0||!!i(a)}getOAuthProviders(){return Array.from(am.values())}async login(a,b){let c=am.get(a);if(!c)throw Error(`Unknown OAuth provider: ${a}`);let d=await c.login(b);this.set(a,{type:"oauth",...d})}logout(a){delete this.data[a],(0,e.writeFileSync)(this.authPath,JSON.stringify(this.data,null,2),"utf-8"),(0,e.chmodSync)(this.authPath,384)}mergeApiKeyCredentials(a,b){return a.some(a=>"api_key"===a.type&&a.key===b.key)?a:[...a,b]}mergeOAuthCredential(a,b){return[...a.filter(a=>"api_key"===a.type),b]}}let ao=null,ap=[{id:"anthropic",label:"Anthropic (Claude)",supportsApiKey:!0,supportsOAuth:!1,recommended:!0},{id:"openai",label:"OpenAI",supportsApiKey:!0,supportsOAuth:!1},{id:"github-copilot",label:"GitHub Copilot",supportsApiKey:!1,supportsOAuth:!0},{id:"openai-codex",label:"ChatGPT Plus/Pro (Codex Subscription)",supportsApiKey:!1,supportsOAuth:!0},{id:"google-gemini-cli",label:"Google Cloud Code Assist (Gemini CLI)",supportsApiKey:!1,supportsOAuth:!0},{id:"google-antigravity",label:"Antigravity (Gemini 3, Claude, GPT-OSS)",supportsApiKey:!1,supportsOAuth:!0},{id:"google",label:"Google (Gemini API)",supportsApiKey:!0,supportsOAuth:!1},{id:"groq",label:"Groq",supportsApiKey:!0,supportsOAuth:!1},{id:"xai",label:"xAI (Grok)",supportsApiKey:!0,supportsOAuth:!1},{id:"openrouter",label:"OpenRouter",supportsApiKey:!0,supportsOAuth:!1},{id:"mistral",label:"Mistral",supportsApiKey:!0,supportsOAuth:!1}],aq=[{id:"web_search",label:"Web search",providers:[{id:"brave",label:"Brave Search",envVar:"BRAVE_API_KEY"},{id:"tavily",label:"Tavily",envVar:"TAVILY_API_KEY"}]},{id:"tool_keys",label:"Tool API keys",providers:[{id:"context7",label:"Context7",envVar:"CONTEXT7_API_KEY"},{id:"jina",label:"Jina AI",envVar:"JINA_API_KEY"},{id:"groq",label:"Groq",envVar:"GROQ_API_KEY"}]},{id:"remote_questions",label:"Remote questions",providers:[{id:"discord_bot",label:"Discord",envVar:"DISCORD_BOT_TOKEN"},{id:"slack_bot",label:"Slack",envVar:"SLACK_BOT_TOKEN"}]}],ar=null;function as(a){return a().toISOString()}function at(a){return(a instanceof Error?a.message:String(a)).replace(/sk-[A-Za-z0-9_-]{6,}/g,"[redacted]").replace(/xox[baprs]-[A-Za-z0-9-]+/g,"[redacted]").replace(/Bearer\s+[^\s]+/gi,"Bearer [redacted]").replace(/([A-Z0-9_]*(?:API[_-]?KEY|TOKEN|SECRET)["'=:\s]+)([^\s,;"']+)/gi,"$1[redacted]").replace(/\s+/g," ").trim()}function au(){return{phase:"idle",strategy:null,startedAt:null,completedAt:null,error:null}}function av(a,b){return a.getCredentialsForProvider(b).some(a=>"oauth"===a.type?"string"==typeof a.access&&a.access.trim().length>0:"string"==typeof a.key&&a.key.trim().length>0)}async function aw(a,b){let c="";try{if((b.headers.get("content-type")||"").includes("application/json")){let a=await b.json();c=function a(b){if(!b)return null;if("string"==typeof b)return b;if("object"!=typeof b)return null;for(let c of[b.message,b.error,b.detail,b.error_description]){if("string"==typeof c&&c.trim().length>0)return c;let b=a(c);if(b)return b}return null}(a)??JSON.stringify(a)}else c=await b.text()}catch{c=""}let d=at(c);return d?`${a} validation failed (${b.status}): ${d}`:`${a} validation failed (${b.status})`}async function ax(a,b,c,d,e={}){try{let f=await a(c,{headers:{Authorization:`Bearer ${d}`,...e},signal:AbortSignal.timeout(15e3)});if(!f.ok)return{ok:!1,message:await aw(b,f)};return{ok:!0,message:`${b} credentials validated`}}catch(a){return{ok:!1,message:`${b} validation failed: ${at(a)}`}}}async function ay(a,b){try{let c=new URL("https://generativelanguage.googleapis.com/v1beta/models");c.searchParams.set("key",b);let d=await a(c,{signal:AbortSignal.timeout(15e3)});if(!d.ok)return{ok:!1,message:await aw("google",d)};return{ok:!0,message:"google credentials validated"}}catch(a){return{ok:!1,message:`google validation failed: ${at(a)}`}}}async function az(a,b){try{let c=await a("https://api.anthropic.com/v1/models",{headers:{"x-api-key":b,"anthropic-version":"2023-06-01"},signal:AbortSignal.timeout(15e3)});if(!c.ok)return{ok:!1,message:await aw("anthropic",c)};return{ok:!0,message:"anthropic credentials validated"}}catch(a){return{ok:!1,message:`anthropic validation failed: ${at(a)}`}}}async function aA(a,b,c){switch(a){case"anthropic":return await az(c,b);case"openai":return await ax(c,a,"https://api.openai.com/v1/models",b);case"google":return await ay(c,b);case"groq":return await ax(c,a,"https://api.groq.com/openai/v1/models",b);case"xai":return await ax(c,a,"https://api.x.ai/v1/models",b);case"openrouter":return await ax(c,a,"https://openrouter.ai/api/v1/models",b,{"HTTP-Referer":"https://localhost","X-Title":"GSD onboarding"});case"mistral":return await ax(c,a,"https://api.mistral.ai/v1/models",b);default:return{ok:!1,message:`${a} does not support API-key validation via onboarding`}}}class aB{constructor(a){this.authStorage=null,this.lastValidation=null,this.activeFlow=null,this.bridgeAuthRefresh=au(),this.deps=a}async getState(){return this.buildState()}async validateAndSaveApiKey(a,b){let c=ap.find(b=>b.id===a);if(!c)throw Error(`Unknown onboarding provider: ${a}`);if(!c.supportsApiKey)throw Error(`${a} must be configured with browser sign-in`);let d=b.trim();if(!d)throw Error("API key is required");let e=this.deps.validateApiKey??(async(a,b)=>await aA(a,b,this.deps.fetch??fetch)),f=await e(a,d),g=as(this.deps.now??(()=>new Date));if(!f.ok)return this.lastValidation={status:"failed",providerId:a,method:"api_key",checkedAt:g,message:at(f.message),persisted:!1},await this.buildState();let h=await this.getAuthStorage();return h.reload(),h.set(a,{type:"api_key",key:d}),this.lastValidation={status:"succeeded",providerId:a,method:"api_key",checkedAt:g,message:at(f.message||`${a} credentials validated`),persisted:!0},await this.refreshBridgeAuth(),await this.buildState()}async startProviderFlow(a){let b=await this.getAuthStorage();b.reload();let c=b.getOAuthProviders().find(b=>b.id===a);if(!c)throw Error(`OAuth provider not available for onboarding: ${a}`);this.activeFlow&&["running","awaiting_browser_auth","awaiting_input"].includes(this.activeFlow.state.status)&&this.cancelActiveFlow();let e={state:{flowId:(this.deps.createFlowId??(()=>(0,d.randomUUID)()))(),providerId:a,providerLabel:c.name,status:"running",updatedAt:as(this.deps.now??(()=>new Date)),auth:null,prompt:null,progress:[],error:null},awaitingInput:null,abortController:new AbortController};return this.activeFlow=e,this.runOAuthFlow(e,c,b),await this.buildState()}async submitProviderFlowInput(a,b){let c=this.activeFlow;if(!c||c.state.flowId!==a)throw Error(`Unknown onboarding flow: ${a}`);if(!c.awaitingInput)throw Error(`Onboarding flow ${a} is not waiting for input`);let d=c.awaitingInput;return c.awaitingInput=null,c.state.prompt=null,c.state.status="running",c.state.updatedAt=as(this.deps.now??(()=>new Date)),d(b),await this.buildState()}async cancelProviderFlow(a){let b=this.activeFlow;if(!b||b.state.flowId!==a)throw Error(`Unknown onboarding flow: ${a}`);return this.cancelActiveFlow(),await this.buildState()}async logoutProvider(a){let b=await this.getAuthStorage();b.reload();let c=await this.buildState(),d=a.trim()||c.required.satisfiedBy?.providerId||c.required.providers.find(a=>a.configured)?.id;if(!d)throw Error("No configured provider is available to log out");let e=c.required.providers.find(a=>a.id===d),f=e?.label??d;if(!e?.configured)throw Error(`${f} is not configured in this workspace`);if("auth_file"!==e.configuredVia)throw Error(`${f} is configured via ${e.configuredVia} and cannot be logged out from the browser surface`);return this.activeFlow&&this.activeFlow.state.providerId===d&&["running","awaiting_browser_auth","awaiting_input"].includes(this.activeFlow.state.status)&&this.cancelActiveFlow(),b.logout(d),this.lastValidation=null,await this.refreshBridgeAuth(),await this.buildState()}async refreshBridgeAuth(){let a=this.deps.refreshBridgeAuth;if(!a){this.bridgeAuthRefresh=au();return}let b=as(this.deps.now??(()=>new Date));this.bridgeAuthRefresh={phase:"pending",strategy:"restart",startedAt:b,completedAt:null,error:null};try{await a(),this.bridgeAuthRefresh={phase:"succeeded",strategy:"restart",startedAt:b,completedAt:as(this.deps.now??(()=>new Date)),error:null}}catch(a){this.bridgeAuthRefresh={phase:"failed",strategy:"restart",startedAt:b,completedAt:as(this.deps.now??(()=>new Date)),error:at(a)}}}async getAuthStorage(){return this.authStorage||(this.deps.authStorage?this.authStorage=this.deps.authStorage:this.deps.createAuthStorage?this.authStorage=await this.deps.createAuthStorage(this.deps.authPath??j.sI):this.authStorage=new an(this.deps.authPath??j.sI)),this.authStorage}buildOptionalSectionState(a){let b=this.deps.env??process.env;return aq.map(c=>{let d=c.providers.filter(c=>{let d=!!c.envVar&&"string"==typeof b[c.envVar]&&b[c.envVar].trim().length>0,e=av(a,c.id);return d||e}).map(a=>a.label);return{id:c.id,label:c.label,blocking:!1,skippable:!0,configured:d.length>0,configuredItems:d}})}buildProviderState(a,b){let c=new Map(a.getOAuthProviders().map(a=>[a.id,a]));return ap.map(d=>{var e;let f=c.get(d.id),g=(e=d.id,av(a,e)?"auth_file":b(e)?"environment":null);return{id:d.id,label:f?.name??d.label,required:!0,recommended:!!d.recommended,configured:null!==g,configuredVia:g,supports:{apiKey:d.supportsApiKey,oauth:d.supportsOAuth,oauthAvailable:!!d.supportsOAuth&&!!f,usesCallbackServer:!!f?.usesCallbackServer}}})}async buildState(){var a,b;let c=await this.getAuthStorage(),d=this.deps.getEnvApiKey??i;c.reload();let e=this.buildProviderState(c,d),f=e.find(a=>a.configured)??null,g=this.buildOptionalSectionState(c),h=(a=!!f,b=this.bridgeAuthRefresh,a?"pending"===b.phase?"bridge_refresh_pending":"failed"===b.phase?"bridge_refresh_failed":null:"required_setup");return{status:h?"blocked":"ready",locked:null!==h,lockReason:h,required:{blocking:!0,skippable:!1,satisfied:!!f,satisfiedBy:f?{providerId:f.id,source:f.configuredVia??"runtime"}:null,providers:e},optional:{blocking:!1,skippable:!0,sections:g},lastValidation:this.lastValidation?{...this.lastValidation}:null,activeFlow:this.activeFlow?structuredClone(this.activeFlow.state):null,bridgeAuthRefresh:{...this.bridgeAuthRefresh}}}cancelActiveFlow(){this.activeFlow&&(this.activeFlow.abortController.abort(),this.activeFlow.awaitingInput&&(this.activeFlow.awaitingInput(""),this.activeFlow.awaitingInput=null),this.activeFlow.state.status="cancelled",this.activeFlow.state.prompt=null,this.activeFlow.state.error=null,this.activeFlow.state.updatedAt=as(this.deps.now??(()=>new Date)))}async runOAuthFlow(a,b,c){try{await c.login(b.id,{onAuth:b=>{a.state.auth=b,a.state.status="awaiting_browser_auth",a.state.updatedAt=as(this.deps.now??(()=>new Date))},onPrompt:async b=>await this.waitForFlowInput(a,"text",b),onProgress:b=>{a.state.progress=[...a.state.progress,at(b)].slice(-20),"awaiting_input"!==a.state.status&&(a.state.status="running"),a.state.updatedAt=as(this.deps.now??(()=>new Date))},onManualCodeInput:async()=>await this.waitForFlowInput(a,"manual_code",{message:"Paste the redirect URL from your browser:",placeholder:"http://localhost:..."}),signal:a.abortController.signal}),a.state.status="succeeded",a.state.prompt=null,a.state.error=null,a.state.updatedAt=as(this.deps.now??(()=>new Date)),this.lastValidation={status:"succeeded",providerId:b.id,method:"oauth",checkedAt:a.state.updatedAt,message:`${b.id} sign-in complete`,persisted:!0},await this.refreshBridgeAuth()}catch(d){let c=a.abortController.signal.aborted;a.state.status=c?"cancelled":"failed",a.state.prompt=null,a.state.error=c?null:at(d),a.state.updatedAt=as(this.deps.now??(()=>new Date)),c||(this.lastValidation={status:"failed",providerId:b.id,method:"oauth",checkedAt:a.state.updatedAt,message:a.state.error||`${b.id} sign-in failed`,persisted:!1})}}async waitForFlowInput(a,b,c){return a.state.status="awaiting_input",a.state.prompt={kind:b,message:c.message,placeholder:c.placeholder,allowEmpty:c.allowEmpty},a.state.updatedAt=as(this.deps.now??(()=>new Date)),await new Promise(b=>{a.awaitingInput=b})}}function aC(){return ar||(ar=new aB({env:process.env,authPath:j.sI,fetch,now:()=>new Date,createFlowId:()=>(0,d.randomUUID)(),validateApiKey:function(a){if("1"===a.GSD_WEB_TEST_FAKE_API_KEY_VALIDATION)return async(a,b)=>{let c=ap.find(b=>b.id===a)?.label??a,d=b.trim().toLowerCase();return!d||d.includes("invalid")||d.includes("reject")||d.includes("fail")?{ok:!1,message:`${c} rejected the supplied key`}:{ok:!0,message:`${c} credentials validated`}}}(process.env),refreshBridgeAuth:ao??void 0,...{}})),ar}async function aD(){return await aC().getState()}function aE(a){ao=a,ar=null}},4431:(a,b,c)=>{"use strict";c.d(b,{KW:()=>h,hg:()=>f,vB:()=>i});var d=c(3024),e=c(6760);function f(a){return g(a)&&function(){let[a,b]=process.versions.node.split(".").map(Number);return a>22||22===a&&b>=7}()?"--experimental-transform-types":"--experimental-strip-types"}function g(a){return a.replace(/\\/g,"/").includes("/node_modules/")}function h(a,b,c=d.existsSync){if(g(a)){let d=b.replace(/\.ts$/,".js"),f=(0,e.join)(a,"dist",d);if(c(f))return{modulePath:f,useCompiledJs:!0}}return{modulePath:(0,e.join)(a,"src",b),useCompiledJs:!1}}function i(a,b,c){return b.useCompiledJs?["--input-type=module"]:["--import",c,f(a),"--input-type=module"]}},6460:(a,b,c)=>{"use strict";c.d(b,{AL:()=>i,PO:()=>d,_B:()=>j,on:()=>k,ql:()=>h});let d="current_project",e=["threaded","recent","relevance"],f=["all","named"],g=["rename"];function h(a){return e.includes(a??"")}function i(a){return f.includes(a??"")}function j(a){return g.includes(a??"")}function k(a){return{query:a?.query?.trim()??"",sortMode:a?.sortMode??"threaded",nameFilter:a?.nameFilter??"all"}}},6487:()=>{},7712:(a,b,c)=>{"use strict";let d;c.d(b,{xD:()=>aa,Fs:()=>_,tL:()=>Z,yd:()=>$,tS:()=>W,pA:()=>v,tl:()=>P,Os:()=>X,jL:()=>R,eG:()=>L,O5:()=>Q,sM:()=>ac});var e=c(1421),f=c(3024),g=c(6193),h=c(6760),i=c(3136),j=c(4431),k=c(6460),l=c(7849),m=c(3576);let n="GSD_AUTO_DASHBOARD_MODULE";function o(){return{active:!1,paused:!1,stepMode:!1,startTime:0,elapsed:0,currentUnit:null,completedUnits:[],basePath:"",totalCost:0,totalTokens:0,rtkSavings:null,rtkEnabled:!1}}async function p(a,b={}){let c=b.env??process.env;if("1"===c.GSD_WEB_TEST_USE_FALLBACK_AUTO_DASHBOARD)return o();let d=b.existsSync??f.existsSync,g=(0,h.join)(a,"src","resources","extensions","gsd","tests","resolve-ts.mjs"),k=c.GSD_WEB_TEST_AUTO_DASHBOARD_MODULE,l=k?{modulePath:k,useCompiledJs:!1}:(0,j.KW)(a,"resources/extensions/gsd/auto.ts",d),m=l.modulePath;if(!l.useCompiledJs&&(!d(g)||!d(m)))throw Error(`authoritative auto dashboard provider not found; checked=${g},${m}`);if(l.useCompiledJs&&!d(m))throw Error(`authoritative auto dashboard provider not found; checked=${m}`);let q=`const { pathToFileURL } = await import("node:url"); const mod = await import(pathToFileURL(process.env.${n}).href); const result = await mod.getAutoDashboardData(); process.stdout.write(JSON.stringify(result));`,r=(0,j.vB)(a,l,(0,i.pathToFileURL)(g).href);return await new Promise((g,i)=>{(0,e.execFile)(b.execPath??process.execPath,[...r,"--eval",q],{cwd:a,env:{...c,[n]:m},maxBuffer:1048576,windowsHide:!0},(a,b,e)=>{if(a)return void i(Error(`authoritative auto dashboard subprocess failed: ${e||a.message}`));try{let a=JSON.parse(b),e=c.GSD_WEB_PROJECT_CWD||"",i=e?function(a,b,c){if(a.active||a.paused)return a;let d=(0,h.join)(b,".gsd","runtime","paused-session.json");if(c(d))try{return JSON.parse((0,f.readFileSync)(d,"utf-8")),{...a,paused:!0}}catch{}let e=(0,h.join)(b,".gsd","auto.lock");if(c(e))try{let b=JSON.parse((0,f.readFileSync)(e,"utf-8"));if("number"==typeof b.pid&&function(a){try{return process.kill(a,0),!0}catch{return!1}}(b.pid))return{...a,active:!0}}catch{}return a}(a,e,d):a;g(i)}catch(a){i(Error(`authoritative auto dashboard subprocess returned invalid JSON: ${a instanceof Error?a.message:String(a)}`))}})})}var q=c(2813);let r=new Set(["get_state","get_available_models","get_session_stats","get_messages","get_last_assistant_text","get_fork_messages","get_commands"]);function s(a){return a.toLowerCase().replace(/\s+/g," ").trim()}function t(a){return!!a.name?.trim()}function u(a,b){let c=`${a.id} ${a.name??""} ${a.allMessagesText} ${a.cwd}`;if("regex"===b.mode){if(!b.regex)return{matches:!1,score:0};let a=c.search(b.regex);return a<0?{matches:!1,score:0}:{matches:!0,score:.1*a}}if(0===b.tokens.length)return{matches:!0,score:0};let d=0,e=null;for(let a of b.tokens){if("phrase"===a.kind){null===e&&(e=s(c));let b=s(a.value);if(!b)continue;let f=e.indexOf(b);if(f<0)return{matches:!1,score:0};d+=.1*f;continue}let b=function(a,b){let c=a.toLowerCase(),d=b.toLowerCase(),e=a=>{if(0===a.length)return{matches:!0,score:0};if(a.length>d.length)return{matches:!1,score:0};let b=0,c=0,e=-1,f=0;for(let g=0;g<d.length&&b<a.length;g++){if(d[g]!==a[b])continue;let h=0===g||/[\s\-_./:]/.test(d[g-1]);e===g-1?c-=5*++f:(f=0,e>=0&&(c+=(g-e-1)*2)),h&&(c-=10),c+=.1*g,e=g,b++}return b<a.length?{matches:!1,score:0}:{matches:!0,score:c}},f=e(c);if(f.matches)return f;let g=c.match(/^(?<letters>[a-z]+)(?<digits>[0-9]+)$/),h=c.match(/^(?<digits>[0-9]+)(?<letters>[a-z]+)$/),i=g?`${g.groups?.digits??""}${g.groups?.letters??""}`:h?`${h.groups?.letters??""}${h.groups?.digits??""}`:"";if(!i)return f;let j=e(i);return j.matches?{matches:!0,score:j.score+5}:f}(a.value,c);if(!b.matches)return{matches:!1,score:0};d+=b.score}return{matches:!0,score:d}}function v(a){let b,c=F().existsSync??f.existsSync,d=c((0,h.join)(a,".gsd")),e=c((0,h.join)(a,".planning")),g=c((0,h.join)(a,".git")),i=c((0,h.join)(a,"package.json")),j=c((0,h.join)(a,"Cargo.toml")),k=c((0,h.join)(a,"go.mod")),l=c((0,h.join)(a,"pyproject.toml")),m=function(a,b){let c=b??F().existsSync??f.existsSync;if(c((0,h.join)(a,"pnpm-workspace.yaml"))||c((0,h.join)(a,"lerna.json"))||c((0,h.join)(a,"rush.json"))||c((0,h.join)(a,"nx.json"))||c((0,h.join)(a,"turbo.json")))return!0;let d=(0,h.join)(a,"package.json");if(c(d))try{let a=(0,f.readFileSync)(d,"utf-8"),b=JSON.parse(a);if(null!=b.workspaces)return!0}catch{}return!1}(a,c),n=0;try{n=(0,f.readdirSync)(a).filter(a=>!a.startsWith(".")).length}catch{}let o={hasGsdFolder:d,hasPlanningFolder:e,hasGitRepo:g,hasPackageJson:i,hasCargo:j,hasGoMod:k,hasPyproject:l,isMonorepo:m,fileCount:n};if(d){let c=(0,h.join)(a,".gsd","milestones"),d=!1;try{d=(0,f.readdirSync)(c,{withFileTypes:!0}).some(a=>a.isDirectory())}catch{}b=d?"active-gsd":"empty-gsd"}else b=e?"v1-legacy":i||j||k||l||n>2||g&&n>0?"brownfield":"blank";return{kind:b,signals:o}}let w={spawn:(a,b,c)=>(0,e.spawn)(a,b,c),existsSync:f.existsSync,execPath:process.execPath,env:process.env,indexWorkspace:a=>K(a),getAutoDashboardData:async()=>{let a=F(),b=a.env??process.env,c=L(b);return await p(c.packageRoot,{execPath:a.execPath??process.execPath,env:b,existsSync:a.existsSync??f.existsSync})},listSessions:async a=>J(a)},x=new Map,y=new Map;async function z(a){let b=F(),c=(0,h.join)(a.packageRoot,"packages","pi-coding-agent","dist","core","session-manager.js");if(!(b.existsSync??f.existsSync)(c))throw Error(`session manager module not found; checked=${c}`);return await new Promise((d,f)=>{(0,e.execFile)(b.execPath??process.execPath,["--input-type=module","--eval",'const { pathToFileURL } = await import("node:url"); const mod = await import(pathToFileURL(process.env.GSD_SESSION_MANAGER_MODULE).href); const sessions = await mod.SessionManager.list(process.env.GSD_SESSION_BROWSER_CWD, process.env.GSD_SESSION_BROWSER_DIR); process.stdout.write(JSON.stringify(sessions.map((session) => ({ ...session, created: session.created.toISOString(), modified: session.modified.toISOString() }))));'],{cwd:a.packageRoot,env:{...b.env??process.env,GSD_SESSION_MANAGER_MODULE:c,GSD_SESSION_BROWSER_CWD:a.projectCwd,GSD_SESSION_BROWSER_DIR:a.projectSessionsDir},maxBuffer:1048576,windowsHide:!0},(a,b,c)=>{if(a)return void f(Error(`session list subprocess failed: ${c||a.message}`));try{let a=JSON.parse(b);d(a.map(a=>({...a,created:new Date(a.created),modified:new Date(a.modified)})))}catch(a){f(Error(`session list subprocess returned invalid JSON: ${a instanceof Error?a.message:String(a)}`))}})})}async function A(a,b,c){let d=F(),g=(0,h.join)(a.packageRoot,"packages","pi-coding-agent","dist","core","session-manager.js");if(!(d.existsSync??f.existsSync)(g))throw Error(`session manager module not found; checked=${g}`);await new Promise((f,h)=>{(0,e.execFile)(d.execPath??process.execPath,["--input-type=module","--eval",'const { pathToFileURL } = await import("node:url"); const mod = await import(pathToFileURL(process.env.GSD_SESSION_MANAGER_MODULE).href); const manager = mod.SessionManager.open(process.env.GSD_TARGET_SESSION_PATH, process.env.GSD_SESSION_BROWSER_DIR); manager.appendSessionInfo(process.env.GSD_TARGET_SESSION_NAME);'],{cwd:a.packageRoot,env:{...d.env??process.env,GSD_SESSION_MANAGER_MODULE:g,GSD_SESSION_BROWSER_DIR:a.projectSessionsDir,GSD_TARGET_SESSION_PATH:b,GSD_TARGET_SESSION_NAME:c},maxBuffer:1048576,windowsHide:!0},(a,b,c)=>{a?h(Error(`session rename subprocess failed: ${c||a.message}`)):f()})})}function B(){return new Date().toISOString()}function C(a){return`${JSON.stringify(a)}
|
|
12
|
-
`}function D(a){return a.replace(/sk-[A-Za-z0-9_-]{6,}/g,"[redacted]").replace(/xox[baprs]-[A-Za-z0-9-]+/g,"[redacted]").replace(/Bearer\s+[^\s]+/gi,"Bearer [redacted]").replace(/([A-Z0-9_]*(?:API[_-]?KEY|TOKEN|SECRET)["'=:\s]+)([^\s,;"']+)/gi,"$1[redacted]")}function E(a){return D(a instanceof Error?a.message:String(a)).replace(/\s+/g," ").trim()}function F(){return{...w}}function G(a){return structuredClone(a)}async function H(a,b){let c=y.get(a),d=Date.now();if(c?.value&&c.expiresAt>d)return G(c.value);if(c?.promise)return G(await c.promise);let e=b().then(b=>(y.set(a,{value:G(b),expiresAt:Date.now()+3e4,promise:null}),b)).catch(b=>{throw y.delete(a),b});return y.set(a,{value:c?.value??null,expiresAt:0,promise:e}),G(await e)}async function I(a,b){let c=F(),d=c.existsSync??f.existsSync,g=(0,h.join)(b,"src","resources","extensions","gsd","tests","resolve-ts.mjs"),k=(0,j.KW)(b,"resources/extensions/gsd/workspace-index.ts",d),l=k.modulePath;if(!k.useCompiledJs&&(!d(g)||!d(l)))throw Error(`workspace index loader not found; checked=${g},${l}`);if(k.useCompiledJs&&!d(l))throw Error(`workspace index module not found; checked=${l}`);let m=(0,j.vB)(b,k,(0,i.pathToFileURL)(g).href);return await new Promise((d,f)=>{(0,e.execFile)(c.execPath??process.execPath,[...m,"--eval",'const { pathToFileURL } = await import("node:url"); const mod = await import(pathToFileURL(process.env.GSD_WORKSPACE_MODULE).href); const result = await mod.indexWorkspace(process.env.GSD_WORKSPACE_BASE); process.stdout.write(JSON.stringify(result));'],{cwd:b,env:{...c.env??process.env,GSD_WORKSPACE_MODULE:l,GSD_WORKSPACE_BASE:a},maxBuffer:1048576,windowsHide:!0},(a,b,c)=>{if(a)return void f(Error(`workspace index subprocess failed: ${c||a.message}`));try{d(JSON.parse(b))}catch(a){f(Error(`workspace index subprocess returned invalid JSON: ${a instanceof Error?a.message:String(a)}`))}})})}function J(a){if(!(0,f.existsSync)(a))return[];let b=(0,f.readdirSync)(a).filter(a=>a.endsWith(".jsonl")).map(b=>(function(a){try{let b,c=(0,f.readFileSync)(a,"utf-8").split("\n").map(a=>a.trim()).filter(Boolean),d="",e="",g=(0,f.statSync)(a).birthtime,h=0;for(let a of c){let c=JSON.parse(a);"session"===c.type?(d="string"==typeof c.id?c.id:d,e="string"==typeof c.cwd?c.cwd:e,"string"==typeof c.timestamp&&(g=new Date(c.timestamp))):"session_info"===c.type&&"string"==typeof c.name?b=c.name:"message"===c.type&&(h+=1)}if(!d)return null;return{path:a,id:d,cwd:e,name:b,created:g,modified:(0,f.statSync)(a).mtime,messageCount:h}}catch{return null}})((0,h.join)(a,b))).filter(a=>null!==a);return b.sort((a,b)=>b.modified.getTime()-a.modified.getTime()),b}async function K(a){let b=L().packageRoot;return await I(a,b)}function L(a=F().env??process.env,b){let c=b||a.GSD_WEB_PROJECT_CWD||process.cwd(),e=a.GSD_WEB_PROJECT_SESSIONS_DIR||function(a,b=l.vo){let c=`--${a.replace(/^[/\\]/,"").replace(/[/\\:]/g,"-")}--`;return(0,h.join)(b,c)}(c);return{projectCwd:c,projectSessionsDir:e,packageRoot:a.GSD_WEB_PACKAGE_ROOT||(void 0!==d?d:d=function(a,b=2){try{let c=(0,h.dirname)((0,i.fileURLToPath)(a)),d=Array.from({length:b},()=>"..");return(0,h.resolve)(c,...d)}catch{return null}}("file:///__w/gsd-2/gsd-2/src/web/bridge-service.ts")??process.cwd())}}function M(a){return"extension_ui_response"===a.type}function N(a){return a.success?a:{...a,error:D(a.error)}}class O{constructor(a,b){this.subscribers=new Set,this.terminalSubscribers=new Set,this.pendingRequests=new Map,this.process=null,this.detachStdoutReader=null,this.startPromise=null,this.refreshPromise=null,this.authRefreshPromise=null,this.requestCounter=0,this.stderrBuffer="",this.config=a,this.deps=b,this.snapshot={phase:"idle",projectCwd:a.projectCwd,projectSessionsDir:a.projectSessionsDir,packageRoot:a.packageRoot,startedAt:null,updatedAt:B(),connectionCount:0,lastCommandType:null,activeSessionId:null,activeSessionFile:null,sessionState:null,lastError:null}}getSnapshot(){return structuredClone(this.snapshot)}publishLiveStateInvalidation(a){var b,c;let d=(c=a,{type:"live_state_invalidation",at:B(),reason:c.reason,source:c.source,domains:[...new Set(c.domains)],workspaceIndexCacheInvalidated:!!c.workspaceIndexCacheInvalidated});return d.workspaceIndexCacheInvalidated&&((b=this.config.projectCwd)?y.delete(b):y.clear()),this.emit(d),d}async ensureStarted(){if(!this.process||"ready"!==this.snapshot.phase){if(this.startPromise)return await this.startPromise;this.startPromise=this.startInternal();try{await this.startPromise}finally{this.startPromise=null}}}async sendInput(a){if(await this.ensureStarted(),!this.process?.stdin)throw Error(this.snapshot.lastError?.message||"RPC bridge is not connected");if(M(a))return this.process.stdin.write(C(a)),null;let b=N(await this.requestResponse(a));if(this.snapshot.lastCommandType=a.type,this.snapshot.updatedAt=B(),!b.success)return this.recordError(b.error,this.snapshot.phase,{commandType:a.type}),this.broadcastStatus(),b;if("get_state"===a.type&&b.success&&"get_state"===b.command)return this.applySessionState(b.data),this.broadcastStatus(),b;let c=function(a,b){if(!b.success)return null;switch(a.type){case"new_session":return"new_session"===b.command&&!1===b.data.cancelled?{reason:"new_session",source:"rpc_command",domains:["resumable_sessions","recovery"]}:null;case"switch_session":return"switch_session"===b.command&&!1===b.data.cancelled?{reason:"switch_session",source:"rpc_command",domains:["resumable_sessions","recovery"]}:null;case"fork":return"fork"===b.command&&!1===b.data.cancelled?{reason:"fork",source:"rpc_command",domains:["resumable_sessions","recovery"]}:null;case"set_session_name":return"set_session_name"===b.command?{reason:"set_session_name",source:"rpc_command",domains:["resumable_sessions"]}:null;default:return null}}(a,b);return c&&this.publishLiveStateInvalidation(c),this.queueStateRefresh(),this.broadcastStatus(),b}async refreshAuth(){if(this.authRefreshPromise)return await this.authRefreshPromise;this.authRefreshPromise=this.refreshAuthInternal().finally(()=>{this.authRefreshPromise=null}),await this.authRefreshPromise}async refreshAuthInternal(){this.startPromise&&await this.startPromise,this.process&&"ready"===this.snapshot.phase&&this.resetProcessForAuthRefresh(),await this.ensureStarted()}resetProcessForAuthRefresh(){let a=this.process;for(let a of(this.process=null,this.detachStdoutReader?.(),this.detachStdoutReader=null,this.stderrBuffer="",this.pendingRequests.values()))clearTimeout(a.timeout),a.reject(Error("RPC bridge restarting to reload auth"));if(this.pendingRequests.clear(),a){a.removeAllListeners("exit"),a.removeAllListeners("error"),a.kill("SIGTERM");try{a?.stdin?.destroy()}catch{}try{a?.stdout?.destroy()}catch{}try{a?.stderr?.destroy()}catch{}}this.snapshot.phase="idle",this.snapshot.updatedAt=B(),this.snapshot.lastError=null,this.broadcastStatus()}subscribe(a){return this.subscribers.add(a),this.snapshot.connectionCount=this.subscribers.size,this.snapshot.updatedAt=B(),this.broadcastStatus(),()=>{this.subscribers.delete(a),this.snapshot.connectionCount=this.subscribers.size,this.snapshot.updatedAt=B(),this.subscribers.size>0&&this.broadcastStatus()}}subscribeTerminal(a){return this.terminalSubscribers.add(a),()=>{this.terminalSubscribers.delete(a)}}async sendTerminalInput(a){await this.sendTerminalCommand({type:"terminal_input",data:a})}async resizeTerminal(a,b){await this.sendTerminalCommand({type:"terminal_resize",cols:a,rows:b})}async redrawTerminal(){await this.sendTerminalCommand({type:"terminal_redraw"})}async sendTerminalCommand(a){await this.ensureStarted();let b=N(await this.requestResponse(a));if(!b.success)throw this.recordError(b.error,this.snapshot.phase,{commandType:a.type}),this.broadcastStatus(),Error(b.error)}async dispose(){for(let a of(this.detachStdoutReader?.(),this.detachStdoutReader=null,this.terminalSubscribers.clear(),this.pendingRequests.values()))clearTimeout(a.timeout),a.reject(Error("RPC bridge disposed"));this.pendingRequests.clear(),this.process&&(this.process.removeAllListeners(),this.process.kill("SIGTERM"),this.process=null),this.snapshot.phase="idle",this.snapshot.connectionCount=0,this.snapshot.updatedAt=B()}async startInternal(){var a,b,c,d;let h,i,j,k,l,m,n;this.snapshot.phase="starting",this.snapshot.startedAt=B(),this.snapshot.updatedAt=this.snapshot.startedAt,this.snapshot.lastError=null,this.broadcastStatus();try{a=this.config,b=this.deps,h=(0,q.N)({packageRoot:a.packageRoot,cwd:a.projectCwd,execPath:b.execPath??process.execPath,hostKind:(b.env??process.env).GSD_WEB_HOST_KIND,mode:"rpc",sessionDir:a.projectSessionsDir,existsSync:b.existsSync??f.existsSync})}catch(a){throw this.snapshot.phase="failed",this.recordError(a,"starting"),a}let o=this.deps.spawn??((a,b,c)=>(0,e.spawn)(a,b,c)),p={...this.deps.env??process.env};delete p.GSD_CODING_AGENT_DIR,p.GSD_WEB_BRIDGE_TUI="1";let r=o(h.command,h.args,{cwd:h.cwd,env:p,stdio:["pipe","pipe","pipe"],windowsHide:!0});this.process=r,this.stderrBuffer="",r.stderr.on("data",a=>{var b,c;let d;this.stderrBuffer=(b=this.stderrBuffer,c=a.toString(),(d=`${b}${c}`).length<=8e3?d:d.slice(d.length-8e3))}),this.detachStdoutReader=(c=r.stdout,d=a=>this.handleStdoutLine(a),j=new g.StringDecoder("utf8"),k="",l=a=>{d(a.endsWith("\r")?a.slice(0,-1):a)},m=a=>{for(k+="string"==typeof a?a:j.write(a);;){let a=k.indexOf("\n");if(-1===a)return;l(k.slice(0,a)),k=k.slice(a+1)}},n=()=>{(k+=j.end()).length>0&&(l(k),k="")},c.on("data",m),c.on("end",n),()=>{c.off("data",m),c.off("end",n)}),r.once("exit",(a,b)=>this.handleProcessExit(a,b)),r.once("error",a=>this.handleProcessExit(null,null,a));let s=new Promise((a,b)=>{i=setTimeout(()=>b(Error("RPC bridge startup timed out after 150000ms")),15e4)});try{await Promise.race([this.refreshState(!0),s]),this.snapshot.phase="ready",this.snapshot.updatedAt=B(),this.snapshot.lastError=null,this.broadcastStatus()}catch(a){throw this.snapshot.phase="failed",this.recordError(a,"starting"),this.broadcastStatus(),a}finally{i&&clearTimeout(i)}}async queueStateRefresh(){if(this.refreshPromise)return await this.refreshPromise;this.refreshPromise=this.refreshState(!1).catch(a=>{this.recordError(a,this.snapshot.phase,{commandType:"get_state"})}).finally(()=>{this.refreshPromise=null}),await this.refreshPromise}async refreshState(a){let b=N(await this.requestResponse({type:"get_state"},a?15e4:void 0));if(!b.success)throw Error(b.error);"get_state"===b.command&&this.applySessionState(b.data),this.snapshot.updatedAt=B(),a||this.broadcastStatus()}applySessionState(a){this.snapshot.sessionState=a,this.snapshot.activeSessionId=a.sessionId,this.snapshot.activeSessionFile=a.sessionFile??null}requestResponse(a,b){if(!this.process?.stdin)return Promise.reject(Error("RPC bridge is not connected"));let c=a.id??`web_${++this.requestCounter}`,d={...a,id:c},e=b??3e4;return new Promise((a,b)=>{let f=setTimeout(()=>{this.pendingRequests.delete(c),b(Error(`Timed out waiting for RPC response to ${d.type}`))},e);this.pendingRequests.set(c,{resolve:b=>{clearTimeout(f),a(b)},reject:a=>{clearTimeout(f),b(a)},timeout:f}),this.process.stdin.write(C(d))})}handleStdoutLine(a){var b,c;let d;try{d=JSON.parse(a)}catch{return}if("object"==typeof(b=d)&&null!==b&&"type"in b&&"terminal_output"===b.type&&"string"==typeof b.data)return void this.emitTerminal(d.data);if("object"==typeof d&&null!==d&&"type"in d&&"response"===d.type){let a=N(d);if(a.id&&this.pendingRequests.has(a.id)){let b=this.pendingRequests.get(a.id);this.pendingRequests.delete(a.id),b.resolve(a);return}}let e="object"==typeof(c=d)&&null!==c&&"type"in c&&"extension_error"===c.type?{...c,error:D(c.error)}:c;if(this.emit(e),"object"==typeof e&&null!==e&&"type"in e&&"session_state_changed"===e.type&&"string"==typeof e.reason){let a=function(a){switch(a){case"new_session":return{reason:"new_session",source:"bridge_event",domains:["resumable_sessions","recovery"]};case"switch_session":return{reason:"switch_session",source:"bridge_event",domains:["resumable_sessions","recovery"]};case"fork":return{reason:"fork",source:"bridge_event",domains:["resumable_sessions","recovery"]};case"set_session_name":return{reason:"set_session_name",source:"bridge_event",domains:["resumable_sessions"]};default:return null}}(e.reason);a&&this.publishLiveStateInvalidation(a),this.queueStateRefresh();return}let f=function(a){if("object"!=typeof a||null===a||!("type"in a))return null;switch(a.type){case"agent_end":return{reason:"agent_end",source:"bridge_event",domains:["auto","workspace","recovery"],workspaceIndexCacheInvalidated:!0};case"turn_end":return{reason:"turn_end",source:"bridge_event",domains:["workspace"],workspaceIndexCacheInvalidated:!0};case"auto_retry_start":return{reason:"auto_retry_start",source:"bridge_event",domains:["auto","recovery"]};case"auto_retry_end":return{reason:"auto_retry_end",source:"bridge_event",domains:["auto","recovery"]};case"auto_compaction_start":return{reason:"auto_compaction_start",source:"bridge_event",domains:["auto","recovery"]};case"auto_compaction_end":return{reason:"auto_compaction_end",source:"bridge_event",domains:["auto","recovery"]};default:return null}}(e);if(f&&this.publishLiveStateInvalidation(f),"object"==typeof e&&null!==e&&"type"in e){let a=e.type;("agent_end"===a||"turn_end"===a||"auto_retry_start"===a||"auto_retry_end"===a||"auto_compaction_start"===a||"auto_compaction_end"===a)&&this.queueStateRefresh()}}handleProcessExit(a,b,c){var d;let e,f;this.detachStdoutReader?.(),this.detachStdoutReader=null,this.process=null;let g=Error((d=this.stderrBuffer,e=`RPC bridge exited${null!==a?` with code ${a}`:""}${b?` (${b})`:""}`,(f=D(d).trim())?`${e}. stderr=${f}`:e));for(let a of this.pendingRequests.values())clearTimeout(a.timeout),a.reject(g);this.pendingRequests.clear(),this.snapshot.phase="failed",this.snapshot.updatedAt=B(),this.recordError(c??g,this.snapshot.activeSessionId?"ready":"starting"),this.broadcastStatus()}recordError(a,b,c={}){this.snapshot.lastError={message:E(a),at:B(),phase:b,afterSessionAttachment:!!this.snapshot.activeSessionId,commandType:c.commandType},this.snapshot.updatedAt=this.snapshot.lastError.at}emit(a){for(let b of this.subscribers)try{b(a)}catch{}}emitTerminal(a){for(let b of this.terminalSubscribers)try{b(a)}catch{}}broadcastStatus(){0!==this.subscribers.size&&this.emit({type:"bridge_status",bridge:this.getSnapshot()})}}function P(a){let b=(0,h.resolve)(a),c=x.get(b);if(c)return c;let d=new O(L(void 0,b),F());return x.set(b,d),d}function Q(a){try{let b=new URL(a.url).searchParams.get("project");if(b)return decodeURIComponent(b)}catch{}return(F().env??process.env).GSD_WEB_PROJECT_CWD||null}function R(a){let b=Q(a);if(!b)throw new S;return b}class S extends Error{constructor(){super("No project selected"),this.name="NoProjectError"}}function T(){return P(L().projectCwd)}function U(a,b){return{id:a.id,path:a.path,cwd:a.cwd,name:a.name,createdAt:a.created.toISOString(),modifiedAt:a.modified.toISOString(),messageCount:a.messageCount,isActive:!!(b&&a.path===b)}}function V(a,b,c={}){return{success:!1,action:"rename",scope:k.PO,code:a,error:b,...c}}async function W(a={},b){let c=L(F().env??process.env,b),d=b?P(b):T();try{await d.ensureStarted()}catch{}let e=d.getSnapshot(),f=await z(c),g=(0,k.on)(a),i=("threaded"===g.sortMode&&!g.query?function(a){let b=[],c=(a,d,e,f)=>{b.push({session:a.session,depth:d,isLastInThread:f,ancestorHasNextSibling:e});for(let b=0;b<a.children.length;b++){let g=a.children[b];if(!g)continue;let h=b===a.children.length-1,i=d>0&&!f;c(g,d+1,[...e,i],h)}};for(let b=0;b<a.length;b++){let d=a[b];d&&c(d,0,[],b===a.length-1)}return b}(function(a){let b=new Map;for(let c of a)b.set(c.path,{session:c,children:[]});let c=[];for(let d of a){let a=b.get(d.path);if(!a)continue;let e=d.parentSessionPath;if(e&&b.has(e)){b.get(e).children.push(a);continue}c.push(a)}let d=a=>{for(let b of(a.sort((a,b)=>b.session.modified.getTime()-a.session.modified.getTime()),a))d(b.children)};return d(c),c}("named"===g.nameFilter?f.filter(a=>t(a)):f)):(function(a,b,c,d){let e="all"===d?a:a.filter(a=>t(a));if(!b.trim())return e;let f=function(a){let b=a.trim();if(!b)return{mode:"tokens",tokens:[],regex:null};if(b.startsWith("re:")){let a=b.slice(3).trim();if(!a)return{mode:"regex",tokens:[],regex:null,error:"Empty regex"};try{return{mode:"regex",tokens:[],regex:RegExp(a,"i")}}catch(a){return{mode:"regex",tokens:[],regex:null,error:a instanceof Error?a.message:String(a)}}}let c=[],d="",e=!1,f=!1,g=a=>{let b=d.trim();d="",b&&c.push({kind:a,value:b})};for(let a=0;a<b.length;a++){let c=b[a];if(c){if('"'===c){e?(g("phrase"),e=!1):(g("fuzzy"),e=!0);continue}if(!e&&/\s/.test(c)){g("fuzzy");continue}d+=c}}return(e&&(f=!0),f)?{mode:"tokens",tokens:b.split(/\s+/).map(a=>a.trim()).filter(a=>a.length>0).map(a=>({kind:"fuzzy",value:a})),regex:null}:(g(e?"phrase":"fuzzy"),{mode:"tokens",tokens:c,regex:null})}(b);if(f.error)return[];if("recent"===c){let a=[];for(let b of e)u(b,f).matches&&a.push(b);return a}let g=[];for(let a of e){let b=u(a,f);b.matches&&g.push({session:a,score:b.score})}return g.sort((a,b)=>a.score!==b.score?a.score-b.score:b.session.modified.getTime()-a.session.modified.getTime()),g.map(a=>a.session)})(f,g.query,g.sortMode,g.nameFilter).map(a=>({session:a,depth:0,isLastInThread:!0,ancestorHasNextSibling:[]}))).map(a=>(function(a,b){let{session:c}=a,d=!!(b&&(0,h.resolve)(c.path)===(0,h.resolve)(b));return{id:c.id,path:c.path,cwd:c.cwd,name:c.name,createdAt:c.created.toISOString(),modifiedAt:c.modified.toISOString(),messageCount:c.messageCount,parentSessionPath:c.parentSessionPath,firstMessage:c.firstMessage,isActive:d,depth:a.depth,isLastInThread:a.isLastInThread,ancestorHasNextSibling:[...a.ancestorHasNextSibling]}})(a,e.activeSessionFile));return{project:{scope:k.PO,cwd:c.projectCwd,sessionsDir:c.projectSessionsDir,activeSessionPath:e.activeSessionFile},query:g,totalSessions:f.length,returnedSessions:i.length,sessions:i}}async function X(a,b){var c,d;let e,f=L(F().env??process.env,b),g=a.name.trim();if(!g)return V("invalid_request","Session name cannot be empty",{sessionPath:a.sessionPath,name:a.name});let i=(c=await z(f),d=a.sessionPath,e=(0,h.resolve)(d),c.find(a=>(0,h.resolve)(a.path)===e));if(!i)return V("not_found","Session is not available in the current project browser",{sessionPath:a.sessionPath,name:g});let j=b?P(b):T();try{await j.ensureStarted()}catch(a){return V("rename_failed",E(a),{sessionPath:i.path,name:g})}let l=j.getSnapshot().activeSessionFile;if(l&&(0,h.resolve)(l)===(0,h.resolve)(i.path)){let a=await ac({type:"set_session_name",name:g},b);return null===a?V("rename_failed","Active session rename did not return a response",{sessionPath:i.path,name:g,isActiveSession:!0,mutation:"rpc"}):a.success?{success:!0,action:"rename",scope:k.PO,sessionPath:i.path,name:g,isActiveSession:!0,mutation:"rpc"}:V("onboarding_locked"===a.code?"onboarding_locked":"rename_failed",a.error,{sessionPath:i.path,name:g,isActiveSession:!0,mutation:"rpc"})}try{return await A(f,i.path,g),j.publishLiveStateInvalidation({reason:"set_session_name",source:"session_manage",domains:["resumable_sessions"]}),{success:!0,action:"rename",scope:k.PO,sessionPath:i.path,name:g,isActiveSession:!1,mutation:"session_file"}}catch(a){return V("rename_failed",E(a),{sessionPath:i.path,name:g,isActiveSession:!1,mutation:"session_file"})}}async function Y(a,b){if(a.getOnboardingState)return await a.getOnboardingState();if(a.getOnboardingNeeded){var c;return{status:(c=await a.getOnboardingNeeded(l.sI,b))?"blocked":"ready",locked:c,lockReason:c?"required_setup":null,required:{blocking:!0,skippable:!1,satisfied:!c,satisfiedBy:c?null:{providerId:"legacy",source:"runtime"},providers:[]},optional:{blocking:!1,skippable:!0,sections:[]},lastValidation:null,activeFlow:null,bridgeAuthRefresh:{phase:"idle",strategy:null,startedAt:null,completedAt:null,error:null}}}return await (0,m.r$)()}async function Z(a){let b=F(),c=b.env??process.env;return await Y(b,c)}async function $(a=["auto","workspace","resumable_sessions"],b){let c=F(),d=L(c.env??process.env,b),e=b?P(b):T();try{await e.ensureStarted()}catch{}let f=e.getSnapshot(),g=[...new Set(a)],h={bridge:f};if(g.includes("workspace")&&(h.workspace=await H(d.projectCwd,async()=>await (c.indexWorkspace??K)(d.projectCwd))),g.includes("auto")){let a=c.getAutoDashboardData??(()=>o());h.auto=await Promise.resolve(a())}return g.includes("resumable_sessions")&&(h.resumableSessions=(await (c.listSessions??(async a=>J(a)))(d.projectSessionsDir)).map(a=>U(a,f.activeSessionFile))),h}async function _(a){let b=F(),c=b.env??process.env,d=L(c,a),e=b.getAutoDashboardData??(()=>o()),f=b.listSessions??(async a=>J(a)),g=v(d.projectCwd),h=await Y(b,c);if(h.locked&&"packaged-standalone"===c.GSD_WEB_HOST_KIND)return{project:{cwd:d.projectCwd,sessionsDir:d.projectSessionsDir,packageRoot:d.packageRoot},workspace:{milestones:[],active:{phase:"pre-planning"},scopes:[{scope:"project",label:"project",kind:"project"}],validationIssues:[]},auto:o(),onboarding:h,onboardingNeeded:!0,resumableSessions:[],bridge:{phase:"idle",projectCwd:d.projectCwd,projectSessionsDir:d.projectSessionsDir,packageRoot:d.packageRoot,startedAt:null,updatedAt:new Date().toISOString(),connectionCount:0,lastCommandType:null,activeSessionId:null,activeSessionFile:null,sessionState:null,lastError:null},projectDetection:g};let i=a?P(a):T(),j=H(d.projectCwd,async()=>await (b.indexWorkspace??K)(d.projectCwd)),k=Promise.resolve(e()),l=f(d.projectSessionsDir);try{await i.ensureStarted()}catch{}let m=i.getSnapshot(),[n,p,q]=await Promise.all([j,k,l]);return{project:{cwd:d.projectCwd,sessionsDir:d.projectSessionsDir,packageRoot:d.packageRoot},workspace:n,auto:p,onboarding:h,onboardingNeeded:h.locked,resumableSessions:q.map(a=>U(a,m.activeSessionFile)),bridge:m,projectDetection:g}}function aa(a,b){return{type:"response",command:a,success:!1,error:E(b)}}async function ab(a){let b=a?P(a):T();await b.refreshAuth()}async function ac(a,b){if(!(!M(a)&&r.has(a.type))){let b=await (0,m.r$)();if(b.locked){let c;return c=b.lockReason??"required_setup",{type:"response",command:a.type,success:!1,error:"bridge_refresh_failed"===c?"Workspace is locked because bridge auth refresh failed after setup":"bridge_refresh_pending"===c?"Workspace is still locked while bridge auth refresh completes":"Workspace is locked until required onboarding completes",code:"onboarding_locked",details:{reason:c,onboarding:{locked:b.locked,lockReason:b.lockReason,required:b.required,lastValidation:b.lastValidation,bridgeAuthRefresh:b.bridgeAuthRefresh}}}}}let c=b?P(b):T();return await c.sendInput(a)}(0,m.Eu)(async()=>{await ab()})},7849:(a,b,c)=>{"use strict";c.d(b,{Ic:()=>j,_y:()=>f,sI:()=>i,vo:()=>h});var d=c(1820),e=c(3873);let f=process.env.GSD_HOME||(0,e.join)((0,d.homedir)(),".gsd"),g=(0,e.join)(f,"agent"),h=(0,e.join)(f,"sessions"),i=(0,e.join)(g,"auth.json");(0,e.join)(f,"web-server.pid");let j=(0,e.join)(f,"web-preferences.json")},8335:()=>{},9225:(a,b,c)=>{"use strict";a.exports=c(4870)}};
|
|
12
|
+
`}function D(a){return a.replace(/sk-[A-Za-z0-9_-]{6,}/g,"[redacted]").replace(/xox[baprs]-[A-Za-z0-9-]+/g,"[redacted]").replace(/Bearer\s+[^\s]+/gi,"Bearer [redacted]").replace(/([A-Z0-9_]*(?:API[_-]?KEY|TOKEN|SECRET)["'=:\s]+)([^\s,;"']+)/gi,"$1[redacted]")}function E(a){return D(a instanceof Error?a.message:String(a)).replace(/\s+/g," ").trim()}function F(){return{...w}}function G(a){return structuredClone(a)}async function H(a,b){let c=y.get(a),d=Date.now();if(c?.value&&c.expiresAt>d)return G(c.value);if(c?.promise)return G(await c.promise);let e=b().then(b=>(y.set(a,{value:G(b),expiresAt:Date.now()+3e4,promise:null}),b)).catch(b=>{throw y.delete(a),b});return y.set(a,{value:c?.value??null,expiresAt:0,promise:e}),G(await e)}async function I(a,b){let c=F(),d=c.existsSync??f.existsSync,g=(0,h.join)(b,"src","resources","extensions","gsd","tests","resolve-ts.mjs"),k=(0,j.KW)(b,"resources/extensions/gsd/workspace-index.ts",d),l=k.modulePath;if(!k.useCompiledJs&&(!d(g)||!d(l)))throw Error(`workspace index loader not found; checked=${g},${l}`);if(k.useCompiledJs&&!d(l))throw Error(`workspace index module not found; checked=${l}`);let m=(0,j.vB)(b,k,(0,i.pathToFileURL)(g).href);return await new Promise((d,f)=>{(0,e.execFile)(c.execPath??process.execPath,[...m,"--eval",'const { pathToFileURL } = await import("node:url"); const mod = await import(pathToFileURL(process.env.GSD_WORKSPACE_MODULE).href); const result = await mod.indexWorkspace(process.env.GSD_WORKSPACE_BASE); process.stdout.write(JSON.stringify(result));'],{cwd:b,env:{...c.env??process.env,GSD_WORKSPACE_MODULE:l,GSD_WORKSPACE_BASE:a},maxBuffer:1048576,windowsHide:!0},(a,b,c)=>{if(a)return void f(Error(`workspace index subprocess failed: ${c||a.message}`));try{d(JSON.parse(b))}catch(a){f(Error(`workspace index subprocess returned invalid JSON: ${a instanceof Error?a.message:String(a)}`))}})})}function J(a){if(!(0,f.existsSync)(a))return[];let b=(0,f.readdirSync)(a).filter(a=>a.endsWith(".jsonl")).map(b=>(function(a){try{let b,c=(0,f.readFileSync)(a,"utf-8").split("\n").map(a=>a.trim()).filter(Boolean),d="",e="",g=(0,f.statSync)(a).birthtime,h=0;for(let a of c){let c=JSON.parse(a);"session"===c.type?(d="string"==typeof c.id?c.id:d,e="string"==typeof c.cwd?c.cwd:e,"string"==typeof c.timestamp&&(g=new Date(c.timestamp))):"session_info"===c.type&&"string"==typeof c.name?b=c.name:"message"===c.type&&(h+=1)}if(!d)return null;return{path:a,id:d,cwd:e,name:b,created:g,modified:(0,f.statSync)(a).mtime,messageCount:h}}catch{return null}})((0,h.join)(a,b))).filter(a=>null!==a);return b.sort((a,b)=>b.modified.getTime()-a.modified.getTime()),b}async function K(a){let b=L().packageRoot;return await I(a,b)}function L(a=F().env??process.env,b){let c=b||a.GSD_WEB_PROJECT_CWD||process.cwd(),e=a.GSD_WEB_PROJECT_SESSIONS_DIR||function(a,b=l.vo){let c=`--${a.replace(/^[/\\]/,"").replace(/[/\\:]/g,"-")}--`;return(0,h.join)(b,c)}(c);return{projectCwd:c,projectSessionsDir:e,packageRoot:a.GSD_WEB_PACKAGE_ROOT||(void 0!==d?d:d=function(a,b=2){try{let c=(0,h.dirname)((0,i.fileURLToPath)(a)),d=Array.from({length:b},()=>"..");return(0,h.resolve)(c,...d)}catch{return null}}("file:///home/runner/_work/gsd-2/gsd-2/src/web/bridge-service.ts")??process.cwd())}}function M(a){return"extension_ui_response"===a.type}function N(a){return a.success?a:{...a,error:D(a.error)}}class O{constructor(a,b){this.subscribers=new Set,this.terminalSubscribers=new Set,this.pendingRequests=new Map,this.process=null,this.detachStdoutReader=null,this.startPromise=null,this.refreshPromise=null,this.authRefreshPromise=null,this.requestCounter=0,this.stderrBuffer="",this.config=a,this.deps=b,this.snapshot={phase:"idle",projectCwd:a.projectCwd,projectSessionsDir:a.projectSessionsDir,packageRoot:a.packageRoot,startedAt:null,updatedAt:B(),connectionCount:0,lastCommandType:null,activeSessionId:null,activeSessionFile:null,sessionState:null,lastError:null}}getSnapshot(){return structuredClone(this.snapshot)}publishLiveStateInvalidation(a){var b,c;let d=(c=a,{type:"live_state_invalidation",at:B(),reason:c.reason,source:c.source,domains:[...new Set(c.domains)],workspaceIndexCacheInvalidated:!!c.workspaceIndexCacheInvalidated});return d.workspaceIndexCacheInvalidated&&((b=this.config.projectCwd)?y.delete(b):y.clear()),this.emit(d),d}async ensureStarted(){if(!this.process||"ready"!==this.snapshot.phase){if(this.startPromise)return await this.startPromise;this.startPromise=this.startInternal();try{await this.startPromise}finally{this.startPromise=null}}}async sendInput(a){if(await this.ensureStarted(),!this.process?.stdin)throw Error(this.snapshot.lastError?.message||"RPC bridge is not connected");if(M(a))return this.process.stdin.write(C(a)),null;let b=N(await this.requestResponse(a));if(this.snapshot.lastCommandType=a.type,this.snapshot.updatedAt=B(),!b.success)return this.recordError(b.error,this.snapshot.phase,{commandType:a.type}),this.broadcastStatus(),b;if("get_state"===a.type&&b.success&&"get_state"===b.command)return this.applySessionState(b.data),this.broadcastStatus(),b;let c=function(a,b){if(!b.success)return null;switch(a.type){case"new_session":return"new_session"===b.command&&!1===b.data.cancelled?{reason:"new_session",source:"rpc_command",domains:["resumable_sessions","recovery"]}:null;case"switch_session":return"switch_session"===b.command&&!1===b.data.cancelled?{reason:"switch_session",source:"rpc_command",domains:["resumable_sessions","recovery"]}:null;case"fork":return"fork"===b.command&&!1===b.data.cancelled?{reason:"fork",source:"rpc_command",domains:["resumable_sessions","recovery"]}:null;case"set_session_name":return"set_session_name"===b.command?{reason:"set_session_name",source:"rpc_command",domains:["resumable_sessions"]}:null;default:return null}}(a,b);return c&&this.publishLiveStateInvalidation(c),this.queueStateRefresh(),this.broadcastStatus(),b}async refreshAuth(){if(this.authRefreshPromise)return await this.authRefreshPromise;this.authRefreshPromise=this.refreshAuthInternal().finally(()=>{this.authRefreshPromise=null}),await this.authRefreshPromise}async refreshAuthInternal(){this.startPromise&&await this.startPromise,this.process&&"ready"===this.snapshot.phase&&this.resetProcessForAuthRefresh(),await this.ensureStarted()}resetProcessForAuthRefresh(){let a=this.process;for(let a of(this.process=null,this.detachStdoutReader?.(),this.detachStdoutReader=null,this.stderrBuffer="",this.pendingRequests.values()))clearTimeout(a.timeout),a.reject(Error("RPC bridge restarting to reload auth"));if(this.pendingRequests.clear(),a){a.removeAllListeners("exit"),a.removeAllListeners("error"),a.kill("SIGTERM");try{a?.stdin?.destroy()}catch{}try{a?.stdout?.destroy()}catch{}try{a?.stderr?.destroy()}catch{}}this.snapshot.phase="idle",this.snapshot.updatedAt=B(),this.snapshot.lastError=null,this.broadcastStatus()}subscribe(a){return this.subscribers.add(a),this.snapshot.connectionCount=this.subscribers.size,this.snapshot.updatedAt=B(),this.broadcastStatus(),()=>{this.subscribers.delete(a),this.snapshot.connectionCount=this.subscribers.size,this.snapshot.updatedAt=B(),this.subscribers.size>0&&this.broadcastStatus()}}subscribeTerminal(a){return this.terminalSubscribers.add(a),()=>{this.terminalSubscribers.delete(a)}}async sendTerminalInput(a){await this.sendTerminalCommand({type:"terminal_input",data:a})}async resizeTerminal(a,b){await this.sendTerminalCommand({type:"terminal_resize",cols:a,rows:b})}async redrawTerminal(){await this.sendTerminalCommand({type:"terminal_redraw"})}async sendTerminalCommand(a){await this.ensureStarted();let b=N(await this.requestResponse(a));if(!b.success)throw this.recordError(b.error,this.snapshot.phase,{commandType:a.type}),this.broadcastStatus(),Error(b.error)}async dispose(){for(let a of(this.detachStdoutReader?.(),this.detachStdoutReader=null,this.terminalSubscribers.clear(),this.pendingRequests.values()))clearTimeout(a.timeout),a.reject(Error("RPC bridge disposed"));this.pendingRequests.clear(),this.process&&(this.process.removeAllListeners(),this.process.kill("SIGTERM"),this.process=null),this.snapshot.phase="idle",this.snapshot.connectionCount=0,this.snapshot.updatedAt=B()}async startInternal(){var a,b,c,d;let h,i,j,k,l,m,n;this.snapshot.phase="starting",this.snapshot.startedAt=B(),this.snapshot.updatedAt=this.snapshot.startedAt,this.snapshot.lastError=null,this.broadcastStatus();try{a=this.config,b=this.deps,h=(0,q.N)({packageRoot:a.packageRoot,cwd:a.projectCwd,execPath:b.execPath??process.execPath,hostKind:(b.env??process.env).GSD_WEB_HOST_KIND,mode:"rpc",sessionDir:a.projectSessionsDir,existsSync:b.existsSync??f.existsSync})}catch(a){throw this.snapshot.phase="failed",this.recordError(a,"starting"),a}let o=this.deps.spawn??((a,b,c)=>(0,e.spawn)(a,b,c)),p={...this.deps.env??process.env};delete p.GSD_CODING_AGENT_DIR,p.GSD_WEB_BRIDGE_TUI="1";let r=o(h.command,h.args,{cwd:h.cwd,env:p,stdio:["pipe","pipe","pipe"],windowsHide:!0});this.process=r,this.stderrBuffer="",r.stderr.on("data",a=>{var b,c;let d;this.stderrBuffer=(b=this.stderrBuffer,c=a.toString(),(d=`${b}${c}`).length<=8e3?d:d.slice(d.length-8e3))}),this.detachStdoutReader=(c=r.stdout,d=a=>this.handleStdoutLine(a),j=new g.StringDecoder("utf8"),k="",l=a=>{d(a.endsWith("\r")?a.slice(0,-1):a)},m=a=>{for(k+="string"==typeof a?a:j.write(a);;){let a=k.indexOf("\n");if(-1===a)return;l(k.slice(0,a)),k=k.slice(a+1)}},n=()=>{(k+=j.end()).length>0&&(l(k),k="")},c.on("data",m),c.on("end",n),()=>{c.off("data",m),c.off("end",n)}),r.once("exit",(a,b)=>this.handleProcessExit(a,b)),r.once("error",a=>this.handleProcessExit(null,null,a));let s=new Promise((a,b)=>{i=setTimeout(()=>b(Error("RPC bridge startup timed out after 150000ms")),15e4)});try{await Promise.race([this.refreshState(!0),s]),this.snapshot.phase="ready",this.snapshot.updatedAt=B(),this.snapshot.lastError=null,this.broadcastStatus()}catch(a){throw this.snapshot.phase="failed",this.recordError(a,"starting"),this.broadcastStatus(),a}finally{i&&clearTimeout(i)}}async queueStateRefresh(){if(this.refreshPromise)return await this.refreshPromise;this.refreshPromise=this.refreshState(!1).catch(a=>{this.recordError(a,this.snapshot.phase,{commandType:"get_state"})}).finally(()=>{this.refreshPromise=null}),await this.refreshPromise}async refreshState(a){let b=N(await this.requestResponse({type:"get_state"},a?15e4:void 0));if(!b.success)throw Error(b.error);"get_state"===b.command&&this.applySessionState(b.data),this.snapshot.updatedAt=B(),a||this.broadcastStatus()}applySessionState(a){this.snapshot.sessionState=a,this.snapshot.activeSessionId=a.sessionId,this.snapshot.activeSessionFile=a.sessionFile??null}requestResponse(a,b){if(!this.process?.stdin)return Promise.reject(Error("RPC bridge is not connected"));let c=a.id??`web_${++this.requestCounter}`,d={...a,id:c},e=b??3e4;return new Promise((a,b)=>{let f=setTimeout(()=>{this.pendingRequests.delete(c),b(Error(`Timed out waiting for RPC response to ${d.type}`))},e);this.pendingRequests.set(c,{resolve:b=>{clearTimeout(f),a(b)},reject:a=>{clearTimeout(f),b(a)},timeout:f}),this.process.stdin.write(C(d))})}handleStdoutLine(a){var b,c;let d;try{d=JSON.parse(a)}catch{return}if("object"==typeof(b=d)&&null!==b&&"type"in b&&"terminal_output"===b.type&&"string"==typeof b.data)return void this.emitTerminal(d.data);if("object"==typeof d&&null!==d&&"type"in d&&"response"===d.type){let a=N(d);if(a.id&&this.pendingRequests.has(a.id)){let b=this.pendingRequests.get(a.id);this.pendingRequests.delete(a.id),b.resolve(a);return}}let e="object"==typeof(c=d)&&null!==c&&"type"in c&&"extension_error"===c.type?{...c,error:D(c.error)}:c;if(this.emit(e),"object"==typeof e&&null!==e&&"type"in e&&"session_state_changed"===e.type&&"string"==typeof e.reason){let a=function(a){switch(a){case"new_session":return{reason:"new_session",source:"bridge_event",domains:["resumable_sessions","recovery"]};case"switch_session":return{reason:"switch_session",source:"bridge_event",domains:["resumable_sessions","recovery"]};case"fork":return{reason:"fork",source:"bridge_event",domains:["resumable_sessions","recovery"]};case"set_session_name":return{reason:"set_session_name",source:"bridge_event",domains:["resumable_sessions"]};default:return null}}(e.reason);a&&this.publishLiveStateInvalidation(a),this.queueStateRefresh();return}let f=function(a){if("object"!=typeof a||null===a||!("type"in a))return null;switch(a.type){case"agent_end":return{reason:"agent_end",source:"bridge_event",domains:["auto","workspace","recovery"],workspaceIndexCacheInvalidated:!0};case"turn_end":return{reason:"turn_end",source:"bridge_event",domains:["workspace"],workspaceIndexCacheInvalidated:!0};case"auto_retry_start":return{reason:"auto_retry_start",source:"bridge_event",domains:["auto","recovery"]};case"auto_retry_end":return{reason:"auto_retry_end",source:"bridge_event",domains:["auto","recovery"]};case"auto_compaction_start":return{reason:"auto_compaction_start",source:"bridge_event",domains:["auto","recovery"]};case"auto_compaction_end":return{reason:"auto_compaction_end",source:"bridge_event",domains:["auto","recovery"]};default:return null}}(e);if(f&&this.publishLiveStateInvalidation(f),"object"==typeof e&&null!==e&&"type"in e){let a=e.type;("agent_end"===a||"turn_end"===a||"auto_retry_start"===a||"auto_retry_end"===a||"auto_compaction_start"===a||"auto_compaction_end"===a)&&this.queueStateRefresh()}}handleProcessExit(a,b,c){var d;let e,f;this.detachStdoutReader?.(),this.detachStdoutReader=null,this.process=null;let g=Error((d=this.stderrBuffer,e=`RPC bridge exited${null!==a?` with code ${a}`:""}${b?` (${b})`:""}`,(f=D(d).trim())?`${e}. stderr=${f}`:e));for(let a of this.pendingRequests.values())clearTimeout(a.timeout),a.reject(g);this.pendingRequests.clear(),this.snapshot.phase="failed",this.snapshot.updatedAt=B(),this.recordError(c??g,this.snapshot.activeSessionId?"ready":"starting"),this.broadcastStatus()}recordError(a,b,c={}){this.snapshot.lastError={message:E(a),at:B(),phase:b,afterSessionAttachment:!!this.snapshot.activeSessionId,commandType:c.commandType},this.snapshot.updatedAt=this.snapshot.lastError.at}emit(a){for(let b of this.subscribers)try{b(a)}catch{}}emitTerminal(a){for(let b of this.terminalSubscribers)try{b(a)}catch{}}broadcastStatus(){0!==this.subscribers.size&&this.emit({type:"bridge_status",bridge:this.getSnapshot()})}}function P(a){let b=(0,h.resolve)(a),c=x.get(b);if(c)return c;let d=new O(L(void 0,b),F());return x.set(b,d),d}function Q(a){try{let b=new URL(a.url).searchParams.get("project");if(b)return decodeURIComponent(b)}catch{}return(F().env??process.env).GSD_WEB_PROJECT_CWD||null}function R(a){let b=Q(a);if(!b)throw new S;return b}class S extends Error{constructor(){super("No project selected"),this.name="NoProjectError"}}function T(){return P(L().projectCwd)}function U(a,b){return{id:a.id,path:a.path,cwd:a.cwd,name:a.name,createdAt:a.created.toISOString(),modifiedAt:a.modified.toISOString(),messageCount:a.messageCount,isActive:!!(b&&a.path===b)}}function V(a,b,c={}){return{success:!1,action:"rename",scope:k.PO,code:a,error:b,...c}}async function W(a={},b){let c=L(F().env??process.env,b),d=b?P(b):T();try{await d.ensureStarted()}catch{}let e=d.getSnapshot(),f=await z(c),g=(0,k.on)(a),i=("threaded"===g.sortMode&&!g.query?function(a){let b=[],c=(a,d,e,f)=>{b.push({session:a.session,depth:d,isLastInThread:f,ancestorHasNextSibling:e});for(let b=0;b<a.children.length;b++){let g=a.children[b];if(!g)continue;let h=b===a.children.length-1,i=d>0&&!f;c(g,d+1,[...e,i],h)}};for(let b=0;b<a.length;b++){let d=a[b];d&&c(d,0,[],b===a.length-1)}return b}(function(a){let b=new Map;for(let c of a)b.set(c.path,{session:c,children:[]});let c=[];for(let d of a){let a=b.get(d.path);if(!a)continue;let e=d.parentSessionPath;if(e&&b.has(e)){b.get(e).children.push(a);continue}c.push(a)}let d=a=>{for(let b of(a.sort((a,b)=>b.session.modified.getTime()-a.session.modified.getTime()),a))d(b.children)};return d(c),c}("named"===g.nameFilter?f.filter(a=>t(a)):f)):(function(a,b,c,d){let e="all"===d?a:a.filter(a=>t(a));if(!b.trim())return e;let f=function(a){let b=a.trim();if(!b)return{mode:"tokens",tokens:[],regex:null};if(b.startsWith("re:")){let a=b.slice(3).trim();if(!a)return{mode:"regex",tokens:[],regex:null,error:"Empty regex"};try{return{mode:"regex",tokens:[],regex:RegExp(a,"i")}}catch(a){return{mode:"regex",tokens:[],regex:null,error:a instanceof Error?a.message:String(a)}}}let c=[],d="",e=!1,f=!1,g=a=>{let b=d.trim();d="",b&&c.push({kind:a,value:b})};for(let a=0;a<b.length;a++){let c=b[a];if(c){if('"'===c){e?(g("phrase"),e=!1):(g("fuzzy"),e=!0);continue}if(!e&&/\s/.test(c)){g("fuzzy");continue}d+=c}}return(e&&(f=!0),f)?{mode:"tokens",tokens:b.split(/\s+/).map(a=>a.trim()).filter(a=>a.length>0).map(a=>({kind:"fuzzy",value:a})),regex:null}:(g(e?"phrase":"fuzzy"),{mode:"tokens",tokens:c,regex:null})}(b);if(f.error)return[];if("recent"===c){let a=[];for(let b of e)u(b,f).matches&&a.push(b);return a}let g=[];for(let a of e){let b=u(a,f);b.matches&&g.push({session:a,score:b.score})}return g.sort((a,b)=>a.score!==b.score?a.score-b.score:b.session.modified.getTime()-a.session.modified.getTime()),g.map(a=>a.session)})(f,g.query,g.sortMode,g.nameFilter).map(a=>({session:a,depth:0,isLastInThread:!0,ancestorHasNextSibling:[]}))).map(a=>(function(a,b){let{session:c}=a,d=!!(b&&(0,h.resolve)(c.path)===(0,h.resolve)(b));return{id:c.id,path:c.path,cwd:c.cwd,name:c.name,createdAt:c.created.toISOString(),modifiedAt:c.modified.toISOString(),messageCount:c.messageCount,parentSessionPath:c.parentSessionPath,firstMessage:c.firstMessage,isActive:d,depth:a.depth,isLastInThread:a.isLastInThread,ancestorHasNextSibling:[...a.ancestorHasNextSibling]}})(a,e.activeSessionFile));return{project:{scope:k.PO,cwd:c.projectCwd,sessionsDir:c.projectSessionsDir,activeSessionPath:e.activeSessionFile},query:g,totalSessions:f.length,returnedSessions:i.length,sessions:i}}async function X(a,b){var c,d;let e,f=L(F().env??process.env,b),g=a.name.trim();if(!g)return V("invalid_request","Session name cannot be empty",{sessionPath:a.sessionPath,name:a.name});let i=(c=await z(f),d=a.sessionPath,e=(0,h.resolve)(d),c.find(a=>(0,h.resolve)(a.path)===e));if(!i)return V("not_found","Session is not available in the current project browser",{sessionPath:a.sessionPath,name:g});let j=b?P(b):T();try{await j.ensureStarted()}catch(a){return V("rename_failed",E(a),{sessionPath:i.path,name:g})}let l=j.getSnapshot().activeSessionFile;if(l&&(0,h.resolve)(l)===(0,h.resolve)(i.path)){let a=await ac({type:"set_session_name",name:g},b);return null===a?V("rename_failed","Active session rename did not return a response",{sessionPath:i.path,name:g,isActiveSession:!0,mutation:"rpc"}):a.success?{success:!0,action:"rename",scope:k.PO,sessionPath:i.path,name:g,isActiveSession:!0,mutation:"rpc"}:V("onboarding_locked"===a.code?"onboarding_locked":"rename_failed",a.error,{sessionPath:i.path,name:g,isActiveSession:!0,mutation:"rpc"})}try{return await A(f,i.path,g),j.publishLiveStateInvalidation({reason:"set_session_name",source:"session_manage",domains:["resumable_sessions"]}),{success:!0,action:"rename",scope:k.PO,sessionPath:i.path,name:g,isActiveSession:!1,mutation:"session_file"}}catch(a){return V("rename_failed",E(a),{sessionPath:i.path,name:g,isActiveSession:!1,mutation:"session_file"})}}async function Y(a,b){if(a.getOnboardingState)return await a.getOnboardingState();if(a.getOnboardingNeeded){var c;return{status:(c=await a.getOnboardingNeeded(l.sI,b))?"blocked":"ready",locked:c,lockReason:c?"required_setup":null,required:{blocking:!0,skippable:!1,satisfied:!c,satisfiedBy:c?null:{providerId:"legacy",source:"runtime"},providers:[]},optional:{blocking:!1,skippable:!0,sections:[]},lastValidation:null,activeFlow:null,bridgeAuthRefresh:{phase:"idle",strategy:null,startedAt:null,completedAt:null,error:null}}}return await (0,m.r$)()}async function Z(a){let b=F(),c=b.env??process.env;return await Y(b,c)}async function $(a=["auto","workspace","resumable_sessions"],b){let c=F(),d=L(c.env??process.env,b),e=b?P(b):T();try{await e.ensureStarted()}catch{}let f=e.getSnapshot(),g=[...new Set(a)],h={bridge:f};if(g.includes("workspace")&&(h.workspace=await H(d.projectCwd,async()=>await (c.indexWorkspace??K)(d.projectCwd))),g.includes("auto")){let a=c.getAutoDashboardData??(()=>o());h.auto=await Promise.resolve(a())}return g.includes("resumable_sessions")&&(h.resumableSessions=(await (c.listSessions??(async a=>J(a)))(d.projectSessionsDir)).map(a=>U(a,f.activeSessionFile))),h}async function _(a){let b=F(),c=b.env??process.env,d=L(c,a),e=b.getAutoDashboardData??(()=>o()),f=b.listSessions??(async a=>J(a)),g=v(d.projectCwd),h=await Y(b,c);if(h.locked&&"packaged-standalone"===c.GSD_WEB_HOST_KIND)return{project:{cwd:d.projectCwd,sessionsDir:d.projectSessionsDir,packageRoot:d.packageRoot},workspace:{milestones:[],active:{phase:"pre-planning"},scopes:[{scope:"project",label:"project",kind:"project"}],validationIssues:[]},auto:o(),onboarding:h,onboardingNeeded:!0,resumableSessions:[],bridge:{phase:"idle",projectCwd:d.projectCwd,projectSessionsDir:d.projectSessionsDir,packageRoot:d.packageRoot,startedAt:null,updatedAt:new Date().toISOString(),connectionCount:0,lastCommandType:null,activeSessionId:null,activeSessionFile:null,sessionState:null,lastError:null},projectDetection:g};let i=a?P(a):T(),j=H(d.projectCwd,async()=>await (b.indexWorkspace??K)(d.projectCwd)),k=Promise.resolve(e()),l=f(d.projectSessionsDir);try{await i.ensureStarted()}catch{}let m=i.getSnapshot(),[n,p,q]=await Promise.all([j,k,l]);return{project:{cwd:d.projectCwd,sessionsDir:d.projectSessionsDir,packageRoot:d.packageRoot},workspace:n,auto:p,onboarding:h,onboardingNeeded:h.locked,resumableSessions:q.map(a=>U(a,m.activeSessionFile)),bridge:m,projectDetection:g}}function aa(a,b){return{type:"response",command:a,success:!1,error:E(b)}}async function ab(a){let b=a?P(a):T();await b.refreshAuth()}async function ac(a,b){if(!(!M(a)&&r.has(a.type))){let b=await (0,m.r$)();if(b.locked){let c;return c=b.lockReason??"required_setup",{type:"response",command:a.type,success:!1,error:"bridge_refresh_failed"===c?"Workspace is locked because bridge auth refresh failed after setup":"bridge_refresh_pending"===c?"Workspace is still locked while bridge auth refresh completes":"Workspace is locked until required onboarding completes",code:"onboarding_locked",details:{reason:c,onboarding:{locked:b.locked,lockReason:b.lockReason,required:b.required,lastValidation:b.lastValidation,bridgeAuthRefresh:b.bridgeAuthRefresh}}}}}let c=b?P(b):T();return await c.sendInput(a)}(0,m.Eu)(async()=>{await ab()})},7849:(a,b,c)=>{"use strict";c.d(b,{Ic:()=>j,_y:()=>f,sI:()=>i,vo:()=>h});var d=c(1820),e=c(3873);let f=process.env.GSD_HOME||(0,e.join)((0,d.homedir)(),".gsd"),g=(0,e.join)(f,"agent"),h=(0,e.join)(f,"sessions"),i=(0,e.join)(g,"auth.json");(0,e.join)(f,"web-server.pid");let j=(0,e.join)(f,"web-preferences.json")},8335:()=>{},9225:(a,b,c)=>{"use strict";a.exports=c(4870)}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
globalThis.__BUILD_MANIFEST={polyfillFiles:["static/chunks/polyfills-42372ed130431b0a.js"],devFiles:[],lowPriorityFiles:["static/
|
|
1
|
+
globalThis.__BUILD_MANIFEST={polyfillFiles:["static/chunks/polyfills-42372ed130431b0a.js"],devFiles:[],lowPriorityFiles:["static/prkokVQFxWtUVIku57_0z/_buildManifest.js","static/prkokVQFxWtUVIku57_0z/_ssgManifest.js"],rootMainFiles:["static/chunks/webpack-b868033a5834586d.js","static/chunks/4bd1b696-e356ca5ba0218e27.js","static/chunks/3794-42fdce068d44fa4f.js","static/chunks/main-app-d3d4c336195465f9.js"],rootMainFilesTree:{},pages:{"/_app":[]}};
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
"wasm": [],
|
|
19
19
|
"assets": [],
|
|
20
20
|
"env": {
|
|
21
|
-
"__NEXT_BUILD_ID": "
|
|
22
|
-
"NEXT_SERVER_ACTIONS_ENCRYPTION_KEY": "
|
|
23
|
-
"__NEXT_PREVIEW_MODE_ID": "
|
|
24
|
-
"__NEXT_PREVIEW_MODE_SIGNING_KEY": "
|
|
25
|
-
"__NEXT_PREVIEW_MODE_ENCRYPTION_KEY": "
|
|
21
|
+
"__NEXT_BUILD_ID": "prkokVQFxWtUVIku57_0z",
|
|
22
|
+
"NEXT_SERVER_ACTIONS_ENCRYPTION_KEY": "JOyW/NkGGBZbrWHv3URRDUgsbPKoFv/QsyVwX2l6Wi8=",
|
|
23
|
+
"__NEXT_PREVIEW_MODE_ID": "a5b55541bc3e0fa2f07c4087828bfdb9",
|
|
24
|
+
"__NEXT_PREVIEW_MODE_SIGNING_KEY": "1d263a5202d738e962bd891f42fec4583353ecdb77162ca3b09f7da49aa38e9c",
|
|
25
|
+
"__NEXT_PREVIEW_MODE_ENCRYPTION_KEY": "82afb9b7e120d168495c89adfe9fcfe9feb930812ef95d0fe02a2f0d3c075948"
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
},
|