@tansr/cli 0.10.2 → 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.
Files changed (133) hide show
  1. package/package.json +1 -1
  2. package/tansr-artifacts.json +1222 -830
  3. package/tansr-bg-A35DNHK2.mjs +5 -0
  4. package/tansr-chunk-2CIB4KCJ.mjs +5 -0
  5. package/{tansr-chunk-XXBNISJJ.mjs → tansr-chunk-2HZJSKHM.mjs} +2 -2
  6. package/{tansr-chunk-E67N3BDI.mjs → tansr-chunk-2PB54HDR.mjs} +2 -2
  7. package/tansr-chunk-33QZBUL6.mjs +6 -0
  8. package/tansr-chunk-3YSQG6KY.mjs +5 -0
  9. package/tansr-chunk-4DAH4AIH.mjs +7 -0
  10. package/{tansr-chunk-S77B4PI7.mjs → tansr-chunk-4IWNKAT5.mjs} +2 -2
  11. package/tansr-chunk-4YAEV3T6.mjs +9 -0
  12. package/tansr-chunk-546BDI3V.mjs +7 -0
  13. package/tansr-chunk-6N333TUL.mjs +241 -0
  14. package/{tansr-chunk-ZY3IR67Q.mjs → tansr-chunk-6QKU3GNA.mjs} +2 -2
  15. package/tansr-chunk-AHUB2IHT.mjs +5 -0
  16. package/tansr-chunk-AOH7YPF3.mjs +8 -0
  17. package/{tansr-chunk-C6COFFZK.mjs → tansr-chunk-B2O4DB4K.mjs} +2 -2
  18. package/tansr-chunk-C2NTVBEY.mjs +5 -0
  19. package/{tansr-chunk-UCG4D6ER.mjs → tansr-chunk-C75DEEUJ.mjs} +2 -2
  20. package/tansr-chunk-ECYZ457U.mjs +5 -0
  21. package/tansr-chunk-EFN24XG3.mjs +25 -0
  22. package/tansr-chunk-ENRIN7EG.mjs +7 -0
  23. package/{tansr-chunk-RVSBSUXE.mjs → tansr-chunk-ITZBYACC.mjs} +2 -2
  24. package/{tansr-chunk-J72JGEKH.mjs → tansr-chunk-IZZYKHSW.mjs} +3 -3
  25. package/tansr-chunk-JIC3VWLQ.mjs +252 -0
  26. package/tansr-chunk-JTGWG4BG.mjs +32 -0
  27. package/tansr-chunk-LA3LGOYQ.mjs +11 -0
  28. package/tansr-chunk-MAMODDQN.mjs +5 -0
  29. package/tansr-chunk-N644DEOO.mjs +5 -0
  30. package/tansr-chunk-NQOYEFEE.mjs +5 -0
  31. package/tansr-chunk-O7P4OFK7.mjs +7 -0
  32. package/tansr-chunk-OEHA7T4Q.mjs +26 -0
  33. package/{tansr-chunk-CI7LFRTK.mjs → tansr-chunk-OKNSOZDU.mjs} +7 -7
  34. package/tansr-chunk-OT4KIQLR.mjs +9 -0
  35. package/tansr-chunk-OUOTEH4A.mjs +5 -0
  36. package/tansr-chunk-Q3XDAUKT.mjs +65 -0
  37. package/tansr-chunk-RFH7OCN6.mjs +5 -0
  38. package/tansr-chunk-RUYIVG72.mjs +12 -0
  39. package/tansr-chunk-SCFXBKV6.mjs +8 -0
  40. package/tansr-chunk-SHLU4JN2.mjs +5 -0
  41. package/{tansr-chunk-M774GK3P.mjs → tansr-chunk-SIV2666W.mjs} +2 -2
  42. package/tansr-chunk-SX3XZNN6.mjs +6 -0
  43. package/tansr-chunk-SXNTYWJY.mjs +8 -0
  44. package/tansr-chunk-UVL2XWKL.mjs +5 -0
  45. package/tansr-chunk-V4HGMAJS.mjs +375 -0
  46. package/{tansr-chunk-OB47UYHK.mjs → tansr-chunk-W2WIN3M2.mjs} +2 -2
  47. package/tansr-chunk-WAYVH5ON.mjs +5 -0
  48. package/tansr-chunk-WPKFARCU.mjs +11 -0
  49. package/{tansr-chunk-726Y5F3M.mjs → tansr-chunk-YEYFEVYF.mjs} +2 -2
  50. package/tansr-chunk-YK3CE3JM.mjs +5 -0
  51. package/tansr-chunk-YOSRXZWY.mjs +5 -0
  52. package/tansr-compaction-history-LZXZTWBV.mjs +5 -0
  53. package/tansr-compaction-log-H2SPLK24.mjs +5 -0
  54. package/tansr-indexed-CPYJVPFI.mjs +5 -0
  55. package/tansr-lock-XWDVZMLY.mjs +5 -0
  56. package/tansr-main-6GDLXIRQ.mjs +7 -0
  57. package/tansr-render-SVMDLHLN.mjs +6 -0
  58. package/tansr-restore-7PS7WCJR.mjs +5 -0
  59. package/tansr-run-acp-entry-EQGUKZ5R.mjs +68 -0
  60. package/tansr-run-approvals-entry-SEYBHLS2.mjs +12 -0
  61. package/{tansr-run-auth-entry-X3SXNPOI.mjs → tansr-run-auth-entry-R3GKGKWX.mjs} +2 -2
  62. package/tansr-run-doctor-B3XK72DW.mjs +11 -0
  63. package/tansr-run-headless-entry-4XTAVPTW.mjs +84 -0
  64. package/tansr-run-init-entry-GH2KDGI6.mjs +5 -0
  65. package/tansr-run-logout-entry-PLGYDEOB.mjs +5 -0
  66. package/tansr-run-mcp-serve-entry-UHK4WSKL.mjs +14 -0
  67. package/tansr-run-orchestrate-entry-M7R3433X.mjs +11 -0
  68. package/tansr-run-org-entry-UONLGJIJ.mjs +17 -0
  69. package/tansr-run-policy-entry-NNQCV5WS.mjs +16 -0
  70. package/tansr-run-profile-entry-PV6OO7FV.mjs +14 -0
  71. package/tansr-run-serve-entry-GWZQZ37P.mjs +16 -0
  72. package/tansr-run-sessions-entry-WL7YLRJL.mjs +25 -0
  73. package/tansr-run-update-entry-YI47IPCC.mjs +5 -0
  74. package/tansr-spill-YVUTIFOS.mjs +5 -0
  75. package/tansr-src-LPMSGRKO.mjs +5 -0
  76. package/{tansr-src-JAODAP53.mjs → tansr-src-RQJPOVDN.mjs} +50 -50
  77. package/tansr-startup-account-MYFJ3NOL.mjs +7 -0
  78. package/{tansr-startup-model-SREG5HNN.mjs → tansr-startup-model-BCGEYUM4.mjs} +3 -3
  79. package/tansr-storage-journal-4E274MUA.mjs +5 -0
  80. package/tansr-todos-replay-TVQKP7OD.mjs +5 -0
  81. package/tansr-tui-3Q7Z3ALV.mjs +73 -0
  82. package/tansr.mjs +1 -1
  83. package/tansrd.mjs +444 -265
  84. package/tansr-bg-QY4G2SNZ.mjs +0 -5
  85. package/tansr-chunk-2C6JKHKM.mjs +0 -25
  86. package/tansr-chunk-53SL6W6G.mjs +0 -6
  87. package/tansr-chunk-5T7X32UX.mjs +0 -6
  88. package/tansr-chunk-6OXR4F5Y.mjs +0 -67
  89. package/tansr-chunk-BCOFZJWA.mjs +0 -279
  90. package/tansr-chunk-BX7CF5RQ.mjs +0 -25
  91. package/tansr-chunk-F7C6ITED.mjs +0 -5
  92. package/tansr-chunk-H6JYYWPW.mjs +0 -35
  93. package/tansr-chunk-HRKJLVKC.mjs +0 -7
  94. package/tansr-chunk-I3TOVAA6.mjs +0 -5
  95. package/tansr-chunk-J2ED6CI4.mjs +0 -5
  96. package/tansr-chunk-KSBP64Q5.mjs +0 -12
  97. package/tansr-chunk-LSYPDTQG.mjs +0 -22
  98. package/tansr-chunk-MWHLITGY.mjs +0 -11
  99. package/tansr-chunk-NA22YT73.mjs +0 -5
  100. package/tansr-chunk-NCIMR6LB.mjs +0 -5
  101. package/tansr-chunk-OSK64SU3.mjs +0 -5
  102. package/tansr-chunk-Q6MUMULP.mjs +0 -5
  103. package/tansr-chunk-QEKVLX7W.mjs +0 -5
  104. package/tansr-chunk-QHEQQ2JB.mjs +0 -9
  105. package/tansr-chunk-QNHXB55W.mjs +0 -11
  106. package/tansr-chunk-QWGSXFEJ.mjs +0 -7
  107. package/tansr-chunk-SJFDQLLC.mjs +0 -5
  108. package/tansr-chunk-TYJWMSVW.mjs +0 -5
  109. package/tansr-chunk-TZJHQ3TT.mjs +0 -38
  110. package/tansr-chunk-UAEARRRH.mjs +0 -8
  111. package/tansr-chunk-WGXWBU37.mjs +0 -8
  112. package/tansr-chunk-ZQ3ZK7IL.mjs +0 -37
  113. package/tansr-main-5V46X7QH.mjs +0 -7
  114. package/tansr-render-PUEISX75.mjs +0 -6
  115. package/tansr-run-acp-entry-ANNUR7IB.mjs +0 -63
  116. package/tansr-run-approvals-entry-SLLTFTSX.mjs +0 -12
  117. package/tansr-run-doctor-RYIQQOOK.mjs +0 -10
  118. package/tansr-run-headless-entry-I53HJDNX.mjs +0 -78
  119. package/tansr-run-init-entry-USPWKDRI.mjs +0 -5
  120. package/tansr-run-logout-entry-KO7ZL2M5.mjs +0 -5
  121. package/tansr-run-mcp-serve-entry-YMQH7WSF.mjs +0 -14
  122. package/tansr-run-orchestrate-entry-YN3M6BWY.mjs +0 -11
  123. package/tansr-run-org-entry-STRRZVI4.mjs +0 -17
  124. package/tansr-run-policy-entry-4ENHRAMQ.mjs +0 -16
  125. package/tansr-run-profile-entry-THJMZ7ZA.mjs +0 -14
  126. package/tansr-run-serve-entry-N5PK7ACI.mjs +0 -99
  127. package/tansr-run-sessions-entry-KIT7PALM.mjs +0 -23
  128. package/tansr-run-update-entry-HYSKHBB6.mjs +0 -5
  129. package/tansr-sqlite-event-store-UQLSSZKP.mjs +0 -26
  130. package/tansr-sqlite-spool-implementation-LHEIRSUX.mjs +0 -29
  131. package/tansr-src-KOEPYVXX.mjs +0 -5
  132. package/tansr-startup-account-QUJKOV6V.mjs +0 -7
  133. package/tansr-tui-DXGFMSII.mjs +0 -75
