blade-code 0.10.99 → 0.10.101

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 (70) hide show
  1. package/dist/blade.js +2 -2
  2. package/dist/{chunk-r22mdmtr.js → chunk-2191220r.js} +1 -1
  3. package/dist/{chunk-bdbyy2ah.js → chunk-2cg8f38t.js} +1 -1
  4. package/dist/{chunk-ap8539bw.js → chunk-2f5kkhan.js} +274 -274
  5. package/dist/chunk-2r0f3b4t.js +1 -0
  6. package/dist/{chunk-qdgwprcv.js → chunk-3an3vxzt.js} +1 -1
  7. package/dist/{chunk-2jffgzdf.js → chunk-3c01jje5.js} +1 -1
  8. package/dist/{chunk-12vzyc3x.js → chunk-8yt4nmyb.js} +1 -1
  9. package/dist/chunk-8z9d0zd0.js +2 -0
  10. package/dist/chunk-9ajkzcqj.js +12 -0
  11. package/dist/chunk-as2ezx8p.js +1 -0
  12. package/dist/{chunk-vd6kmnc7.js → chunk-bswjne5v.js} +1 -1
  13. package/dist/{chunk-9z0yx0bn.js → chunk-c663rajb.js} +1 -1
  14. package/dist/chunk-cjgpas7y.js +23 -0
  15. package/dist/{chunk-6yz49rz2.js → chunk-dcjh1cj6.js} +1 -1
  16. package/dist/{chunk-71jnx206.js → chunk-f8z5v101.js} +1 -1
  17. package/dist/{chunk-ga15nptz.js → chunk-fqbc1ppx.js} +1 -1
  18. package/dist/{chunk-h8qjkxee.js → chunk-hpjnk87v.js} +18 -18
  19. package/dist/{chunk-1gjn9bp7.js → chunk-j22d84s7.js} +1 -1
  20. package/dist/{chunk-45sgvghd.js → chunk-jvxskq6a.js} +1 -1
  21. package/dist/{chunk-6vcy0nq7.js → chunk-kdatgrjy.js} +1 -1
  22. package/dist/{chunk-akfez2cs.js → chunk-kfcs62nw.js} +1 -1
  23. package/dist/{chunk-gmnv1jme.js → chunk-mzab7qak.js} +1 -1
  24. package/dist/{chunk-xg959k9w.js → chunk-n5jfmzp2.js} +1 -1
  25. package/dist/{chunk-d7j7z8hy.js → chunk-nh4jy5cs.js} +9 -1
  26. package/dist/{chunk-hyk4fw18.js → chunk-qgjgjzbx.js} +1 -1
  27. package/dist/{chunk-5dkzqgxa.js → chunk-qjeadpj2.js} +1 -1
  28. package/dist/chunk-qjv5kz7q.js +171 -0
  29. package/dist/chunk-sa7t9kht.js +6 -0
  30. package/dist/{chunk-p7zvg7e3.js → chunk-tazb5tze.js} +1 -1
  31. package/dist/chunk-tc9rq0st.js +160 -0
  32. package/dist/{chunk-a42rvwg4.js → chunk-tp5bep1y.js} +1 -1
  33. package/dist/{chunk-qwjfxvda.js → chunk-twhf09qs.js} +1 -1
  34. package/dist/{chunk-et6pvc3y.js → chunk-vc7gh3wc.js} +1 -1
  35. package/dist/{chunk-pmb5kr86.js → chunk-wbf4qcws.js} +2 -2
  36. package/dist/chunk-ykf4cqpg.js +8 -0
  37. package/dist/{chunk-1pscfw5q.js → chunk-z0dmm227.js} +1 -1
  38. package/dist/{chunk-fqwq3626.js → chunk-z5a8ay9s.js} +1 -1
  39. package/dist/{chunk-gwj637ey.js → chunk-zjpph3ys.js} +1 -1
  40. package/dist/{chunk-x5j6nexe.js → chunk-zydvg30x.js} +1 -1
  41. package/dist/web/assets/{ChatView-Cwc3fRAC.js → ChatView-Cc4bXZ6x.js} +14 -14
  42. package/dist/web/assets/{CodeBlockHighlighter-IGDocZUy.js → CodeBlockHighlighter-DZcVFtJE.js} +1 -1
  43. package/dist/web/assets/{FilePreview-EWE-k9VN.js → FilePreview-CzNS6kfM.js} +1 -1
  44. package/dist/web/assets/{KanbanBoard-FiiVQgTQ.js → KanbanBoard-cdh2g0r0.js} +1 -1
  45. package/dist/web/assets/{MarkdownRenderer-DjhWmikM.js → MarkdownRenderer-BqBOUlXa.js} +3 -3
  46. package/dist/web/assets/{SettingsModal-bHPx0fVG.js → SettingsModal-meSWhCOP.js} +1 -1
  47. package/dist/web/assets/{TaskSwitcher-CclOfJEl.js → TaskSwitcher-CiQi64Yl.js} +1 -1
  48. package/dist/web/assets/{TerminalPanel-Bnep8jE2.js → TerminalPanel-Bze9t5mz.js} +1 -1
  49. package/dist/web/assets/{arrow-left-CiX0E9Mt.js → arrow-left-DpTnLOBT.js} +1 -1
  50. package/dist/web/assets/{calendar-clock-Bgfr-twh.js → calendar-clock-DlAXXpl_.js} +1 -1
  51. package/dist/web/assets/{chevrons-up-down-B4T5fHUs.js → chevrons-up-down-CmAktdaR.js} +1 -1
  52. package/dist/web/assets/{clock-3-CGIhJjon.js → clock-3-_w8nIuEK.js} +1 -1
  53. package/dist/web/assets/{external-link-DnQv1VYE.js → external-link-AlymrIfc.js} +1 -1
  54. package/dist/web/assets/{folder-C5f8TpGj.js → folder-CrxO-9Rc.js} +1 -1
  55. package/dist/web/assets/{index-DNoVz0u1.js → index-JJH0FKfo.js} +5 -5
  56. package/dist/web/assets/{pause-Cb0ijwnO.js → pause-GQZaG_P3.js} +1 -1
  57. package/dist/web/assets/{play-Dsw1qmpk.js → play-BPhmPVpi.js} +1 -1
  58. package/dist/web/assets/{session-events-B4Cq2TwN.js → session-events-CO2pRY9U.js} +8 -8
  59. package/dist/web/assets/{teamService-C69fFhny.js → teamService-BqS4iOx0.js} +1 -1
  60. package/dist/web/index.html +2 -2
  61. package/package.json +1 -1
  62. package/dist/chunk-3ghvdscg.js +0 -9
  63. package/dist/chunk-5tq3s9h5.js +0 -160
  64. package/dist/chunk-c2s9rgyj.js +0 -1
  65. package/dist/chunk-cc3d4nne.js +0 -23
  66. package/dist/chunk-hcz98dbj.js +0 -1
  67. package/dist/chunk-mhfwp1f0.js +0 -2
  68. package/dist/chunk-mq4x8zhq.js +0 -171
  69. package/dist/chunk-spdrxj5e.js +0 -6
  70. package/dist/chunk-xz5ar75z.js +0 -8
