@x-otto/session 0.0.1-alpha.6 → 0.1.0-alpha.9
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/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/in-memory-session.ts","../src/residency-policy.ts","../src/message-bytes.ts","../src/store.ts","../src/memory-persistence.ts","../src/session-repository.ts","../src/session-write-lease.ts","../src/relational-session-persistence.ts","../src/relational-bridge.ts","../src/replacement-blob-codec.ts","../src/replacement-hydrator.ts","../src/constants.ts","../src/sqlite-session-repository.ts","../src/session-archive-store.ts","../src/remote-persistence.ts"],"mappings":";;;KAIY,YAAA;EACN,IAAA;EAAiB,EAAA;EAAY,QAAA;EAAmB,OAAA,EAAS,CAAA;EAAG,SAAA;AAAA;EAE5D,IAAA;EACA,EAAA;EACA,QAAA;EACA,OAAA;EACA,cAAA;EAJA;;;;;;EAWA,WAAA,GAAc,CAAA;EAOd;;;;;;EAAA,mBAAA;EACA,SAAA;AAAA;;;;;;AA4BN;;EApBM,IAAA;EAAe,EAAA;EAAY,QAAA;EAAmB,SAAA;AAAA;;;;AA8BpD;;;;;;EApBM,IAAA;EACA,EAAA;EACA,QAAA,WAoCJ;EAlCI,KAAA,mBAqCJ;EAnCI,KAAA;EACA,SAAA;AAAA;AAAA,UAGW,cAAA;EACf,OAAA;EACA,QAAA,EAAU,CAAA;AAAA;;;AA0EZ;;;UAlEiB,sBAAA;EACf,WAAA;EAmEA;;;;;AASF;;;;;;;EA/DE,QAAA;EACA,KAAA;EACA,SAAA;EACA,aAAA;EACA,qBAAA;EACA,SAAA;EAqEyB;EAnEzB,OAAA;EAqEA;;;;EAhEA,YAAA;EAqEA;EAnEA,YAAA;EAmEU;AAOZ;;;;;EAnEE,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EAAS,+BAAA;EAAA,cAkBE,YAAA,CAAA;EAAA,cAGA,YAAA,CAAA;EAAA,UAIJ,SAAA,CAAU,QAAA,EAAU,eAAA,CAAgB,CAAA;EfPxC;;;;;;EeiBT,cAAA,CAAe,KAAA,WAAgB,OAAA;AAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/in-memory-session.ts","../src/residency-policy.ts","../src/message-bytes.ts","../src/store.ts","../src/memory-persistence.ts","../src/session-repository.ts","../src/session-write-lease.ts","../src/relational-session-persistence.ts","../src/relational-bridge.ts","../src/replacement-blob-codec.ts","../src/replacement-hydrator.ts","../src/constants.ts","../src/sqlite-session-repository.ts","../src/session-archive-store.ts","../src/remote-persistence.ts"],"mappings":";;;KAIY,YAAA;EACN,IAAA;EAAiB,EAAA;EAAY,QAAA;EAAmB,OAAA,EAAS,CAAA;EAAG,SAAA;AAAA;EAE5D,IAAA;EACA,EAAA;EACA,QAAA;EACA,OAAA;EACA,cAAA;EAJA;;;;;;EAWA,WAAA,GAAc,CAAA;EAOd;;;;;;EAAA,mBAAA;EACA,SAAA;AAAA;;;;;;AA4BN;;EApBM,IAAA;EAAe,EAAA;EAAY,QAAA;EAAmB,SAAA;AAAA;;;;AA8BpD;;;;;;EApBM,IAAA;EACA,EAAA;EACA,QAAA,WAoCJ;EAlCI,KAAA,mBAqCJ;EAnCI,KAAA;EACA,SAAA;AAAA;AAAA,UAGW,cAAA;EACf,OAAA;EACA,QAAA,EAAU,CAAA;AAAA;;;AA0EZ;;;UAlEiB,sBAAA;EACf,WAAA;EAmEA;;;;;AASF;;;;;;;EA/DE,QAAA;EACA,KAAA;EACA,SAAA;EACA,aAAA;EACA,qBAAA;EACA,SAAA;EAqEyB;EAnEzB,OAAA;EAqEA;;;;EAhEA,YAAA;EAqEA;EAnEA,YAAA;EAmEU;AAOZ;;;;;EAnEE,UAAA;EAuEA;;;;;EAjEA,qBAAA;EA+E+B;;;;EA1E/B,eAAA;EA6EA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AA,UAIJ,SAAA,CAAU,QAAA,EAAU,eAAA,CAAgB,CAAA;EfPxC;;;;;;EeiBT,cAAA,CAAe,KAAA,WAAgB,OAAA;AAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{currentHostname as e,decodeLeaseToken as t,encodeLeaseToken as n,isProcessAlive as r,normalizeEnv as i}from"@x-otto/env";import{MemoryPersistenceBase as a,RemotePersistence as o,RemotePersistenceError as s,RemoteSnapshotConflictError as c,acquireDb as l,paginate as u,releaseDb as d}from"@x-otto/persistence";import{createHash as f,randomUUID as p}from"node:crypto";import{closeSync as m,createWriteStream as h,existsSync as g,mkdirSync as _,openSync as ee,readFileSync as v,renameSync as y,rmSync as te,statSync as b,unlinkSync as x,utimesSync as S,writeSync as ne}from"node:fs";import{dirname as C,join as re,resolve as w}from"node:path";import{createGzip as T,gunzipSync as E}from"node:zlib";import{readFile as ie}from"node:fs/promises";const D={derived:0,ai:1,custom:2};function O(e){if(typeof e!=`object`||!e)return 0;let t=e,n=0,r=t.tool_calls;if(Array.isArray(r))for(let e of r){if(typeof e!=`object`||!e)continue;let t=e.function;t&&typeof t==`object`&&typeof t.arguments==`string`&&(n+=t.arguments.length)}let i=t.content;if(typeof i==`string`)return n+i.length;if(!Array.isArray(i))return n;for(let e of i){if(typeof e!=`object`||!e)continue;let t=e;typeof t.text==`string`&&(n+=t.text.length);let r=t.source;r&&typeof r==`object`&&typeof r.data==`string`&&(n+=r.data.length),typeof t.data==`string`&&(n+=t.data.length);let i=t.image_url;i&&typeof i==`object`&&typeof i.url==`string`&&(n+=i.url.length),t.type===`tool_call`&&typeof t.arguments==`object`&&t.arguments!=null&&(n+=JSON.stringify(t.arguments).length),t.type===`tool_use`&&t.input!=null&&(n+=JSON.stringify(t.input).length)}return n}const ae=i(process.env.OTTO_SESSION_IDLE_TIMEOUT_MS,1800*1e3),oe=i(process.env.OTTO_SESSION_MAX,50),k=i(process.env.OTTO_SESSION_PAGE_SIZE,20),A=i(process.env.OTTO_SESSION_SNAPSHOT_VERSION,1),j=[`message`,`compaction`,`clear`,`compaction-lock`];function M(e){return j.includes(e)}const N={editedFiles:50,subagents:100,turnSummaries:200,drafts:50,inputHistory:100};var P=class{constructor(e){this.host=e}capStoredHistory(e,t){let n=this.host.getEntries(),r=0;for(let e of n)e.type===`message`&&r++;if(r<=e)return{capped:!1,removedCount:0,boundaryLimited:!1,activeOversized:!1};let i=r-e,{removed:a,boundaryLimited:o}=this.removeOldestMessages(i,t);return this.host.setMessageCount(r-a),{capped:a>0,removedCount:a,boundaryLimited:o,activeOversized:this.host.getMessageCount()>e}}wouldTrimTouchActiveContext(e){let t=this.host.getMessageCount();if(t<=e)return!1;let n=t-e,r=this.host.getActiveCompactionId();if(r===void 0)return!0;let i=0;for(let e of this.host.getEntries()){if(e.id===r)break;e.type===`message`&&i++}return i<n}wouldByteTrimTouchActiveContext(e){if(e<=0||this.host.getEstimatedBytes()<=e)return!1;let t=this.host.getActiveCompactionId();if(t===void 0)return!0;let n=0;for(let e of this.host.getEntries()){if(e.id===t)break;e.type===`message`&&(n+=O(e.message))}return this.host.getEstimatedBytes()-n>e}capStoredHistoryByBytes(e,t){let n=this.host.getEntries();if(e<=0||this.host.getEstimatedBytes()<=e)return{capped:!1,removedCount:0,boundaryLimited:!1,activeOversized:!1};let r=0;for(let e of n)e.type===`message`&&r++;let i=this.host.getEstimatedBytes(),a=0;for(let t of n){if(i<=e||a>=r-1)break;t.type===`message`&&(i-=O(t.message),a++)}if(a===0)return{capped:!1,removedCount:0,boundaryLimited:!1,activeOversized:!1};let{removed:o,boundaryLimited:s}=this.removeOldestMessages(a,t);return this.host.setMessageCount(r-o),{capped:o>0,removedCount:o,boundaryLimited:s,activeOversized:this.host.getEstimatedBytes()>e}}verifyEstimatedContentBytes(){let e=0;for(let t of this.host.getEntries())if(t.type===`message`)e+=O(t.message);else if(t.type===`compaction`&&t.replacement)for(let n of t.replacement)e+=O(n);return{counter:this.host.getEstimatedBytes(),recomputed:e,drift:e-this.host.getEstimatedBytes()}}removeOldestMessages(e,t){let n=this.host.getEntries(),r=this.host.getEntryMap(),i=this.host.getActiveCompactionId(),a=!1,o=0,s=0;for(;s<n.length&&o<e;){let e=n[s];if(i!==void 0&&e.id===i){a=!0;break}e.type===`message`?(this.host.setEstimatedBytes(this.host.getEstimatedBytes()-O(e.message)),r.delete(e.id),n.splice(s,1),o++):s++}if(t)for(;s<n.length;){let e=n[s];if(i!==void 0&&e.id===i){a=!0;break}if(e.type!==`message`){s++;continue}if(t(e.message))break;this.host.setEstimatedBytes(this.host.getEstimatedBytes()-O(e.message)),r.delete(e.id),n.splice(s,1),o++}return this.host.getEstimatedBytes()<0&&this.host.setEstimatedBytes(0),{removed:o,boundaryLimited:a}}};const se={now:()=>Date.now()},ce={uuid:()=>crypto.randomUUID()};var F=class{sessionEntries=[];entryMap=new Map;clock;idGen;_estimatedContentBytes=0;get estimatedContentBytes(){return this._estimatedContentBytes}get messageCount(){return this.meta.messageCount}verifyEstimatedContentBytes(){return this.residencyPolicy.verifyEstimatedContentBytes()}meta;panelState={};residencyPolicy;constructor(e,t,n,r){this.id=e,this.clock=r?.clock??se,this.idGen=r?.idGen??ce;let i=this.clock.now();this.meta={createdAt:i,lastActiveAt:i,messageCount:0,compactionCount:0,parentSessionId:t,forkPoint:n,tags:[]},this.residencyPolicy=new P(this.createResidencyHost())}createResidencyHost(){return{getEntries:()=>this.sessionEntries,getEntryMap:()=>this.entryMap,getEstimatedBytes:()=>this._estimatedContentBytes,setEstimatedBytes:e=>{this._estimatedContentBytes=e},getMessageCount:()=>this.meta.messageCount,setMessageCount:e=>{this.meta.messageCount=e},getActiveCompactionId:()=>this.findActiveCompaction()?.id}}_leafId=void 0;get leafId(){return this._leafId}markActivity(){this.meta.lastActiveAt=this.clock.now()}append(e){let t={type:`message`,id:this.idGen.uuid(),parentId:this._leafId,message:e,timestamp:this.clock.now()};this._leafId=t.id,this.sessionEntries.push(t),this.entryMap.set(t.id,t),this.meta.messageCount++,this.markActivity(),this._estimatedContentBytes+=O(e)}removeLast(){if(!this._leafId)return;let e=this.entryMap.get(this._leafId);if(!e||e.type!==`message`)return;let t=this.sessionEntries.lastIndexOf(e);t!==-1&&(this.sessionEntries.splice(t,1),this.entryMap.delete(e.id),this._leafId=e.parentId,this.meta.messageCount=Math.max(0,this.meta.messageCount-1),this._estimatedContentBytes-=O(e.message))}compact(e,t){let n=this.getBranchMessageEntries();if(t<=0||t>n.length)return;let r={type:`compaction`,id:this.idGen.uuid(),parentId:this._leafId,summary:e,compactedCount:t,timestamp:this.clock.now()};this.sessionEntries.push(r),this.entryMap.set(r.id,r),this.meta.compactionCount++,this.markActivity(),this._leafId=r.id}recordCompaction(e,t){let n=this.findActiveCompaction(),r={type:`compaction`,id:this.idGen.uuid(),parentId:this._leafId,summary:e,compactedCount:t.length,replacement:[...t],timestamp:this.clock.now()};for(let e of t)this._estimatedContentBytes+=O(e);this.sessionEntries.push(r),this.entryMap.set(r.id,r),this.meta.compactionCount++,this.markActivity(),this._leafId=r.id,n&&n.replacement!=null&&this.replacementStripEligibility?.(n.id)===!0&&this.stripReplacementInPlace(n.id)}replacementStripEligibility;setReplacementStripEligibility(e){this.replacementStripEligibility=e}findActiveCompaction(){return this._leafId?this.findActiveCompactionFrom(this._leafId):void 0}stripReplacementInPlace(e){let t=this.entryMap.get(e);if(!t||t.type!==`compaction`)return;let n=t;if(n.replacement==null)return;for(let e of n.replacement)this._estimatedContentBytes-=O(e);this._estimatedContentBytes<0&&(this._estimatedContentBytes=0);let{replacement:r,...i}=n,a={...i,replacementStripped:!0};this.entryMap.set(e,a);let o=this.sessionEntries.findIndex(t=>t.id===e);o>=0&&(this.sessionEntries[o]=a)}clearContext(e){let t={type:`clear`,id:this.idGen.uuid(),parentId:this._leafId,timestamp:this.clock.now()};this.sessionEntries.push(t),this.entryMap.set(t.id,t),this.markActivity(),this._leafId=t.id,e?.purge===!0&&this.purgeBeforeBoundary(t.id)}appendCompactionLock(e,t){let n={type:`compaction-lock`,id:this.idGen.uuid(),parentId:this._leafId,phase:e,token:t,timestamp:this.clock.now()};this.sessionEntries.push(n),this.entryMap.set(n.id,n),this._leafId=n.id}compactionLockState(){let e=this.walkBranch();for(let t=e.length-1;t>=0;t--){let n=e[t];if(n&&n.type===`compaction-lock`)return{phase:n.phase,token:n.token,timestamp:n.timestamp}}}purgeClearedHistory(){let e;for(let t=this.sessionEntries.length-1;t>=0;t--)if(this.sessionEntries[t].type===`clear`){e=this.sessionEntries[t].id;break}return e?this.purgeBeforeBoundary(e):{removedCount:0,strippedReplacements:0}}purgeBeforeBoundary(e){let t=this.sessionEntries.findIndex(t=>t.id===e);if(t<0)return{removedCount:0,strippedReplacements:0};let n=0,r=0,i=0,a=t;for(;r<a;){let e=this.sessionEntries[r];e.type===`message`?(this._estimatedContentBytes-=O(e.message),this.entryMap.delete(e.id),this.sessionEntries.splice(r,1),a--,i++):(e.type===`compaction`&&e.replacement!=null&&(this.stripReplacementInPlace(e.id),n++),r++)}return this._estimatedContentBytes<0&&(this._estimatedContentBytes=0),this.meta.messageCount-=i,{removedCount:i,strippedReplacements:n}}branch(e){if(!this.entryMap.has(e))throw Error(`Entry "${e}" not found in session "${this.id}"`);let t=this.findActiveCompactionFrom(e);if(t&&t.replacementStripped)throw Error(`branch: target chain's active compaction boundary "${t.id}" has a stripped replacement (RFC-160); hydrate it via loadEntriesByIds before branching`);this._leafId=e,this.markActivity()}findActiveCompactionFrom(e){let t=new Set,n=this.entryMap.get(e);for(;n&&!t.has(n.id);){if(t.add(n.id),n.type===`compaction`)return n;if(n.type===`clear`)return;n=n.parentId?this.entryMap.get(n.parentId):void 0}}entries(){return this.sessionEntries}branchEntries(){return this.walkBranch()}buildContext(){let e=this.walkBranch(),t=this.lastBoundaryIndex(e),n=e.slice(t+1).filter(e=>e.type===`message`).map(e=>e.message);if(t===-1)return{messages:n};let r=e[t];if(r.type===`clear`)return{messages:n};let i=r;return{summary:i.summary,messages:i.replacement?[...i.replacement,...n]:n}}messages(){return this.walkBranch().filter(e=>e.type===`message`).map(e=>e.message)}visibleMessages(){let e=this.walkBranch(),t=-1;for(let n=e.length-1;n>=0;n--)if(e[n]?.type===`clear`){t=n;break}return e.slice(t+1).filter(e=>e.type===`message`).map(e=>e.message)}metadata(){return{...this.meta,tags:[...this.meta.tags],...this.meta.config?{config:structuredClone(this.meta.config)}:{}}}setTitle(e,t){let n=this.meta.titleSource==null?-1:D[this.meta.titleSource];return D[t]<n?!1:(this.meta.title=e,this.meta.titleSource=t,!0)}setSdkVersion(e){this.meta.sdkVersion=e}setArchived(e){this.meta.archived=e}setPinned(e,t){this.meta.pinned=e,this.meta.pinGroup=e?t:void 0}touchIfActivity(e){e?.touch!==!1&&this.markActivity()}getTodoList(){return this.panelState.todoList}setTodoList(e,t){this.panelState.todoList=[...e],this.touchIfActivity(t)}getEditedFiles(){return this.panelState.editedFiles}setEditedFiles(e,t){this.panelState.editedFiles=e.slice(0,N.editedFiles),this.touchIfActivity(t)}getInputHistory(){return this.meta.config?.inputHistory}setInputHistory(e){if(e.length===0){this.meta.config?.inputHistory!==void 0&&delete this.meta.config.inputHistory;return}this.meta.config||(this.meta.config={}),this.meta.config.inputHistory=e.slice(-N.inputHistory)}getSubagents(){return this.panelState.subagents}setSubagents(e,t){this.panelState.subagents=e.slice(0,N.subagents),this.touchIfActivity(t)}getTurnSummaries(){return this.panelState.turnSummaries}setTurnSummaries(e,t){this.panelState.turnSummaries=e.slice(-N.turnSummaries),this.touchIfActivity(t)}getTurnCount(){return this.meta.config?.turnCount}setTurnCount(e){this.meta.config||(this.meta.config={}),this.meta.config.turnCount=e}getDrafts(){return this.panelState.drafts}setDrafts(e,t){this.panelState.drafts=e.slice(0,N.drafts),this.touchIfActivity(t)}capStoredHistory(e,t){return this.residencyPolicy.capStoredHistory(e,t)}wouldTrimTouchActiveContext(e){return this.residencyPolicy.wouldTrimTouchActiveContext(e)}wouldByteTrimTouchActiveContext(e){return this.residencyPolicy.wouldByteTrimTouchActiveContext(e)}capStoredHistoryByBytes(e,t){return this.residencyPolicy.capStoredHistoryByBytes(e,t)}setTags(e){this.meta.tags=[...e]}addTag(e){this.meta.tags.includes(e)||this.meta.tags.push(e)}restoreEntries(e,t,n){this.sessionEntries.length=0,this.entryMap.clear();let r=0;for(let t of e)if(this.sessionEntries.push(t),this.entryMap.set(t.id,t),t.type===`message`)r+=O(t.message);else if(t.type===`compaction`&&t.replacement)for(let e of t.replacement)r+=O(e);this._estimatedContentBytes=r,Object.assign(this.meta,t),this._leafId=n&&this.entryMap.has(n)?n:e.length>0?e[e.length-1]?.id:void 0}toSnapshot(){return{entries:[...this.sessionEntries],metadata:this.metadata(),leafId:this._leafId}}walkBranch(){if(!this._leafId)return[];let e=[],t=new Set,n=this.entryMap.get(this._leafId);for(;n&&!t.has(n.id);)t.add(n.id),e.push(n),n=n.parentId?this.entryMap.get(n.parentId):void 0;return e.reverse(),e}getBranchMessageEntries(){let e=this.walkBranch(),t=this.lastBoundaryIndex(e);return e.slice(t+1).filter(e=>e.type===`message`)}lastBoundaryIndex(e){for(let t=e.length-1;t>=0;t--){let n=e[t]?.type;if(n===`compaction`||n===`clear`)return t}return-1}},I=class{sessions=new Map;ports;constructor(e){this.ports=e}newId(){return this.ports?.idGen?.uuid()??crypto.randomUUID()}async createSession(e=this.newId()){let t=new F(e,void 0,void 0,this.ports);return this.sessions.set(e,t),t}getSession(e){return this.sessions.get(e)}listSessions(){return Array.from(this.sessions.values())}listSessionsPaginated(e){let{page:t,sortBy:n=`lastActiveAt`,order:r=`desc`}=e,i=e.pageSize??50,a=Array.from(this.sessions.values());return a.sort((e,t)=>{let i=e.metadata(),a=t.metadata(),o=n===`createdAt`?i.createdAt:i.lastActiveAt,s=n===`createdAt`?a.createdAt:a.lastActiveAt;return r===`asc`?o-s:s-o}),u(a,{page:t,pageSize:i})}async deleteSession(e){return this.sessions.delete(e)}async forkSession(e,t=this.newId()){let n=this.sessions.get(e);if(!n)return;let r=n.toSnapshot(),i=this.ports?.clock?.now()??Date.now(),a=new F(t,e,r.entries.length,this.ports);return a.restoreEntries([...r.entries],{...r.metadata,createdAt:i,lastActiveAt:i,parentSessionId:e,forkPoint:r.entries.length,tags:[...r.metadata.tags,`fork`]},r.leafId),this.sessions.set(t,a),a}};function le(e){return new I(e)}var ue=class extends a{constructor(){super({defaultPageSize:k,defaultSortBy:`lastActiveAt`})}extractId(e){return e.id}getSortValue(e,t){return t===`createdAt`?e.metadata.createdAt:e.metadata.lastActiveAt}async listRecentMeta(e){return this.entries().filter(([,e])=>!e.metadata.archived).sort(([,e],[,t])=>t.metadata.lastActiveAt-e.metadata.lastActiveAt).slice(0,e).map(([e])=>e)}};function L(e){return`sha256:${f(`sha256`).update(e,`utf-8`).digest(`hex`)}`}async function R(e,t,n){if(e!==`compaction`)return t;let r=t.replacement;if(!Array.isArray(r))return t;let i=r.map(e=>JSON.stringify(e)),a=i.map(L);await n.putBlobs(i.map((e,t)=>({hash:a[t],content:e})));let{replacement:o,...s}=t;return{...s,replacementHashes:a}}async function z(e,t,n){if(e!==`compaction`)return t;let r=t.replacementHashes;if(!Array.isArray(r)||r.length===0){if(Array.isArray(r)){let{replacementHashes:e,...n}=t;return{...n,replacement:[]}}return t}let i=await n.getBlobs(r),a=r.map(e=>{let t=i.get(e);if(t==null)throw Error(`decodeReplacementFromBlobs: blob ${e} missing from message_blobs (corrupted import/partial backup?); refusing to assemble a lossy replacement (RFC-160 D7)`);return JSON.parse(t)}),{replacementHashes:o,...s}=t;return{...s,replacement:a}}function B(e,t){let n=e.metadata;return{id:e.id,workspaceKey:t,...n.title==null?{}:{title:n.title},...n.titleSource==null?{}:{titleSource:n.titleSource},...n.parentSessionId==null?{}:{parentSessionId:n.parentSessionId},...n.forkPoint==null?{}:{forkPoint:n.forkPoint},...e.leafId==null?{}:{leafId:e.leafId},tags:n.tags??[],...n.config==null?{}:{config:n.config},createdAt:n.createdAt,lastActiveAt:n.lastActiveAt,...n.archived==null?{}:{archived:n.archived},...n.pinned==null?{}:{pinned:n.pinned},...n.pinGroup==null?{}:{pinGroup:n.pinGroup}}}function V(e){let{type:t,id:n,parentId:r,timestamp:i,...a}=e;return{entryId:n,...r==null?{}:{parentId:r},type:t,data:a,createdAt:i}}function H(e){return{type:e.type,id:e.entryId,...e.parentId==null?{}:{parentId:e.parentId},timestamp:e.createdAt,...e.data}}async function de(e,t,n){await n.createSession(B(e,t));for(let t of e.entries)await n.appendEntry(e.id,V(t));await n.touchSession({id:e.id,leafId:e.leafId,lastActiveAt:e.metadata.lastActiveAt,title:e.metadata.title,titleSource:e.metadata.titleSource,config:e.metadata.config,archived:e.metadata.archived,pinned:e.metadata.pinned,pinGroup:e.metadata.pinGroup})}async function U(e,t,n){let r=await t.getSession(e);if(!r)return null;let i,a=!1;n?.maxEntries==null?i=(await t.loadEntries(e)).map(e=>H(e)):await t.getEntryCount(e)>n.maxEntries?(i=(await t.loadTailEntries(e,n.maxEntries)).map(e=>H(e)),a=!0,n.canStartHistory&&(i=pe(i,n.canStartHistory))):i=(await t.loadEntries(e)).map(e=>H(e)),n?.stripInactiveReplacements?(i=fe(i,r.leafId??void 0),i=await W(i,t,{onlyUnstripped:!0})):i=await W(i,t,{onlyUnstripped:!1});let o=a?await t.countEntriesByType(e,`message`):i.filter(e=>e.type===`message`).length,s=a?await t.countEntriesByType(e,`compaction`):i.filter(e=>e.type===`compaction`).length,c={createdAt:r.createdAt,lastActiveAt:r.lastActiveAt,messageCount:o,compactionCount:s,tags:r.tags,...r.title==null?{}:{title:r.title},...r.titleSource==null?{}:{titleSource:r.titleSource},...r.parentSessionId==null?{}:{parentSessionId:r.parentSessionId},...r.forkPoint==null?{}:{forkPoint:r.forkPoint},...r.config==null?{}:{config:r.config},...r.archived==null?{}:{archived:r.archived},...r.pinned==null?{}:{pinned:r.pinned},...r.pinGroup==null?{}:{pinGroup:r.pinGroup}};return{version:A,id:e,entries:i,metadata:c,...r.leafId==null?{}:{leafId:r.leafId}}}async function W(e,t,n){let r=[];for(let i of e){let e=i;if(e.type!==`compaction`||e.replacementHashes==null){r.push(i);continue}if(n.onlyUnstripped&&e.replacementStripped){let{replacementHashes:t,...n}=e;r.push(n);continue}let{replacementStripped:a,...o}=await z(`compaction`,e,t);r.push(o)}return r}function fe(e,t){let n=new Map;for(let t of e)n.set(t.id,t);let r,i=new Set,a=t?n.get(t):void 0;for(;a&&!i.has(a.id);){if(i.add(a.id),a.type===`compaction`){r=a.id;break}if(a.type===`clear`)break;a=a.parentId?n.get(a.parentId):void 0}let o=-1;for(let t=e.length-1;t>=0;t--)if(e[t].type===`compaction`){o=t;break}return e.map((e,t)=>{if(e.type!==`compaction`||e.id===r||t===o)return e;let n=e;if(n.replacement!=null){let{replacement:e,...t}=n;return{...t,replacementStripped:!0}}return n.replacementHashes==null?e:{...n,replacementStripped:!0}})}function pe(e,t){let n=0;for(;n<e.length;){let r=e[n];if(r.type!==`message`||t(r.message))break;n++}return n>0?e.slice(n):e}function me(e){return typeof e?.hydrateReplacements==`function`}function he(e){return e.some(e=>e.type===`compaction`&&e.replacementStripped)}async function G(e,t,n){let r=t.filter(e=>e.type===`compaction`&&e.replacementStripped).map(e=>e.id);if(r.length===0)return[...t];let i=await n.loadEntriesByIds(e,r),a=new Map;for(let e of i)a.set(e.entryId,e.data);let o=[];for(let r of t){if(r.type!==`compaction`||!r.replacementStripped){o.push(r);continue}let t=a.get(r.id);if(t&&t.replacementHashes!=null&&(t=await z(`compaction`,t,n)),!t||t.replacement==null)throw Error(`hydrateStrippedReplacements: authoritative row for compaction "${r.id}" in session "${e}" is missing or has no replacement (corrupted import?); refusing to continue with stripped state (RFC-160 rule 3)`);let{replacementStripped:i,...s}=r;o.push({...s,replacement:t.replacement})}return o}var K=class extends Error{constructor(e){super(`Session write lease denied for ${e}: another live process owns the write lease (this process is read-only for the session; refusing to save — RFC-159 D3)`),this.sessionId=e,this.name=`SessionWriteLeaseDeniedError`}};const ge={uuid:()=>p()};function _e(i){let a=i.staleMs??6e4,o=i.renewEveryMs??1e4,s=new Map,c=!1,l=e(),u=e=>re(i.lockDir,`${e}.lock`),d=e=>{try{return t(v(u(e),`utf-8`).trim())}catch{return null}},f=e=>d(e)?.token??null,h=(e,t)=>{try{_(i.lockDir,{recursive:!0});let r=ee(u(e),`wx`);try{ne(r,n(t,process.pid,l))}finally{m(r)}return!0}catch(e){if(e.code!==`EEXIST`)throw e;return!1}},g=e=>e.pid===void 0||e.host===void 0||e.host!==l?!1:!r(e.pid),C=e=>e.pid===void 0||e.host===void 0||e.host!==l?!1:r(e.pid),w=(e,t)=>{let n=setInterval(()=>{if(f(e)!==t){T(e);return}try{let t=new Date;S(u(e),t,t)}catch{T(e)}},o);n.unref(),s.set(e,{token:t,timer:n})},T=e=>{let t=s.get(e);t&&(clearInterval(t.timer),s.delete(e))},E={acquire(e){if(c)return!1;let t=s.get(e);if(t){if(f(e)===t.token)return!0;T(e)}let n=(i.idGen??ge).uuid();if(h(e,n))return w(e,n),!0;let r=d(e),o;try{o=b(u(e)).mtimeMs}catch{return h(e,n)?(w(e,n),!0):!1}if(r!==null&&C(r)||!(r!==null&&g(r))&&Date.now()-o<=a)return!1;let l=`${u(e)}.stale-${p()}`;try{y(u(e),l),te(l,{force:!0})}catch{return!1}return h(e,n)?(w(e,n),!0):!1},release(e){let t=s.get(e);if(t){if(f(e)===t.token)try{x(u(e))}catch{}T(e)}},releaseAll(){for(let e of[...s.keys()])E.release(e)},isOwner(e){if(c)return!1;let t=s.get(e);return t!=null&&f(e)===t.token},peekLockedByOther(e){if(c)return!1;let t=s.get(e);if(t!=null&&f(e)===t.token)return!1;let n;try{n=b(u(e)).mtimeMs}catch{return!1}return Date.now()-n<=a},inspect(e){let t=d(e);if(t===null)return{locked:!1};let n;try{n=Date.now()-b(u(e)).mtimeMs}catch{return{locked:!1}}let i=t.pid!==void 0&&t.host!==void 0&&t.host===l?r(t.pid):void 0;return{locked:!0,pid:t.pid,hostname:t.host,alive:i,mtimeAgoMs:n}},forceRelease(e){try{x(u(e))}catch{}T(e)},close(){c=!0,E.releaseAll()}};return i.installExitHook!==!1&&process.on(`exit`,()=>E.releaseAll()),E}function q(){return{acquire:()=>!0,release:()=>{},releaseAll:()=>{},isOwner:()=>!0,peekLockedByOther:()=>!1,inspect:()=>({locked:!1}),forceRelease:()=>{},close:()=>{}}}function J(e){return typeof e?.archiveSession==`function`&&typeof e?.restoreArchivedSession==`function`}const ve={warn:()=>{}};var ye=class{repo;resolveWorkspaceKey;defaultPageSize;logger;persisted=new Map;maxLoadEntries;canStartHistory;writeLease;stripInactiveReplacements;constructor(e){this.repo=e.repo;let t=e.workspaceKey;this.resolveWorkspaceKey=typeof t==`function`?()=>t()||`default`:()=>t||`default`,this.defaultPageSize=e.defaultPageSize??20,this.logger=e.logger??ve,this.maxLoadEntries=e.maxLoadEntries,this.canStartHistory=e.canStartHistory,this.writeLease=e.writeLease,this.stripInactiveReplacements=e.stripInactiveReplacements??!1}assertWritable(e){if(this.writeLease&&!this.writeLease.acquire(e))throw this.logger.warn({sessionId:e},`archive/restore rejected: session write lease held by another live process (read-only; RFC-159 D3)`),new K(e)}async archiveSession(e){if(!J(this.repo))throw Error(`archiveSession is not supported by this repository`);return this.assertWritable(e),this.repo.archiveSession(e)}async restoreArchivedSession(e){return J(this.repo)?(this.assertWritable(e),this.repo.restoreArchivedSession(e)):0}async save(e){if(this.writeLease&&!this.writeLease.acquire(e.id))throw this.logger.warn({sessionId:e.id},`save rejected: session write lease held by another live process (read-only; RFC-159 D3)`),new K(e.id);await this.repo.createSession(B(e,this.resolveWorkspaceKey()));let t=this.persisted.get(e.id),n=0;if(t!=null){let r=e.entries.findIndex(e=>e.id===t);n=r>=0?r+1:0}if(n===0){let n=await this.repo.getEntryCount(e.id);n>0&&t==null&&this.logger.warn({sessionId:e.id,dbCount:n},`Session has persisted entries but no local cursor (restart or concurrent writer); reconciling via full idempotent append (append-forever, no loss)`)}for(let t=n;t<e.entries.length;t++){let n=V(e.entries[t]),r=await R(n.type,n.data,this.repo);await this.repo.appendEntry(e.id,{...n,data:r})}let{leafPersisted:r}=await this.repo.touchSession({id:e.id,leafId:e.leafId,lastActiveAt:e.metadata.lastActiveAt,title:e.metadata.title,titleSource:e.metadata.titleSource,config:e.metadata.config,archived:e.metadata.archived,pinned:e.metadata.pinned,pinGroup:e.metadata.pinGroup});!r&&e.leafId!=null&&this.logger.warn({sessionId:e.id,rejectedLeafId:e.leafId},`touchSession: leafId not found among session entries (rejected to avoid dangling leaf; likely concurrent writer race); existing leaf_id preserved`);let i=e.entries[e.entries.length-1];i?this.persisted.set(e.id,i.id):this.persisted.delete(e.id)}async load(e){let t=await this.repo.getSession(e);if(!t)return null;let n=this.resolveWorkspaceKey(),r=t.workspaceKey||`default`;if(r!==n)return this.logger.warn({sessionId:e,sessionWorkspaceKey:r,expectedWorkspaceKey:n},`RelationalSessionPersistence.load: session belongs to a different workspace, refusing cross-workspace restore`),null;let i=await U(e,this.repo,{...this.maxLoadEntries==null?{}:{maxEntries:this.maxLoadEntries},...this.canStartHistory?{canStartHistory:this.canStartHistory}:{},...this.stripInactiveReplacements?{stripInactiveReplacements:!0}:{}}),a=i?.entries[i.entries.length-1];return a&&this.persisted.set(e,a.id),i}getPersistedCursor(e){return this.persisted.get(e)}async hydrateReplacements(e,t){return G(e,t,this.repo)}async delete(e){let t=await this.repo.deleteSession(e);return this.persisted.delete(e),this.writeLease?.release(e),t}async list(){return(await this.repo.listSessions(this.resolveWorkspaceKey())).map(e=>e.id)}async listRecentMeta(e){return this.repo.listRecentSessionIds(this.resolveWorkspaceKey(),e)}async listPaginated(e){let t=await this.repo.listSessions(this.resolveWorkspaceKey()),n=e.sortBy===`createdAt`?[...t].sort((e,t)=>t.createdAt-e.createdAt):t,r=e.order===`asc`?[...n].reverse():n,i=e.pageSize??this.defaultPageSize;return u(r.map(e=>e.id),{page:e.page,pageSize:i})}},Y=class{archiveDir;ephemeral;deps;constructor(e){this.archiveDir=e.archiveDir,this.ephemeral=e.ephemeral??!1,this.deps=e}archivePath(e){return w(this.archiveDir,`${e}.jsonl.gz`)}async archiveSession(e){if(this.ephemeral)return this.deps.setArchived(e,!0),`:memory:/${e}.jsonl.gz`;let t=this.archivePath(e);g(this.archiveDir)||_(this.archiveDir,{recursive:!0});let n=await this.deps.loadEntries(e),r=T(),i=h(t);r.pipe(i);let a=new TextEncoder;for(let e of n)r.write(a.encode(JSON.stringify(e)+`
|
|
2
|
-
`));return r.end(),await new Promise((e,t)=>{i.on(`finish`,e),i.on(`error`,t)}),this.deps.setArchived(e,!0),t}async restoreArchivedSession(e){let t=this.archivePath(e);if(!
|
|
1
|
+
import{currentHostname as e,decodeLeaseToken as t,encodeLeaseToken as n,isProcessAlive as r,normalizeEnv as i}from"@x-otto/env";import{MemoryPersistenceBase as a,RemotePersistence as o,RemotePersistenceError as s,RemoteSnapshotConflictError as c,acquireDb as l,paginate as u,releaseDb as d}from"@x-otto/persistence";import{createHash as f,randomUUID as p}from"node:crypto";import{closeSync as ee,createWriteStream as m,existsSync as h,mkdirSync as g,openSync as te,readFileSync as _,renameSync as ne,rmSync as re,statSync as v,unlinkSync as y,utimesSync as b,writeFileSync as ie,writeSync as ae}from"node:fs";import{dirname as x,join as S,resolve as C}from"node:path";import{createGzip as w,gunzipSync as T}from"node:zlib";import{readFile as E}from"node:fs/promises";const D={derived:0,ai:1,custom:2};function O(e){if(typeof e!=`object`||!e)return 0;let t=e,n=0,r=t.tool_calls;if(Array.isArray(r))for(let e of r){if(typeof e!=`object`||!e)continue;let t=e.function;t&&typeof t==`object`&&typeof t.arguments==`string`&&(n+=t.arguments.length)}let i=t.content;if(typeof i==`string`)return n+i.length;if(!Array.isArray(i))return n;for(let e of i){if(typeof e!=`object`||!e)continue;let t=e;typeof t.text==`string`&&(n+=t.text.length);let r=t.source;r&&typeof r==`object`&&typeof r.data==`string`&&(n+=r.data.length),typeof t.data==`string`&&(n+=t.data.length);let i=t.image_url;i&&typeof i==`object`&&typeof i.url==`string`&&(n+=i.url.length),t.type===`tool_call`&&typeof t.arguments==`object`&&t.arguments!=null&&(n+=JSON.stringify(t.arguments).length),t.type===`tool_use`&&t.input!=null&&(n+=JSON.stringify(t.input).length)}return n}const oe=i(process.env.OTTO_SESSION_IDLE_TIMEOUT_MS,1800*1e3),se=i(process.env.OTTO_SESSION_MAX,50),k=i(process.env.OTTO_SESSION_PAGE_SIZE,20),A=i(process.env.OTTO_SESSION_SNAPSHOT_VERSION,1),j=[`message`,`compaction`,`clear`,`compaction-lock`];function M(e){return j.includes(e)}const N={editedFiles:50,subagents:100,turnSummaries:200,drafts:50,inputHistory:100};var P=class{constructor(e){this.host=e}capStoredHistory(e,t){let n=this.host.getEntries(),r=0;for(let e of n)e.type===`message`&&r++;if(r<=e)return{capped:!1,removedCount:0,boundaryLimited:!1,activeOversized:!1};let i=r-e,{removed:a,boundaryLimited:o}=this.removeOldestMessages(i,t);return this.host.setMessageCount(r-a),{capped:a>0,removedCount:a,boundaryLimited:o,activeOversized:this.host.getMessageCount()>e}}wouldTrimTouchActiveContext(e){let t=this.host.getMessageCount();if(t<=e)return!1;let n=t-e,r=this.host.getActiveCompactionId();if(r===void 0)return!0;let i=0;for(let e of this.host.getEntries()){if(e.id===r)break;e.type===`message`&&i++}return i<n}wouldByteTrimTouchActiveContext(e){if(e<=0||this.host.getEstimatedBytes()<=e)return!1;let t=this.host.getActiveCompactionId();if(t===void 0)return!0;let n=0;for(let e of this.host.getEntries()){if(e.id===t)break;e.type===`message`&&(n+=O(e.message))}return this.host.getEstimatedBytes()-n>e}capStoredHistoryByBytes(e,t){let n=this.host.getEntries();if(e<=0||this.host.getEstimatedBytes()<=e)return{capped:!1,removedCount:0,boundaryLimited:!1,activeOversized:!1};let r=0;for(let e of n)e.type===`message`&&r++;let i=this.host.getEstimatedBytes(),a=0;for(let t of n){if(i<=e||a>=r-1)break;t.type===`message`&&(i-=O(t.message),a++)}if(a===0)return{capped:!1,removedCount:0,boundaryLimited:!1,activeOversized:!1};let{removed:o,boundaryLimited:s}=this.removeOldestMessages(a,t);return this.host.setMessageCount(r-o),{capped:o>0,removedCount:o,boundaryLimited:s,activeOversized:this.host.getEstimatedBytes()>e}}verifyEstimatedContentBytes(){let e=0;for(let t of this.host.getEntries())if(t.type===`message`)e+=O(t.message);else if(t.type===`compaction`&&t.replacement)for(let n of t.replacement)e+=O(n);return{counter:this.host.getEstimatedBytes(),recomputed:e,drift:e-this.host.getEstimatedBytes()}}removeOldestMessages(e,t){let n=this.host.getEntries(),r=this.host.getEntryMap(),i=this.host.getActiveCompactionId(),a=!1,o=0,s=0;for(;s<n.length&&o<e;){let e=n[s];if(i!==void 0&&e.id===i){a=!0;break}e.type===`message`?(this.host.setEstimatedBytes(this.host.getEstimatedBytes()-O(e.message)),r.delete(e.id),n.splice(s,1),o++):s++}if(t)for(;s<n.length;){let e=n[s];if(i!==void 0&&e.id===i){a=!0;break}if(e.type!==`message`){s++;continue}if(t(e.message))break;this.host.setEstimatedBytes(this.host.getEstimatedBytes()-O(e.message)),r.delete(e.id),n.splice(s,1),o++}return this.host.getEstimatedBytes()<0&&this.host.setEstimatedBytes(0),{removed:o,boundaryLimited:a}}};const ce={now:()=>Date.now()},le={uuid:()=>crypto.randomUUID()};var F=class{sessionEntries=[];entryMap=new Map;clock;idGen;_estimatedContentBytes=0;get estimatedContentBytes(){return this._estimatedContentBytes}get messageCount(){return this.meta.messageCount}verifyEstimatedContentBytes(){return this.residencyPolicy.verifyEstimatedContentBytes()}meta;panelState={};residencyPolicy;constructor(e,t,n,r){this.id=e,this.clock=r?.clock??ce,this.idGen=r?.idGen??le;let i=this.clock.now();this.meta={createdAt:i,lastActiveAt:i,messageCount:0,compactionCount:0,parentSessionId:t,forkPoint:n,tags:[]},this.residencyPolicy=new P(this.createResidencyHost())}createResidencyHost(){return{getEntries:()=>this.sessionEntries,getEntryMap:()=>this.entryMap,getEstimatedBytes:()=>this._estimatedContentBytes,setEstimatedBytes:e=>{this._estimatedContentBytes=e},getMessageCount:()=>this.meta.messageCount,setMessageCount:e=>{this.meta.messageCount=e},getActiveCompactionId:()=>this.findActiveCompaction()?.id}}_leafId=void 0;get leafId(){return this._leafId}markActivity(){this.meta.lastActiveAt=this.clock.now()}append(e){let t={type:`message`,id:this.idGen.uuid(),parentId:this._leafId,message:e,timestamp:this.clock.now()};this._leafId=t.id,this.sessionEntries.push(t),this.entryMap.set(t.id,t),this.meta.messageCount++,this.markActivity(),this._estimatedContentBytes+=O(e)}removeLast(){if(!this._leafId)return;let e=this.entryMap.get(this._leafId);if(!e||e.type!==`message`)return;let t=this.sessionEntries.lastIndexOf(e);t!==-1&&(this.sessionEntries.splice(t,1),this.entryMap.delete(e.id),this._leafId=e.parentId,this.meta.messageCount=Math.max(0,this.meta.messageCount-1),this._estimatedContentBytes-=O(e.message))}compact(e,t){let n=this.getBranchMessageEntries();if(t<=0||t>n.length)return;let r={type:`compaction`,id:this.idGen.uuid(),parentId:this._leafId,summary:e,compactedCount:t,timestamp:this.clock.now()};this.sessionEntries.push(r),this.entryMap.set(r.id,r),this.meta.compactionCount++,this.markActivity(),this._leafId=r.id}recordCompaction(e,t){let n=this.findActiveCompaction(),r={type:`compaction`,id:this.idGen.uuid(),parentId:this._leafId,summary:e,compactedCount:t.length,replacement:[...t],timestamp:this.clock.now()};for(let e of t)this._estimatedContentBytes+=O(e);this.sessionEntries.push(r),this.entryMap.set(r.id,r),this.meta.compactionCount++,this.markActivity(),this._leafId=r.id,n&&n.replacement!=null&&this.replacementStripEligibility?.(n.id)===!0&&this.stripReplacementInPlace(n.id)}replacementStripEligibility;setReplacementStripEligibility(e){this.replacementStripEligibility=e}findActiveCompaction(){return this._leafId?this.findActiveCompactionFrom(this._leafId):void 0}stripReplacementInPlace(e){let t=this.entryMap.get(e);if(!t||t.type!==`compaction`)return;let n=t;if(n.replacement==null)return;for(let e of n.replacement)this._estimatedContentBytes-=O(e);this._estimatedContentBytes<0&&(this._estimatedContentBytes=0);let{replacement:r,...i}=n,a={...i,replacementStripped:!0};this.entryMap.set(e,a);let o=this.sessionEntries.findIndex(t=>t.id===e);o>=0&&(this.sessionEntries[o]=a)}clearContext(e){let t={type:`clear`,id:this.idGen.uuid(),parentId:this._leafId,timestamp:this.clock.now()};this.sessionEntries.push(t),this.entryMap.set(t.id,t),this.markActivity(),this._leafId=t.id,e?.purge===!0&&this.purgeBeforeBoundary(t.id)}appendCompactionLock(e,t){let n={type:`compaction-lock`,id:this.idGen.uuid(),parentId:this._leafId,phase:e,token:t,timestamp:this.clock.now()};this.sessionEntries.push(n),this.entryMap.set(n.id,n),this._leafId=n.id}compactionLockState(){let e=this.walkBranch();for(let t=e.length-1;t>=0;t--){let n=e[t];if(n&&n.type===`compaction-lock`)return{phase:n.phase,token:n.token,timestamp:n.timestamp}}}purgeClearedHistory(){let e;for(let t=this.sessionEntries.length-1;t>=0;t--)if(this.sessionEntries[t].type===`clear`){e=this.sessionEntries[t].id;break}return e?this.purgeBeforeBoundary(e):{removedCount:0,strippedReplacements:0}}purgeBeforeBoundary(e){let t=this.sessionEntries.findIndex(t=>t.id===e);if(t<0)return{removedCount:0,strippedReplacements:0};let n=0,r=0,i=0,a=t;for(;r<a;){let e=this.sessionEntries[r];e.type===`message`?(this._estimatedContentBytes-=O(e.message),this.entryMap.delete(e.id),this.sessionEntries.splice(r,1),a--,i++):(e.type===`compaction`&&e.replacement!=null&&(this.stripReplacementInPlace(e.id),n++),r++)}return this._estimatedContentBytes<0&&(this._estimatedContentBytes=0),this.meta.messageCount-=i,{removedCount:i,strippedReplacements:n}}branch(e){if(!this.entryMap.has(e))throw Error(`Entry "${e}" not found in session "${this.id}"`);let t=this.findActiveCompactionFrom(e);if(t&&t.replacementStripped)throw Error(`branch: target chain's active compaction boundary "${t.id}" has a stripped replacement (RFC-160); hydrate it via loadEntriesByIds before branching`);this._leafId=e,this.markActivity()}findActiveCompactionFrom(e){let t=new Set,n=this.entryMap.get(e);for(;n&&!t.has(n.id);){if(t.add(n.id),n.type===`compaction`)return n;if(n.type===`clear`)return;n=n.parentId?this.entryMap.get(n.parentId):void 0}}entries(){return this.sessionEntries}branchEntries(){return this.walkBranch()}buildContext(){let e=this.walkBranch(),t=this.lastBoundaryIndex(e),n=e.slice(t+1).filter(e=>e.type===`message`).map(e=>e.message);if(t===-1)return{messages:n};let r=e[t];if(r.type===`clear`)return{messages:n};let i=r;return{summary:i.summary,messages:i.replacement?[...i.replacement,...n]:n}}messages(){return this.walkBranch().filter(e=>e.type===`message`).map(e=>e.message)}visibleMessages(){let e=this.walkBranch(),t=-1;for(let n=e.length-1;n>=0;n--)if(e[n]?.type===`clear`){t=n;break}return e.slice(t+1).filter(e=>e.type===`message`).map(e=>e.message)}metadata(){return{...this.meta,tags:[...this.meta.tags],...this.meta.config?{config:structuredClone(this.meta.config)}:{}}}setTitle(e,t){let n=this.meta.titleSource==null?-1:D[this.meta.titleSource];return D[t]<n?!1:(this.meta.title=e,this.meta.titleSource=t,!0)}setSdkVersion(e){this.meta.sdkVersion=e}setArchived(e){this.meta.archived=e}setPinned(e,t){this.meta.pinned=e,this.meta.pinGroup=e?t:void 0}touchIfActivity(e){e?.touch!==!1&&this.markActivity()}getTodoList(){return this.panelState.todoList}setTodoList(e,t){this.panelState.todoList=[...e],this.touchIfActivity(t)}getEditedFiles(){return this.panelState.editedFiles}setEditedFiles(e,t){this.panelState.editedFiles=e.slice(0,N.editedFiles),this.touchIfActivity(t)}getInputHistory(){return this.meta.config?.inputHistory}setInputHistory(e){if(e.length===0){this.meta.config?.inputHistory!==void 0&&delete this.meta.config.inputHistory;return}this.meta.config||(this.meta.config={}),this.meta.config.inputHistory=e.slice(-N.inputHistory)}getSubagents(){return this.panelState.subagents}setSubagents(e,t){this.panelState.subagents=e.slice(0,N.subagents),this.touchIfActivity(t)}getTurnSummaries(){return this.panelState.turnSummaries}setTurnSummaries(e,t){this.panelState.turnSummaries=e.slice(-N.turnSummaries),this.touchIfActivity(t)}getTurnCount(){return this.meta.config?.turnCount}setTurnCount(e){this.meta.config||(this.meta.config={}),this.meta.config.turnCount=e}getDrafts(){return this.panelState.drafts}setDrafts(e,t){this.panelState.drafts=e.slice(0,N.drafts),this.touchIfActivity(t)}capStoredHistory(e,t){return this.residencyPolicy.capStoredHistory(e,t)}wouldTrimTouchActiveContext(e){return this.residencyPolicy.wouldTrimTouchActiveContext(e)}wouldByteTrimTouchActiveContext(e){return this.residencyPolicy.wouldByteTrimTouchActiveContext(e)}capStoredHistoryByBytes(e,t){return this.residencyPolicy.capStoredHistoryByBytes(e,t)}setTags(e){this.meta.tags=[...e]}addTag(e){this.meta.tags.includes(e)||this.meta.tags.push(e)}restoreEntries(e,t,n){this.sessionEntries.length=0,this.entryMap.clear();let r=0;for(let t of e)if(this.sessionEntries.push(t),this.entryMap.set(t.id,t),t.type===`message`)r+=O(t.message);else if(t.type===`compaction`&&t.replacement)for(let e of t.replacement)r+=O(e);this._estimatedContentBytes=r,Object.assign(this.meta,t),this._leafId=n&&this.entryMap.has(n)?n:e.length>0?e[e.length-1]?.id:void 0}toSnapshot(){return{entries:[...this.sessionEntries],metadata:this.metadata(),leafId:this._leafId}}walkBranch(){if(!this._leafId)return[];let e=[],t=new Set,n=this.entryMap.get(this._leafId);for(;n&&!t.has(n.id);)t.add(n.id),e.push(n),n=n.parentId?this.entryMap.get(n.parentId):void 0;return e.reverse(),e}getBranchMessageEntries(){let e=this.walkBranch(),t=this.lastBoundaryIndex(e);return e.slice(t+1).filter(e=>e.type===`message`)}lastBoundaryIndex(e){for(let t=e.length-1;t>=0;t--){let n=e[t]?.type;if(n===`compaction`||n===`clear`)return t}return-1}},I=class{sessions=new Map;ports;constructor(e){this.ports=e}newId(){return this.ports?.idGen?.uuid()??crypto.randomUUID()}async createSession(e=this.newId()){let t=new F(e,void 0,void 0,this.ports);return this.sessions.set(e,t),t}getSession(e){return this.sessions.get(e)}listSessions(){return Array.from(this.sessions.values())}listSessionsPaginated(e){let{page:t,sortBy:n=`lastActiveAt`,order:r=`desc`}=e,i=e.pageSize??50,a=Array.from(this.sessions.values());return a.sort((e,t)=>{let i=e.metadata(),a=t.metadata(),o=n===`createdAt`?i.createdAt:i.lastActiveAt,s=n===`createdAt`?a.createdAt:a.lastActiveAt;return r===`asc`?o-s:s-o}),u(a,{page:t,pageSize:i})}async deleteSession(e){return this.sessions.delete(e)}async forkSession(e,t=this.newId()){let n=this.sessions.get(e);if(!n)return;let r=n.toSnapshot(),i=this.ports?.clock?.now()??Date.now(),a=new F(t,e,r.entries.length,this.ports);return a.restoreEntries([...r.entries],{...r.metadata,createdAt:i,lastActiveAt:i,parentSessionId:e,forkPoint:r.entries.length,tags:[...r.metadata.tags,`fork`]},r.leafId),this.sessions.set(t,a),a}};function ue(e){return new I(e)}var de=class extends a{constructor(){super({defaultPageSize:k,defaultSortBy:`lastActiveAt`})}extractId(e){return e.id}getSortValue(e,t){return t===`createdAt`?e.metadata.createdAt:e.metadata.lastActiveAt}async listRecentMeta(e){return this.entries().filter(([,e])=>!e.metadata.archived).sort(([,e],[,t])=>t.metadata.lastActiveAt-e.metadata.lastActiveAt).slice(0,e).map(([e])=>e)}};function L(e){return`sha256:${f(`sha256`).update(e,`utf-8`).digest(`hex`)}`}async function R(e,t,n){if(e!==`compaction`)return t;let r=t.replacement;if(!Array.isArray(r))return t;let i=r.map(e=>JSON.stringify(e)),a=i.map(L);await n.putBlobs(i.map((e,t)=>({hash:a[t],content:e})));let{replacement:o,...s}=t;return{...s,replacementHashes:a}}async function z(e,t,n){if(e!==`compaction`)return t;let r=t.replacementHashes;if(!Array.isArray(r)||r.length===0){if(Array.isArray(r)){let{replacementHashes:e,...n}=t;return{...n,replacement:[]}}return t}let i=await n.getBlobs(r),a=r.map(e=>{let t=i.get(e);if(t==null)throw Error(`decodeReplacementFromBlobs: blob ${e} missing from message_blobs (corrupted import/partial backup?); refusing to assemble a lossy replacement (RFC-160 D7)`);return JSON.parse(t)}),{replacementHashes:o,...s}=t;return{...s,replacement:a}}function B(e,t){let n=e.metadata;return{id:e.id,workspaceKey:t,...n.title==null?{}:{title:n.title},...n.titleSource==null?{}:{titleSource:n.titleSource},...n.parentSessionId==null?{}:{parentSessionId:n.parentSessionId},...n.forkPoint==null?{}:{forkPoint:n.forkPoint},...e.leafId==null?{}:{leafId:e.leafId},tags:n.tags??[],...n.config==null?{}:{config:n.config},createdAt:n.createdAt,lastActiveAt:n.lastActiveAt,...n.archived==null?{}:{archived:n.archived},...n.pinned==null?{}:{pinned:n.pinned},...n.pinGroup==null?{}:{pinGroup:n.pinGroup}}}function V(e){let{type:t,id:n,parentId:r,timestamp:i,...a}=e;return{entryId:n,...r==null?{}:{parentId:r},type:t,data:a,createdAt:i}}function H(e){return{type:e.type,id:e.entryId,...e.parentId==null?{}:{parentId:e.parentId},timestamp:e.createdAt,...e.data}}async function fe(e,t,n){await n.createSession(B(e,t));for(let t of e.entries)await n.appendEntry(e.id,V(t));await n.touchSession({id:e.id,leafId:e.leafId,lastActiveAt:e.metadata.lastActiveAt,title:e.metadata.title,titleSource:e.metadata.titleSource,config:e.metadata.config,archived:e.metadata.archived,pinned:e.metadata.pinned,pinGroup:e.metadata.pinGroup})}async function U(e,t,n){let r=await t.getSession(e);if(!r)return null;let i,a=!1;n?.maxEntries==null?i=(await t.loadEntries(e)).map(e=>H(e)):await t.getEntryCount(e)>n.maxEntries?(i=(await t.loadTailEntries(e,n.maxEntries)).map(e=>H(e)),a=!0,n.canStartHistory&&(i=me(i,n.canStartHistory))):i=(await t.loadEntries(e)).map(e=>H(e)),n?.stripInactiveReplacements?(i=pe(i,r.leafId??void 0),i=await W(i,t,{onlyUnstripped:!0})):i=await W(i,t,{onlyUnstripped:!1});let o=a?await t.countEntriesByType(e,`message`):i.filter(e=>e.type===`message`).length,s=a?await t.countEntriesByType(e,`compaction`):i.filter(e=>e.type===`compaction`).length,c={createdAt:r.createdAt,lastActiveAt:r.lastActiveAt,messageCount:o,compactionCount:s,tags:r.tags,...r.title==null?{}:{title:r.title},...r.titleSource==null?{}:{titleSource:r.titleSource},...r.parentSessionId==null?{}:{parentSessionId:r.parentSessionId},...r.forkPoint==null?{}:{forkPoint:r.forkPoint},...r.config==null?{}:{config:r.config},...r.archived==null?{}:{archived:r.archived},...r.pinned==null?{}:{pinned:r.pinned},...r.pinGroup==null?{}:{pinGroup:r.pinGroup}};return{version:A,id:e,entries:i,metadata:c,...r.leafId==null?{}:{leafId:r.leafId}}}async function W(e,t,n){let r=[];for(let i of e){let e=i;if(e.type!==`compaction`||e.replacementHashes==null){r.push(i);continue}if(n.onlyUnstripped&&e.replacementStripped){let{replacementHashes:t,...n}=e;r.push(n);continue}let{replacementStripped:a,...o}=await z(`compaction`,e,t);r.push(o)}return r}function pe(e,t){let n=new Map;for(let t of e)n.set(t.id,t);let r,i=new Set,a=t?n.get(t):void 0;for(;a&&!i.has(a.id);){if(i.add(a.id),a.type===`compaction`){r=a.id;break}if(a.type===`clear`)break;a=a.parentId?n.get(a.parentId):void 0}let o=-1;for(let t=e.length-1;t>=0;t--)if(e[t].type===`compaction`){o=t;break}return e.map((e,t)=>{if(e.type!==`compaction`||e.id===r||t===o)return e;let n=e;if(n.replacement!=null){let{replacement:e,...t}=n;return{...t,replacementStripped:!0}}return n.replacementHashes==null?e:{...n,replacementStripped:!0}})}function me(e,t){let n=0;for(;n<e.length;){let r=e[n];if(r.type!==`message`||t(r.message))break;n++}return n>0?e.slice(n):e}function he(e){return typeof e?.hydrateReplacements==`function`}function ge(e){return e.some(e=>e.type===`compaction`&&e.replacementStripped)}async function G(e,t,n){let r=t.filter(e=>e.type===`compaction`&&e.replacementStripped).map(e=>e.id);if(r.length===0)return[...t];let i=await n.loadEntriesByIds(e,r),a=new Map;for(let e of i)a.set(e.entryId,e.data);let o=[];for(let r of t){if(r.type!==`compaction`||!r.replacementStripped){o.push(r);continue}let t=a.get(r.id);if(t&&t.replacementHashes!=null&&(t=await z(`compaction`,t,n)),!t||t.replacement==null)throw Error(`hydrateStrippedReplacements: authoritative row for compaction "${r.id}" in session "${e}" is missing or has no replacement (corrupted import?); refusing to continue with stripped state (RFC-160 rule 3)`);let{replacementStripped:i,...s}=r;o.push({...s,replacement:t.replacement})}return o}var K=class extends Error{constructor(e){super(`Session write lease denied for ${e}: another live process owns the write lease (this process is read-only for the session; refusing to save — RFC-159 D3)`),this.sessionId=e,this.name=`SessionWriteLeaseDeniedError`}};const _e={uuid:()=>p()};function q(i){let a=i.staleMs??6e4,o=i.renewEveryMs??1e4,s=new Map,c=!1,l=e(),u=e=>S(i.lockDir,`${e}.lock`),d=e=>S(i.lockDir,`${e}.tombstone`),f=e=>{try{g(i.lockDir,{recursive:!0}),ie(d(e),String(Date.now()),`utf8`)}catch{}},m=e=>{try{let t=Number(_(d(e),`utf8`));return Number.isFinite(t)&&Date.now()-t<=6e5}catch{return!1}},h=e=>{try{return t(_(u(e),`utf-8`).trim())}catch{return null}},x=e=>h(e)?.token??null,C=(e,t)=>{try{g(i.lockDir,{recursive:!0});let r=te(u(e),`wx`);try{ae(r,n(t,process.pid,l))}finally{ee(r)}return!0}catch(e){if(e.code!==`EEXIST`)throw e;return!1}},w=e=>e.pid===void 0||e.host===void 0||e.host!==l?!1:!r(e.pid),T=e=>e.pid===void 0||e.host===void 0||e.host!==l?!1:r(e.pid),E=(e,t)=>{let n=setInterval(()=>{if(x(e)!==t){D(e);return}try{let t=new Date;b(u(e),t,t)}catch{D(e)}},o);n.unref(),s.set(e,{token:t,timer:n})},D=e=>{let t=s.get(e);t&&(clearInterval(t.timer),s.delete(e))},O={acquire(e){if(c)return!1;let t=s.get(e);if(t){if(x(e)===t.token)return!0;if(m(e))return D(e),!1;D(e)}let n=(i.idGen??_e).uuid();if(C(e,n))return E(e,n),!0;let r=h(e),o;try{o=v(u(e)).mtimeMs}catch{return C(e,n)?(E(e,n),!0):!1}if(r!==null&&T(r)||!(r!==null&&w(r))&&Date.now()-o<=a)return!1;let l=`${u(e)}.stale-${p()}`;try{ne(u(e),l),re(l,{force:!0})}catch{return!1}return C(e,n)?(E(e,n),!0):!1},release(e){let t=s.get(e);if(t){if(x(e)===t.token)try{y(u(e))}catch{}D(e)}},releaseAll(){for(let e of[...s.keys()])O.release(e)},isOwner(e){if(c)return!1;let t=s.get(e);return t!=null&&x(e)===t.token},peekLockedByOther(e){if(c)return!1;let t=s.get(e);if(t!=null&&x(e)===t.token)return!1;let n;try{n=v(u(e)).mtimeMs}catch{return!1}return Date.now()-n<=a},inspect(e){let t=h(e);if(t===null)return{locked:!1};let n;try{n=Date.now()-v(u(e)).mtimeMs}catch{return{locked:!1}}let i=t.pid!==void 0&&t.host!==void 0&&t.host===l?r(t.pid):void 0;return{locked:!0,pid:t.pid,hostname:t.host,alive:i,mtimeAgoMs:n}},forceRelease(e){try{y(u(e))}catch{}f(e),D(e)},close(){c=!0,O.releaseAll()}};return i.installExitHook!==!1&&process.on(`exit`,()=>O.releaseAll()),O}function ve(){return{acquire:()=>!0,release:()=>{},releaseAll:()=>{},isOwner:()=>!0,peekLockedByOther:()=>!1,inspect:()=>({locked:!1}),forceRelease:()=>{},close:()=>{}}}function J(e){return typeof e?.archiveSession==`function`&&typeof e?.restoreArchivedSession==`function`}const ye={warn:()=>{}};var be=class{repo;resolveWorkspaceKey;defaultPageSize;logger;persisted=new Map;maxLoadEntries;canStartHistory;writeLease;stripInactiveReplacements;constructor(e){this.repo=e.repo;let t=e.workspaceKey;this.resolveWorkspaceKey=typeof t==`function`?()=>t()||`default`:()=>t||`default`,this.defaultPageSize=e.defaultPageSize??20,this.logger=e.logger??ye,this.maxLoadEntries=e.maxLoadEntries,this.canStartHistory=e.canStartHistory,this.writeLease=e.writeLease,this.stripInactiveReplacements=e.stripInactiveReplacements??!1}assertWritable(e){if(this.writeLease&&!this.writeLease.acquire(e))throw this.logger.warn({sessionId:e},`archive/restore rejected: session write lease held by another live process (read-only; RFC-159 D3)`),new K(e)}async archiveSession(e){if(!J(this.repo))throw Error(`archiveSession is not supported by this repository`);return this.assertWritable(e),this.repo.archiveSession(e)}async restoreArchivedSession(e){return J(this.repo)?(this.assertWritable(e),this.repo.restoreArchivedSession(e)):0}async save(e){if(this.writeLease&&!this.writeLease.acquire(e.id))throw this.logger.warn({sessionId:e.id},`save rejected: session write lease held by another live process (read-only; RFC-159 D3)`),new K(e.id);await this.repo.createSession(B(e,this.resolveWorkspaceKey()));let t=this.persisted.get(e.id),n=0;if(t!=null){let r=e.entries.findIndex(e=>e.id===t);n=r>=0?r+1:0}if(n===0){let n=await this.repo.getEntryCount(e.id);n>0&&t==null&&this.logger.warn({sessionId:e.id,dbCount:n},`Session has persisted entries but no local cursor (restart or concurrent writer); reconciling via full idempotent append (append-forever, no loss)`)}for(let t=n;t<e.entries.length;t++){if(t%8==0&&this.writeLease&&!this.writeLease.isOwner(e.id))throw this.logger.warn({sessionId:e.id},`write lease lost mid-save (stale takeover by another process) — aborting append to avoid concurrent write`),new K(e.id);let n=V(e.entries[t]),r=await R(n.type,n.data,this.repo);await this.repo.appendEntry(e.id,{...n,data:r})}let{leafPersisted:r}=await this.repo.touchSession({id:e.id,leafId:e.leafId,lastActiveAt:e.metadata.lastActiveAt,title:e.metadata.title,titleSource:e.metadata.titleSource,config:e.metadata.config,archived:e.metadata.archived,pinned:e.metadata.pinned,pinGroup:e.metadata.pinGroup});!r&&e.leafId!=null&&this.logger.warn({sessionId:e.id,rejectedLeafId:e.leafId},`touchSession: leafId not found among session entries (rejected to avoid dangling leaf; likely concurrent writer race); existing leaf_id preserved`);let i=e.entries[e.entries.length-1];i?this.persisted.set(e.id,i.id):this.persisted.delete(e.id)}async load(e){let t=await this.repo.getSession(e);if(!t)return null;let n=this.resolveWorkspaceKey(),r=t.workspaceKey||`default`;if(r!==n)return this.logger.warn({sessionId:e,sessionWorkspaceKey:r,expectedWorkspaceKey:n},`RelationalSessionPersistence.load: session belongs to a different workspace, refusing cross-workspace restore`),null;let i=await U(e,this.repo,{...this.maxLoadEntries==null?{}:{maxEntries:this.maxLoadEntries},...this.canStartHistory?{canStartHistory:this.canStartHistory}:{},...this.stripInactiveReplacements?{stripInactiveReplacements:!0}:{}}),a=i?.entries[i.entries.length-1];return a&&this.persisted.set(e,a.id),i}getPersistedCursor(e){return this.persisted.get(e)}async hydrateReplacements(e,t){return G(e,t,this.repo)}async delete(e){let t=await this.repo.deleteSession(e);return this.persisted.delete(e),this.writeLease?.release(e),t}async list(){return(await this.repo.listSessions(this.resolveWorkspaceKey())).map(e=>e.id)}async listRecentMeta(e){return this.repo.listRecentSessionIds(this.resolveWorkspaceKey(),e)}async listPaginated(e){let t=await this.repo.listSessions(this.resolveWorkspaceKey()),n=e.sortBy===`createdAt`?[...t].sort((e,t)=>t.createdAt-e.createdAt):t,r=e.order===`asc`?[...n].reverse():n,i=e.pageSize??this.defaultPageSize;return u(r.map(e=>e.id),{page:e.page,pageSize:i})}},Y=class{archiveDir;ephemeral;deps;constructor(e){this.archiveDir=e.archiveDir,this.ephemeral=e.ephemeral??!1,this.deps=e}archivePath(e){return C(this.archiveDir,`${e}.jsonl.gz`)}async archiveSession(e){if(this.ephemeral)return this.deps.setArchived(e,!0),`:memory:/${e}.jsonl.gz`;let t=this.archivePath(e);h(this.archiveDir)||g(this.archiveDir,{recursive:!0});let n=await this.deps.loadEntries(e),r=w(),i=m(t);r.pipe(i);let a=new TextEncoder;for(let e of n)r.write(a.encode(JSON.stringify(e)+`
|
|
2
|
+
`));return r.end(),await new Promise((e,t)=>{i.on(`finish`,e),i.on(`error`,t)}),this.deps.setArchived(e,!0),t}async restoreArchivedSession(e){let t=this.archivePath(e);if(!h(t))return 0;let n=T(await E(t)).toString(`utf-8`).trim().split(`
|
|
3
3
|
`).filter(Boolean),r=await this.deps.loadEntries(e),i=0;for(let t of n){let n=JSON.parse(t);r.some(e=>e.entryId===n.entryId)||(await this.deps.appendEntry(e,n),i++)}return this.deps.setArchived(e,!1),i}};const X=[{version:1,up:e=>{e.exec(`
|
|
4
4
|
CREATE TABLE IF NOT EXISTS workspaces (
|
|
5
5
|
id TEXT PRIMARY KEY,
|
|
@@ -47,7 +47,7 @@ import{currentHostname as e,decodeLeaseToken as t,encodeLeaseToken as n,isProces
|
|
|
47
47
|
content TEXT NOT NULL,
|
|
48
48
|
created_at INTEGER NOT NULL
|
|
49
49
|
);
|
|
50
|
-
`)}}],Z=`default`;var
|
|
50
|
+
`)}}],Z=`default`;var xe=class{db;archiveStore;ephemeral;constructor(e){this.db=l(e.dbPath,e.wal!==!1,X),this.ephemeral=e.dbPath===`:memory:`,this.archiveStore=new Y({archiveDir:C(x(e.dbPath),`archives`),ephemeral:this.ephemeral,loadEntries:e=>this.loadEntries(e),appendEntry:(e,t)=>this.appendEntry(e,t),setArchived:(e,t)=>{this.db.prepare(`UPDATE sessions SET archived = ? WHERE id = ?`).run(t?1:0,e)}})}close(){d(this.db)}async archiveSession(e){return this.archiveStore.archiveSession(e)}async restoreArchivedSession(e){return this.archiveStore.restoreArchivedSession(e)}async createSession(e){this.db.prepare(`INSERT INTO sessions
|
|
51
51
|
(id, workspace_key, title, title_source, parent_session_id, fork_point, leaf_id, owner_id, tags, config, next_seq, created_at, last_active_at, archived, pinned, pin_group)
|
|
52
52
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, ?, ?, ?, ?, ?)
|
|
53
53
|
ON CONFLICT (id) DO NOTHING`).run(e.id,e.workspaceKey||Z,e.title??null,e.titleSource??null,e.parentSessionId??null,e.forkPoint??null,e.leafId??null,e.ownerId??null,JSON.stringify(e.tags??[]),e.config==null?null:JSON.stringify(e.config),e.createdAt,e.lastActiveAt,e.archived==null?null:e.archived?1:0,e.pinned==null?null:e.pinned?1:0,e.pinGroup??null)}async touchSession(e){let{id:t,leafId:n,lastActiveAt:r,title:i,titleSource:a,config:o,archived:s,pinned:c,pinGroup:l}=e;return{leafPersisted:this.db.transaction(()=>{let e=null,u=!0;return n!=null&&(this.db.prepare(`SELECT 1 FROM session_entries WHERE session_id = ? AND entry_id = ?`).get(t,n)?e=n:u=!1),this.db.prepare(u?`UPDATE sessions SET
|
|
@@ -81,5 +81,5 @@ import{currentHostname as e,decodeLeaseToken as t,encodeLeaseToken as n,isProces
|
|
|
81
81
|
SELECT * FROM session_entries
|
|
82
82
|
WHERE session_id = ? AND seq < ?
|
|
83
83
|
ORDER BY seq DESC LIMIT ?
|
|
84
|
-
) ORDER BY seq ASC`).all(e,t,n).map($)}async countEntriesByType(e,t){return this.db.prepare(`SELECT COUNT(*) AS n FROM session_entries WHERE session_id = ? AND type = ?`).get(e,t).n}async putBlobs(e){if(e.length===0)return;let t=this.db.prepare(`INSERT OR IGNORE INTO message_blobs (hash, content, created_at) VALUES (?, ?, ?)`);this.db.transaction(e=>{let n=Date.now();for(let r of e)t.run(r.hash,r.content,n)}).immediate(e)}async getBlobs(e){let t=new Map;for(let n of this.batchInQuery(e,e=>`SELECT hash, content FROM message_blobs WHERE hash IN (${e})`))for(let e of n)t.set(e.hash,e.content);return t}async loadEntriesByIds(e,t){let n=[];for(let r of this.batchInQuery(t,e=>`SELECT * FROM session_entries WHERE session_id = ? AND entry_id IN (${e})`,[e]))n.push(...r);return n.sort((e,t)=>e.seq-t.seq),n.map($)}*batchInQuery(e,t,n=[]){if(e.length!==0)for(let r=0;r<e.length;r+=500){let i=e.slice(r,r+500),a=i.map(()=>`?`).join(`,`);yield this.db.prepare(t(a)).all(...n,...i)}}};function Q(e){return{id:e.id,workspaceKey:e.workspace_key??Z,...e.title==null?{}:{title:e.title},...e.title_source==null?{}:{titleSource:e.title_source},...e.parent_session_id==null?{}:{parentSessionId:e.parent_session_id},...e.fork_point==null?{}:{forkPoint:e.fork_point},...e.leaf_id==null?{}:{leafId:e.leaf_id},...e.owner_id==null?{}:{ownerId:e.owner_id},tags:JSON.parse(e.tags),...e.config==null?{}:{config:JSON.parse(e.config)},entryCount:e.next_seq,createdAt:e.created_at,lastActiveAt:e.last_active_at,...e.archived==null?{}:{archived:e.archived===1},...e.pinned==null?{}:{pinned:e.pinned===1},...e.pin_group==null?{}:{pinGroup:e.pin_group}}}function $(e){return{sessionId:e.session_id,seq:e.seq,entryId:e.entry_id,...e.parent_id==null?{}:{parentId:e.parent_id},type:e.type,data:JSON.parse(e.data),createdAt:e.created_at}}var
|
|
84
|
+
) ORDER BY seq ASC`).all(e,t,n).map($)}async countEntriesByType(e,t){return this.db.prepare(`SELECT COUNT(*) AS n FROM session_entries WHERE session_id = ? AND type = ?`).get(e,t).n}async putBlobs(e){if(e.length===0)return;let t=this.db.prepare(`INSERT OR IGNORE INTO message_blobs (hash, content, created_at) VALUES (?, ?, ?)`);this.db.transaction(e=>{let n=Date.now();for(let r of e)t.run(r.hash,r.content,n)}).immediate(e)}async getBlobs(e){let t=new Map;for(let n of this.batchInQuery(e,e=>`SELECT hash, content FROM message_blobs WHERE hash IN (${e})`))for(let e of n)t.set(e.hash,e.content);return t}async loadEntriesByIds(e,t){let n=[];for(let r of this.batchInQuery(t,e=>`SELECT * FROM session_entries WHERE session_id = ? AND entry_id IN (${e})`,[e]))n.push(...r);return n.sort((e,t)=>e.seq-t.seq),n.map($)}*batchInQuery(e,t,n=[]){if(e.length!==0)for(let r=0;r<e.length;r+=500){let i=e.slice(r,r+500),a=i.map(()=>`?`).join(`,`);yield this.db.prepare(t(a)).all(...n,...i)}}};function Q(e){return{id:e.id,workspaceKey:e.workspace_key??Z,...e.title==null?{}:{title:e.title},...e.title_source==null?{}:{titleSource:e.title_source},...e.parent_session_id==null?{}:{parentSessionId:e.parent_session_id},...e.fork_point==null?{}:{forkPoint:e.fork_point},...e.leaf_id==null?{}:{leafId:e.leaf_id},...e.owner_id==null?{}:{ownerId:e.owner_id},tags:JSON.parse(e.tags),...e.config==null?{}:{config:JSON.parse(e.config)},entryCount:e.next_seq,createdAt:e.created_at,lastActiveAt:e.last_active_at,...e.archived==null?{}:{archived:e.archived===1},...e.pinned==null?{}:{pinned:e.pinned===1},...e.pin_group==null?{}:{pinGroup:e.pin_group}}}function $(e){return{sessionId:e.session_id,seq:e.seq,entryId:e.entry_id,...e.parent_id==null?{}:{parentId:e.parent_id},type:e.type,data:JSON.parse(e.data),createdAt:e.created_at}}var Se=class extends o{turnFlush=`snapshot`;constructor(e){let{userId:t,wsKey:n,...r}=e,i=e.getHeaders;super({...r,wsKey:n,getHeaders:t?async()=>({...await i?.().catch(()=>({}))??{},"X-Otto-User-Id":t}):i,defaultSortBy:`lastActiveAt`,defaultPageSize:k})}get serviceLabel(){return`会话服务`}get endpointFlag(){return`--session-url`}extractId(e){return e.id}async listRecentMeta(e){let t=`/${encodeURIComponent(this.wsKey)}/recent`;return(await(await this.request(`${t}?limit=${encodeURIComponent(String(e))}`,{method:`GET`})).json()).ids}};export{F as InMemorySession,de as InMemorySessionPersistence,I as InMemorySessionStore,N as PANEL_STATE_LIMITS,be as RelationalSessionPersistence,s as RemotePersistenceError,Se as RemoteSessionPersistence,c as RemoteSnapshotConflictError,P as ResidencyPolicy,j as SESSION_ENTRY_TYPES,oe as SESSION_IDLE_TIMEOUT_MS,se as SESSION_MAX,X as SESSION_MIGRATIONS,k as SESSION_PAGE_SIZE,A as SESSION_SNAPSHOT_VERSION,Y as SessionArchiveStore,K as SessionWriteLeaseDeniedError,xe as SqliteSessionRepository,ue as createInMemorySessionStore,ve as createNoopSessionWriteLeaseManager,q as createSessionWriteLeaseManager,z as decodeReplacementFromBlobs,R as encodeReplacementToBlobs,V as entryToInput,O as estimateMessageContentBytes,fe as explodeSnapshot,ge as hasStrippedReplacements,L as hashMessageContent,G as hydrateStrippedReplacements,M as isKnownSessionEntryType,U as reassembleSnapshot,H as rowToEntry,B as sessionRowFromSnapshot,J as supportsArchive,he as supportsReplacementHydration};
|
|
85
85
|
//# sourceMappingURL=index.js.map
|