@henlii/pidance 0.2.26 → 0.2.27

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.
Files changed (53) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +12 -12
  3. package/.next/build-manifest.json +2 -2
  4. package/.next/prerender-manifest.json +3 -3
  5. package/.next/required-server-files.json +1 -1
  6. package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  7. package/.next/server/app/_global-error.html +1 -1
  8. package/.next/server/app/_global-error.rsc +1 -1
  9. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  11. package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  12. package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  13. package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  14. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  15. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  16. package/.next/server/app/_not-found.html +1 -1
  17. package/.next/server/app/_not-found.rsc +3 -3
  18. package/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
  19. package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  20. package/.next/server/app/_not-found.segments/_index.segment.rsc +3 -3
  21. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  22. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  23. package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  24. package/.next/server/app/api/about/route.js +1 -1
  25. package/.next/server/app/index.html +1 -1
  26. package/.next/server/app/index.rsc +5 -5
  27. package/.next/server/app/index.segments/__PAGE__.segment.rsc +3 -3
  28. package/.next/server/app/index.segments/_full.segment.rsc +5 -5
  29. package/.next/server/app/index.segments/_head.segment.rsc +1 -1
  30. package/.next/server/app/index.segments/_index.segment.rsc +3 -3
  31. package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  32. package/.next/server/app/page.js +15 -15
  33. package/.next/server/app/page_client-reference-manifest.js +1 -1
  34. package/.next/server/app-paths-manifest.json +12 -12
  35. package/.next/server/chunks/188.js +1 -1
  36. package/.next/server/chunks/5274.js +1 -1
  37. package/.next/server/chunks/5304.js +2 -2
  38. package/.next/server/chunks/7594.js +3 -3
  39. package/.next/server/middleware-build-manifest.js +1 -1
  40. package/.next/server/pages/404.html +1 -1
  41. package/.next/server/pages/500.html +1 -1
  42. package/.next/server/server-reference-manifest.json +1 -1
  43. package/.next/static/chunks/9780-9ff103301d973613.js +1 -0
  44. package/.next/static/chunks/app/page-84ae8f24274d9a34.js +25 -0
  45. package/.next/static/css/0cf9ed5690d76263.css +1 -0
  46. package/README.en.md +1 -1
  47. package/README.md +1 -1
  48. package/package.json +5 -3
  49. package/.next/static/chunks/9780-a21716489f365d66.js +0 -1
  50. package/.next/static/chunks/app/page-3f3ed6eed59df96a.js +0 -25
  51. package/.next/static/css/782855e5398f955b.css +0 -1
  52. /package/.next/static/{tj04wII7Oz8Z4qdCTh4TE → P-GwTOtxwpdnWwlj9T66x}/_buildManifest.js +0 -0
  53. /package/.next/static/{tj04wII7Oz8Z4qdCTh4TE → P-GwTOtxwpdnWwlj9T66x}/_ssgManifest.js +0 -0