@@ -1,17 +1,17 @@
1
- import{ni as r}from"./chunk-d8wzc602.js";import{Li as d,Ni as x,Pi as j,Ti as u,Ui as i}from"./chunk-q3vza5gt.js";import{Vi as y}from"./chunk-w9xfks7f.js";import{stat as a}from"node:fs/promises";import k from"node:path";import*as U from"node:path";var e=50,__=100,E_=new Set(["queued","running","completed","failed","cancelled","interrupted"]),R_=new Set(["high","medium","low"]),W_=/^[A-Za-z0-9_-]+$/,$_=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?(?:Z|[+-]\d{2}:\d{2})$/;function H_(_){return typeof _==="string"&&$_.test(_)&&Number.isFinite(Date.parse(_))}function v(_){return typeof _==="string"&&U.isAbsolute(_)}function M_(_){return Buffer.from(JSON.stringify(_),"utf8").toString("base64url")}function Q_(_){try{if(!W_.test(_))throw Error("invalid");let E=Buffer.from(_,"base64url").toString("utf8");if(Buffer.from(E,"utf8").toString("base64url")!==_)throw Error("invalid");let R=JSON.parse(E);if(R.version!==1||typeof R.includeSubagents!=="boolean"||R.archived!==void 0&&typeof R.archived!=="boolean"||!(R.cwd===null||v(R.cwd))||!H_(R.lastMessageTime)||!v(R.projectPath)||!x(R.sessionId))throw Error("invalid");return{version:1,cwd:R.cwd===null?null:U.resolve(R.cwd),includeSubagents:R.includeSubagents,archived:R.archived??!1,lastMessageTime:R.lastMessageTime,projectPath:U.resolve(R.projectPath),sessionId:R.sessionId}}catch{throw Error("Invalid session cursor")}}function J(_){let E="";for(let R=0;R<_.length;R+=1)E+=_.charCodeAt(R).toString(16).padStart(4,"0");return E}function V_(_){if(!_.cursor)return;let E=Q_(_.cursor);if(E.cwd!==_.cwd||E.includeSubagents!==_.includeSubagents||(E.archived??!1)!==_.archived)throw Error("Session cursor scope does not match this query");return E}function O_(_={}){let{cwd:E,cursor:R,limit:W,includeSubagents:$=!1,archived:H=!1}=_;if(E!==void 0&&!U.isAbsolute(E))throw Error("Session catalog cwd must be absolute");let M=W===void 0?e:W;if(!Number.isInteger(M)||M<1||M>__)throw Error("Session catalog limit must be an integer from 1 to 100");return{cwd:E===void 0?null:U.resolve(E),cursor:R??void 0,limit:M,includeSubagents:$,archived:H}}function N_(_={}){let E=c(_.taskStatus,E_,"task status"),R=c(_.taskPriority,R_,"task priority"),W=S(_.taskDueAfter,"taskDueAfter"),$=S(_.taskDueBefore,"taskDueBefore");return X_(W,$),{...E?{taskStatuses:E}:{},...R?{taskPriorities:R}:{},...W?{taskDueAfter:W}:{},...$?{taskDueBefore:$}:{}}}function c(_,E,R){if(_===void 0)return;let W=Array.isArray(_)?_:[_];if(W.length===0)return;let $=new Set;for(let H of W){if(typeof H!=="string"||!E.has(H))throw Error(`Invalid session ${R} filter`);$.add(H)}return[...$].sort()}function S(_,E){if(_===void 0)return;if(typeof _!=="string"||!Number.isFinite(Date.parse(_)))throw Error(`Invalid session ${E} filter`);return new Date(_).toISOString()}function X_(_,E){if(_!==void 0&&E!==void 0&&_>E)throw Error("Session task due range is inverted")}function Y_(_,E){if(_.lastMessageTime>E.lastMessageTime)return-1;if(_.lastMessageTime<E.lastMessageTime)return 1;if(_.projectPath<E.projectPath)return-1;if(_.projectPath>E.projectPath)return 1;if(_.sessionId<E.sessionId)return-1;if(_.sessionId>E.sessionId)return 1;return 0}function f_(_,E){let R=[..._],W=V_(E);if(W)R=R.filter((M)=>Y_(M,{sessionId:W.sessionId,projectPath:W.projectPath,lastMessageTime:W.lastMessageTime})>0);let $=R.slice(0,E.limit);if($.length===0||R.length<=$.length)return{sessions:$};let H=$[$.length-1];return{sessions:$,nextCursor:M_({version:1,cwd:E.cwd,includeSubagents:E.includeSubagents,archived:E.archived,lastMessageTime:H.lastMessageTime,projectPath:H.projectPath,sessionId:H.sessionId})}}function G_(_){return _.type==="message_created"||_.type==="token_budget_handoff_recorded"||_.type==="part_created"||_.type==="part_updated"||_.type==="turn_started"||_.type==="turn_completed"||_.type==="turn_aborted"||_.type==="interaction_requested"||_.type==="interaction_responded"||_.type==="interaction_recovered"||_.type==="review_started"||_.type==="review_completed"}function O(_){return _.type==="message_created"&&_.data.role==="user"&&(_.data.inboxMessageId!==void 0||_.data.parentMessageId===void 0)}function N(_,E){let R=_.find((W)=>O(W)&&W.data.messageId===E);if(!R)throw Error(`Rewind checkpoint not found: ${E}`);return{messageId:E,preview:m(_,E),createdAt:R.data.createdAt}}function m(_,E){let R=_.flatMap((W)=>{if(W.type!=="part_created"||W.data.messageId!==E)return[];if(W.data.partType==="text"){let $=W.data.payload;return typeof $.text==="string"?[$.text]:[]}if(W.data.partType==="image")return["[Image]"];return[]}).join("").trim();if(R.length<=160)return R;return`${R.slice(0,160)}...`}function h(_,E){N(_,E);let R=_.findIndex((M)=>M.type==="message_created"&&M.data.messageId===E),W=_[R],$=W?.type==="message_created"?W.data.inboxMessageId:void 0,H=new Set(_.flatMap((M)=>M.type==="turn_started"&&$&&M.data.inputMessageIds?.includes($)?[M.data.turnId]:[]));return _.filter((M,Q)=>{if((M.type==="turn_started"||M.type==="turn_completed"||M.type==="turn_aborted")&&H.has(M.data.turnId))return!1;return Q<R||!G_(M)})}function D(_){let E=[];for(let R of _){if(R.type!=="session_rewound"){E.push(R);continue}if(N(E,R.data.targetMessageId),R.data.mode!=="code")E=h(E,R.data.targetMessageId)}return E}function j_(_){let E=D(_);return E.filter(O).map((R)=>({messageId:R.data.messageId,preview:m(E,R.data.messageId),createdAt:R.data.createdAt})).reverse()}function u_(_,E){let R=D(_),W=N(R,E),$=R.findIndex((M)=>M.type==="message_created"&&M.data.messageId===E),H=R.slice($);return{checkpoint:W,projectedEntries:h(R,E),removedTurns:H.filter(O).length,snapshotMessageIds:H.flatMap((M)=>M.type==="part_created"&&M.data.partType==="tool_call"?[M.data.partId]:[])}}import*as I from"node:fs";import{createReadStream as T_}from"node:fs";import*as X from"node:fs/promises";import*as f from"node:path";import{createInterface as Z_}from"node:readline";var b=65536;function w(_){let E=_.data;if(E===null||typeof E!=="object"||Array.isArray(E))throw Error("Session event data must be a JSON object");return JSON.stringify(_)}function g_(_,E,R){let W=_.trim();if(!W)return;try{return JSON.parse(W)}catch($){throw Error(`Invalid session JSONL in ${R} at line ${E}`,{cause:$})}}function z(_,E="session transcript"){let R=_.split(`
1
+ import{ni as r}from"./chunk-d8wzc602.js";import{Li as d,Ni as x,Pi as j,Ti as u,Ui as i}from"./chunk-q3vza5gt.js";import{Vi as I}from"./chunk-w9xfks7f.js";import{stat as a}from"node:fs/promises";import B from"node:path";import*as U from"node:path";var e=50,__=100,E_=new Set(["queued","running","completed","failed","cancelled","interrupted"]),R_=new Set(["high","medium","low"]),W_=/^[A-Za-z0-9_-]+$/,$_=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?(?:Z|[+-]\d{2}:\d{2})$/;function H_(_){return typeof _==="string"&&$_.test(_)&&Number.isFinite(Date.parse(_))}function v(_){return typeof _==="string"&&U.isAbsolute(_)}function M_(_){return Buffer.from(JSON.stringify(_),"utf8").toString("base64url")}function Q_(_){try{if(!W_.test(_))throw Error("invalid");let E=Buffer.from(_,"base64url").toString("utf8");if(Buffer.from(E,"utf8").toString("base64url")!==_)throw Error("invalid");let R=JSON.parse(E);if(R.version!==1||typeof R.includeSubagents!=="boolean"||R.archived!==void 0&&typeof R.archived!=="boolean"||!(R.cwd===null||v(R.cwd))||!H_(R.lastMessageTime)||!v(R.projectPath)||!x(R.sessionId))throw Error("invalid");return{version:1,cwd:R.cwd===null?null:U.resolve(R.cwd),includeSubagents:R.includeSubagents,archived:R.archived??!1,lastMessageTime:R.lastMessageTime,projectPath:U.resolve(R.projectPath),sessionId:R.sessionId}}catch{throw Error("Invalid session cursor")}}function J(_){let E="";for(let R=0;R<_.length;R+=1)E+=_.charCodeAt(R).toString(16).padStart(4,"0");return E}function V_(_){if(!_.cursor)return;let E=Q_(_.cursor);if(E.cwd!==_.cwd||E.includeSubagents!==_.includeSubagents||(E.archived??!1)!==_.archived)throw Error("Session cursor scope does not match this query");return E}function O_(_={}){let{cwd:E,cursor:R,limit:W,includeSubagents:$=!1,archived:M=!1}=_;if(E!==void 0&&!U.isAbsolute(E))throw Error("Session catalog cwd must be absolute");let H=W===void 0?e:W;if(!Number.isInteger(H)||H<1||H>__)throw Error("Session catalog limit must be an integer from 1 to 100");return{cwd:E===void 0?null:U.resolve(E),cursor:R??void 0,limit:H,includeSubagents:$,archived:M}}function N_(_={}){let E=c(_.taskStatus,E_,"task status"),R=c(_.taskPriority,R_,"task priority"),W=S(_.taskDueAfter,"taskDueAfter"),$=S(_.taskDueBefore,"taskDueBefore");return X_(W,$),{...E?{taskStatuses:E}:{},...R?{taskPriorities:R}:{},...W?{taskDueAfter:W}:{},...$?{taskDueBefore:$}:{}}}function c(_,E,R){if(_===void 0)return;let W=Array.isArray(_)?_:[_];if(W.length===0)return;let $=new Set;for(let M of W){if(typeof M!=="string"||!E.has(M))throw Error(`Invalid session ${R} filter`);$.add(M)}return[...$].sort()}function S(_,E){if(_===void 0)return;if(typeof _!=="string"||!Number.isFinite(Date.parse(_)))throw Error(`Invalid session ${E} filter`);return new Date(_).toISOString()}function X_(_,E){if(_!==void 0&&E!==void 0&&_>E)throw Error("Session task due range is inverted")}function Y_(_,E){if(_.lastMessageTime>E.lastMessageTime)return-1;if(_.lastMessageTime<E.lastMessageTime)return 1;if(_.projectPath<E.projectPath)return-1;if(_.projectPath>E.projectPath)return 1;if(_.sessionId<E.sessionId)return-1;if(_.sessionId>E.sessionId)return 1;return 0}function f_(_,E){let R=[..._],W=V_(E);if(W)R=R.filter((H)=>Y_(H,{sessionId:W.sessionId,projectPath:W.projectPath,lastMessageTime:W.lastMessageTime})>0);let $=R.slice(0,E.limit);if($.length===0||R.length<=$.length)return{sessions:$};let M=$[$.length-1];return{sessions:$,nextCursor:M_({version:1,cwd:E.cwd,includeSubagents:E.includeSubagents,archived:E.archived,lastMessageTime:M.lastMessageTime,projectPath:M.projectPath,sessionId:M.sessionId})}}function G_(_){return _.type==="message_created"||_.type==="token_budget_handoff_recorded"||_.type==="part_created"||_.type==="part_updated"||_.type==="turn_started"||_.type==="turn_completed"||_.type==="turn_aborted"||_.type==="turn_recovery_acknowledged"||_.type==="interaction_requested"||_.type==="interaction_responded"||_.type==="interaction_recovered"||_.type==="review_started"||_.type==="review_completed"}function O(_){return _.type==="message_created"&&_.data.role==="user"&&(_.data.inboxMessageId!==void 0||_.data.parentMessageId===void 0)}function N(_,E){let R=_.find((W)=>O(W)&&W.data.messageId===E);if(!R)throw Error(`Rewind checkpoint not found: ${E}`);return{messageId:E,preview:m(_,E),createdAt:R.data.createdAt}}function m(_,E){let R=_.flatMap((W)=>{if(W.type!=="part_created"||W.data.messageId!==E)return[];if(W.data.partType==="text"){let $=W.data.payload;return typeof $.text==="string"?[$.text]:[]}if(W.data.partType==="image")return["[Image]"];return[]}).join("").trim();if(R.length<=160)return R;return`${R.slice(0,160)}...`}function h(_,E){N(_,E);let R=_.findIndex((H)=>H.type==="message_created"&&H.data.messageId===E),W=_[R],$=W?.type==="message_created"?W.data.inboxMessageId:void 0,M=new Set(_.flatMap((H)=>H.type==="turn_started"&&$&&H.data.inputMessageIds?.includes($)?[H.data.turnId]:[]));return _.filter((H,Q)=>{if((H.type==="turn_started"||H.type==="turn_completed"||H.type==="turn_aborted"||H.type==="turn_recovery_acknowledged")&&M.has(H.data.turnId))return!1;return Q<R||!G_(H)})}function w(_){let E=[];for(let R of _){if(R.type!=="session_rewound"){E.push(R);continue}if(N(E,R.data.targetMessageId),R.data.mode!=="code")E=h(E,R.data.targetMessageId)}return E}function j_(_){let E=w(_);return E.filter(O).map((R)=>({messageId:R.data.messageId,preview:m(E,R.data.messageId),createdAt:R.data.createdAt})).reverse()}function u_(_,E){let R=w(_),W=N(R,E),$=R.findIndex((H)=>H.type==="message_created"&&H.data.messageId===E),M=R.slice($);return{checkpoint:W,projectedEntries:h(R,E),removedTurns:M.filter(O).length,snapshotMessageIds:M.flatMap((H)=>H.type==="part_created"&&H.data.partType==="tool_call"?[H.data.partId]:[])}}import*as z from"node:fs";import{createReadStream as g_}from"node:fs";import*as X from"node:fs/promises";import*as f from"node:path";import{createInterface as T_}from"node:readline";var b=65536;function D(_){let E=_.data;if(E===null||typeof E!=="object"||Array.isArray(E))throw Error("Session event data must be a JSON object");return JSON.stringify(_)}function Z_(_,E,R){let W=_.trim();if(!W)return;try{return JSON.parse(W)}catch($){throw Error(`Invalid session JSONL in ${R} at line ${E}`,{cause:$})}}function y(_,E="session transcript"){let R=_.split(`
2
2
  `),W=!_.endsWith(`
3
- `),$=[];for(let[H,M]of R.entries())try{let Q=g_(M,H+1,E);if(Q){if(typeof Q.seq!=="number")Q.seq=$.length+1;$.push(Q)}}catch(Q){if(W&&H===R.length-1)break;throw Q}return $}class G{static appendQueues=new Map;filePath;constructor(_){this.filePath=_}static maxSeq(_){let E=0;for(let R of _)if(typeof R.seq==="number"&&R.seq>E)E=R.seq;return E}static stampSeqFrom(_,E){let R=E;return _.map((W)=>{if(typeof W.seq==="number"){if(W.seq>R)R=W.seq;return W}return R+=1,{...W,seq:R}})}static stampSeq(_,E){return G.stampSeqFrom(_,G.maxSeq(E))}async append(_){try{let[E]=await this.appendEntries([_]);return E}catch(E){throw console.error(`[JSONLStore] 追加写入失败: ${this.filePath}`,E),E}}async appendBatch(_){try{return await this.appendEntries(_)}catch(E){throw console.error(`[JSONLStore] 批量追加写入失败: ${this.filePath}`,E),E}}async appendEntries(_){if(_.length===0)return[];return this.enqueue(async()=>{await X.mkdir(f.dirname(this.filePath),{recursive:!0,mode:493});let E=await X.open(this.filePath,"a+",384);try{let R=await this.repairIncompleteTail(E),W=await this.readTailSeq(E),$=G.stampSeqFrom(_,W),H=`${$.map(w).join(`
3
+ `),$=[];for(let[M,H]of R.entries())try{let Q=Z_(H,M+1,E);if(Q){if(typeof Q.seq!=="number")Q.seq=$.length+1;$.push(Q)}}catch(Q){if(W&&M===R.length-1)break;throw Q}return $}class G{static appendQueues=new Map;filePath;constructor(_){this.filePath=_}static maxSeq(_){let E=0;for(let R of _)if(typeof R.seq==="number"&&R.seq>E)E=R.seq;return E}static stampSeqFrom(_,E){let R=E;return _.map((W)=>{if(typeof W.seq==="number"){if(W.seq>R)R=W.seq;return W}return R+=1,{...W,seq:R}})}static stampSeq(_,E){return G.stampSeqFrom(_,G.maxSeq(E))}async append(_){try{let[E]=await this.appendEntries([_]);return E}catch(E){throw console.error(`[JSONLStore] 追加写入失败: ${this.filePath}`,E),E}}async appendBatch(_){try{return await this.appendEntries(_)}catch(E){throw console.error(`[JSONLStore] 批量追加写入失败: ${this.filePath}`,E),E}}async appendEntries(_){if(_.length===0)return[];return this.enqueue(async()=>{await X.mkdir(f.dirname(this.filePath),{recursive:!0,mode:493});let E=await X.open(this.filePath,"a+",384);try{let R=await this.repairIncompleteTail(E),W=await this.readTailSeq(E),$=G.stampSeqFrom(_,W),M=`${$.map(D).join(`
4
4
  `)}
5
- `;return await E.appendFile(R+H,"utf8"),await E.sync(),$}finally{await E.close()}})}async createExclusive(_){if(_.length===0)throw Error("Cannot create an empty session transcript");await X.mkdir(f.dirname(this.filePath),{recursive:!0,mode:493});let E;try{E=await X.open(this.filePath,"wx",384);let W=`${G.stampSeq(_,[]).map(w).join(`
5
+ `;return await E.appendFile(R+M,"utf8"),await E.sync(),$}finally{await E.close()}})}async createExclusive(_){if(_.length===0)throw Error("Cannot create an empty session transcript");await X.mkdir(f.dirname(this.filePath),{recursive:!0,mode:493});let E;try{E=await X.open(this.filePath,"wx",384);let W=`${G.stampSeq(_,[]).map(D).join(`
6
6
  `)}
7
- `;await E.writeFile(W,"utf-8"),await E.sync()}catch(R){if(E)await E.close(),E=void 0,await X.unlink(this.filePath).catch(()=>{return});throw R}finally{await E?.close()}}async readAll(){if(!I.existsSync(this.filePath))return[];let _=await X.readFile(this.filePath,"utf-8");return z(_,this.filePath)}async readStream(_){return new Promise((E,R)=>{if(!I.existsSync(this.filePath)){E();return}let W=T_(this.filePath,"utf-8"),$=Z_({input:W,crlfDelay:Number.POSITIVE_INFINITY}),H=0;$.on("line",async(M)=>{let Q=M.trim();if(Q.length===0)return;try{let Y=JSON.parse(Q);if(H+=1,typeof Y.seq!=="number")Y.seq=H;await _(Y)}catch(Y){console.warn(`[JSONLStore] 解析 JSON 行失败: ${Q}`,Y)}}),$.on("close",()=>E()),$.on("error",R),W.on("error",R)})}async filter(_){let E=[];return await this.readStream((R)=>{if(_(R))E.push(R)}),E}async readLast(_){return(await this.readAll()).slice(-_)}async readFromSeq(_){return(await this.readAll()).filter((R)=>(R.seq??0)>=_)}async getStats(){try{if(!I.existsSync(this.filePath))return{exists:!1,size:0,lineCount:0};let _=await X.stat(this.filePath),R=(await X.readFile(this.filePath,"utf-8")).split(`
8
- `).filter((W)=>W.trim().length>0).length;return{exists:!0,size:_.size,lineCount:R}}catch(_){return console.error(`[JSONLStore] 获取统计信息失败: ${this.filePath}`,_),{exists:!1,size:0,lineCount:0}}}async exists(){try{return await X.access(this.filePath),!0}catch{return!1}}async delete(){try{return await this.enqueue(async()=>{try{return await X.unlink(this.filePath),!0}catch(_){if(_.code==="ENOENT")return!1;throw _}})}catch(_){throw console.error(`[JSONLStore] 删除文件失败: ${this.filePath}`,_),_}}async deleteValidated(_){return this.enqueue(async()=>{let E;try{E=await X.open(this.filePath,"r")}catch(W){if(W.code==="ENOENT")return!1;throw W}let R;try{R=z(await E.readFile("utf8"),"session transcript")}finally{await E.close()}if(!_(R))return!1;try{return await X.unlink(this.filePath),!0}catch(W){if(W.code==="ENOENT")return!1;throw W}})}async appendValidated(_){return this.appendValidatedAsync(async(E)=>_(E))}async appendValidatedBatch(_){return this.appendValidatedBatchAsync(async(E)=>_(E))}async appendValidatedBatchAsync(_){return this.enqueue(async()=>{let E=await X.open(this.filePath,"r+");try{let{entries:R,separator:W,size:$}=await this.readCommittedState(E,"session transcript"),H=await _(R);if(H.length===0)return[];let M=G.stampSeq(H,R),Q=`${M.map(w).join(`
7
+ `;await E.writeFile(W,"utf-8"),await E.sync()}catch(R){if(E)await E.close(),E=void 0,await X.unlink(this.filePath).catch(()=>{return});throw R}finally{await E?.close()}}async readAll(){if(!z.existsSync(this.filePath))return[];let _=await X.readFile(this.filePath,"utf-8");return y(_,this.filePath)}async readStream(_){return new Promise((E,R)=>{if(!z.existsSync(this.filePath)){E();return}let W=g_(this.filePath,"utf-8"),$=T_({input:W,crlfDelay:Number.POSITIVE_INFINITY}),M=0;$.on("line",async(H)=>{let Q=H.trim();if(Q.length===0)return;try{let Y=JSON.parse(Q);if(M+=1,typeof Y.seq!=="number")Y.seq=M;await _(Y)}catch(Y){console.warn(`[JSONLStore] 解析 JSON 行失败: ${Q}`,Y)}}),$.on("close",()=>E()),$.on("error",R),W.on("error",R)})}async filter(_){let E=[];return await this.readStream((R)=>{if(_(R))E.push(R)}),E}async readLast(_){return(await this.readAll()).slice(-_)}async readFromSeq(_){return(await this.readAll()).filter((R)=>(R.seq??0)>=_)}async getStats(){try{if(!z.existsSync(this.filePath))return{exists:!1,size:0,lineCount:0};let _=await X.stat(this.filePath),R=(await X.readFile(this.filePath,"utf-8")).split(`
8
+ `).filter((W)=>W.trim().length>0).length;return{exists:!0,size:_.size,lineCount:R}}catch(_){return console.error(`[JSONLStore] 获取统计信息失败: ${this.filePath}`,_),{exists:!1,size:0,lineCount:0}}}async exists(){try{return await X.access(this.filePath),!0}catch{return!1}}async delete(){try{return await this.enqueue(async()=>{try{return await X.unlink(this.filePath),!0}catch(_){if(_.code==="ENOENT")return!1;throw _}})}catch(_){throw console.error(`[JSONLStore] 删除文件失败: ${this.filePath}`,_),_}}async deleteValidated(_){return this.enqueue(async()=>{let E;try{E=await X.open(this.filePath,"r")}catch(W){if(W.code==="ENOENT")return!1;throw W}let R;try{R=y(await E.readFile("utf8"),"session transcript")}finally{await E.close()}if(!_(R))return!1;try{return await X.unlink(this.filePath),!0}catch(W){if(W.code==="ENOENT")return!1;throw W}})}async appendValidated(_){return this.appendValidatedAsync(async(E)=>_(E))}async appendValidatedBatch(_){return this.appendValidatedBatchAsync(async(E)=>_(E))}async appendValidatedBatchAsync(_){return this.enqueue(async()=>{let E=await X.open(this.filePath,"r+");try{let{entries:R,separator:W,size:$}=await this.readCommittedState(E,"session transcript"),M=await _(R);if(M.length===0)return[];let H=G.stampSeq(M,R),Q=`${H.map(D).join(`
9
9
  `)}
10
- `;return await E.write(W+Q,$,"utf8"),await E.sync(),M}finally{await E.close()}})}async appendValidatedAsync(_){return this.enqueue(async()=>{let E=await X.open(this.filePath,"r+");try{let{entries:R,separator:W,size:$}=await this.readCommittedState(E,"session transcript"),H=await _(R),[M]=G.stampSeq([H],R),Q=`${W}${w(M)}
11
- `;return await E.write(Q,$,"utf8"),await E.sync(),M}finally{await E.close()}})}getFilePath(){return this.filePath}async enqueue(_){let R=(G.appendQueues.get(this.filePath)??Promise.resolve()).catch(()=>{return}).then(_),W=R.then(()=>{return},()=>{return});G.appendQueues.set(this.filePath,W);try{return await R}finally{if(G.appendQueues.get(this.filePath)===W)G.appendQueues.delete(this.filePath)}}async readCommittedState(_,E=this.filePath){let R=await this.repairIncompleteTail(_),W=await _.readFile("utf8"),$=z(W,E),{size:H}=await _.stat();return{entries:$,separator:R,size:H}}async readTailSeq(_){let{size:E}=await _.stat();if(E===0)return 0;let R=Math.max(0,E-b),W=Buffer.allocUnsafe(E-R);await _.read(W,0,W.length,R);let $=W.toString("utf8").split(`
12
- `);for(let M=$.length-1;M>=0;M--){let Q=$[M].trim();if(!Q)continue;if(M===0&&R>0)break;try{let Y=JSON.parse(Q).seq;if(typeof Y==="number")return Y}catch{}break}let H=await _.readFile("utf8");return G.maxSeq(z(H,this.filePath))}async repairIncompleteTail(_){let{size:E}=await _.stat();if(E===0)return"";let R=Buffer.allocUnsafe(1);if(await _.read(R,0,1,E-1),R[0]===10)return"";let W=await this.findTailStart(_,E),$=Buffer.allocUnsafe(E-W);await _.read($,0,$.length,W);try{return JSON.parse($.toString("utf8").trim()),`
13
- `}catch{return await _.truncate(W),""}}async findTailStart(_,E){let R=E;while(R>0){let W=Math.max(0,R-b),$=Buffer.allocUnsafe(R-W);await _.read($,0,$.length,W);let H=$.lastIndexOf(10);if(H>=0)return W+H+1;R=W}return 0}}function K_(){return typeof globalThis.Bun<"u"}function U_(_){return{exec:(E)=>_.exec(E),prepare:(E)=>{let R=_.prepare(E);return{run:(...W)=>{R.run(...W)},get:(...W)=>R.get(...W),all:(...W)=>R.all(...W)}},transaction:(E)=>_.transaction(E)(),pragma:(E)=>_.pragma(E,{simple:!0}),close:()=>_.close()}}function F_(_){return{exec:(E)=>_.exec(E),prepare:(E)=>{let R=_.query(E);return{run:(...W)=>{R.run(...W)},get:(...W)=>R.get(...W),all:(...W)=>R.all(...W)}},transaction:(E)=>_.transaction(E)(),pragma:(E)=>{let R=_.query(`PRAGMA ${E}`).get();if(!R)return;let W=Object.values(R);return W.length===1?W[0]:R},close:()=>_.close()}}var C_=["PRAGMA journal_mode=WAL;","PRAGMA busy_timeout=5000;","PRAGMA synchronous=NORMAL;","PRAGMA foreign_keys=ON;"].join(`
14
- `);async function l(_){try{let E;if(K_()){let{Database:W}=await import("bun:sqlite");E=F_(new W(_))}else{let $=(await import("better-sqlite3")).default;E=U_(new $(_))}return E.exec(C_),E}catch{return null}}function n(_){let E=Number(_.pragma("user_version")??0);if(E===5)return;if(E>0&&E!==5)_.exec(`
10
+ `;return await E.write(W+Q,$,"utf8"),await E.sync(),H}finally{await E.close()}})}async appendValidatedAsync(_){return this.enqueue(async()=>{let E=await X.open(this.filePath,"r+");try{let{entries:R,separator:W,size:$}=await this.readCommittedState(E,"session transcript"),M=await _(R),[H]=G.stampSeq([M],R),Q=`${W}${D(H)}
11
+ `;return await E.write(Q,$,"utf8"),await E.sync(),H}finally{await E.close()}})}getFilePath(){return this.filePath}async enqueue(_){let R=(G.appendQueues.get(this.filePath)??Promise.resolve()).catch(()=>{return}).then(_),W=R.then(()=>{return},()=>{return});G.appendQueues.set(this.filePath,W);try{return await R}finally{if(G.appendQueues.get(this.filePath)===W)G.appendQueues.delete(this.filePath)}}async readCommittedState(_,E=this.filePath){let R=await this.repairIncompleteTail(_),W=await _.readFile("utf8"),$=y(W,E),{size:M}=await _.stat();return{entries:$,separator:R,size:M}}async readTailSeq(_){let{size:E}=await _.stat();if(E===0)return 0;let R=Math.max(0,E-b),W=Buffer.allocUnsafe(E-R);await _.read(W,0,W.length,R);let $=W.toString("utf8").split(`
12
+ `);for(let H=$.length-1;H>=0;H--){let Q=$[H].trim();if(!Q)continue;if(H===0&&R>0)break;try{let Y=JSON.parse(Q).seq;if(typeof Y==="number")return Y}catch{}break}let M=await _.readFile("utf8");return G.maxSeq(y(M,this.filePath))}async repairIncompleteTail(_){let{size:E}=await _.stat();if(E===0)return"";let R=Buffer.allocUnsafe(1);if(await _.read(R,0,1,E-1),R[0]===10)return"";let W=await this.findTailStart(_,E),$=Buffer.allocUnsafe(E-W);await _.read($,0,$.length,W);try{return JSON.parse($.toString("utf8").trim()),`
13
+ `}catch{return await _.truncate(W),""}}async findTailStart(_,E){let R=E;while(R>0){let W=Math.max(0,R-b),$=Buffer.allocUnsafe(R-W);await _.read($,0,$.length,W);let M=$.lastIndexOf(10);if(M>=0)return W+M+1;R=W}return 0}}function K_(){return typeof globalThis.Bun<"u"}function U_(_){return{exec:(E)=>_.exec(E),prepare:(E)=>{let R=_.prepare(E);return{run:(...W)=>{R.run(...W)},get:(...W)=>R.get(...W),all:(...W)=>R.all(...W)}},transaction:(E)=>_.transaction(E)(),pragma:(E)=>_.pragma(E,{simple:!0}),close:()=>_.close()}}function F_(_){return{exec:(E)=>_.exec(E),prepare:(E)=>{let R=_.query(E);return{run:(...W)=>{R.run(...W)},get:(...W)=>R.get(...W),all:(...W)=>R.all(...W)}},transaction:(E)=>_.transaction(E)(),pragma:(E)=>{let R=_.query(`PRAGMA ${E}`).get();if(!R)return;let W=Object.values(R);return W.length===1?W[0]:R},close:()=>_.close()}}var C_=["PRAGMA journal_mode=WAL;","PRAGMA busy_timeout=5000;","PRAGMA synchronous=NORMAL;","PRAGMA foreign_keys=ON;"].join(`
14
+ `);async function l(_){try{let E;if(K_()){let{Database:W}=await import("bun:sqlite");E=F_(new W(_))}else{let $=(await import("better-sqlite3")).default;E=U_(new $(_))}return E.exec(C_),E}catch{return null}}function o(_){let E=Number(_.pragma("user_version")??0);if(E===5)return;if(E>0&&E!==5)_.exec(`
15
15
  DROP TABLE IF EXISTS parts_fts;
16
16
  DROP TABLE IF EXISTS parts;
17
17
  DROP TABLE IF EXISTS sessions;
@@ -104,10 +104,10 @@ CREATE VIRTUAL TABLE IF NOT EXISTS parts_fts USING fts5(
104
104
  seq UNINDEXED,
105
105
  tokenize = 'unicode61'
106
106
  );
107
- `),_.exec("PRAGMA user_version=5;")}var B_=r("Service"),B;function s(){return k.join(u(),"index.db")}async function k_(){let _=s();if(B&&B.path===_)return B.db;let E=(async()=>{let R=await l(_);if(!R)return null;try{return n(R),R}catch{return null}})();return B={path:_,db:E},E}function A_(){B=void 0}function x_(_){if(_&&typeof _==="object"){let E=_.text;if(typeof E==="string")return E}return null}function D_(_,E,R,W){_.prepare("DELETE FROM parts WHERE project_path=? AND session_id=?").run(E,R),_.prepare("DELETE FROM parts_fts WHERE project_path=? AND session_id=?").run(E,R);let $=new Map;for(let Q of W)if(Q.type==="message_created")$.set(Q.data.messageId,Q.data.role);let H=_.prepare(`INSERT OR REPLACE INTO parts
107
+ `),_.exec("PRAGMA user_version=5;")}var k_=r("Service"),k;function s(){return B.join(u(),"index.db")}async function B_(){let _=s();if(k&&k.path===_)return k.db;let E=(async()=>{let R=await l(_);if(!R)return null;try{return o(R),R}catch{return null}})();return k={path:_,db:E},E}function A_(){k=void 0}function x_(_){if(_&&typeof _==="object"){let E=_.text;if(typeof E==="string")return E}return null}function w_(_,E,R,W){_.prepare("DELETE FROM parts WHERE project_path=? AND session_id=?").run(E,R),_.prepare("DELETE FROM parts_fts WHERE project_path=? AND session_id=?").run(E,R);let $=new Map;for(let Q of W)if(Q.type==="message_created")$.set(Q.data.messageId,Q.data.role);let M=_.prepare(`INSERT OR REPLACE INTO parts
108
108
  (project_path, session_id, part_id, message_id, part_type, role, seq, timestamp, text)
109
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`),M=_.prepare(`INSERT INTO parts_fts (text, project_path, session_id, part_id, role, timestamp, seq)
110
- VALUES (?, ?, ?, ?, ?, ?, ?)`);for(let Q of W){if(Q.type!=="part_created"&&Q.type!=="part_updated")continue;if(Q.data.partType!=="text")continue;let Y=x_(Q.data.payload);if(Y===null)continue;let T=$.get(Q.data.messageId)??"assistant",F=Q.seq??0;if(H.run(E,R,Q.data.partId,Q.data.messageId,Q.data.partType,T,F,Q.timestamp,Y),T==="user"||T==="assistant")M.run(Y,E,R,Q.data.partId,T,Q.timestamp,F)}}function w_(_,E){_.prepare(`INSERT INTO sessions
109
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`),H=_.prepare(`INSERT INTO parts_fts (text, project_path, session_id, part_id, role, timestamp, seq)
110
+ VALUES (?, ?, ?, ?, ?, ?, ?)`);for(let Q of W){if(Q.type!=="part_created"&&Q.type!=="part_updated")continue;if(Q.data.partType!=="text")continue;let Y=x_(Q.data.payload);if(Y===null)continue;let g=$.get(Q.data.messageId)??"assistant",F=Q.seq??0;if(M.run(E,R,Q.data.partId,Q.data.messageId,Q.data.partType,g,F,Q.timestamp,Y),g==="user"||g==="assistant")H.run(Y,E,R,Q.data.partId,g,Q.timestamp,F)}}function D_(_,E){_.prepare(`INSERT INTO sessions
111
111
  (project_path, session_id, root_id, parent_id, relation_type, title,
112
112
  agent_type, model, task_status, task_priority, task_kind, task_due_at,
113
113
  archived_at, last_message_time, project_sort_key,
@@ -126,15 +126,15 @@ CREATE VIRTUAL TABLE IF NOT EXISTS parts_fts USING fts5(
126
126
  session_sort_key=excluded.session_sort_key,
127
127
  first_message_time=excluded.first_message_time, message_count=excluded.message_count,
128
128
  has_errors=excluded.has_errors, is_subagent=excluded.is_subagent,
129
- metadata_json=excluded.metadata_json`).run(E.projectPath,E.sessionId,E.rootId,E.parentId??null,E.relationType??null,E.title??null,E.agentType??null,E.model??null,E.taskStatus,E.taskPriority??null,E.taskKind??null,E.taskDueAt??null,E.archivedAt??null,E.lastMessageTime,J(E.projectPath),J(E.sessionId),E.firstMessageTime,E.messageCount,E.hasErrors?1:0,E.relationType==="subagent"?1:0,JSON.stringify(E))}function t(_,E,R){for(let W of["sessions","parts","parts_fts"])_.prepare(`DELETE FROM ${W} WHERE project_path=? AND session_id=?`).run(E,R)}function p(_,E,R){t(_,E,R),_.prepare("DELETE FROM projection_state WHERE project_path=? AND session_id=?").run(E,R)}function L(_,E,R,W,$,H){_.prepare(`INSERT INTO projection_state
129
+ metadata_json=excluded.metadata_json`).run(E.projectPath,E.sessionId,E.rootId,E.parentId??null,E.relationType??null,E.title??null,E.agentType??null,E.model??null,E.taskStatus,E.taskPriority??null,E.taskKind??null,E.taskDueAt??null,E.archivedAt??null,E.lastMessageTime,J(E.projectPath),J(E.sessionId),E.firstMessageTime,E.messageCount,E.hasErrors?1:0,E.relationType==="subagent"?1:0,JSON.stringify(E))}function t(_,E,R){for(let W of["sessions","parts","parts_fts"])_.prepare(`DELETE FROM ${W} WHERE project_path=? AND session_id=?`).run(E,R)}function p(_,E,R){t(_,E,R),_.prepare("DELETE FROM projection_state WHERE project_path=? AND session_id=?").run(E,R)}function L(_,E,R,W,$,M){_.prepare(`INSERT INTO projection_state
130
130
  (project_path, session_id, last_seq, file_size, mtime_ms)
131
131
  VALUES (?, ?, ?, ?, ?)
132
132
  ON CONFLICT(project_path, session_id) DO UPDATE SET
133
133
  last_seq=excluded.last_seq, file_size=excluded.file_size,
134
- mtime_ms=excluded.mtime_ms`).run(E,R,W,$,H)}async function z_(_,E,R,W,$=j(R,E)){let H;try{let V=await a($);H={size:V.size,mtimeMs:V.mtimeMs}}catch{return _.transaction(()=>p(_,R,E)),!0}let M=_.prepare("SELECT last_seq, file_size, mtime_ms FROM projection_state WHERE project_path=? AND session_id=?").get(R,E);if(M&&M.file_size===H.size&&M.mtime_ms===Math.floor(H.mtimeMs))return!1;let Y=await new G($).readAll(),T=Y.reduce((V,g)=>typeof g.seq==="number"&&g.seq>V?g.seq:V,0),F=D(Y),Z=W(Y,E,R);if(Y.length===0||!Z)return _.transaction(()=>{t(_,R,E),L(_,R,E,T,H.size,Math.floor(H.mtimeMs))}),!0;let C=_.prepare("SELECT last_message_time FROM sessions WHERE project_path=? AND session_id=?").get(Z.projectPath,Z.sessionId),A=k.resolve($)===k.resolve(j(Z.projectPath,Z.sessionId));if(C&&!A&&typeof C.last_message_time==="string"&&C.last_message_time>Z.lastMessageTime)return L(_,R,E,T,H.size,Math.floor(H.mtimeMs)),!0;return _.transaction(()=>{w_(_,Z),D_(_,Z.projectPath,Z.sessionId,F),L(_,R,E,T,H.size,Math.floor(H.mtimeMs))}),!0}var o=new WeakMap;async function I_(_,E,R=0){let W=o.get(_)??{};if(o.set(_,W),W.inFlight)return W.inFlight;if(R>0&&W.lastCompletedAt!==void 0&&Date.now()-W.lastCompletedAt<=R)return;let $=y_(_,E);W.inFlight=$;try{await $,W.lastCompletedAt=Date.now()}finally{if(W.inFlight===$)W.inFlight=void 0}}async function y_(_,E){let{readdir:R}=await import("node:fs/promises"),W=await i(),$=new Set,M=(await Promise.all(W.map(async(V)=>{let g=d(V),K=k.join(u(),"projects",V);try{return(await R(K)).flatMap((q)=>{if(!q.endsWith(".jsonl"))return[];let P=q.slice(0,-6);if(!x(P))return[];return[{filePath:k.join(K,q),projectPath:g,sessionId:P}]})}catch{return[]}}))).flat();for(let V of M)$.add(`${V.projectPath}\x00${V.sessionId}`);let Q=_.prepare(`SELECT project_path, session_id, last_seq, file_size, mtime_ms
135
- FROM projection_state`).all(),Y=new Map(Q.map((V)=>[`${V.project_path}\x00${V.session_id}`,V])),T=[],F=Math.min(128,M.length),Z=0;await Promise.all(Array.from({length:F},async()=>{while(Z<M.length){let V=M[Z++];if(!V)continue;try{let g=await a(V.filePath),K=Y.get(`${V.projectPath}\x00${V.sessionId}`);if(K&&K.file_size===g.size&&K.mtime_ms===Math.floor(g.mtimeMs))continue}catch{}T.push(V)}}));let C=Math.min(32,T.length),A=0;await Promise.all(Array.from({length:C},async()=>{while(A<T.length){let V=T[A++];if(!V)continue;try{await z_(_,V.sessionId,V.projectPath,E,V.filePath)}catch(g){if(g.code!=="ENOENT")B_.warn(`[SessionService] Skipping invalid session transcript: ${V.sessionId}`)}}}));for(let V of Q)if(!$.has(`${V.project_path}\x00${V.session_id}`))_.transaction(()=>p(_,V.project_path,V.session_id))}function t_(_,E,R){_.transaction(()=>p(_,R,E))}async function e_(_){let{rm:E}=await import("node:fs/promises");A_();let R=s();for(let H of["","-wal","-shm"])await E(`${R}${H}`,{force:!0}).catch(()=>{return});let W=await k_();if(!W)return null;return await I_(W,_),W.prepare("SELECT COUNT(*) c FROM sessions").get()?.c??0}function _E(_,E,R,W){let $=E.replace(/["*]/g," ").trim().split(/\s+/)[0];if(!$)return[];let H=`"${$}"*`,M=R?`SELECT session_id, role, timestamp, text FROM parts_fts
134
+ mtime_ms=excluded.mtime_ms`).run(E,R,W,$,M)}async function y_(_,E,R,W,$=j(R,E)){let M;try{let V=await a($);M={size:V.size,mtimeMs:V.mtimeMs}}catch{return _.transaction(()=>p(_,R,E)),!0}let H=_.prepare("SELECT last_seq, file_size, mtime_ms FROM projection_state WHERE project_path=? AND session_id=?").get(R,E);if(H&&H.file_size===M.size&&H.mtime_ms===Math.floor(M.mtimeMs))return!1;let Y=await new G($).readAll(),g=Y.reduce((V,Z)=>typeof Z.seq==="number"&&Z.seq>V?Z.seq:V,0),F=w(Y),T=W(Y,E,R);if(Y.length===0||!T)return _.transaction(()=>{t(_,R,E),L(_,R,E,g,M.size,Math.floor(M.mtimeMs))}),!0;let C=_.prepare("SELECT last_message_time FROM sessions WHERE project_path=? AND session_id=?").get(T.projectPath,T.sessionId),A=B.resolve($)===B.resolve(j(T.projectPath,T.sessionId));if(C&&!A&&typeof C.last_message_time==="string"&&C.last_message_time>T.lastMessageTime)return L(_,R,E,g,M.size,Math.floor(M.mtimeMs)),!0;return _.transaction(()=>{D_(_,T),w_(_,T.projectPath,T.sessionId,F),L(_,R,E,g,M.size,Math.floor(M.mtimeMs))}),!0}var n=new WeakMap;async function z_(_,E,R=0){let W=n.get(_)??{};if(n.set(_,W),W.inFlight)return W.inFlight;if(R>0&&W.lastCompletedAt!==void 0&&Date.now()-W.lastCompletedAt<=R)return;let $=I_(_,E);W.inFlight=$;try{await $,W.lastCompletedAt=Date.now()}finally{if(W.inFlight===$)W.inFlight=void 0}}async function I_(_,E){let{readdir:R}=await import("node:fs/promises"),W=await i(),$=new Set,H=(await Promise.all(W.map(async(V)=>{let Z=d(V),K=B.join(u(),"projects",V);try{return(await R(K)).flatMap((q)=>{if(!q.endsWith(".jsonl"))return[];let P=q.slice(0,-6);if(!x(P))return[];return[{filePath:B.join(K,q),projectPath:Z,sessionId:P}]})}catch{return[]}}))).flat();for(let V of H)$.add(`${V.projectPath}\x00${V.sessionId}`);let Q=_.prepare(`SELECT project_path, session_id, last_seq, file_size, mtime_ms
135
+ FROM projection_state`).all(),Y=new Map(Q.map((V)=>[`${V.project_path}\x00${V.session_id}`,V])),g=[],F=Math.min(128,H.length),T=0;await Promise.all(Array.from({length:F},async()=>{while(T<H.length){let V=H[T++];if(!V)continue;try{let Z=await a(V.filePath),K=Y.get(`${V.projectPath}\x00${V.sessionId}`);if(K&&K.file_size===Z.size&&K.mtime_ms===Math.floor(Z.mtimeMs))continue}catch{}g.push(V)}}));let C=Math.min(32,g.length),A=0;await Promise.all(Array.from({length:C},async()=>{while(A<g.length){let V=g[A++];if(!V)continue;try{await y_(_,V.sessionId,V.projectPath,E,V.filePath)}catch(Z){if(Z.code!=="ENOENT")k_.warn(`[SessionService] Skipping invalid session transcript: ${V.sessionId}`)}}}));for(let V of Q)if(!$.has(`${V.project_path}\x00${V.session_id}`))_.transaction(()=>p(_,V.project_path,V.session_id))}function t_(_,E,R){_.transaction(()=>p(_,R,E))}async function e_(_){let{rm:E}=await import("node:fs/promises");A_();let R=s();for(let M of["","-wal","-shm"])await E(`${R}${M}`,{force:!0}).catch(()=>{return});let W=await B_();if(!W)return null;return await z_(W,_),W.prepare("SELECT COUNT(*) c FROM sessions").get()?.c??0}function _E(_,E,R,W){let $=E.replace(/["*]/g," ").trim().split(/\s+/)[0];if(!$)return[];let M=`"${$}"*`,H=R?`SELECT session_id, role, timestamp, text FROM parts_fts
136
136
  WHERE parts_fts MATCH ? AND project_path = ?
137
137
  ORDER BY timestamp DESC LIMIT ?`:`SELECT session_id, role, timestamp, text FROM parts_fts
138
138
  WHERE parts_fts MATCH ?
139
- ORDER BY timestamp DESC LIMIT ?`,Q=_.prepare(M);return R?Q.all(H,R,W):Q.all(H,W)}
140
- export{D as Xd,j_ as Yd,u_ as Zd,z as _d,G as $d,J as ae,V_ as be,O_ as ce,N_ as de,Y_ as ee,f_ as fe,s as ge,k_ as he,A_ as ie,z_ as je,I_ as ke,t_ as le,e_ as me,_E as ne};
139
+ ORDER BY timestamp DESC LIMIT ?`,Q=_.prepare(H);return R?Q.all(M,R,W):Q.all(M,W)}
140
+ export{w as Xd,j_ as Yd,u_ as Zd,y as _d,G as $d,J as ae,V_ as be,O_ as ce,N_ as de,Y_ as ee,f_ as fe,s as ge,B_ as he,A_ as ie,y_ as je,z_ as ke,t_ as le,e_ as me,_E as ne};
@@ -1,2 +1,2 @@
1
- import{Bi as d,Di as h}from"./chunk-mhfwp1f0.js";var q={debug:{alias:"d",type:"string",describe:'Enable debug mode with optional category filtering (e.g., "agent,ui" or "!chat,!loop")',group:"Debug Options:"},model:{type:"string",describe:"Override the current run model using a model config ID (TUI / print / headless)",group:"AI Options:"},print:{alias:"p",type:"boolean",describe:"Print response and exit (useful for pipes)",group:"Output Options:"},headless:{type:"boolean",describe:"Run full agent loop without Ink UI and print all events to the terminal",group:"Output Options:"},"output-format":{alias:["outputFormat"],type:"string",choices:["text","json","stream-json","jsonl"],default:"text",describe:"Output format: --print supports text|json|stream-json; --headless supports text|jsonl",group:"Output Options:"},"json-schema":{alias:["jsonSchema"],type:"string",describe:"Inline JSON Schema for the turn-scoped structured final response",group:"Output Options:"},"output-schema":{alias:["outputSchema"],type:"string",describe:"Path to a JSON Schema file for the structured final response",group:"Output Options:"},"include-partial-messages":{alias:["includePartialMessages"],type:"boolean",describe:"Include partial message chunks as they arrive",group:"Output Options:"},"input-format":{alias:["inputFormat"],type:"string",choices:["text","stream-json"],default:"text",describe:"Input format",group:"Input Options:"},"replay-user-messages":{alias:["replayUserMessages"],type:"boolean",describe:"Re-emit user messages from stdin",group:"Input Options:"},"allowed-tools":{alias:["allowedTools"],type:"array",string:!0,describe:"Comma or space-separated list of tool names to allow",group:"Security Options:"},"disallowed-tools":{alias:["disallowedTools"],type:"array",string:!0,describe:"Comma or space-separated list of tool names to deny",group:"Security Options:"},"mcp-config":{alias:["mcpConfig"],type:"array",string:!0,describe:"Load MCP servers from JSON files or strings",group:"MCP Options:"},"system-prompt":{alias:["systemPrompt"],type:"string",describe:"System prompt to use for the session (replaces default)",group:"AI Options:"},"append-system-prompt":{alias:["appendSystemPrompt"],type:"string",describe:"Append a system prompt to the default system prompt",group:"AI Options:"},"max-turns":{alias:["maxTurns"],type:"number",describe:"Maximum conversation turns (-1: unlimited, 0: disable chat, N>0: limit to N turns)",group:"AI Options:",default:void 0},"max-concurrent-tasks":{alias:["maxConcurrentTasks"],type:"number",describe:"Maximum top-level tasks running concurrently in this process",group:"AI Options:",default:void 0},"max-queued-tasks":{alias:["maxQueuedTasks"],type:"number",describe:"Maximum top-level tasks waiting for an admission slot",group:"AI Options:",default:void 0},"max-queued-task-bytes":{alias:["maxQueuedTaskBytes"],type:"number",describe:"Maximum retained bytes across queued top-level tasks",group:"AI Options:",default:void 0},"max-resident-session-runtimes":{alias:["maxResidentSessionRuntimes"],type:"number",describe:"Maximum initialized Session runtimes resident in this process",group:"AI Options:",default:void 0},"session-runtime-idle-ms":{alias:["sessionRuntimeIdleMs"],type:"number",describe:"Idle time before an evictable Web Session runtime is disposed",group:"AI Options:",default:void 0},"permission-mode":{alias:["permissionMode"],type:"string",choices:["default","autoEdit","yolo","plan"],describe:"Permission mode (default: ask for non-read tools, autoEdit: auto-approve edits, yolo: auto-approve all, plan: reserved)",group:"Security Options:"},yolo:{type:"boolean",describe:"Auto-approve all tools (shortcut for --permission-mode=yolo)",group:"Security Options:"},"trust-workspace":{alias:["trustWorkspace"],type:"boolean",describe:"Trust the current workspace before loading project models, MCP, LSP, permissions, or plugins",group:"Security Options:"},continue:{alias:"c",type:"boolean",describe:"Continue the most recent conversation",group:"Session Options:"},resume:{alias:"r",describe:"Resume a conversation - provide a session ID or interactively select a conversation to resume",group:"Session Options:",coerce:(b)=>{if(b===void 0||b===!0||b==="")return"true";return String(b)}},"fork-session":{alias:["forkSession"],type:"boolean",describe:"Create a new session ID when resuming",group:"Session Options:"},settings:{type:"string",describe:"Path to a settings JSON file or JSON string",group:"Configuration:"},"add-dir":{alias:["addDir"],type:"array",string:!0,describe:"Additional directories to allow tool access to",group:"Security Options:"},ide:{type:"boolean",describe:"Automatically connect to IDE on startup",group:"Integration:"},acp:{type:"boolean",describe:"Run in ACP (Agent Client Protocol) mode for IDE integration",group:"Integration:"},"strict-mcp-config":{alias:["strictMcpConfig"],type:"boolean",describe:"Only use MCP servers from --mcp-config",group:"MCP Options:"},"session-id":{alias:["sessionId"],type:"string",describe:"Use a specific session ID for the conversation",group:"Session Options:"},agents:{type:"string",describe:"JSON object defining custom agents",group:"AI Options:"},"setting-sources":{alias:["settingSources"],type:"string",describe:"Comma-separated list of setting sources to load",group:"Configuration:"},"plugin-dir":{alias:["pluginDir"],type:"array",string:!0,describe:"Load plugins from specified directories",group:"Plugin Options:"}},w={scriptName:"blade",usage:"$0 [command] [options]",description:h(),version:d(),locale:"en",showHelpOnFail:!0,demandCommand:!1,recommendCommands:!0,strict:!1};
1
+ import{Bi as d,Di as h}from"./chunk-8z9d0zd0.js";var q={debug:{alias:"d",type:"string",describe:'Enable debug mode with optional category filtering (e.g., "agent,ui" or "!chat,!loop")',group:"Debug Options:"},model:{type:"string",describe:"Override the current run model using a model config ID (TUI / print / headless)",group:"AI Options:"},print:{alias:"p",type:"boolean",describe:"Print response and exit (useful for pipes)",group:"Output Options:"},headless:{type:"boolean",describe:"Run full agent loop without Ink UI and print all events to the terminal",group:"Output Options:"},"output-format":{alias:["outputFormat"],type:"string",choices:["text","json","stream-json","jsonl"],default:"text",describe:"Output format: --print supports text|json|stream-json; --headless supports text|jsonl",group:"Output Options:"},"json-schema":{alias:["jsonSchema"],type:"string",describe:"Inline JSON Schema for the turn-scoped structured final response",group:"Output Options:"},"output-schema":{alias:["outputSchema"],type:"string",describe:"Path to a JSON Schema file for the structured final response",group:"Output Options:"},"include-partial-messages":{alias:["includePartialMessages"],type:"boolean",describe:"Include partial message chunks as they arrive",group:"Output Options:"},"input-format":{alias:["inputFormat"],type:"string",choices:["text","stream-json"],default:"text",describe:"Input format",group:"Input Options:"},"replay-user-messages":{alias:["replayUserMessages"],type:"boolean",describe:"Re-emit user messages from stdin",group:"Input Options:"},"allowed-tools":{alias:["allowedTools"],type:"array",string:!0,describe:"Comma or space-separated list of tool names to allow",group:"Security Options:"},"disallowed-tools":{alias:["disallowedTools"],type:"array",string:!0,describe:"Comma or space-separated list of tool names to deny",group:"Security Options:"},"mcp-config":{alias:["mcpConfig"],type:"array",string:!0,describe:"Load MCP servers from JSON files or strings",group:"MCP Options:"},"system-prompt":{alias:["systemPrompt"],type:"string",describe:"System prompt to use for the session (replaces default)",group:"AI Options:"},"append-system-prompt":{alias:["appendSystemPrompt"],type:"string",describe:"Append a system prompt to the default system prompt",group:"AI Options:"},"max-turns":{alias:["maxTurns"],type:"number",describe:"Maximum conversation turns (-1: unlimited, 0: disable chat, N>0: limit to N turns)",group:"AI Options:",default:void 0},"max-concurrent-tasks":{alias:["maxConcurrentTasks"],type:"number",describe:"Maximum top-level tasks running concurrently in this process",group:"AI Options:",default:void 0},"max-queued-tasks":{alias:["maxQueuedTasks"],type:"number",describe:"Maximum top-level tasks waiting for an admission slot",group:"AI Options:",default:void 0},"max-queued-task-bytes":{alias:["maxQueuedTaskBytes"],type:"number",describe:"Maximum retained bytes across queued top-level tasks",group:"AI Options:",default:void 0},"max-resident-session-runtimes":{alias:["maxResidentSessionRuntimes"],type:"number",describe:"Maximum initialized Session runtimes resident in this process",group:"AI Options:",default:void 0},"session-runtime-idle-ms":{alias:["sessionRuntimeIdleMs"],type:"number",describe:"Idle time before an evictable Web Session runtime is disposed",group:"AI Options:",default:void 0},"permission-mode":{alias:["permissionMode"],type:"string",choices:["default","autoEdit","yolo","plan"],describe:"Permission mode (default: ask for non-read tools, autoEdit: auto-approve edits, yolo: auto-approve all, plan: reserved)",group:"Security Options:"},yolo:{type:"boolean",describe:"Auto-approve all tools (shortcut for --permission-mode=yolo)",group:"Security Options:"},"trust-workspace":{alias:["trustWorkspace"],type:"boolean",describe:"Trust the current workspace before loading project models, MCP, LSP, permissions, or plugins",group:"Security Options:"},continue:{alias:"c",type:"boolean",describe:"Continue the most recent conversation",group:"Session Options:"},resume:{alias:"r",describe:"Resume a conversation - provide a session ID or interactively select a conversation to resume",group:"Session Options:",coerce:(b)=>{if(b===void 0||b===!0||b==="")return"true";return String(b)}},"fork-session":{alias:["forkSession"],type:"boolean",describe:"Create a new session ID when resuming",group:"Session Options:"},settings:{type:"string",describe:"Path to a settings JSON file or JSON string",group:"Configuration:"},"add-dir":{alias:["addDir"],type:"array",string:!0,describe:"Additional directories to allow tool access to",group:"Security Options:"},ide:{type:"boolean",describe:"Automatically connect to IDE on startup",group:"Integration:"},acp:{type:"boolean",describe:"Run in ACP (Agent Client Protocol) mode for IDE integration",group:"Integration:"},"strict-mcp-config":{alias:["strictMcpConfig"],type:"boolean",describe:"Only use MCP servers from --mcp-config",group:"MCP Options:"},"session-id":{alias:["sessionId"],type:"string",describe:"Use a specific session ID for the conversation",group:"Session Options:"},agents:{type:"string",describe:"JSON object defining custom agents",group:"AI Options:"},"setting-sources":{alias:["settingSources"],type:"string",describe:"Comma-separated list of setting sources to load",group:"Configuration:"},"plugin-dir":{alias:["pluginDir"],type:"array",string:!0,describe:"Load plugins from specified directories",group:"Plugin Options:"}},w={scriptName:"blade",usage:"$0 [command] [options]",description:h(),version:d(),locale:"en",showHelpOnFail:!0,demandCommand:!1,recommendCommands:!0,strict:!1};
2
2
  export{q as oe,w as pe};
@@ -1,4 +1,4 @@
1
- import{qa as F,sa as L}from"./chunk-ap8539bw.js";import{Gd as $,Id as B,Qd as Q}from"./chunk-x5j6nexe.js";import{Sf as y}from"./chunk-d7j7z8hy.js";import{Nh as V}from"./chunk-9sx3vsyj.js";async function j(){await y(V())}async function I(b){let q=b.message||b._?.[0];if(typeof q==="string"&&q.trim())return q;let z=b.stdin??process.stdin;if(!z.isTTY){let G=[];for await(let K of z)G.push(K);return Buffer.concat(G).toString("utf-8").trim()}if(b.defaultMessage!==void 0)return b.defaultMessage;throw Error("No input provided")}async function M(b){let q=b.message||b._?.[0];if(typeof q==="string"&&q.trim())return q;let z=b.stdin??process.stdin;if(z.isTTY)return;let G=[];for await(let Z of z)G.push(Buffer.isBuffer(Z)?Z:Buffer.from(Z));return Buffer.concat(G).toString("utf-8").trim()||void 0}async function R(b){if(!F(b))return{mode:"agent",content:b};let q=await L(b,{cwd:V(),surface:"headless",workspaceRoot:V()});if(!q.success)return{mode:"output",content:`Error: ${q.error||"未知错误"}`,exitCode:1};let z=q.data;if(z?.action==="invoke_skill"){let{skillName:G,skillArgs:K}=z;return{mode:"agent",content:K?`Please use the "${G}" skill to help me with: ${K}`:`Please use the "${G}" skill.`}}if(z?.action==="invoke_custom_command"||z?.action==="invoke_plugin_command"){let G=z.processedContent;return{mode:"agent",content:`# Custom Command: /${z.commandName}
1
+ import{qa as F,sa as L}from"./chunk-2f5kkhan.js";import{Gd as $,Id as B,Qd as Q}from"./chunk-zydvg30x.js";import{Sf as y}from"./chunk-nh4jy5cs.js";import{Nh as V}from"./chunk-9sx3vsyj.js";async function j(){await y(V())}async function I(b){let q=b.message||b._?.[0];if(typeof q==="string"&&q.trim())return q;let z=b.stdin??process.stdin;if(!z.isTTY){let G=[];for await(let K of z)G.push(K);return Buffer.concat(G).toString("utf-8").trim()}if(b.defaultMessage!==void 0)return b.defaultMessage;throw Error("No input provided")}async function M(b){let q=b.message||b._?.[0];if(typeof q==="string"&&q.trim())return q;let z=b.stdin??process.stdin;if(z.isTTY)return;let G=[];for await(let Z of z)G.push(Buffer.isBuffer(Z)?Z:Buffer.from(Z));return Buffer.concat(G).toString("utf-8").trim()||void 0}async function R(b){if(!F(b))return{mode:"agent",content:b};let q=await L(b,{cwd:V(),surface:"headless",workspaceRoot:V()});if(!q.success)return{mode:"output",content:`Error: ${q.error||"未知错误"}`,exitCode:1};let z=q.data;if(z?.action==="invoke_skill"){let{skillName:G,skillArgs:K}=z;return{mode:"agent",content:K?`Please use the "${G}" skill to help me with: ${K}`:`Please use the "${G}" skill.`}}if(z?.action==="invoke_custom_command"||z?.action==="invoke_plugin_command"){let G=z.processedContent;return{mode:"agent",content:`# Custom Command: /${z.commandName}
2
2
 
3
3
  ${G}`}}return{mode:"output",content:q.content||q.message||"",exitCode:0}}import{readFile as D,stat as H}from"node:fs/promises";import J from"node:path";function x(b,q){let z;try{z=JSON.parse(b)}catch(G){throw Error(`Invalid JSON output schema from ${q}`,{cause:G})}return B(z).schema}async function _(b){if(b.jsonSchema!==void 0&&b.outputSchema!==void 0)throw Error("--json-schema cannot be combined with --output-schema");if(b.jsonSchema!==void 0)return x(b.jsonSchema,"--json-schema");if(b.outputSchema===void 0)return;let q=J.resolve(b.outputSchema),z=await H(q);if(!z.isFile())throw Error(`Output schema path is not a regular file: ${q}`);if(z.size>$)throw Error(`Output schema exceeds ${$} bytes: ${q}`);return x(await D(q,"utf8"),q)}function N(b){if(!(b instanceof Error))return!1;return b.message.includes("未找到会话")||b.message.includes("ENOENT")||b.message.includes("no such file")}async function W(b){try{return await Q.loadSessionModelContext(b,V())}catch(q){if(N(q))return null;throw q}}async function C(b){if(b.resume===!0||b.resume==="true")throw Error("--resume without a session ID is only supported in interactive UI mode");if(typeof b.resume==="string"&&b.resume.length>0){if(b.forkSession){let G=V(),K=await Q.forkSession(b.resume,{newSessionId:b.sessionId,sourceProjectPath:G,targetProjectPath:G});return{...K,messages:await Q.loadSessionModelContext(K.sessionId,G)}}let[q,z]=await Promise.all([Q.loadSessionModelContext(b.resume),Q.findSessionMetadata(b.resume)]);return{sessionId:b.resume,messages:q,metadata:z}}if(b.continue){let q=b.forkSession?await Q.listSessions({cwd:V()}):await Q.listSessions();if(q.length>0){let z=q[0].sessionId;if(b.forkSession){let G=V(),K=await Q.forkSession(z,{newSessionId:b.sessionId,sourceProjectPath:G,targetProjectPath:G});return{...K,messages:await Q.loadSessionModelContext(K.sessionId,G)}}return{sessionId:z,messages:await Q.loadSessionModelContext(z),metadata:q[0]}}if(b.forkSession)throw Error("Cannot fork: no sessions are available to continue")}if(b.sessionId){let q=await W(b.sessionId);return{sessionId:b.sessionId,messages:q??[],...q?{metadata:await Q.findSessionMetadata(b.sessionId,V())}:{}}}return{sessionId:`${b.fallbackSessionPrefix}-${Date.now()}`,messages:[]}}
4
4
  export{j as m,I as n,M as o,R as p,_ as q,C as r};
@@ -1,2 +1,2 @@
1
- import{O as I}from"./chunk-ap8539bw.js";import{Qd as M}from"./chunk-x5j6nexe.js";import P from"node:path";function w(s){let a=s.replace(/\s+/g," ").trim();return a.length<=72?a:`${a.slice(0,69)}...`}function W(s){let a=s.replace(/\s+/g," ").trim();return a.length<=500?a:`${a.slice(0,497)}...`}function A(s){return`task/${s.replace(/[^a-zA-Z0-9_-]/g,"-").slice(0,40)}`}class C{static async createSessionTask(s){if(!s.prompt.trim())throw Error("Task prompt must not be blank");if(!P.isAbsolute(s.sourceProjectPath))throw Error("Task source project path must be absolute");let a=P.resolve(s.sourceProjectPath),t;try{return t=s.isolation==="worktree"?await I.enter({sessionId:s.sessionId,workspaceRoot:a,name:A(s.sessionId)}):void 0,{metadata:await M.createSessionMetadata(s.sessionId,t?.workspaceRoot??a,{title:s.title?.trim()||w(s.prompt),taskPromptSummary:W(s.prompt),taskPriority:s.taskPriority,taskKind:s.taskKind,taskDueAt:s.taskDueAt,taskDispatch:s.dispatch,taskModelId:s.dispatch?.modelId,selectedModelId:s.dispatch?.modelId,permissionMode:s.dispatch?.permissionMode,reasoningEffort:s.dispatch?.reasoningEffort,serviceTier:s.dispatch?.serviceTier,responseVerbosity:s.dispatch?.responseVerbosity,communicationStyle:s.dispatch?.communicationStyle,communicationStyleDigest:s.dispatch?.communicationStyleDigest,projectInstructionsDigest:s.dispatch?.projectInstructionsDigest,taskRetriedFrom:s.retriedFrom,taskIsolation:s.isolation,taskSourceProjectPath:a,taskWorktree:t}),taskWorktree:t}}catch(k){if(t)await I.exit({sessionId:s.sessionId,action:"remove",discardChanges:!0}).catch(()=>{return});throw k}}}var $=256,V=8388608,x=30000;class i extends Error{kind;pendingItems;pendingBytes;constructor(s,a,t){super(a,t);this.kind=s;this.name="BoundedSerialEgressError",this.pendingItems=t?.pendingItems,this.pendingBytes=t?.pendingBytes}}function T(s){s.catch(()=>{return})}class K{options;pending=[];flushWaiters=[];pendingBytes=0;nextSequence=0;completedSequence=0;draining=!1;closed=!1;failure;activeWriteAbort;activeWriteStop;activeWriteTimeout;constructor(s){this.options=s;if(this.assertPositiveInteger(s.maxPendingItems,"maxPendingItems"),this.assertPositiveInteger(s.maxPendingBytes,"maxPendingBytes"),this.assertPositiveInteger(s.writeTimeoutMs,"writeTimeoutMs"),s.signal?.addEventListener("abort",this.handleAbort,{once:!0}),s.signal?.aborted)this.handleAbort()}offer(s){if(this.closed)return{accepted:!1,error:this.failure??new i("closed","Egress is already closed")};let a;try{a=this.options.sizeOf(s)}catch(h){return this.rejectAdmission(new i("invalid_size","Egress size calculation failed",{cause:h}))}if(!Number.isSafeInteger(a)||a<0)return this.rejectAdmission(new i("invalid_size","Egress size must be a non-negative safe integer"));if(a>this.options.maxPendingBytes)return this.rejectAdmission(new i("oversized",`Egress value requires ${a} bytes; limit is ${this.options.maxPendingBytes}`));if(this.pending.length>=this.options.maxPendingItems||this.pendingBytes+a>this.options.maxPendingBytes)return this.rejectAdmission(new i("overflow",`Egress pending limit exceeded (${this.pending.length} items, ${this.pendingBytes} bytes)`));let t,k,c=new Promise((h,m)=>{t=h,k=m});return T(c),this.nextSequence+=1,this.pending.push({value:s,bytes:a,sequence:this.nextSequence,resolve:t,reject:k,completion:c}),this.pendingBytes+=a,this.startDrain(),{accepted:!0,completion:c}}flush(){if(this.failure){let c=Promise.reject(this.failure);return T(c),c}let s=this.nextSequence;if(s<=this.completedSequence)return Promise.resolve();let a,t,k=new Promise((c,h)=>{a=c,t=h});return T(k),this.flushWaiters.push({targetSequence:s,resolve:a,reject:t}),k}close(s){let a=s instanceof i?s:new i("closed","Egress was closed",{cause:s});this.fail(a)}stats(){return{closed:this.closed,pendingItems:this.pending.length,pendingBytes:this.pendingBytes}}handleAbort=()=>{this.fail(new i("aborted","Egress was aborted",{cause:this.options.signal?.reason}))};rejectAdmission(s){return this.fail(s),{accepted:!1,error:s}}startDrain(){if(this.draining||this.closed)return;this.draining=!0;let s=this.drain();T(s)}async drain(){try{while(!this.closed){let s=this.pending[0];if(!s)return;try{await this.writeOne(s.value)}catch(a){this.fail(this.normalizeWriteError(a));return}if(this.closed||this.pending[0]!==s)return;this.pending.shift(),this.pendingBytes-=s.bytes,this.completedSequence=s.sequence,s.resolve(),this.settleFlushWaiters()}}finally{if(this.draining=!1,!this.closed&&this.pending.length>0)this.startDrain()}}async writeOne(s){let a=new AbortController;this.activeWriteAbort=a;let t,k,c=new Promise((S,f)=>{k=f});T(c),this.activeWriteStop=k;let h=Promise.resolve().then(()=>this.options.write(s,a.signal));T(h);let m=new Promise((S,f)=>{t=setTimeout(()=>{let D=new i("write_timeout",`Egress write timed out after ${this.options.writeTimeoutMs}ms`);a.abort(D),f(D)},this.options.writeTimeoutMs),this.activeWriteTimeout=t});T(m);try{await Promise.race([h,m,c])}finally{if(t!==void 0)clearTimeout(t);if(this.activeWriteTimeout===t)this.activeWriteTimeout=void 0;if(this.activeWriteAbort===a)this.activeWriteAbort=void 0;if(this.activeWriteStop===k)this.activeWriteStop=void 0}}normalizeWriteError(s){if(s instanceof i)return s;return new i("write_failed","Egress write failed",{cause:s})}fail(s){if(this.closed)return;if(s.pendingItems??=this.pending.length,s.pendingBytes??=this.pendingBytes,this.closed=!0,this.failure=s,this.options.signal?.removeEventListener("abort",this.handleAbort),this.activeWriteTimeout!==void 0)clearTimeout(this.activeWriteTimeout),this.activeWriteTimeout=void 0;this.activeWriteAbort?.abort(s),this.activeWriteStop?.(s),this.activeWriteAbort=void 0,this.activeWriteStop=void 0;let a=this.pending.splice(0);this.pendingBytes=0;for(let t of a)t.reject(s);for(let t of this.flushWaiters.splice(0))t.reject(s);try{this.options.onFailure?.(s)}catch{}}settleFlushWaiters(){for(let s=0;s<this.flushWaiters.length;){let a=this.flushWaiters[s];if(a.targetSequence>this.completedSequence){s+=1;continue}this.flushWaiters.splice(s,1),a.resolve()}}assertPositiveInteger(s,a){if(!Number.isSafeInteger(s)||s<=0)throw RangeError(`${a} must be a positive safe integer`)}}
1
+ import{O as I}from"./chunk-2f5kkhan.js";import{Qd as M}from"./chunk-zydvg30x.js";import P from"node:path";function w(s){let a=s.replace(/\s+/g," ").trim();return a.length<=72?a:`${a.slice(0,69)}...`}function W(s){let a=s.replace(/\s+/g," ").trim();return a.length<=500?a:`${a.slice(0,497)}...`}function A(s){return`task/${s.replace(/[^a-zA-Z0-9_-]/g,"-").slice(0,40)}`}class C{static async createSessionTask(s){if(!s.prompt.trim())throw Error("Task prompt must not be blank");if(!P.isAbsolute(s.sourceProjectPath))throw Error("Task source project path must be absolute");let a=P.resolve(s.sourceProjectPath),t;try{return t=s.isolation==="worktree"?await I.enter({sessionId:s.sessionId,workspaceRoot:a,name:A(s.sessionId)}):void 0,{metadata:await M.createSessionMetadata(s.sessionId,t?.workspaceRoot??a,{title:s.title?.trim()||w(s.prompt),taskPromptSummary:W(s.prompt),taskPriority:s.taskPriority,taskKind:s.taskKind,taskDueAt:s.taskDueAt,taskDispatch:s.dispatch,taskModelId:s.dispatch?.modelId,selectedModelId:s.dispatch?.modelId,permissionMode:s.dispatch?.permissionMode,reasoningEffort:s.dispatch?.reasoningEffort,serviceTier:s.dispatch?.serviceTier,responseVerbosity:s.dispatch?.responseVerbosity,communicationStyle:s.dispatch?.communicationStyle,communicationStyleDigest:s.dispatch?.communicationStyleDigest,projectInstructionsDigest:s.dispatch?.projectInstructionsDigest,taskRetriedFrom:s.retriedFrom,taskIsolation:s.isolation,taskSourceProjectPath:a,taskWorktree:t}),taskWorktree:t}}catch(k){if(t)await I.exit({sessionId:s.sessionId,action:"remove",discardChanges:!0}).catch(()=>{return});throw k}}}var $=256,V=8388608,x=30000;class i extends Error{kind;pendingItems;pendingBytes;constructor(s,a,t){super(a,t);this.kind=s;this.name="BoundedSerialEgressError",this.pendingItems=t?.pendingItems,this.pendingBytes=t?.pendingBytes}}function T(s){s.catch(()=>{return})}class K{options;pending=[];flushWaiters=[];pendingBytes=0;nextSequence=0;completedSequence=0;draining=!1;closed=!1;failure;activeWriteAbort;activeWriteStop;activeWriteTimeout;constructor(s){this.options=s;if(this.assertPositiveInteger(s.maxPendingItems,"maxPendingItems"),this.assertPositiveInteger(s.maxPendingBytes,"maxPendingBytes"),this.assertPositiveInteger(s.writeTimeoutMs,"writeTimeoutMs"),s.signal?.addEventListener("abort",this.handleAbort,{once:!0}),s.signal?.aborted)this.handleAbort()}offer(s){if(this.closed)return{accepted:!1,error:this.failure??new i("closed","Egress is already closed")};let a;try{a=this.options.sizeOf(s)}catch(h){return this.rejectAdmission(new i("invalid_size","Egress size calculation failed",{cause:h}))}if(!Number.isSafeInteger(a)||a<0)return this.rejectAdmission(new i("invalid_size","Egress size must be a non-negative safe integer"));if(a>this.options.maxPendingBytes)return this.rejectAdmission(new i("oversized",`Egress value requires ${a} bytes; limit is ${this.options.maxPendingBytes}`));if(this.pending.length>=this.options.maxPendingItems||this.pendingBytes+a>this.options.maxPendingBytes)return this.rejectAdmission(new i("overflow",`Egress pending limit exceeded (${this.pending.length} items, ${this.pendingBytes} bytes)`));let t,k,c=new Promise((h,m)=>{t=h,k=m});return T(c),this.nextSequence+=1,this.pending.push({value:s,bytes:a,sequence:this.nextSequence,resolve:t,reject:k,completion:c}),this.pendingBytes+=a,this.startDrain(),{accepted:!0,completion:c}}flush(){if(this.failure){let c=Promise.reject(this.failure);return T(c),c}let s=this.nextSequence;if(s<=this.completedSequence)return Promise.resolve();let a,t,k=new Promise((c,h)=>{a=c,t=h});return T(k),this.flushWaiters.push({targetSequence:s,resolve:a,reject:t}),k}close(s){let a=s instanceof i?s:new i("closed","Egress was closed",{cause:s});this.fail(a)}stats(){return{closed:this.closed,pendingItems:this.pending.length,pendingBytes:this.pendingBytes}}handleAbort=()=>{this.fail(new i("aborted","Egress was aborted",{cause:this.options.signal?.reason}))};rejectAdmission(s){return this.fail(s),{accepted:!1,error:s}}startDrain(){if(this.draining||this.closed)return;this.draining=!0;let s=this.drain();T(s)}async drain(){try{while(!this.closed){let s=this.pending[0];if(!s)return;try{await this.writeOne(s.value)}catch(a){this.fail(this.normalizeWriteError(a));return}if(this.closed||this.pending[0]!==s)return;this.pending.shift(),this.pendingBytes-=s.bytes,this.completedSequence=s.sequence,s.resolve(),this.settleFlushWaiters()}}finally{if(this.draining=!1,!this.closed&&this.pending.length>0)this.startDrain()}}async writeOne(s){let a=new AbortController;this.activeWriteAbort=a;let t,k,c=new Promise((S,f)=>{k=f});T(c),this.activeWriteStop=k;let h=Promise.resolve().then(()=>this.options.write(s,a.signal));T(h);let m=new Promise((S,f)=>{t=setTimeout(()=>{let D=new i("write_timeout",`Egress write timed out after ${this.options.writeTimeoutMs}ms`);a.abort(D),f(D)},this.options.writeTimeoutMs),this.activeWriteTimeout=t});T(m);try{await Promise.race([h,m,c])}finally{if(t!==void 0)clearTimeout(t);if(this.activeWriteTimeout===t)this.activeWriteTimeout=void 0;if(this.activeWriteAbort===a)this.activeWriteAbort=void 0;if(this.activeWriteStop===k)this.activeWriteStop=void 0}}normalizeWriteError(s){if(s instanceof i)return s;return new i("write_failed","Egress write failed",{cause:s})}fail(s){if(this.closed)return;if(s.pendingItems??=this.pending.length,s.pendingBytes??=this.pendingBytes,this.closed=!0,this.failure=s,this.options.signal?.removeEventListener("abort",this.handleAbort),this.activeWriteTimeout!==void 0)clearTimeout(this.activeWriteTimeout),this.activeWriteTimeout=void 0;this.activeWriteAbort?.abort(s),this.activeWriteStop?.(s),this.activeWriteAbort=void 0,this.activeWriteStop=void 0;let a=this.pending.splice(0);this.pendingBytes=0;for(let t of a)t.reject(s);for(let t of this.flushWaiters.splice(0))t.reject(s);try{this.options.onFailure?.(s)}catch{}}settleFlushWaiters(){for(let s=0;s<this.flushWaiters.length;){let a=this.flushWaiters[s];if(a.targetSequence>this.completedSequence){s+=1;continue}this.flushWaiters.splice(s,1),a.resolve()}}assertPositiveInteger(s,a){if(!Number.isSafeInteger(s)||s<=0)throw RangeError(`${a} must be a positive safe integer`)}}
2
2
  export{C as v,$ as w,V as x,x as y,i as z,K as A};
@@ -1 +1 @@
1
- import{Bb as d,Cb as e,Db as f,Eb as g,Fb as h,Gb as i,Hb as j,Ib as k,Pb as l,Qb as m,Rb as n,Sb as o,Ub as p,Vb as q,Wb as r,ub as a,vb as b,xb as c}from"./chunk-mq4x8zhq.js";import"./chunk-8hprmrd5.js";import"./chunk-x5j6nexe.js";import"./chunk-s0tq8gyx.js";import"./chunk-h8qjkxee.js";import"./chunk-dg0d3303.js";import"./chunk-3awjdsef.js";import"./chunk-2hb222re.js";import"./chunk-fvfc95g3.js";import"./chunk-qcy79mva.js";import"./chunk-6yz49rz2.js";import"./chunk-c6tq09mt.js";import"./chunk-f9asjkfz.js";import"./chunk-czcxx8tb.js";import"./chunk-maebpz1j.js";import"./chunk-9sx3vsyj.js";import"./chunk-70hwyc2w.js";import"./chunk-d8wzc602.js";import"./chunk-425p4nwx.js";import"./chunk-k7vv9vne.js";import"./chunk-mhfwp1f0.js";import"./chunk-2va6ex5v.js";import"./chunk-q3vza5gt.js";import"./chunk-w9xfks7f.js";export{g as saveUserMessage,i as saveToolUse,j as saveToolResult,k as saveCompaction,h as saveAssistantMessage,d as isRootSystemPrompt,m as handleTaskListUpdate,n as handleSkillActivation,o as extractModelSwitch,r as executeLoopGenerator,f as drainLoop,c as checkStopHook,a as checkOutputRecovery,b as checkIncompleteIntent,q as checkAndCompactInLoop,p as applyToolDomainEffects,l as StreamingToolExecutor,e as ConversationState};
1
+ import{Bb as d,Cb as e,Db as f,Eb as g,Fb as h,Gb as i,Hb as j,Ib as k,Pb as l,Qb as m,Rb as n,Sb as o,Ub as p,Vb as q,Wb as r,ub as a,vb as b,xb as c}from"./chunk-qjv5kz7q.js";import"./chunk-8hprmrd5.js";import"./chunk-zydvg30x.js";import"./chunk-s0tq8gyx.js";import"./chunk-hpjnk87v.js";import"./chunk-dg0d3303.js";import"./chunk-3awjdsef.js";import"./chunk-2hb222re.js";import"./chunk-fvfc95g3.js";import"./chunk-qcy79mva.js";import"./chunk-dcjh1cj6.js";import"./chunk-c6tq09mt.js";import"./chunk-f9asjkfz.js";import"./chunk-czcxx8tb.js";import"./chunk-maebpz1j.js";import"./chunk-9sx3vsyj.js";import"./chunk-70hwyc2w.js";import"./chunk-d8wzc602.js";import"./chunk-425p4nwx.js";import"./chunk-k7vv9vne.js";import"./chunk-8z9d0zd0.js";import"./chunk-2va6ex5v.js";import"./chunk-q3vza5gt.js";import"./chunk-w9xfks7f.js";export{g as saveUserMessage,i as saveToolUse,j as saveToolResult,k as saveCompaction,h as saveAssistantMessage,d as isRootSystemPrompt,m as handleTaskListUpdate,n as handleSkillActivation,o as extractModelSwitch,r as executeLoopGenerator,f as drainLoop,c as checkStopHook,a as checkOutputRecovery,b as checkIncompleteIntent,q as checkAndCompactInLoop,p as applyToolDomainEffects,l as StreamingToolExecutor,e as ConversationState};
@@ -1 +1 @@
1
- import{Kd as a,Ld as b,Md as c,Nd as d,Od as e,Pd as f,Qd as g}from"./chunk-x5j6nexe.js";import"./chunk-s0tq8gyx.js";import"./chunk-h8qjkxee.js";import"./chunk-2hb222re.js";import"./chunk-qcy79mva.js";import"./chunk-c6tq09mt.js";import"./chunk-maebpz1j.js";import"./chunk-9sx3vsyj.js";import"./chunk-d8wzc602.js";import"./chunk-k7vv9vne.js";import"./chunk-mhfwp1f0.js";import"./chunk-q3vza5gt.js";import"./chunk-w9xfks7f.js";export{b as __setSessionSnapshotIOForTesting,c as __resetSessionSnapshotIOForTesting,g as SessionService,d as SessionMissingCreationError,e as SessionArchivedError,f as SessionArchiveConflictError,a as STALE_EMPTY_SESSION_AGE_MS};
1
+ import{Kd as a,Ld as b,Md as c,Nd as d,Od as e,Pd as f,Qd as g}from"./chunk-zydvg30x.js";import"./chunk-s0tq8gyx.js";import"./chunk-hpjnk87v.js";import"./chunk-2hb222re.js";import"./chunk-qcy79mva.js";import"./chunk-c6tq09mt.js";import"./chunk-maebpz1j.js";import"./chunk-9sx3vsyj.js";import"./chunk-d8wzc602.js";import"./chunk-k7vv9vne.js";import"./chunk-8z9d0zd0.js";import"./chunk-q3vza5gt.js";import"./chunk-w9xfks7f.js";export{b as __setSessionSnapshotIOForTesting,c as __resetSessionSnapshotIOForTesting,g as SessionService,d as SessionMissingCreationError,e as SessionArchivedError,f as SessionArchiveConflictError,a as STALE_EMPTY_SESSION_AGE_MS};
@@ -1 +1 @@
1
- import{Nf as a,Of as b,Pf as c,Qf as d,Rf as e,Sf as f,Tf as g,Uf as h,Vf as i,Wf as j}from"./chunk-d7j7z8hy.js";import"./chunk-fvfc95g3.js";import"./chunk-qcy79mva.js";import"./chunk-p0rvgzpx.js";import"./chunk-6yz49rz2.js";import"./chunk-c6tq09mt.js";import"./chunk-fqwq3626.js";import"./chunk-f9asjkfz.js";import"./chunk-czcxx8tb.js";import"./chunk-maebpz1j.js";import"./chunk-9sx3vsyj.js";import"./chunk-70hwyc2w.js";import"./chunk-d8wzc602.js";import"./chunk-425p4nwx.js";import"./chunk-k7vv9vne.js";import"./chunk-mhfwp1f0.js";import"./chunk-cp7xsjj2.js";import"./chunk-2va6ex5v.js";import"./chunk-q3vza5gt.js";import"./chunk-w9xfks7f.js";export{g as withWorkspaceAgentResources,i as snapshotWorkspaceAgentResources,f as resolveWorkspaceAgentResources,j as resetWorkspaceAgentResources,d as refreshWorkspaceCommunicationStyles,h as getWorkspaceAgentResourceCacheStats,e as configureInvocationPluginDirs,c as WorkspaceAgentResourceCapacityError,a as MAX_RESIDENT_WORKSPACE_AGENT_RESOURCES,b as MAX_ACTIVE_WORKSPACE_AGENT_RESOURCES};
1
+ import{Nf as a,Of as b,Pf as c,Qf as d,Rf as e,Sf as f,Tf as g,Uf as h,Vf as i,Wf as j}from"./chunk-nh4jy5cs.js";import"./chunk-fvfc95g3.js";import"./chunk-qcy79mva.js";import"./chunk-p0rvgzpx.js";import"./chunk-dcjh1cj6.js";import"./chunk-c6tq09mt.js";import"./chunk-z5a8ay9s.js";import"./chunk-f9asjkfz.js";import"./chunk-czcxx8tb.js";import"./chunk-maebpz1j.js";import"./chunk-9sx3vsyj.js";import"./chunk-70hwyc2w.js";import"./chunk-d8wzc602.js";import"./chunk-425p4nwx.js";import"./chunk-k7vv9vne.js";import"./chunk-8z9d0zd0.js";import"./chunk-cp7xsjj2.js";import"./chunk-2va6ex5v.js";import"./chunk-q3vza5gt.js";import"./chunk-w9xfks7f.js";export{g as withWorkspaceAgentResources,i as snapshotWorkspaceAgentResources,f as resolveWorkspaceAgentResources,j as resetWorkspaceAgentResources,d as refreshWorkspaceCommunicationStyles,h as getWorkspaceAgentResourceCacheStats,e as configureInvocationPluginDirs,c as WorkspaceAgentResourceCapacityError,a as MAX_RESIDENT_WORKSPACE_AGENT_RESOURCES,b as MAX_ACTIVE_WORKSPACE_AGENT_RESOURCES};
@@ -1,4 +1,4 @@
1
- import{Xf as b1,Yf as L0,Zf as z1,cg as N0}from"./chunk-fvfc95g3.js";import{hg as jO,ig as wO}from"./chunk-qcy79mva.js";import{lg as A1}from"./chunk-p0rvgzpx.js";import{mg as b0,og as J0}from"./chunk-6yz49rz2.js";import{qh as S0,rh as GO,vh as I0}from"./chunk-fqwq3626.js";import{Bh as L,Eh as c1,zh as u}from"./chunk-czcxx8tb.js";import{Nh as M}from"./chunk-9sx3vsyj.js";import{ni as k,oi as S}from"./chunk-d8wzc602.js";import{Bi as u0}from"./chunk-mhfwp1f0.js";import{Ii as N}from"./chunk-cp7xsjj2.js";import H1 from"node:path";import LO from"node:path";import v0 from"node:fs";import W0 from"node:os";import E from"node:path";import dO from"yaml";var U1=2000,V1=50,j1=1000,Y4={type:"object",properties:{verdict:{type:"string",enum:["pass","fail","partial"]},summary:{type:"string",minLength:1,maxLength:U1},findings:{type:"array",maxItems:V1,items:{type:"string",minLength:1,maxLength:j1}}},required:["verdict","summary","findings"],additionalProperties:!1};function F1(O,$){let Q=O.trim().replaceAll(/\s+/g," ");if($)Q=Q.replaceAll($,".");return Q.replace(/\bBearer\s+[^\s"'`]+/gi,"Bearer [redacted]").replace(/\bsk-[A-Za-z0-9_-]{8,}\b/g,"[redacted-key]").replace(/\b(api(?:[_-]?|\s+)key|access(?:[_-]?|\s+)token|authorization|cookie|password|passwd|refresh(?:[_-]?|\s+)token|secret|session(?:[_-]?|\s+)token)\b(\s*[:=]\s*)([^\s,;]+)/gi,"$1$2[redacted]")}function hO(O){if(O.length<=N0)return O;let $=" [verification feedback truncated]",Q=O.slice(0,N0-$.length);if(/[\uD800-\uDBFF]$/.test(Q))Q=Q.slice(0,-1);return Q.trimEnd()+$}function B1(O){if(!O||typeof O!=="object"||Array.isArray(O))return;let $=O;if($.verdict!=="pass"&&$.verdict!=="fail"&&$.verdict!=="partial"||typeof $.summary!=="string"||!$.summary.trim()||$.summary.length>U1||!Array.isArray($.findings)||$.findings.length>V1||!$.findings.every((Q)=>typeof Q==="string"&&Q.trim().length>0&&Q.length<=j1))return;return{verdict:$.verdict,summary:$.summary.trim(),findings:$.findings.map((Q)=>Q.trim())}}function X4(O,$){let Q=B1(O);if(!Q)return;let Z=F1(Q.summary,$),J=Q.findings.map((K)=>F1(K,$));return hO([Z,J.length>0?`Findings:
1
+ import{Xf as b1,Yf as L0,Zf as z1,cg as N0}from"./chunk-fvfc95g3.js";import{hg as jO,ig as wO}from"./chunk-qcy79mva.js";import{lg as A1}from"./chunk-p0rvgzpx.js";import{mg as b0,og as J0}from"./chunk-dcjh1cj6.js";import{qh as S0,rh as GO,vh as I0}from"./chunk-z5a8ay9s.js";import{Bh as L,Eh as c1,zh as u}from"./chunk-czcxx8tb.js";import{Nh as M}from"./chunk-9sx3vsyj.js";import{ni as k,oi as S}from"./chunk-d8wzc602.js";import{Bi as u0}from"./chunk-8z9d0zd0.js";import{Ii as N}from"./chunk-cp7xsjj2.js";import H1 from"node:path";import LO from"node:path";import v0 from"node:fs";import W0 from"node:os";import E from"node:path";import dO from"yaml";var U1=2000,V1=50,j1=1000,Y4={type:"object",properties:{verdict:{type:"string",enum:["pass","fail","partial"]},summary:{type:"string",minLength:1,maxLength:U1},findings:{type:"array",maxItems:V1,items:{type:"string",minLength:1,maxLength:j1}}},required:["verdict","summary","findings"],additionalProperties:!1};function F1(O,$){let Q=O.trim().replaceAll(/\s+/g," ");if($)Q=Q.replaceAll($,".");return Q.replace(/\bBearer\s+[^\s"'`]+/gi,"Bearer [redacted]").replace(/\bsk-[A-Za-z0-9_-]{8,}\b/g,"[redacted-key]").replace(/\b(api(?:[_-]?|\s+)key|access(?:[_-]?|\s+)token|authorization|cookie|password|passwd|refresh(?:[_-]?|\s+)token|secret|session(?:[_-]?|\s+)token)\b(\s*[:=]\s*)([^\s,;]+)/gi,"$1$2[redacted]")}function hO(O){if(O.length<=N0)return O;let $=" [verification feedback truncated]",Q=O.slice(0,N0-$.length);if(/[\uD800-\uDBFF]$/.test(Q))Q=Q.slice(0,-1);return Q.trimEnd()+$}function B1(O){if(!O||typeof O!=="object"||Array.isArray(O))return;let $=O;if($.verdict!=="pass"&&$.verdict!=="fail"&&$.verdict!=="partial"||typeof $.summary!=="string"||!$.summary.trim()||$.summary.length>U1||!Array.isArray($.findings)||$.findings.length>V1||!$.findings.every((Q)=>typeof Q==="string"&&Q.trim().length>0&&Q.length<=j1))return;return{verdict:$.verdict,summary:$.summary.trim(),findings:$.findings.map((Q)=>Q.trim())}}function X4(O,$){let Q=B1(O);if(!Q)return;let Z=F1(Q.summary,$),J=Q.findings.map((K)=>F1(K,$));return hO([Z,J.length>0?`Findings:
2
2
  ${J.map((K)=>`- ${K}`).join(`
3
3
  `)}`:""].filter(Boolean).join(`
4
4
 
@@ -28,6 +28,14 @@ current workspace provides direct evidence for every explicit requirement.
28
28
  contradiction, failed check, defect, or missing required artifact.
29
29
  8. SAFE FEEDBACK. Keep summary and findings concise, use workspace-relative
30
30
  file locations, and never include credentials or secret values.
31
+ 9. HOST CONTROL PLANE. This reserved verifier runs only after the host durably
32
+ accepts the parent Agent's UpdateGoal complete call. During verification, the
33
+ Goal intentionally remains status=verifying with
34
+ completionVerification.status=pending. Treat that state as an awaiting
35
+ verdict, never as evidence that UpdateGoal was omitted. Do not require
36
+ status=complete or a PASS verdict before issuing your own verdict because
37
+ only your PASS permits the host to commit them. This proves only the
38
+ completion-candidate control action, not the requested deliverables.
31
39
 
32
40
  ## Verdict
33
41
 
@@ -1,4 +1,4 @@
1
- import{a as T,b as W,c as X,d as Y}from"./chunk-xz5ar75z.js";import"./chunk-j00px1es.js";import"./chunk-39qzk9nm.js";import"./chunk-ga15nptz.js";import"./chunk-a42rvwg4.js";import"./chunk-6vcy0nq7.js";import"./chunk-ap8539bw.js";import"./chunk-0zhdjaen.js";import"./chunk-bdbyy2ah.js";import"./chunk-hz5rsfxv.js";import"./chunk-mq4x8zhq.js";import"./chunk-8hprmrd5.js";import"./chunk-x5j6nexe.js";import"./chunk-s0tq8gyx.js";import"./chunk-h8qjkxee.js";import{ve as R}from"./chunk-12vzyc3x.js";import"./chunk-rej5bbbs.js";import{Re as Q}from"./chunk-1pscfw5q.js";import"./chunk-v508x7cg.js";import"./chunk-dg0d3303.js";import"./chunk-3awjdsef.js";import"./chunk-53xtssbf.js";import"./chunk-2hb222re.js";import"./chunk-r22mdmtr.js";import"./chunk-d7j7z8hy.js";import"./chunk-fvfc95g3.js";import"./chunk-qcy79mva.js";import"./chunk-p0rvgzpx.js";import"./chunk-6yz49rz2.js";import"./chunk-c6tq09mt.js";import"./chunk-fqwq3626.js";import"./chunk-f9asjkfz.js";import"./chunk-czcxx8tb.js";import"./chunk-maebpz1j.js";import"./chunk-9sx3vsyj.js";import"./chunk-70hwyc2w.js";import"./chunk-d8wzc602.js";import"./chunk-425p4nwx.js";import"./chunk-k7vv9vne.js";import{Bi as M}from"./chunk-mhfwp1f0.js";import"./chunk-cp7xsjj2.js";import"./chunk-2va6ex5v.js";import"./chunk-q3vza5gt.js";import"./chunk-w9xfks7f.js";import m from"chalk";import K from"open";var A=`
1
+ import{a as T,b as W,c as X,d as Y}from"./chunk-ykf4cqpg.js";import"./chunk-j00px1es.js";import"./chunk-39qzk9nm.js";import"./chunk-fqbc1ppx.js";import"./chunk-tp5bep1y.js";import"./chunk-kdatgrjy.js";import"./chunk-2f5kkhan.js";import"./chunk-0zhdjaen.js";import"./chunk-2cg8f38t.js";import"./chunk-hz5rsfxv.js";import"./chunk-qjv5kz7q.js";import"./chunk-8hprmrd5.js";import"./chunk-zydvg30x.js";import"./chunk-s0tq8gyx.js";import"./chunk-hpjnk87v.js";import{ve as R}from"./chunk-8yt4nmyb.js";import"./chunk-rej5bbbs.js";import{Re as Q}from"./chunk-z0dmm227.js";import"./chunk-v508x7cg.js";import"./chunk-dg0d3303.js";import"./chunk-3awjdsef.js";import"./chunk-53xtssbf.js";import"./chunk-2hb222re.js";import"./chunk-2191220r.js";import"./chunk-nh4jy5cs.js";import"./chunk-fvfc95g3.js";import"./chunk-qcy79mva.js";import"./chunk-p0rvgzpx.js";import"./chunk-dcjh1cj6.js";import"./chunk-c6tq09mt.js";import"./chunk-z5a8ay9s.js";import"./chunk-f9asjkfz.js";import"./chunk-czcxx8tb.js";import"./chunk-maebpz1j.js";import"./chunk-9sx3vsyj.js";import"./chunk-70hwyc2w.js";import"./chunk-d8wzc602.js";import"./chunk-425p4nwx.js";import"./chunk-k7vv9vne.js";import{Bi as M}from"./chunk-8z9d0zd0.js";import"./chunk-cp7xsjj2.js";import"./chunk-2va6ex5v.js";import"./chunk-q3vza5gt.js";import"./chunk-w9xfks7f.js";import m from"chalk";import K from"open";var A=`
2
2
  ____ _ _
3
3
  | __ )| | __ _ __| | ___
4
4
  | _ \\| |/ _\` |/ _\` |/ _ \\
@@ -1 +1 @@
1
- import{ge as a,he as b,ie as c,je as d,ke as e,le as f,me as g,ne as h}from"./chunk-h8qjkxee.js";import"./chunk-d8wzc602.js";import"./chunk-q3vza5gt.js";import"./chunk-w9xfks7f.js";export{d as syncSession,e as syncAll,h as searchProjectionText,c as resetProjectionDbCache,f as removeSessionFromProjection,g as rebuildProjectionIndex,b as getProjectionDb,a as getIndexDbPath};
1
+ import{ge as a,he as b,ie as c,je as d,ke as e,le as f,me as g,ne as h}from"./chunk-hpjnk87v.js";import"./chunk-d8wzc602.js";import"./chunk-q3vza5gt.js";import"./chunk-w9xfks7f.js";export{d as syncSession,e as syncAll,h as searchProjectionText,c as resetProjectionDbCache,f as removeSessionFromProjection,g as rebuildProjectionIndex,b as getProjectionDb,a as getIndexDbPath};