@tansr/cli 0.10.3 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/tansr-artifacts.json +1223 -831
- package/tansr-bg-A35DNHK2.mjs +5 -0
- package/tansr-chunk-2CIB4KCJ.mjs +5 -0
- package/{tansr-chunk-XXBNISJJ.mjs → tansr-chunk-2HZJSKHM.mjs} +2 -2
- package/{tansr-chunk-CJP7YEGC.mjs → tansr-chunk-2PB54HDR.mjs} +2 -2
- package/tansr-chunk-33QZBUL6.mjs +6 -0
- package/tansr-chunk-3YSQG6KY.mjs +5 -0
- package/tansr-chunk-4DAH4AIH.mjs +7 -0
- package/{tansr-chunk-HHL7HM62.mjs → tansr-chunk-4IWNKAT5.mjs} +2 -2
- package/tansr-chunk-4YAEV3T6.mjs +9 -0
- package/tansr-chunk-546BDI3V.mjs +7 -0
- package/tansr-chunk-6N333TUL.mjs +241 -0
- package/{tansr-chunk-KQVXXXEF.mjs → tansr-chunk-6QKU3GNA.mjs} +2 -2
- package/tansr-chunk-AHUB2IHT.mjs +5 -0
- package/tansr-chunk-AOH7YPF3.mjs +8 -0
- package/{tansr-chunk-C6COFFZK.mjs → tansr-chunk-B2O4DB4K.mjs} +2 -2
- package/tansr-chunk-C2NTVBEY.mjs +5 -0
- package/{tansr-chunk-D7VSW2LQ.mjs → tansr-chunk-C75DEEUJ.mjs} +2 -2
- package/tansr-chunk-ECYZ457U.mjs +5 -0
- package/tansr-chunk-EFN24XG3.mjs +25 -0
- package/tansr-chunk-ENRIN7EG.mjs +7 -0
- package/{tansr-chunk-RVSBSUXE.mjs → tansr-chunk-ITZBYACC.mjs} +2 -2
- package/{tansr-chunk-GMPMRXL4.mjs → tansr-chunk-IZZYKHSW.mjs} +3 -3
- package/tansr-chunk-JIC3VWLQ.mjs +252 -0
- package/tansr-chunk-JTGWG4BG.mjs +32 -0
- package/tansr-chunk-LA3LGOYQ.mjs +11 -0
- package/tansr-chunk-MAMODDQN.mjs +5 -0
- package/tansr-chunk-N644DEOO.mjs +5 -0
- package/tansr-chunk-NQOYEFEE.mjs +5 -0
- package/tansr-chunk-O7P4OFK7.mjs +7 -0
- package/tansr-chunk-OEHA7T4Q.mjs +26 -0
- package/{tansr-chunk-ZV3NCXTD.mjs → tansr-chunk-OKNSOZDU.mjs} +7 -7
- package/tansr-chunk-OT4KIQLR.mjs +9 -0
- package/tansr-chunk-OUOTEH4A.mjs +5 -0
- package/tansr-chunk-Q3XDAUKT.mjs +65 -0
- package/tansr-chunk-RFH7OCN6.mjs +5 -0
- package/tansr-chunk-RUYIVG72.mjs +12 -0
- package/tansr-chunk-SCFXBKV6.mjs +8 -0
- package/tansr-chunk-SHLU4JN2.mjs +5 -0
- package/{tansr-chunk-M774GK3P.mjs → tansr-chunk-SIV2666W.mjs} +2 -2
- package/tansr-chunk-SX3XZNN6.mjs +6 -0
- package/tansr-chunk-SXNTYWJY.mjs +8 -0
- package/tansr-chunk-UVL2XWKL.mjs +5 -0
- package/tansr-chunk-V4HGMAJS.mjs +375 -0
- package/{tansr-chunk-2X337GKC.mjs → tansr-chunk-W2WIN3M2.mjs} +2 -2
- package/tansr-chunk-WAYVH5ON.mjs +5 -0
- package/tansr-chunk-WPKFARCU.mjs +11 -0
- package/{tansr-chunk-726Y5F3M.mjs → tansr-chunk-YEYFEVYF.mjs} +2 -2
- package/tansr-chunk-YK3CE3JM.mjs +5 -0
- package/tansr-chunk-YOSRXZWY.mjs +5 -0
- package/tansr-compaction-history-LZXZTWBV.mjs +5 -0
- package/tansr-compaction-log-H2SPLK24.mjs +5 -0
- package/tansr-indexed-CPYJVPFI.mjs +5 -0
- package/tansr-lock-XWDVZMLY.mjs +5 -0
- package/tansr-main-6GDLXIRQ.mjs +7 -0
- package/tansr-render-SVMDLHLN.mjs +6 -0
- package/tansr-restore-7PS7WCJR.mjs +5 -0
- package/tansr-run-acp-entry-EQGUKZ5R.mjs +68 -0
- package/tansr-run-approvals-entry-SEYBHLS2.mjs +12 -0
- package/{tansr-run-auth-entry-7HA4C4NJ.mjs → tansr-run-auth-entry-R3GKGKWX.mjs} +2 -2
- package/tansr-run-doctor-B3XK72DW.mjs +11 -0
- package/tansr-run-headless-entry-4XTAVPTW.mjs +84 -0
- package/tansr-run-init-entry-GH2KDGI6.mjs +5 -0
- package/tansr-run-logout-entry-PLGYDEOB.mjs +5 -0
- package/tansr-run-mcp-serve-entry-UHK4WSKL.mjs +14 -0
- package/tansr-run-orchestrate-entry-M7R3433X.mjs +11 -0
- package/tansr-run-org-entry-UONLGJIJ.mjs +17 -0
- package/tansr-run-policy-entry-NNQCV5WS.mjs +16 -0
- package/tansr-run-profile-entry-PV6OO7FV.mjs +14 -0
- package/tansr-run-serve-entry-GWZQZ37P.mjs +16 -0
- package/tansr-run-sessions-entry-WL7YLRJL.mjs +25 -0
- package/tansr-run-update-entry-YI47IPCC.mjs +5 -0
- package/tansr-spill-YVUTIFOS.mjs +5 -0
- package/tansr-src-LPMSGRKO.mjs +5 -0
- package/{tansr-src-A6WDMY6X.mjs → tansr-src-RQJPOVDN.mjs} +50 -50
- package/tansr-startup-account-MYFJ3NOL.mjs +7 -0
- package/{tansr-startup-model-I6LOCFDP.mjs → tansr-startup-model-BCGEYUM4.mjs} +3 -3
- package/tansr-storage-journal-4E274MUA.mjs +5 -0
- package/tansr-todos-replay-TVQKP7OD.mjs +5 -0
- package/tansr-tui-3Q7Z3ALV.mjs +73 -0
- package/tansr.mjs +1 -1
- package/tansrd.mjs +444 -265
- package/tansr-bg-EAYYM4XW.mjs +0 -5
- package/tansr-chunk-2C6JKHKM.mjs +0 -25
- package/tansr-chunk-4LNN4SQL.mjs +0 -22
- package/tansr-chunk-5T7X32UX.mjs +0 -6
- package/tansr-chunk-5TJVZSZE.mjs +0 -6
- package/tansr-chunk-74H5GQTJ.mjs +0 -35
- package/tansr-chunk-7T6OLLFW.mjs +0 -12
- package/tansr-chunk-BX7CF5RQ.mjs +0 -25
- package/tansr-chunk-DN22GXHD.mjs +0 -8
- package/tansr-chunk-F7C6ITED.mjs +0 -5
- package/tansr-chunk-GDJ5YVNY.mjs +0 -5
- package/tansr-chunk-GR6BWQGG.mjs +0 -38
- package/tansr-chunk-HRKJLVKC.mjs +0 -7
- package/tansr-chunk-I3TOVAA6.mjs +0 -5
- package/tansr-chunk-IZICOKKF.mjs +0 -279
- package/tansr-chunk-J2LWM3S7.mjs +0 -5
- package/tansr-chunk-M6XHWCMA.mjs +0 -11
- package/tansr-chunk-MWHLITGY.mjs +0 -11
- package/tansr-chunk-N3R2URKL.mjs +0 -5
- package/tansr-chunk-NA22YT73.mjs +0 -5
- package/tansr-chunk-OSK64SU3.mjs +0 -5
- package/tansr-chunk-QEKVLX7W.mjs +0 -5
- package/tansr-chunk-QHEQQ2JB.mjs +0 -9
- package/tansr-chunk-QUFHVA3F.mjs +0 -5
- package/tansr-chunk-QWGSXFEJ.mjs +0 -7
- package/tansr-chunk-SJFDQLLC.mjs +0 -5
- package/tansr-chunk-X4GLXJ2Z.mjs +0 -67
- package/tansr-chunk-X5REV3T3.mjs +0 -8
- package/tansr-chunk-ZQ3ZK7IL.mjs +0 -37
- package/tansr-main-STVTNYAI.mjs +0 -7
- package/tansr-render-PUEISX75.mjs +0 -6
- package/tansr-run-acp-entry-6J44XOYJ.mjs +0 -63
- package/tansr-run-approvals-entry-HQWSIW3P.mjs +0 -12
- package/tansr-run-doctor-7T6IAXYE.mjs +0 -10
- package/tansr-run-headless-entry-XEFQC5LE.mjs +0 -78
- package/tansr-run-init-entry-3VKXS2WK.mjs +0 -5
- package/tansr-run-logout-entry-VNCNNCSS.mjs +0 -5
- package/tansr-run-mcp-serve-entry-5KLWER3G.mjs +0 -14
- package/tansr-run-orchestrate-entry-AR57AZLR.mjs +0 -11
- package/tansr-run-org-entry-TJPRLGCL.mjs +0 -17
- package/tansr-run-policy-entry-DHMQ3PAP.mjs +0 -16
- package/tansr-run-profile-entry-LOFPHFG4.mjs +0 -14
- package/tansr-run-serve-entry-CHVKUY5J.mjs +0 -99
- package/tansr-run-sessions-entry-JOMFB5LJ.mjs +0 -23
- package/tansr-run-update-entry-XI6KG7UI.mjs +0 -5
- package/tansr-sqlite-event-store-UQLSSZKP.mjs +0 -26
- package/tansr-sqlite-spool-implementation-LHEIRSUX.mjs +0 -29
- package/tansr-src-KOEPYVXX.mjs +0 -5
- package/tansr-startup-account-7ZFSP3FV.mjs +0 -7
- package/tansr-tui-OWG3JNA6.mjs +0 -75
package/tansr-chunk-DN22GXHD.mjs
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { createRequire as __tansrCreateRequire } from 'module';const require=__tansrCreateRequire(import.meta.url);
|
|
2
|
-
import { fileURLToPath as __tansrFileURLToPath } from 'url';import { dirname as __tansrDirname } from 'path';
|
|
3
|
-
const __filename=__tansrFileURLToPath(import.meta.url);const __dirname=__tansrDirname(__filename);
|
|
4
|
-
import{b as W,d as Z,h as ee,i as ne,j as te,p as se}from"./tansr-chunk-GDJ5YVNY.mjs";import{b as k,d as X}from"./tansr-chunk-J2LWM3S7.mjs";import{c as Q,k as V}from"./tansr-chunk-HRKJLVKC.mjs";import{Eb as z,F as D,G as N,H as J,d as v,fa as K,k as x,l as I,me as H,t as A,x as j,z as h}from"./tansr-chunk-IZICOKKF.mjs";import{m as E}from"./tansr-chunk-NA22YT73.mjs";import{D as $,Fb as F,Ib as Y}from"./tansr-chunk-QWGSXFEJ.mjs";var S={persistFailed:"cli.sessions.persist_failed",checkpointFailed:"cli.sessions.checkpoint_failed",resumeNotFound:"cli.sessions.resume.not_found",resumeFailed:"cli.sessions.resume.failed",resumeRestored:"cli.sessions.resume.restored",resumeForked:"cli.sessions.resume.forked",resumeNone:"cli.sessions.resume.none",resumeAlreadyCurrent:"cli.sessions.resume.already_current",syntheticToolResult:"cli.sessions.synthetic_tool_result",warningIntegrityBreak:"cli.sessions.warning.integrity_break",warningSynthesized:"cli.sessions.warning.synthesized_results",warningTruncated:"cli.sessions.warning.truncated_messages",warningOversizeReplaced:"cli.sessions.warning.oversize_replaced",warningMicrocompactReplayed:"cli.sessions.warning.microcompact_replayed",warningPruneReplayed:"cli.sessions.warning.prune_replayed",warningUnknownKinds:"cli.sessions.warning.unknown_kinds",resumeStyleUnknown:"cli.sessions.resume.output_style_unknown",resumeUsageStale:"cli.sessions.resume.usage_stale",resumeGrantsRestored:"cli.sessions.resume.grants_restored",exportUsage:"cli.sessions.export.usage",exportUnknownFormat:"cli.sessions.export.unknown_format",exportNotFound:"cli.sessions.export.not_found",exportFailed:"cli.sessions.export.failed",exportWritten:"cli.sessions.export.written",usage:"cli.sessions.usage",pruneUsage:"cli.sessions.prune.usage",pruneInvalidNumber:"cli.sessions.prune.invalid_number",pruneCandidate:"cli.sessions.prune.candidate",pruneSidecarOnlyEntry:"cli.sessions.prune.sidecar_only_entry",pruneSidecarOnlySummary:"cli.sessions.prune.sidecar_only_summary",pruneBrokenEntry:"cli.sessions.prune.broken_entry",pruneBrokenHint:"cli.sessions.prune.broken_hint",pruneSummary:"cli.sessions.prune.summary",pruneKept:"cli.sessions.prune.kept",pruneNothing:"cli.sessions.prune.nothing",pruneDryRunHint:"cli.sessions.prune.dry_run_hint",pruneDeleted:"cli.sessions.prune.deleted",pruneSkippedLocked:"cli.sessions.prune.skipped_locked",pruneSkippedFresh:"cli.sessions.prune.skipped_fresh",pruneApplied:"cli.sessions.prune.applied",pruneAborted:"cli.sessions.prune.aborted"},qe=Object.values(S);import{mkdir as Ne,rename as Ce}from"node:fs/promises";import De from"node:path";var M="agent_notification",re="agent_notification_ack";function Ve(n){return n.channel==="report"?{type:M,version:1,channel:"report",agentId:n.agentId,notificationId:n.notificationId,message:n.message,wake:n.wake}:{type:M,version:1,channel:"settled",agentId:n.agentId,notificationId:n.notificationId,outcome:n.outcome,summary:n.summary}}function $e(n){return{type:re,version:1,agentId:n.agentId,notificationId:n.notificationId}}function _e(n){if(typeof n!="object"||n===null)return null;let e=n;if(e.type!==M||e.version!==1||typeof e.agentId!="string"||typeof e.notificationId!="string")return null;let t=e.channel;return t==="report"?typeof e.message!="string"||typeof e.wake!="boolean"?null:n:t==="settled"?typeof e.outcome!="string"||typeof e.summary!="string"?null:n:null}function Re(n){if(typeof n!="object"||n===null)return null;let e=n;return e.type!==re||e.version!==1||typeof e.agentId!="string"||typeof e.notificationId!="string"?null:n}function oe(n){let e=new Set;for(let r of n){if(r.kind!=="queue_ack")continue;let u=Re(r.payload);u!==null&&e.add(u.notificationId)}let t=[];for(let r of n){if(r.kind!=="queue_enqueue")continue;let u=_e(r.payload);u!==null&&(e.has(u.notificationId)||t.push({enqueueEventId:r.eventId,seq:r.seq,payload:u}))}return t}function T(n){let e=[];for(let t of n){if(t.kind!=="event")continue;let r=ee(t.payload);r!==null&&e.push({seq:t.seq,payload:r})}return e}function Ae(n){return n.filter(e=>e.payload.phase!=="started").length}async function we(n,e){let t=await X(n,e);if(t===null)return null;try{let r=await N(t,{repair:!1});return T(r.records)}catch{return null}}async function ze(n,e){let t=[...e.attempts];if(e.compactBoundary!==void 0&&Ae(t)<5){let r=await we(n,e.compactBoundary.sourceSessionId);r!==null&&(t=[...r,...t])}return ne(t.map(r=>r.payload))}var Pe=1440*60*1e3;function ie(n){let e=[];for(let t of n){if(t.kind!=="event")continue;let r=se(t.payload);r===null||r.type!==te||e.push({seq:t.seq,payload:r})}return e}var Oe=new Set(["allow","deny","ask"]);function We(n,e={}){let t=(e.now??(()=>new Date))().getTime(),r=e.ttlMs??Pe,u=[],o=new Set,c=0;for(let i of n){let{payload:l}=i,a=Date.parse(l.at);if(Number.isNaN(a)||t-a>r){c+=1;continue}if(!Oe.has(l.behavior)){c+=1;continue}let s=l.behavior;for(let p of l.rules){let m=`${s}\0${p}`;o.has(m)||(o.add(m),u.push({rule:p,behavior:s}))}}return{entries:u,skipped:c}}var ve=5;function Ze(n,e=ve){let t=n.map(r=>r.behavior==="allow"?r.rule:`${r.behavior}:${r.rule}`);return t.length<=e?t.join(", "):`${t.slice(0,e).join(", ")} …(+${t.length-e})`}var ae="session_event";var xe=()=>new Date;function nn(n,e,t){return e==="silenced"||e==="merged"&&n.phase===void 0?null:{type:ae,version:1,kind:n.kind,severity:n.severity,origin:n.origin,scope:n.scope,detail:n.detail,mode:n.mode,...n.phase!==void 0?{phase:n.phase}:{},count:n.count,occurredAt:n.occurredAt,change:e,at:(t??xe)().toISOString()}}function de(n){if(typeof n!="object"||n===null)return null;let e=n;if(e.type!==ae||e.version!==1||typeof e.kind!="string"||typeof e.scope!="string")return null;let t=e.phase;if(t!==void 0&&t!=="enter"&&t!=="exit")return null;let r=e.change;return r!=="new"&&r!=="merged"?null:n}function Ie(n){return n==="kernel"||n==="tui"||n==="providers"||n==="platform"||n==="tool"?n:"kernel"}function ue(n){let e=new Map;for(let t of n){if(t.kind!=="event")continue;let r=de(t.payload);if(r===null||r.phase===void 0)continue;let u=`${r.kind}\0${r.scope}`;r.phase==="enter"?e.has(u)||e.set(u,{kind:r.kind,scope:r.scope,origin:Ie(r.origin)}):e.delete(u)}return[...e.values()]}function ce(n){let e=null;for(let t of n){if(t.kind!=="event")continue;let r=de(t.payload);r===null||r.kind!=="model_switched"||r.scope!==""&&(e=r.scope)}return e}async function le(n,e){let t=await Te(n,e,{migrateToVault:!1,readOnly:!0});return t.ok?{ok:!0,messages:t.messages,warnings:t.warnings,...t.meta?.cwd!==void 0?{storedCwd:t.meta.cwd}:{},...t.compactBoundary!==void 0?{compactBoundary:t.compactBoundary}:{},...t.heldBy!==void 0?{heldBy:t.heldBy}:{}}:{ok:!1,reason:t.reason,detail:t.detail}}function Me(n){for(let e of n){if(e.branchId!==D||e.kind!=="compact_boundary")continue;let t=$.safeParse(e.payload);return t.success?t.data:void 0}}async function Te(n,e,t={}){let r=t.readOnly===!0,u=!r&&(t.migrateToVault??!0),o;try{o=A(n,e)}catch(s){return{ok:!1,reason:"not_found",detail:s instanceof Error?s.message:String(s)}}let c=!1;if(await k(o)===null){let s=V(n);if(s===null)return{ok:!1,reason:"not_found",detail:e};let p;try{p=A(s,e)}catch{return{ok:!1,reason:"not_found",detail:e}}if(await k(p)===null)return{ok:!1,reason:"not_found",detail:e};if(u)try{await Ne(De.dirname(o),{recursive:!0,mode:Q}),await Ce(p,o)}catch{o=p,c=!0}else o=p}let i=null,l;if(r)try{let s=await x(o);s.alive&&s.pid!==void 0&&(l={pid:s.pid,...s.host!==void 0?{host:s.host}:{},...s.startedAt!==void 0?{startedAt:s.startedAt}:{}})}catch(s){return{ok:!1,reason:"io_error",detail:s instanceof Error?s.message:String(s)}}else try{i=await I(o)}catch(s){return s instanceof v&&s.code==="SESSION_LOCKED"?{ok:!1,reason:"locked",detail:s.message}:{ok:!1,reason:"io_error",detail:s instanceof Error?s.message:String(s)}}let a=async()=>{i!==null&&await i.release()};try{let s=await N(o,r?{repair:!1}:{}),p=J(s.records),m=z(p.messages),y=K(m.messages,{resolvePersistedPath:Z(o),resolvePrunedPath:W(o)});if(m.messages.length===0)return await a(),{ok:!1,reason:"not_found",detail:e};let _=s.records.filter(b=>b.branchId===D&&(b.kind==="user_prompt"||b.kind==="assistant_message"||b.kind==="tool_result")&&b.visibility.model).length,R=s.records[s.records.length-1]?.eventId??null,f=[...p.warnings,...s.repairs];s.integrityBreakAt!==void 0&&f.push(E(S.warningIntegrityBreak,{index:s.integrityBreakAt})),s.unknownKinds!==void 0&&f.push(E(S.warningUnknownKinds,{count:s.unknownKinds.length,kinds:s.unknownKinds.join(", ")})),m.synthesizedResults>0&&f.push(E(S.warningSynthesized,{count:m.synthesizedResults})),m.droppedMessages>0&&f.push(E(S.warningTruncated,{count:m.droppedMessages})),y.clampReplacedCount>0&&f.push(E(S.warningOversizeReplaced,{count:y.clampReplacedCount})),y.pruneReplayedCount>0&&f.push(E(S.warningPruneReplayed,{count:y.pruneReplayedCount})),y.evictReplayedCount>0&&f.push(E(S.warningMicrocompactReplayed,{count:y.evictReplayedCount}));let w=i!==null&&!c&&p.warnings.length===0&&m.droppedMessages===0&&s.integrityBreakAt===void 0,d;try{d=await h(o)}catch{}let g=Me(s.records),B=oe(s.records),G=T(s.records),L=ie(s.records),q=ue(s.records),ke=d?.provider!==void 0&&d.provider!==""&&d.model!==void 0&&d.model!==""?`${d.provider}/${d.model}`:null,P=ce(s.records)??ke,O=H(s.records);return!w||i===null?(await a(),{ok:!0,sessionId:e,messages:y.messages,journalMessageCount:_,continuable:!1,...l!==void 0?{heldBy:l}:{},lastEventId:R,lastSeq:p.lastSeq,cursor:s.cursor,warnings:f,...d!==void 0?{meta:d}:{},...g!==void 0?{compactBoundary:g}:{},pendingAgentNotifications:B,compactionAttempts:G,sessionGrants:L,sessionEventConditions:q,...P!==null?{lastEffectiveModel:P}:{},...O!==void 0?{usageSnapshot:O}:{}}):{ok:!0,sessionId:e,messages:y.messages,journalMessageCount:_,continuable:!0,lock:i,lastEventId:R,lastSeq:p.lastSeq,cursor:s.cursor,warnings:f,...d!==void 0?{meta:d}:{},...g!==void 0?{compactBoundary:g}:{},pendingAgentNotifications:B,compactionAttempts:G,sessionGrants:L,sessionEventConditions:q,...P!==null?{lastEffectiveModel:P}:{},...O!==void 0?{usageSnapshot:O}:{}}}catch(s){return await a(),{ok:!1,reason:"corrupt",detail:s instanceof Error?s.message:String(s)}}}async function An(n,e,t,r=()=>new Date){let u=await le(n,e);if(!u.ok)return{ok:!1,reason:u.reason,detail:u.detail};let o;try{o=await h(A(n,e))}catch{o=void 0}let c=r().toISOString();if(t==="json"){let i={schemaVersion:1,sessionId:e,exportedAt:c,...o!==void 0?{meta:o}:{},warnings:u.warnings,messages:u.messages};return{ok:!0,text:JSON.stringify(Y(i),null,2)}}return{ok:!0,text:F(Ue(e,c,o,u.warnings,u.messages))}}function pe(n,e){return`> [image ${n}, base64 ${e.length} chars omitted]`}function Ue(n,e,t,r,u){let o=[`# Tansr session ${n}`,""];t!==void 0&&(t.title!==void 0&&o.push(`- title: ${t.title}`),o.push(`- cwd: ${t.cwd}`),o.push(`- created: ${t.createdAt}`),(t.provider!==void 0||t.model!==void 0)&&o.push(`- model: ${t.provider??"?"}/${t.model??"?"}`)),o.push(`- exported: ${e}`),r.length>0&&o.push("","## Warnings","",...r.map(c=>`- ${c}`));for(let c of u){o.push("","---","",`## ${c.role==="user"?"User":"Assistant"}`,"");for(let i of c.blocks)switch(i.t){case"text":o.push(i.text,"");break;case"thinking":o.push("> _[thinking]_",...i.text.split(`
|
|
5
|
-
`).map(l=>`> ${l}`),"");break;case"opaque":o.push(`> [opaque reasoning payload · provider: ${i.provider}]`,"");break;case"tool_call":o.push(`**Tool call — ${i.name}** (\`${i.id}\`)`,"","````json",JSON.stringify(i.args,null,2)??"null","````","");break;case"tool_result":{o.push(`**Tool result** (\`${i.callId}\`)${i.isError===!0?" — error":""}`,"");for(let l of i.content)l.t==="text"?o.push("````",l.text,"````",""):o.push(pe(l.mime,l.data),"");break}case"image":o.push(pe(i.mime,i.data),"");break}}return o.join(`
|
|
6
|
-
`)+`
|
|
7
|
-
`}import{readdir as fe,rm as Be,stat as ye}from"node:fs/promises";import U from"node:path";var Ge=90,Le=500;async function ge(n){let e=0,t;try{t=await fe(n,{withFileTypes:!0})}catch{return 0}for(let r of t){let u=U.join(n,r.name);if(r.isDirectory())e+=await ge(u);else try{e+=(await ye(u)).size}catch{}}return e}function Se(n){try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}async function C(n,e){try{return(await x(n,{isPidAlive:e})).alive}catch{return!1}}function Ee(n){let e=new Date(n);return e.setHours(0,0,0,0),e.getTime()}async function me(n){try{return await ye(n)}catch{return null}}async function he(n){let e=U.join(n,"sessions"),t;try{t=(await fe(e,{withFileTypes:!0})).filter(i=>i.isDirectory()).map(i=>i.name)}catch{return{valid:[],sidecarOnly:[],broken:[]}}let r=[],u=[],o=[];for(let c of t){let i=U.join(e,c),l=await ge(i),a=await k(i),s=await me(j(i)),p=(await me(i))?.mtimeMs??0;if(s===null&&a===null){u.push({name:c,dir:i,mtimeMs:p,bytes:l});continue}try{let m=await h(i);if(a===null)throw new Error("journal_missing");if(m.sessionId!==c)throw new Error("meta_mismatch");r.push({sessionId:c,dir:i,updatedAt:a.mtimeMs,bytes:l})}catch{o.push({name:c,dir:i,mtimeMs:p,bytes:l})}}return{valid:r,sidecarOnly:u,broken:o}}async function In(n){let{valid:e,sidecarOnly:t,broken:r}=await he(n),u=e.reduce((o,c)=>o+c.bytes,0)+t.reduce((o,c)=>o+c.bytes,0)+r.reduce((o,c)=>o+c.bytes,0);return{sessions:e.length,brokenDirs:r.length,sidecarOnlyDirs:t.length,totalBytes:u}}async function Nn(n,e={}){let t=e.keepDays??Ge,r=e.keepLast??Le,u=e.now??Date.now(),o=e.isPidAlive??Se,c=new Set(e.protectSessionIds??[]),{valid:i,sidecarOnly:l,broken:a}=await he(n),s=[...i].sort((d,g)=>g.updatedAt-d.updatedAt),p=new Set;for(let d of s.slice(0,r))p.add(d.sessionId);let m=u-t*864e5,y=Ee(u),_=0;for(let d of s)(d.updatedAt>=m||d.updatedAt>=y)&&p.add(d.sessionId),c.has(d.sessionId)&&p.add(d.sessionId),!p.has(d.sessionId)&&await C(d.dir,o)&&(p.add(d.sessionId),_+=1);let R=i.filter(d=>!p.has(d.sessionId)).sort((d,g)=>d.updatedAt-g.updatedAt),f=new Set;for(let d of l)(d.mtimeMs>=m||d.mtimeMs>=y)&&f.add(d.name),c.has(d.name)&&f.add(d.name),!f.has(d.name)&&await C(d.dir,o)&&f.add(d.name);let w=l.filter(d=>!f.has(d.name)).sort((d,g)=>d.mtimeMs-g.mtimeMs);return{candidates:R,sidecarOnly:w,totalSidecarOnly:l.length,sidecarOnlyKeptCount:l.length-w.length,broken:a,totalSessions:i.length,keptCount:i.length-R.length,inUseCount:_}}async function Cn(n,e={}){let t=e.isPidAlive??Se,r=e.now??Date.now(),u=e.rmDir??(a=>Be(a,{recursive:!0,force:!0})),o=[],c=[],i=[],l=Ee(r);for(let a of n.candidates){let s;try{s=await I(a.dir,{isPidAlive:t,staleMs:1/0})}catch(m){if(m instanceof v&&m.code==="SESSION_LOCKED"){c.push(a.sessionId);continue}return{deleted:o,skippedLocked:c,skippedFresh:i,aborted:{name:a.sessionId,message:m instanceof Error?m.message:String(m)}}}let p=(await k(a.dir))?.mtimeMs;if(p===void 0||p>=l){await s.release(),i.push(a.sessionId);continue}try{await u(a.dir)}catch(m){try{await s.release()}catch{}return{deleted:o,skippedLocked:c,skippedFresh:i,aborted:{name:a.sessionId,message:m instanceof Error?m.message:String(m)}}}await s.release(),o.push({name:a.sessionId,bytes:a.bytes}),e.onDeleted?.({name:a.sessionId,bytes:a.bytes})}for(let a of n.sidecarOnly)if(!(a.mtimeMs>=l)&&!await C(a.dir,t)){try{await u(a.dir)}catch(s){return{deleted:o,skippedLocked:c,skippedFresh:i,aborted:{name:a.name,message:s instanceof Error?s.message:String(s)}}}o.push({name:a.name,bytes:a.bytes}),e.onDeleted?.({name:a.name,bytes:a.bytes})}if(e.includeBroken===!0){for(let a of n.broken)if(!(a.mtimeMs>=l)&&!await C(a.dir,t)){try{await u(a.dir)}catch(s){return{deleted:o,skippedLocked:c,skippedFresh:i,aborted:{name:a.name,message:s instanceof Error?s.message:String(s)}}}o.push({name:a.name,bytes:a.bytes}),e.onDeleted?.({name:a.name,bytes:a.bytes})}}return{deleted:o,skippedLocked:c,skippedFresh:i}}export{S as a,Ve as b,$e as c,ze as d,We as e,Ze as f,nn as g,le as h,Te as i,An as j,Ge as k,Le as l,In as m,Nn as n,Cn as o};
|
|
8
|
-
//# sourceMappingURL=tansr-chunk-DN22GXHD.mjs.map
|
package/tansr-chunk-F7C6ITED.mjs
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { createRequire as __tansrCreateRequire } from 'module';const require=__tansrCreateRequire(import.meta.url);
|
|
2
|
-
import { fileURLToPath as __tansrFileURLToPath } from 'url';import { dirname as __tansrDirname } from 'path';
|
|
3
|
-
const __filename=__tansrFileURLToPath(import.meta.url);const __dirname=__tansrDirname(__filename);
|
|
4
|
-
var j=Object.freeze({invalid_options:"invalid_options",invalid_input:"invalid_input",bytes_exceeded:"bytes_exceeded",invalid_utf8:"invalid_utf8",unexpected_end:"unexpected_end",unexpected_token:"unexpected_token",trailing_data:"trailing_data",invalid_number:"invalid_number",unsafe_integer:"unsafe_integer",invalid_string:"invalid_string",lone_surrogate:"lone_surrogate",invalid_key:"invalid_key",duplicate_key:"duplicate_key",depth_exceeded:"depth_exceeded",nodes_exceeded:"nodes_exceeded",unsupported_value:"unsupported_value",invalid_property:"invalid_property",cyclic_reference:"cyclic_reference",not_canonical:"not_canonical"}),P=Object.freeze(["whitespace","key_order","escape"]),c=class extends Error{code;path;offset;reason;constructor(t,n,e={}){super(n),this.name="CanonicalError",this.code=t,e.path!==void 0&&(this.path=e.path),e.offset!==void 0&&(this.offset=e.offset),e.reason!==void 0&&(this.reason=e.reason)}toJSON(){let t={code:this.code,message:this.message};return this.path!==void 0&&(t.path=this.path),this.offset!==void 0&&(t.offset=this.offset),this.reason!==void 0&&(t.reason=this.reason),t}};function R(r){return typeof r=="number"?String(r):r.replaceAll("~","~0").replaceAll("/","~1")}function d(r,t){return r+"/"+R(t)}var b=32,_=1e5,x=/^[\x21-\x7e]+$/,I=Object.freeze(["maxBytes","maxDepth","maxNodes","isProxy"]),T=Object.freeze(["maxBytes","maxDepth","maxNodes"]),B=Object.getPrototypeOf(Uint8Array.prototype),L=Object.getOwnPropertyDescriptor(B,"byteLength").get;function u(r){return r instanceof Uint8Array}function N(r){return L.call(r)}function h(r){throw new c("invalid_options",r)}function g(r,t,n,e,i){if(!Object.hasOwn(r,t)||r[t]===void 0)return i===void 0&&h(`options.${t} is required`),i;let s=r[t];return(typeof s!="number"||!Number.isSafeInteger(s)||s<n||s>e)&&h(`options.${t} must be a safe integer in [${n}, ${e}]`),s}function m(r,t){(r===null||typeof r!="object"||Array.isArray(r))&&h("options must be an object");let n=t==="encode"?I:T;for(let s of Reflect.ownKeys(r))(typeof s!="string"||!n.includes(s))&&h(`unknown option ${String(s)}`);let e=r,i=null;return t==="encode"&&e.isProxy!==void 0&&(typeof e.isProxy!="function"&&h("options.isProxy must be a function"),i=e.isProxy),{maxBytes:g(e,"maxBytes",1,Number.MAX_SAFE_INTEGER),maxDepth:g(e,"maxDepth",0,b,b),maxNodes:g(e,"maxNodes",1,_,_),isProxy:i}}var $=/[\ud800-\udfff]/;function f(r){if(!$.test(r))return!0;for(let t=0;t<r.length;t++){let n=r.charCodeAt(t);if(n>=55296&&n<=56319){let e=r.charCodeAt(++t);if(!(e>=56320&&e<=57343))return!1}else if(n>=56320&&n<=57343)return!1}return!0}function O(r){let t=r.length,n=(i,s=128,o=191)=>i<t&&r[i]>=s&&r[i]<=o,e=0;for(;e<t;){let i=r[e];if(i<=127){e+=1;continue}if(i>=194&&i<=223){if(n(e+1)){e+=2;continue}return e}if(i>=224&&i<=239){let s=i===224?160:128,o=i===237?159:191;if(n(e+1,s,o)&&n(e+2)){e+=3;continue}return e}if(i>=240&&i<=244){let s=i===240?144:128,o=i===244?143:191;if(n(e+1,s,o)&&n(e+2)&&n(e+3)){e+=4;continue}return e}return e}return-1}var z=/^[\x00-\x7f]*$/;function p(r){if(z.test(r))return r.length;let t=0;for(let n=0;n<r.length;n++){let e=r.charCodeAt(n);if(e<128)t+=1;else if(e<2048)t+=2;else if(e>=55296&&e<=56319){let i=r.charCodeAt(n+1);i>=56320&&i<=57343?(t+=4,n++):t+=3}else t+=3}return t}var F=new TextEncoder,C=class{maxBytes;maxDepth;maxNodes;isProxy;parts=[];used=0;nodes=0;ancestors=new Set;constructor({maxBytes:t,maxDepth:n,maxNodes:e,isProxy:i}){this.maxBytes=t,this.maxDepth=n,this.maxNodes=e,this.isProxy=i}fail(t,n,e){throw new c(t,n,{path:e})}ascii(t,n){this.used+=t.length,this.used>this.maxBytes&&this.fail("bytes_exceeded",`encoded bytes exceed maxBytes ${this.maxBytes}`,n),this.parts.push(t)}quoted(t,n){t.length>this.maxBytes-this.used&&this.fail("bytes_exceeded",`encoded bytes exceed maxBytes ${this.maxBytes}`,n),this.used+=p(t),this.used>this.maxBytes&&this.fail("bytes_exceeded",`encoded bytes exceed maxBytes ${this.maxBytes}`,n),this.parts.push(t)}number(t,n){Number.isInteger(t)||this.fail("invalid_number","number must be an integer (no fraction, NaN or Infinity)",n),Number.isSafeInteger(t)||this.fail("unsafe_integer","integer exceeds 2^53-1",n),(t<0||Object.is(t,-0))&&this.fail("invalid_number","number must be nonnegative (no -0)",n),this.ascii(String(t),n)}string(t,n){f(t)||this.fail("lone_surrogate","string contains an unpaired surrogate",n),this.quoted(JSON.stringify(t),n)}dataDescriptor(t,n,e){let i=Object.getOwnPropertyDescriptor(t,n);return(i===void 0||!Object.hasOwn(i,"value")||!i.enumerable)&&this.fail("invalid_property","properties must be enumerable own data properties (no accessor / hole)",e),i.value}array(t,n,e){let i=Object.getOwnPropertyDescriptor(t,"length")?.value;(typeof i!="number"||!Number.isSafeInteger(i))&&this.fail("invalid_property","array length is not an integer",e),this.nodes+i>this.maxNodes&&this.fail("nodes_exceeded",`node count exceeds maxNodes ${this.maxNodes}`,e),Reflect.ownKeys(t).length!==i+1&&this.fail("invalid_property","array must be dense without extra own properties",e),this.ascii("[",e);for(let o=0;o<i;o++){let a=d(e,o),l=this.dataDescriptor(t,String(o),a);o>0&&this.ascii(",",e),this.write(l,n+1,a)}this.ascii("]",e)}object(t,n,e){let i=Object.getPrototypeOf(t);i!==Object.prototype&&i!==null&&this.fail("unsupported_value","objects must be plain (Object.prototype or null prototype)",e);let s=Reflect.ownKeys(t);for(let a of s)typeof a!="string"&&this.fail("invalid_property","symbol keys are not representable",e);let o=s.sort();this.ascii("{",e);for(let a=0;a<o.length;a++){let l=o[a],y=d(e,l),U=this.dataDescriptor(t,l,y);x.test(l)||this.fail("invalid_key","keys must be nonempty printable ASCII (0x21-0x7e)",y),a>0&&this.ascii(",",e),this.ascii(JSON.stringify(l)+":",y),this.write(U,n+1,y)}this.ascii("}",e)}write(t,n,e){if(n>this.maxDepth&&this.fail("depth_exceeded",`nesting depth exceeds maxDepth ${this.maxDepth}`,e),++this.nodes>this.maxNodes&&this.fail("nodes_exceeded",`node count exceeds maxNodes ${this.maxNodes}`,e),t===null){this.ascii("null",e);return}switch(typeof t){case"string":this.string(t,e);return;case"boolean":this.ascii(t?"true":"false",e);return;case"number":this.number(t,e);return;case"object":break;default:this.fail("unsupported_value",`${typeof t} is not representable`,e)}let i=t;this.isProxy!==null&&this.isProxy(i)&&this.fail("unsupported_value","Proxy objects are not representable",e),this.ancestors.has(i)&&this.fail("cyclic_reference","value contains itself",e),this.ancestors.add(i),Array.isArray(i)?this.array(i,n,e):this.object(i,n,e),this.ancestors.delete(i)}};function v(r,t){let n=new C(m(t,"encode"));return n.write(r,0,""),n.parts.join("")}function H(r,t){return F.encode(v(r,t))}var K=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}),A=/"(?:[^"\\\u0000-\u001f]|\\(?:["\\/bfnrt]|u[0-9a-fA-F]{4}))*"/y,J=/^[0-9a-fA-F]{4}$/,M=new Set([8,9,10,12,13]),E=r=>r===32||r===9||r===10||r===13,D=r=>r>=48&&r<=57,w=class{text;strict;maxDepth;maxNodes;at=0;nodes=0;violation=null;constructor(t,n,{maxDepth:e,maxNodes:i}){this.text=t,this.strict=n,this.maxDepth=e,this.maxNodes=i}byteOffset(t){return p(this.text.slice(0,t))}fail(t,n,e,i=this.at){throw new c(t,n,{path:e,offset:this.byteOffset(i)})}note(t,n,e){this.strict&&this.violation===null&&(this.violation={reason:t,path:n,at:e})}document(){let t=this.value(0,"");if(this.whitespace(""),this.at!==this.text.length&&this.fail("trailing_data","unexpected bytes after the root value",""),this.violation!==null){let{reason:n,path:e,at:i}=this.violation;throw new c("not_canonical",`input is valid but not canonical (${n})`,{path:e,offset:this.byteOffset(i),reason:n})}return t}whitespace(t){let n=this.at;for(;this.at<this.text.length&&E(this.text.charCodeAt(this.at));)this.at++;this.at!==n&&this.note("whitespace",t,n)}value(t,n){this.whitespace(n),t>this.maxDepth&&this.fail("depth_exceeded",`nesting depth exceeds maxDepth ${this.maxDepth}`,n),++this.nodes>this.maxNodes&&this.fail("nodes_exceeded",`node count exceeds maxNodes ${this.maxNodes}`,n),this.at>=this.text.length&&this.fail("unexpected_end","expected a value",n);let e=this.text.charCodeAt(this.at);if(e===34)return this.string(n);if(e===123)return this.object(t,n);if(e===91)return this.array(t,n);if(e===116)return this.literal("true",!0,n);if(e===102)return this.literal("false",!1,n);if(e===110)return this.literal("null",null,n);if(D(e))return this.number(n);(e===45||e===43||e===46)&&this.fail("invalid_number","number token must be 0 or [1-9][0-9]* (no sign, fraction or exponent)",n),this.fail("unexpected_token","unexpected character at value position",n)}literal(t,n,e){if(this.text.startsWith(t,this.at))return this.at+=t.length,n;t.startsWith(this.text.slice(this.at))&&this.fail("unexpected_end",`truncated literal ${t}`,e),this.fail("unexpected_token",`invalid literal (expected ${t})`,e)}number(t){let n=this.at;if(this.text.charCodeAt(this.at)===48)this.at++;else for(;this.at<this.text.length&&D(this.text.charCodeAt(this.at));)this.at++;if(this.at<this.text.length){let i=this.text.charCodeAt(this.at);i===44||i===93||i===125||E(i)||this.fail("invalid_number","number token must be 0 or [1-9][0-9]* (no leading zero, fraction or exponent)",t,n)}let e=Number(this.text.slice(n,this.at));return Number.isSafeInteger(e)||this.fail("unsafe_integer","integer exceeds 2^53-1",t,n),e}string(t,n=!1){let e=this.at;A.lastIndex=e;let i=A.exec(this.text);i===null&&this.diagnoseString(t,e);let s=i[0];this.at=A.lastIndex;let o=JSON.parse(s);return f(o)||this.fail("lone_surrogate","string contains an unpaired surrogate",t,e),this.strict&&this.violation===null&&s.includes("\\")&&this.escapes(s,e,n?d(t,o):t),o}diagnoseString(t,n){let e=this.text,i=n+1;for(;i<e.length;){let s=e.charCodeAt(i);if(s===34)break;if(s<32&&this.fail("invalid_string","unescaped control character in string",t,i),s===92){if(i+1>=e.length&&this.fail("unexpected_end","input ends inside an escape sequence",t,i),e.charCodeAt(i+1)===117){let a=e.slice(i+2,i+6);J.test(a)||(i+6>e.length&&this.fail("unexpected_end","input ends inside a \\u escape",t,i),this.fail("invalid_string","\\u escape requires four hexadecimal digits",t,i)),i+=6;continue}'"\\/bfnrt'.includes(e[i+1])||this.fail("invalid_string","invalid escape sequence",t,i),i+=2;continue}i++}this.fail("unexpected_end","unterminated string",t,n)}escapes(t,n,e){for(let i=1;i<t.length-1;i++){if(t.charCodeAt(i)!==92)continue;let s=t[i+1];if(s==="u"){let o=t.slice(i+2,i+6),a=Number.parseInt(o,16);if(o!==o.toLowerCase()||a>=32||M.has(a)){this.note("escape",e,n+i);return}i+=5}else if(s==="/"){this.note("escape",e,n+i);return}else i+=1}}expect(t,n,e){this.at>=this.text.length&&this.fail("unexpected_end",n,e),this.text.charCodeAt(this.at)!==t&&this.fail("unexpected_token",n,e),this.at++}object(t,n){this.at++;let e=Object.create(null);if(this.whitespace(n),this.at>=this.text.length&&this.fail("unexpected_end","unterminated object",n),this.text.charCodeAt(this.at)===125)return this.at++,e;let i=null;for(;;){this.whitespace(n),this.at>=this.text.length&&this.fail("unexpected_end","unterminated object",n),this.text.charCodeAt(this.at)!==34&&this.fail("unexpected_token","expected a string key",n);let s=this.at,o=this.string(n,!0),a=d(n,o);x.test(o)||this.fail("invalid_key","keys must be nonempty printable ASCII (0x21-0x7e)",a,s),Object.hasOwn(e,o)&&this.fail("duplicate_key","duplicate key after escape decoding",a,s),i!==null&&o<i&&this.note("key_order",a,s),i=o,this.whitespace(n),this.expect(58,'expected ":" after key',a),e[o]=this.value(t+1,a),this.whitespace(n),this.at>=this.text.length&&this.fail("unexpected_end","unterminated object",n);let l=this.text.charCodeAt(this.at++);if(l===125)return e;l!==44&&this.fail("unexpected_token",'expected "," or "}"',n,this.at-1)}}array(t,n){this.at++;let e=[];if(this.whitespace(n),this.at>=this.text.length&&this.fail("unexpected_end","unterminated array",n),this.text.charCodeAt(this.at)===93)return this.at++,e;for(let i=0;;i++){e.push(this.value(t+1,d(n,i))),this.whitespace(n),this.at>=this.text.length&&this.fail("unexpected_end","unterminated array",n);let s=this.text.charCodeAt(this.at++);if(s===93)return e;s!==44&&this.fail("unexpected_token",'expected "," or "]"',n,this.at-1)}}};function X(r,t,n){let e=m(t,"decode"),i;if(typeof r=="string"){if(p(r)>e.maxBytes)throw new c("bytes_exceeded",`input exceeds maxBytes ${e.maxBytes}`,{path:"",offset:0});i=r}else if(u(r)){if(N(r)>e.maxBytes)throw new c("bytes_exceeded",`input exceeds maxBytes ${e.maxBytes}`,{path:"",offset:0});try{i=K.decode(r)}catch{throw new c("invalid_utf8","input is not valid UTF-8",{path:"",offset:Math.max(0,O(r))})}}else throw new c("invalid_input","input must be a Uint8Array or a string");return new w(i,n,e).document()}function q(r,t){return X(r,t,!1)}var Y=new TextEncoder,G=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function k(r){if(!u(r)||r.length!==32)throw new c("invalid_options","sha256 must return 32 bytes");return r}function S(r,t){if(typeof r!="string"||r.length===0||r.includes("\0")||!f(r))throw new c("invalid_options","domain must be a nonempty well-formed string without U+0000");if(!u(t))throw new c("invalid_input","bytes must be a Uint8Array");let n=Y.encode(r),e=new Uint8Array(n.length+1+t.length);return e.set(n,0),e[n.length]=0,e.set(t,n.length+1),e}function V(r,t,n){if(typeof n!="function")throw new c("invalid_options","sha256 must be a function");let e=n(S(r,t));return e!==null&&typeof e=="object"&&typeof e.then=="function"?e.then(k):k(e)}function W(r){if(!u(r))throw new c("invalid_input","bytes must be a Uint8Array");let t="";for(let n=0;n<r.length;n++)t+=G[r[n]];return t}export{c as a,v as b,H as c,q as d,V as e,W as f};
|
|
5
|
-
//# sourceMappingURL=tansr-chunk-F7C6ITED.mjs.map
|
package/tansr-chunk-GDJ5YVNY.mjs
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { createRequire as __tansrCreateRequire } from 'module';const require=__tansrCreateRequire(import.meta.url);
|
|
2
|
-
import { fileURLToPath as __tansrFileURLToPath } from 'url';import { dirname as __tansrDirname } from 'path';
|
|
3
|
-
const __filename=__tansrFileURLToPath(import.meta.url);const __dirname=__tansrDirname(__filename);
|
|
4
|
-
import{t as S}from"./tansr-chunk-IZICOKKF.mjs";import{I as y,J as p,L as A}from"./tansr-chunk-ZQ3ZK7IL.mjs";import{Ib as m}from"./tansr-chunk-QWGSXFEJ.mjs";import{existsSync as C}from"node:fs";import M from"node:path";function l(e){return M.join(e,y)}function G(e){return A({resolveDir:()=>l(S(e.storageRoot,e.currentSessionId())),...e.onPut!==void 0?{onPut:e.onPut}:{}})}function L(e){let t=l(e);return r=>{let n=p(t,"prune",r);return C(n)?n:void 0}}import{existsSync as x}from"node:fs";function j(e){return({content:t})=>{let r=e.put({content:t,kind:"tool-result"});return r!==void 0?{path:r.path}:void 0}}function K(e){let t=l(e);return(r,n)=>{let o=p(t,"content",n);return x(o)?o:void 0}}function H(e={}){let t=e.maxRecent??5,r=[],n=0,o=0,a=0,f=()=>{if(e.scheme===void 0)return{};try{let i=e.scheme();return i===void 0?{}:{schemeId:i.id,schemeFingerprint:i.fingerprint}}catch{return{}}},g=i=>{r.unshift(i),r.length>t&&(r.length=t),i.ok?(n+=1,a+=i.reclaimedTokens??0):i.reason!=="nothing_to_compact"&&(o+=1)};return{observer:{onCompactionFinished:i=>{try{let{outcome:s}=i;if(s===void 0)return;let P=i.durationMs??0,N=s.ok?{trigger:i.trigger,ok:!0,reclaimedTokens:Math.max(0,s.measurementBefore.contextTokens-s.measurementAfter.contextTokens),durationMs:P,...f()}:{trigger:i.trigger,ok:!1,reason:s.reason,...s.errorKind!==void 0?{errorKind:s.errorKind}:{},durationMs:P,...f()};g(N)}catch{}}},snapshot:()=>r.length===0?void 0:{recent:[...r],total:{succeeded:n,failed:o,reclaimedTokens:a}},restore(i){r=[],n=0,o=0,a=0;for(let s of i)g({...s})}}}var u="compaction_attempt";var I=()=>new Date;function T(e){return e!==void 0?{schemeId:e.id,schemeFingerprint:e.fingerprint}:{}}function X(e,t,r){return{type:u,version:1,phase:"started",compactionId:e.compactionId,trigger:e.trigger,...e.mechanism!==void 0?{mechanism:e.mechanism}:{},...e.beforeTokens!==void 0?{beforeTokens:e.beforeTokens}:{},...T(t),...e.agentId!==void 0?{agentId:e.agentId}:{},at:(r??I)().toISOString()}}function Q(e,t,r){let n=e.outcome,o={type:u,version:1,compactionId:e.compactionId,trigger:e.trigger,...e.mechanism!==void 0?{mechanism:e.mechanism}:{},...e.durationMs!==void 0?{durationMs:e.durationMs}:{},...T(t),...e.agentId!==void 0?{agentId:e.agentId}:{},at:(r??I)().toISOString()};return n===void 0?{...o,phase:"succeeded"}:n.ok?{...o,phase:"succeeded",beforeTokens:n.measurementBefore.contextTokens,afterTokens:n.measurementAfter.contextTokens}:{...o,phase:"failed",beforeTokens:n.measurementBefore.contextTokens,reason:n.reason,...n.errorKind!==void 0?{errorKind:n.errorKind}:{}}}function z(e){if(typeof e!="object"||e===null)return null;let t=e;if(t.type!==u||t.version!==1)return null;let r=t.phase;return r!=="started"&&r!=="succeeded"&&r!=="failed"||typeof t.compactionId!="string"||typeof t.trigger!="string"||typeof t.at!="string"?null:e}function J(e){let t=[];for(let r of e)if(r.phase!=="started"){if(r.phase==="succeeded"){if(r.beforeTokens===void 0||r.afterTokens===void 0)continue;t.push({trigger:r.trigger,ok:!0,reclaimedTokens:Math.max(0,r.beforeTokens-r.afterTokens),durationMs:r.durationMs??0,...r.schemeId!==void 0?{schemeId:r.schemeId}:{},...r.schemeFingerprint!==void 0?{schemeFingerprint:r.schemeFingerprint}:{}});continue}t.push({trigger:r.trigger,ok:!1,...r.reason!==void 0?{reason:r.reason}:{},...r.errorKind!==void 0?{errorKind:r.errorKind}:{},durationMs:r.durationMs??0,...r.schemeId!==void 0?{schemeId:r.schemeId}:{},...r.schemeFingerprint!==void 0?{schemeFingerprint:r.schemeFingerprint}:{}})}return t}var E="permission_mode_change",h="session_grant",_="approval_requested",O="approval_decided",R="session_grants_restored",d=1;var c=()=>new Date;function $(e){return{type:E,version:d,from:e.from,to:e.to,trigger:e.trigger,at:(e.now??c)().toISOString()}}function ee(e){let t={type:h,version:d,rules:[...e.rules],behavior:e.behavior,origin:e.origin,...e.scope!==void 0?{scope:e.scope}:{},...e.toolName!==void 0?{toolName:e.toolName}:{},at:(e.now??c)().toISOString()};return m(t)}function te(e){let t={type:R,version:d,entries:e.entries.map(r=>({...r})),skipped:e.skipped,at:(e.now??c)().toISOString()};return m(t)}function re(e){return{type:_,version:d,callId:e.callId,toolName:e.toolName,at:(e.now??c)().toISOString()}}function ne(e){let t=(e.now??c)();return{type:O,version:d,callId:e.callId,toolName:e.toolName,decision:e.decision,...e.scope!==void 0?{scope:e.scope}:{},...e.cancelled===!0?{cancelled:!0}:{},...e.requestedAtMs!==void 0?{elapsedMs:Math.max(0,t.getTime()-e.requestedAtMs)}:{},at:t.toISOString()}}function oe(e){if(typeof e!="object"||e===null)return null;let t=e;if(t.version!==d||typeof t.at!="string")return null;let r=t.type;return r===E?typeof t.from!="string"||typeof t.to!="string"||typeof t.trigger!="string"?null:e:r===h?!Array.isArray(t.rules)||!t.rules.every(n=>typeof n=="string")||typeof t.behavior!="string"||typeof t.origin!="string"?null:e:r===_?typeof t.callId!="string"||typeof t.toolName!="string"?null:e:r===O?typeof t.callId!="string"||typeof t.toolName!="string"||typeof t.decision!="string"?null:e:r===R?!Array.isArray(t.entries)||!t.entries.every(n=>typeof n=="object"&&n!==null&&typeof n.rule=="string"&&typeof n.behavior=="string")||typeof t.skipped!="number"?null:e:null}var k=128;function ie(e=k){let t=new Map,r=()=>{if(t.size<=e)return;let n=t.keys().next();n.done||t.delete(n.value)};return{markRequested(n,o){t.set(n,{requestedAtMs:o}),r()},markDecided(n,o){let a=t.get(n);a!==void 0&&(a.decidedAtMs=o)},consume(n){let o=t.get(n);if(o!==void 0&&(t.delete(n),o.decidedAtMs!==void 0))return{requestedAt:new Date(o.requestedAtMs).toISOString(),decidedAt:new Date(o.decidedAtMs).toISOString()}}}}export{G as a,L as b,j as c,K as d,H as e,X as f,Q as g,z as h,J as i,h as j,$ as k,ee as l,te as m,re as n,ne as o,oe as p,ie as q};
|
|
5
|
-
//# sourceMappingURL=tansr-chunk-GDJ5YVNY.mjs.map
|