@@ -1,4 +1,4 @@
1
- "use strict";exports.id=7594,exports.ids=[7594],exports.modules={1060:(a,b,c)=>{c.d(b,{Ac:()=>n,GO:()=>i,X:()=>k,_4:()=>d,cV:()=>j,k2:()=>l,oC:()=>m});let d=262144,e={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",bmp:"image/bmp",ico:"image/x-icon",avif:"image/avif"},f={mp3:"audio/mpeg",wav:"audio/wav",ogg:"audio/ogg",oga:"audio/ogg",opus:"audio/ogg",m4a:"audio/mp4",aac:"audio/aac",flac:"audio/flac",weba:"audio/webm"},g={mp4:"video/mp4",m4v:"video/mp4",webm:"video/webm",ogv:"video/ogg",mov:"video/quicktime",mkv:"video/x-matroska",avi:"video/x-msvideo"},h={pdf:"application/pdf",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"};function i(a){return(a.replace(/\\/g,"/").split("/").pop()??"").toLowerCase().split(".").pop()??""}function j(a){return e[i(a)]??null}function k(a){return f[i(a)]??null}function l(a){return g[i(a)]??null}function m(a){return h[i(a)]??null}function n(a){let b=i(a);return"pdf"===b||"docx"===b?b:null}},2416:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{j1:()=>w});var e=c(75430),f=c(60396),g=c(68524),h=c(89953),i=c(5815),j=c(85664),k=c(65107),l=c(95237),m=c(38195),n=c(62693),o=c(31524),p=c(52960),q=c(13737),r=c(60185),s=c(28121),t=c(87538),u=a([e,l,r,s]);function v(a){return"string"==typeof a&&a?a:void 0}[e,l,r,s]=u.then?(await u)():u;class x{static{this.PARTIAL_RENDER_MIN_INTERVAL_MS=100}constructor(a){this.options=a,this.listeners=[],this.runtime=null,this.unsubscribe=null,this.extensionUi=null,this.idleTimer=null,this.startupHoldTimer=null,this.startupHold=!0,this.activeCommandCount=0,this._scheduledRecheck=!1,this.onDestroyCallback=null,this._alive=!0,this.promptRunning=!1,this.lastStopReason=null,this.followUpQueue=[],this.followUpQueueHydrated=!1,this.flushingFollowUp=!1,this.followUpFlushBatch=[],this.followUpFlushCursor=0,this.followUpFlushConfirmed=!1,this.followUpFlushAsOne=!1,this.followUpFlushOriginal=[],this.bashRunning=!1,this.bashCommand=null,this.localQueue={steering:[],followUp:[]},this.promptReceipts=new Map,this.promptInFlight=new Map,this.pendingBinaryBatches=[],this.destroyPromise=null,this.hasQueueSnapshot=!1,this.renderBridgeTheme=(0,t.Lm)(),this.toolRenderStates=new Map,this.realSessionId=a.sessionId,this.realSessionFile=a.sessionFile,this.idleTimeoutMs=a.idleTimeoutMs??3e4,this.agentDir=a.agentDir??(0,f.$M)(),this.activeToolNames=a.toolNames}get sessionId(){return this.realSessionId}get sessionFile(){return this.realSessionFile}listPendingExtensionRequests(){return Array.from(this.extensionUi?.pendingSnapshot.values()??[])}get inner(){let a=this.runtime?.session;if(a)return{sessionManager:a.sessionManager}}isAlive(){return this._alive&&null!==this.runtime}isRunning(){if(!this._alive||!this.runtime)return!1;let a=this.runtime.session;return this.promptRunning||this.bashRunning||a.isStreaming||a.isCompacting}onDestroy(a){this.onDestroyCallback=a}onEvent(a){let b=0===this.listeners.length;return this.listeners.push(a),b&&this.resetIdleTimer(),()=>{let b=this.listeners.length>0;this.listeners=this.listeners.filter(b=>b!==a),b&&0===this.listeners.length&&this.resetIdleTimer()}}beginExtensionBinding(){}async waitForExtensionsBound(){}emit(a){for(let b of this.listeners)try{b(a)}catch(a){console.error("[pidance] sdk host listener error:",a)}}notifyRunning(){this.options.onRunningChange?.()}resetIdleTimer(){if(this.idleTimer&&clearTimeout(this.idleTimer),this.idleTimer=null,!this._alive||!this.runtime||this.startupHold||this.isRunning()||this.flushingFollowUp||this.listeners.length>0)return;if(this.followUpQueue.length>0&&!this.isFollowUpHeld())return void this.scheduleFollowUpFlush();let a=this.idleTimeoutMs;this.idleTimer=setTimeout(()=>{if((this.idleTimer=null,!this.isRunning()&&!this.flushingFollowUp)&&!(this.listeners.length>0)){if(this.followUpQueue.length>0&&!this.isFollowUpHeld())return void this.scheduleFollowUpFlush();this.destroyAsync()}},a)}releaseStartupHold(){this.startupHold&&(this.startupHold=!1,this.startupHoldTimer&&clearTimeout(this.startupHoldTimer),this.startupHoldTimer=null)}isSettled(){return!!this.runtime&&!!this._alive&&!this.isRunning()}isFollowUpHeld(){let a=(0,g.rV)(this.agentDir);return!0===(0,g.ql)(a,`sessionQueueHold.${this.realSessionId}`)}setFollowUpHeld(a){try{(0,g.xP)(`sessionQueueHold.${this.realSessionId}`,!!a||null,this.agentDir)}catch(a){console.error("[pidance] failed to persist follow-up hold:",a)}}hydrateFollowUpQueue(){if(this.followUpQueueHydrated)return;this.followUpQueueHydrated=!0;let a=(0,g.rV)(this.agentDir),b=(0,g.ql)(a,`sessionQueue.${this.realSessionId}`);this.followUpQueue=Array.isArray(b)?b.filter(a=>"string"==typeof a&&a.trim().length>0):[]}persistFollowUpQueue(){try{(0,g.xP)(`sessionQueue.${this.realSessionId}`,this.followUpQueue,this.agentDir)}catch(a){console.error("[pidance] failed to persist follow-up queue:",a)}}scheduleFollowUpFlush(){!this._alive||!this.runtime||this.flushingFollowUp||0===this.followUpQueue.length||this.isFollowUpHeld()||this.isSettled()&&(this.flushingFollowUp=!0,this.followUpFlushAsOne=!0===(0,g.rV)(this.agentDir).queueFlushAsOne,this.followUpFlushOriginal=[...this.followUpQueue],this.followUpFlushBatch=this.followUpFlushAsOne?[this.followUpFlushOriginal.join("\n\n")]:[...this.followUpFlushOriginal],this.followUpFlushCursor=0,this.followUpFlushConfirmed=!1,this.sendNextFollowUp())}async sendNextFollowUp(){if(!this.flushingFollowUp)return;if(this.isFollowUpHeld())return void this.abortFollowUpFlush();let a=this.followUpFlushBatch[this.followUpFlushCursor];if(void 0===a)return void this.finishFollowUpFlush();if(!this.isSettled())return void setTimeout(()=>{this.flushingFollowUp&&this.followUpFlushCursor<this.followUpFlushBatch.length&&this.sendNextFollowUp()},80);this.followUpFlushConfirmed=!1;try{await this.send({type:"prompt",message:a})}catch(b){let a=b instanceof Error?b.message:String(b);this.emit({type:"follow_up_flush_error",errorMessage:a}),this.abortFollowUpFlush()}}confirmFollowUpFlush(){if(!this.flushingFollowUp||this.followUpFlushConfirmed)return;let a=this.followUpFlushBatch[this.followUpFlushCursor];if(void 0===a)return;if(this.followUpFlushConfirmed=!0,this.followUpFlushAsOne){let a=new Set(this.followUpFlushOriginal);this.followUpQueue=this.followUpQueue.filter(b=>!a.has(b))}else{let b=this.followUpQueue.indexOf(a);b>=0&&this.followUpQueue.splice(b,1)}let b=[...this.followUpQueue];(this.persistFollowUpQueue(),this.emit({type:"follow_up_flushed",sessionId:this.realSessionId,item:a,remaining:b}),this.followUpFlushAsOne)?this.finishFollowUpFlush():(this.followUpFlushCursor+=1,this.followUpFlushCursor>=this.followUpFlushBatch.length?this.finishFollowUpFlush():this.sendNextFollowUp())}abortFollowUpFlush(){this.flushingFollowUp&&(this.flushingFollowUp=!1,this.followUpFlushBatch=[],this.followUpFlushCursor=0,this.followUpFlushConfirmed=!1,this.followUpFlushAsOne=!1,this.followUpFlushOriginal=[],this.persistFollowUpQueue(),this.resetIdleTimer())}finishFollowUpFlush(){this.flushingFollowUp=!1,this.followUpFlushBatch=[],this.followUpFlushCursor=0,this.followUpFlushConfirmed=!1,this.followUpFlushAsOne=!1,this.followUpFlushOriginal=[],this.persistFollowUpQueue(),this.resetIdleTimer(),this.followUpQueue.length>0&&!this.isFollowUpHeld()&&this.scheduleFollowUpFlush()}get session(){if(!this.runtime)throw Error("SDK session is not alive");return this.runtime.session}get services(){if(!this.runtime)throw Error("SDK session is not alive");return this.runtime.services}syncIdentityFromSession(){let a=this.session,b=a.sessionId||this.realSessionId,c=a.sessionFile||this.realSessionFile,d=this.realSessionId;this.realSessionId=b,this.realSessionFile=c,c&&this.options.cacheSessionPath?.(b,c),d!==b&&this.options.onSessionRekeyed?.(d,b,this)}async rebindSession(){let a=this.session;this.extensionUi?.dispose(),this.extensionUi=(0,m.t)(a=>{this.trackExtensionSideEffects(a),this.emit(a)}),await a.bindExtensions({uiContext:this.extensionUi.uiContext,mode:"rpc",commandContextActions:{waitForIdle:()=>a.waitForIdle(),newSession:async a=>{let b=await this.runtime.newSession(a);return b.cancelled||await this.rebindSession(),b},fork:async(a,b)=>{let c=await this.runtime.fork(a,b);return c.cancelled||await this.rebindSession(),{cancelled:c.cancelled}},navigateTree:async(b,c)=>({cancelled:(await a.navigateTree(b,{summarize:c?.summarize,customInstructions:c?.customInstructions,replaceInstructions:c?.replaceInstructions,label:c?.label})).cancelled}),switchSession:async(a,b)=>{let c=await this.runtime.switchSession(a,b);return c.cancelled||await this.rebindSession(),c},reload:async()=>{await a.reload()}},onError:a=>{this.setFollowUpHeld(!0),this.emit({type:"extension_error",extensionPath:a.extensionPath,event:a.event,error:a.error})}}),this.unsubscribe?.(),this.unsubscribe=a.subscribe(a=>{this.resetIdleTimer(),this.handleSessionEvent(a)}),this.syncIdentityFromSession()}trackExtensionSideEffects(a){if("extension_ui_request"!==a.type)return;let b=v(a.method);if("setStatus"===b){let b=v(a.statusKey)??v(a.key)??"default",c=v(a.statusText)??v(a.text)??"";c?this.extensionUi?.statuses.set(b,c):this.extensionUi?.statuses.delete(b)}if("setWidget"===b){let b=v(a.widgetKey)??v(a.key)??"default",c=a.widgetLines??a.content;null==c?this.extensionUi?.widgets.delete(b):this.extensionUi?.widgets.set(b,{lines:c,placement:a.widgetPlacement})}this.notifyRunning()}maybeAutoNameSession(){try{let a=this.session?.sessionManager;if(!a||a.getSessionName())return;let b=(a.buildSessionContext().messages??[]).find(a=>"user"===a.role),c=function(a){let b="";"string"==typeof a?b=a:Array.isArray(a)&&(b=a.filter(a=>"object"==typeof a&&null!==a&&"text"===a.type&&"string"==typeof a.text).map(a=>a.text).join("\n"));let c=b.replace(/\s+/g," ").trim();if(c)return c.length>60?`${c.slice(0,60)}…`:c}(b?.content);c&&a.appendSessionInfo(c)}catch{}}readStopReasonFromAgentEnd(a){let b=a.messages;if(!Array.isArray(b))return null;for(let a=b.length-1;a>=0;a--){let c=b[a],d=c?.message?.stopReason??c?.stopReason;if("string"==typeof d){if("aborted"===d)return"aborted";if("error"===d||"prompt_error"===d)return"error";return"completed"}}return null}removePendingBinaryBatch(a){this.pendingBinaryBatches=this.pendingBinaryBatches.filter(b=>b.submissionId!==a)}persistPendingBinaryBlocks(a){if(0!==a.length)try{let b=this.session.sessionManager;(0,l.kb)(b);let c=b.getEntries(),d=[...c].reverse().find(a=>"message"===a.type&&a.message?.role==="user"&&"string"==typeof a.id)?.id||b.getLeafId()||void 0;for(let c of a){let a=d?{...c,messageEntryId:d}:c,e=b.appendCustomEntry(q.uG,a);this.emit({type:"message_end",entryId:e,message:(0,q.FH)(a,Date.now())})}(0,l.kb)(b),this.options.onSessionListInvalidate?.()}catch(a){console.error("[pidance] persist binary message failed:",a)}}handleSessionEvent(a){switch(a.type){case"agent_start":this.promptRunning=!0,(0,i.NK)(this.realSessionId,Date.now()),this.notifyRunning();break;case"agent_end":this.promptRunning=!1,this.lastStopReason=this.readStopReasonFromAgentEnd(a)??this.lastStopReason??"completed",("aborted"===this.lastStopReason||"error"===this.lastStopReason)&&this.setFollowUpHeld(!0),(0,i.PI)(this.realSessionId),this.options.onSessionListInvalidate?.(),this.realSessionFile&&(0,k.$9)(this.realSessionFile),this.maybeAutoNameSession(),this.notifyRunning(),this.emit({type:"prompt_done"});break;case"agent_settled":this.promptRunning=!1,this.notifyRunning(),"completed"===this.lastStopReason?this.flushingFollowUp?this.followUpFlushConfirmed?this.sendNextFollowUp():this.confirmFollowUpFlush():this.scheduleFollowUpFlush():this.flushingFollowUp&&("aborted"===this.lastStopReason||"error"===this.lastStopReason)&&this.abortFollowUpFlush();let b="agent_settled"===a.type&&!this.flushingFollowUp&&(0===this.followUpQueue.length||this.isFollowUpHeld());this.resetIdleTimer(),b&&this.destroyAsync();break;case"compaction_start":case"auto_compaction_start":this.notifyRunning();break;case"compaction_end":case"auto_compaction_end":this.notifyRunning(),!0!==a.aborted&&!a.errorMessage&&this.isSettled()&&this.scheduleFollowUpFlush(),this.resetIdleTimer();break;case"message_end":{let b=a.message;if(b?.role==="user"){this.confirmFollowUpFlush();let a=this.pendingBinaryBatches.shift();setImmediate(()=>{try{(0,l.kb)(this.session.sessionManager),this.syncIdentityFromSession(),this.persistPendingBinaryBlocks(a?.blocks??[]),this.options.onSessionListInvalidate?.()}catch(a){console.error("[pidance] materialize after user message failed:",a)}})}break}case"queue_update":{let b=Array.isArray(a.steering)?a.steering.filter(a=>"string"==typeof a):[],c=Array.isArray(a.followUp)?a.followUp.filter(a=>"string"==typeof a):[];this.localQueue={steering:b,followUp:c},this.hasQueueSnapshot=!0}}let c=a;if("agent_end"===a.type)try{let b=this.session.getSessionStats().contextUsage;b&&"number"==typeof b.contextWindow&&b.contextWindow>0&&(c={...a,contextUsage:{contextWindow:b.contextWindow,percent:"number"==typeof b.percent?b.percent:null,tokens:"number"==typeof b.tokens?b.tokens:null}})}catch{}this.emit(this.withRenderedToolLines(c))}withRenderedToolLines(a){try{if(!this.renderBridgeTheme)return a;switch(a.type){case"tool_execution_update":{if(!this.shouldRenderPartialUpdate(a.toolCallId))return a;let b=this.getToolRenderDefinition(a.toolName);if(!b)return a;let c=this.buildToolRenderContext(a.toolCallId,a.args??a.input,{isPartial:!0,expanded:!0,isError:!0===a.isError,resultSlot:!0});if(!c)return a;let d=(0,t.t_)(b,a.partialResult,{expanded:!0,isPartial:!0},c,b=>this.updateToolRenderLastComponent(a.toolCallId,!0,b));return d?{...a,renderedLines:d}:a}case"tool_call":{let b=this.getToolRenderDefinition(a.toolName);if(!b)return a;let c=this.buildToolRenderContext(a.toolCallId,a.input,{isPartial:!1,expanded:!0,isError:!1,resultSlot:!1});if(!c)return a;let d=(0,t.GD)(b,a.input,c,b=>this.updateToolRenderLastComponent(a.toolCallId,!1,b));return d?{...a,renderedCallLines:d}:a}case"tool_result":{let b=this.getToolRenderDefinition(a.toolName);if(!b)return a;let c=this.buildToolRenderContext(a.toolCallId,a.args??a.input,{isPartial:!1,expanded:!0,isError:!0===a.isError,resultSlot:!0});if(!c)return a;let d=(0,t.t_)(b,{content:a.content,details:a.details,isError:!0===a.isError,...void 0!==a.usage?{usage:a.usage}:{}},{expanded:!0,isPartial:!1},c,b=>this.updateToolRenderLastComponent(a.toolCallId,!0,b));return d?{...a,renderedResultLines:d}:a}case"message_start":case"message_end":{let b=a.message;if(b?.role!=="custom"||"string"!=typeof b.customType||""===b.customType)return a;let c=this.session.extensionRunner,d="function"==typeof c?.getMessageRenderer?c.getMessageRenderer(b.customType):void 0,e=(0,t.Mf)(d,a.message,this.renderBridgeTheme);return e?{...a,renderedLines:e}:a}default:return a}}catch{return a}}getToolRenderDefinition(a){if("string"==typeof a&&""!==a)try{return this.session.getToolDefinition(a)}catch{return}}buildToolRenderContext(a,b,c){let d=this.getOrCreateToolRenderState(a);return d?{args:b,toolCallId:a,invalidate:()=>{},lastComponent:c.resultSlot?d.lastResultComponent:d.lastCallComponent,state:d.state,cwd:this.realCwd,executionStarted:!0,argsComplete:!0,isPartial:c.isPartial,expanded:c.expanded,showImages:!1,isError:c.isError}:null}getOrCreateToolRenderState(a){if("string"!=typeof a||""===a)return null;let b=this.toolRenderStates.get(a);return b||(b={state:{},lastCallComponent:void 0,lastResultComponent:void 0,lastPartialRenderAt:void 0},this.toolRenderStates.set(a,b)),b}updateToolRenderLastComponent(a,b,c){if("string"!=typeof a||""===a)return;let d=this.toolRenderStates.get(a);d&&(b?d.lastResultComponent=c:d.lastCallComponent=c)}shouldRenderPartialUpdate(a){if("string"!=typeof a||""===a)return!0;let b=Date.now(),c=this.getOrCreateToolRenderState(a);return!c||(void 0===c.lastPartialRenderAt||!(b-c.lastPartialRenderAt<x.PARTIAL_RENDER_MIN_INTERVAL_MS))&&(c.lastPartialRenderAt=b,!0)}get realCwd(){try{return this.session.sessionManager.getHeader()?.cwd||this.options.cwd}catch{return this.options.cwd}}async start(){try{var a,b;let c=(a=this.realSessionFile,b=this.options.cwd,a?(0,l.G1)(a):(0,l.Qu)(b)),d=c.getCwd()||this.options.cwd,f=this.agentDir,g=this.activeToolNames,h=async({cwd:a,agentDir:b,sessionManager:c,sessionStartEvent:d})=>{let f=(0,s._D)({cwd:a,agentDir:b,appendBinary:a=>this.appendBinary(a,c)}),h={name:s.Jv,label:"Send file to user",description:"Publish an agent-created project file as a user-visible attachment with preview/download support.",promptSnippet:"deliver a generated file to the user as a downloadable attachment",promptGuidelines:["When the user needs a generated file, call send_file_to_user; do not only print a local path or paste Base64.","Only report a file as delivered after send_file_to_user returns successfully."],parameters:s.Tv,async execute(a,b,c){let d=await f(b,c);return{content:[{type:"text",text:`Delivered ${d.name} to the user (entry ${d.entryId}).`}],details:d}}},i=await (0,e.createAgentSessionServices)({cwd:a,agentDir:b,resourceLoaderOptions:{appendSystemPromptOverride:s.n3,extensionFactories:[a=>a.registerTool(h)]}});for(let a of i.modelRuntime.getModels())(0,o.yu)(a);return{...await (0,e.createAgentSessionFromServices)({services:i,sessionManager:c,sessionStartEvent:d,tools:g&&g.length>0?g:void 0,noTools:g&&0===g.length?"all":void 0}),services:i,diagnostics:i.diagnostics}};this.runtime=await (0,e.createAgentSessionRuntime)(h,{cwd:d,agentDir:f,sessionManager:c}),this.runtime.setRebindSession(async()=>{await this.rebindSession()}),this.runtime.setBeforeSessionInvalidate(()=>{this.extensionUi?.dispose(),this.unsubscribe?.(),this.unsubscribe=null}),await this.rebindSession(),this.syncIdentityFromSession(),this.hydrateFollowUpQueue(),this.startupHoldTimer=setTimeout(()=>{this.startupHoldTimer=null,this.startupHold=!1,this.resetIdleTimer()},15e3),this.startupHoldTimer.unref?.(),this.resetIdleTimer(),this.followUpQueue.length>0&&!this.isFollowUpHeld()&&this.isSettled()&&this.scheduleFollowUpFlush()}catch(a){throw await this.destroyAsync(),a}}projectState(){let a=this.session,b=a.model,c={stateSources:{rpcGetState:!1,sdkSession:!0,sessionStats:!0,localQueue:!0,localExtensionUi:!0},sessionId:this.realSessionId,sessionFile:this.realSessionFile,sessionName:a.sessionName,isStreaming:a.isStreaming,isCompacting:a.isCompacting,isPromptRunning:this.promptRunning,lastStopReason:this.lastStopReason,isBashRunning:this.bashRunning,pendingBash:this.bashCommand,autoCompactionEnabled:a.autoCompactionEnabled,steeringMode:a.steeringMode,followUpMode:a.followUpMode,thinkingLevel:a.thinkingLevel,systemPrompt:a.systemPrompt??"",model:b?{id:b.id,provider:b.provider,modelId:b.id}:void 0,messageCount:a.messages.length,pendingMessageCount:a.pendingMessageCount,extensionStatuses:Array.from(this.extensionUi?.statuses.entries()??[],([a,b])=>({key:a,text:b})),extensionWidgets:Array.from(this.extensionUi?.widgets.entries()??[],([a,b])=>({key:a,lines:Array.isArray(b?.lines)?b.lines:[],placement:b?.placement==="belowEditor"?"belowEditor":"aboveEditor"})),pendingExtensionRequests:Array.from(this.extensionUi?.pendingSnapshot.values()??[])};c.queuedMessages={steering:this.hasQueueSnapshot?[...this.localQueue.steering]:[],followUp:[...this.followUpQueue]};try{let b=a.getSessionStats(),d=b?.contextUsage;d&&"number"==typeof d.contextWindow&&d.contextWindow>0&&(c.contextUsage={contextWindow:d.contextWindow,percent:"number"==typeof d.percent?d.percent:null,tokens:"number"==typeof d.tokens?d.tokens:null})}catch{}return c}appendActivity(a){if(!this.runtime)throw Error("Cannot append activity: session not alive");let b=a&&"object"==typeof a&&"type"in a&&"append_activity"===a.type?(0,j.qF)(a):(0,j.l$)(a),c=this.session.sessionManager.appendCustomEntry(j.cP,b);return this.options.onSessionListInvalidate?.(),{entryId:c,activity:b}}appendBinary(a,b){if(!this._alive||!this.runtime||this.destroyPromise)throw Error("Cannot append binary message: session not alive");let c=this.session.sessionManager;if(b&&c!==b)throw Error("Cannot publish file after the session changed");let d=a&&"object"==typeof a&&!Array.isArray(a)?a:{},e="append_binary"===d.type?d.binaryBlock:a,f=(0,r.Nu)(e?[e]:void 0,this.agentDir)[0];if(!f)throw Error("binaryBlock is required");let g=c.appendCustomEntry(q.uG,f);try{this.options.onSessionListInvalidate?.()}catch(a){console.error("[pidance] binary message list notification failed:",a)}try{this.emit({type:"message_end",entryId:g,message:(0,q.FH)(f,Date.now())})}catch(a){console.error("[pidance] binary message event notification failed:",a)}return{entryId:g,binary:f}}async send(a){if(!this.runtime)throw Error("SDK session is not alive");let b=a.type;"get_state"!==b&&"ensure_session"!==b&&this.releaseStartupHold(),this.activeCommandCount+=1,this.resetIdleTimer();let c=this.session;try{switch(b){case"prompt":{let b=(0,p.JT)(a),d=this.promptReceipts.get(b.submissionId);if(d)return d;let e=b.submissionId,f=this.promptInFlight.get(e);if(f)return f;let g=(0,r.Nu)(b.binaryBlocks,this.agentDir);if(this.bashRunning)throw Error("Cannot send a prompt while a shell command is running");if(c.isCompacting){if(b.images?.length||g.length>0)throw Error("Media attachments cannot be queued while compaction is in progress");let a={submissionId:b.submissionId,sessionId:this.realSessionId,status:"accepted"};return this.followUpQueue=[...this.followUpQueue,b.message],this.promptReceipts.set(b.submissionId,a),this.persistFollowUpQueue(),this.options.onSessionListInvalidate?.(),a}if(!(0,h.kP)(this.realSessionId))throw Error(h.GT);this.promptRunning=!0,this.lastStopReason=null,(0,i.NK)(this.realSessionId,Date.now()),this.notifyRunning();let j=(async()=>{try{await new Promise((d,f)=>{let h=!1,j=()=>{c.isStreaming||c.isCompacting||this.bashRunning||this.promptRunning&&(this.promptRunning=!1,"aborted"!==this.lastStopReason&&"error"!==this.lastStopReason&&(this.lastStopReason="completed"),(0,i.PI)(this.realSessionId),this.notifyRunning(),this.emit({type:"prompt_done"}),this.resetIdleTimer())};c.prompt(b.message,{images:b.images??a.images,streamingBehavior:a.streamingBehavior,source:"rpc",preflightResult:a=>{a&&(h=!0,g.length>0&&this.pendingBinaryBatches.push({submissionId:e,blocks:g}),this.syncIdentityFromSession(),this.setFollowUpHeld(!1),this.options.onSessionListInvalidate?.(),d())}}).then(()=>{if(!h){h=!0;try{(0,l.kb)(c.sessionManager)}catch(a){console.error("[pidance] materialize after prompt failed:",a)}this.syncIdentityFromSession(),this.options.onSessionListInvalidate?.(),d()}j()}).catch(a=>{"aborted"!==this.lastStopReason&&(this.lastStopReason="error"),this.setFollowUpHeld(!0),j(),h||(h=!0,f(a))})});let d={submissionId:b.submissionId,sessionId:this.realSessionId,status:"accepted"};return this.promptReceipts.set(e,d),d}catch(d){this.removePendingBinaryBatch(e),this.promptRunning=!1,this.lastStopReason="aborted"===this.lastStopReason?"aborted":"error",this.setFollowUpHeld(!0),(0,i.PI)(this.realSessionId),this.notifyRunning();let a=d instanceof Error?d.message:String(d);this.emit({type:"prompt_error",errorMessage:a}),this.emit({type:"prompt_done"});let c={submissionId:b.submissionId,sessionId:this.realSessionId,status:"rejected"};throw this.promptReceipts.set(e,c),d}finally{this.promptInFlight.delete(e)}})();return this.promptInFlight.set(e,j),j}case"abort":return this.lastStopReason="aborted",this.setFollowUpHeld(!0),this.promptRunning=!1,this.notifyRunning(),await c.abort(),this.notifyRunning(),null;case"get_state":return this.projectState();case"set_model":{let b=String(a.provider??""),d=String(a.modelId??""),e=(0,n.E)(c.modelRuntime,b,d);if(!e)try{e=(await c.modelRuntime.getAvailable()).find(a=>a.provider===b&&a.id===d)}catch{e=void 0}if(!e)throw Error(`Model not found: ${b}/${d}`);return await c.setModel((0,o.eU)(e)),this.options.onSessionListInvalidate?.(),e}case"set_thinking_level":return c.model&&(0,o.yu)(c.model),c.setThinkingLevel(a.level),this.options.onSessionListInvalidate?.(),null;case"compact":{let b=await c.compact("string"==typeof a.customInstructions?a.customInstructions:void 0);return this.options.onSessionListInvalidate?.(),this.notifyRunning(),this.resetIdleTimer(),b}case"steer":{let b=String(a.message??"");if(!this.isRunning()&&!this.flushingFollowUp)return this.send({type:"prompt",message:b,images:a.images,streamingBehavior:"steer"});return await c.steer(b,a.images),null}case"set_follow_up_queue":{let b=Array.isArray(a.items)?a.items.filter(a=>"string"==typeof a&&a.trim().length>0):[];return this.flushingFollowUp&&this.abortFollowUpFlush(),this.followUpQueue=b,this.persistFollowUpQueue(),this.isSettled()&&b.length>0&&this.scheduleFollowUpFlush(),this.resetIdleTimer(),{ok:!0,queued:this.followUpQueue.length}}case"follow_up":return await c.followUp(String(a.message??""),a.images),null;case"set_session_name":{let b=String(a.name??"").trim();if(!b)throw Error("Session name cannot be empty");return c.setSessionName(b),this.options.onSessionListInvalidate?.(),null}case"set_auto_compaction":return c.setAutoCompactionEnabled(!!a.enabled),null;case"set_auto_retry":return c.setAutoRetryEnabled(!!a.enabled),null;case"clear_queue":return c.clearQueue();case"get_tools":{let a=c.getAllTools(),b=new Set(c.getActiveToolNames());return{source:"sdk",tools:a.map(a=>({name:a.name,description:a.description??"",active:b.has(a.name)}))}}case"set_tools":{let b=Array.isArray(a.tools)?a.tools.filter(a=>"string"==typeof a):[];return c.setActiveToolsByName(b),this.activeToolNames=b,null}case"get_commands":{let a=[];for(let b of c.extensionRunner.getRegisteredCommands())a.push({name:b.invocationName,description:b.description,source:"extension",sourceInfo:b.sourceInfo});for(let b of c.promptTemplates)a.push({name:b.name,description:b.description,source:"prompt_template"});try{let b=c.resourceLoader?.getSkills?.();for(let c of b?.skills??[])a.push({name:`skill:${c.name}`,description:c.description,source:"skill",sourceInfo:c.sourceInfo})}catch{}return{commands:a}}case"get_session_stats":return c.getSessionStats();case"bash":if(c.isStreaming)throw Error("Cannot run bash while agent is streaming");this.bashRunning=!0,this.bashCommand={command:String(a.command??""),excludeFromContext:!!a.excludeFromContext,startedAt:Date.now()},this.notifyRunning();try{return await c.executeBash(String(a.command??""),void 0,{excludeFromContext:!!a.excludeFromContext})}finally{this.bashRunning=!1,this.bashCommand=null,this.notifyRunning(),this.resetIdleTimer()}case"abort_bash":return c.abortBash(),this.bashRunning=!1,this.bashCommand=null,this.notifyRunning(),null;case"abort_compaction":return c.abortCompaction(),null;case"extension_ui_response":{let b=v(a.id);if(!b)throw Error("extension_ui_response requires id");let c={...a};return delete c.type,delete c.id,!this.extensionUi?.respond(b,c),this.notifyRunning(),null}case"extension_ui_input":{let b=v(a.id),c="string"==typeof a.data?a.data:"";return b&&this.extensionUi?.inputCustom(b,c),null}case"append_activity":return this.appendActivity(a);case"append_binary":return this.appendBinary(a);case"fork":{if(this.bashRunning)throw Error("Cannot fork while a shell command is running");let b=String(a.entryId??"");if(!b)throw Error("entryId is required");let c=await this.runtime.fork(b);return c.cancelled||(await this.rebindSession(),this.syncIdentityFromSession(),this.options.onSessionListInvalidate?.()),{cancelled:c.cancelled,newSessionId:c.cancelled?void 0:this.realSessionId,text:c.selectedText}}case"navigate_tree":{if(this.bashRunning)throw Error("Cannot navigate while a shell command is running");let b=v(a.targetId);if(!b)throw Error("targetId is required");let d=await c.navigateTree(b,{summarize:a.summarize,customInstructions:v(a.customInstructions)});if(!d.cancelled&&this.realSessionFile){c.sessionManager.getLeafId();let a=c.sessionManager.getLeafId(),b=c.sessionManager.getEntries(),d=b.at(-1)?.id;a&&d&&a!==d?(0,k.R3)(this.realSessionFile,a):this.realSessionFile&&(0,k.$9)(this.realSessionFile)}return this.options.onSessionListInvalidate?.(),{cancelled:d.cancelled}}case"select_leaf_exact":{let b=v(a.entryId);if(!b)throw Error("entryId is required");if(this.options.navigationActions)return this.options.navigationActions.selectLeafExact(this.sessionId,b);let d=await c.navigateTree(b,{summarize:!1});if(!d.cancelled&&this.realSessionFile){let a=c.sessionManager.getLeafId(),b=c.sessionManager.getEntries().at(-1)?.id;a&&b&&a!==b?(0,k.R3)(this.realSessionFile,a):(0,k.$9)(this.realSessionFile)}return{cancelled:d.cancelled}}case"branch_from_assistant":{let b=v(a.assistantEntryId);if(!b)throw Error("assistantEntryId is required");if(this.options.navigationActions)return this.options.navigationActions.branchFromAssistant(this.sessionId,b);throw Error("branch_from_assistant is unavailable")}case"create_session_from_leaf":{let b=v(a.entryId);if(!b)throw Error("entryId is required");if(this.options.navigationActions)return this.options.navigationActions.createSessionFromLeaf(this.sessionId,b);throw Error("create_session_from_leaf is unavailable")}case"set_branch_label":{let b=v(a.targetId);if(!b)throw Error("targetId is required");let d=void 0===a.label||null===a.label?void 0:String(a.label);return c.sessionManager.appendLabelChange(b,d),this.options.onSessionListInvalidate?.(),null}case"reload":return await c.reload(),await this.rebindSession(),null;case"get_last_assistant_text":return{text:c.getLastAssistantText()};case"ensure_session":return null;default:throw Error(`Unsupported command: ${b}`)}}finally{this.activeCommandCount=Math.max(0,this.activeCommandCount-1),0===this.activeCommandCount&&this.resetIdleTimer()}}destroy(){this.destroyAsync()}async destroyAsync(){if(this.destroyPromise)return this.destroyPromise;if(this._alive||this.runtime){if(this.activeCommandCount>0){if(this._scheduledRecheck)return;this._scheduledRecheck=!0,setTimeout(()=>{this._scheduledRecheck=!1,!this.destroyPromise&&this._alive&&this.destroyAsync()},0);return}return this._alive=!1,this.idleTimer&&clearTimeout(this.idleTimer),this.idleTimer=null,this.startupHoldTimer&&clearTimeout(this.startupHoldTimer),this.startupHoldTimer=null,this.startupHold=!1,this.destroyPromise=(async()=>{this.unsubscribe?.(),this.unsubscribe=null,this.extensionUi?.dispose(),this.extensionUi=null;let a=this.runtime;if(this.runtime=null,a)try{await a.dispose()}catch(a){console.error("[pidance] sdk runtime dispose error:",a)}this.promptRunning=!1,this.bashRunning=!1,this.bashCommand=null,this.flushingFollowUp=!1,this.followUpFlushBatch=[],this.followUpFlushCursor=0,this.followUpFlushConfirmed=!1,this.followUpFlushAsOne=!1,this.followUpFlushOriginal=[],(0,i.PI)(this.realSessionId),this.onDestroyCallback?.(),this.notifyRunning()})(),this.destroyPromise}}}async function w(a){let b=new x(a);return await b.start(),b}d()}catch(a){d(a)}})},5815:(a,b,c)=>{c.d(b,{MG:()=>h,NK:()=>f,PI:()=>g});let d="__piRunningStartedAt";function e(){let a=globalThis;return d in a&&a[d]instanceof Map||(a[d]=new Map),a[d]}function f(a,b){let c=e();c.has(a)||c.set(a,b)}function g(a){e().delete(a)}function h(){return e()}},26773:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{$k:()=>u,A4:()=>m,DU:()=>o,EM:()=>r,Fn:()=>t,HG:()=>q,OF:()=>w});var e=c(40402),f=c(95237);c(68524);var g=c(2416),h=c(5815),i=c(89953),j=a([e,f,g]);function k(){if(!globalThis.__piSessions){globalThis.__piSessions=new Map;let a=()=>{globalThis.__piSessions?.forEach(a=>a.destroy())};process.once("exit",a),process.once("SIGINT",a),process.once("SIGTERM",a)}return globalThis.__piSessions}function l(){return globalThis.__piStartLocks||(globalThis.__piStartLocks=new Map),globalThis.__piStartLocks}function m(a){return k().get(a)}function n(){return[...l().keys()]}async function o(a){let b=l().get(a);if(!b)return null;try{return(await b).realSessionId}catch{return null}}function p(){let a=new Set(n());for(let[b,c]of k())c.isRunning()&&a.add(c.sessionId||b);return[...a]}function q(){return p()}[e,f,g]=j.then?(await j)():j;let y=new Map;function r(a,b=Date.now()){let c={},d=(0,h.MG)(),e=p(),f=new Set(e);for(let a of e){let e=d.get(a)??y.get(a)??b;y.set(a,e),c[a]=e}for(let a of[...y.keys()])f.has(a)||y.delete(a);return c}function s(){return globalThis.__piRunningListeners||(globalThis.__piRunningListeners=new Set),globalThis.__piRunningListeners}function t(a){let b=s();return b.add(a),()=>{b.delete(a)}}function u(){let a=[];for(let[b,c]of k()){let d=c.listPendingExtensionRequests();0!==d.length&&a.push({sessionId:c.sessionId||b,requests:d})}return a}let z="",A=new Set,B=null;function v(){!function a(){let b=new Set(function(){let a=new Set(n());for(let[b,c]of k())c.isAlive()&&a.add(c.sessionId||b);return[...a]}());for(let a of b)(0,i.AZ)(a),A.add(a);for(let a of[...A])b.has(a)||((0,i.Hl)(a),A.delete(a));if(0===b.size){B&&(clearInterval(B),B=null);return}B||(B=setInterval(()=>{a()},8e3),B.unref?.())}();let a=q(),b=u(),c=JSON.stringify({ids:[...a].sort(),pending:b.map(a=>({sessionId:a.sessionId,ids:a.requests.map(a=>a.id??null)}))});if(c!==z)for(let b of(z=c,s()))try{b(a)}catch{}}async function w(a,b,c,d,e){return x(a,b,c,d,e)}async function x(a,b,c,d,f){let h=k(),j=l(),m=h.get(a);if(m?.isAlive())return{session:m,realSessionId:a};let n=j.get(a);if(n)return n;if(!(0,i.kP)(a))throw Error(i.GT);v();let o=(async()=>{try{let j=await (0,g.j1)({sessionId:a,sessionFile:b,cwd:c,toolNames:d,navigationActions:f,onRunningChange:()=>v(),onSessionListInvalidate:()=>(0,e.mD)(),cacheSessionPath:(a,b)=>(0,e.O8)(a,b),onSessionRekeyed:(a,b,c)=>{let d;d=k(),a!==b&&d.delete(a),d.set(b,c),a!==b&&((0,i.kP)(b),(0,i.Hl)(a))}}),l=j.sessionId,m=j.sessionFile;return m&&(0,e.O8)(l,m),l!==a&&(0,i.kP)(l),j.onDestroy(()=>{h.get(l)===j&&h.delete(l),a!==l&&h.get(a)===j&&h.delete(a),(0,i.Hl)(l),a!==l&&(0,i.Hl)(a),v()}),h.set(l,j),j.beginExtensionBinding(),{session:j,realSessionId:l}}catch(b){throw(0,i.Hl)(a),v(),b}})().finally(()=>{j.delete(a),v()});return j.set(a,o),o}d()}catch(a){d(a)}})},28121:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{Jv:()=>r,Tv:()=>t,_D:()=>q,n3:()=>n});var e=c(89477),f=c(42524),g=c(86697),h=c(26238),i=c(69835),j=c(80547),k=c(1060),l=c(60185),m=a([i,j,l]);[i,j,l]=m.then?(await m)():m;let r="send_file_to_user",s="## Pidance file delivery\nWhen the `send_file_to_user` tool is available and you create a file that the user needs to view, download, or play, call it instead of only printing a local path or embedding Base64. The tool publishes a user-visible attachment message: images keep the original for preview and download, audio/video follow the UI playback size policy, and other files get a download card. Only claim that a file was sent after the tool returns success.";function n(a){return a.some(a=>a===s)?a:[...a,s]}let t={type:"object",additionalProperties:!1,properties:{path:{type:"string",description:"Absolute or current-project-relative path of the file to deliver."},name:{type:"string",description:"Optional filename shown to the user; the source basename is used by default."}},required:["path"]};function o(a){if(a?.aborted)throw a.reason instanceof Error?a.reason:Error("file delivery aborted")}async function p(a,b){let c,d;if("string"!=typeof a||!a.trim())throw Error("path is required");let f=(0,g.resolve)(b,a.trim()),h=(0,j.bk)()?null:await (0,j.mc)();if(h&&!(0,j.A$)(f,h))throw Error("file path is not allowed");try{c=(0,e.lstatSync)(f)}catch{throw Error("file not found")}if(c.isSymbolicLink())throw Error("symbolic-link sources are not allowed");if(!c.isFile())throw Error("path must be a regular file");try{d=(0,e.realpathSync)(f)}catch{throw Error("file path could not be resolved")}if(h&&!(0,j.A$)(d,h))throw Error("file path is not allowed");return{path:d,stat:c}}function q(a){return async function(b,c){let d;o(c);let j=await p(b.path,a.cwd),m=j.path,n="string"==typeof b.name&&b.name.trim()?b.name.trim():(0,g.basename)(m),q="number"==typeof e.constants.O_NOFOLLOW?e.constants.O_NOFOLLOW:0,r="number"==typeof e.constants.O_NONBLOCK?e.constants.O_NONBLOCK:0,s=await (0,f.open)(m,e.constants.O_RDONLY|q|r);try{let b=await s.stat();if(!b.isFile())throw Error("path must be a regular file");if(0!==j.stat.dev&&0!==j.stat.ino&&(b.dev!==j.stat.dev||b.ino!==j.stat.ino))throw Error("file changed during open");if(b.size>i.Gt)throw Error(`file exceeds ${i.Gt} bytes`);o(c);let f=(0,e.createReadStream)("",{fd:s.fd,autoClose:!1,signal:c});d=await (0,i.xd)(n,h.Readable.toWeb(f),a.agentDir,i.Gt),o(c);let g=(0,l.iU)({path:d.path,name:d.name,mimeType:(0,k.cV)(m)??(0,k.X)(m)??(0,k.k2)(m)??(0,k.oC)(m)??({txt:"text/plain",md:"text/markdown",json:"application/json",csv:"text/csv",html:"text/html",xml:"application/xml",zip:"application/zip",gz:"application/gzip",tar:"application/x-tar"})[(0,k.GO)(m)]??"application/octet-stream",size:d.size},a.agentDir),{entryId:p}=a.appendBinary(g);return d=void 0,{entryId:p,name:g.name,size:g.size}}finally{if(await s.close().catch(()=>{}),d)try{(0,e.unlinkSync)(d.path)}catch{}}}}d()}catch(a){d(a)}})},31524:(a,b,c)=>{c.d(b,{Ut:()=>e,eU:()=>f,yu:()=>g});let d=["off","minimal","low","medium","high","xhigh","max"];function e(a,b){return a?d.filter(a=>b?.[a]!==null):["off"]}function f(a){if(!a.reasoning)return a;let b=a.thinkingLevelMap,c={...b??{}},d=!1;for(let a of["xhigh","max"])Object.prototype.hasOwnProperty.call(c,a)&&void 0!==c[a]||(c[a]=a,d=!0);return!d&&b?a:{...a,thinkingLevelMap:c}}function g(a){let b=f(a);if(b===a)return a;try{return a.thinkingLevelMap=b.thinkingLevelMap,a}catch{return b}}},37594:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{C9:()=>G,DQ:()=>F,Md:()=>E,Yz:()=>D,mB:()=>J});var e=c(29021),f=c(33873),g=c(80547),h=c(60396),i=c(95237),j=c(52960),k=c(79495),l=c(81879),m=c(46935),n=c(31514),o=c(65107),p=c(56429),q=c(40402),r=c(85664),s=c(15461),t=c(76817),u=c(86226),v=c(68524),w=c(89953),x=c(50955),y=c(40239),z=c(5815),A=c(26773),B=c(68816),C=a([g,i,l,p,q,A]);[g,i,l,p,q,A]=C.then?(await C)():C;let F="Subagent sessions are read-only";class G extends Error{constructor(){super(F)}toString(){return this.message}}async function D(a,b){if(await b(a))throw new G}function E(a){let b=a instanceof Error?a.message:String(a);return a instanceof G||b===F?403:b.includes("Session not found")?404:(0,w.wE)(a)||b===w.GT||"Session is being deleted"===b||b.includes("closed while its title")?409:500}let H={listAllSessions:q.dQ,resolveSessionPath:q.os,getRpcSession:p.A4,waitForSessionStart:p.DU,startRpcSession:p.OF,getRunningRpcSessionIds:p.HG,listPendingExtensionUi:p.$k,subscribeRunningSessions:p.Fn,allowFileRoot:g.wz,invalidateSessionListCache:q.mD,openSessionCwd:a=>(0,i.kW)(a).getHeader()?.cwd??process.cwd(),openSessionManager:a=>(0,q.Zx)({filePath:a}),openSessionView:i.kW,reparentSessionFile:i.i5,existsSync:e.existsSync,now:()=>Date.now(),archiveFs:y.Iq},I=["systemPrompt"],J=function(a={}){let b={...H,...a},c=(0,y.Ki)({fs:b.archiveFs,agentDir:b.archiveAgentDir,resolveSessionPath:b.resolveSessionPath,readSessionHeader:q.eP,isReadOnly:async a=>{let c=(await b.listAllSessions()).find(b=>b.id===a);return c?.readOnly===!0},isRunning:a=>b.getRunningRpcSessionIds().includes(a),getSessionInfo:async a=>(await b.listAllSessions()).find(b=>b.id===a)??null,invalidateSessionListCache:b.invalidateSessionListCache,now:()=>new Date(b.now()).toISOString()}),d=()=>(0,y.$T)(b.archiveFs??y.Iq,b.archiveAgentDir?.()??(0,h.$M)()),g=new Map,p=async a=>{let c=b.getRpcSession(a);if(c){if("function"==typeof c.destroyAsync)return void await c.destroyAsync();c.isAlive()&&c.destroy()}},C=async(a,b)=>{if(!(0,w.kP)(a))throw Error(w.GT);try{return await b()}finally{(0,w.Hl)(a)}},E=async(a,b)=>(await p(a),C(a,b)),F={async listSessions(){let a=await b.listAllSessions(),{active:c,archived:e}=(0,y.uD)(a,d());return{sessions:c,archivedSessions:e,archivedCount:e.length,runningSessionIds:b.getRunningRpcSessionIds()}},async listArchivedSessions(){let a=await b.listAllSessions();return(0,y.uD)(a,d()).archived},async listActiveSessions(){let a=await b.listAllSessions();return(0,y.uD)(a,d()).active},listAllSessions:async()=>b.listAllSessions(),async isArchived(a){let c=await b.listAllSessions();return(0,y.YV)(c,d()).has(a)},archiveSession:async a=>c.archiveSession(a),restoreSession:async a=>c.restoreSession(a),archiveSessions:async a=>c.archiveSessions(a),restoreSessions:async a=>c.restoreSessions(a),removeArchiveRecordAfterPermanentDelete(a){(0,y.rQ)(b.archiveFs??y.Iq,b.archiveAgentDir?.()??(0,h.$M)(),a)},resolvePath:a=>b.resolveSessionPath(a),getSessionInfo:async a=>a&&"string"==typeof a?(await b.listAllSessions()).find(b=>b.id===a)??null:null,async isReadOnly(a){let c=(await b.listAllSessions()).find(b=>b.id===a);return c?.readOnly===!0},async getReadView(a){let c=await b.resolveSessionPath(a);if(!c)return null;let d=b.getRpcSession(a),e=d?.inner;return d?.isAlive()&&e?.sessionManager?{source:"live",filePath:c,manager:e.sessionManager}:{source:"disk",filePath:c,manager:b.openSessionManager(c)}},getLive(a){let c=b.getRpcSession(a);return c?.isAlive()?c:void 0},getLiveSession:a=>F.getLive(a),isLive:a=>!!F.getLive(a),async ensureLive(a){if(await D(a,F.isReadOnly),g.has(a))throw Error("Session is being deleted");let c=F.getLive(a);if(c)return c;if((0,w.wy)(a))throw Error(w.GT);let d=await b.resolveSessionPath(a);if(!d)throw Error("Session not found");let e=b.openSessionCwd(d),{session:f}=await b.startRpcSession(a,d,e,void 0,G);return f},destroy(a){b.getRpcSession(a)?.destroy()},async destroyAsync(a){let c=b.getRpcSession(a);c&&("function"==typeof c.destroyAsync?await c.destroyAsync():c.destroy())},deleteSession(a){let c=g.get(a);if(c)return c;let d=(async()=>{await D(a,F.isReadOnly);let c=await b.waitForSessionStart?.(a)??a,d=await b.resolveSessionPath(a);if(!d){try{(0,v.xP)(`sessionQueue.${a}`,null),(0,v.xP)(`sessionQueueHold.${a}`,null)}catch(a){console.error("[pidance] failed to clear queue prefs after missing delete:",a)}return(0,q.BR)(a),b.invalidateSessionListCache(),F.removeArchiveRecordAfterPermanentDelete(a),{skippedSubagents:0}}if((0,w.wy)(a)||(0,w.wy)(c))throw Error(w.GT);let g=(0,q.eP)(d)?.parentSession,h=(0,q.eP)(d)?.id===a?(0,x.ku)(d,a):[],i=b.getRpcSession(c)??b.getRpcSession(a),j=b.getRunningRpcSessionIds();if(i?.isAlive?.()&&(j.includes(a)||j.includes(c)))try{await i.send({type:"abort"})}catch(a){console.error("[pidance] abort before delete failed:",a)}return await F.destroyAsync(i?.sessionId??c),C(i?.sessionId??c,async()=>{let c=d.replace(/\\/g,"/").split("/").slice(0,-1).join("/");try{for(let a of(0,e.readdirSync)(c).filter(a=>a.endsWith(".jsonl")&&(0,f.join)(c,a)!==d)){let e=(0,f.join)(c,a);try{let a=(0,q.eP)(e);a?.type==="session"&&a.parentSession===d&&(a.id?(await b.waitForSessionStart?.(a.id),await E(a.id,()=>{b.reparentSessionFile(e,g)})):b.reparentSessionFile(e,g))}catch{}}}catch{}try{(0,e.unlinkSync)(d)}catch(a){if("ENOENT"!==a.code)throw a}(0,o.$9)(d);let i=(0,f.resolve)(d.slice(0,-6)),j=(0,x.uq)(h,i,q.BR);try{(0,v.xP)(`sessionQueue.${a}`,null),(0,v.xP)(`sessionQueueHold.${a}`,null)}catch(a){console.error("[pidance] failed to clear queue prefs after delete:",a)}return(0,q.BR)(a),b.invalidateSessionListCache(),F.removeArchiveRecordAfterPermanentDelete(a),{skippedSubagents:j}})})();return g.set(a,d),d.finally(()=>{g.get(a)===d&&g.delete(a)})},async start(a,c,d,e){if(await D(a,F.isReadOnly),g.has(a))throw Error("Session is being deleted");return b.startRpcSession(a,c,d,e,G)},send:async(a,b)=>(await F.ensureLive(a)).send(b),async submitPrompt(a,b){await D(a,F.isReadOnly);let c=(0,j.JT)(b);try{let b=await F.send(a,c);if(b&&"object"==typeof b&&b.status)return b;return{submissionId:c.submissionId,sessionId:a,status:"accepted"}}catch(b){if((0,w.wE)(b))throw b;return{submissionId:c.submissionId,sessionId:a,status:"rejected"}}},async getAgentState(a,b){if(await F.isReadOnly(a))return{live:!1,activeRun:!1,readOnly:!0};let c=F.getLive(a);if(!c)return{live:!1,activeRun:!1,...(0,w.wy)(a)?{lockedByOther:!0}:{}};let d=await c.send({type:"get_state"}),e="function"==typeof c.isRunning?!!c.isRunning():!!(d&&(d.isStreaming||d.isPromptRunning||d.isCompacting||d.isBashRunning));return{live:!0,activeRun:e,lockedByOther:!1,state:function(a,b){if(!b?.light||!a||"object"!=typeof a||Array.isArray(a))return a;let c={...a};for(let a of I)delete c[a];return c}(d,b)}},async renameSession(a,c){await D(a,F.isReadOnly);let d=c.trim();if(!d)throw Error("name is required");let e=F.getLive(a);if(e?.isAlive()){await e.send({type:"set_session_name",name:d}),b.invalidateSessionListCache();return}let f=await b.resolveSessionPath(a);if(!f)throw Error("Session not found");await E(a,()=>{b.openSessionView(f).appendSessionInfo(d),b.invalidateSessionListCache()})},async autoNameSession(a){await D(a,F.isReadOnly);let b=await F.ensureLive(a);await b.waitUntilReady?.();let c=await F.getNavigationSnapshot(a);if(!c)throw Error("Session not found");let d=c.context.messages??[],e=(0,k.CL)(),f=await (0,k.K)({messages:d,provider:e.provider,modelId:e.modelId,baseUrl:e.baseUrl,api:e.api,apiKey:e.apiKey,headers:e.headers});if(!b.isAlive())throw Error("The session was closed while its title was being generated. Please try again.");try{await b.send({type:"set_session_name",name:f.title})}catch{await F.destroyAsync(a),await F.renameSession(a,f.title)}return{title:f.title,usage:f.usage??null}},async exportSession(a,c){let d=await b.resolveSessionPath(a);if(!d)throw Error("Session not found");return(0,l.by)(d,c)},async getNavigationSnapshot(a,c={}){let d=await F.getReadView(a);if(!d)return null;let{filePath:e,manager:f}=d,{leafId:g,tree:h,context:i,header:j,sessionName:k}=(0,q.jK)(f,c),l=j?.parentSession?await (0,q.u1)(j.parentSession):void 0,m=(await b.listAllSessions()).find(b=>b.id===a),n=j?{path:e,id:j.id,cwd:j.cwd??"",name:k,created:j.timestamp,modified:j.timestamp,messageCount:i.totalMessageCount??i.messages.length,firstMessage:m?.firstMessage??"(no messages)",parentSessionId:l,...m?.subagent?{subagent:m.subagent,readOnly:!0}:{}}:null;return{filePath:e,leafId:g,tree:h,context:i,header:j,sessionName:k,parentSessionId:l,info:n}},async getContextPage(a,b){let c=await F.getReadView(a);if(!c)return{context:null};let d=c.manager,e=d.getEntries?.()??[],f=(0,q.Uv)(e,b.leafId,{deferThinking:b.deferThinking,deferToolResultImages:b.deferToolResultImages}),g=b.limit;return{context:b.before?(0,m.tr)(f,b.before,g??m._w):null!==g?(0,m.G1)(f,g):{...f,hasMoreBefore:!1,totalMessageCount:f.messages.length}}},async getEntryThinking(a,b,c){let d=await F.getReadView(a);if(!d)return null;let e=d.manager.getEntries().find(a=>a.id===b);if(!e||"message"!==e.type||e.message?.role!=="assistant")return null;let f=e.message.content?.[c];return f&&(0,n.mv)(f.type)?{thinking:(0,n.Ux)(f)}:null},async getToolResultDetails(a,b){let c=await F.getReadView(a);if(!c)return null;let d=c.manager.getEntries().find(a=>"message"===a.type&&a.message?.role==="toolResult"&&a.message.toolCallId===b);return d?{details:d.message?.details??null,content:Array.isArray(d.message?.content)?d.message.content:[]}:null},async appendActivity(a,c){await D(a,F.isReadOnly);let d=F.getLive(a),e=!!d?.inner?.sessionManager,f=d?.appendActivity;return d?.isAlive()&&e&&"function"==typeof f?await f.call(d,c):await E(a,async()=>{let d=await b.resolveSessionPath(a);if(!d)throw Error("Session not found");let e=(0,r.l$)(c),f=b.openSessionView(d).appendCustomEntry(r.cP,e);return b.invalidateSessionListCache(),{entryId:f,activity:e}})},appendCommandEntry:async(a,c)=>(await D(a,F.isReadOnly),await E(a,async()=>{let d=await b.resolveSessionPath(a);if(!d)throw Error("Session not found");let e=(0,s.fc)(c);if(!e.command)throw Error("command is required");let f=b.openSessionView(d).appendCustomEntry(s.OE,e);return b.invalidateSessionListCache(),{entryId:f,data:e}})),async createNew({cwd:a,command:c}){if(!a||"string"!=typeof a)throw Error("cwd is required");if(!b.existsSync(a))throw Error(`Directory does not exist: ${a}`);let{provider:d,modelId:e,toolNames:f,thinkingLevel:g,...h}=c,j=`__new__${b.now()}`,{session:k,realSessionId:l}=await b.startRpcSession(j,"",a,f,G);if(b.allowFileRoot(a),b.invalidateSessionListCache(),d&&e&&await k.send({type:"set_model",provider:d,modelId:e}),g&&await k.send({type:"set_thinking_level",level:g}),"ensure_session"===h.type){try{let a=k.inner,b=a?.sessionManager;b&&"function"==typeof b.getSessionFile&&(0,i.kb)(b)}catch(a){console.error("[pidance] materialize ensure_session failed:",a)}return{sessionId:l,data:null}}let m=await k.send(h);return{sessionId:l,data:m}},getRunningIds:()=>b.getRunningRpcSessionIds(),getRunningStartedAt(){let a=new Set(b.getRunningRpcSessionIds()),c={};for(let[b,d]of(0,z.MG)())a.has(b)&&(c[b]=d);for(let[b,d]of Object.entries((0,A.EM)()))!a.has(b)||b in c||(c[b]=d);return c},async searchFulltext(a,c={}){let d=await (0,B.s)(a,{limits:void 0!==c.maxHits?{maxHits:c.maxHits}:void 0}),e=c.scope??"active";if("all"===e)return d;let f=await b.listAllSessions(),g=(0,y.$T)(b.archiveFs??y.Iq,b.archiveAgentDir?.()??(0,h.$M)()),i=(0,y.mT)(d.sessionIds,f,g,e);return{...d,sessionIds:d.sessionIds.filter(a=>i.has(a)),hits:d.hits.filter(a=>i.has(a.sessionId))}},listPendingExtensionUi:()=>b.listPendingExtensionUi(),subscribeRunning:a=>b.subscribeRunningSessions(a),async selectLeafExact(a,c){if("string"!=typeof c||""===c.trim())throw Error("entryId is required");let d=c.trim(),e=b.getRpcSession(a);if(e?.isAlive?.()&&e.inner?.isBashRunning)throw Error("Cannot switch branch while a shell command is running");return E(a,async()=>{let c=await b.resolveSessionPath(a);if(!c)throw Error("Session not found");let e=b.openSessionView(c),f=e.getLeafId();if(d===f)return{cancelled:!1};if(d===e.getLastEntryId())return(0,o.$9)(c),{cancelled:!1};if(!e.getEntry(d))throw Error(`Entry ${d} not found`);try{return e.branch(d),(0,o.R3)(c,d),{cancelled:!1}}finally{b.invalidateSessionListCache()}})},async branchFromAssistant(a,c){if("string"!=typeof c||""===c.trim())throw Error("assistantEntryId is required");let d=c.trim(),e=b.getRpcSession(a);if(e?.isAlive?.()&&e.inner?.isBashRunning)throw Error("Cannot branch while a shell command is running");return E(a,async()=>{let c=await b.resolveSessionPath(a);if(!c)throw Error("Session not found");let e=b.openSessionView(c),f=e.getLeafId();if(!f)throw Error("Session has no leaf");let g=e.getBranch(f),h=e.getEntry(d);if(!h)throw Error("Entry not found");if("message"!==h.type||h.message?.role!=="assistant")throw Error("Only assistant messages can be branched from");let i=(0,t.wo)(g,d);try{return e.branch(i),i===e.getLastEntryId()?(0,o.$9)(c):(0,o.R3)(c,i),{cancelled:!1}}finally{b.invalidateSessionListCache()}})},async createSessionFromLeaf(a,c){if("string"!=typeof c||""===c.trim())throw Error("entryId is required");let d=c.trim(),e=b.getRpcSession(a),f=e?.inner;return E(a,async()=>{let c=(f?.sessionFile||e?.sessionFile)??await b.resolveSessionPath(a);if(!c)throw Error("Session not found");let g=(0,i.kW)(c),h=g.getEntry(d);if(!h)throw Error("Invalid entry ID");let j=d;if("message"===h.type&&h.message?.role==="assistant"){let a=g.getLeafId();if(!a)throw Error("Session has no leaf");let b=g.getBranch(a);j=(0,t.wo)(b,d)}let k=g.getSessionDir(),l=(0,i.G1)(c,k),m=l.createBranchedSession(j);if(!m)throw Error("Failed to create session");(0,i.kb)(l);let n=(0,i.kW)(m,k),o=n.getSessionId();(0,q.O8)(o,m),b.invalidateSessionListCache();let p=f?.model;return p&&(0,u.yN)(n.getEntries().some(a=>"model_change"===a.type),{provider:p.provider,modelId:p.id})&&n.appendModelChange(p.provider,p.id),{cancelled:!1,newSessionId:o}})}},G={selectLeafExact:(a,b)=>F.selectLeafExact(a,b),branchFromAssistant:(a,b)=>F.branchFromAssistant(a,b),createSessionFromLeaf:(a,b)=>F.createSessionFromLeaf(a,b)};return F}();d()}catch(a){d(a)}})},38195:(a,b,c)=>{c.d(b,{t:()=>g});var d=c(716),e=c(87538);function f(a,b,c,e,f,g,h){let i=(0,d.randomUUID)();return new Promise((d,j)=>{let k,l=!1,m=()=>{a.delete(i),b.delete(i),k&&clearTimeout(k),e?.signal?.removeEventListener("abort",o)},n=a=>{l||(l=!0,m(),d(a))},o=()=>n(f);e?.signal?.addEventListener("abort",o,{once:!0}),e?.timeout&&(k=setTimeout(()=>n(f),e.timeout)),a.set(i,{resolve:a=>{try{n(h(a))}catch(a){if(l)return;l=!0,m(),j(a instanceof Error?a:Error(String(a)))}},reject:a=>{l||(l=!0,m(),j(a))}});let p={type:"extension_ui_request",id:i,...g};b.set(i,p),c(p)})}function g(a){let b=new Map,c=new Map,g=new Map,h=new Map,i=new Map,j={select:(d,e,g)=>f(b,c,a,g,void 0,{method:"select",title:d,options:e,timeout:g?.timeout},a=>"cancelled"in a&&a.cancelled?void 0:"value"in a?a.value:void 0),confirm:(d,e,g)=>f(b,c,a,g,!1,{method:"confirm",title:d,message:e,timeout:g?.timeout},a=>(!("cancelled"in a)||!a.cancelled)&&"confirmed"in a&&!!a.confirmed),input:(d,e,g)=>f(b,c,a,g,void 0,{method:"input",title:d,placeholder:e,timeout:g?.timeout},a=>"cancelled"in a&&a.cancelled?void 0:"value"in a?a.value:void 0),notify(b,c){a({type:"extension_ui_request",id:(0,d.randomUUID)(),method:"notify",message:b,notifyType:c})},onTerminalInput:()=>()=>{},setStatus(b,c){c?g.set(b,c):g.delete(b),a({type:"extension_ui_request",id:(0,d.randomUUID)(),method:"setStatus",statusKey:b,statusText:c})},setWorkingMessage(){},setWorkingVisible(){},setWorkingIndicator(){},setHiddenThinkingLabel(){},setWidget(b,c,f){if("function"==typeof c){let a=(0,e.tU)(c,(0,e.Lm)());if(null===a)return;c=a}(void 0===c||Array.isArray(c))&&(null==c?h.delete(b):h.set(b,{lines:c,placement:f?.placement}),a({type:"extension_ui_request",id:(0,d.randomUUID)(),method:"setWidget",widgetKey:b,widgetLines:c,widgetPlacement:f?.placement}))},setFooter(){},setHeader(){},setTitle(b){a({type:"extension_ui_request",id:(0,d.randomUUID)(),method:"setTitle",title:b})},async custom(b){let c=(0,d.randomUUID)();return new Promise(d=>{let f,g=!1,h=b=>{g||(g=!0,i.delete(c),a({type:"extension_ui_request",id:c,method:"custom",closed:!0,lines:[]}),d(b))},k=()=>{if(g)return;let b=[];try{let a=f?.render?.(92);Array.isArray(a)&&(b=a.filter(a=>"string"==typeof a))}catch(a){console.error("[pidance] custom UI render failed:",a)}a({type:"extension_ui_request",id:c,method:"custom",lines:b})};i.set(c,{handleInput:a=>{if("\x03"===a)return void h(void 0);try{f?.handleInput?.(a)}catch(a){console.error("[pidance] custom UI input failed:",a)}},done:h});let l=function(a,b=92,c=40){return Object.freeze({terminal:Object.freeze({columns:b,rows:c,kittyProtocolActive:!1}),requestRender:a})}(()=>{k()},92,40),m=(0,e.Lm)()??j.theme;Promise.resolve().then(()=>b(l,m,{},h)).then(a=>{g||(f=a,k())}).catch(a=>{console.error("[pidance] custom UI factory failed:",a),h(void 0)})})},pasteToEditor(a){this.setEditorText(a)},setEditorText(b){a({type:"extension_ui_request",id:(0,d.randomUUID)(),method:"set_editor_text",text:b})},getEditorText:()=>"",editor:async(d,e)=>f(b,c,a,void 0,void 0,{method:"editor",title:d,prefill:e},a=>"cancelled"in a&&a.cancelled?void 0:"value"in a?a.value:void 0),addAutocompleteProvider(){},setEditorComponent(){},getEditorComponent(){},get theme(){let a=a=>String(a??""),b=(a,b)=>void 0===b?"":String(b);return new Proxy({fg:b,bg:b,bold:a,dim:a,italic:a},{get:(b,c)=>c in b?b[c]:"then"!==c?a:void 0})},getAllThemes:()=>[],getTheme(){},setTheme:()=>({success:!1,error:"Theme switching not supported in Web mode"}),getToolsExpanded:()=>!1,setToolsExpanded(){}};return{uiContext:j,pending:b,statuses:g,widgets:h,pendingSnapshot:c,respond(a,c){let d=b.get(a);return!!d&&(d.resolve(c),!0)},inputCustom(a,b){let c=i.get(a);return!!c&&(c.handleInput(b),!0)},dispose(){for(let[a,d]of b)b.delete(a),c.delete(a),d.reject(Error("Extension UI disposed"));for(let a of i.values())a.done(void 0);i.clear(),g.clear(),h.clear()}}}},40239:(a,b,c)=>{c.d(b,{$T:()=>m,Iq:()=>g,J3:()=>t,Ki:()=>u,YV:()=>q,mT:()=>r,rQ:()=>p,uD:()=>s});var d=c(29021),e=c(33873),f=c(60396);let g={existsSync:d.existsSync,lstatSync:d.lstatSync,mkdirSync:d.mkdirSync,readFileSync:(a,b)=>(0,d.readFileSync)(a,b),writeFileSync:(a,b,c)=>(0,d.writeFileSync)(a,b,c),renameSync:d.renameSync,unlinkSync:d.unlinkSync,readdirSync:d.readdirSync};function h(a=(0,f.$M)()){return(0,e.join)(a,"pidance-archive")}function i(a){return"string"!=typeof a||a.length<8||a.length>64||!/^[0-9a-fA-F][0-9a-fA-F-]{7,63}$/.test(a)?null:`${a}.json`}function j(a,b){try{let c=h(b);if(!a.existsSync(c))return null;let d=a.lstatSync(c);if(d.isSymbolicLink()||!d.isDirectory())return null;return c}catch{return null}}function k(a){return"object"==typeof a&&null!==a&&!(1!==a.version||"string"!=typeof a.sessionId||0===a.sessionId.length||"string"!=typeof a.sessionPath||0===a.sessionPath.length||"string"!=typeof a.archivedAt||Number.isNaN(Date.parse(a.archivedAt)))}function l(a,b,c){let d=i(c);if(!d)return null;let f=j(a,b);if(!f)return null;let g=(0,e.join)(f,d);try{if(!a.existsSync(g)||a.lstatSync(g).isSymbolicLink())return null;let b=a.readFileSync(g,"utf8");if(b.length>65536)return null;let d=JSON.parse(b);if(!k(d)||d.sessionId!==c)return null;return d}catch{return null}}function m(a,b){let c=globalThis.__piArchiveRecordsCache;if(c&&Date.now()-c.ts<5e3)return c.records;let d=j(a,b),e=[];if(d){let c=[];try{c=a.readdirSync(d)}catch{c=[]}for(let d of c){let c=function(a){if("string"!=typeof a||!a.endsWith(".json"))return null;let b=a.slice(0,-5);return b.length<8||b.length>64||!/^[0-9a-fA-F][0-9a-fA-F-]{7,63}$/.test(b)?null:b}(d);if(!c)continue;let f=l(a,b,c);f&&e.push(f)}}return globalThis.__piArchiveRecordsCache={records:e,ts:Date.now()},e}function n(){globalThis.__piArchiveRecordsCache=void 0}function o(a,b,c){let d=i(c);if(!d)return!1;let f=j(a,b);if(!f)return!1;let g=(0,e.join)(f,d);try{if(!a.existsSync(g))return!1;return a.unlinkSync(g),n(),!a.existsSync(g)}catch{return!1}}function p(a,b,c){o(a,b,c)}function q(a,b){let c=new Map;for(let a of b)c.set(a.sessionId,a);let d=new Set;for(let b of a){let a=c.get(b.id);a&&a.sessionPath===b.path&&d.add(b.id)}return d}function r(a,b,c,d){let e=q(b,c),f=new Set;for(let b of a){let a=e.has(b);("active"===d?!a:a)&&f.add(b)}return f}function s(a,b){let c=q(a,b),d=new Map;for(let a of b)d.set(a.sessionId,a);let e=[],f=[];for(let b of a)if(c.has(b.id)){let a=d.get(b.id);f.push({...b,archivedAt:a?a.archivedAt:void 0})}else e.push(b);return{active:e,archived:f}}class t extends Error{constructor(){super("Session is running; cannot archive while active")}toString(){return this.message}}function u(a){let b=a.fs??g,c=()=>a.agentDir?.()??(0,f.$M)(),d=async d=>{if(await a.isReadOnly(d))throw Error("Subagent sessions are read-only");if(a.isRunning(d))throw new t;let f=await a.resolveSessionPath(d);if(!f)throw Error("Session not found");let g=a.readSessionHeader(f);if(!g||g.id!==d)throw Error("Session header id mismatch");let j={version:1,sessionId:d,sessionPath:f,archivedAt:a.now()};return!function(a,b,c){let d=i(c.sessionId);if(!d)throw Error("Invalid session id");if(!k(c))throw Error("Invalid archive record");let f=function(a,b){let c=h(b);try{a.existsSync(c)||a.mkdirSync(c,{recursive:!0});let b=a.lstatSync(c);if(b.isSymbolicLink()||!b.isDirectory())return null;return c}catch{return null}}(a,b);if(!f)throw Error("Archive directory unavailable");let g=(0,e.join)(f,d),j=(0,e.join)(f,`.${d}.${process.pid}.${Date.now().toString(36)}.tmp`);try{a.writeFileSync(j,JSON.stringify(c),{encoding:"utf8",flag:"wx"}),a.renameSync(j,g),n()}catch(b){try{a.existsSync(j)&&a.unlinkSync(j)}catch{}throw b}}(b,c(),j),a.invalidateSessionListCache(),j.archivedAt},j=async d=>{if(null===l(b,c(),d))throw Error("Session is not archived");if(!await a.resolveSessionPath(d))throw Error("Session not found");if(!o(b,c(),d))throw Error("Failed to remove archive record");return a.invalidateSessionListCache(),a.getSessionInfo(d)},m=async a=>{let b=[],c=[];for(let e of a)try{await d(e),b.push(e)}catch(a){c.push({id:e,error:a instanceof Error?a.message:String(a)})}return{succeededIds:b,failed:c}},p=async a=>{let b=[],c=[];for(let d of a)try{await j(d),b.push(d)}catch(a){c.push({id:d,error:a instanceof Error?a.message:String(a)})}return{succeededIds:b,failed:c}};return{archiveSession:d,restoreSession:j,archiveSessions:m,restoreSessions:p}}},46935:(a,b,c)=>{c.d(b,{G1:()=>h,NN:()=>g,Uf:()=>d,_w:()=>e,tr:()=>i});let d=80,e=80;function f(a,b){return"number"==typeof a&&Number.isFinite(a)?Math.max(1,Math.min(Math.floor(a),500)):b}function g(a,b=d){let c=a.get("limit")??a.get("tail");if(null===c||""===c)return null;let e=Number(c);return!Number.isFinite(e)||e<=0?b:f(e,b)}function h(a,b=d){let c=a.messages.length,e=f(b,d);if(c<=e)return{...a,hasMoreBefore:!1,totalMessageCount:c};let g=c-e;return{messages:a.messages.slice(g),entryIds:a.entryIds.slice(g),thinkingLevel:a.thinkingLevel,model:a.model,hasMoreBefore:!0,totalMessageCount:c}}function i(a,b,c=e){let d=a.messages.length,g=a.entryIds.indexOf(b);if(g<=0)return{messages:[],entryIds:[],thinkingLevel:a.thinkingLevel,model:a.model,hasMoreBefore:!1,totalMessageCount:d};let h=Math.max(0,g-f(c,e));return{messages:a.messages.slice(h,g),entryIds:a.entryIds.slice(h,g),thinkingLevel:a.thinkingLevel,model:a.model,hasMoreBefore:h>0,totalMessageCount:d}}},52960:(a,b,c)=>{c.d(b,{D_:()=>i,JT:()=>h,QR:()=>j});var d=c(13737);function e(){return"u">typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():`sub-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function f(a){if(void 0===a)return;if(!Array.isArray(a))throw Error("images must be an array");let b=[];for(let c of a){if(!c||"object"!=typeof c)throw Error("invalid image");let a="string"==typeof c.data?c.data:void 0,e="string"==typeof c.mimeType?c.mimeType:"string"==typeof c.mime_type?c.mime_type:void 0,f=(0,d.Ln)(e);if(!a||!f?.startsWith("image/"))throw Error("invalid image");if(a.length>4194304)throw Error("invalid image: payload too large");b.push({type:"image",data:a,mimeType:f})}return b}function g(a){if("string"!=typeof a.message)throw Error("message is required");return a.message}function h(a,b=e){return{type:"prompt",message:g(a),submissionId:"string"==typeof a.submissionId&&a.submissionId.trim()?a.submissionId.trim():b(),images:f(a.images),binaryBlocks:function(a){if(void 0===a)return;if(!Array.isArray(a))throw Error("binaryBlocks must be an array");if(a.length>32)throw Error("too many binary blocks");let b=[];for(let c of a){if(!c||"object"!=typeof c||Array.isArray(c))throw Error("invalid binary block");let a="string"==typeof c.path?c.path.trim():"",e="string"==typeof c.name?c.name.trim():"",f=(0,d.Ln)(c.mimeType),g=c.size,h=void 0===c.previewPath?void 0:"string"==typeof c.previewPath?c.previewPath.trim():null;if(!a||!e||!f||!Number.isSafeInteger(g)||g<0||null===h)throw Error("invalid binary block");b.push({path:a,name:e,mimeType:f,size:g,...h?{previewPath:h}:{}})}return b}(a.binaryBlocks)}}function i(a){return"prompt"===a||"abort"===a||"steer"===a||"follow_up"===a}function j(a,b=e){if(!a||"object"!=typeof a||Array.isArray(a))throw Error("command is required");let c=a.type;if("prompt"===c)return h(a,b);if("abort"===c)return{type:"abort"};if("steer"===c)return{type:"steer",message:g(a),images:f(a.images)};if("follow_up"===c)return{type:"follow_up",message:g(a),images:f(a.images)};throw Error(`Unsupported message command: ${String(c)}`)}},53023:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{Uj:()=>j});var e=c(85664),f=c(93127),g=c(95237),h=a([f,g]);function i(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}[f,g]=h.then?(await h)():h;let k=`
1
+ "use strict";exports.id=7594,exports.ids=[7594],exports.modules={1060:(a,b,c)=>{c.d(b,{Ac:()=>n,GO:()=>i,X:()=>k,_4:()=>d,cV:()=>j,k2:()=>l,oC:()=>m});let d=262144,e={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",bmp:"image/bmp",ico:"image/x-icon",avif:"image/avif"},f={mp3:"audio/mpeg",wav:"audio/wav",ogg:"audio/ogg",oga:"audio/ogg",opus:"audio/ogg",m4a:"audio/mp4",aac:"audio/aac",flac:"audio/flac",weba:"audio/webm"},g={mp4:"video/mp4",m4v:"video/mp4",webm:"video/webm",ogv:"video/ogg",mov:"video/quicktime",mkv:"video/x-matroska",avi:"video/x-msvideo"},h={pdf:"application/pdf",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"};function i(a){return(a.replace(/\\/g,"/").split("/").pop()??"").toLowerCase().split(".").pop()??""}function j(a){return e[i(a)]??null}function k(a){return f[i(a)]??null}function l(a){return g[i(a)]??null}function m(a){return h[i(a)]??null}function n(a){let b=i(a);return"pdf"===b||"docx"===b?b:null}},2416:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{j1:()=>w});var e=c(75430),f=c(60396),g=c(68524),h=c(89953),i=c(5815),j=c(85664),k=c(65107),l=c(95237),m=c(38195),n=c(62693),o=c(31524),p=c(52960),q=c(13737),r=c(60185),s=c(28121),t=c(87538),u=a([e,l,r,s]);function v(a){return"string"==typeof a&&a?a:void 0}[e,l,r,s]=u.then?(await u)():u;class x{static{this.PARTIAL_RENDER_MIN_INTERVAL_MS=100}constructor(a){this.options=a,this.listeners=[],this.runtime=null,this.unsubscribe=null,this.extensionUi=null,this.idleTimer=null,this.startupHoldTimer=null,this.startupHold=!0,this.activeCommandCount=0,this._scheduledRecheck=!1,this.onDestroyCallback=null,this._alive=!0,this.promptRunning=!1,this.lastStopReason=null,this.followUpQueue=[],this.followUpQueueRevision=0,this.followUpQueueHydrated=!1,this.flushingFollowUp=!1,this.followUpFlushBatch=[],this.followUpFlushCursor=0,this.followUpFlushConfirmed=!1,this.followUpFlushAsOne=!1,this.followUpFlushOriginal=[],this.bashRunning=!1,this.bashCommand=null,this.localQueue={steering:[],followUp:[]},this.turnMetrics={startedAt:0,firstTokenAt:null,ttftMs:null,decodeMs:0,outputTokens:0,sampled:!1},this.promptReceipts=new Map,this.promptInFlight=new Map,this.pendingBinaryBatches=[],this.destroyPromise=null,this.hasQueueSnapshot=!1,this.renderBridgeTheme=(0,t.Lm)(),this.toolRenderStates=new Map,this.realSessionId=a.sessionId,this.realSessionFile=a.sessionFile,this.idleTimeoutMs=a.idleTimeoutMs??3e4,this.agentDir=a.agentDir??(0,f.$M)(),this.activeToolNames=a.toolNames}get sessionId(){return this.realSessionId}get sessionFile(){return this.realSessionFile}listPendingExtensionRequests(){return Array.from(this.extensionUi?.pendingSnapshot.values()??[])}get inner(){let a=this.runtime?.session;if(a)return{sessionManager:a.sessionManager}}isAlive(){return this._alive&&null!==this.runtime}isRunning(){if(!this._alive||!this.runtime)return!1;let a=this.runtime.session;return this.promptRunning||this.bashRunning||a.isStreaming||a.isCompacting}onDestroy(a){this.onDestroyCallback=a}onEvent(a){let b=0===this.listeners.length;return this.listeners.push(a),b&&this.resetIdleTimer(),()=>{let b=this.listeners.length>0;this.listeners=this.listeners.filter(b=>b!==a),b&&0===this.listeners.length&&this.resetIdleTimer()}}beginExtensionBinding(){}async waitForExtensionsBound(){}emit(a){for(let b of this.listeners)try{b(a)}catch(a){console.error("[pidance] sdk host listener error:",a)}}notifyRunning(){this.options.onRunningChange?.()}resetIdleTimer(){if(this.idleTimer&&clearTimeout(this.idleTimer),this.idleTimer=null,!this._alive||!this.runtime||this.startupHold||this.isRunning()||this.flushingFollowUp||this.listeners.length>0)return;if(this.followUpQueue.length>0&&!this.isFollowUpHeld())return void this.scheduleFollowUpFlush();let a=this.idleTimeoutMs;this.idleTimer=setTimeout(()=>{if((this.idleTimer=null,!this.isRunning()&&!this.flushingFollowUp)&&!(this.listeners.length>0)){if(this.followUpQueue.length>0&&!this.isFollowUpHeld())return void this.scheduleFollowUpFlush();this.destroyAsync()}},a)}releaseStartupHold(){this.startupHold&&(this.startupHold=!1,this.startupHoldTimer&&clearTimeout(this.startupHoldTimer),this.startupHoldTimer=null)}isSettled(){return!!this.runtime&&!!this._alive&&!this.isRunning()}isFollowUpHeld(){let a=(0,g.rV)(this.agentDir);return!0===(0,g.ql)(a,`sessionQueueHold.${this.realSessionId}`)}setFollowUpHeld(a){try{(0,g.xP)(`sessionQueueHold.${this.realSessionId}`,!!a||null,this.agentDir)}catch(a){console.error("[pidance] failed to persist follow-up hold:",a)}}hydrateFollowUpQueue(){if(this.followUpQueueHydrated)return;this.followUpQueueHydrated=!0;let a=(0,g.rV)(this.agentDir),b=(0,g.ql)(a,`sessionQueue.${this.realSessionId}`),c=a=>Array.isArray(a)?a.filter(a=>"string"==typeof a&&a.trim().length>0):[];if(Array.isArray(b)){this.followUpQueue=c(b);return}let d=b&&"object"==typeof b?b:null;this.followUpQueue=c(d?.items),"number"==typeof d?.revision&&(this.followUpQueueRevision=d.revision)}updateFollowUpQueue(a){this.followUpQueue=a,this.followUpQueueRevision+=1}persistFollowUpQueue(){try{(0,g.xP)(`sessionQueue.${this.realSessionId}`,{items:this.followUpQueue,revision:this.followUpQueueRevision},this.agentDir)}catch(a){console.error("[pidance] failed to persist follow-up queue:",a)}}scheduleFollowUpFlush(){!this._alive||!this.runtime||this.flushingFollowUp||0===this.followUpQueue.length||this.isFollowUpHeld()||this.isSettled()&&(this.flushingFollowUp=!0,this.followUpFlushAsOne=!0===(0,g.rV)(this.agentDir).queueFlushAsOne,this.followUpFlushOriginal=[...this.followUpQueue],this.followUpFlushBatch=this.followUpFlushAsOne?[this.followUpFlushOriginal.join("\n\n")]:[...this.followUpFlushOriginal],this.followUpFlushCursor=0,this.followUpFlushConfirmed=!1,this.sendNextFollowUp())}async sendNextFollowUp(){if(!this.flushingFollowUp)return;if(this.isFollowUpHeld())return void this.abortFollowUpFlush();let a=this.followUpFlushBatch[this.followUpFlushCursor];if(void 0===a)return void this.finishFollowUpFlush();if(!this.isSettled())return void setTimeout(()=>{this.flushingFollowUp&&this.followUpFlushCursor<this.followUpFlushBatch.length&&this.sendNextFollowUp()},80);this.followUpFlushConfirmed=!1;try{await this.send({type:"prompt",message:a}),this.removeDeliveredFollowUp()&&this.emit({type:"follow_up_flushed",sessionId:this.realSessionId,item:a,remaining:[...this.followUpQueue]})}catch(b){let a=b instanceof Error?b.message:String(b);this.emit({type:"follow_up_flush_error",errorMessage:a}),this.abortFollowUpFlush()}}removeDeliveredFollowUp(){if(this.followUpFlushAsOne){let a=new Set(this.followUpFlushOriginal),b=this.followUpQueue.filter(b=>!a.has(b));return b.length!==this.followUpQueue.length&&(this.updateFollowUpQueue(b),this.persistFollowUpQueue(),!0)}let a=this.followUpFlushBatch[this.followUpFlushCursor];if(void 0===a)return!1;let b=this.followUpQueue.indexOf(a);if(b<0)return!1;let c=[...this.followUpQueue];return c.splice(b,1),this.updateFollowUpQueue(c),this.persistFollowUpQueue(),!0}confirmFollowUpFlush(){if(!this.flushingFollowUp||this.followUpFlushConfirmed)return;let a=this.followUpFlushBatch[this.followUpFlushCursor];if(void 0===a)return;this.followUpFlushConfirmed=!0,this.removeDeliveredFollowUp();let b=[...this.followUpQueue];(this.persistFollowUpQueue(),this.emit({type:"follow_up_flushed",sessionId:this.realSessionId,item:a,remaining:b}),this.followUpFlushAsOne)?this.finishFollowUpFlush():(this.followUpFlushCursor+=1,this.followUpFlushCursor>=this.followUpFlushBatch.length?this.finishFollowUpFlush():this.sendNextFollowUp())}abortFollowUpFlush(){this.flushingFollowUp&&(this.flushingFollowUp=!1,this.followUpFlushBatch=[],this.followUpFlushCursor=0,this.followUpFlushConfirmed=!1,this.followUpFlushAsOne=!1,this.followUpFlushOriginal=[],this.persistFollowUpQueue(),this.resetIdleTimer())}finishFollowUpFlush(){this.flushingFollowUp=!1,this.followUpFlushBatch=[],this.followUpFlushCursor=0,this.followUpFlushConfirmed=!1,this.followUpFlushAsOne=!1,this.followUpFlushOriginal=[],this.persistFollowUpQueue(),this.resetIdleTimer(),this.followUpQueue.length>0&&!this.isFollowUpHeld()&&this.scheduleFollowUpFlush()}get session(){if(!this.runtime)throw Error("SDK session is not alive");return this.runtime.session}get services(){if(!this.runtime)throw Error("SDK session is not alive");return this.runtime.services}syncIdentityFromSession(){let a=this.session,b=a.sessionId||this.realSessionId,c=a.sessionFile||this.realSessionFile,d=this.realSessionId;this.realSessionId=b,this.realSessionFile=c,c&&this.options.cacheSessionPath?.(b,c),d!==b&&this.options.onSessionRekeyed?.(d,b,this)}async rebindSession(){let a=this.session;this.extensionUi?.dispose(),this.extensionUi=(0,m.t)(a=>{this.trackExtensionSideEffects(a),this.emit(a)}),await a.bindExtensions({uiContext:this.extensionUi.uiContext,mode:"rpc",commandContextActions:{waitForIdle:()=>a.waitForIdle(),newSession:async a=>{let b=await this.runtime.newSession(a);return b.cancelled||await this.rebindSession(),b},fork:async(a,b)=>{let c=await this.runtime.fork(a,b);return c.cancelled||await this.rebindSession(),{cancelled:c.cancelled}},navigateTree:async(b,c)=>({cancelled:(await a.navigateTree(b,{summarize:c?.summarize,customInstructions:c?.customInstructions,replaceInstructions:c?.replaceInstructions,label:c?.label})).cancelled}),switchSession:async(a,b)=>{let c=await this.runtime.switchSession(a,b);return c.cancelled||await this.rebindSession(),c},reload:async()=>{await a.reload()}},onError:a=>{this.setFollowUpHeld(!0),this.emit({type:"extension_error",extensionPath:a.extensionPath,event:a.event,error:a.error})}}),this.unsubscribe?.(),this.unsubscribe=a.subscribe(a=>{this.resetIdleTimer(),this.handleSessionEvent(a)}),this.syncIdentityFromSession()}trackExtensionSideEffects(a){if("extension_ui_request"!==a.type)return;let b=v(a.method);if("setStatus"===b){let b=v(a.statusKey)??v(a.key)??"default",c=v(a.statusText)??v(a.text)??"";c?this.extensionUi?.statuses.set(b,c):this.extensionUi?.statuses.delete(b)}if("setWidget"===b){let b=v(a.widgetKey)??v(a.key)??"default",c=a.widgetLines??a.content;null==c?this.extensionUi?.widgets.delete(b):this.extensionUi?.widgets.set(b,{lines:c,placement:a.widgetPlacement})}this.notifyRunning()}maybeAutoNameSession(){try{let a=this.session?.sessionManager;if(!a||a.getSessionName())return;let b=(a.buildSessionContext().messages??[]).find(a=>"user"===a.role),c=function(a){let b="";"string"==typeof a?b=a:Array.isArray(a)&&(b=a.filter(a=>"object"==typeof a&&null!==a&&"text"===a.type&&"string"==typeof a.text).map(a=>a.text).join("\n"));let c=b.replace(/\s+/g," ").trim();if(c)return c.length>60?`${c.slice(0,60)}…`:c}(b?.content);c&&a.appendSessionInfo(c)}catch{}}readStopReasonFromAgentEnd(a){let b=a.messages;if(!Array.isArray(b))return null;for(let a=b.length-1;a>=0;a--){let c=b[a],d=c?.message?.stopReason??c?.stopReason;if("string"==typeof d){if("aborted"===d)return"aborted";if("error"===d||"prompt_error"===d)return"error";return"completed"}}return null}removePendingBinaryBatch(a){this.pendingBinaryBatches=this.pendingBinaryBatches.filter(b=>b.submissionId!==a)}persistPendingBinaryBlocks(a){if(0!==a.length)try{let b=this.session.sessionManager;(0,l.kb)(b);let c=b.getEntries(),d=[...c].reverse().find(a=>"message"===a.type&&a.message?.role==="user"&&"string"==typeof a.id)?.id||b.getLeafId()||void 0;for(let c of a){let a=d?{...c,messageEntryId:d}:c,e=b.appendCustomEntry(q.uG,a);this.emit({type:"message_end",entryId:e,message:(0,q.FH)(a,Date.now())})}(0,l.kb)(b),this.options.onSessionListInvalidate?.()}catch(a){console.error("[pidance] persist binary message failed:",a)}}static hasRenderableContent(a){if(!a)return!1;let b=a.content;return"string"==typeof b?b.length>0:Array.isArray(b)&&b.length>0}static outputTokensOf(a){let b=a?.usage?.output;return"number"==typeof b&&Number.isFinite(b)&&b>=0?b:null}accumulateTurnMetrics(a){let b=Date.now();if("agent_start"===a.type){this.turnMetrics={startedAt:b,firstTokenAt:null,ttftMs:null,decodeMs:0,outputTokens:0,sampled:!1};return}if("message_start"===a.type||"message_update"===a.type){let c=a.message;if(c?.role==="user")return;null===this.turnMetrics.firstTokenAt&&x.hasRenderableContent(c)&&(this.turnMetrics.firstTokenAt=b,null===this.turnMetrics.ttftMs&&this.turnMetrics.startedAt>0&&b>=this.turnMetrics.startedAt&&(this.turnMetrics.ttftMs=b-this.turnMetrics.startedAt));return}if("message_end"===a.type){let c=a.message;if(c?.role!=="assistant")return;let d=null===this.turnMetrics.firstTokenAt?null:Math.max(0,b-this.turnMetrics.firstTokenAt);this.turnMetrics.firstTokenAt=null;let e=x.outputTokensOf(c);null!==d&&null!==e&&(this.turnMetrics.decodeMs+=d,this.turnMetrics.outputTokens+=e,this.turnMetrics.sampled=!0)}}projectTurnMetrics(){let a={};return null!==this.turnMetrics.ttftMs&&this.turnMetrics.startedAt>0&&(a.ttftMs=this.turnMetrics.ttftMs),this.turnMetrics.sampled&&this.turnMetrics.decodeMs>0&&(a.tokensPerSecond=this.turnMetrics.outputTokens/(this.turnMetrics.decodeMs/1e3)),a}handleSessionEvent(a){switch(this.accumulateTurnMetrics(a),a.type){case"agent_start":this.promptRunning=!0,(0,i.NK)(this.realSessionId,Date.now()),this.notifyRunning();break;case"agent_end":this.promptRunning=!1,this.lastStopReason=this.readStopReasonFromAgentEnd(a)??this.lastStopReason??"completed",("aborted"===this.lastStopReason||"error"===this.lastStopReason)&&this.setFollowUpHeld(!0),(0,i.PI)(this.realSessionId),this.options.onSessionListInvalidate?.(),this.realSessionFile&&(0,k.$9)(this.realSessionFile),this.maybeAutoNameSession(),this.notifyRunning(),this.emit({type:"prompt_done"});break;case"agent_settled":this.promptRunning=!1,this.notifyRunning(),"completed"===this.lastStopReason?this.flushingFollowUp?this.followUpFlushConfirmed?this.sendNextFollowUp():this.confirmFollowUpFlush():this.scheduleFollowUpFlush():this.flushingFollowUp&&("aborted"===this.lastStopReason||"error"===this.lastStopReason)&&this.abortFollowUpFlush();let b="agent_settled"===a.type&&!this.flushingFollowUp&&(0===this.followUpQueue.length||this.isFollowUpHeld());this.resetIdleTimer(),b&&this.destroyAsync();break;case"compaction_start":case"auto_compaction_start":this.notifyRunning();break;case"compaction_end":case"auto_compaction_end":this.notifyRunning(),!0!==a.aborted&&!a.errorMessage&&this.isSettled()&&this.scheduleFollowUpFlush(),this.resetIdleTimer();break;case"message_end":{let b=a.message;if(b?.role==="user"){this.confirmFollowUpFlush();let a=this.pendingBinaryBatches.shift();setImmediate(()=>{try{(0,l.kb)(this.session.sessionManager),this.syncIdentityFromSession(),this.persistPendingBinaryBlocks(a?.blocks??[]),this.options.onSessionListInvalidate?.()}catch(a){console.error("[pidance] materialize after user message failed:",a)}})}break}case"queue_update":{let b=Array.isArray(a.steering)?a.steering.filter(a=>"string"==typeof a):[],c=Array.isArray(a.followUp)?a.followUp.filter(a=>"string"==typeof a):[];this.localQueue={steering:b,followUp:c},this.hasQueueSnapshot=!0}}let c=a,d="message_end"===a.type&&a.message?.role==="assistant";if("agent_end"===a.type||d){let b=this.contextUsageSnapshot();b&&(c={...a,contextUsage:b})}this.emit(this.withRenderedToolLines(c))}contextUsageSnapshot(){try{let a=this.session.getContextUsage();if(a&&"number"==typeof a.contextWindow&&a.contextWindow>0)return{contextWindow:a.contextWindow,percent:"number"==typeof a.percent?a.percent:null,tokens:"number"==typeof a.tokens?a.tokens:null}}catch{}}withRenderedToolLines(a){try{if(!this.renderBridgeTheme)return a;switch(a.type){case"tool_execution_update":{if(!this.shouldRenderPartialUpdate(a.toolCallId))return a;let b=this.getToolRenderDefinition(a.toolName);if(!b)return a;let c=this.buildToolRenderContext(a.toolCallId,a.args??a.input,{isPartial:!0,expanded:!0,isError:!0===a.isError,resultSlot:!0});if(!c)return a;let d=(0,t.t_)(b,a.partialResult,{expanded:!0,isPartial:!0},c,b=>this.updateToolRenderLastComponent(a.toolCallId,!0,b));return d?{...a,renderedLines:d}:a}case"tool_call":{let b=this.getToolRenderDefinition(a.toolName);if(!b)return a;let c=this.buildToolRenderContext(a.toolCallId,a.input,{isPartial:!1,expanded:!0,isError:!1,resultSlot:!1});if(!c)return a;let d=(0,t.GD)(b,a.input,c,b=>this.updateToolRenderLastComponent(a.toolCallId,!1,b));return d?{...a,renderedCallLines:d}:a}case"tool_result":{let b=this.getToolRenderDefinition(a.toolName);if(!b)return a;let c=this.buildToolRenderContext(a.toolCallId,a.args??a.input,{isPartial:!1,expanded:!0,isError:!0===a.isError,resultSlot:!0});if(!c)return a;let d=(0,t.t_)(b,{content:a.content,details:a.details,isError:!0===a.isError,...void 0!==a.usage?{usage:a.usage}:{}},{expanded:!0,isPartial:!1},c,b=>this.updateToolRenderLastComponent(a.toolCallId,!0,b));return d?{...a,renderedResultLines:d}:a}case"message_start":case"message_end":{let b=a.message;if(b?.role!=="custom"||"string"!=typeof b.customType||""===b.customType)return a;let c=this.session.extensionRunner,d="function"==typeof c?.getMessageRenderer?c.getMessageRenderer(b.customType):void 0,e=(0,t.Mf)(d,a.message,this.renderBridgeTheme);return e?{...a,renderedLines:e}:a}default:return a}}catch{return a}}getToolRenderDefinition(a){if("string"==typeof a&&""!==a)try{return this.session.getToolDefinition(a)}catch{return}}buildToolRenderContext(a,b,c){let d=this.getOrCreateToolRenderState(a);return d?{args:b,toolCallId:a,invalidate:()=>{},lastComponent:c.resultSlot?d.lastResultComponent:d.lastCallComponent,state:d.state,cwd:this.realCwd,executionStarted:!0,argsComplete:!0,isPartial:c.isPartial,expanded:c.expanded,showImages:!1,isError:c.isError}:null}getOrCreateToolRenderState(a){if("string"!=typeof a||""===a)return null;let b=this.toolRenderStates.get(a);return b||(b={state:{},lastCallComponent:void 0,lastResultComponent:void 0,lastPartialRenderAt:void 0},this.toolRenderStates.set(a,b)),b}updateToolRenderLastComponent(a,b,c){if("string"!=typeof a||""===a)return;let d=this.toolRenderStates.get(a);d&&(b?d.lastResultComponent=c:d.lastCallComponent=c)}shouldRenderPartialUpdate(a){if("string"!=typeof a||""===a)return!0;let b=Date.now(),c=this.getOrCreateToolRenderState(a);return!c||(void 0===c.lastPartialRenderAt||!(b-c.lastPartialRenderAt<x.PARTIAL_RENDER_MIN_INTERVAL_MS))&&(c.lastPartialRenderAt=b,!0)}get realCwd(){try{return this.session.sessionManager.getHeader()?.cwd||this.options.cwd}catch{return this.options.cwd}}async start(){try{var a,b;let c=(a=this.realSessionFile,b=this.options.cwd,a?(0,l.G1)(a):(0,l.Qu)(b)),d=c.getCwd()||this.options.cwd,f=this.agentDir,g=this.activeToolNames,h=async({cwd:a,agentDir:b,sessionManager:c,sessionStartEvent:d})=>{let f=(0,s._D)({cwd:a,agentDir:b,appendBinary:a=>this.appendBinary(a,c)}),h={name:s.Jv,label:"Send file to user",description:"Publish an agent-created project file as a user-visible attachment with preview/download support.",promptSnippet:"deliver a generated file to the user as a downloadable attachment",promptGuidelines:["When the user needs a generated file, call send_file_to_user; do not only print a local path or paste Base64.","Only report a file as delivered after send_file_to_user returns successfully."],parameters:s.Tv,async execute(a,b,c){let d=await f(b,c);return{content:[{type:"text",text:`Delivered ${d.name} to the user (entry ${d.entryId}).`}],details:d}}},i=await (0,e.createAgentSessionServices)({cwd:a,agentDir:b,resourceLoaderOptions:{appendSystemPromptOverride:s.n3,extensionFactories:[a=>a.registerTool(h)]}});for(let a of i.modelRuntime.getModels())(0,o.yu)(a);return{...await (0,e.createAgentSessionFromServices)({services:i,sessionManager:c,sessionStartEvent:d,tools:g&&g.length>0?g:void 0,noTools:g&&0===g.length?"all":void 0}),services:i,diagnostics:i.diagnostics}};this.runtime=await (0,e.createAgentSessionRuntime)(h,{cwd:d,agentDir:f,sessionManager:c}),this.runtime.setRebindSession(async()=>{await this.rebindSession()}),this.runtime.setBeforeSessionInvalidate(()=>{this.extensionUi?.dispose(),this.unsubscribe?.(),this.unsubscribe=null}),await this.rebindSession(),this.syncIdentityFromSession(),this.hydrateFollowUpQueue(),this.startupHoldTimer=setTimeout(()=>{this.startupHoldTimer=null,this.startupHold=!1,this.resetIdleTimer()},15e3),this.startupHoldTimer.unref?.(),this.resetIdleTimer(),this.followUpQueue.length>0&&!this.isFollowUpHeld()&&this.isSettled()&&this.scheduleFollowUpFlush()}catch(a){throw await this.destroyAsync(),a}}projectState(){let a=this.session,b=a.model,c={stateSources:{rpcGetState:!1,sdkSession:!0,sessionStats:!0,localQueue:!0,localExtensionUi:!0},sessionId:this.realSessionId,sessionFile:this.realSessionFile,sessionName:a.sessionName,isStreaming:a.isStreaming,isCompacting:a.isCompacting,isPromptRunning:this.promptRunning,lastStopReason:this.lastStopReason,isBashRunning:this.bashRunning,turnMetrics:this.projectTurnMetrics(),pendingBash:this.bashCommand,autoCompactionEnabled:a.autoCompactionEnabled,steeringMode:a.steeringMode,followUpMode:a.followUpMode,thinkingLevel:a.thinkingLevel,systemPrompt:a.systemPrompt??"",model:b?{id:b.id,provider:b.provider,modelId:b.id}:void 0,messageCount:a.messages.length,pendingMessageCount:a.pendingMessageCount,extensionStatuses:Array.from(this.extensionUi?.statuses.entries()??[],([a,b])=>({key:a,text:b})),extensionWidgets:Array.from(this.extensionUi?.widgets.entries()??[],([a,b])=>({key:a,lines:Array.isArray(b?.lines)?b.lines:[],placement:b?.placement==="belowEditor"?"belowEditor":"aboveEditor"})),pendingExtensionRequests:Array.from(this.extensionUi?.pendingSnapshot.values()??[])};c.queuedMessages={steering:this.hasQueueSnapshot?[...this.localQueue.steering]:[],followUp:[...this.followUpQueue],followUpRevision:this.followUpQueueRevision};try{let b=a.getContextUsage();b&&"number"==typeof b.contextWindow&&b.contextWindow>0&&(c.contextUsage={contextWindow:b.contextWindow,percent:"number"==typeof b.percent?b.percent:null,tokens:"number"==typeof b.tokens?b.tokens:null})}catch{}return c}appendActivity(a){if(!this.runtime)throw Error("Cannot append activity: session not alive");let b=a&&"object"==typeof a&&"type"in a&&"append_activity"===a.type?(0,j.qF)(a):(0,j.l$)(a),c=this.session.sessionManager.appendCustomEntry(j.cP,b);return this.options.onSessionListInvalidate?.(),{entryId:c,activity:b}}appendBinary(a,b){if(!this._alive||!this.runtime||this.destroyPromise)throw Error("Cannot append binary message: session not alive");let c=this.session.sessionManager;if(b&&c!==b)throw Error("Cannot publish file after the session changed");let d=a&&"object"==typeof a&&!Array.isArray(a)?a:{},e="append_binary"===d.type?d.binaryBlock:a,f=(0,r.Nu)(e?[e]:void 0,this.agentDir)[0];if(!f)throw Error("binaryBlock is required");let g=c.appendCustomEntry(q.uG,f);try{this.options.onSessionListInvalidate?.()}catch(a){console.error("[pidance] binary message list notification failed:",a)}try{this.emit({type:"message_end",entryId:g,message:(0,q.FH)(f,Date.now())})}catch(a){console.error("[pidance] binary message event notification failed:",a)}return{entryId:g,binary:f}}async send(a){if(!this.runtime)throw Error("SDK session is not alive");let b=a.type;"get_state"!==b&&"ensure_session"!==b&&this.releaseStartupHold(),this.activeCommandCount+=1,this.resetIdleTimer();let c=this.session;try{switch(b){case"prompt":{let b=(0,p.JT)(a),d=this.promptReceipts.get(b.submissionId);if(d)return d;let e=b.submissionId,f=this.promptInFlight.get(e);if(f)return f;let g=(0,r.Nu)(b.binaryBlocks,this.agentDir);if(this.bashRunning)throw Error("Cannot send a prompt while a shell command is running");if(c.isCompacting){if(b.images?.length||g.length>0)throw Error("Media attachments cannot be queued while compaction is in progress");let a={submissionId:b.submissionId,sessionId:this.realSessionId,status:"accepted"};return this.updateFollowUpQueue([...this.followUpQueue,b.message]),this.promptReceipts.set(b.submissionId,a),this.persistFollowUpQueue(),this.options.onSessionListInvalidate?.(),a}if(!(0,h.kP)(this.realSessionId))throw Error(h.GT);this.promptRunning=!0,this.lastStopReason=null,(0,i.NK)(this.realSessionId,Date.now()),this.notifyRunning();let j=(async()=>{try{await new Promise((d,f)=>{let h=!1,j=()=>{c.isStreaming||c.isCompacting||this.bashRunning||this.promptRunning&&(this.promptRunning=!1,"aborted"!==this.lastStopReason&&"error"!==this.lastStopReason&&(this.lastStopReason="completed"),(0,i.PI)(this.realSessionId),this.notifyRunning(),this.emit({type:"prompt_done"}),this.resetIdleTimer())};c.prompt(b.message,{images:b.images??a.images,streamingBehavior:a.streamingBehavior,source:"rpc",preflightResult:a=>{a&&(h=!0,g.length>0&&this.pendingBinaryBatches.push({submissionId:e,blocks:g}),this.syncIdentityFromSession(),this.setFollowUpHeld(!1),this.options.onSessionListInvalidate?.(),d())}}).then(()=>{if(!h){h=!0;try{(0,l.kb)(c.sessionManager)}catch(a){console.error("[pidance] materialize after prompt failed:",a)}this.syncIdentityFromSession(),this.options.onSessionListInvalidate?.(),d()}j()}).catch(a=>{"aborted"!==this.lastStopReason&&(this.lastStopReason="error"),this.setFollowUpHeld(!0),j(),h||(h=!0,f(a))})});let d={submissionId:b.submissionId,sessionId:this.realSessionId,status:"accepted"};return this.promptReceipts.set(e,d),d}catch(d){this.removePendingBinaryBatch(e),this.promptRunning=!1,this.lastStopReason="aborted"===this.lastStopReason?"aborted":"error",this.setFollowUpHeld(!0),(0,i.PI)(this.realSessionId),this.notifyRunning();let a=d instanceof Error?d.message:String(d);this.emit({type:"prompt_error",errorMessage:a}),this.emit({type:"prompt_done"});let c={submissionId:b.submissionId,sessionId:this.realSessionId,status:"rejected"};throw this.promptReceipts.set(e,c),d}finally{this.promptInFlight.delete(e)}})();return this.promptInFlight.set(e,j),j}case"abort":return this.lastStopReason="aborted",this.setFollowUpHeld(!0),this.promptRunning=!1,this.notifyRunning(),await c.abort(),this.notifyRunning(),null;case"get_state":return this.projectState();case"set_model":{let b=String(a.provider??""),d=String(a.modelId??""),e=(0,n.E)(c.modelRuntime,b,d);if(!e)try{e=(await c.modelRuntime.getAvailable()).find(a=>a.provider===b&&a.id===d)}catch{e=void 0}if(!e)throw Error(`Model not found: ${b}/${d}`);return await c.setModel((0,o.eU)(e)),this.options.onSessionListInvalidate?.(),e}case"set_thinking_level":return c.model&&(0,o.yu)(c.model),c.setThinkingLevel(a.level),this.options.onSessionListInvalidate?.(),null;case"compact":{let b=await c.compact("string"==typeof a.customInstructions?a.customInstructions:void 0);return this.options.onSessionListInvalidate?.(),this.notifyRunning(),this.resetIdleTimer(),b}case"steer":{let b=String(a.message??"");if(!this.isRunning()&&!this.flushingFollowUp)return this.send({type:"prompt",message:b,images:a.images,streamingBehavior:"steer"});return await c.steer(b,a.images),null}case"set_follow_up_queue":{let b=Array.isArray(a.items)?a.items.filter(a=>"string"==typeof a&&a.trim().length>0):[];return this.flushingFollowUp&&this.abortFollowUpFlush(),this.updateFollowUpQueue(b),this.persistFollowUpQueue(),this.isSettled()&&b.length>0&&this.scheduleFollowUpFlush(),this.resetIdleTimer(),{ok:!0,queued:this.followUpQueue.length}}case"follow_up":return await c.followUp(String(a.message??""),a.images),null;case"set_session_name":{let b=String(a.name??"").trim();if(!b)throw Error("Session name cannot be empty");return c.setSessionName(b),this.options.onSessionListInvalidate?.(),null}case"set_auto_compaction":return c.setAutoCompactionEnabled(!!a.enabled),null;case"set_auto_retry":return c.setAutoRetryEnabled(!!a.enabled),null;case"clear_queue":return c.clearQueue();case"get_tools":{let a=c.getAllTools(),b=new Set(c.getActiveToolNames());return{source:"sdk",tools:a.map(a=>({name:a.name,description:a.description??"",active:b.has(a.name)}))}}case"set_tools":{let b=Array.isArray(a.tools)?a.tools.filter(a=>"string"==typeof a):[];return c.setActiveToolsByName(b),this.activeToolNames=b,null}case"get_commands":{let a=[];for(let b of c.extensionRunner.getRegisteredCommands())a.push({name:b.invocationName,description:b.description,source:"extension",sourceInfo:b.sourceInfo});for(let b of c.promptTemplates)a.push({name:b.name,description:b.description,source:"prompt_template"});try{let b=c.resourceLoader?.getSkills?.();for(let c of b?.skills??[])a.push({name:`skill:${c.name}`,description:c.description,source:"skill",sourceInfo:c.sourceInfo})}catch{}return{commands:a}}case"get_session_stats":return c.getSessionStats();case"bash":if(c.isStreaming)throw Error("Cannot run bash while agent is streaming");this.bashRunning=!0,this.bashCommand={command:String(a.command??""),excludeFromContext:!!a.excludeFromContext,startedAt:Date.now()},this.notifyRunning();try{return await c.executeBash(String(a.command??""),void 0,{excludeFromContext:!!a.excludeFromContext})}finally{this.bashRunning=!1,this.bashCommand=null,this.notifyRunning(),this.resetIdleTimer()}case"abort_bash":return c.abortBash(),this.bashRunning=!1,this.bashCommand=null,this.notifyRunning(),null;case"abort_compaction":return c.abortCompaction(),null;case"extension_ui_response":{let b=v(a.id);if(!b)throw Error("extension_ui_response requires id");let c={...a};return delete c.type,delete c.id,!this.extensionUi?.respond(b,c),this.notifyRunning(),null}case"extension_ui_input":{let b=v(a.id),c="string"==typeof a.data?a.data:"";return b&&this.extensionUi?.inputCustom(b,c),null}case"append_activity":return this.appendActivity(a);case"append_binary":return this.appendBinary(a);case"fork":{if(this.bashRunning)throw Error("Cannot fork while a shell command is running");let b=String(a.entryId??"");if(!b)throw Error("entryId is required");let c=await this.runtime.fork(b);return c.cancelled||(await this.rebindSession(),this.syncIdentityFromSession(),this.options.onSessionListInvalidate?.()),{cancelled:c.cancelled,newSessionId:c.cancelled?void 0:this.realSessionId,text:c.selectedText}}case"navigate_tree":{if(this.bashRunning)throw Error("Cannot navigate while a shell command is running");let b=v(a.targetId);if(!b)throw Error("targetId is required");let d=await c.navigateTree(b,{summarize:a.summarize,customInstructions:v(a.customInstructions)});if(!d.cancelled&&this.realSessionFile){c.sessionManager.getLeafId();let a=c.sessionManager.getLeafId(),b=c.sessionManager.getEntries(),d=b.at(-1)?.id;a&&d&&a!==d?(0,k.R3)(this.realSessionFile,a):this.realSessionFile&&(0,k.$9)(this.realSessionFile)}return this.options.onSessionListInvalidate?.(),{cancelled:d.cancelled}}case"select_leaf_exact":{let b=v(a.entryId);if(!b)throw Error("entryId is required");if(this.options.navigationActions)return this.options.navigationActions.selectLeafExact(this.sessionId,b);let d=await c.navigateTree(b,{summarize:!1});if(!d.cancelled&&this.realSessionFile){let a=c.sessionManager.getLeafId(),b=c.sessionManager.getEntries().at(-1)?.id;a&&b&&a!==b?(0,k.R3)(this.realSessionFile,a):(0,k.$9)(this.realSessionFile)}return{cancelled:d.cancelled}}case"branch_from_assistant":{let b=v(a.assistantEntryId);if(!b)throw Error("assistantEntryId is required");if(this.options.navigationActions)return this.options.navigationActions.branchFromAssistant(this.sessionId,b);throw Error("branch_from_assistant is unavailable")}case"create_session_from_leaf":{let b=v(a.entryId);if(!b)throw Error("entryId is required");if(this.options.navigationActions)return this.options.navigationActions.createSessionFromLeaf(this.sessionId,b);throw Error("create_session_from_leaf is unavailable")}case"set_branch_label":{let b=v(a.targetId);if(!b)throw Error("targetId is required");let d=void 0===a.label||null===a.label?void 0:String(a.label);return c.sessionManager.appendLabelChange(b,d),this.options.onSessionListInvalidate?.(),null}case"reload":return await c.reload(),await this.rebindSession(),null;case"get_last_assistant_text":return{text:c.getLastAssistantText()};case"ensure_session":return null;default:throw Error(`Unsupported command: ${b}`)}}finally{this.activeCommandCount=Math.max(0,this.activeCommandCount-1),0===this.activeCommandCount&&this.resetIdleTimer()}}destroy(){this.destroyAsync()}async destroyAsync(){if(this.destroyPromise)return this.destroyPromise;if(this._alive||this.runtime){if(this.activeCommandCount>0){if(this._scheduledRecheck)return;this._scheduledRecheck=!0,setTimeout(()=>{this._scheduledRecheck=!1,!this.destroyPromise&&this._alive&&this.destroyAsync()},0);return}return this._alive=!1,this.idleTimer&&clearTimeout(this.idleTimer),this.idleTimer=null,this.startupHoldTimer&&clearTimeout(this.startupHoldTimer),this.startupHoldTimer=null,this.startupHold=!1,this.destroyPromise=(async()=>{this.unsubscribe?.(),this.unsubscribe=null,this.extensionUi?.dispose(),this.extensionUi=null;let a=this.runtime;if(this.runtime=null,a)try{await a.dispose()}catch(a){console.error("[pidance] sdk runtime dispose error:",a)}this.promptRunning=!1,this.bashRunning=!1,this.bashCommand=null,this.flushingFollowUp=!1,this.followUpFlushBatch=[],this.followUpFlushCursor=0,this.followUpFlushConfirmed=!1,this.followUpFlushAsOne=!1,this.followUpFlushOriginal=[],(0,i.PI)(this.realSessionId),this.onDestroyCallback?.(),this.notifyRunning()})(),this.destroyPromise}}}async function w(a){let b=new x(a);return await b.start(),b}d()}catch(a){d(a)}})},5815:(a,b,c)=>{c.d(b,{MG:()=>h,NK:()=>f,PI:()=>g});let d="__piRunningStartedAt";function e(){let a=globalThis;return d in a&&a[d]instanceof Map||(a[d]=new Map),a[d]}function f(a,b){let c=e();c.has(a)||c.set(a,b)}function g(a){e().delete(a)}function h(){return e()}},26773:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{$k:()=>u,A4:()=>m,DU:()=>o,EM:()=>r,Fn:()=>t,HG:()=>q,OF:()=>w});var e=c(40402),f=c(95237);c(68524);var g=c(2416),h=c(5815),i=c(89953),j=a([e,f,g]);function k(){if(!globalThis.__piSessions){globalThis.__piSessions=new Map;let a=()=>{globalThis.__piSessions?.forEach(a=>a.destroy())};process.once("exit",a),process.once("SIGINT",a),process.once("SIGTERM",a)}return globalThis.__piSessions}function l(){return globalThis.__piStartLocks||(globalThis.__piStartLocks=new Map),globalThis.__piStartLocks}function m(a){return k().get(a)}function n(){return[...l().keys()]}async function o(a){let b=l().get(a);if(!b)return null;try{return(await b).realSessionId}catch{return null}}function p(){let a=new Set(n());for(let[b,c]of k())c.isRunning()&&a.add(c.sessionId||b);return[...a]}function q(){return p()}[e,f,g]=j.then?(await j)():j;let y=new Map;function r(a,b=Date.now()){let c={},d=(0,h.MG)(),e=p(),f=new Set(e);for(let a of e){let e=d.get(a)??y.get(a)??b;y.set(a,e),c[a]=e}for(let a of[...y.keys()])f.has(a)||y.delete(a);return c}function s(){return globalThis.__piRunningListeners||(globalThis.__piRunningListeners=new Set),globalThis.__piRunningListeners}function t(a){let b=s();return b.add(a),()=>{b.delete(a)}}function u(){let a=[];for(let[b,c]of k()){let d=c.listPendingExtensionRequests();0!==d.length&&a.push({sessionId:c.sessionId||b,requests:d})}return a}let z="",A=new Set,B=null;function v(){!function a(){let b=new Set(function(){let a=new Set(n());for(let[b,c]of k())c.isAlive()&&a.add(c.sessionId||b);return[...a]}());for(let a of b)(0,i.AZ)(a),A.add(a);for(let a of[...A])b.has(a)||((0,i.Hl)(a),A.delete(a));if(0===b.size){B&&(clearInterval(B),B=null);return}B||(B=setInterval(()=>{a()},8e3),B.unref?.())}();let a=q(),b=u(),c=JSON.stringify({ids:[...a].sort(),pending:b.map(a=>({sessionId:a.sessionId,ids:a.requests.map(a=>a.id??null)}))});if(c!==z)for(let b of(z=c,s()))try{b(a)}catch{}}async function w(a,b,c,d,e){return x(a,b,c,d,e)}async function x(a,b,c,d,f){let h=k(),j=l(),m=h.get(a);if(m?.isAlive())return{session:m,realSessionId:a};let n=j.get(a);if(n)return n;if(!(0,i.kP)(a))throw Error(i.GT);v();let o=(async()=>{try{let j=await (0,g.j1)({sessionId:a,sessionFile:b,cwd:c,toolNames:d,navigationActions:f,onRunningChange:()=>v(),onSessionListInvalidate:()=>(0,e.mD)(),cacheSessionPath:(a,b)=>(0,e.O8)(a,b),onSessionRekeyed:(a,b,c)=>{let d;d=k(),a!==b&&d.delete(a),d.set(b,c),a!==b&&((0,i.kP)(b),(0,i.Hl)(a))}}),l=j.sessionId,m=j.sessionFile;return m&&(0,e.O8)(l,m),l!==a&&(0,i.kP)(l),j.onDestroy(()=>{h.get(l)===j&&h.delete(l),a!==l&&h.get(a)===j&&h.delete(a),(0,i.Hl)(l),a!==l&&(0,i.Hl)(a),v()}),h.set(l,j),j.beginExtensionBinding(),{session:j,realSessionId:l}}catch(b){throw(0,i.Hl)(a),v(),b}})().finally(()=>{j.delete(a),v()});return j.set(a,o),o}d()}catch(a){d(a)}})},28121:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{Jv:()=>r,Tv:()=>t,_D:()=>q,n3:()=>n});var e=c(89477),f=c(42524),g=c(86697),h=c(26238),i=c(69835),j=c(80547),k=c(1060),l=c(60185),m=a([i,j,l]);[i,j,l]=m.then?(await m)():m;let r="send_file_to_user",s="## Pidance file delivery\nWhen the `send_file_to_user` tool is available and you create a file that the user needs to view, download, or play, call it instead of only printing a local path or embedding Base64. The tool publishes a user-visible attachment message: images keep the original for preview and download, audio/video follow the UI playback size policy, and other files get a download card. Only claim that a file was sent after the tool returns success.";function n(a){return a.some(a=>a===s)?a:[...a,s]}let t={type:"object",additionalProperties:!1,properties:{path:{type:"string",description:"Absolute or current-project-relative path of the file to deliver."},name:{type:"string",description:"Optional filename shown to the user; the source basename is used by default."}},required:["path"]};function o(a){if(a?.aborted)throw a.reason instanceof Error?a.reason:Error("file delivery aborted")}async function p(a,b){let c,d;if("string"!=typeof a||!a.trim())throw Error("path is required");let f=(0,g.resolve)(b,a.trim()),h=(0,j.bk)()?null:await (0,j.mc)();if(h&&!(0,j.A$)(f,h))throw Error("file path is not allowed");try{c=(0,e.lstatSync)(f)}catch{throw Error("file not found")}if(c.isSymbolicLink())throw Error("symbolic-link sources are not allowed");if(!c.isFile())throw Error("path must be a regular file");try{d=(0,e.realpathSync)(f)}catch{throw Error("file path could not be resolved")}if(h&&!(0,j.A$)(d,h))throw Error("file path is not allowed");return{path:d,stat:c}}function q(a){return async function(b,c){let d;o(c);let j=await p(b.path,a.cwd),m=j.path,n="string"==typeof b.name&&b.name.trim()?b.name.trim():(0,g.basename)(m),q="number"==typeof e.constants.O_NOFOLLOW?e.constants.O_NOFOLLOW:0,r="number"==typeof e.constants.O_NONBLOCK?e.constants.O_NONBLOCK:0,s=await (0,f.open)(m,e.constants.O_RDONLY|q|r);try{let b=await s.stat();if(!b.isFile())throw Error("path must be a regular file");if(0!==j.stat.dev&&0!==j.stat.ino&&(b.dev!==j.stat.dev||b.ino!==j.stat.ino))throw Error("file changed during open");if(b.size>i.Gt)throw Error(`file exceeds ${i.Gt} bytes`);o(c);let f=(0,e.createReadStream)("",{fd:s.fd,autoClose:!1,signal:c});d=await (0,i.xd)(n,h.Readable.toWeb(f),a.agentDir,i.Gt),o(c);let g=(0,l.iU)({path:d.path,name:d.name,mimeType:(0,k.cV)(m)??(0,k.X)(m)??(0,k.k2)(m)??(0,k.oC)(m)??({txt:"text/plain",md:"text/markdown",json:"application/json",csv:"text/csv",html:"text/html",xml:"application/xml",zip:"application/zip",gz:"application/gzip",tar:"application/x-tar"})[(0,k.GO)(m)]??"application/octet-stream",size:d.size},a.agentDir),{entryId:p}=a.appendBinary(g);return d=void 0,{entryId:p,name:g.name,size:g.size}}finally{if(await s.close().catch(()=>{}),d)try{(0,e.unlinkSync)(d.path)}catch{}}}}d()}catch(a){d(a)}})},31524:(a,b,c)=>{c.d(b,{Ut:()=>e,eU:()=>f,yu:()=>g});let d=["off","minimal","low","medium","high","xhigh","max"];function e(a,b){return a?d.filter(a=>b?.[a]!==null):["off"]}function f(a){if(!a.reasoning)return a;let b=a.thinkingLevelMap,c={...b??{}},d=!1;for(let a of["xhigh","max"])Object.prototype.hasOwnProperty.call(c,a)&&void 0!==c[a]||(c[a]=a,d=!0);return!d&&b?a:{...a,thinkingLevelMap:c}}function g(a){let b=f(a);if(b===a)return a;try{return a.thinkingLevelMap=b.thinkingLevelMap,a}catch{return b}}},37594:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{C9:()=>G,DQ:()=>F,Md:()=>E,Yz:()=>D,mB:()=>J});var e=c(29021),f=c(33873),g=c(80547),h=c(60396),i=c(95237),j=c(52960),k=c(79495),l=c(81879),m=c(46935),n=c(31514),o=c(65107),p=c(56429),q=c(40402),r=c(85664),s=c(15461),t=c(76817),u=c(86226),v=c(68524),w=c(89953),x=c(50955),y=c(40239),z=c(5815),A=c(26773),B=c(68816),C=a([g,i,l,p,q,A]);[g,i,l,p,q,A]=C.then?(await C)():C;let F="Subagent sessions are read-only";class G extends Error{constructor(){super(F)}toString(){return this.message}}async function D(a,b){if(await b(a))throw new G}function E(a){let b=a instanceof Error?a.message:String(a);return a instanceof G||b===F?403:b.includes("Session not found")?404:(0,w.wE)(a)||b===w.GT||"Session is being deleted"===b||b.includes("closed while its title")?409:500}let H={listAllSessions:q.dQ,resolveSessionPath:q.os,getRpcSession:p.A4,waitForSessionStart:p.DU,startRpcSession:p.OF,getRunningRpcSessionIds:p.HG,listPendingExtensionUi:p.$k,subscribeRunningSessions:p.Fn,allowFileRoot:g.wz,invalidateSessionListCache:q.mD,openSessionCwd:a=>(0,i.kW)(a).getHeader()?.cwd??process.cwd(),openSessionManager:a=>(0,q.Zx)({filePath:a}),openSessionView:i.kW,reparentSessionFile:i.i5,existsSync:e.existsSync,now:()=>Date.now(),archiveFs:y.Iq},I=["systemPrompt"],J=function(a={}){let b={...H,...a},c=(0,y.Ki)({fs:b.archiveFs,agentDir:b.archiveAgentDir,resolveSessionPath:b.resolveSessionPath,readSessionHeader:q.eP,isReadOnly:async a=>{let c=(await b.listAllSessions()).find(b=>b.id===a);return c?.readOnly===!0},isRunning:a=>b.getRunningRpcSessionIds().includes(a),getSessionInfo:async a=>(await b.listAllSessions()).find(b=>b.id===a)??null,invalidateSessionListCache:b.invalidateSessionListCache,now:()=>new Date(b.now()).toISOString()}),d=()=>(0,y.$T)(b.archiveFs??y.Iq,b.archiveAgentDir?.()??(0,h.$M)()),g=new Map,p=async a=>{let c=b.getRpcSession(a);if(c){if("function"==typeof c.destroyAsync)return void await c.destroyAsync();c.isAlive()&&c.destroy()}},C=async(a,b)=>{if(!(0,w.kP)(a))throw Error(w.GT);try{return await b()}finally{(0,w.Hl)(a)}},E=async(a,b)=>(await p(a),C(a,b)),F={async listSessions(){let a=await b.listAllSessions(),{active:c,archived:e}=(0,y.uD)(a,d());return{sessions:c,archivedSessions:e,archivedCount:e.length,runningSessionIds:b.getRunningRpcSessionIds()}},async listArchivedSessions(){let a=await b.listAllSessions();return(0,y.uD)(a,d()).archived},async listActiveSessions(){let a=await b.listAllSessions();return(0,y.uD)(a,d()).active},listAllSessions:async()=>b.listAllSessions(),async isArchived(a){let c=await b.listAllSessions();return(0,y.YV)(c,d()).has(a)},archiveSession:async a=>c.archiveSession(a),restoreSession:async a=>c.restoreSession(a),archiveSessions:async a=>c.archiveSessions(a),restoreSessions:async a=>c.restoreSessions(a),removeArchiveRecordAfterPermanentDelete(a){(0,y.rQ)(b.archiveFs??y.Iq,b.archiveAgentDir?.()??(0,h.$M)(),a)},resolvePath:a=>b.resolveSessionPath(a),getSessionInfo:async a=>a&&"string"==typeof a?(await b.listAllSessions()).find(b=>b.id===a)??null:null,async isReadOnly(a){let c=(await b.listAllSessions()).find(b=>b.id===a);return c?.readOnly===!0},async getReadView(a){let c=await b.resolveSessionPath(a);if(!c)return null;let d=b.getRpcSession(a),e=d?.inner;return d?.isAlive()&&e?.sessionManager?{source:"live",filePath:c,manager:e.sessionManager}:{source:"disk",filePath:c,manager:b.openSessionManager(c)}},getLive(a){let c=b.getRpcSession(a);return c?.isAlive()?c:void 0},getLiveSession:a=>F.getLive(a),isLive:a=>!!F.getLive(a),async ensureLive(a){if(await D(a,F.isReadOnly),g.has(a))throw Error("Session is being deleted");let c=F.getLive(a);if(c)return c;if((0,w.wy)(a))throw Error(w.GT);let d=await b.resolveSessionPath(a);if(!d)throw Error("Session not found");let e=b.openSessionCwd(d),{session:f}=await b.startRpcSession(a,d,e,void 0,G);return f},destroy(a){b.getRpcSession(a)?.destroy()},async destroyAsync(a){let c=b.getRpcSession(a);c&&("function"==typeof c.destroyAsync?await c.destroyAsync():c.destroy())},deleteSession(a){let c=g.get(a);if(c)return c;let d=(async()=>{await D(a,F.isReadOnly);let c=await b.waitForSessionStart?.(a)??a,d=await b.resolveSessionPath(a);if(!d){try{(0,v.xP)(`sessionQueue.${a}`,null),(0,v.xP)(`sessionQueueHold.${a}`,null)}catch(a){console.error("[pidance] failed to clear queue prefs after missing delete:",a)}return(0,q.BR)(a),b.invalidateSessionListCache(),F.removeArchiveRecordAfterPermanentDelete(a),{skippedSubagents:0}}if((0,w.wy)(a)||(0,w.wy)(c))throw Error(w.GT);let g=(0,q.eP)(d)?.parentSession,h=(0,q.eP)(d)?.id===a?(0,x.ku)(d,a):[],i=b.getRpcSession(c)??b.getRpcSession(a),j=b.getRunningRpcSessionIds();if(i?.isAlive?.()&&(j.includes(a)||j.includes(c)))try{await i.send({type:"abort"})}catch(a){console.error("[pidance] abort before delete failed:",a)}return await F.destroyAsync(i?.sessionId??c),C(i?.sessionId??c,async()=>{let c=d.replace(/\\/g,"/").split("/").slice(0,-1).join("/");try{for(let a of(0,e.readdirSync)(c).filter(a=>a.endsWith(".jsonl")&&(0,f.join)(c,a)!==d)){let e=(0,f.join)(c,a);try{let a=(0,q.eP)(e);a?.type==="session"&&a.parentSession===d&&(a.id?(await b.waitForSessionStart?.(a.id),await E(a.id,()=>{b.reparentSessionFile(e,g)})):b.reparentSessionFile(e,g))}catch{}}}catch{}try{(0,e.unlinkSync)(d)}catch(a){if("ENOENT"!==a.code)throw a}(0,o.$9)(d);let i=(0,f.resolve)(d.slice(0,-6)),j=(0,x.uq)(h,i,q.BR);try{(0,v.xP)(`sessionQueue.${a}`,null),(0,v.xP)(`sessionQueueHold.${a}`,null)}catch(a){console.error("[pidance] failed to clear queue prefs after delete:",a)}return(0,q.BR)(a),b.invalidateSessionListCache(),F.removeArchiveRecordAfterPermanentDelete(a),{skippedSubagents:j}})})();return g.set(a,d),d.finally(()=>{g.get(a)===d&&g.delete(a)})},async start(a,c,d,e){if(await D(a,F.isReadOnly),g.has(a))throw Error("Session is being deleted");return b.startRpcSession(a,c,d,e,G)},send:async(a,b)=>(await F.ensureLive(a)).send(b),async submitPrompt(a,b){await D(a,F.isReadOnly);let c=(0,j.JT)(b);try{let b=await F.send(a,c);if(b&&"object"==typeof b&&b.status)return b;return{submissionId:c.submissionId,sessionId:a,status:"accepted"}}catch(b){if((0,w.wE)(b))throw b;return{submissionId:c.submissionId,sessionId:a,status:"rejected"}}},async getAgentState(a,b){if(await F.isReadOnly(a))return{live:!1,activeRun:!1,readOnly:!0};let c=F.getLive(a);if(!c)return{live:!1,activeRun:!1,...(0,w.wy)(a)?{lockedByOther:!0}:{}};let d=await c.send({type:"get_state"}),e="function"==typeof c.isRunning?!!c.isRunning():!!(d&&(d.isStreaming||d.isPromptRunning||d.isCompacting||d.isBashRunning));return{live:!0,activeRun:e,lockedByOther:!1,state:function(a,b){if(!b?.light||!a||"object"!=typeof a||Array.isArray(a))return a;let c={...a};for(let a of I)delete c[a];return c}(d,b)}},async renameSession(a,c){await D(a,F.isReadOnly);let d=c.trim();if(!d)throw Error("name is required");let e=F.getLive(a);if(e?.isAlive()){await e.send({type:"set_session_name",name:d}),b.invalidateSessionListCache();return}let f=await b.resolveSessionPath(a);if(!f)throw Error("Session not found");await E(a,()=>{b.openSessionView(f).appendSessionInfo(d),b.invalidateSessionListCache()})},async autoNameSession(a){await D(a,F.isReadOnly);let b=await F.ensureLive(a);await b.waitUntilReady?.();let c=await F.getNavigationSnapshot(a);if(!c)throw Error("Session not found");let d=c.context.messages??[],e=(0,k.CL)(),f=await (0,k.K)({messages:d,provider:e.provider,modelId:e.modelId,baseUrl:e.baseUrl,api:e.api,apiKey:e.apiKey,headers:e.headers});if(!b.isAlive())throw Error("The session was closed while its title was being generated. Please try again.");try{await b.send({type:"set_session_name",name:f.title})}catch{await F.destroyAsync(a),await F.renameSession(a,f.title)}return{title:f.title,usage:f.usage??null}},async exportSession(a,c){let d=await b.resolveSessionPath(a);if(!d)throw Error("Session not found");return(0,l.by)(d,c)},async getNavigationSnapshot(a,c={}){let d=await F.getReadView(a);if(!d)return null;let{filePath:e,manager:f}=d,{leafId:g,tree:h,context:i,header:j,sessionName:k}=(0,q.jK)(f,c),l=j?.parentSession?await (0,q.u1)(j.parentSession):void 0,m=(await b.listAllSessions()).find(b=>b.id===a),n=j?{path:e,id:j.id,cwd:j.cwd??"",name:k,created:j.timestamp,modified:j.timestamp,messageCount:i.totalMessageCount??i.messages.length,firstMessage:m?.firstMessage??"(no messages)",parentSessionId:l,...m?.subagent?{subagent:m.subagent,readOnly:!0}:{}}:null;return{filePath:e,leafId:g,tree:h,context:i,header:j,sessionName:k,parentSessionId:l,info:n}},async getContextPage(a,b){let c=await F.getReadView(a);if(!c)return{context:null};let d=c.manager,e=d.getEntries?.()??[],f=(0,q.Uv)(e,b.leafId,{deferThinking:b.deferThinking,deferToolResultImages:b.deferToolResultImages}),g=b.limit;return{context:b.before?(0,m.tr)(f,b.before,g??m._w):null!==g?(0,m.G1)(f,g):{...f,hasMoreBefore:!1,totalMessageCount:f.messages.length}}},async getEntryThinking(a,b,c){let d=await F.getReadView(a);if(!d)return null;let e=d.manager.getEntries().find(a=>a.id===b);if(!e||"message"!==e.type||e.message?.role!=="assistant")return null;let f=e.message.content?.[c];return f&&(0,n.mv)(f.type)?{thinking:(0,n.Ux)(f)}:null},async getToolResultDetails(a,b){let c=await F.getReadView(a);if(!c)return null;let d=c.manager.getEntries().find(a=>"message"===a.type&&a.message?.role==="toolResult"&&a.message.toolCallId===b);return d?{details:d.message?.details??null,content:Array.isArray(d.message?.content)?d.message.content:[]}:null},async appendActivity(a,c){await D(a,F.isReadOnly);let d=F.getLive(a),e=!!d?.inner?.sessionManager,f=d?.appendActivity;return d?.isAlive()&&e&&"function"==typeof f?await f.call(d,c):await E(a,async()=>{let d=await b.resolveSessionPath(a);if(!d)throw Error("Session not found");let e=(0,r.l$)(c),f=b.openSessionView(d).appendCustomEntry(r.cP,e);return b.invalidateSessionListCache(),{entryId:f,activity:e}})},appendCommandEntry:async(a,c)=>(await D(a,F.isReadOnly),await E(a,async()=>{let d=await b.resolveSessionPath(a);if(!d)throw Error("Session not found");let e=(0,s.fc)(c);if(!e.command)throw Error("command is required");let f=b.openSessionView(d).appendCustomEntry(s.OE,e);return b.invalidateSessionListCache(),{entryId:f,data:e}})),async createNew({cwd:a,command:c}){if(!a||"string"!=typeof a)throw Error("cwd is required");if(!b.existsSync(a))throw Error(`Directory does not exist: ${a}`);let{provider:d,modelId:e,toolNames:f,thinkingLevel:g,...h}=c,j=`__new__${b.now()}`,{session:k,realSessionId:l}=await b.startRpcSession(j,"",a,f,G);if(b.allowFileRoot(a),b.invalidateSessionListCache(),d&&e&&await k.send({type:"set_model",provider:d,modelId:e}),g&&await k.send({type:"set_thinking_level",level:g}),"ensure_session"===h.type){try{let a=k.inner,b=a?.sessionManager;b&&"function"==typeof b.getSessionFile&&(0,i.kb)(b)}catch(a){console.error("[pidance] materialize ensure_session failed:",a)}return{sessionId:l,data:null}}let m=await k.send(h);return{sessionId:l,data:m}},getRunningIds:()=>b.getRunningRpcSessionIds(),getRunningStartedAt(){let a=new Set(b.getRunningRpcSessionIds()),c={};for(let[b,d]of(0,z.MG)())a.has(b)&&(c[b]=d);for(let[b,d]of Object.entries((0,A.EM)()))!a.has(b)||b in c||(c[b]=d);return c},async searchFulltext(a,c={}){let d=await (0,B.s)(a,{limits:void 0!==c.maxHits?{maxHits:c.maxHits}:void 0}),e=c.scope??"active";if("all"===e)return d;let f=await b.listAllSessions(),g=(0,y.$T)(b.archiveFs??y.Iq,b.archiveAgentDir?.()??(0,h.$M)()),i=(0,y.mT)(d.sessionIds,f,g,e);return{...d,sessionIds:d.sessionIds.filter(a=>i.has(a)),hits:d.hits.filter(a=>i.has(a.sessionId))}},listPendingExtensionUi:()=>b.listPendingExtensionUi(),subscribeRunning:a=>b.subscribeRunningSessions(a),async selectLeafExact(a,c){if("string"!=typeof c||""===c.trim())throw Error("entryId is required");let d=c.trim(),e=b.getRpcSession(a);if(e?.isAlive?.()&&e.inner?.isBashRunning)throw Error("Cannot switch branch while a shell command is running");return E(a,async()=>{let c=await b.resolveSessionPath(a);if(!c)throw Error("Session not found");let e=b.openSessionView(c),f=e.getLeafId();if(d===f)return{cancelled:!1};if(d===e.getLastEntryId())return(0,o.$9)(c),{cancelled:!1};if(!e.getEntry(d))throw Error(`Entry ${d} not found`);try{return e.branch(d),(0,o.R3)(c,d),{cancelled:!1}}finally{b.invalidateSessionListCache()}})},async branchFromAssistant(a,c){if("string"!=typeof c||""===c.trim())throw Error("assistantEntryId is required");let d=c.trim(),e=b.getRpcSession(a);if(e?.isAlive?.()&&e.inner?.isBashRunning)throw Error("Cannot branch while a shell command is running");return E(a,async()=>{let c=await b.resolveSessionPath(a);if(!c)throw Error("Session not found");let e=b.openSessionView(c),f=e.getLeafId();if(!f)throw Error("Session has no leaf");let g=e.getBranch(f),h=e.getEntry(d);if(!h)throw Error("Entry not found");if("message"!==h.type||h.message?.role!=="assistant")throw Error("Only assistant messages can be branched from");let i=(0,t.wo)(g,d);try{return e.branch(i),i===e.getLastEntryId()?(0,o.$9)(c):(0,o.R3)(c,i),{cancelled:!1}}finally{b.invalidateSessionListCache()}})},async createSessionFromLeaf(a,c){if("string"!=typeof c||""===c.trim())throw Error("entryId is required");let d=c.trim(),e=b.getRpcSession(a),f=e?.inner;return E(a,async()=>{let c=(f?.sessionFile||e?.sessionFile)??await b.resolveSessionPath(a);if(!c)throw Error("Session not found");let g=(0,i.kW)(c),h=g.getEntry(d);if(!h)throw Error("Invalid entry ID");let j=d;if("message"===h.type&&h.message?.role==="assistant"){let a=g.getLeafId();if(!a)throw Error("Session has no leaf");let b=g.getBranch(a);j=(0,t.wo)(b,d)}let k=g.getSessionDir(),l=(0,i.G1)(c,k),m=l.createBranchedSession(j);if(!m)throw Error("Failed to create session");(0,i.kb)(l);let n=(0,i.kW)(m,k),o=n.getSessionId();(0,q.O8)(o,m),b.invalidateSessionListCache();let p=f?.model;return p&&(0,u.yN)(n.getEntries().some(a=>"model_change"===a.type),{provider:p.provider,modelId:p.id})&&n.appendModelChange(p.provider,p.id),{cancelled:!1,newSessionId:o}})}},G={selectLeafExact:(a,b)=>F.selectLeafExact(a,b),branchFromAssistant:(a,b)=>F.branchFromAssistant(a,b),createSessionFromLeaf:(a,b)=>F.createSessionFromLeaf(a,b)};return F}();d()}catch(a){d(a)}})},38195:(a,b,c)=>{c.d(b,{t:()=>g});var d=c(716),e=c(87538);function f(a,b,c,e,f,g,h){let i=(0,d.randomUUID)();return new Promise((d,j)=>{let k,l=!1,m=()=>{a.delete(i),b.delete(i),k&&clearTimeout(k),e?.signal?.removeEventListener("abort",o)},n=a=>{l||(l=!0,m(),d(a))},o=()=>n(f);e?.signal?.addEventListener("abort",o,{once:!0}),e?.timeout&&(k=setTimeout(()=>n(f),e.timeout)),a.set(i,{resolve:a=>{try{n(h(a))}catch(a){if(l)return;l=!0,m(),j(a instanceof Error?a:Error(String(a)))}},reject:a=>{l||(l=!0,m(),j(a))}});let p={type:"extension_ui_request",id:i,...g};b.set(i,p),c(p)})}function g(a){let b=new Map,c=new Map,g=new Map,h=new Map,i=new Map,j={select:(d,e,g)=>f(b,c,a,g,void 0,{method:"select",title:d,options:e,timeout:g?.timeout},a=>"cancelled"in a&&a.cancelled?void 0:"value"in a?a.value:void 0),confirm:(d,e,g)=>f(b,c,a,g,!1,{method:"confirm",title:d,message:e,timeout:g?.timeout},a=>(!("cancelled"in a)||!a.cancelled)&&"confirmed"in a&&!!a.confirmed),input:(d,e,g)=>f(b,c,a,g,void 0,{method:"input",title:d,placeholder:e,timeout:g?.timeout},a=>"cancelled"in a&&a.cancelled?void 0:"value"in a?a.value:void 0),notify(b,c){a({type:"extension_ui_request",id:(0,d.randomUUID)(),method:"notify",message:b,notifyType:c})},onTerminalInput:()=>()=>{},setStatus(b,c){c?g.set(b,c):g.delete(b),a({type:"extension_ui_request",id:(0,d.randomUUID)(),method:"setStatus",statusKey:b,statusText:c})},setWorkingMessage(){},setWorkingVisible(){},setWorkingIndicator(){},setHiddenThinkingLabel(){},setWidget(b,c,f){if("function"==typeof c){let a=(0,e.tU)(c,(0,e.Lm)());if(null===a)return;c=a}(void 0===c||Array.isArray(c))&&(null==c?h.delete(b):h.set(b,{lines:c,placement:f?.placement}),a({type:"extension_ui_request",id:(0,d.randomUUID)(),method:"setWidget",widgetKey:b,widgetLines:c,widgetPlacement:f?.placement}))},setFooter(){},setHeader(){},setTitle(b){a({type:"extension_ui_request",id:(0,d.randomUUID)(),method:"setTitle",title:b})},async custom(b){let c=(0,d.randomUUID)();return new Promise(d=>{let f,g=!1,h=b=>{g||(g=!0,i.delete(c),a({type:"extension_ui_request",id:c,method:"custom",closed:!0,lines:[]}),d(b))},k=()=>{if(g)return;let b=[];try{let a=f?.render?.(92);Array.isArray(a)&&(b=a.filter(a=>"string"==typeof a))}catch(a){console.error("[pidance] custom UI render failed:",a)}a({type:"extension_ui_request",id:c,method:"custom",lines:b})};i.set(c,{handleInput:a=>{if("\x03"===a)return void h(void 0);try{f?.handleInput?.(a)}catch(a){console.error("[pidance] custom UI input failed:",a)}},done:h});let l=function(a,b=92,c=40){return Object.freeze({terminal:Object.freeze({columns:b,rows:c,kittyProtocolActive:!1}),requestRender:a})}(()=>{k()},92,40),m=(0,e.Lm)()??j.theme;Promise.resolve().then(()=>b(l,m,{},h)).then(a=>{g||(f=a,k())}).catch(a=>{console.error("[pidance] custom UI factory failed:",a),h(void 0)})})},pasteToEditor(a){this.setEditorText(a)},setEditorText(b){a({type:"extension_ui_request",id:(0,d.randomUUID)(),method:"set_editor_text",text:b})},getEditorText:()=>"",editor:async(d,e)=>f(b,c,a,void 0,void 0,{method:"editor",title:d,prefill:e},a=>"cancelled"in a&&a.cancelled?void 0:"value"in a?a.value:void 0),addAutocompleteProvider(){},setEditorComponent(){},getEditorComponent(){},get theme(){let a=a=>String(a??""),b=(a,b)=>void 0===b?"":String(b);return new Proxy({fg:b,bg:b,bold:a,dim:a,italic:a},{get:(b,c)=>c in b?b[c]:"then"!==c?a:void 0})},getAllThemes:()=>[],getTheme(){},setTheme:()=>({success:!1,error:"Theme switching not supported in Web mode"}),getToolsExpanded:()=>!1,setToolsExpanded(){}};return{uiContext:j,pending:b,statuses:g,widgets:h,pendingSnapshot:c,respond(a,c){let d=b.get(a);return!!d&&(d.resolve(c),!0)},inputCustom(a,b){let c=i.get(a);return!!c&&(c.handleInput(b),!0)},dispose(){for(let[a,d]of b)b.delete(a),c.delete(a),d.reject(Error("Extension UI disposed"));for(let a of i.values())a.done(void 0);i.clear(),g.clear(),h.clear()}}}},40239:(a,b,c)=>{c.d(b,{$T:()=>m,Iq:()=>g,J3:()=>t,Ki:()=>u,YV:()=>q,mT:()=>r,rQ:()=>p,uD:()=>s});var d=c(29021),e=c(33873),f=c(60396);let g={existsSync:d.existsSync,lstatSync:d.lstatSync,mkdirSync:d.mkdirSync,readFileSync:(a,b)=>(0,d.readFileSync)(a,b),writeFileSync:(a,b,c)=>(0,d.writeFileSync)(a,b,c),renameSync:d.renameSync,unlinkSync:d.unlinkSync,readdirSync:d.readdirSync};function h(a=(0,f.$M)()){return(0,e.join)(a,"pidance-archive")}function i(a){return"string"!=typeof a||a.length<8||a.length>64||!/^[0-9a-fA-F][0-9a-fA-F-]{7,63}$/.test(a)?null:`${a}.json`}function j(a,b){try{let c=h(b);if(!a.existsSync(c))return null;let d=a.lstatSync(c);if(d.isSymbolicLink()||!d.isDirectory())return null;return c}catch{return null}}function k(a){return"object"==typeof a&&null!==a&&!(1!==a.version||"string"!=typeof a.sessionId||0===a.sessionId.length||"string"!=typeof a.sessionPath||0===a.sessionPath.length||"string"!=typeof a.archivedAt||Number.isNaN(Date.parse(a.archivedAt)))}function l(a,b,c){let d=i(c);if(!d)return null;let f=j(a,b);if(!f)return null;let g=(0,e.join)(f,d);try{if(!a.existsSync(g)||a.lstatSync(g).isSymbolicLink())return null;let b=a.readFileSync(g,"utf8");if(b.length>65536)return null;let d=JSON.parse(b);if(!k(d)||d.sessionId!==c)return null;return d}catch{return null}}function m(a,b){let c=globalThis.__piArchiveRecordsCache;if(c&&Date.now()-c.ts<5e3)return c.records;let d=j(a,b),e=[];if(d){let c=[];try{c=a.readdirSync(d)}catch{c=[]}for(let d of c){let c=function(a){if("string"!=typeof a||!a.endsWith(".json"))return null;let b=a.slice(0,-5);return b.length<8||b.length>64||!/^[0-9a-fA-F][0-9a-fA-F-]{7,63}$/.test(b)?null:b}(d);if(!c)continue;let f=l(a,b,c);f&&e.push(f)}}return globalThis.__piArchiveRecordsCache={records:e,ts:Date.now()},e}function n(){globalThis.__piArchiveRecordsCache=void 0}function o(a,b,c){let d=i(c);if(!d)return!1;let f=j(a,b);if(!f)return!1;let g=(0,e.join)(f,d);try{if(!a.existsSync(g))return!1;return a.unlinkSync(g),n(),!a.existsSync(g)}catch{return!1}}function p(a,b,c){o(a,b,c)}function q(a,b){let c=new Map;for(let a of b)c.set(a.sessionId,a);let d=new Set;for(let b of a){let a=c.get(b.id);a&&a.sessionPath===b.path&&d.add(b.id)}return d}function r(a,b,c,d){let e=q(b,c),f=new Set;for(let b of a){let a=e.has(b);("active"===d?!a:a)&&f.add(b)}return f}function s(a,b){let c=q(a,b),d=new Map;for(let a of b)d.set(a.sessionId,a);let e=[],f=[];for(let b of a)if(c.has(b.id)){let a=d.get(b.id);f.push({...b,archivedAt:a?a.archivedAt:void 0})}else e.push(b);return{active:e,archived:f}}class t extends Error{constructor(){super("Session is running; cannot archive while active")}toString(){return this.message}}function u(a){let b=a.fs??g,c=()=>a.agentDir?.()??(0,f.$M)(),d=async d=>{if(await a.isReadOnly(d))throw Error("Subagent sessions are read-only");if(a.isRunning(d))throw new t;let f=await a.resolveSessionPath(d);if(!f)throw Error("Session not found");let g=a.readSessionHeader(f);if(!g||g.id!==d)throw Error("Session header id mismatch");let j={version:1,sessionId:d,sessionPath:f,archivedAt:a.now()};return!function(a,b,c){let d=i(c.sessionId);if(!d)throw Error("Invalid session id");if(!k(c))throw Error("Invalid archive record");let f=function(a,b){let c=h(b);try{a.existsSync(c)||a.mkdirSync(c,{recursive:!0});let b=a.lstatSync(c);if(b.isSymbolicLink()||!b.isDirectory())return null;return c}catch{return null}}(a,b);if(!f)throw Error("Archive directory unavailable");let g=(0,e.join)(f,d),j=(0,e.join)(f,`.${d}.${process.pid}.${Date.now().toString(36)}.tmp`);try{a.writeFileSync(j,JSON.stringify(c),{encoding:"utf8",flag:"wx"}),a.renameSync(j,g),n()}catch(b){try{a.existsSync(j)&&a.unlinkSync(j)}catch{}throw b}}(b,c(),j),a.invalidateSessionListCache(),j.archivedAt},j=async d=>{if(null===l(b,c(),d))throw Error("Session is not archived");if(!await a.resolveSessionPath(d))throw Error("Session not found");if(!o(b,c(),d))throw Error("Failed to remove archive record");return a.invalidateSessionListCache(),a.getSessionInfo(d)},m=async a=>{let b=[],c=[];for(let e of a)try{await d(e),b.push(e)}catch(a){c.push({id:e,error:a instanceof Error?a.message:String(a)})}return{succeededIds:b,failed:c}},p=async a=>{let b=[],c=[];for(let d of a)try{await j(d),b.push(d)}catch(a){c.push({id:d,error:a instanceof Error?a.message:String(a)})}return{succeededIds:b,failed:c}};return{archiveSession:d,restoreSession:j,archiveSessions:m,restoreSessions:p}}},46935:(a,b,c)=>{c.d(b,{G1:()=>h,NN:()=>g,Uf:()=>d,_w:()=>e,tr:()=>i});let d=80,e=80;function f(a,b){return"number"==typeof a&&Number.isFinite(a)?Math.max(1,Math.min(Math.floor(a),500)):b}function g(a,b=d){let c=a.get("limit")??a.get("tail");if(null===c||""===c)return null;let e=Number(c);return!Number.isFinite(e)||e<=0?b:f(e,b)}function h(a,b=d){let c=a.messages.length,e=f(b,d);if(c<=e)return{...a,hasMoreBefore:!1,totalMessageCount:c};let g=c-e;return{messages:a.messages.slice(g),entryIds:a.entryIds.slice(g),thinkingLevel:a.thinkingLevel,model:a.model,hasMoreBefore:!0,totalMessageCount:c}}function i(a,b,c=e){let d=a.messages.length,g=a.entryIds.indexOf(b);if(g<=0)return{messages:[],entryIds:[],thinkingLevel:a.thinkingLevel,model:a.model,hasMoreBefore:!1,totalMessageCount:d};let h=Math.max(0,g-f(c,e));return{messages:a.messages.slice(h,g),entryIds:a.entryIds.slice(h,g),thinkingLevel:a.thinkingLevel,model:a.model,hasMoreBefore:h>0,totalMessageCount:d}}},52960:(a,b,c)=>{c.d(b,{D_:()=>i,JT:()=>h,QR:()=>j});var d=c(13737);function e(){return"u">typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():`sub-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function f(a){if(void 0===a)return;if(!Array.isArray(a))throw Error("images must be an array");let b=[];for(let c of a){if(!c||"object"!=typeof c)throw Error("invalid image");let a="string"==typeof c.data?c.data:void 0,e="string"==typeof c.mimeType?c.mimeType:"string"==typeof c.mime_type?c.mime_type:void 0,f=(0,d.Ln)(e);if(!a||!f?.startsWith("image/"))throw Error("invalid image");if(a.length>4194304)throw Error("invalid image: payload too large");b.push({type:"image",data:a,mimeType:f})}return b}function g(a){if("string"!=typeof a.message)throw Error("message is required");return a.message}function h(a,b=e){return{type:"prompt",message:g(a),submissionId:"string"==typeof a.submissionId&&a.submissionId.trim()?a.submissionId.trim():b(),images:f(a.images),binaryBlocks:function(a){if(void 0===a)return;if(!Array.isArray(a))throw Error("binaryBlocks must be an array");if(a.length>32)throw Error("too many binary blocks");let b=[];for(let c of a){if(!c||"object"!=typeof c||Array.isArray(c))throw Error("invalid binary block");let a="string"==typeof c.path?c.path.trim():"",e="string"==typeof c.name?c.name.trim():"",f=(0,d.Ln)(c.mimeType),g=c.size,h=void 0===c.previewPath?void 0:"string"==typeof c.previewPath?c.previewPath.trim():null;if(!a||!e||!f||!Number.isSafeInteger(g)||g<0||null===h)throw Error("invalid binary block");b.push({path:a,name:e,mimeType:f,size:g,...h?{previewPath:h}:{}})}return b}(a.binaryBlocks)}}function i(a){return"prompt"===a||"abort"===a||"steer"===a||"follow_up"===a}function j(a,b=e){if(!a||"object"!=typeof a||Array.isArray(a))throw Error("command is required");let c=a.type;if("prompt"===c)return h(a,b);if("abort"===c)return{type:"abort"};if("steer"===c)return{type:"steer",message:g(a),images:f(a.images)};if("follow_up"===c)return{type:"follow_up",message:g(a),images:f(a.images)};throw Error(`Unsupported message command: ${String(c)}`)}},53023:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{Uj:()=>j});var e=c(85664),f=c(93127),g=c(95237),h=a([f,g]);function i(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}[f,g]=h.then?(await h)():h;let k=`
2
2
  .pidance-activity{margin:1.5rem 0;padding:1rem 1.25rem;border:1px solid #ccc;border-radius:8px;background:#fafafa;color:#222;font-family:system-ui,-apple-system,Segoe UI,sans-serif;font-size:14px;line-height:1.45}
3
3
  .pidance-activity h2{margin:0 0 0.75rem;font-size:1.1rem;font-weight:600}
4
4
  .pidance-activity-card{margin:0.75rem 0;padding:0.75rem 1rem;border:1px solid #ddd;border-radius:6px;background:#fff}
@@ -97,7 +97,7 @@ ${g}`:[...Array.isArray(b.content)?b.content:[],{type:"text",text:g}];return[...
97
97
  }
98
98
  containsActive.set(node, has);
99
99
  }
100
- }`));return{body:(0,k.Uj)(c,q),contentType:"text/html; charset=utf-8",fileName:f}}finally{(0,g.rmSync)(m,{force:!0}),(0,g.rmSync)(n,{force:!0})}}d()}catch(a){d(a)}})},86226:(a,b,c)=>{c.d(b,{yN:()=>d});function d(a,b){return!a&&!!b}},87538:(a,b,c)=>{let d;c.d(b,{Lm:()=>i,Mf:()=>n,GD:()=>l,t_:()=>k,tU:()=>m});let e=JSON.parse('{"$schema":"https://raw.githubusercontent.com/earendil-works/pi/main/packages/coding-agent/src/modes/interactive/theme/theme-schema.json","name":"dark","vars":{"cyan":"#00d7ff","blue":"#5f87ff","green":"#b5bd68","red":"#cc6666","yellow":"#ffff00","text":"#d4d4d4","gray":"#808080","dimGray":"#666666","darkGray":"#505050","accent":"#8abeb7","selectedBg":"#3a3a4a","userMsgBg":"#343541","toolPendingBg":"#282832","toolSuccessBg":"#283228","toolErrorBg":"#3c2828","customMsgBg":"#2d2838"},"colors":{"accent":"accent","border":"blue","borderAccent":"cyan","borderMuted":"darkGray","success":"green","error":"red","warning":"yellow","muted":"gray","dim":"dimGray","text":"text","thinkingText":"gray","selectedBg":"selectedBg","userMessageBg":"userMsgBg","userMessageText":"text","customMessageBg":"customMsgBg","customMessageText":"text","customMessageLabel":"#9575cd","toolPendingBg":"toolPendingBg","toolSuccessBg":"toolSuccessBg","toolErrorBg":"toolErrorBg","toolTitle":"text","toolOutput":"gray","mdHeading":"#f0c674","mdLink":"#81a2be","mdLinkUrl":"dimGray","mdCode":"accent","mdCodeBlock":"green","mdCodeBlockBorder":"gray","mdQuote":"gray","mdQuoteBorder":"gray","mdHr":"gray","mdListBullet":"accent","toolDiffAdded":"green","toolDiffRemoved":"red","toolDiffContext":"gray","syntaxComment":"#6A9955","syntaxKeyword":"#569CD6","syntaxFunction":"#DCDCAA","syntaxVariable":"#9CDCFE","syntaxString":"#CE9178","syntaxNumber":"#B5CEA8","syntaxType":"#4EC9B0","syntaxOperator":"#D4D4D4","syntaxPunctuation":"#D4D4D4","thinkingOff":"darkGray","thinkingMinimal":"#6e6e6e","thinkingLow":"#5f87af","thinkingMedium":"#81a2be","thinkingHigh":"#b294bb","thinkingXhigh":"#d183e8","thinkingMax":"#ff5fff","bashMode":"green"},"export":{"pageBg":"#18181e","cardBg":"#1e1e24","infoBg":"#3c3728"}}');function f(a){let b=a.replace("#",""),c=Number.parseInt(3===b.length?b.split("").map(a=>a+a).join(""):b,16);return{r:c>>16&255,g:c>>8&255,b:255&c}}class g{constructor(a,b,c="truecolor",d){for(const[b,e]of(this.fgAnsiMap=new Map,this.bgAnsiMap=new Map,this.mode=c,this.name=d?.name,Object.entries({...a,thinkingMax:a.thinkingMax??a.thinkingXhigh})))this.fgAnsiMap.set(b,function(a,b){if(""===a)return"\x1b[39m";if("number"==typeof a)return`\x1b[38;5;${a}m`;if("string"==typeof a&&a.startsWith("#")){if("truecolor"===b){let{r:b,g:c,b:d}=f(a);return`\x1b[38;2;${b};${c};${d}m`}return"\x1b[38;5;7m"}throw Error(`Invalid color value: ${String(a)}`)}(e,c));for(const[a,d]of Object.entries(b))this.bgAnsiMap.set(a,function(a,b){if(""===a)return"\x1b[49m";if("number"==typeof a)return`\x1b[48;5;${a}m`;if("string"==typeof a&&a.startsWith("#")){if("truecolor"===b){let{r:b,g:c,b:d}=f(a);return`\x1b[48;2;${b};${c};${d}m`}return"\x1b[48;5;0m"}throw Error(`Invalid color value: ${String(a)}`)}(d,c))}fg(a,b){let c=this.fgAnsiMap.get(a);if(!c)throw Error(`Unknown theme color: ${a}`);return`${c}${b}\x1b[39m`}bg(a,b){let c=this.bgAnsiMap.get(a);if(!c)throw Error(`Unknown theme background color: ${a}`);return`${c}${b}\x1b[49m`}bold(a){return`\x1b[1m${a}\x1b[22m`}italic(a){return`\x1b[3m${a}\x1b[23m`}underline(a){return`\x1b[4m${a}\x1b[24m`}inverse(a){return`\x1b[7m${a}\x1b[27m`}strikethrough(a){return`\x1b[9m${a}\x1b[29m`}getFgAnsi(a){let b=this.fgAnsiMap.get(a);if(!b)throw Error(`Unknown theme color: ${a}`);return b}getBgAnsi(a){let b=this.bgAnsiMap.get(a);if(!b)throw Error(`Unknown theme background color: ${a}`);return b}getColorMode(){return this.mode}getThinkingBorderColor(a){let b={off:"thinkingOff",minimal:"thinkingMinimal",low:"thinkingLow",medium:"thinkingMedium",high:"thinkingHigh",xhigh:"thinkingXhigh",max:"thinkingMax"}[a]??"thinkingOff";return a=>this.fg(b,a)}getBashModeBorderColor(){return a=>this.fg("bashMode",a)}}let h=new Set(["selectedBg","userMessageBg","customMessageBg","toolPendingBg","toolSuccessBg","toolErrorBg"]);function i(){if(void 0!==d)return d;try{d=function(a){let b={...a.colors,thinkingMax:a.colors.thinkingMax??a.colors.thinkingXhigh},c=a.vars??{},d={},e={};for(let[a,f]of Object.entries(b)){let b=function a(b,c,d=new Set){if("number"==typeof b||""===b||b.startsWith("#"))return b;if(d.has(b))throw Error(`Circular variable reference detected: ${b}`);if(!(b in c))throw Error(`Variable reference not found: ${b}`);return d.add(b),a(c[b],c,d)}(f,c);h.has(a)?e[a]=b:d[a]=b}return new g(d,e,"truecolor",{name:a.name})}(e)}catch{d=null}return d}function j(a,b=100){if(!a||"object"!=typeof a||"function"!=typeof a.render)return null;try{let c=a.render(b);if(!function(a){if(!Array.isArray(a)||0===a.length||!a.every(a=>"string"==typeof a)||a.length>500)return!1;let b=0;for(let c of a)if(c.length>4e3||(b+=c.length)>204800)return!1;return!0}(c))return null;return c}catch{return null}}function k(a,b,c,d,e){let f=function(a){if(!a||"object"!=typeof a)return;let b=a.renderResult??a.ln;return"function"==typeof b?b:void 0}(a);if(!f)return null;let g=i();if(!g)return null;try{let a=f(b,c,g,d);return a&&"object"==typeof a&&e?.(a),j(a)}catch{return null}}function l(a,b,c,d){let e=function(a){if(!a||"object"!=typeof a)return;let b=a.renderCall;return"function"==typeof b?b:void 0}(a);if(!e)return null;let f=i();if(!f)return null;try{let a=e(b,f,c);return a&&"object"==typeof a&&d?.(a),j(a)}catch{return null}}function m(a,b,c=100){if("function"!=typeof a||!b)return null;try{let d=a(void 0,b);return j(d,c)}catch{return null}}function n(a,b,c,d=100){if("function"!=typeof a||!c)return null;try{let e=a(b,{expanded:!0},c);return j(e,d)}catch{return null}}},89953:(a,b,c)=>{c.d(b,{AZ:()=>o,GT:()=>g,Hl:()=>p,kP:()=>n,wE:()=>m,wy:()=>q});var d=c(89477),e=c(86697),f=c(60396);let g="Session is locked by another Pidance process (writable host ownership)";function h(a){return(0,e.join)(a,"pidance-running-leases")}function i(a,b){let c=b.replace(/[^a-zA-Z0-9._-]+/g,"_").slice(0,180);return(0,e.join)(h(a),`${c}.json`)}function j(a){try{let b=JSON.parse((0,d.readFileSync)(a,"utf8"));if("number"!=typeof b.pid||"string"!=typeof b.sessionId||"number"!=typeof b.heartbeatAt)return null;return{pid:b.pid,sessionId:b.sessionId,heartbeatAt:b.heartbeatAt,startedAt:"number"==typeof b.startedAt?b.startedAt:b.heartbeatAt}}catch{return null}}function k(a,b){(0,d.writeFileSync)(a,`${JSON.stringify(b)}
101
- `,{mode:384})}function l(a,b){return b-a.heartbeatAt<=2e4&&function(a){if(!Number.isFinite(a)||a<=0)return!1;try{return process.kill(a,0),!0}catch(a){return"EPERM"===a.code}}(a.pid)}function m(a){return(a instanceof Error?a.message:String(a)).includes("locked by another Pidance process")}function n(a,b=(0,f.$M)(),c=Date.now()){if(!a)return!1;let e=h(b);(0,d.existsSync)(e)||(0,d.mkdirSync)(e,{recursive:!0,mode:448});let g=i(b,a),m=(0,d.existsSync)(g)?j(g):null;return(!(m&&l(m,c))||m.pid===process.pid)&&(k(g,{pid:process.pid,sessionId:a,heartbeatAt:c,startedAt:m&&m.pid===process.pid?m.startedAt:c}),!0)}function o(a,b=(0,f.$M)(),c=Date.now()){if(!a)return;let e=i(b,a),g=(0,d.existsSync)(e)?j(e):null;g&&g.pid!==process.pid&&l(g,c)||((0,d.existsSync)(h(b))||(0,d.mkdirSync)(h(b),{recursive:!0,mode:448}),k(e,{pid:process.pid,sessionId:a,heartbeatAt:c,startedAt:g&&g.pid===process.pid?g.startedAt:c}))}function p(a,b=(0,f.$M)()){if(!a)return;let c=i(b,a),e=(0,d.existsSync)(c)?j(c):null;if(!e||e.pid===process.pid)try{(0,d.unlinkSync)(c)}catch{}}function q(a,b=(0,f.$M)(),c=Date.now()){if(!a)return!1;let e=(0,d.existsSync)(i(b,a))?j(i(b,a)):null;return!!e&&!!l(e,c)&&e.pid!==process.pid}},92395:(a,b,c)=>{c.d(b,{Ej:()=>q,FN:()=>j,J7:()=>s,Tj:()=>r,oT:()=>m,wq:()=>i,xH:()=>t});var d=c(89477),e=c(86697),f=c(60396);function g(a){return(0,e.join)((0,e.resolve)(a),".pi","settings.json")}function h(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function i(a){if(!(0,d.existsSync)(a))return{};try{let b=JSON.parse((0,d.readFileSync)(a,"utf8"));return h(b)?{...b}:{}}catch{return{}}}function j(a,b){let c=(0,e.dirname)(a);(0,d.mkdirSync)(c,{recursive:!0});let f=`${a}.${process.pid}.${Date.now()}.tmp`,g=`${JSON.stringify(b,null,2)}
100
+ }`));return{body:(0,k.Uj)(c,q),contentType:"text/html; charset=utf-8",fileName:f}}finally{(0,g.rmSync)(m,{force:!0}),(0,g.rmSync)(n,{force:!0})}}d()}catch(a){d(a)}})},86226:(a,b,c)=>{c.d(b,{yN:()=>d});function d(a,b){return!a&&!!b}},87538:(a,b,c)=>{let d;c.d(b,{Lm:()=>i,Mf:()=>n,GD:()=>l,t_:()=>k,tU:()=>m});let e=JSON.parse('{"$schema":"https://raw.githubusercontent.com/earendil-works/pi/main/packages/coding-agent/src/modes/interactive/theme/theme-schema.json","name":"dark","vars":{"cyan":"#00d7ff","blue":"#5f87ff","green":"#b5bd68","red":"#cc6666","yellow":"#ffff00","text":"#d4d4d4","gray":"#808080","dimGray":"#666666","darkGray":"#505050","accent":"#8abeb7","selectedBg":"#3a3a4a","userMsgBg":"#343541","toolPendingBg":"#282832","toolSuccessBg":"#283228","toolErrorBg":"#3c2828","customMsgBg":"#2d2838"},"colors":{"accent":"accent","border":"blue","borderAccent":"cyan","borderMuted":"darkGray","success":"green","error":"red","warning":"yellow","muted":"gray","dim":"dimGray","text":"text","thinkingText":"gray","selectedBg":"selectedBg","userMessageBg":"userMsgBg","userMessageText":"text","customMessageBg":"customMsgBg","customMessageText":"text","customMessageLabel":"#9575cd","toolPendingBg":"toolPendingBg","toolSuccessBg":"toolSuccessBg","toolErrorBg":"toolErrorBg","toolTitle":"text","toolOutput":"gray","mdHeading":"#f0c674","mdLink":"#81a2be","mdLinkUrl":"dimGray","mdCode":"accent","mdCodeBlock":"green","mdCodeBlockBorder":"gray","mdQuote":"gray","mdQuoteBorder":"gray","mdHr":"gray","mdListBullet":"accent","toolDiffAdded":"green","toolDiffRemoved":"red","toolDiffContext":"gray","syntaxComment":"#6A9955","syntaxKeyword":"#569CD6","syntaxFunction":"#DCDCAA","syntaxVariable":"#9CDCFE","syntaxString":"#CE9178","syntaxNumber":"#B5CEA8","syntaxType":"#4EC9B0","syntaxOperator":"#D4D4D4","syntaxPunctuation":"#D4D4D4","thinkingOff":"darkGray","thinkingMinimal":"#6e6e6e","thinkingLow":"#5f87af","thinkingMedium":"#81a2be","thinkingHigh":"#b294bb","thinkingXhigh":"#d183e8","thinkingMax":"#ff5fff","bashMode":"green"},"export":{"pageBg":"#18181e","cardBg":"#1e1e24","infoBg":"#3c3728"}}');function f(a){let b=a.replace("#",""),c=Number.parseInt(3===b.length?b.split("").map(a=>a+a).join(""):b,16);return{r:c>>16&255,g:c>>8&255,b:255&c}}class g{constructor(a,b,c="truecolor",d){for(const[b,e]of(this.fgAnsiMap=new Map,this.bgAnsiMap=new Map,this.mode=c,this.name=d?.name,Object.entries({...a,thinkingMax:a.thinkingMax??a.thinkingXhigh})))this.fgAnsiMap.set(b,function(a,b){if(""===a)return"\x1b[39m";if("number"==typeof a)return`\x1b[38;5;${a}m`;if("string"==typeof a&&a.startsWith("#")){if("truecolor"===b){let{r:b,g:c,b:d}=f(a);return`\x1b[38;2;${b};${c};${d}m`}return"\x1b[38;5;7m"}throw Error(`Invalid color value: ${String(a)}`)}(e,c));for(const[a,d]of Object.entries(b))this.bgAnsiMap.set(a,function(a,b){if(""===a)return"\x1b[49m";if("number"==typeof a)return`\x1b[48;5;${a}m`;if("string"==typeof a&&a.startsWith("#")){if("truecolor"===b){let{r:b,g:c,b:d}=f(a);return`\x1b[48;2;${b};${c};${d}m`}return"\x1b[48;5;0m"}throw Error(`Invalid color value: ${String(a)}`)}(d,c))}fg(a,b){let c=this.fgAnsiMap.get(a);if(!c)throw Error(`Unknown theme color: ${a}`);return`${c}${b}\x1b[39m`}bg(a,b){let c=this.bgAnsiMap.get(a);if(!c)throw Error(`Unknown theme background color: ${a}`);return`${c}${b}\x1b[49m`}bold(a){return`\x1b[1m${a}\x1b[22m`}italic(a){return`\x1b[3m${a}\x1b[23m`}underline(a){return`\x1b[4m${a}\x1b[24m`}inverse(a){return`\x1b[7m${a}\x1b[27m`}strikethrough(a){return`\x1b[9m${a}\x1b[29m`}getFgAnsi(a){let b=this.fgAnsiMap.get(a);if(!b)throw Error(`Unknown theme color: ${a}`);return b}getBgAnsi(a){let b=this.bgAnsiMap.get(a);if(!b)throw Error(`Unknown theme background color: ${a}`);return b}getColorMode(){return this.mode}getThinkingBorderColor(a){let b={off:"thinkingOff",minimal:"thinkingMinimal",low:"thinkingLow",medium:"thinkingMedium",high:"thinkingHigh",xhigh:"thinkingXhigh",max:"thinkingMax"}[a]??"thinkingOff";return a=>this.fg(b,a)}getBashModeBorderColor(){return a=>this.fg("bashMode",a)}}let h=new Set(["selectedBg","userMessageBg","customMessageBg","toolPendingBg","toolSuccessBg","toolErrorBg"]);function i(){if(void 0!==d)return d;try{d=function(a){let b={...a.colors,thinkingMax:a.colors.thinkingMax??a.colors.thinkingXhigh},c=a.vars??{},d={},e={};for(let[a,f]of Object.entries(b)){let b=function a(b,c,d=new Set){if("number"==typeof b||""===b||b.startsWith("#"))return b;if(d.has(b))throw Error(`Circular variable reference detected: ${b}`);if(!(b in c))throw Error(`Variable reference not found: ${b}`);return d.add(b),a(c[b],c,d)}(f,c);h.has(a)?e[a]=b:d[a]=b}return new g(d,e,"truecolor",{name:a.name})}(e)}catch{d=null}return d}function j(a,b=100){if(!a||"object"!=typeof a||"function"!=typeof a.render)return null;try{let c=a.render(b);if(!function(a){if(!Array.isArray(a)||0===a.length||!a.every(a=>"string"==typeof a)||a.length>500)return!1;let b=0;for(let c of a)if(c.length>4e3||(b+=c.length)>204800)return!1;return!0}(c))return null;return c}catch{return null}}function k(a,b,c,d,e){let f=function(a){if(!a||"object"!=typeof a)return;let b=a.renderResult??a.ln;return"function"==typeof b?b:void 0}(a);if(!f)return null;let g=i();if(!g)return null;try{let a=f(b,c,g,d);return a&&"object"==typeof a&&e?.(a),j(a)}catch{return null}}function l(a,b,c,d){let e=function(a){if(!a||"object"!=typeof a)return;let b=a.renderCall;return"function"==typeof b?b:void 0}(a);if(!e)return null;let f=i();if(!f)return null;try{let a=e(b,f,c);return a&&"object"==typeof a&&d?.(a),j(a)}catch{return null}}function m(a,b,c=100){if("function"!=typeof a||!b)return null;try{let d=a(void 0,b);return j(d,c)}catch{return null}}function n(a,b,c,d=100){if("function"!=typeof a||!c)return null;try{let e=a(b,{expanded:!0},c);return j(e,d)}catch{return null}}},89953:(a,b,c)=>{c.d(b,{AZ:()=>u,GT:()=>h,Hl:()=>v,kP:()=>t,wE:()=>s,wy:()=>w});var d=c(716),e=c(89477),f=c(86697),g=c(60396);let h="Session is locked by another Pidance process (writable host ownership)",i="Timed out acquiring Pidance running-lease lock";function j(a){return(0,f.join)(a,"pidance-running-leases")}function k(a,b){let c=b.replace(/[^a-zA-Z0-9._-]+/g,"_").slice(0,180);return(0,f.join)(j(a),`${c}.json`)}function l(a){if(!Number.isFinite(a)||a<=0)return!1;try{return process.kill(a,0),!0}catch(a){return"EPERM"===a.code}}function m(a){try{let b=JSON.parse((0,e.readFileSync)(a,"utf8"));if("number"!=typeof b.pid||"string"!=typeof b.sessionId||"number"!=typeof b.heartbeatAt)return null;return{pid:b.pid,sessionId:b.sessionId,heartbeatAt:b.heartbeatAt,startedAt:"number"==typeof b.startedAt?b.startedAt:b.heartbeatAt}}catch{return null}}function n(a){try{let b=JSON.parse((0,e.readFileSync)(a,"utf8"));if("number"!=typeof b.pid||"string"!=typeof b.token)return null;return{pid:b.pid,token:b.token}}catch{return null}}function o(a,b){let c=j(a);(0,e.existsSync)(c)||(0,e.mkdirSync)(c,{recursive:!0,mode:448});let g=(0,f.join)(c,".lease-lock"),h=(0,d.randomBytes)(8).toString("hex"),k=Date.now()+3e3,m=!1;for(;!m;){let a=`${g}.${process.pid}.${h}.tmp`;try{(0,e.writeFileSync)(a,JSON.stringify({pid:process.pid,token:h}),{mode:384}),(0,e.linkSync)(a,g),m=!0}catch(b){if("EEXIST"!==b.code){try{(0,e.unlinkSync)(a)}catch{}throw b}}try{(0,e.unlinkSync)(a)}catch{}if(m)break;let b=n(g);if(b&&!l(b.pid)){try{n(g)?.token===b.token&&(0,e.unlinkSync)(g)}catch{}continue}if(!b)try{Date.now()-(0,e.statSync)(g).mtimeMs>1e4&&(0,e.unlinkSync)(g)}catch{}if(Date.now()>=k)throw Error(i);!function(){let a=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(a,0,0,5)}()}try{return b()}finally{try{n(g)?.token===h&&(0,e.unlinkSync)(g)}catch{}}}function p(a){return a instanceof Error&&a.message===i}function q(a,b){let c=`${a}.${process.pid}.tmp`;(0,e.writeFileSync)(c,`${JSON.stringify(b)}
101
+ `,{mode:384}),(0,e.renameSync)(c,a)}function r(a,b){return b-a.heartbeatAt<=2e4&&l(a.pid)}function s(a){return(a instanceof Error?a.message:String(a)).includes("locked by another Pidance process")}function t(a,b=(0,g.$M)(),c=Date.now()){if(!a)return!1;try{return o(b,()=>{let d=k(b,a),f=(0,e.existsSync)(d)?m(d):null;return(!(f&&r(f,c))||f.pid===process.pid)&&(q(d,{pid:process.pid,sessionId:a,heartbeatAt:c,startedAt:f&&f.pid===process.pid?f.startedAt:c}),!0)})}catch(a){if(p(a))return!1;throw a}}function u(a,b=(0,g.$M)(),c=Date.now()){if(a)try{o(b,()=>{let d=k(b,a),f=(0,e.existsSync)(d)?m(d):null;f&&f.pid!==process.pid&&r(f,c)||q(d,{pid:process.pid,sessionId:a,heartbeatAt:c,startedAt:f&&f.pid===process.pid?f.startedAt:c})})}catch(a){if(!p(a))throw a}}function v(a,b=(0,g.$M)()){if(a)try{o(b,()=>{let c=k(b,a),d=(0,e.existsSync)(c)?m(c):null;if(!d||d.pid===process.pid)try{(0,e.unlinkSync)(c)}catch{}})}catch(a){if(!p(a))throw a}}function w(a,b=(0,g.$M)(),c=Date.now()){if(!a)return!1;let d=(0,e.existsSync)(k(b,a))?m(k(b,a)):null;return!!d&&!!r(d,c)&&d.pid!==process.pid}},92395:(a,b,c)=>{c.d(b,{Ej:()=>q,FN:()=>j,J7:()=>s,Tj:()=>r,oT:()=>m,wq:()=>i,xH:()=>t});var d=c(89477),e=c(86697),f=c(60396);function g(a){return(0,e.join)((0,e.resolve)(a),".pi","settings.json")}function h(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function i(a){if(!(0,d.existsSync)(a))return{};try{let b=JSON.parse((0,d.readFileSync)(a,"utf8"));return h(b)?{...b}:{}}catch{return{}}}function j(a,b){let c=(0,e.dirname)(a);(0,d.mkdirSync)(c,{recursive:!0});let f=`${a}.${process.pid}.${Date.now()}.tmp`,g=`${JSON.stringify(b,null,2)}
102
102
  `;try{(0,d.writeFileSync)(f,g,{flag:"wx",mode:384}),(0,d.renameSync)(f,a)}catch(a){try{(0,d.unlinkSync)(f)}catch{}throw a}}function k(a){return"string"==typeof a&&a.length>0?a:void 0}function l(a,b){return"all"===a||"one-at-a-time"===a?a:b}class m{constructor(a={}){this.dirty=!1;const b=a.agentDir??(0,f.$M)();this.globalPath=(0,e.join)((0,e.resolve)(b),"settings.json"),this.global=i(this.globalPath)}static create(a,b){return new m({agentDir:b})}view(){return this.global}getDefaultProvider(){return k(this.view().defaultProvider)}getDefaultModel(){return k(this.view().defaultModel)}getDefaultThinkingLevel(){return k(this.view().defaultThinkingLevel)}getSteeringMode(){return l(this.view().steeringMode,"one-at-a-time")}getFollowUpMode(){return l(this.view().followUpMode,"one-at-a-time")}getCompactionSettings(){let a=h(this.view().compaction)?this.view().compaction:{};return{enabled:"boolean"!=typeof a.enabled||a.enabled,reserveTokens:"number"==typeof a.reserveTokens?a.reserveTokens:16384,keepRecentTokens:"number"==typeof a.keepRecentTokens?a.keepRecentTokens:2e4}}getRetrySettings(){let a=h(this.view().retry)?this.view().retry:{};return{enabled:"boolean"!=typeof a.enabled||a.enabled,maxRetries:"number"==typeof a.maxRetries?a.maxRetries:3,baseDelayMs:"number"==typeof a.baseDelayMs?a.baseDelayMs:2e3}}getPackages(){return this.global.packages}setDefaultProvider(a){this.global.defaultProvider=a,this.dirty=!0}setDefaultModel(a){this.global.defaultModel=a,this.dirty=!0}setDefaultModelAndProvider(a,b){this.global.defaultProvider=a,this.global.defaultModel=b,this.dirty=!0}setDefaultThinkingLevel(a){this.global.defaultThinkingLevel=a,this.dirty=!0}setSteeringMode(a){this.global.steeringMode=a,this.dirty=!0}setFollowUpMode(a){this.global.followUpMode=a,this.dirty=!0}setCompactionEnabled(a){let b=h(this.global.compaction)?{...this.global.compaction}:{};b.enabled=a,this.global.compaction=b,this.dirty=!0}setRetryEnabled(a){let b=h(this.global.retry)?{...this.global.retry}:{};b.enabled=a,this.global.retry=b,this.dirty=!0}setPackages(a){this.global.packages=a,this.dirty=!0}async flush(){this.dirty&&(j(this.globalPath,this.global),this.dirty=!1)}flushSync(){this.dirty&&(j(this.globalPath,this.global),this.dirty=!1)}}function n(a){return Array.isArray(a)?a:[]}function o(a){return"string"==typeof a?a:a.source}function p(a){return"string"!=typeof a&&Array.isArray(a.extensions)&&0===a.extensions.length&&Array.isArray(a.skills)&&0===a.skills.length&&Array.isArray(a.prompts)&&0===a.prompts.length&&Array.isArray(a.themes)&&0===a.themes.length}function q(a,b={}){return"global"===a?n(i(b.agentDir?(0,e.join)((0,e.resolve)(b.agentDir),"settings.json"):(0,f.pA)()).packages):b.cwd?n(i(g(b.cwd)).packages):[]}function r(a,b,c={}){if("global"===a){let a=c.agentDir?(0,e.join)((0,e.resolve)(c.agentDir),"settings.json"):(0,f.pA)(),d=i(a);d.packages=b,j(a,d);return}if(!c.cwd)throw Error("project packages 需要 cwd");let d=g(c.cwd),h=i(d);h.packages=b,j(d,h)}function s(a,b,c,d={}){let e=q(b,d),f=!1,g=e.map(b=>o(b)!==a?b:(f=!0,c)?{..."string"==typeof b?{source:b}:b,extensions:[],skills:[],prompts:[],themes:[]}:o(b));return!!f&&(r(b,g,d),!0)}function t(a){let b=new Map;for(let c of q("global",a))b.set(`global\0${o(c)}`,p(c));if(a.cwd)for(let c of q("project",a))b.set(`project\0${o(c)}`,p(c));return b}},93127:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{Nw:()=>h,Zq:()=>k,rW:()=>l,wr:()=>i,ye:()=>j});var e=c(33873),f=c(95237),g=a([f]);f=(g.then?(await g)():g)[0];class k extends Error{constructor(a){super(a),this.name="SessionExportError",this.code="bad-request"}}function h(a){return null===a||""===a?"html":"jsonl"===a?"jsonl":null}function i(a,b={}){let c=(0,f.kW)(a);return function(a,b={}){let c=b.leafId,d="string"==typeof c&&c.length>0?c:void 0;if(void 0!==d&&!a.getEntry(d))throw new k(`Invalid leafId: ${d}`);let e=void 0!==d?a.getBranch(d):a.getBranch(),g=(b.now??(()=>new Date))().toISOString(),h={type:"session",version:f.iR,id:a.getSessionId(),timestamp:g,cwd:a.getCwd()},i=[JSON.stringify(h)],j=null;for(let a of e){let b={...a,parentId:j};i.push(JSON.stringify(b)),j=a.id}return`${i.join("\n")}
103
103
  `}(c,b)}function j(a){let b=(0,e.basename)(a,".jsonl");return`pi-session-${b}.jsonl`}let l="application/x-ndjson; charset=utf-8";d()}catch(a){d(a)}})}};
