blade-code 0.10.127 → 0.10.128
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blade.js +2 -2
- package/dist/chunk-0ktte40x.js +185 -0
- package/dist/{chunk-85bamng3.js → chunk-10w2pj3r.js} +1 -1
- package/dist/{chunk-1b2dkwpv.js → chunk-12hdakw4.js} +2 -2
- package/dist/chunk-1acb8fwq.js +120 -0
- package/dist/{chunk-gna6njws.js → chunk-1aw643j2.js} +2 -2
- package/dist/{chunk-6kwg4hcv.js → chunk-1xg7qx35.js} +1 -1
- package/dist/chunk-3pwqqk7w.js +1 -0
- package/dist/chunk-3q7g9206.js +1 -0
- package/dist/{chunk-t23n4wn0.js → chunk-41byj2h8.js} +2 -2
- package/dist/{chunk-8zftskf2.js → chunk-562w5zc6.js} +1 -1
- package/dist/chunk-5x56nka1.js +1 -0
- package/dist/{chunk-mpwyf1fe.js → chunk-60he05xs.js} +1 -1
- package/dist/{chunk-1g0d9yw0.js → chunk-6m4sqwj0.js} +2 -2
- package/dist/{chunk-m76jmvsf.js → chunk-6v2hhgka.js} +2 -2
- package/dist/chunk-7hajkvde.js +1 -0
- package/dist/{chunk-a552m4hx.js → chunk-85jv1sr7.js} +1 -1
- package/dist/{chunk-adkpwx6c.js → chunk-8hd4vd20.js} +1 -1
- package/dist/{chunk-cw2b3383.js → chunk-96w8ay2h.js} +1 -1
- package/dist/{chunk-wmds1jq3.js → chunk-9hnfz9bx.js} +1 -1
- package/dist/{chunk-dknmpacf.js → chunk-9n90djh7.js} +1 -1
- package/dist/chunk-9wptwfmg.js +1 -0
- package/dist/{chunk-ve4kvj1n.js → chunk-a7gghhvn.js} +20 -20
- package/dist/{chunk-a0t558d4.js → chunk-ap01rwg0.js} +1 -1
- package/dist/{chunk-sv833k2e.js → chunk-atema2rc.js} +2 -2
- package/dist/{chunk-a3ewfebr.js → chunk-b408cqg1.js} +2 -2
- package/dist/{chunk-7n7swtwg.js → chunk-c47db31j.js} +2 -2
- package/dist/chunk-cm8fy1jn.js +1 -0
- package/dist/chunk-dp4r5bay.js +1 -0
- package/dist/chunk-dtxza4zh.js +1 -0
- package/dist/{chunk-0zzh482s.js → chunk-ektgnqmh.js} +1 -1
- package/dist/{chunk-g7f3nhg2.js → chunk-fa0pyv9k.js} +1 -1
- package/dist/{chunk-xvn80fge.js → chunk-fgbqm2jh.js} +1 -1
- package/dist/{chunk-w7n73ag8.js → chunk-gxwkwkhp.js} +1 -1
- package/dist/chunk-hd7bxzvy.js +1 -0
- package/dist/chunk-hks48s9k.js +1 -0
- package/dist/chunk-hmncnf7p.js +1 -0
- package/dist/chunk-j6fj679p.js +10 -0
- package/dist/{chunk-gqv0vkg9.js → chunk-jxc67ydz.js} +2 -2
- package/dist/{chunk-hhmhs2q1.js → chunk-jy0vfp8a.js} +1 -1
- package/dist/chunk-m8czdpyg.js +1 -0
- package/dist/{chunk-t727txa9.js → chunk-mkvvyq49.js} +2 -2
- package/dist/{chunk-hmwz31tc.js → chunk-mm05y2c5.js} +1 -1
- package/dist/{chunk-xdvn6yrd.js → chunk-mvgmsjwq.js} +1 -1
- package/dist/{chunk-dh03cybw.js → chunk-n4q6fvqe.js} +2 -2
- package/dist/{chunk-p0khbmbc.js → chunk-n8w1jxsh.js} +1 -1
- package/dist/{chunk-y94239bb.js → chunk-nx8xb7dm.js} +1 -1
- package/dist/{chunk-s20hq62y.js → chunk-p2rxrxct.js} +3 -3
- package/dist/{chunk-23wg4jvz.js → chunk-p5awnndq.js} +1 -1
- package/dist/{chunk-eq1anf88.js → chunk-p7349xay.js} +1 -1
- package/dist/{chunk-zm2bbagg.js → chunk-pq6g92cz.js} +1 -1
- package/dist/{chunk-z1zr4wts.js → chunk-q3y3s16v.js} +1 -1
- package/dist/{chunk-g2jx4y8f.js → chunk-qm632an7.js} +1 -1
- package/dist/{chunk-68sf54n4.js → chunk-r04vwtej.js} +2 -2
- package/dist/chunk-rz2wc93t.js +171 -0
- package/dist/{chunk-8qp8v96d.js → chunk-s7axaw78.js} +1 -1
- package/dist/chunk-s7peh6kf.js +2 -0
- package/dist/{chunk-2xezz3nt.js → chunk-skv2gb99.js} +1 -1
- package/dist/{chunk-s6562rsq.js → chunk-ted1hyvb.js} +1 -1
- package/dist/chunk-v4nqv1pr.js +1708 -0
- package/dist/{chunk-9hm3hy8d.js → chunk-ws6gtw33.js} +1 -1
- package/dist/chunk-wtmhqy5s.js +1 -0
- package/dist/{chunk-rw2sq3mf.js → chunk-xejvs1fk.js} +1 -1
- package/dist/chunk-xnstybjm.js +2 -0
- package/dist/chunk-xpdtg9h9.js +23 -0
- package/dist/{chunk-ye4wyq1k.js → chunk-xshrj2nd.js} +1 -1
- package/dist/{chunk-hbafhk9y.js → chunk-xzfc1s6k.js} +1 -1
- package/dist/{chunk-r5nvt35e.js → chunk-y93nqyqd.js} +2 -2
- package/dist/{chunk-pezzyyyk.js → chunk-yqpej45c.js} +2 -2
- package/dist/chunk-yqqeh12b.js +2 -0
- package/dist/{chunk-shd1ec3n.js → chunk-yysqw1cq.js} +1 -1
- package/dist/chunk-z2jwm4s8.js +1 -0
- package/dist/{chunk-q265drks.js → chunk-z3hpstky.js} +1 -1
- package/dist/{chunk-2t6b962t.js → chunk-zfyg3888.js} +1 -1
- package/package.json +1 -1
- package/dist/chunk-2a0vs0a0.js +0 -1
- package/dist/chunk-2j2mnzdg.js +0 -2
- package/dist/chunk-462sbp8t.js +0 -171
- package/dist/chunk-54f7t2g3.js +0 -1
- package/dist/chunk-8k26rhcp.js +0 -1
- package/dist/chunk-9cvq8w6k.js +0 -10
- package/dist/chunk-9rj1may5.js +0 -1
- package/dist/chunk-9xzw649r.js +0 -2
- package/dist/chunk-az5eb47t.js +0 -1
- package/dist/chunk-d4z5cp40.js +0 -2
- package/dist/chunk-d71gxct6.js +0 -118
- package/dist/chunk-hxfqcy5r.js +0 -23
- package/dist/chunk-k0n2028d.js +0 -1
- package/dist/chunk-mg4jnq0p.js +0 -1
- package/dist/chunk-mxkezzj9.js +0 -1
- package/dist/chunk-mzxwhhnc.js +0 -1
- package/dist/chunk-tqjrt537.js +0 -1
- package/dist/chunk-xba79vkf.js +0 -1703
- package/dist/chunk-xgp318dt.js +0 -1
- package/dist/chunk-xnbzrh8b.js +0 -140
- package/dist/chunk-y3jbc2xx.js +0 -1
- package/dist/chunk-yc64nfym.js +0 -1
- package/dist/chunk-yqh061d8.js +0 -1
package/dist/chunk-xgp318dt.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Bb as c,Fb as d,Gb as e,Hb as f,Ib as g,Jb as h,Kb as i,Lb as j,Mb as k,Tb as l,Ub as m,Vb as n,Wb as o,Yb as p,Zb as q,_b as r,yb as a,zb as b}from"./chunk-462sbp8t.js";import"./chunk-sca5q3tt.js";import"./chunk-d71gxct6.js";import"./chunk-q265drks.js";import"./chunk-xnbzrh8b.js";import"./chunk-ye4wyq1k.js";import"./chunk-7n7swtwg.js";import"./chunk-8qp8v96d.js";import"./chunk-0zzh482s.js";import"./chunk-adkpwx6c.js";import"./chunk-s20hq62y.js";import"./chunk-2t6b962t.js";import"./chunk-y94239bb.js";import"./chunk-cw2b3383.js";import"./chunk-2j2mnzdg.js";import"./chunk-s6562rsq.js";import"./chunk-hbafhk9y.js";import"./chunk-68sf54n4.js";import"./chunk-sv833k2e.js";import"./chunk-w7n73ag8.js";import"./chunk-a3ewfebr.js";import"./chunk-6kwg4hcv.js";import"./chunk-9xzw649r.js";import"./chunk-hmwz31tc.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};
|
package/dist/chunk-xnbzrh8b.js
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import{Ei as r}from"./chunk-68sf54n4.js";import{aj as d,cj as x,ej as j,ij as u,jj as i}from"./chunk-9xzw649r.js";import{kj as I}from"./chunk-hmwz31tc.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
|
-
`),W=!_.endsWith(`
|
|
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
|
-
`)}
|
|
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
|
-
`)}
|
|
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
|
-
`)}
|
|
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
|
-
DROP TABLE IF EXISTS parts_fts;
|
|
16
|
-
DROP TABLE IF EXISTS parts;
|
|
17
|
-
DROP TABLE IF EXISTS sessions;
|
|
18
|
-
DROP TABLE IF EXISTS projection_state;
|
|
19
|
-
`);_.exec(`
|
|
20
|
-
CREATE TABLE IF NOT EXISTS projection_state (
|
|
21
|
-
project_path TEXT NOT NULL,
|
|
22
|
-
session_id TEXT NOT NULL,
|
|
23
|
-
last_seq INTEGER NOT NULL DEFAULT 0,
|
|
24
|
-
file_size INTEGER NOT NULL DEFAULT 0,
|
|
25
|
-
mtime_ms INTEGER NOT NULL DEFAULT 0,
|
|
26
|
-
PRIMARY KEY (project_path, session_id)
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
CREATE TABLE IF NOT EXISTS sessions (
|
|
30
|
-
project_path TEXT NOT NULL,
|
|
31
|
-
session_id TEXT NOT NULL,
|
|
32
|
-
root_id TEXT,
|
|
33
|
-
parent_id TEXT,
|
|
34
|
-
relation_type TEXT,
|
|
35
|
-
title TEXT,
|
|
36
|
-
agent_type TEXT,
|
|
37
|
-
model TEXT,
|
|
38
|
-
task_status TEXT,
|
|
39
|
-
task_priority TEXT,
|
|
40
|
-
task_kind TEXT,
|
|
41
|
-
task_due_at TEXT,
|
|
42
|
-
archived_at TEXT,
|
|
43
|
-
last_message_time TEXT,
|
|
44
|
-
project_sort_key TEXT NOT NULL,
|
|
45
|
-
session_sort_key TEXT NOT NULL,
|
|
46
|
-
first_message_time TEXT,
|
|
47
|
-
message_count INTEGER NOT NULL DEFAULT 0,
|
|
48
|
-
has_errors INTEGER NOT NULL DEFAULT 0,
|
|
49
|
-
is_subagent INTEGER NOT NULL DEFAULT 0,
|
|
50
|
-
-- 完整 StoredSessionMetadata JSON,读回时直接反序列化,保证与 JSONL 路径一致。
|
|
51
|
-
metadata_json TEXT NOT NULL,
|
|
52
|
-
PRIMARY KEY (project_path, session_id)
|
|
53
|
-
);
|
|
54
|
-
CREATE INDEX IF NOT EXISTS idx_sessions_catalog ON sessions(
|
|
55
|
-
last_message_time DESC,
|
|
56
|
-
project_sort_key ASC,
|
|
57
|
-
session_sort_key ASC
|
|
58
|
-
);
|
|
59
|
-
CREATE INDEX IF NOT EXISTS idx_sessions_archived ON sessions(
|
|
60
|
-
archived_at,
|
|
61
|
-
project_path,
|
|
62
|
-
parent_id
|
|
63
|
-
);
|
|
64
|
-
-- 任务看板过滤/排序:按项目锁定后再按状态、优先级、截止时间收敛。
|
|
65
|
-
CREATE INDEX IF NOT EXISTS idx_sessions_task_board ON sessions(
|
|
66
|
-
project_path,
|
|
67
|
-
task_status,
|
|
68
|
-
task_priority,
|
|
69
|
-
task_due_at
|
|
70
|
-
);
|
|
71
|
-
CREATE INDEX IF NOT EXISTS idx_sessions_task_status ON sessions(
|
|
72
|
-
task_status,
|
|
73
|
-
project_path
|
|
74
|
-
);
|
|
75
|
-
CREATE INDEX IF NOT EXISTS idx_sessions_task_priority ON sessions(
|
|
76
|
-
task_priority,
|
|
77
|
-
task_due_at
|
|
78
|
-
) WHERE task_priority IS NOT NULL;
|
|
79
|
-
CREATE INDEX IF NOT EXISTS idx_sessions_task_due_at ON sessions(
|
|
80
|
-
task_due_at
|
|
81
|
-
) WHERE task_due_at IS NOT NULL;
|
|
82
|
-
|
|
83
|
-
CREATE TABLE IF NOT EXISTS parts (
|
|
84
|
-
project_path TEXT NOT NULL,
|
|
85
|
-
session_id TEXT NOT NULL,
|
|
86
|
-
part_id TEXT NOT NULL,
|
|
87
|
-
message_id TEXT,
|
|
88
|
-
part_type TEXT,
|
|
89
|
-
role TEXT,
|
|
90
|
-
seq INTEGER,
|
|
91
|
-
timestamp TEXT,
|
|
92
|
-
text TEXT,
|
|
93
|
-
PRIMARY KEY (project_path, session_id, part_id)
|
|
94
|
-
);
|
|
95
|
-
CREATE INDEX IF NOT EXISTS idx_parts_session ON parts(project_path, session_id);
|
|
96
|
-
|
|
97
|
-
CREATE VIRTUAL TABLE IF NOT EXISTS parts_fts USING fts5(
|
|
98
|
-
text,
|
|
99
|
-
project_path UNINDEXED,
|
|
100
|
-
session_id UNINDEXED,
|
|
101
|
-
part_id UNINDEXED,
|
|
102
|
-
role UNINDEXED,
|
|
103
|
-
timestamp UNINDEXED,
|
|
104
|
-
seq UNINDEXED,
|
|
105
|
-
tokenize = 'unicode61'
|
|
106
|
-
);
|
|
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
|
-
(project_path, session_id, part_id, message_id, part_type, role, seq, timestamp, text)
|
|
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
|
-
(project_path, session_id, root_id, parent_id, relation_type, title,
|
|
112
|
-
agent_type, model, task_status, task_priority, task_kind, task_due_at,
|
|
113
|
-
archived_at, last_message_time, project_sort_key,
|
|
114
|
-
session_sort_key, first_message_time, message_count, has_errors,
|
|
115
|
-
is_subagent, metadata_json)
|
|
116
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
117
|
-
ON CONFLICT(project_path, session_id) DO UPDATE SET
|
|
118
|
-
root_id=excluded.root_id, parent_id=excluded.parent_id,
|
|
119
|
-
relation_type=excluded.relation_type, title=excluded.title,
|
|
120
|
-
agent_type=excluded.agent_type, model=excluded.model,
|
|
121
|
-
task_status=excluded.task_status, task_priority=excluded.task_priority,
|
|
122
|
-
task_kind=excluded.task_kind, task_due_at=excluded.task_due_at,
|
|
123
|
-
archived_at=excluded.archived_at,
|
|
124
|
-
last_message_time=excluded.last_message_time,
|
|
125
|
-
project_sort_key=excluded.project_sort_key,
|
|
126
|
-
session_sort_key=excluded.session_sort_key,
|
|
127
|
-
first_message_time=excluded.first_message_time, message_count=excluded.message_count,
|
|
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,$,M){_.prepare(`INSERT INTO projection_state
|
|
130
|
-
(project_path, session_id, last_seq, file_size, mtime_ms)
|
|
131
|
-
VALUES (?, ?, ?, ?, ?)
|
|
132
|
-
ON CONFLICT(project_path, session_id) DO UPDATE SET
|
|
133
|
-
last_seq=excluded.last_seq, file_size=excluded.file_size,
|
|
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
|
-
WHERE parts_fts MATCH ? AND project_path = ?
|
|
137
|
-
ORDER BY timestamp DESC LIMIT ?`:`SELECT session_id, role, timestamp, text FROM parts_fts
|
|
138
|
-
WHERE parts_fts MATCH ?
|
|
139
|
-
ORDER BY timestamp DESC LIMIT ?`,Q=_.prepare(H);return R?Q.all(M,R,W):Q.all(M,W)}
|
|
140
|
-
export{w as $d,j_ as ae,u_ as be,y as ce,G as de,J as ee,V_ as fe,O_ as ge,N_ as he,Y_ as ie,f_ as je,s as ke,B_ as le,A_ as me,y_ as ne,z_ as oe,t_ as pe,e_ as qe,_E as re};
|
package/dist/chunk-y3jbc2xx.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ue as a,ve as b,we as c}from"./chunk-t23n4wn0.js";import"./chunk-1b2dkwpv.js";import"./chunk-gqv0vkg9.js";import"./chunk-v508x7cg.js";import"./chunk-ye4wyq1k.js";import"./chunk-85bamng3.js";import"./chunk-m76jmvsf.js";import"./chunk-y94239bb.js";import"./chunk-cw2b3383.js";import"./chunk-2j2mnzdg.js";import"./chunk-s6562rsq.js";import"./chunk-hbafhk9y.js";import"./chunk-68sf54n4.js";import"./chunk-sv833k2e.js";import"./chunk-w7n73ag8.js";import"./chunk-a3ewfebr.js";import"./chunk-1g0d9yw0.js";import"./chunk-6kwg4hcv.js";import"./chunk-9xzw649r.js";import"./chunk-hmwz31tc.js";export{a as validatePermissions,c as validateOutput,b as loadConfiguration};
|
package/dist/chunk-yc64nfym.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{se as a,te as b}from"./chunk-t727txa9.js";import"./chunk-a3ewfebr.js";import"./chunk-hmwz31tc.js";export{a as globalOptions,b as cliConfig};
|
package/dist/chunk-yqh061d8.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$e as m,Pe as a,Qe as b,Re as c,Se as d,Te as e,Ue as f,Ve as g,We as h,Xe as i,Ye as j,Ze as k,_e as l,af as n,bf as o,cf as p,df as q}from"./chunk-gqv0vkg9.js";import"./chunk-v508x7cg.js";import"./chunk-ye4wyq1k.js";import"./chunk-m76jmvsf.js";import"./chunk-y94239bb.js";import"./chunk-cw2b3383.js";import"./chunk-2j2mnzdg.js";import"./chunk-s6562rsq.js";import"./chunk-hbafhk9y.js";import"./chunk-68sf54n4.js";import"./chunk-sv833k2e.js";import"./chunk-w7n73ag8.js";import"./chunk-a3ewfebr.js";import"./chunk-1g0d9yw0.js";import"./chunk-6kwg4hcv.js";import"./chunk-9xzw649r.js";import"./chunk-hmwz31tc.js";export{a as vanillaStore,c as sessionActions,l as getThinkingModeEnabled,b as getState,n as getServiceTier,o as getResponseVerbosity,m as getReasoningEffort,j as getModelById,e as getMessages,k as getMcpServers,i as getCurrentModel,f as getConfig,p as getCommunicationStyle,h as getAllModels,g as ensureStoreInitialized,q as configActions,d as appActions};
|