@@ -0,0 +1,32 @@
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{l as ae,n as ue,o as de,p as ce}from"./tansr-chunk-SXNTYWJY.mjs";import{i as se,j as ie}from"./tansr-chunk-OUOTEH4A.mjs";import{a as _,b as K}from"./tansr-chunk-AMMPDY4V.mjs";import{b as u,c as le}from"./tansr-chunk-YOSRXZWY.mjs";import{P as te,_ as re,ba as ne,ca as oe}from"./tansr-chunk-JIC3VWLQ.mjs";import{Ja as z,Ka as Z,fb as ee}from"./tansr-chunk-6N333TUL.mjs";import{f as X,m}from"./tansr-chunk-YK3CE3JM.mjs";import{V as q}from"./tansr-chunk-ENRIN7EG.mjs";var L=["text","json","stream-json"];var ke={"-p":"prompt","--prompt":"prompt","--max-turns":"maxTurns","--model":"model","--lang":"lang","--resume":"resume","--max-budget-usd":"maxBudgetUsd","--output-format":"outputFormat","--input-format":"inputFormat","--permission-mode":"permissionMode","--allowedTools":"allowedTools","--disallowedTools":"disallowedTools","--effort":"effort","--output-style":"outputStyle","--context-scheme":"contextScheme","--sessions-dir":"sessionsDir","--checkpoints-dir":"checkpointsDir","--cwd":"cwd","--restore":"restore"},Ee={"--json":"json","--verbose":"verbose","--continue":"continueSession","--cc-compat":"ccCompat","--bg":"bg","--branch-summary":"branchSummary","--trust-project-hooks":"trustProjectHooks"};function h(t,e){return{ok:!1,error:e?{key:t,params:e}:{key:t}}}function Re(t){if(!/^\d+$/.test(t))return;let e=Number(t);return Number.isSafeInteger(e)&&e>0?e:void 0}function Te(t){if(!/^\d+(\.\d+)?$/.test(t))return;let e=Number(t);return Number.isFinite(e)&&e>0?e:void 0}function we(t){let e=t.split(",").map(r=>r.trim()).filter(r=>r!=="");if(e.length===0)return{ok:!1,bad:t};for(let r of e)if(te(r)===null)return{ok:!1,bad:r};return{ok:!0,rules:e}}function H(t){return t.outputFormat??(t.json?"stream-json":"text")}function J(t){if(t.branchSummary===!0&&(!t.resume?.trim()||!t.restore?.trim()))return{key:u.branchSummaryRequirements};if(t.inputFormat==="ndjson"&&(!t.prompt?.trim()||H(t)!=="stream-json"||t.ccCompat||t.bg))return{key:u.ndjsonRequirements}}function me(t){let e={json:!1};for(let n=0;n<t.length;n++){let s=t[n],a=s,c;if(s.startsWith("--")){let i=s.indexOf("=");i!==-1&&(a=s.slice(0,i),c=s.slice(i+1))}let f=Ee[a];if(f!==void 0){if(c!==void 0)return h(u.noValueAllowed,{flag:a});e[f]=!0;continue}if(a==="-w"||a==="--worktree"){let i;if(c!==void 0)i=c;else{let d=t[n+1];d!==void 0&&!(d.startsWith("-")&&d!=="-")&&(i=d,n++)}e.worktree=i!==void 0?{name:i}:{};continue}let l=ke[a];if(l!==void 0){let i;if(c!==void 0)i=c;else{let d=t[n+1];if(d===void 0||d.startsWith("-")&&d!=="-")return h(u.missingValue,{flag:a});i=d,n++}if(l==="maxTurns"){let d=Re(i);if(d===void 0)return h(u.invalidNumber,{flag:a,value:i});e.maxTurns=d}else if(l==="maxBudgetUsd"){let d=Te(i);if(d===void 0)return h(u.invalidNumber,{flag:a,value:i});e.maxBudgetUsd=d}else if(l==="inputFormat"){if(i!=="text"&&i!=="ndjson")return h(u.invalidChoice,{flag:a,value:i,expected:"text|ndjson"});e.inputFormat=i}else if(l==="outputFormat"){if(!L.includes(i))return h(u.invalidChoice,{flag:a,value:i,expected:L.join("|")});e.outputFormat=i}else if(l==="permissionMode"){if(!q.includes(i))return h(u.invalidChoice,{flag:a,value:i,expected:q.join("|")});e.permissionMode=i}else if(l==="effort"){let d=ie(i);if(d===void 0)return h(u.invalidChoice,{flag:a,value:i,expected:se.join("|")});e.effort=d}else if(l==="allowedTools"||l==="disallowedTools"){let d=we(i);if(!d.ok)return h(u.invalidRule,{flag:a,rule:d.bad});e[l]=[...e[l]??[],...d.rules]}else e[l]=i;continue}return s.startsWith("-")&&s!=="-"?h(u.unknownFlag,{flag:a}):h(u.unexpectedArg,{arg:s})}let r=J(e);return r!==void 0?{ok:!1,error:r}:e.continueSession===!0&&e.resume!==void 0?h(u.conflictingFlags,{a:"--continue",b:"--resume"}):e.ccCompat===!0&&H(e)!=="stream-json"?h(u.ccCompatRequiresStreamJson):e.bg===!0&&e.prompt===void 0?h(u.bgRequiresPrompt):e.cwd!==void 0&&e.worktree!==void 0?h(u.conflictingFlags,{a:"--cwd",b:"-w/--worktree"}):{ok:!0,options:e}}function _e(t){let e=[];for(let r=0;r<t.length;r++){let n=t[r];if(n!=="--bg"){if(n==="-w"||n==="--worktree"||n==="--cwd"){let s=t[r+1];s!==void 0&&!(s.startsWith("-")&&s!=="-")&&r++;continue}n.startsWith("--worktree=")||n.startsWith("--cwd=")||e.push(n)}}return e}function ve(t=process.stdin){return{controlStream:t,isTTY:t.isTTY===!0,readAll:()=>fe(t)}}async function fe(t){let e=[];for await(let r of t)e.push(typeof r=="string"?Buffer.from(r,"utf8"):r);return Buffer.concat(e).toString("utf8")}async function Y(t,e){let r=t.prompt,n=!e.isTTY;if(r!==void 0&&r!==""){if(!n)return{ok:!0,prompt:r};let s=(await e.readAll()).trim();return s===""?{ok:!0,prompt:r}:{ok:!0,prompt:`${r}
5
+
6
+ ${s}`}}if(n){let s=(await e.readAll()).trim();if(s!=="")return{ok:!0,prompt:s}}return{ok:!1,error:{key:u.missingPrompt}}}import{randomUUID as Oe}from"node:crypto";var j=class{#s=new TextDecoder("utf-8");#e;#r="";#t=!1;#n=0;constructor(e=8388608){this.#e=e}get droppedLines(){return this.#n}push(e){let r=typeof e=="string"?e:this.#s.decode(e,{stream:!0});return this.#o(r)}flush(){let e=this.#s.decode(),r=this.#o(e);if(!this.#t&&this.#r.length>0){let n=this.#r.replace(/\r$/,"");n.length>0&&r.push(n)}else this.#t&&(this.#n+=1);return this.#r="",this.#t=!1,r}#o(e){let r=[],n=e;for(;;){let s=n.indexOf(`
7
+ `);if(s===-1){if(this.#t)break;this.#r+=n,this.#r.length>this.#e&&(this.#r="",this.#t=!0);break}let a=n.slice(0,s);if(n=n.slice(s+1),this.#t){this.#t=!1,this.#n+=1;continue}let c=(this.#r+a).replace(/\r$/,"");if(this.#r="",c.length>this.#e){this.#n+=1;continue}c.length>0&&r.push(c)}return r}};var D=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),b=t=>({outcome:"rejected",code:t});async function pe(t,e,r){if(e==="input_capabilities")return t.inputCapabilities();if(!D(r)||typeof r.inputId!="string"||!D(r.target)||typeof r.target.turnId!="string"||typeof r.target.historyEpoch!="string")return b("invalid_input");let n={turnId:r.target.turnId,historyEpoch:r.target.historyEpoch};if(e==="input_status")return{receipt:t.getInputStatus(r.inputId,n)};if(e!=="steer")return b("method_not_found");if(r.ack==="durable")return b("durable_unsupported");if(r.ack!==void 0&&r.ack!=="memory")return b("invalid_input");let s=r.content;return!D(s)||!(typeof s.text=="string"&&!("blocks"in s))&&!(Array.isArray(s.blocks)&&s.blocks.length>0&&!("text"in s)&&s.blocks.every(a=>D(a)&&a.t==="text"&&typeof a.text=="string"))?b("content_unsupported"):t.submitInput({inputId:r.inputId,target:n,content:s,ack:"memory"})}function ge(t,e,r,n){let s=new j(65536),a=new Set,c=!1,f=0,l,i=R=>{if(l===void 0)try{e.write(JSON.stringify(R)+`
8
+ `)||t.pause()}catch(k){l={error:k},x()}},d=(R,k)=>i({type:"tansr.input.response",v:1,id:R,result:k}),y=()=>{c||t.resume()},I=R=>{for(let k of R){if(c)break;let S;try{S=JSON.parse(k)}catch{d(null,b("invalid_frame"));continue}if(typeof S!="object"||S===null||Array.isArray(S)){d(null,b("invalid_frame"));continue}let p=S,T=p.id;if(typeof T!="string"&&typeof T!="number"||p.v!==1){d(null,b("invalid_frame"));continue}if(p.method==="cancel"){n(),d(T,{outcome:"cancel_requested"});continue}if(p.method!=="steer"&&p.method!=="input_status"&&p.method!=="input_capabilities"){d(T,b("method_not_found"));continue}let w=pe(r,p.method,p.params).then(O=>d(T,O),()=>d(T,b("input_failed")));a.add(w),w.then(()=>a.delete(w),()=>a.delete(w))}for(;!c&&f<s.droppedLines;)f++,d(null,b("frame_too_large"))},g=R=>{c||I(s.push(R))},A=()=>{c||(I(s.flush()),x())},C=()=>{d(null,b("input_failed")),x()};function x(){c=!0,t.off("data",g),t.off("end",A),t.off("error",C),e.off("drain",y),t.pause()}return i({type:"tansr.input.ready",v:1,capabilities:r.inputCapabilities(),maxLineCodeUnits:64*1024}),c||(t.on("data",g),t.on("end",A),t.on("error",C),e.on("drain",y),e.writableNeedDrain&&t.pause()),{stop:x,async close(){if(x(),await Promise.allSettled([...a]),l!==void 0)throw l.error}}}function Ie(t){return{input_tokens:t.inputTokens,output_tokens:t.outputTokens,...t.cacheReadInputTokens!==void 0?{cache_read_input_tokens:t.cacheReadInputTokens}:{},...t.cacheCreationInputTokens!==void 0?{cache_creation_input_tokens:t.cacheCreationInputTokens}:{}}}function Ce(t){return t.exitCode===0?"success":t.reason==="max_turns"?"error_max_turns":"error_during_execution"}var M=class{#s;#e;#r;#t;#n=new Map;#o=new Map;#i=[];constructor(e,r){this.#s=e,this.#e=r.sessionId,this.#r=r.model,this.#t=r.toolNames}#a(e){let r;try{r=JSON.stringify(e)}catch(n){r=JSON.stringify({type:"system",subtype:"serialization_error",session_id:this.#e,message:n instanceof Error?n.message:String(n)})}this.#s.write(r+`
9
+ `)}writeInit(){this.#a({type:"system",subtype:"init",session_id:this.#e,model:this.#r.model,tools:[...this.#t]})}render(e){switch(e.type){case"msg.block.start":e.blockType==="text"&&this.#n.set(e.index,"");break;case"msg.text.delta":{let r=this.#n.get(e.index);r!==void 0&&this.#n.set(e.index,r+e.text);break}case"msg.block.end":{let r=this.#n.get(e.index);r!==void 0&&(this.#n.delete(e.index),r!==""&&(this.#i.push(r),this.#a({type:"assistant",message:{role:"assistant",content:[{type:"text",text:r}]},session_id:this.#e})));break}case"msg.retracted":this.#n.delete(e.index);break;case"tool.proposed":this.#a({type:"assistant",message:{role:"assistant",content:[{type:"tool_use",id:e.toolCallId,name:e.name,input:e.args}]},session_id:this.#e});break;case"tool.output.delta":{let r=this.#o.get(e.toolCallId)??"";this.#o.set(e.toolCallId,r+e.chunk);break}case"tool.completed":case"tool.failed":{let r=this.#o.get(e.toolCallId);this.#o.delete(e.toolCallId);let n=e.type==="tool.failed",s=n?e.message:e.content??r;this.#a({type:"user",message:{role:"user",content:[{type:"tool_result",tool_use_id:e.toolCallId,content:s!==void 0?[{type:"text",text:s}]:[],...n?{is_error:!0}:{}}]},session_id:this.#e});break}default:break}}writeResult(e){this.#a({type:"result",subtype:Ce(e),is_error:e.exitCode!==0,session_id:this.#e,...e.exitCode===0?{result:this.#i.join(`
10
+ `)}:{},...e.usage!==void 0?{usage:Ie(e.usage)}:{},...e.error!==void 0?{error:e.error}:{}})}};function ye(t,e){return JSON.stringify({type:"error",scope:"serialization",message:e,...t!==void 0?{seq:t}:{}})}function he(t){try{return JSON.stringify(t)}catch(e){let r=e instanceof Error?e.message:String(e);return ye(typeof t.seq=="number"?t.seq:void 0,r)}}function G(t,e){t.write(he(e)+`
11
+ `)}function Q(t,e){let r;try{r=JSON.stringify(e)}catch(n){r=ye(void 0,n instanceof Error?n.message:String(n))}t.write(r+`
12
+ `)}function Ae(t){try{return JSON.stringify(t)??"undefined"}catch{return"<unserializable>"}}var P=class{#s;#e;#r;#t=new Map;#n=new Map;#o=new Map;constructor(e,r,n={}){this.#s=e,this.#e=r,this.#r=n.verbose===!0}#i(e){return this.#o.get(e)??e}render(e){switch(e.type){case"msg.block.start":this.#n.set(e.index,e.blockType),e.blockType==="text"&&this.#t.set(e.index,"");break;case"msg.text.delta":{let r=this.#t.get(e.index);r!==void 0&&this.#t.set(e.index,r+e.text);break}case"msg.block.end":{let r=this.#t.get(e.index);r!==void 0&&(this.#t.delete(e.index),r!==""&&this.#s.write(r+`
13
+ `));break}case"msg.retracted":this.#t.delete(e.index);break;case"turn.started":this.#r&&this.#e.write(m(u.turnStarted)+`
14
+ `);break;case"tool.proposed":this.#o.set(e.toolCallId,e.name),this.#r&&this.#e.write(m(u.toolProposed,{name:e.name,args:Ae(e.args)})+`
15
+ `);break;case"tool.permission.decided":if(this.#r){let r={name:this.#i(e.toolCallId),decision:e.decision,source:e.decisionSource};this.#e.write((e.matchedRule!==void 0?m(u.toolPermissionDecidedRule,{...r,rule:e.matchedRule}):m(u.toolPermissionDecided,r))+`
16
+ `)}break;case"tool.started":this.#e.write(m(u.toolStarted,{name:this.#i(e.toolCallId)})+`
17
+ `);break;case"tool.completed":this.#e.write(m(u.toolCompleted,{name:this.#i(e.toolCallId),duration:X(e.durationMs)})+`
18
+ `);break;case"tool.failed":this.#e.write(m(u.toolFailed,{name:this.#i(e.toolCallId),errorType:e.errorType,message:e.message})+`
19
+ `);break;case"tool.permission.requested":this.#e.write(m(u.toolPermissionRequested,{name:e.name})+`
20
+ `);break;case"turn.error":this.#e.write(m(u.turnError,{message:e.message})+`
21
+ `);break;default:break}}};var He=1e4,Me={isTTY:!0,readAll:()=>Promise.resolve("")};function Pe(t,e){if(t===void 0)return{...e};let r=(c,f)=>c===void 0&&f===void 0?void 0:(c??0)+(f??0),n=r(t.cacheReadInputTokens,e.cacheReadInputTokens),s=r(t.cacheCreationInputTokens,e.cacheCreationInputTokens),a=r(t.reasoningOutputTokens,e.reasoningOutputTokens);return{inputTokens:t.inputTokens+e.inputTokens,outputTokens:t.outputTokens+e.outputTokens,...n!==void 0?{cacheReadInputTokens:n}:{},...s!==void 0?{cacheCreationInputTokens:s}:{},...a!==void 0?{reasoningOutputTokens:a}:{}}}async function Fe(t,e){let r=e.stdin??Me,n=J(t);if(n!==void 0||t.inputFormat==="ndjson"&&r.controlStream===void 0)return e.stderr.write(m(n?.key??u.ndjsonRequirements)+`
22
+ `),_.usage;let s=t.inputFormat==="ndjson"?{ok:!0,prompt:t.prompt}:await Y(t,r);if(!s.ok)return e.stderr.write(m(s.error.key,s.error.params)+`
23
+ `),_.usage;let a=H(t),c=e.model??{provider:"cli",model:t.model??"default"},f=e.sessionId??Oe();if(e.effortDiagnostic!==void 0&&a==="text"&&t.verbose===!0){let o=e.effortDiagnostic,E=o.source==="flag"?"--effort":o.source==="env"?"TANSR_EFFORT":"config";e.stderr.write((o.thinking!==void 0?m(u.effortApplied,{level:o.level,source:E,budget:o.thinking.budget,maxTokens:o.maxTokens}):m(u.effortDefault,{level:o.level,source:E}))+`
24
+ `)}let l=e.queryHooks?.([s.prompt]),i;if(e.compaction!==void 0&&e.contextWindowTokens!==void 0){let{manager:o,...E}=e.compaction,$=ne(E,e.compactionManagerOptions,{client:e.client,contextWindowTokens:e.contextWindowTokens,...e.transcriptHint!==void 0?{transcriptHint:e.transcriptHint}:{}}),V=ee(e.reminders);V!==void 0&&$.registerPostCompactInvalidation(V),i={...E,manager:$}}let y=(e.runQueryImpl??re)({...e.sessionCapture!==void 0?{sessionCapture:e.sessionCapture,sessionCaptureInputStart:e.initialHistory?.length??0}:{},...e.contextMaterials!==void 0?{contextMaterials:e.contextMaterials}:{},...e.onInputsConsumed===void 0?{}:{onInputsConsumed:o=>e.onInputsConsumed(o.map(E=>E.text))},client:e.client,executor:e.executor,system:e.system,tools:e.tools,model:c,maxTokens:e.maxTokens??z,...e.maxOutputTokens!==void 0?{maxOutputTokens:e.maxOutputTokens}:{},maxTokensEscalation:{ceilingTokens:Z},...e.thinking!==void 0?{thinking:e.thinking}:{},sessionId:f,initialMessages:[...e.initialHistory??[],{role:"user",blocks:[{t:"text",text:s.prompt}]}],...e.contextWindowTokens!==void 0?{contextWindowTokens:e.contextWindowTokens}:{},...i!==void 0?{compaction:i}:{},...t.maxTurns!==void 0?{maxTurns:t.maxTurns}:{},...e.reminders!==void 0?{reminders:e.reminders}:{},...e.sessionEvents!==void 0?{sessionEvents:e.sessionEvents}:{},...l!==void 0?{hooks:l}:{},...e.budget!==void 0?{budget:e.budget}:{},...e.toolResultBudget!==void 0?{toolResultBudget:e.toolResultBudget}:{},...e.requestMeasurement!==void 0?{requestMeasurement:e.requestMeasurement}:{}}),I=e.forceExit??(o=>process.exit(o)),g=de(e.stderr),A=ue({hardExitAfterMs:He,...e.processLifecycle,...e.onSigint!==void 0?{signalSource:e.onSigint}:{},drain:o=>{o.kind==="interrupt"&&e.stderr.write(m(u.interruptAbort)+`
25
+ `),y.abort()},exitCode:_.aborted,exit:I,onSecondSignal:g.onSecondSignal,onHardExit:g.onHardExit}),C=()=>{A.dispose()},x=ae({logger:{info:o=>e.stderr.write(o+`
26
+ `),error:o=>e.stderr.write(o+`
27
+ `)},onFatal:"log",...e.processGuardTarget!==void 0?{target:e.processGuardTarget}:{}}),R=a==="text"?new P(e.stdout,e.stderr,{verbose:t.verbose===!0}):void 0,k=a==="stream-json"&&t.ccCompat===!0?new M(e.stdout,{sessionId:f,model:c,toolNames:e.tools.map(o=>o.name)}):void 0;k?.writeInit();let S,p,T=e.restoredFrom!==void 0,w,O=o=>{e.trackEvent?.(o),o.type==="cost.usage.updated"&&(p=Pe(p,o.usage)),o.type==="session.compacted"&&(T=!0),(o.type==="turn.completed"||o.type==="turn.aborted")&&(S=o.reason),o.type==="turn.error"&&o.errorKind==="internal_error"&&!o.recoverable&&(w=o.message),a==="stream-json"?k!==void 0?k.render(o):G(e.stdout,o):R?.render(o)},U=o=>{k!==void 0?k.writeResult(o):Q(e.stdout,o)},N=()=>{for(let o of e.drainSideEvents?.()??[])O(o)};e.resumedFromSeq!==void 0&&O({type:"session.resumed",fromSeq:e.resumedFromSeq,sessionId:f,seq:0,ts:Date.now(),v:"v0",source:"cli"}),e.restoredFrom!==void 0&&O({type:"session.restored",checkpointId:e.restoredFrom.checkpointId,fromMessages:e.restoredFrom.fromMessages,toMessages:e.restoredFrom.toMessages,sessionId:f,seq:e.resumedFromSeq!==void 0?1:0,ts:Date.now(),v:"v0",source:"cli"});let xe=async()=>{if(e.onFinalMessages!==void 0)try{await e.onFinalMessages(y.messages(),{rewritten:T})}catch(o){let E=o instanceof Error?o.message:String(o);e.stderr.write(m(u.internalError,{message:E})+`
28
+ `)}},Se=o=>{if(e.stderr.write(m(u.internalError,{message:o})+`
29
+ `),a!=="text"){let E={type:"result",sessionId:f,exitCode:_.modelError,error:o,...p!==void 0?{usage:p}:{}};U(E)}return _.modelError},F=t.inputFormat==="ndjson"?new oe(f):void 0;F?.bind(y);let B=F===void 0?void 0:ge(r.controlStream,e.stdout,F,()=>y.abort());try{N();for await(let o of y.events)(o.type==="turn.completed"||o.type==="turn.aborted")&&B?.stop(),N(),O(o);N()}catch(o){w=o instanceof Error?o.message:String(o),B!==void 0&&y.abort("internal_error")}finally{try{await B?.close()}finally{F?.finish(y),x();try{await xe()}finally{C()}}}if(w!==void 0)return Se(w);if(S===void 0){if(e.stderr.write(m(u.internalError,{message:m(u.noTerminalEvent)})+`
30
+ `),a!=="text"){let o={type:"result",sessionId:f,exitCode:_.modelError,error:m(u.noTerminalEvent),...p!==void 0?{usage:p}:{}};U(o)}return _.modelError}let W=K(S);if(a!=="text"){let o={type:"result",sessionId:f,reason:S,exitCode:W,...p!==void 0?{usage:p}:{}};U(o)}else{let o=le(S);e.stderr.write(m(u.summary,{reason:o!==void 0?m(o):S,exitCode:W})+`
31
+ `)}return W}import{timingSafeEqual as Le}from"node:crypto";var je=/^\/v1\/approvals\/([^/]+)\/credential$/,De={unknown_challenge:404,expired:410,digest_mismatch:409,already_resolved:409},Ue=64*1024;function be(t){let e=t.trim();if(e==="")return null;let r=e.lastIndexOf(":"),n=r===-1?"127.0.0.1":e.slice(0,r),s=r===-1?e:e.slice(r+1);if(!/^\d+$/.test(s))return null;let a=Number(s);return!Number.isInteger(a)||a<0||a>65535||n===""?null:{host:n,port:a}}function Ne(t,e){if(t===void 0||!t.startsWith("Bearer "))return!1;let r=Buffer.from(t.slice(7)),n=Buffer.from(e);return r.length!==n.length?!1:Le(r,n)}function v(t,e,r){let n=JSON.stringify(r);t.writeHead(e,{"content-type":"application/json"}),t.end(n)}function Be(t){return new Promise(e=>{let r=[],n=0,s=!1;t.on("data",a=>{if(!s){if(n+=a.length,n>Ue){s=!0,r.length=0;return}r.push(a)}}),t.on("end",()=>e(s?null:Buffer.concat(r).toString("utf8"))),t.on("error",()=>e(null))})}async function We(t){let e=be(t.listen);if(e===null)throw new Error(`approval-listener:监听地址不合法,收到 ${t.listen}`);let r=async(l,i)=>{let d=(()=>{try{return new URL(l.url??"/","http://localhost").pathname}catch{return"/"}})(),y=je.exec(d);if(y===null){v(i,404,{error:"not_found"});return}if(!Ne(l.headers.authorization,t.token)){v(i,401,{error:"unauthorized"});return}if(l.method!=="POST"){i.setHeader("allow","POST"),v(i,405,{error:"method_not_allowed"});return}let I=await Be(l);if(I===null){v(i,413,{error:"body_too_large"});return}let g;try{let x=JSON.parse(I===""?"{}":I);if(typeof x!="object"||x===null||Array.isArray(x)){v(i,400,{error:"invalid_body"});return}g=x}catch{v(i,400,{error:"invalid_json"});return}if(typeof g.digest!="string"||g.digest===""||g.verdict!=="approve"&&g.verdict!=="deny"||typeof g.approver!="string"||g.approver.trim()===""){v(i,400,{error:"invalid_body"});return}let A=decodeURIComponent(y[1]),C=t.coordinator.submit({challengeId:A,digest:g.digest,verdict:g.verdict,approver:g.approver});if(C.code==="accepted"){v(i,200,{challengeId:A,result:"accepted"});return}v(i,De[C.code]??409,{error:`approval_${C.code}`})},n=ce.createServer((l,i)=>{r(l,i)});await new Promise((l,i)=>{let d=y=>i(y);n.once("error",d),n.listen(e.port,e.host,()=>{n.removeListener("error",d),l()})});let s=n.address(),a=typeof s=="object"&&s!==null?s.port:e.port,c=e.host==="0.0.0.0"||e.host==="::"?"127.0.0.1":e.host;return{url:`http://${c.includes(":")?`[${c}]`:c}:${a}`,close:()=>new Promise(l=>{n.close(()=>l()),n.closeAllConnections?.()})}}export{H as a,me as b,_e as c,ve as d,j as e,pe as f,Fe as g,be as h,We as i};
32
+ //# sourceMappingURL=tansr-chunk-JTGWG4BG.mjs.map
@@ -0,0 +1,11 @@
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{c as l}from"./tansr-chunk-3YSQG6KY.mjs";import{randomUUID as M}from"node:crypto";import{link as Me,open as b,rm as g,stat as z,readFile as De,utimes as Je}from"node:fs/promises";import O from"node:os";var c=class extends Error{code;constructor(r,t){super(t),this.name="JournalError",this.code=r}};function d(e){return e instanceof Error&&typeof e.code=="string"}var j=class extends c{records;cause;constructor(r,t){let n=t instanceof Error?t.message:String(t);super("JOURNAL_SEAL_FAILED",`journal 本批 ${r.length} 条记录已落盘(不得重写),但封段句柄操作失败,writer 已进入不可写状态:${n}`),this.name="JournalSealFailedError",this.records=r,this.cause=t}},T=class extends c{commitId;records;durability;cause;constructor(r,t,n,o){super("JOURNAL_RECONCILIATION_REQUIRED",`Journal original commit ${r} requires reconciliation (${n}); do not replay the batch`),this.name="JournalReconciliationRequiredError",this.commitId=r,this.records=t,this.durability=n,this.cause=o}},v=class extends c{line;detail;constructor(r,t,n){super("JOURNAL_CORRUPTED",`journal 第 ${r} 行数据损坏:${t}`),this.name="JournalCorruptionError",this.line=r,n!==void 0&&(this.detail=n)}};import{mkdir as pe,open as ye,readFile as we,rename as ge,rm as he}from"node:fs/promises";import w from"node:path";var Q="indexed-journal-v1",Z="indexed-journal-v2";function F(e){return e===Q||e===Z}import{randomUUID as ee}from"node:crypto";import{link as te,lstat as Ge,mkdir as ze,open as re,readFile as ne,rm as oe}from"node:fs/promises";import C from"node:path";import{types as ie}from"node:util";var U="sdk2FreshCreation",ae="tansr-sdk2-fresh-creation-v1",se=new Set(["ENOTSUP","EOPNOTSUPP","ENOSYS","EPERM","EXDEV"]),R=class extends Error{constructor(t){super(`Archive fresh creation: ${t}`);this.code=t;this.name="ArchiveFreshStoreError"}code},f=e=>{throw new R(e)},P=e=>e!==null&&typeof e=="object"&&"code"in e?e.code:void 0;function _(e,r){if(e===null||typeof e=="string"||typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e))return e;if(typeof e!="object"||ie.isProxy(e)||r.has(e))return f("invalid_input");let t=Array.isArray(e);if(!t&&Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)return f("invalid_input");r.add(e);try{if(t){let o=[];if(Reflect.ownKeys(e).length!==e.length+1)return f("invalid_input");for(let a=0;a<e.length;a++){let i=Object.getOwnPropertyDescriptor(e,String(a));if(!i||!("value"in i)||!i.enumerable)return f("invalid_input");o.push(_(i.value,r))}return o}let n=Object.create(null);for(let o of Reflect.ownKeys(e)){let a=Object.getOwnPropertyDescriptor(e,o);if(typeof o!="string"||!a||!("value"in a)||!a.enumerable)return f("invalid_input");n[o]=_(a.value,r)}return n}finally{r.delete(e)}}function Be(e,r){let t=_(e,new Set);if(!t||typeof t!="object"||Array.isArray(t))return f("invalid_input");let n=t;if(typeof n.sessionId!="string"||n.sessionId.length===0||Object.keys(n).some(o=>o!=="sessionId"&&!r.includes(o)))return f("invalid_input");for(let o of["title","platformSessionId","cwd"])if(o in n&&typeof n[o]!="string")return f("invalid_input");return"meta"in n&&(!n.meta||typeof n.meta!="object"||Array.isArray(n.meta))||"retentionDays"in n&&n.retentionDays!==null&&(typeof n.retentionDays!="number"||!Number.isFinite(n.retentionDays)||n.retentionDays<0)?f("invalid_input"):Object.assign(n,{sessionId:n.sessionId})}function ce(e){if(e===null||typeof e!="object"||!(U in e))return null;let r=e[U];if(!r||typeof r!="object"||Array.isArray(r))return f("reconciliation_required");let t=r;return Object.keys(t).sort().join(",")!=="attempt,format,state"||t.format!==ae||typeof t.attempt!="string"||!/^[a-f0-9-]{36}$/.test(t.attempt)||t.state!=="pending"&&t.state!=="complete"?f("reconciliation_required"):t.state}function q(e){ce(e)==="pending"&&f("reconciliation_required")}async function N(e,r,t){let n=C.join(e,"meta.json"),o=C.join(e,`.meta-create-${ee()}.tmp`),a=`${JSON.stringify(r,null,2)}
5
+ `,i=await re(o,"wx");try{try{await i.writeFile(a,"utf8"),await i.sync()}finally{await i.close()}try{return await te(o,n),!0}catch(s){if(P(s)==="EEXIST")return!1;if(!se.has(String(P(s))))throw s;if(t==="fresh")return f("unsupported_capability");let u=await $(e);try{try{return await ne(n,"utf8"),!1}catch(S){if(P(S)!=="ENOENT")throw S}return await x(n,a),!0}finally{await u.release()}}}finally{await oe(o,{force:!0})}}import{lstat as le,open as ue}from"node:fs/promises";import de from"node:path";var fe=".session-storage-migration.json",tt=".session-storage-migration-inventory.json";async function me(e){let r=de.join(e,fe),t;try{t=await le(r)}catch(o){if(o.code==="ENOENT")return null;throw o}if(!t.isFile()||t.isSymbolicLink()||t.size>65536)throw new c("JOURNAL_RECONCILIATION_REQUIRED","Local migration guard is unavailable");let n=await ue(r,"r");try{let o=Buffer.alloc(t.size),a=0;for(;a<o.length;){let s=await n.read(o,a,o.length-a,a);if(!s.bytesRead)throw new Error("Short migration guard");a+=s.bytesRead}if((await n.stat()).size!==t.size)throw new Error("Migration guard changed");let i=JSON.parse(o.toString());if(i.format!=="local-session-migration-v1"||!i.operationId||!["frozen","published"].includes(i.phase)||![i.requestDigest,i.inventoryDigest].every(s=>/^[a-f0-9]{64}$/.test(s))||(i.phase==="published"?!i.targetReceipt:i.targetReceipt!==null))throw new Error("Invalid migration guard");return i}catch{throw new c("JOURNAL_RECONCILIATION_REQUIRED","Local migration guard requires original-key reconciliation")}finally{await n.close()}}async function y(e,r){let t=await me(e);if(t&&t.operationId!==r)throw new c("STORAGE_VERSION_UNSUPPORTED","Original local layout is frozen or retired; query its original migration key")}var Se=l.object({schemaVersion:l.literal(1),sessionId:l.string(),createdAt:l.string(),cwd:l.string(),title:l.string().optional(),platformSessionId:l.string().optional(),firstUserMessage:l.string().optional(),model:l.string().optional(),provider:l.string().optional(),outputStyle:l.string().optional(),forkedFrom:l.object({sessionId:l.string(),checkpointId:l.string()}).optional(),retentionDays:l.number().optional()}),Ee=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;function xe(e){if(!Ee.test(e))throw new c("INVALID_SESSION_ID",`非法 sessionId ${JSON.stringify(e)}:仅允许字母数字与 . _ -,且须以字母数字开头`)}function Ie(e,r){return xe(r),w.join(e,"sessions",r)}var be="checkpoints";function ut(e){return w.join(e,be)}function dt(e){return w.join(e,"journal.jsonl")}var Oe="segments",ke="manifest.json";function Ae(e){return w.join(e,Oe)}function ft(e){return w.join(e,ke)}function Pe(e){return`${String(e).padStart(6,"0")}.jsonl`}function mt(e,r){return w.join(Ae(e),Pe(r))}function I(e){return w.join(e,"meta.json")}function L(e){return w.join(e,"lock")}var H=0,Re=new Set(["EPERM","EACCES","EBUSY"]),_e=[5,10,20,40,80,160,320],Ne={rename:ge,sleep:e=>new Promise(r=>setTimeout(r,e)),platform:process.platform};async function Le(e,r,t=Ne){for(let n=0;;n++)try{await t.rename(e,r);return}catch(o){let a=_e[n];if(!(t.platform==="win32"&&d(o)&&o.code!==void 0&&Re.has(o.code))||a===void 0)throw o;await t.sleep(a)}}async function x(e,r){H+=1;let t=`${e}.tmp-${process.pid}-${H.toString(36)}-${Date.now()}`,n=await ye(t,"w");try{typeof r=="string"?await n.writeFile(r,"utf8"):await n.writeFile(r),await n.sync()}finally{await n.close()}try{await Le(t,e)}catch(o){throw await he(t,{force:!0}).catch(()=>{}),o}}async function h(e){let r=await we(I(e),"utf8"),t;try{t=JSON.parse(r)}catch{throw new c("META_INVALID",`meta.json 不是合法 JSON:${I(e)}`)}q(t);let n=Se.safeParse(t);if(!n.success)throw new c("META_INVALID",`meta.json 不符合 SessionMeta schema:${n.error.message}`);return n.data}async function pt(e,r){await y(e);let n={...await h(e),title:r};await y(e),await x(I(e),`${JSON.stringify(n,null,2)}
6
+ `)}async function yt(e,r){await y(e);let n={...await h(e),outputStyle:r};await y(e),await x(I(e),`${JSON.stringify(n,null,2)}
7
+ `)}async function wt(e){let r=Ie(e.storageRoot,e.sessionId);await pe(r,{recursive:!0});try{let n=await h(r);if(n.sessionId!==e.sessionId)throw new c("META_MISMATCH",`meta.json 中 sessionId(${n.sessionId})与目录名(${e.sessionId})不一致`);return{sessionDir:r,meta:n,created:!1}}catch(n){if(!d(n)||n.code!=="ENOENT")throw n}let t={schemaVersion:1,sessionId:e.sessionId,createdAt:new Date().toISOString(),cwd:e.cwd};if(e.extra?.title!==void 0&&(t.title=e.extra.title),e.extra?.firstUserMessage!==void 0&&(t.firstUserMessage=e.extra.firstUserMessage),e.extra?.model!==void 0&&(t.model=e.extra.model),e.extra?.provider!==void 0&&(t.provider=e.extra.provider),e.extra?.outputStyle!==void 0&&(t.outputStyle=e.extra.outputStyle),e.extra?.forkedFrom!==void 0&&(t.forkedFrom={...e.extra.forkedFrom}),e.extra?.retentionDays!==void 0&&(t.retentionDays=e.extra.retentionDays),F(e.journalLayout)){let{acquireSessionLock:n}=await import("./tansr-lock-XWDVZMLY.mjs"),o=await n(r,{requireAtomicPublication:!0});try{try{let s=await h(r);if(s.sessionId!==e.sessionId)throw new c("META_MISMATCH","Competing indexed session has a different id");return{sessionDir:r,meta:s,created:!1}}catch(s){if(!d(s)||s.code!=="ENOENT")throw s}let{initializeIndexedJournal:a,readIndexedJournalResume:i}=await import("./tansr-indexed-CPYJVPFI.mjs");if(await a(r,e.journalProjectionSeed,e.journalLayout),await i(r,{rehydrateImages:!1,reconcile:!0}),!await N(r,t,"fresh")){let s=await h(r);if(s.sessionId!==e.sessionId)throw new c("META_MISMATCH","Competing indexed session has a different id");return{sessionDir:r,meta:s,created:!1}}return{sessionDir:r,meta:t,created:!0}}finally{await o.release()}}if(await y(r),!await N(r,t,"legacy")){let n=await h(r);if(n.sessionId!==e.sessionId)throw new c("META_MISMATCH","Competing session metadata has a different id");return{sessionDir:r,meta:n,created:!1}}return{sessionDir:r,meta:t,created:!0}}var V=1440*60*1e3,X=V,Ot=V/3,je=5e3;function Y(e){try{return process.kill(e,0),!0}catch(r){return!!(d(r)&&r.code==="EPERM")}}async function K(e){try{let r=await De(e,"utf8"),t=JSON.parse(r);return t!==null&&typeof t=="object"&&typeof t.pid=="number"?t:null}catch{return null}}async function Te(e,r){let t=`${e}.${M()}.tmp`,n=await b(t,"wx");try{let o={pid:process.pid,startedAt:new Date().toISOString(),host:O.hostname(),nonce:M()},a=`${JSON.stringify(o)}
8
+ `;try{await n.writeFile(a,"utf8"),await n.sync()}catch(i){throw await n.close().catch(()=>{}),i}await n.close();try{await Me(t,e)}catch(i){if(d(i)&&i.code==="EEXIST")return null;if(!r&&d(i)&&["ENOTSUP","EOPNOTSUPP","ENOSYS","EPERM","EXDEV"].includes(i.code))return await ve(e,a)?o:null;throw i}return o}finally{await g(t,{force:!0}).catch(()=>{})}}async function G(e,r){let t=Buffer.from(`${JSON.stringify(r)}
9
+ `),n;try{n=await b(e,"r")}catch(o){if(d(o)&&o.code==="ENOENT")return!1;throw o}try{let o=await n.stat();if(!o.isFile()||o.size!==t.length)return!1;let a=Buffer.alloc(t.length),i=0;for(;i<a.length;){let{bytesRead:s}=await n.read(a,i,a.length-i,i);if(!s)return!1;i+=s}return a.equals(t)}finally{await n.close()}}async function ve(e,r){let t;try{t=await b(e,"wx")}catch(n){if(d(n)&&n.code==="EEXIST")return!1;throw n}try{try{await t.writeFile(r,"utf8"),await t.sync()}catch(n){throw await t.close().catch(()=>{}),n}return await t.close(),!0}catch(n){throw await g(e,{force:!0}).catch(()=>{}),n}}async function Fe(e){let r;try{r=await b(e,"wx",384)}catch(n){if(d(n)&&n.code==="EEXIST")return null;throw n}let t={pid:process.pid,startedAt:new Date().toISOString(),host:O.hostname(),nonce:M()};try{return await r.writeFile(`${JSON.stringify(t)}
10
+ `,"utf8"),{payload:t,handle:r}}catch(n){throw await r.close().catch(()=>{}),await g(e,{force:!0}).catch(()=>{}),n}}async function kt(e,r={}){let t=L(e),n=r.staleMs??X,o=r.isPidAlive??Y,a;try{a=(await z(t)).mtimeMs}catch(u){if(d(u)&&u.code==="ENOENT")return{held:!1,alive:!1,stale:!1};throw u}let i=await K(t),s=i!==null&&(i.host!==O.hostname()||o(i.pid));return{held:!0,...i!==null?{pid:i.pid,host:i.host,startedAt:i.startedAt}:{},alive:s,mtimeMs:a,stale:Date.now()-a>n}}async function $(e,r={}){r.legacyMigrationGuard!==!1&&await y(e,r.migrationOperationId);let t=L(e),n=r.directCreateAndHold===!0,o=r.staleMs??(n?je:X),a=r.isPidAlive??Y;for(let i=0;i<2;i++){let s=n?await Fe(t):await Te(t,r.requireAtomicPublication===!0).then(p=>p?{payload:p,handle:void 0}:null);if(s){let{payload:p}=s,k=s.handle,D=async()=>{if(!k)return;let m=k;k=void 0,await m.close()};try{r.legacyMigrationGuard!==!1&&await y(e,r.migrationOperationId)}catch(m){throw await D().catch(()=>{}),(n||await G(t,p))&&await g(t,{force:!0}),m}let A=!1,E,J=!1;return{lockPath:t,async release(){if(A)return;if(E)return E;let m=(async()=>{await D(),n&&!J?(J=!0,await g(t,{force:!0})):await G(t,p)&&await g(t,{force:!0}),A=!0})();E=m;try{await m}finally{E===m&&(E=void 0)}},async touch(){if(!A){r.legacyMigrationGuard!==!1&&await y(e,r.migrationOperationId);try{let m=new Date;await Je(t,m,m)}catch(m){if(d(m))return;throw m}}}}}let u=await K(t),S=null;try{S=(await z(t)).mtimeMs}catch(p){if(d(p)&&p.code==="ENOENT")continue;throw p}let B=u!==null&&(u.host!==O.hostname()||a(u.pid)),W=Date.now()-S>o;if(!(u===null?W:!B)){let p=u?`pid=${u.pid} host=${u.host} since=${u.startedAt}`:"未知持有者";throw new c("SESSION_LOCKED",`会话已被其他进程锁定(${p}),锁文件:${t}`)}await g(t,{force:!0})}throw new c("SESSION_LOCKED",`会话锁竞争激烈,清理陈旧锁后重试仍失败:${t}`)}export{c as a,d as b,j as c,T as d,v as e,Q as f,Z as g,F as h,fe as i,tt as j,me as k,y as l,V as m,Ot as n,je as o,kt as p,$ as q,R as r,Be as s,Se as t,xe as u,Ie as v,ut as w,dt as x,Oe as y,Ae as z,ft as A,Pe as B,mt as C,I as D,Le as E,x as F,h as G,pt as H,yt as I,wt as J};
11
+ //# sourceMappingURL=tansr-chunk-LA3LGOYQ.mjs.map
@@ -0,0 +1,5 @@
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 I=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"]),a=class extends Error{code;path;offset;reason;constructor(e,n,t={}){super(n),this.name="CanonicalError",this.code=e,t.path!==void 0&&(this.path=t.path),t.offset!==void 0&&(this.offset=t.offset),t.reason!==void 0&&(this.reason=t.reason)}toJSON(){let e={code:this.code,message:this.message};return this.path!==void 0&&(e.path=this.path),this.offset!==void 0&&(e.offset=this.offset),this.reason!==void 0&&(e.reason=this.reason),e}};function R(r){return typeof r=="number"?String(r):r.replaceAll("~","~0").replaceAll("/","~1")}function l(r,e){return r+"/"+R(e)}var _=32,C=1e5,h=/^[\x21-\x7e]+$/,T=Object.freeze(["maxBytes","maxDepth","maxNodes","isProxy"]),L=Object.freeze(["maxBytes","maxDepth","maxNodes"]),B=Object.getPrototypeOf(Uint8Array.prototype),$=Object.getOwnPropertyDescriptor(B,"byteLength").get;function d(r){return r instanceof Uint8Array}function O(r){return $.call(r)}function u(r){throw new a("invalid_options",r)}function b(r,e,n,t,i){if(!Object.hasOwn(r,e)||r[e]===void 0)return i===void 0&&u(`options.${e} is required`),i;let s=r[e];return(typeof s!="number"||!Number.isSafeInteger(s)||s<n||s>t)&&u(`options.${e} must be a safe integer in [${n}, ${t}]`),s}function m(r,e){(r===null||typeof r!="object"||Array.isArray(r))&&u("options must be an object");let n=e==="encode"?T:L;for(let s of Reflect.ownKeys(r))(typeof s!="string"||!n.includes(s))&&u(`unknown option ${String(s)}`);let t=r,i=null;return e==="encode"&&t.isProxy!==void 0&&(typeof t.isProxy!="function"&&u("options.isProxy must be a function"),i=t.isProxy),{maxBytes:b(t,"maxBytes",1,Number.MAX_SAFE_INTEGER),maxDepth:b(t,"maxDepth",0,_,_),maxNodes:b(t,"maxNodes",1,C,C),isProxy:i}}var z=/[\ud800-\udfff]/;function f(r){if(!z.test(r))return!0;for(let e=0;e<r.length;e++){let n=r.charCodeAt(e);if(n>=55296&&n<=56319){let t=r.charCodeAt(++e);if(!(t>=56320&&t<=57343))return!1}else if(n>=56320&&n<=57343)return!1}return!0}function v(r){let e=r.length,n=(i,s=128,o=191)=>i<e&&r[i]>=s&&r[i]<=o,t=0;for(;t<e;){let i=r[t];if(i<=127){t+=1;continue}if(i>=194&&i<=223){if(n(t+1)){t+=2;continue}return t}if(i>=224&&i<=239){let s=i===224?160:128,o=i===237?159:191;if(n(t+1,s,o)&&n(t+2)){t+=3;continue}return t}if(i>=240&&i<=244){let s=i===240?144:128,o=i===244?143:191;if(n(t+1,s,o)&&n(t+2)&&n(t+3)){t+=4;continue}return t}return t}return-1}var F=/^[\x00-\x7f]*$/;function x(r){if(F.test(r))return r.length;let e=0;for(let n=0;n<r.length;n++){let t=r.charCodeAt(n);if(t<128)e+=1;else if(t<2048)e+=2;else if(t>=55296&&t<=56319){let i=r.charCodeAt(n+1);i>=56320&&i<=57343?(e+=4,n++):e+=3}else e+=3}return e}var K=new TextEncoder,H=/^[\x00-\x7f]*$/,g=new Map,M=4096,X=64,A=class{maxBytes;maxDepth;maxNodes;isProxy;text="";used=0;nodes=0;ancestors=new Set;keys=[];constructor({maxBytes:e,maxDepth:n,maxNodes:t,isProxy:i}){this.maxBytes=e,this.maxDepth=n,this.maxNodes=t,this.isProxy=i}fail(e,n,t=0){let i="";for(let s=0;s<this.keys.length-t;s++)i=l(i,this.keys[s]);throw new a(e,n,{path:i})}ascii(e,n=0){this.used+=e.length,this.used>this.maxBytes&&this.fail("bytes_exceeded",`encoded bytes exceed maxBytes ${this.maxBytes}`,n),this.text+=e}quoted(e){e.length>this.maxBytes-this.used&&this.fail("bytes_exceeded",`encoded bytes exceed maxBytes ${this.maxBytes}`),this.used+=x(e),this.used>this.maxBytes&&this.fail("bytes_exceeded",`encoded bytes exceed maxBytes ${this.maxBytes}`),this.text+=e}number(e){Number.isInteger(e)||this.fail("invalid_number","number must be an integer (no fraction, NaN or Infinity)"),Number.isSafeInteger(e)||this.fail("unsafe_integer","integer exceeds 2^53-1"),(e<0||Object.is(e,-0))&&this.fail("invalid_number","number must be nonnegative (no -0)"),this.ascii(String(e))}string(e){if(H.test(e)){this.ascii(JSON.stringify(e));return}f(e)||this.fail("lone_surrogate","string contains an unpaired surrogate"),this.quoted(JSON.stringify(e))}dataDescriptor(e,n){let t=Object.getOwnPropertyDescriptor(e,n);return(t===void 0||!Object.hasOwn(t,"value")||!t.enumerable)&&this.fail("invalid_property","properties must be enumerable own data properties (no accessor / hole)"),t.value}array(e,n){let t=Object.getOwnPropertyDescriptor(e,"length")?.value;(typeof t!="number"||!Number.isSafeInteger(t))&&this.fail("invalid_property","array length is not an integer"),this.nodes+t>this.maxNodes&&this.fail("nodes_exceeded",`node count exceeds maxNodes ${this.maxNodes}`),Reflect.ownKeys(e).length!==t+1&&this.fail("invalid_property","array must be dense without extra own properties"),this.ascii("[");for(let s=0;s<t;s++){this.keys.push(s);let o=this.dataDescriptor(e,String(s));s>0&&this.ascii(",",1),this.write(o,n+1),this.keys.pop()}this.ascii("]")}object(e,n){let t=Object.getPrototypeOf(e);t!==Object.prototype&&t!==null&&this.fail("unsupported_value","objects must be plain (Object.prototype or null prototype)");let i=Reflect.ownKeys(e);for(let o of i)typeof o!="string"&&this.fail("invalid_property","symbol keys are not representable");let s=i.sort();this.ascii("{");for(let o=0;o<s.length;o++){let c=s[o];this.keys.push(c);let p=this.dataDescriptor(e,c),y=g.get(c);y===void 0&&(h.test(c)||this.fail("invalid_key","keys must be nonempty printable ASCII (0x21-0x7e)"),y=JSON.stringify(c)+":",c.length<=X&&(g.size>=M&&g.clear(),g.set(c,y))),o>0&&this.ascii(",",1),this.ascii(y),this.write(p,n+1),this.keys.pop()}this.ascii("}")}write(e,n){if(n>this.maxDepth&&this.fail("depth_exceeded",`nesting depth exceeds maxDepth ${this.maxDepth}`),++this.nodes>this.maxNodes&&this.fail("nodes_exceeded",`node count exceeds maxNodes ${this.maxNodes}`),e===null){this.ascii("null");return}switch(typeof e){case"string":this.string(e);return;case"boolean":this.ascii(e?"true":"false");return;case"number":this.number(e);return;case"object":break;default:this.fail("unsupported_value",`${typeof e} is not representable`)}let t=e;this.isProxy!==null&&this.isProxy(t)&&this.fail("unsupported_value","Proxy objects are not representable"),this.ancestors.has(t)&&this.fail("cyclic_reference","value contains itself"),this.ancestors.add(t),Array.isArray(t)?this.array(t,n):this.object(t,n),this.ancestors.delete(t)}};function E(r,e){let n=new A(m(e,"encode"));return n.write(r,0),n.text}function q(r,e){return K.encode(E(r,e))}var J=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}),w=/"(?:[^"\\\u0000-\u001f]|\\(?:["\\/bfnrt]|u[0-9a-fA-F]{4}))*"/y,Y=/^[0-9a-fA-F]{4}$/,G=new Set([8,9,10,12,13]),k=r=>r===32||r===9||r===10||r===13,D=r=>r>=48&&r<=57,N=class{text;strict;maxDepth;maxNodes;at=0;nodes=0;violation=null;constructor(e,n,{maxDepth:t,maxNodes:i}){this.text=e,this.strict=n,this.maxDepth=t,this.maxNodes=i}byteOffset(e){return x(this.text.slice(0,e))}fail(e,n,t,i=this.at){throw new a(e,n,{path:t,offset:this.byteOffset(i)})}note(e,n,t){this.strict&&this.violation===null&&(this.violation={reason:e,path:n,at:t})}document(){let e=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:t,at:i}=this.violation;throw new a("not_canonical",`input is valid but not canonical (${n})`,{path:t,offset:this.byteOffset(i),reason:n})}return e}whitespace(e){let n=this.at;for(;this.at<this.text.length&&k(this.text.charCodeAt(this.at));)this.at++;this.at!==n&&this.note("whitespace",e,n)}value(e,n){this.whitespace(n),e>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 t=this.text.charCodeAt(this.at);if(t===34)return this.string(n);if(t===123)return this.object(e,n);if(t===91)return this.array(e,n);if(t===116)return this.literal("true",!0,n);if(t===102)return this.literal("false",!1,n);if(t===110)return this.literal("null",null,n);if(D(t))return this.number(n);(t===45||t===43||t===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(e,n,t){if(this.text.startsWith(e,this.at))return this.at+=e.length,n;e.startsWith(this.text.slice(this.at))&&this.fail("unexpected_end",`truncated literal ${e}`,t),this.fail("unexpected_token",`invalid literal (expected ${e})`,t)}number(e){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||k(i)||this.fail("invalid_number","number token must be 0 or [1-9][0-9]* (no leading zero, fraction or exponent)",e,n)}let t=Number(this.text.slice(n,this.at));return Number.isSafeInteger(t)||this.fail("unsafe_integer","integer exceeds 2^53-1",e,n),t}string(e,n=!1){let t=this.at;w.lastIndex=t;let i=w.exec(this.text);i===null&&this.diagnoseString(e,t);let s=i[0];this.at=w.lastIndex;let o=JSON.parse(s);return f(o)||this.fail("lone_surrogate","string contains an unpaired surrogate",e,t),this.strict&&this.violation===null&&s.includes("\\")&&this.escapes(s,t,n?l(e,o):e),o}diagnoseString(e,n){let t=this.text,i=n+1;for(;i<t.length;){let s=t.charCodeAt(i);if(s===34)break;if(s<32&&this.fail("invalid_string","unescaped control character in string",e,i),s===92){if(i+1>=t.length&&this.fail("unexpected_end","input ends inside an escape sequence",e,i),t.charCodeAt(i+1)===117){let c=t.slice(i+2,i+6);Y.test(c)||(i+6>t.length&&this.fail("unexpected_end","input ends inside a \\u escape",e,i),this.fail("invalid_string","\\u escape requires four hexadecimal digits",e,i)),i+=6;continue}'"\\/bfnrt'.includes(t[i+1])||this.fail("invalid_string","invalid escape sequence",e,i),i+=2;continue}i++}this.fail("unexpected_end","unterminated string",e,n)}escapes(e,n,t){for(let i=1;i<e.length-1;i++){if(e.charCodeAt(i)!==92)continue;let s=e[i+1];if(s==="u"){let o=e.slice(i+2,i+6),c=Number.parseInt(o,16);if(o!==o.toLowerCase()||c>=32||G.has(c)){this.note("escape",t,n+i);return}i+=5}else if(s==="/"){this.note("escape",t,n+i);return}else i+=1}}expect(e,n,t){this.at>=this.text.length&&this.fail("unexpected_end",n,t),this.text.charCodeAt(this.at)!==e&&this.fail("unexpected_token",n,t),this.at++}object(e,n){this.at++;let t=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++,t;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),c=l(n,o);h.test(o)||this.fail("invalid_key","keys must be nonempty printable ASCII (0x21-0x7e)",c,s),Object.hasOwn(t,o)&&this.fail("duplicate_key","duplicate key after escape decoding",c,s),i!==null&&o<i&&this.note("key_order",c,s),i=o,this.whitespace(n),this.expect(58,'expected ":" after key',c),t[o]=this.value(e+1,c),this.whitespace(n),this.at>=this.text.length&&this.fail("unexpected_end","unterminated object",n);let p=this.text.charCodeAt(this.at++);if(p===125)return t;p!==44&&this.fail("unexpected_token",'expected "," or "}"',n,this.at-1)}}array(e,n){this.at++;let t=[];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++,t;for(let i=0;;i++){t.push(this.value(e+1,l(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 t;s!==44&&this.fail("unexpected_token",'expected "," or "]"',n,this.at-1)}}};function S(r,e,n){let t=m(e,"decode"),i;if(typeof r=="string"){if(x(r)>t.maxBytes)throw new a("bytes_exceeded",`input exceeds maxBytes ${t.maxBytes}`,{path:"",offset:0});i=r}else if(d(r)){if(O(r)>t.maxBytes)throw new a("bytes_exceeded",`input exceeds maxBytes ${t.maxBytes}`,{path:"",offset:0});try{i=J.decode(r)}catch{throw new a("invalid_utf8","input is not valid UTF-8",{path:"",offset:Math.max(0,v(r))})}}else throw new a("invalid_input","input must be a Uint8Array or a string");return new N(i,n,t).document()}function Q(r,e){return S(r,e,!1)}function V(r,e){return S(r,e,!0)}var W=new TextEncoder,Z=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function U(r){if(!d(r)||r.length!==32)throw new a("invalid_options","sha256 must return 32 bytes");return r}function j(r,e){if(typeof r!="string"||r.length===0||r.includes("\0")||!f(r))throw new a("invalid_options","domain must be a nonempty well-formed string without U+0000");if(!d(e))throw new a("invalid_input","bytes must be a Uint8Array");let n=W.encode(r),t=new Uint8Array(n.length+1+e.length);return t.set(n,0),t[n.length]=0,t.set(e,n.length+1),t}function ee(r,e,n){if(typeof n!="function")throw new a("invalid_options","sha256 must be a function");let t=n(j(r,e));return t!==null&&typeof t=="object"&&typeof t.then=="function"?t.then(U):U(t)}function te(r){if(!d(r))throw new a("invalid_input","bytes must be a Uint8Array");let e="";for(let n=0;n<r.length;n++)e+=Z[r[n]];return e}export{a,E as b,q as c,Q as d,V as e,ee as f,te as g};
5
+ //# sourceMappingURL=tansr-chunk-MAMODDQN.mjs.map
@@ -0,0 +1,5 @@
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{h as l,i as c}from"./tansr-chunk-OEHA7T4Q.mjs";import{E as g,F as A}from"./tansr-chunk-EFN24XG3.mjs";import{a as m,b as u,h as p}from"./tansr-chunk-OKAA4BJC.mjs";var y=c.join(",");function E(e={}){return{accept:"application/json",[l]:y,...e}}var R="https://api.tansr.com",Se="tansr-cli";function _e(e){let r=e.TANSR_API_BASE_URL?.trim(),t=r!==void 0&&r!==""?r:R;return t.endsWith("/")?t.slice(0,-1):t}var d=class extends Error{status;code;constructor(r,t,i){super(i),this.name="AuthApiError",this.status=r,this.code=t}};async function S(e){let r=`http_${e.status}`,t=e.statusText;try{let i=await e.json();typeof i.error?.code=="string"&&(r=i.error.code),typeof i.error?.message=="string"&&(t=i.error.message)}catch{}return new d(e.status,r,t)}function T(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function _(e){try{let r=new URL(e);return r.pathname+r.search}catch{return p.handshake}}async function he(e,r,t){let i=e.fetchImpl??fetch,f=`${e.baseUrl}${p.handshake}`,n=await i(f,{method:"POST",headers:E({[m]:r,[u]:t,...A({signingKey:g(t),method:"POST",pathWithQuery:_(f)})})});if(!n.ok)throw await S(n);let a=null;try{a=await n.json()}catch{}let o=T(a)?a:{},s=T(o.app)?o.app:{};return{protocol:typeof o.protocol=="string"?o.protocol:"",app:{id:typeof s.id=="string"?s.id:"",name:typeof s.name=="string"?s.name:"",ownerType:typeof s.ownerType=="string"?s.ownerType:""},configEtag:typeof o.configEtag=="string"?o.configEtag:null,serverTime:typeof o.serverTime=="string"?o.serverTime:null,features:Array.isArray(o.features)?o.features.filter(P=>typeof P=="string"):[]}}export{E as a,Se as b,_e as c,d,he as e};
5
+ //# sourceMappingURL=tansr-chunk-N644DEOO.mjs.map
@@ -0,0 +1,5 @@
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 e={invalid:"cli.bundle.warn.invalid",entrySkipped:"cli.bundle.warn.entry_skipped",unreachable:"cli.bundle.warn.unreachable",staleCache:"cli.bundle.warn.stale_cache",reauthRequired:"cli.bundle.warn.reauth_required",governanceKeyIgnored:"cli.bundle.warn.governance_key_ignored",governanceKeyClamped:"cli.bundle.warn.governance_key_clamped",qualityWindowApplied:"cli.bundle.info.quality_window_applied",schemeInvalid:"cli.bundle.warn.scheme_invalid",contextSchemeLockedInvalid:"cli.bundle.error.context_scheme_locked_invalid",contextConfigurationUnavailable:"cli.bundle.error.context_configuration_unavailable",contextCacheInvalidationFailed:"cli.bundle.warn.context_cache_invalidation_failed",adjudicatorUnresolved:"cli.bundle.warn.adjudicator_unresolved",modelRoleUnavailable:"cli.bundle.warn.model_role_unavailable",modelRolePolicyInvalid:"cli.bundle.error.model_role_policy_invalid",modelPruned:"cli.bundle.warn.model_pruned",aliasPruned:"cli.bundle.warn.alias_pruned",selectionPruned:"cli.bundle.warn.selection_pruned",selectionInvalid:"cli.bundle.warn.selection_invalid",defaultFallback:"cli.bundle.warn.default_model_fallback",effectiveModelsEmpty:"cli.bundle.error.effective_models_empty",pinnedPolicyInvalid:"cli.bundle.warn.pinned_policy_invalid",budgetCurrencyKeyMissing:"cli.bundle.warn.budget_currency_key_missing",budgetCurrencyUnknown:"cli.bundle.warn.budget_currency_unknown",contextSchemeLocked:"cli.bundle.info.context_scheme_locked",schemeOverrideRejected:"cli.bundle.warn.context_scheme_override_rejected",adjudicatorOverrideRejected:"cli.bundle.warn.adjudicator_override_rejected",configRefreshed:"cli.bundle.info.config_refreshed",configRefreshModels:"cli.bundle.info.config_refresh_models",configRefreshModelRoles:"cli.bundle.info.config_refresh_model_roles",configRefreshAliasMain:"cli.bundle.info.config_refresh_alias_main",configRefreshAliasFast:"cli.bundle.info.config_refresh_alias_fast",configRefreshFastGroup:"cli.bundle.info.config_refresh_fast_group",configRefreshDirect:"cli.bundle.info.config_refresh_direct",configRefreshAdjudicator:"cli.bundle.info.config_refresh_adjudicator",configRefreshScheme:"cli.bundle.info.config_refresh_scheme",taskConcurrencyUpdated:"cli.bundle.info.task_concurrency_updated",configRefreshColdMarker:"cli.bundle.info.config_refresh_cold_marker",configRefreshNoChange:"cli.bundle.info.config_refresh_no_change",platformWarning:"cli.bundle.warn.platform_warning",usageEstimated:"cli.bundle.warn.usage_estimated",dailyTokenLimit:"cli.bundle.warn.daily_token_limit",idempotencyConflict:"cli.bundle.warn.idempotency_conflict",idempotencyNotReplayable:"cli.bundle.warn.idempotency_not_replayable",signatureRejected:"cli.bundle.warn.signature_rejected",serverBelowFloor:"cli.bundle.warn.server_below_floor",orgSoftLockIssued:"cli.bundle.warn.org_soft_lock_issued",orgSoftLockSuspended:"cli.bundle.warn.org_soft_lock_suspended",orgSoftLockExpired:"cli.bundle.warn.org_soft_lock_expired",orgSoftLock:"cli.bundle.warn.org_soft_lock",orgSoftLockLifted:"cli.bundle.info.org_soft_lock_lifted",licenseRequiredNone:"cli.bundle.error.license_required_none",licenseRequiredIssued:"cli.bundle.error.license_required_issued",licenseRequiredSuspended:"cli.bundle.error.license_required_suspended",licenseRequiredRevoked:"cli.bundle.error.license_required_revoked",licenseRequiredExpired:"cli.bundle.error.license_required_expired",licenseRequired:"cli.bundle.error.license_required",licenseRequiredUnavailable:"cli.bundle.error.license_required_unavailable",directEndpointRetired:"cli.bundle.warn.direct_endpoint_retired",orgMemoryDenied:"cli.bundle.warn.org_memory_denied",orgMemoryDenyLifted:"cli.bundle.info.org_memory_deny_lifted",settingsLockedLocalIgnored:"cli.bundle.warn.settings_locked_local_ignored",settingsLockedEnvIgnored:"cli.bundle.warn.settings_locked_env_ignored",settingsLockedFlagIgnored:"cli.bundle.warn.settings_locked_flag_ignored",settingsShadowObserving:"cli.bundle.warn.settings_shadow_observing",settingsSectionIgnored:"cli.bundle.warn.settings_section_ignored",settingsKeyInvalid:"cli.bundle.warn.settings_key_invalid",settingsKeyUnknown:"cli.bundle.warn.settings_key_unknown",settingsDiscarded:"cli.bundle.warn.settings_discarded",planConcurrencyExceeded:"cli.bundle.warn.plan_concurrency_exceeded",planConcurrencyExceededGeneric:"cli.bundle.warn.plan_concurrency_exceeded_generic"},n=Object.values(e);export{e as a};
5
+ //# sourceMappingURL=tansr-chunk-NQOYEFEE.mjs.map