@@ -1 +1 @@
1
- globalThis.__BUILD_MANIFEST={polyfillFiles:["static/chunks/polyfills-42372ed130431b0a.js"],devFiles:[],lowPriorityFiles:["static/tj04wII7Oz8Z4qdCTh4TE/_buildManifest.js","static/tj04wII7Oz8Z4qdCTh4TE/_ssgManifest.js"],rootMainFiles:["static/chunks/webpack-d2379fd13c5c78c6.js","static/chunks/4bd1b696-e356ca5ba0218e27.js","static/chunks/3794-907785a527d8128b.js","static/chunks/main-app-06b2b50b226e40d1.js"],rootMainFilesTree:{},pages:{"/_app":[]}};
1
+ globalThis.__BUILD_MANIFEST={polyfillFiles:["static/chunks/polyfills-42372ed130431b0a.js"],devFiles:[],lowPriorityFiles:["static/P-GwTOtxwpdnWwlj9T66x/_buildManifest.js","static/P-GwTOtxwpdnWwlj9T66x/_ssgManifest.js"],rootMainFiles:["static/chunks/webpack-d2379fd13c5c78c6.js","static/chunks/4bd1b696-e356ca5ba0218e27.js","static/chunks/3794-907785a527d8128b.js","static/chunks/main-app-06b2b50b226e40d1.js"],rootMainFilesTree:{},pages:{"/_app":[]}};
@@ -1 +1 @@
1
- <!DOCTYPE html><html lang="en" translate="no" class="__variable_66b8ca notranslate"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" href="/_next/static/media/7deddc85b7ffd1dc-s.p.woff2" as="font" crossorigin="" type="font/woff2"/><link rel="preload" href="/_next/static/media/ec14413c594b3356-s.p.woff2" as="font" crossorigin="" type="font/woff2"/><link rel="stylesheet" href="/_next/static/css/88714c00e109ce28.css" data-precedence="next"/><link rel="stylesheet" href="/_next/static/css/782855e5398f955b.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-d2379fd13c5c78c6.js"/><script src="/_next/static/chunks/4bd1b696-e356ca5ba0218e27.js" async=""></script><script src="/_next/static/chunks/3794-907785a527d8128b.js" async=""></script><script src="/_next/static/chunks/main-app-06b2b50b226e40d1.js" async=""></script><script src="/_next/static/chunks/9780-a21716489f365d66.js" async=""></script><script src="/_next/static/chunks/app/layout-88764b4be2728d3f.js" async=""></script><meta name="robots" content="noindex"/><meta name="next-size-adjust" content=""/><meta name="google" content="notranslate"/><title>404: This page could not be found.</title><title>Pidance</title><meta name="description" content="Open-source web client for the Pi coding agent"/><link rel="icon" href="/brand/pidance-logo.png"/><link rel="apple-touch-icon" href="/brand/pidance-logo.png"/><script>(function(){try{var r=document.documentElement,m=localStorage.getItem("pi-theme"),s=localStorage.getItem("pi-theme-style");if(m!=="light"&&m!=="dark"&&m!=="system")m="light";if(s!=="fusion"&&s!=="chamber")s="chamber";var d=m==="dark"||(m==="system"&&matchMedia("(prefers-color-scheme: dark)").matches);r.classList.toggle("dark",d);r.dataset.themeMode=m;r.dataset.themeStyle=s}catch(e){}})();</script><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body translate="no" class="notranslate" style="height:100dvh;display:flex;flex-direction:column"><div hidden=""><!--$--><!--/$--></div><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding:0 23px 0 0;font-size:24px;font-weight:500;vertical-align:top;line-height:49px">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:49px;margin:0">This page could not be found.</h2></div></div></div><!--$--><!--/$--><script src="/_next/static/chunks/webpack-d2379fd13c5c78c6.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[99780,[\"9780\",\"static/chunks/9780-a21716489f365d66.js\",\"7177\",\"static/chunks/app/layout-88764b4be2728d3f.js\"],\"I18nProvider\"]\n3:I[57121,[],\"\"]\n4:I[74581,[],\"\"]\n5:I[90484,[],\"OutletBoundary\"]\n6:\"$Sreact.suspense\"\n9:I[90484,[],\"ViewportBoundary\"]\nb:I[90484,[],\"MetadataBoundary\"]\nd:I[27123,[],\"default\",1]\n:HL[\"/_next/static/media/7deddc85b7ffd1dc-s.p.woff2\",\"font\",{\"crossOrigin\":\"\",\"type\":\"font/woff2\"}]\n:HL[\"/_next/static/media/ec14413c594b3356-s.p.woff2\",\"font\",{\"crossOrigin\":\"\",\"type\":\"font/woff2\"}]\n:HL[\"/_next/static/css/88714c00e109ce28.css\",\"style\"]\n:HL[\"/_next/static/css/782855e5398f955b.css\",\"style\"]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"c\":[\"\",\"_not-found\"],\"q\":\"\",\"i\":false,\"f\":[[[\"\",{\"children\":[\"_not-found\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",16],[[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/88714c00e109ce28.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\",\"nonce\":\"$undefined\"}],[\"$\",\"link\",\"1\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/782855e5398f955b.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\",\"nonce\":\"$undefined\"}]],[\"$\",\"html\",null,{\"lang\":\"en\",\"translate\":\"no\",\"className\":\"__variable_66b8ca notranslate\",\"suppressHydrationWarning\":true,\"children\":[[\"$\",\"head\",null,{\"children\":[[\"$\",\"meta\",null,{\"name\":\"google\",\"content\":\"notranslate\"}],[\"$\",\"script\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"(function(){try{var r=document.documentElement,m=localStorage.getItem(\\\"pi-theme\\\"),s=localStorage.getItem(\\\"pi-theme-style\\\");if(m!==\\\"light\\\"\u0026\u0026m!==\\\"dark\\\"\u0026\u0026m!==\\\"system\\\")m=\\\"light\\\";if(s!==\\\"fusion\\\"\u0026\u0026s!==\\\"chamber\\\")s=\\\"chamber\\\";var d=m===\\\"dark\\\"||(m===\\\"system\\\"\u0026\u0026matchMedia(\\\"(prefers-color-scheme: dark)\\\").matches);r.classList.toggle(\\\"dark\\\",d);r.dataset.themeMode=m;r.dataset.themeStyle=s}catch(e){}})();\"}}]]}],[\"$\",\"body\",null,{\"translate\":\"no\",\"className\":\"notranslate\",\"style\":{\"height\":\"100dvh\",\"display\":\"flex\",\"flexDirection\":\"column\"},\"children\":[\"$\",\"$L2\",null,{\"children\":[\"$\",\"$L3\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L4\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]}]}]]}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L3\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L4\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":404}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],null,[\"$\",\"$L5\",null,{\"children\":[\"$\",\"$6\",null,{\"name\":\"Next.MetadataOutlet\",\"children\":\"$@7\"}]}]]}],{},null,false,null]},null,false,\"$@8\"]},null,false,null],[\"$\",\"$1\",\"h\",{\"children\":[[\"$\",\"meta\",null,{\"name\":\"robots\",\"content\":\"noindex\"}],[\"$\",\"$L9\",null,{\"children\":\"$La\"}],[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$Lb\",null,{\"children\":[\"$\",\"$6\",null,{\"name\":\"Next.Metadata\",\"children\":\"$Lc\"}]}]}],[\"$\",\"meta\",null,{\"name\":\"next-size-adjust\",\"content\":\"\"}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$d\",[]],\"S\":true,\"h\":null,\"s\":\"$undefined\",\"l\":\"$undefined\",\"p\":\"$undefined\",\"d\":\"$undefined\",\"b\":\"tj04wII7Oz8Z4qdCTh4TE\"}\n"])</script><script>self.__next_f.push([1,"e:[]\n8:\"$We\"\n"])</script><script>self.__next_f.push([1,"a:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n"])</script><script>self.__next_f.push([1,"f:I[86869,[],\"IconMark\"]\n7:null\nc:[[\"$\",\"title\",\"0\",{\"children\":\"Pidance\"}],[\"$\",\"meta\",\"1\",{\"name\":\"description\",\"content\":\"Open-source web client for the Pi coding agent\"}],[\"$\",\"link\",\"2\",{\"rel\":\"icon\",\"href\":\"/brand/pidance-logo.png\"}],[\"$\",\"link\",\"3\",{\"rel\":\"apple-touch-icon\",\"href\":\"/brand/pidance-logo.png\"}],[\"$\",\"$Lf\",\"4\",{}]]\n"])</script></body></html>
1
+ <!DOCTYPE html><html lang="en" translate="no" class="__variable_66b8ca notranslate"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" href="/_next/static/media/7deddc85b7ffd1dc-s.p.woff2" as="font" crossorigin="" type="font/woff2"/><link rel="preload" href="/_next/static/media/ec14413c594b3356-s.p.woff2" as="font" crossorigin="" type="font/woff2"/><link rel="stylesheet" href="/_next/static/css/88714c00e109ce28.css" data-precedence="next"/><link rel="stylesheet" href="/_next/static/css/0cf9ed5690d76263.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-d2379fd13c5c78c6.js"/><script src="/_next/static/chunks/4bd1b696-e356ca5ba0218e27.js" async=""></script><script src="/_next/static/chunks/3794-907785a527d8128b.js" async=""></script><script src="/_next/static/chunks/main-app-06b2b50b226e40d1.js" async=""></script><script src="/_next/static/chunks/9780-9ff103301d973613.js" async=""></script><script src="/_next/static/chunks/app/layout-88764b4be2728d3f.js" async=""></script><meta name="robots" content="noindex"/><meta name="next-size-adjust" content=""/><meta name="google" content="notranslate"/><title>404: This page could not be found.</title><title>Pidance</title><meta name="description" content="Open-source web client for the Pi coding agent"/><link rel="icon" href="/brand/pidance-logo.png"/><link rel="apple-touch-icon" href="/brand/pidance-logo.png"/><script>(function(){try{var r=document.documentElement,m=localStorage.getItem("pi-theme"),s=localStorage.getItem("pi-theme-style");if(m!=="light"&&m!=="dark"&&m!=="system")m="light";if(s!=="fusion"&&s!=="chamber")s="chamber";var d=m==="dark"||(m==="system"&&matchMedia("(prefers-color-scheme: dark)").matches);r.classList.toggle("dark",d);r.dataset.themeMode=m;r.dataset.themeStyle=s}catch(e){}})();</script><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body translate="no" class="notranslate" style="height:100dvh;display:flex;flex-direction:column"><div hidden=""><!--$--><!--/$--></div><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding:0 23px 0 0;font-size:24px;font-weight:500;vertical-align:top;line-height:49px">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:49px;margin:0">This page could not be found.</h2></div></div></div><!--$--><!--/$--><script src="/_next/static/chunks/webpack-d2379fd13c5c78c6.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[99780,[\"9780\",\"static/chunks/9780-9ff103301d973613.js\",\"7177\",\"static/chunks/app/layout-88764b4be2728d3f.js\"],\"I18nProvider\"]\n3:I[57121,[],\"\"]\n4:I[74581,[],\"\"]\n5:I[90484,[],\"OutletBoundary\"]\n6:\"$Sreact.suspense\"\n9:I[90484,[],\"ViewportBoundary\"]\nb:I[90484,[],\"MetadataBoundary\"]\nd:I[27123,[],\"default\",1]\n:HL[\"/_next/static/media/7deddc85b7ffd1dc-s.p.woff2\",\"font\",{\"crossOrigin\":\"\",\"type\":\"font/woff2\"}]\n:HL[\"/_next/static/media/ec14413c594b3356-s.p.woff2\",\"font\",{\"crossOrigin\":\"\",\"type\":\"font/woff2\"}]\n:HL[\"/_next/static/css/88714c00e109ce28.css\",\"style\"]\n:HL[\"/_next/static/css/0cf9ed5690d76263.css\",\"style\"]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"c\":[\"\",\"_not-found\"],\"q\":\"\",\"i\":false,\"f\":[[[\"\",{\"children\":[\"_not-found\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",16],[[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/88714c00e109ce28.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\",\"nonce\":\"$undefined\"}],[\"$\",\"link\",\"1\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/0cf9ed5690d76263.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\",\"nonce\":\"$undefined\"}]],[\"$\",\"html\",null,{\"lang\":\"en\",\"translate\":\"no\",\"className\":\"__variable_66b8ca notranslate\",\"suppressHydrationWarning\":true,\"children\":[[\"$\",\"head\",null,{\"children\":[[\"$\",\"meta\",null,{\"name\":\"google\",\"content\":\"notranslate\"}],[\"$\",\"script\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"(function(){try{var r=document.documentElement,m=localStorage.getItem(\\\"pi-theme\\\"),s=localStorage.getItem(\\\"pi-theme-style\\\");if(m!==\\\"light\\\"\u0026\u0026m!==\\\"dark\\\"\u0026\u0026m!==\\\"system\\\")m=\\\"light\\\";if(s!==\\\"fusion\\\"\u0026\u0026s!==\\\"chamber\\\")s=\\\"chamber\\\";var d=m===\\\"dark\\\"||(m===\\\"system\\\"\u0026\u0026matchMedia(\\\"(prefers-color-scheme: dark)\\\").matches);r.classList.toggle(\\\"dark\\\",d);r.dataset.themeMode=m;r.dataset.themeStyle=s}catch(e){}})();\"}}]]}],[\"$\",\"body\",null,{\"translate\":\"no\",\"className\":\"notranslate\",\"style\":{\"height\":\"100dvh\",\"display\":\"flex\",\"flexDirection\":\"column\"},\"children\":[\"$\",\"$L2\",null,{\"children\":[\"$\",\"$L3\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L4\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]}]}]]}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L3\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L4\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":404}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],null,[\"$\",\"$L5\",null,{\"children\":[\"$\",\"$6\",null,{\"name\":\"Next.MetadataOutlet\",\"children\":\"$@7\"}]}]]}],{},null,false,null]},null,false,\"$@8\"]},null,false,null],[\"$\",\"$1\",\"h\",{\"children\":[[\"$\",\"meta\",null,{\"name\":\"robots\",\"content\":\"noindex\"}],[\"$\",\"$L9\",null,{\"children\":\"$La\"}],[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$Lb\",null,{\"children\":[\"$\",\"$6\",null,{\"name\":\"Next.Metadata\",\"children\":\"$Lc\"}]}]}],[\"$\",\"meta\",null,{\"name\":\"next-size-adjust\",\"content\":\"\"}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$d\",[]],\"S\":true,\"h\":null,\"s\":\"$undefined\",\"l\":\"$undefined\",\"p\":\"$undefined\",\"d\":\"$undefined\",\"b\":\"P-GwTOtxwpdnWwlj9T66x\"}\n"])</script><script>self.__next_f.push([1,"e:[]\n8:\"$We\"\n"])</script><script>self.__next_f.push([1,"a:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n"])</script><script>self.__next_f.push([1,"f:I[86869,[],\"IconMark\"]\n7:null\nc:[[\"$\",\"title\",\"0\",{\"children\":\"Pidance\"}],[\"$\",\"meta\",\"1\",{\"name\":\"description\",\"content\":\"Open-source web client for the Pi coding agent\"}],[\"$\",\"link\",\"2\",{\"rel\":\"icon\",\"href\":\"/brand/pidance-logo.png\"}],[\"$\",\"link\",\"3\",{\"rel\":\"apple-touch-icon\",\"href\":\"/brand/pidance-logo.png\"}],[\"$\",\"$Lf\",\"4\",{}]]\n"])</script></body></html>
@@ -1 +1 @@
1
- <!DOCTYPE html><html id="__next_error__"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-d2379fd13c5c78c6.js"/><script src="/_next/static/chunks/4bd1b696-e356ca5ba0218e27.js" async=""></script><script src="/_next/static/chunks/3794-907785a527d8128b.js" async=""></script><script src="/_next/static/chunks/main-app-06b2b50b226e40d1.js" async=""></script><meta name="next-size-adjust" content=""/><title>500: This page couldn’t load</title><style>:root {--next-error-bg: #fff;--next-error-text: #171717;--next-error-title: #171717;--next-error-message: #171717;--next-error-digest: #666666;--next-error-btn-text: #fff;--next-error-btn-bg: #171717;--next-error-btn-border: none;--next-error-btn-secondary-text: #171717;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(0,0,0,0.08);}@media (prefers-color-scheme: dark) {:root {--next-error-bg: #0a0a0a;--next-error-text: #ededed;--next-error-title: #ededed;--next-error-message: #ededed;--next-error-digest: #a0a0a0;--next-error-btn-text: #0a0a0a;--next-error-btn-bg: #ededed;--next-error-btn-border: none;--next-error-btn-secondary-text: #ededed;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(255,255,255,0.14);}}body { margin: 0; color: var(--next-error-text); background: var(--next-error-bg); }</style><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body><div hidden=""><!--$--><!--/$--></div><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;display:flex;align-items:center;justify-content:center"><div style="margin-top:-32px;max-width:325px;padding:32px 28px;text-align:left"><svg width="32" height="32" viewBox="-0.2 -1.5 32 32" fill="none" style="margin-bottom:24px"><path d="M16.9328 0C18.0839 0.000116771 19.1334 0.658832 19.634 1.69531L31.4299 26.1309C32.0708 27.4588 31.1036 28.9999 29.6291 29H2.00215C0.527541 29 -0.439628 27.4588 0.201371 26.1309L11.9973 1.69531C12.4979 0.658823 13.5474 7.75066e-05 14.6984 0H16.9328ZM3.59493 26H28.0363L16.9328 3H14.6984L3.59493 26ZM15.8156 19C16.9202 19.0001 17.8156 19.8955 17.8156 21C17.8156 22.1045 16.9202 22.9999 15.8156 23C14.7111 23 13.8156 22.1046 13.8156 21C13.8156 19.8954 14.7111 19 15.8156 19ZM17.3156 16.5H14.3156V8.5H17.3156V16.5Z" fill="var(--next-error-title)"></path></svg><h1 style="font-size:24px;font-weight:500;letter-spacing:-0.02em;line-height:32px;margin:0 0 12px 0;color:var(--next-error-title)">This page couldn’t load</h1><p style="font-size:14px;font-weight:400;line-height:21px;margin:0 0 20px 0;color:var(--next-error-message)">A server error occurred. Reload to try again.</p><form style="margin:0"><button type="submit" style="display:inline-flex;align-items:center;justify-content:center;height:32px;padding:0 12px;font-size:14px;font-weight:500;line-height:20px;border-radius:6px;cursor:pointer;color:var(--next-error-btn-text);background:var(--next-error-btn-bg);border:var(--next-error-btn-border)">Reload</button></form></div></div><!--$--><!--/$--><script src="/_next/static/chunks/webpack-d2379fd13c5c78c6.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[57121,[],\"\"]\n3:I[74581,[],\"\"]\n4:I[90484,[],\"OutletBoundary\"]\n5:\"$Sreact.suspense\"\n8:I[90484,[],\"ViewportBoundary\"]\na:I[90484,[],\"MetadataBoundary\"]\nc:I[27123,[],\"default\",1]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"c\":[\"\",\"_global-error\"],\"q\":\"\",\"i\":false,\"f\":[[[\"\",{\"children\":[\"_global-error\",{\"children\":[\"__PAGE__\",{}]}]}],[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[[\"$\",\"html\",null,{\"id\":\"__next_error__\",\"children\":[[\"$\",\"head\",null,{\"children\":[[\"$\",\"title\",null,{\"children\":\"500: This page couldn’t load\"}],[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\":root {--next-error-bg: #fff;--next-error-text: #171717;--next-error-title: #171717;--next-error-message: #171717;--next-error-digest: #666666;--next-error-btn-text: #fff;--next-error-btn-bg: #171717;--next-error-btn-border: none;--next-error-btn-secondary-text: #171717;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(0,0,0,0.08);}@media (prefers-color-scheme: dark) {:root {--next-error-bg: #0a0a0a;--next-error-text: #ededed;--next-error-title: #ededed;--next-error-message: #ededed;--next-error-digest: #a0a0a0;--next-error-btn-text: #0a0a0a;--next-error-btn-bg: #ededed;--next-error-btn-border: none;--next-error-btn-secondary-text: #ededed;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(255,255,255,0.14);}}body { margin: 0; color: var(--next-error-text); background: var(--next-error-bg); }\"}}]]}],[\"$\",\"body\",null,{\"children\":[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"display\":\"flex\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"style\":{\"marginTop\":\"-32px\",\"maxWidth\":\"325px\",\"padding\":\"32px 28px\",\"textAlign\":\"left\"},\"children\":[[\"$\",\"svg\",null,{\"width\":\"32\",\"height\":\"32\",\"viewBox\":\"-0.2 -1.5 32 32\",\"fill\":\"none\",\"style\":{\"marginBottom\":\"24px\"},\"children\":[\"$\",\"path\",null,{\"d\":\"M16.9328 0C18.0839 0.000116771 19.1334 0.658832 19.634 1.69531L31.4299 26.1309C32.0708 27.4588 31.1036 28.9999 29.6291 29H2.00215C0.527541 29 -0.439628 27.4588 0.201371 26.1309L11.9973 1.69531C12.4979 0.658823 13.5474 7.75066e-05 14.6984 0H16.9328ZM3.59493 26H28.0363L16.9328 3H14.6984L3.59493 26ZM15.8156 19C16.9202 19.0001 17.8156 19.8955 17.8156 21C17.8156 22.1045 16.9202 22.9999 15.8156 23C14.7111 23 13.8156 22.1046 13.8156 21C13.8156 19.8954 14.7111 19 15.8156 19ZM17.3156 16.5H14.3156V8.5H17.3156V16.5Z\",\"fill\":\"var(--next-error-title)\"}]}],[\"$\",\"h1\",null,{\"style\":{\"fontSize\":\"24px\",\"fontWeight\":500,\"letterSpacing\":\"-0.02em\",\"lineHeight\":\"32px\",\"margin\":\"0 0 12px 0\",\"color\":\"var(--next-error-title)\"},\"children\":\"This page couldn’t load\"}],[\"$\",\"p\",null,{\"style\":{\"fontSize\":\"14px\",\"fontWeight\":400,\"lineHeight\":\"21px\",\"margin\":\"0 0 20px 0\",\"color\":\"var(--next-error-message)\"},\"children\":\"A server error occurred. Reload to try again.\"}],[\"$\",\"form\",null,{\"style\":{\"margin\":0},\"children\":[\"$\",\"button\",null,{\"type\":\"submit\",\"style\":{\"display\":\"inline-flex\",\"alignItems\":\"center\",\"justifyContent\":\"center\",\"height\":\"32px\",\"padding\":\"0 12px\",\"fontSize\":\"14px\",\"fontWeight\":500,\"lineHeight\":\"20px\",\"borderRadius\":\"6px\",\"cursor\":\"pointer\",\"color\":\"var(--next-error-btn-text)\",\"background\":\"var(--next-error-btn-bg)\",\"border\":\"var(--next-error-btn-border)\"},\"children\":\"Reload\"}]}]]}]}]}]]}],null,[\"$\",\"$L4\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.MetadataOutlet\",\"children\":\"$@6\"}]}]]}],{},null,false,null]},null,false,\"$@7\"]},null,false,\"$@7\"],[\"$\",\"$1\",\"h\",{\"children\":[null,[\"$\",\"$L8\",null,{\"children\":\"$L9\"}],[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$La\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.Metadata\",\"children\":\"$Lb\"}]}]}],[\"$\",\"meta\",null,{\"name\":\"next-size-adjust\",\"content\":\"\"}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$c\",[]],\"S\":true,\"h\":null,\"s\":\"$undefined\",\"l\":\"$undefined\",\"p\":\"$undefined\",\"d\":\"$undefined\",\"b\":\"tj04wII7Oz8Z4qdCTh4TE\"}\n"])</script><script>self.__next_f.push([1,"d:[]\n7:\"$Wd\"\n"])</script><script>self.__next_f.push([1,"9:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n"])</script><script>self.__next_f.push([1,"6:null\nb:[]\n"])</script></body></html>
1
+ <!DOCTYPE html><html id="__next_error__"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-d2379fd13c5c78c6.js"/><script src="/_next/static/chunks/4bd1b696-e356ca5ba0218e27.js" async=""></script><script src="/_next/static/chunks/3794-907785a527d8128b.js" async=""></script><script src="/_next/static/chunks/main-app-06b2b50b226e40d1.js" async=""></script><meta name="next-size-adjust" content=""/><title>500: This page couldn’t load</title><style>:root {--next-error-bg: #fff;--next-error-text: #171717;--next-error-title: #171717;--next-error-message: #171717;--next-error-digest: #666666;--next-error-btn-text: #fff;--next-error-btn-bg: #171717;--next-error-btn-border: none;--next-error-btn-secondary-text: #171717;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(0,0,0,0.08);}@media (prefers-color-scheme: dark) {:root {--next-error-bg: #0a0a0a;--next-error-text: #ededed;--next-error-title: #ededed;--next-error-message: #ededed;--next-error-digest: #a0a0a0;--next-error-btn-text: #0a0a0a;--next-error-btn-bg: #ededed;--next-error-btn-border: none;--next-error-btn-secondary-text: #ededed;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(255,255,255,0.14);}}body { margin: 0; color: var(--next-error-text); background: var(--next-error-bg); }</style><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body><div hidden=""><!--$--><!--/$--></div><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;display:flex;align-items:center;justify-content:center"><div style="margin-top:-32px;max-width:325px;padding:32px 28px;text-align:left"><svg width="32" height="32" viewBox="-0.2 -1.5 32 32" fill="none" style="margin-bottom:24px"><path d="M16.9328 0C18.0839 0.000116771 19.1334 0.658832 19.634 1.69531L31.4299 26.1309C32.0708 27.4588 31.1036 28.9999 29.6291 29H2.00215C0.527541 29 -0.439628 27.4588 0.201371 26.1309L11.9973 1.69531C12.4979 0.658823 13.5474 7.75066e-05 14.6984 0H16.9328ZM3.59493 26H28.0363L16.9328 3H14.6984L3.59493 26ZM15.8156 19C16.9202 19.0001 17.8156 19.8955 17.8156 21C17.8156 22.1045 16.9202 22.9999 15.8156 23C14.7111 23 13.8156 22.1046 13.8156 21C13.8156 19.8954 14.7111 19 15.8156 19ZM17.3156 16.5H14.3156V8.5H17.3156V16.5Z" fill="var(--next-error-title)"></path></svg><h1 style="font-size:24px;font-weight:500;letter-spacing:-0.02em;line-height:32px;margin:0 0 12px 0;color:var(--next-error-title)">This page couldn’t load</h1><p style="font-size:14px;font-weight:400;line-height:21px;margin:0 0 20px 0;color:var(--next-error-message)">A server error occurred. Reload to try again.</p><form style="margin:0"><button type="submit" style="display:inline-flex;align-items:center;justify-content:center;height:32px;padding:0 12px;font-size:14px;font-weight:500;line-height:20px;border-radius:6px;cursor:pointer;color:var(--next-error-btn-text);background:var(--next-error-btn-bg);border:var(--next-error-btn-border)">Reload</button></form></div></div><!--$--><!--/$--><script src="/_next/static/chunks/webpack-d2379fd13c5c78c6.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[57121,[],\"\"]\n3:I[74581,[],\"\"]\n4:I[90484,[],\"OutletBoundary\"]\n5:\"$Sreact.suspense\"\n8:I[90484,[],\"ViewportBoundary\"]\na:I[90484,[],\"MetadataBoundary\"]\nc:I[27123,[],\"default\",1]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"c\":[\"\",\"_global-error\"],\"q\":\"\",\"i\":false,\"f\":[[[\"\",{\"children\":[\"_global-error\",{\"children\":[\"__PAGE__\",{}]}]}],[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[[\"$\",\"html\",null,{\"id\":\"__next_error__\",\"children\":[[\"$\",\"head\",null,{\"children\":[[\"$\",\"title\",null,{\"children\":\"500: This page couldn’t load\"}],[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\":root {--next-error-bg: #fff;--next-error-text: #171717;--next-error-title: #171717;--next-error-message: #171717;--next-error-digest: #666666;--next-error-btn-text: #fff;--next-error-btn-bg: #171717;--next-error-btn-border: none;--next-error-btn-secondary-text: #171717;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(0,0,0,0.08);}@media (prefers-color-scheme: dark) {:root {--next-error-bg: #0a0a0a;--next-error-text: #ededed;--next-error-title: #ededed;--next-error-message: #ededed;--next-error-digest: #a0a0a0;--next-error-btn-text: #0a0a0a;--next-error-btn-bg: #ededed;--next-error-btn-border: none;--next-error-btn-secondary-text: #ededed;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(255,255,255,0.14);}}body { margin: 0; color: var(--next-error-text); background: var(--next-error-bg); }\"}}]]}],[\"$\",\"body\",null,{\"children\":[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"display\":\"flex\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"style\":{\"marginTop\":\"-32px\",\"maxWidth\":\"325px\",\"padding\":\"32px 28px\",\"textAlign\":\"left\"},\"children\":[[\"$\",\"svg\",null,{\"width\":\"32\",\"height\":\"32\",\"viewBox\":\"-0.2 -1.5 32 32\",\"fill\":\"none\",\"style\":{\"marginBottom\":\"24px\"},\"children\":[\"$\",\"path\",null,{\"d\":\"M16.9328 0C18.0839 0.000116771 19.1334 0.658832 19.634 1.69531L31.4299 26.1309C32.0708 27.4588 31.1036 28.9999 29.6291 29H2.00215C0.527541 29 -0.439628 27.4588 0.201371 26.1309L11.9973 1.69531C12.4979 0.658823 13.5474 7.75066e-05 14.6984 0H16.9328ZM3.59493 26H28.0363L16.9328 3H14.6984L3.59493 26ZM15.8156 19C16.9202 19.0001 17.8156 19.8955 17.8156 21C17.8156 22.1045 16.9202 22.9999 15.8156 23C14.7111 23 13.8156 22.1046 13.8156 21C13.8156 19.8954 14.7111 19 15.8156 19ZM17.3156 16.5H14.3156V8.5H17.3156V16.5Z\",\"fill\":\"var(--next-error-title)\"}]}],[\"$\",\"h1\",null,{\"style\":{\"fontSize\":\"24px\",\"fontWeight\":500,\"letterSpacing\":\"-0.02em\",\"lineHeight\":\"32px\",\"margin\":\"0 0 12px 0\",\"color\":\"var(--next-error-title)\"},\"children\":\"This page couldn’t load\"}],[\"$\",\"p\",null,{\"style\":{\"fontSize\":\"14px\",\"fontWeight\":400,\"lineHeight\":\"21px\",\"margin\":\"0 0 20px 0\",\"color\":\"var(--next-error-message)\"},\"children\":\"A server error occurred. Reload to try again.\"}],[\"$\",\"form\",null,{\"style\":{\"margin\":0},\"children\":[\"$\",\"button\",null,{\"type\":\"submit\",\"style\":{\"display\":\"inline-flex\",\"alignItems\":\"center\",\"justifyContent\":\"center\",\"height\":\"32px\",\"padding\":\"0 12px\",\"fontSize\":\"14px\",\"fontWeight\":500,\"lineHeight\":\"20px\",\"borderRadius\":\"6px\",\"cursor\":\"pointer\",\"color\":\"var(--next-error-btn-text)\",\"background\":\"var(--next-error-btn-bg)\",\"border\":\"var(--next-error-btn-border)\"},\"children\":\"Reload\"}]}]]}]}]}]]}],null,[\"$\",\"$L4\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.MetadataOutlet\",\"children\":\"$@6\"}]}]]}],{},null,false,null]},null,false,\"$@7\"]},null,false,\"$@7\"],[\"$\",\"$1\",\"h\",{\"children\":[null,[\"$\",\"$L8\",null,{\"children\":\"$L9\"}],[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$La\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.Metadata\",\"children\":\"$Lb\"}]}]}],[\"$\",\"meta\",null,{\"name\":\"next-size-adjust\",\"content\":\"\"}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$c\",[]],\"S\":true,\"h\":null,\"s\":\"$undefined\",\"l\":\"$undefined\",\"p\":\"$undefined\",\"d\":\"$undefined\",\"b\":\"P-GwTOtxwpdnWwlj9T66x\"}\n"])</script><script>self.__next_f.push([1,"d:[]\n7:\"$Wd\"\n"])</script><script>self.__next_f.push([1,"9:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n"])</script><script>self.__next_f.push([1,"6:null\nb:[]\n"])</script></body></html>
@@ -1 +1 @@
1
- {"node":{},"edge":{},"encryptionKey":"jqNxaEt+kwRxDxY1O+6JDGQC+xIcZvsYfWALvb/NGFE="}
1
+ {"node":{},"edge":{},"encryptionKey":"Y4EG5kwsq58mKwUm9MMpTq4/rII31jSMJpWA1HSER/0="}