@tansr/cli 0.9.0 → 0.10.1

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 (87) hide show
  1. package/NOTICE +1 -1
  2. package/package.json +1 -1
  3. package/tansr-artifacts.json +1309 -0
  4. package/tansr-bg-OUP4JX3I.mjs +5 -0
  5. package/tansr-chunk-2AJTBN37.mjs +29 -0
  6. package/tansr-chunk-2C6JKHKM.mjs +25 -0
  7. package/tansr-chunk-2QKLANZQ.mjs +7 -0
  8. package/tansr-chunk-3GJD3L4B.mjs +22 -0
  9. package/tansr-chunk-4R5ZK4RG.mjs +21 -0
  10. package/tansr-chunk-54YMMSEF.mjs +35 -0
  11. package/tansr-chunk-5T7X32UX.mjs +6 -0
  12. package/tansr-chunk-5VWLEU5D.mjs +4 -0
  13. package/tansr-chunk-726Y5F3M.mjs +5 -0
  14. package/tansr-chunk-AEIS2NWD.mjs +37 -0
  15. package/tansr-chunk-AMMPDY4V.mjs +5 -0
  16. package/tansr-chunk-BCOFZJWA.mjs +279 -0
  17. package/tansr-chunk-BX7CF5RQ.mjs +25 -0
  18. package/tansr-chunk-C6COFFZK.mjs +12 -0
  19. package/tansr-chunk-C7GGA5ID.mjs +5 -0
  20. package/tansr-chunk-DIT3PBNB.mjs +5 -0
  21. package/tansr-chunk-F5STVU7J.mjs +5 -0
  22. package/tansr-chunk-F7C6ITED.mjs +5 -0
  23. package/tansr-chunk-HQY7FXGU.mjs +67 -0
  24. package/tansr-chunk-HRKJLVKC.mjs +7 -0
  25. package/tansr-chunk-I3TOVAA6.mjs +5 -0
  26. package/tansr-chunk-J2ED6CI4.mjs +5 -0
  27. package/tansr-chunk-LLW6GX7K.mjs +38 -0
  28. package/tansr-chunk-LSGFLGLS.mjs +7 -0
  29. package/tansr-chunk-M63EZH2M.mjs +8 -0
  30. package/tansr-chunk-M774GK3P.mjs +6 -0
  31. package/tansr-chunk-MWHLITGY.mjs +11 -0
  32. package/tansr-chunk-MXYVQZY3.mjs +5 -0
  33. package/tansr-chunk-NA22YT73.mjs +5 -0
  34. package/tansr-chunk-NCIMR6LB.mjs +5 -0
  35. package/tansr-chunk-NROI7AG5.mjs +5 -0
  36. package/tansr-chunk-OKAA4BJC.mjs +5 -0
  37. package/tansr-chunk-OSK64SU3.mjs +5 -0
  38. package/tansr-chunk-PIET7WB3.mjs +5 -0
  39. package/tansr-chunk-Q6MUMULP.mjs +5 -0
  40. package/tansr-chunk-QEKVLX7W.mjs +5 -0
  41. package/tansr-chunk-QHEQQ2JB.mjs +9 -0
  42. package/tansr-chunk-QNHXB55W.mjs +11 -0
  43. package/tansr-chunk-QWGSXFEJ.mjs +7 -0
  44. package/tansr-chunk-R4W5HKDF.mjs +12 -0
  45. package/tansr-chunk-RRAMVVYF.mjs +5 -0
  46. package/tansr-chunk-RVSBSUXE.mjs +5 -0
  47. package/tansr-chunk-S3KHAGOR.mjs +5 -0
  48. package/tansr-chunk-S77B4PI7.mjs +6 -0
  49. package/tansr-chunk-SJFDQLLC.mjs +5 -0
  50. package/tansr-chunk-TYJWMSVW.mjs +5 -0
  51. package/tansr-chunk-UAEARRRH.mjs +8 -0
  52. package/tansr-chunk-WW5ZPL6Q.mjs +5 -0
  53. package/tansr-chunk-XAQNKJIC.mjs +4 -0
  54. package/tansr-chunk-XIOD3RQD.mjs +23 -0
  55. package/tansr-chunk-XXBNISJJ.mjs +7 -0
  56. package/tansr-chunk-YAYVXUHY.mjs +6 -0
  57. package/tansr-chunk-ZQ3ZK7IL.mjs +37 -0
  58. package/tansr-ink-devtools-stub-GTR5M7WR.mjs +4 -0
  59. package/tansr-main-O6RSYTGN.mjs +7 -0
  60. package/tansr-marked.esm-R6UL3675.mjs +68 -0
  61. package/tansr-portal-FWLKNJM2.mjs +5 -0
  62. package/tansr-render-PUEISX75.mjs +6 -0
  63. package/tansr-run-acp-entry-XJMGBZ7Q.mjs +63 -0
  64. package/tansr-run-approvals-entry-I6FX6AYX.mjs +12 -0
  65. package/tansr-run-auth-entry-LJC3UJWR.mjs +36 -0
  66. package/tansr-run-doctor-RFMVNKS5.mjs +10 -0
  67. package/tansr-run-headless-entry-G2G44HY3.mjs +78 -0
  68. package/tansr-run-init-entry-JVJEH4PI.mjs +5 -0
  69. package/tansr-run-logout-entry-DI42PBLR.mjs +5 -0
  70. package/tansr-run-mcp-serve-entry-ZPOSEKDA.mjs +14 -0
  71. package/tansr-run-orchestrate-entry-43QIZUZA.mjs +11 -0
  72. package/tansr-run-org-entry-D2FTJY7E.mjs +17 -0
  73. package/tansr-run-policy-entry-SLI4BZ2I.mjs +16 -0
  74. package/tansr-run-profile-entry-643TLJUU.mjs +14 -0
  75. package/tansr-run-serve-entry-CX6EBQAV.mjs +99 -0
  76. package/tansr-run-sessions-entry-MROXZKQS.mjs +23 -0
  77. package/tansr-run-update-entry-BOZIZIWN.mjs +5 -0
  78. package/tansr-sqlite-event-store-UQLSSZKP.mjs +26 -0
  79. package/tansr-sqlite-spool-implementation-LHEIRSUX.mjs +29 -0
  80. package/tansr-src-5BMLUX6E.mjs +143 -0
  81. package/tansr-src-KOEPYVXX.mjs +5 -0
  82. package/tansr-startup-account-YMNFBBH2.mjs +7 -0
  83. package/tansr-startup-model-LYYMNZ32.mjs +6 -0
  84. package/tansr-tui-4EYUVRFQ.mjs +75 -0
  85. package/tansr-undici.cjs +49 -0
  86. package/tansr.mjs +1 -1180
  87. package/tansrd.mjs +772 -0
@@ -0,0 +1,7 @@
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{Pa as l,Qa as v}from"./tansr-chunk-HQY7FXGU.mjs";import{cf as y,ve as u,we as d,xe as p}from"./tansr-chunk-BCOFZJWA.mjs";import{m as i}from"./tansr-chunk-NA22YT73.mjs";function W(n){let{engine:M,contextEvents:r,emitUsage:g,tuning:t={},onRequestMeasured:x,usageObserver:f,notifyWriteBlocked:a,notifySaved:E=()=>{},stderr:s=process.stderr,...o}=n;return{...o,interactive:!0,writePlanePreflight:u(M,o.memoryDir,o.cwd),onWritePlaneBlocked:e=>s.write(i(y.memoryWritePlaneBlocked,{detail:d(e)})+`
5
+ `),onWriteBlockedUpstream:e=>{let m=v(e),c=i(m.key,m.params);a!==void 0?a(c):s.write(c+`
6
+ `)},...t.inviteGate!==void 0?{inviteGate:t.inviteGate}:{},...t.backpressureInterval!==void 0?{backpressureInterval:t.backpressureInterval}:{},...t.extractionTruncation!==void 0?{extractionTruncation:t.extractionTruncation}:{},...t.truncationRecentRounds!==void 0?{truncationRecentRounds:t.truncationRecentRounds}:{},...t.runImpl!==void 0?{runImpl:t.runImpl}:{},probeWrite:e=>r().memoryWrite({...e,source:"extract"}),probeInvite:e=>r().memoryInvite(e),probeExtraction:e=>r().memoryExtraction(e),onUsage:e=>g(p(e)),requestMeasurement:{onRequestMeasured:x??(e=>{r().observer.onRequestMeasured?.(e),f?.(e)})},notifySaved:E}}function R(n){return l(W(n))}export{R as a};
7
+ //# sourceMappingURL=tansr-chunk-LSGFLGLS.mjs.map
@@ -0,0 +1,8 @@
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{E as Ne,i as Te,k as xe}from"./tansr-chunk-3GJD3L4B.mjs";import{c as J,d as q,j as P,o as Re,s as Se}from"./tansr-chunk-HRKJLVKC.mjs";import{$d as ke,_d as be,ae as ve,be as Ee,ce as Q,cf as Ie,df as R,fe as U,ge as C,he as Ae,ie as _e,je as Pe}from"./tansr-chunk-BCOFZJWA.mjs";import{D as ee,F as Oe,G as Le,K as Ce,L as Me}from"./tansr-chunk-2C6JKHKM.mjs";import{d as he}from"./tansr-chunk-DIT3PBNB.mjs";var ne={app_model_selection_empty:"cli.bundle.error.app_model_selection_empty",owner_model_selection_empty:"cli.bundle.error.owner_model_selection_empty",default_model_pool_empty:"cli.bundle.error.default_model_pool_empty",selected_models_unavailable:"cli.bundle.error.selected_models_unavailable"},M="tansr",je="TANSR_KEY",vn="TANSR_DIRECT_KEYLESS",En=["imagegen","videogen","asr","tts"],Be=Object.freeze({imageGen:Object.freeze([]),videoGen:Object.freeze([]),speechToText:Object.freeze([]),textToSpeech:Object.freeze([])}),Fe=["test","small","medium","large"],An=["active","grace","lapsed"];function f(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function _n(e){if(!f(e)||typeof e.handle!="string"||e.handle===""||typeof e.modelId!="string"||e.modelId===""||typeof e.protocol!="string")return null;let n=Te(e.adapterDiagnostics),t=e.pricing,o=null;return f(t)&&typeof t.currency=="string"&&typeof t.inPerMillion=="string"&&typeof t.outPerMillion=="string"&&(o={currency:t.currency,inPerMillion:t.inPerMillion,outPerMillion:t.outPerMillion,cacheReadPerMillion:typeof t.cacheReadPerMillion=="string"?t.cacheReadPerMillion:"0",cacheWritePerMillion:typeof t.cacheWritePerMillion=="string"?t.cacheWritePerMillion:"0"}),{handle:e.handle,modelId:e.modelId,displayName:typeof e.displayName=="string"?e.displayName:e.handle,protocol:e.protocol,kind:typeof e.kind=="string"&&e.kind!==""?e.kind:null,family:typeof e.family=="string"&&e.family!==""?e.family:null,manufacturer:typeof e.manufacturer=="string"&&e.manufacturer!==""?e.manufacturer:null,tags:Array.isArray(e.tags)?e.tags.filter(r=>typeof r=="string"&&r!==""):[],capabilities:f(e.capabilities)?e.capabilities:{},contextWindow:typeof e.contextWindow=="number"?e.contextWindow:null,recommendedContextTokens:typeof e.recommendedContextTokens=="number"?e.recommendedContextTokens:null,pricing:o,...n===void 0?{}:{adapterDiagnostics:n}}}function Pn(e){return!f(e)||typeof e.handle!="string"||e.handle===""||typeof e.baseUrl!="string"||e.baseUrl===""||typeof e.protocol!="string"||typeof e.modelId!="string"||e.modelId===""?null:{handle:e.handle,baseUrl:e.baseUrl,protocol:e.protocol,modelId:e.modelId,credentialEnv:typeof e.credentialEnv=="string"?e.credentialEnv:null}}function Ue(e){return Array.isArray(e)?f(e[0])?e[0]:null:f(e)?e:null}function De(e){let n=Ue(e);return n===null||typeof n.profileId!="string"||n.profileId===""||n.modelHandle!==void 0&&(typeof n.modelHandle!="string"||n.modelHandle==="")?null:{profileId:n.profileId,...n.modelHandle!==void 0?{modelHandle:n.modelHandle}:{},budgets:f(n.budgets)?n.budgets:{},escalation:f(n.escalation)?n.escalation:{},...n.locked===!0?{locked:!0}:{}}}function On(e){if(Array.isArray(e.adjudicators))return e.adjudicators.map(De).filter(t=>t!==null);let n=De(e.adjudicator);return n!==null?[n]:[]}function Ln(e){let n=Ue(e);return n===null||typeof n.schemeId!="string"||n.schemeId===""?null:{schemeId:n.schemeId,stage:n.stage==="production"?"production":"experimental",scheme:f(n.scheme)?n.scheme:{},...n.locked===!0?{locked:!0}:{}}}function Cn(e){if(!f(e))return null;let n=e.dailyTokenLimit;return typeof n=="number"&&Number.isFinite(n)&&n>0?{dailyTokenLimit:Math.floor(n)}:null}function Mn(e){if(!f(e))return null;let n=e.org;if(!f(n)||typeof n.id!="string"||n.id==="")return null;let t=null;if(f(e.budgets)){let o=e.budgets.dailyTokenLimit;t={dailyTokenLimit:typeof o=="number"&&Number.isFinite(o)&&o>0?Math.floor(o):null}}return{org:{id:n.id,name:typeof n.name=="string"?n.name:""},licenseStatus:typeof e.licenseStatus=="string"?e.licenseStatus:"",softLock:e.softLock===!0,budgets:t}}function In(e){if(!f(e)||e.enabled!==!0)return null;let n=e.dailyLimit;return{enabled:!0,pricePerCall:typeof e.pricePerCall=="string"&&e.pricePerCall!==""?e.pricePerCall:null,currency:typeof e.currency=="string"&&e.currency!==""?e.currency:null,dailyLimit:typeof n=="number"&&Number.isFinite(n)&&n>0?Math.floor(n):null,defaultVendor:typeof e.defaultVendor=="string"&&e.defaultVendor!==""?e.defaultVendor:null}}function W(e){if(!f(e)||e.enabled!==!0)return null;let n=e.dailyLimit;return{enabled:!0,dailyLimit:typeof n=="number"&&Number.isFinite(n)&&n>0?Math.floor(n):null}}function Tn(e){if(!f(e))return null;let n={imagegen:W(e.imagegen),videogen:W(e.videogen),asr:W(e.asr),tts:W(e.tts)};return En.some(t=>n[t]!==null)?n:null}function xn(e){if(!f(e))return Be;let n=xe({platformModels:e});if(n===null)return Be;let{imageGen:t,videoGen:o,speechToText:r,textToSpeech:i}=n.platformModels;return{imageGen:t,videoGen:o,speechToText:r,textToSpeech:i}}function Nn(e){return f(e)&&(e.mode==="allow"||e.mode==="deny")?{mode:e.mode}:null}function $(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0}function Bn(e){if(!f(e))return null;let n=e.tier;if(typeof n!="string"||!Fe.includes(n))return null;let t=e.caps;if(!f(t)||!$(t.concurrency)||!$(t.apps)||!$(t.orgMembers)||!(t.monthlyEndUsers===null||$(t.monthlyEndUsers))||typeof t.gatewayLane!="boolean")return null;let o=e.status;if(typeof o!="string"||!An.includes(o)||typeof e.expiresAt!="string"||e.expiresAt==="")return null;let r=e.lapsedFrom;return{tier:n,caps:{concurrency:t.concurrency,apps:t.apps,orgMembers:t.orgMembers,monthlyEndUsers:t.monthlyEndUsers,gatewayLane:t.gatewayLane},status:o,expiresAt:e.expiresAt,...typeof r=="string"&&Fe.includes(r)?{lapsedFrom:r}:{}}}var Fn=["platform","org","team","user"];function Dn(e){if(!f(e)||!f(e.values))return null;let n=o=>Array.isArray(o)?[...new Set(o.filter(r=>typeof r=="string"&&r!==""))]:[],t={};if(f(e.origins))for(let[o,r]of Object.entries(e.origins))typeof r=="string"&&Fn.includes(r)&&(t[o]=r);return{values:structuredClone(e.values),locks:n(e.locks),origins:t,shadow:n(e.shadow)}}function Ve(e){if(!f(e)||typeof e.version!="number"||typeof e.etag!="string")return null;let n=Array.isArray(e.diagnostics)?e.diagnostics.find(l=>f(l)&&typeof l.code=="string"&&Object.hasOwn(ne,l.code))?.code:e.modelAvailabilityReason,t=Array.isArray(e.models)?e.models.map(_n).filter(l=>l!==null):[],o=Array.isArray(e.directEndpoints)?e.directEndpoints.map(Pn).filter(l=>l!==null):[],r={};if(f(e.aliases))for(let[l,p]of Object.entries(e.aliases))typeof p=="string"&&p!==""&&(r[l]=p);let i=Array.isArray(e.fastFallbackGroup)?e.fastFallbackGroup.filter(l=>typeof l=="string"&&l!==""):[],a=(()=>{if(!f(e.aliasOrigins))return null;let l={};return typeof e.aliasOrigins.main=="string"&&e.aliasOrigins.main!==""&&(l.main=e.aliasOrigins.main),typeof e.aliasOrigins.fast=="string"&&e.aliasOrigins.fast!==""&&(l.fast=e.aliasOrigins.fast),Object.keys(l).length>0?l:null})(),c=f(e.app)&&typeof e.app.id=="string"&&e.app.id!==""?{id:e.app.id,name:typeof e.app.name=="string"?e.app.name:""}:null,s=On(e);return{...typeof n=="string"&&Object.hasOwn(ne,n)?{modelAvailabilityReason:n}:{},version:e.version,etag:e.etag,publishedAt:typeof e.publishedAt=="string"?e.publishedAt:"",configVersion:typeof e.configVersion=="string"&&e.configVersion!==""?e.configVersion:null,app:c,models:t,aliases:r,fastFallbackGroup:i,aliasOrigins:a,directEndpoints:o,adjudicators:s,adjudicator:s[0]??null,contextScheme:Ln(e.contextScheme),guardrails:Cn(e.guardrails),orgGovernance:Mn(e.governance??e.orgGovernance),websearch:In(e.websearch),orgMemory:Nn(e.orgMemory),settings:Dn(e.settings),plan:Bn(e.plan),media:Tn(e.media),platformModels:xn(e.platformModels)}}function wn(e){switch(e){case"openai_chat":case"openai":return"openai";case"anthropic_messages":case"anthropic":return"anthropic";case"openai_responses":case"openai-responses":return"openai-responses";default:return null}}function jn(e,n){let t=be.safeParse(e),o=t.success?t.data:{},r=!t.success&&Object.keys(e).length>0,i={...o,...n!==null&&n>0?{maxContext:n}:{}};return{override:Object.keys(i).length>0?i:void 0,dropped:r}}function Un(e,n){return e===null||e<=0||n===null||n<=0||n>=e?{effectiveWindow:e,clamped:!1}:{effectiveWindow:n,clamped:!0}}function Vn(e){if(e===null)return null;let n=Number(e.inPerMillion),t=Number(e.outPerMillion);if(!Number.isFinite(n)||!Number.isFinite(t))return null;let o=Number(e.cacheReadPerMillion);return{inputPerMillion:n,outputPerMillion:t,...Number.isFinite(o)&&o>0?{cachedInputPerMillion:o}:{}}}function Lt(e){return{providers:{[M]:{protocol:"twp",baseUrl:`${e}/t1`,auth:{env:je},models:{}}},modelAliases:{}}}function Ct(e,n){let t=[];e.models.length===0&&e.modelAvailabilityReason!==void 0&&t.push({key:ne[e.modelAvailabilityReason]});let o=[],r={protocol:"twp",baseUrl:`${n}/t1`,auth:{env:je},models:{},pricing:{},modelCapabilities:{}},i={};for(let s of e.models){r.models[s.handle]=s.handle,i[s.handle]=`${M}/${s.handle}`;let{effectiveWindow:l,clamped:p}=Un(s.contextWindow,s.recommendedContextTokens),{override:b,dropped:S}=jn(s.capabilities,l);p&&t.push({key:R.qualityWindowApplied,params:{handle:s.handle,declared:s.contextWindow??0,effective:l??0}}),S&&t.push({key:R.entrySkipped,params:{handle:s.handle,reason:"capabilities"}}),b!==void 0&&r.modelCapabilities!==void 0&&(r.modelCapabilities[s.handle]=b);let m=Vn(s.pricing);if(m!==null&&r.pricing!==void 0){r.pricing[s.handle]=m;let y=s.pricing?.currency;y!==void 0&&_e.includes(y)?o.push({providerId:M,modelName:s.handle,currency:y,pricing:m,note:"client-config bundle"}):y!==void 0&&t.push({key:R.entrySkipped,params:{handle:s.handle,reason:`currency ${y}`}})}}let a={[M]:r},c={};for(let s of e.directEndpoints){let l=wn(s.protocol);if(l===null){t.push({key:R.entrySkipped,params:{handle:s.handle,reason:`protocol ${s.protocol}`}});continue}if(s.handle===M){t.push({key:R.entrySkipped,params:{handle:s.handle,reason:"reserved handle"}});continue}a[s.handle]={protocol:l,baseUrl:s.baseUrl,auth:{env:s.credentialEnv??vn},models:{}},c[s.handle]=`${s.handle}/${s.modelId}`}for(let[s,l]of Object.entries(e.aliases))c[s]=l.includes("/")?l:`${M}/${l}`;return{fragment:{providers:a,modelAliases:c,catalogAliases:i},diagnostics:t,pricingUpdates:o}}function Mt(e){if(e.length===0)return;let n=Pe();return n.refreshPricing(e,"refreshed"),n}var we=new Set(["__proto__","constructor","prototype"]);function te(e,n){if(f(e)&&f(n)){let t={};for(let o of Object.keys(e))we.has(o)||(t[o]=e[o]);for(let o of Object.keys(n))we.has(o)||(t[o]=o in t?te(t[o],n[o]):n[o]);return t}return n}function Gn(){return{$schemaVersion:1,providers:{},modelAliases:{},fallbacks:{},telemetry:{enabled:!1}}}function It(e,n,t){let o=e??Gn(),r=te(n.providers,o.providers),i={...t?.catalogAliases??{},...n.modelAliases,...o.modelAliases};return t!==null&&(r=te(r,t.providers),i={...i,...t.modelAliases}),{...o,providers:r,modelAliases:i}}import Kn from"node:os";import Ge from"node:path";var Yn="TANSR_RECORD",oe;function Wn(e){if(oe===void 0){let n=e().toISOString();oe=`${n.slice(0,10).replaceAll("-","")}-${n.slice(11,19).replaceAll(":","")}-${process.pid}`}return oe}var Ke=0;function Ye(e){return e.replaceAll(/[^A-Za-z0-9._-]/g,"_")}function re(e,n,t={}){let o=t.env??process.env;if(o[Yn]?.trim()!=="1")return e;let r=t.homedir??(()=>Kn.homedir()),i=t.now??(()=>new Date),a=o.TANSR_CONFIG_DIR?.trim(),c=a!==void 0&&a!==""?a:Ge.join(r(),".tansr"),s=Ge.join(c,"recordings",Wn(i));Ke+=1;let l=`${String(Ke).padStart(2,"0")}-${Ye(n.providerId)}-${Ye(n.modelName)}`;return new Le({inner:e,dir:s,name:l,source:`${n.providerId}/${n.modelName}`,env:o,now:i})}var V={anthropicUrl:"TANSR_TEST_ANTHROPIC_URL",openaiUrl:"TANSR_TEST_OPENAI_URL",model:"TANSR_TEST_MODEL",apiKey:"TANSR_TEST_API_KEY"};function Ut(e,n,t={}){let o=new ee(e,{...t.env!==void 0?{env:t.env}:{},...t.fetchImpl!==void 0?{fetchImpl:t.fetchImpl}:{},...t.twp!==void 0?{twp:t.twp}:{},...t.governor!==void 0?{governor:t.governor}:{}}),{client:r,resolved:i}=Ce(o,n,{...t.onProviderSelected!==void 0?{onProviderSelected:t.onProviderSelected}:{},...t.attemptObserver!==void 0?{attemptObserver:t.attemptObserver}:{},...t.governor!==void 0?{governor:t.governor}:{}});return{client:re(r,i,{...t.env!==void 0?{env:t.env}:{}}),resolved:i,registry:o}}var $n=2;function Vt(e,n,t={}){let o=new ee(e,{...t.env!==void 0?{env:t.env}:{},...t.fetchImpl!==void 0?{fetchImpl:t.fetchImpl}:{},...t.twp!==void 0?{twp:t.twp}:{},...t.governor!==void 0?{governor:t.governor}:{}}),r=o.resolveAlias(n),i=o.createClient(r),a=o.fallbacksFor(n),c=Me(t.governor),s=new Oe({entries:a,createClient:l=>l===a[0]?i:o.createClient(l),retry:{...c.retry??{},maxAttempts:$n},...c.retryBudget!==void 0?{retryBudget:c.retryBudget}:{},...t.onProviderSelected!==void 0?{onProviderSelected:t.onProviderSelected}:{},...t.attemptObserver!==void 0?{attemptObserver:t.attemptObserver}:{}});return{client:re(s,r,{...t.env!==void 0?{env:t.env}:{}}),resolved:r}}function ie(e,n){let t=e[n]?.trim();return t===void 0||t===""?void 0:t}function We(e){let n=ie(e,V.anthropicUrl),t=ie(e,V.openaiUrl),o=ie(e,V.model);if(o===void 0||n===void 0&&t===void 0)return null;let r={};return n!==void 0&&(r["maas-anthropic"]={protocol:"anthropic",baseUrl:n,auth:{env:V.apiKey},models:{main:o}}),t!==void 0&&(r["maas-openai"]={protocol:"openai",baseUrl:t,auth:{env:V.apiKey},models:{main:o}}),{$schemaVersion:1,providers:r,modelAliases:{main:`${n!==void 0?"maas-anthropic":"maas-openai"}/main`},fallbacks:{},telemetry:{enabled:!1}}}import{readdir as Zn,readFile as Hn,rm as zn}from"node:fs/promises";import le from"node:os";import Z from"node:path";var Xn="bundle-cache",Jn=384;function qn(e){return`${e.replace(/[^A-Za-z0-9-]/g,t=>`_${t.codePointAt(0).toString(16)}`)}.json`}function Ze(e,n,t=le.homedir()){let o=P(e,t);return o!==null?o.bundleCacheFile:Z.join(He(e,t),qn(n))}function He(e,n=le.homedir()){let t=e.TANSR_CONFIG_DIR?.trim(),o=t!==void 0&&t!==""?t:Z.join(n,".tansr");return Z.join(o,Xn)}async function Xt(e,n=le.homedir()){let t=[],o=He(e,n),r=[];try{r=await Zn(o)}catch{r=[]}for(let a of r){if(!a.endsWith(".json"))continue;let c=Z.join(o,a);await $e(c)&&t.push(c)}let i=P(e,n);return i!==null&&await $e(i.bundleCacheFile)&&t.push(i.bundleCacheFile),t}async function $e(e){try{return await zn(e),!0}catch{return!1}}async function se(e,n,t=o=>Hn(o,"utf8")){let o;try{o=await t(e)}catch{return null}let r;try{r=JSON.parse(o)}catch{return null}if(typeof r!="object"||r===null)return null;let i=r;if(i.version!==1||i.apiBaseUrl!==n||typeof i.etag!="string"||typeof i.fetchedAt!="string")return null;let a=Date.parse(i.fetchedAt);if(Number.isNaN(a))return null;let c=Ve(i.bundle);return c===null?null:{etag:i.etag,fetchedAtMs:a,bundle:c}}async function Qn(e,n){let t={version:1,apiBaseUrl:n.apiBaseUrl,etag:n.etag,fetchedAt:new Date(n.fetchedAtMs).toISOString(),bundle:n.bundle};await Re(e,JSON.stringify(t,null,2)+`
5
+ `,{mode:Jn})}async function Jt(e,n,t){let o=await se(e,n);o!==null&&await Qn(e,{apiBaseUrl:n,etag:o.etag,fetchedAtMs:t,bundle:o.bundle})}import{readFile as et}from"node:fs/promises";import nt from"node:os";var ao="remote:org",tt=ve.filter(e=>!Ee.includes(e)),ot=["TANSR_OFFLINE","TANSR_ALLOW_ROOT_BYPASS"],rt=[{env:"TANSR_LANG",keyPath:"locale"},{env:"TANSR_EFFORT",keyPath:"effort"},{env:"TANSR_OUTPUT_STYLE",keyPath:"outputStyle"},{env:"TANSR_SANDBOX",keyPath:"sandbox.mode"},{env:"TANSR_AUDIT",keyPath:"audit.enabled"},{env:"TANSR_AUDIT_DIR",keyPath:"audit.dir"},{env:"TANSR_SEMANTIC_INDEX_URL",keyPath:"semanticIndex.url"},{env:"TANSR_SEMANTIC_INDEX_REPO",keyPath:"semanticIndex.repoId"},{env:"TANSR_SEMANTIC_INDEX_BRANCH",keyPath:"semanticIndex.branch"},{env:"TANSR_SEMANTIC_INDEX_TIMEOUT_MS",keyPath:"semanticIndex.timeoutMs"},{env:"TANSR_UPDATE_CHANNEL",keyPath:"update.channel"},{env:"TANSR_UPDATE_PINNED_VERSION",keyPath:"update.pinnedVersion"},{env:"TANSR_UPDATE_MANIFEST_URL",keyPath:"update.manifestUrl"},{env:"TANSR_NO_UPDATE_CHECK",keyPath:"update.checkEnabled"}],qe=[{option:"lang",flag:"--lang",keyPath:"locale"},{option:"effort",flag:"--effort",keyPath:"effort"},{option:"outputStyle",flag:"--output-style",keyPath:"outputStyle"},{option:"maxBudgetUsd",flag:"--max-budget-usd",keyPath:"budget.maxUsd"},{option:"model",flag:"--model",keyPath:"model.selected"},{option:"theme",flag:"--theme",keyPath:"ui.theme"},{option:"contextScheme",flag:"--context-scheme",keyPath:"context.activeScheme"}];function co(e){return qe.filter(n=>e[n.option]!==void 0).map(n=>({flag:n.flag,keyPath:n.keyPath}))}function uo(e,n){if(e===void 0||e.suppressedFlags.length===0)return n;let t={...n};for(let o of qe)n[o.option]!==void 0&&e.suppressedFlags.includes(o.flag)&&delete t[o.option];return t}var ae=[];function Qe(e){ae=e}function fo(){let e=ae;return ae=[],e}var it="TANSR_ESCAPE_LOCAL";function H(e){return e[it]==="1"}var en="mode.localProviders",ce={active:"cli.escape.active",pruned:"cli.escape.pruned"};function nn(e){if(e===null)return!1;let n=O(en);if(e.shadow.some(o=>I(n,O(o))))return!1;let t=e.values.mode;return E(t)?t.localProviders===!0:!1}async function tn(e){if(H(e.env))return null;let n=e.readFile??(i=>et(i,"utf8")),t=e.homedir??nt.homedir(),o;try{let i=JSON.parse(await n(Se(e.env,t))),a=typeof i.keyId=="string"&&i.keyId!==""?i.keyId:typeof i.derivedApp?.keyId=="string"&&i.derivedApp.keyId!==""?i.derivedApp.keyId:null;if(a===null)return null;o=a}catch{return null}return(await se(Ze(e.env,o,t),Ne(e.env),n))?.bundle.settings??null}var G=new Set(["__proto__","constructor","prototype"]),lt=["site."];function st(e){return lt.some(n=>e===n.slice(0,-1)||e.startsWith(n))}function E(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function O(e){return e.split(".")}function I(e,n){return n.length>e.length?!1:n.every((t,o)=>t===e[o])}function ze(e,n){return n.length<=e.length?!1:e.every((t,o)=>t===n[o])}function Xe(e,n){return I(e,n)||I(n,e)}function on(e,n){if(E(e)&&E(n)){let t={};for(let o of Object.keys(e))G.has(o)||(t[o]=e[o]);for(let o of Object.keys(n))G.has(o)||(t[o]=Object.prototype.hasOwnProperty.call(t,o)?on(t[o],n[o]):n[o]);return t}return n}function A(e,n){let t=e;for(let o of n){if(!E(t)||!Object.prototype.hasOwnProperty.call(t,o))return!1;t=t[o]}return!0}function Je(e,n,t){let o=e;for(let r=0;r<n.length-1;r++){let i=n[r];E(o[i])||(o[i]={}),o=o[i]}o[n[n.length-1]]=t}function de(e,n){if(n.length===0)return;let t=[e],o=e;for(let r=0;r<n.length-1;r++){let i=o[n[r]];if(!E(i))return;o=i,t.push(o)}delete o[n[n.length-1]];for(let r=t.length-1;r>0&&Object.keys(t[r]).length===0;r--)delete t[r-1][n[r-1]]}function dt(e,n){let t=[],o=e;for(let r=0;r<n.length;r++){let i=n[r];if(typeof i=="number")return t;t.push(i);let a=E(o)?o[i]:void 0;if(Array.isArray(a)&&r<n.length-1||typeof n[r+1]=="number")return t;o=a}return t}function rn(e,n,t){if(E(e)){let o=Object.keys(e);if(o.length>0){for(let r of o)rn(e[r],[...n,r],t);return}}n.length>0&&t.push(n)}var at=16;function ct(e,n,t){return n===void 0||!t.locked&&!t.unlocked||!t.locked&&e.allowedAuthEnvVarsLayer==="managed"?e:{...e,allowedAuthEnvVars:[...n],allowedAuthEnvVarsLayer:"remote"}}function L(e,n){return!n.locked&&!n.unlocked?!1:n.locked?!0:e!=="managed"}function ut(e,n,t){if(n===void 0)return e;let o=e;return n.mode!==void 0&&L(e.modeLayer,t("mode"))&&(o={...o,mode:n.mode,modeLayer:"remote"}),n.allowWrite!==void 0&&L(e.allowWriteLayer,t("allowWrite"))&&(o={...o,allowWrite:[...n.allowWrite],allowWriteLayer:"remote"}),n.network!==void 0&&L(e.networkLayer,t("network"))&&(o={...o,network:n.network,networkLayer:"remote"}),o}function ft(e,n,t){if(n===void 0)return e;let o=e;return n.manifestUrl!==void 0&&L(e.manifestUrlLayer,t("manifestUrl"))&&(o={...o,manifestUrl:n.manifestUrl,manifestUrlLayer:"remote"}),n.channel!==void 0&&L(e.channelLayer,t("channel"))&&(o={...o,channel:n.channel,channelLayer:"remote"}),n.pinnedVersion!==void 0&&L(e.pinnedVersionLayer,t("pinnedVersion"))&&(o={...o,pinnedVersion:n.pinnedVersion,pinnedVersionLayer:"remote"}),n.checkEnabled!==void 0&&L(e.checkEnabledLayer,t("checkEnabled"))&&(o={...o,checkEnabled:n.checkEnabled,checkEnabledLayer:"remote"}),o}function ln(e){let n=[],t=new Set,o=(d,u)=>{let g=`${d}|${JSON.stringify(u??{})}`;t.has(g)||(t.add(g),n.push(u!==void 0?{key:d,params:u}:{key:d}))},r=d=>(o(R.settingsDiscarded,{detail:d}),{loaded:e.merged,applied:null,notices:n}),i=structuredClone(e.settings.values);for(let d of tt)Object.prototype.hasOwnProperty.call(i,d)&&(delete i[d],o(R.settingsSectionIgnored,{section:d}));de(i,O(en));let a=e.settings.locks.map(O),c=e.settings.shadow.map(O),s={},l={},p=[],b=(d,u)=>{if(!G.has(u[u.length-1]??"")){if(c.some(g=>I(u,g))){p.push(u);return}if(E(d)&&(c.some(g=>ze(u,g))||a.some(g=>ze(u,g)))){for(let g of Object.keys(d))G.has(g)||b(d[g],[...u,g]);return}if(a.some(g=>I(u,g))){Je(s,u,d);return}Je(l,u,d)}};for(let d of Object.keys(i))G.has(d)||b(i[d],[d]);let S=[];for(let d=e.layers.length-1;d>=0;d--){let u=e.layers[d];u.layer==="managed"&&S.push(l),S.push(u.raw)}S.includes(l)||S.push(l),S.push(s);let m=null;for(let d=0;d<at&&m===null;d++){let u={};for(let k of S)u=on(u,k);let g=ke.safeParse(structuredClone(u));if(g.success){m=g.data;break}let h=!1;for(let k of g.error.issues){let kn=k.code==="invalid_type"&&k.received==="undefined"?k.path.slice(0,-1):k.path,j=dt(u,kn);if(j.length===0)return r("unusable");let ye=A(s,j)?s:A(l,j)?l:null;ye!==null&&(o(R.settingsKeyInvalid,{path:j.join(".")}),de(ye,j),h=!0)}if(!h)return r("not_converging")}if(m===null)return r("not_converging");for(let d of[s,l]){let u=[];rn(d,[],u);for(let g of u){if(A(m,g))continue;let h=g.join(".");st(h)||o(R.settingsKeyUnknown,{path:h}),de(d,g)}}let y=a.filter(d=>A(s,d));for(let d of y){let u=e.layers.filter(h=>h.layer!=="builtin"&&A(h.raw,d)).map(h=>h.layer),g=[[[Q,"allowedAuthEnvVars"],e.merged.http.allowedAuthEnvVarsLayer],[[U,"mode"],e.merged.sandbox.modeLayer],[[U,"allowWrite"],e.merged.sandbox.allowWriteLayer],[[U,"network"],e.merged.sandbox.networkLayer],[[C,"channel"],e.merged.update.channelLayer],[[C,"pinnedVersion"],e.merged.update.pinnedVersionLayer],[[C,"manifestUrl"],e.merged.update.manifestUrlLayer],[[C,"checkEnabled"],e.merged.update.checkEnabledLayer]];for(let[h,k]of g)k!==void 0&&k!=="remote"&&I(h,d)&&A(s,h)&&!u.includes(k)&&u.push(k);u.length>0&&o(R.settingsLockedLocalIgnored,{path:d.join("."),layers:u.join(", ")})}for(let d of rt){if(ot.includes(d.env))continue;let u=e.env[d.env];if(u===void 0||u.trim()==="")continue;let g=O(d.keyPath);y.some(h=>Xe(h,g))&&(delete e.env[d.env],o(R.settingsLockedEnvIgnored,{env:d.env,path:d.keyPath}))}let T=[];for(let d of e.flags??[]){let u=O(d.keyPath);y.some(g=>Xe(g,u))&&(T.push(d.flag),o(R.settingsLockedFlagIgnored,{flag:d.flag,path:d.keyPath}))}T.sort();for(let d of p)o(R.settingsShadowObserving,{path:d.join(".")});let{permissions:x,hooks:N,mcpServers:K,policy:B,workspaceTrust:F,memory:D}=e.merged,{permissions:w,hooks:Y,mcpServers:v,policy:un,workspaceTrust:fn,http:gn,sandbox:me,update:Et,...pn}=m,X=d=>u=>({locked:A(s,[d,u]),unlocked:A(l,[d,u])}),mn=ct(e.merged.http,m.http?.allowedAuthEnvVars,X(Q)("allowedAuthEnvVars")),yn=ut(e.merged.sandbox,m.sandbox,X(U)),hn=ft(e.merged.update,m.update,X(C)),Rn={...pn,permissions:x,hooks:N,mcpServers:K,policy:B,workspaceTrust:F,memory:D,http:mn,sandbox:yn,update:hn},Sn=Object.keys(s).length>0,bn=Object.keys(l).length>0;return!Sn&&!bn&&p.length===0?{loaded:e.merged,applied:null,notices:n}:{loaded:Rn,applied:{locks:y.map(d=>d.join(".")).sort(),shadow:p.map(d=>d.join(".")).sort(),origins:e.settings.origins,appliedLocked:s,appliedUnlocked:l,suppressedFlags:T},notices:n}}import{existsSync as gt,mkdirSync as pt,readFileSync as mt,writeFileSync as sn}from"node:fs";import{readFile as yt}from"node:fs/promises";import an from"node:os";import fe from"node:path";function ht(e,n){let t=e.TANSR_CONFIG_DIR?.trim();return t!==void 0&&t!==""?t:fe.join(n,".tansr")}function cn(e){let n;try{n=JSON.parse(e)}catch{return{}}if(typeof n!="object"||n===null||Array.isArray(n))return{};let t=n,o={},r=t.model;if(typeof r=="object"&&r!==null&&!Array.isArray(r)){let a=r.selected;typeof a=="string"&&a.trim()!==""&&(o.model={selected:a})}let i=t.window;if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let a=i.byModel;if(typeof a=="object"&&a!==null&&!Array.isArray(a)){let c={};for(let[s,l]of Object.entries(a))typeof l=="number"&&Number.isFinite(l)&&l>0&&(c[s]=l);Object.keys(c).length>0&&(o.window={byModel:c})}}return o}async function ge(e){let n=e.homedir??an.homedir(),t=P(e.env,n);if(t===null)return null;let o=e.readFile??(i=>yt(i,"utf8")),r;try{r=await o(t.configFile)}catch{return{config:{},filePath:t.configFile}}return{config:cn(r),filePath:t.configFile}}function dn(e){let n;try{n=mt(e,"utf8")}catch{return null}try{let t=JSON.parse(n);return typeof t!="object"||t===null||Array.isArray(t)?null:t}catch{return null}}function ue(e){let n=e?.model;if(typeof n!="object"||n===null||Array.isArray(n))return;let t=n.selected;return typeof t=="string"&&t.trim()!==""?t:void 0}function Rt(e){let n=e?.window;if(typeof n!="object"||n===null||Array.isArray(n))return{};let t=n.byModel;if(typeof t!="object"||t===null||Array.isArray(t))return{};let o={};for(let[r,i]of Object.entries(t))typeof i=="number"&&Number.isFinite(i)&&i>0&&(o[r]=i);return o}function pe(e){try{let n=e.homedir??an.homedir(),t=P(e.env,n);if(t===null||gt(t.configFile))return!1;let o=ht(e.env,n),r=fe.join(o,"settings.local.json"),i=fe.join(o,"settings.json"),a=dn(r),c=dn(i),s=ue(a)??ue(c),l=Rt(a);if(s===void 0&&Object.keys(l).length===0)return!1;let p={...s!==void 0?{model:{selected:s}}:{},...Object.keys(l).length>0?{window:{byModel:l}}:{}};if(pt(t.root,{recursive:!0,mode:J}),sn(t.configFile,`${JSON.stringify(p,null,2)}
6
+ `,{encoding:"utf8",mode:q}),c!==null&&ue(c)!==void 0)try{let b=c.model;delete b.selected,Object.keys(b).length===0&&delete c.model,sn(i,`${JSON.stringify(c,null,2)}
7
+ `,"utf8")}catch{}return!0}catch{return!1}}var St="cli.init.guide.uninited";function nr(e){return e.gate.escape||e.remoteEnabled?{key:Ie.noProvider}:{key:St,params:{url:he(e.env)}}}function _(e,n){let t=e;for(let o of n){if(typeof t!="object"||t===null||Array.isArray(t)||!Object.prototype.hasOwnProperty.call(t,o))return!1;t=t[o]}return!0}var z=["model","selected"],bt=["modelAliases","main"];function kt(e,n,t){let o=n.some(a=>(a.layer==="projectLocal"||a.layer==="projectShared")&&_(a.raw,bt)),r=e.model?.selected;if(r===void 0)return{projectPinnedMain:o};let i=(()=>{if(t!==null&&_(t.appliedLocked,z))return"remote:org";let a=!1;for(let c of n){if(!a&&c.layer!=="managed"&&(a=!0,t!==null&&_(t.appliedUnlocked,z)))return"remote:org";if(_(c.raw,z))return c.layer}if(!a&&t!==null&&_(t.appliedUnlocked,z))return"remote:org"})();return{selected:r,...i!==void 0?{layer:i}:{},projectPinnedMain:o}}function vt(e){let{loaded:n,modelSelection:t}=e,o=e.identity.model?.selected;o!==void 0&&(t.layer===void 0||t.layer==="user")&&(n={...n,model:{...n.model,selected:o}},t={selected:o,layer:"identity",projectPinnedMain:t.projectPinnedMain});let r=e.identity.window?.byModel;if(r!==void 0){let i=c=>{let s=["window","byModel",c];return e.remote!==null&&(_(e.remote.appliedLocked,s)||_(e.remote.appliedUnlocked,s))?!0:e.layers.some(l=>(l.layer==="managed"||l.layer==="projectLocal"||l.layer==="projectShared")&&_(l.raw,s))},a={};for(let[c,s]of Object.entries(r))i(c)||(a[c]=s);Object.keys(a).length>0&&(n={...n,window:{...n.window,byModel:{...n.window?.byModel,...a}}})}return{loaded:n,modelSelection:t}}async function tr(e={}){let n=e.env??process.env,t=e.loadOptions?.fs,o=H(n)?null:e.remoteSettingsOverride!==void 0?e.remoteSettingsOverride:await tn({env:n,...e.loadOptions?.homedir!==void 0?{homedir:e.loadOptions.homedir}:{},...t!==void 0?{readFile:v=>t.readFile(v)}:{}}),{config:r,diagnostics:i,sources:a,layers:c}=await Ae({cwd:e.cwd??process.cwd(),env:n,...e.loadOptions??{},captureLayers:!0}),s=e.loadOptions?.captureLayers===!0&&c!==void 0?{layers:c}:{},l=r,p=null,b=[];if(o!==null){let v=ln({merged:r,layers:c??[],settings:o,env:n,...e.flagOverrides!==void 0?{flags:e.flagOverrides}:{}});l=v.loaded,p=v.applied,b=v.notices}let S=p!==null?{remoteSettings:p}:{},m=kt(l,c??[],p);t===void 0&&pe({env:n,...e.loadOptions?.homedir!==void 0?{homedir:e.loadOptions.homedir}:{}});let y=await ge({env:n,...e.loadOptions?.homedir!==void 0?{homedir:e.loadOptions.homedir}:{},...t!==void 0?{readFile:v=>t.readFile(v)}:{}}),T=y!==null&&(y.config.model!==void 0||y.config.window!==void 0);y!==null&&({loaded:l,modelSelection:m}=vt({loaded:l,modelSelection:m,identity:y.config,layers:c??[],remote:p}));let x=T?{identitySettings:{filePath:y.filePath,values:y.config}}:{},N=H(n),K=nn(o),B=N||K,F=Object.keys(l.providers).length>0,D=F?null:We(n),w={escape:N,platformAllowed:K,pruned:B?null:F?"config":D!==null?"env":null},Y=[];if(N&&Y.push({key:ce.active}),w.pruned!==null&&Y.push({key:ce.pruned}),Qe([...b,...Y]),F&&B){let{policy:v,workspaceTrust:un,sandbox:fn,update:gn,...me}=l;return{loaded:l,diagnostics:i,sources:a,providerOrigin:"config",registryConfig:me,localProviders:w,modelSelection:m,...s,...S,...x}}return D!==null&&B?{loaded:l,diagnostics:i,sources:a,providerOrigin:"env",registryConfig:D,localProviders:w,modelSelection:m,...s,...S,...x}:{loaded:l,diagnostics:i,sources:a,providerOrigin:"none",registryConfig:null,localProviders:w,modelSelection:m,...s,...S,...x}}export{M as a,je as b,vn as c,Be as d,Ve as e,Lt as f,Ct as g,Mt as h,It as i,Ut as j,Vt as k,Ze as l,Xt as m,se as n,Qn as o,Jt as p,ao as q,co as r,uo as s,fo as t,H as u,ce as v,nr as w,tr as x};
8
+ //# sourceMappingURL=tansr-chunk-M63EZH2M.mjs.map
@@ -0,0 +1,6 @@
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{o as s}from"./tansr-chunk-HRKJLVKC.mjs";import{readFile as u}from"node:fs/promises";import p from"node:os";import c from"node:path";var l="update-state.json",f=384;function q(e=process.env,t=p.homedir()){let n=e.TANSR_CONFIG_DIR?.trim(),r=n!==void 0&&n!==""?n:c.join(t,".tansr");return c.join(r,l)}function h(e,t){let n;try{n=new URL(e).origin}catch{n=e}return`${n}|${t}`}function g(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}function S(e){if(typeof e!="object"||e===null)return!1;let t=e;return g(t.sequence)&&typeof t.version=="string"&&typeof t.seenAt=="string"&&typeof t.url=="string"&&(t.issuedAt===void 0||typeof t.issuedAt=="string")}async function a(e){let t;try{t=await u(e,"utf8")}catch{return{}}let n;try{n=JSON.parse(t)}catch{return{}}if(typeof n!="object"||n===null)return{};let r=n;if(r.version!==1||typeof r.channels!="object"||r.channels===null)return{};let o={};for(let[d,i]of Object.entries(r.channels))S(i)&&(o[d]=i);return o}function w(e){return{async read(t){return(await a(e))[t]??null},async write(t,n){try{let o={version:1,channels:{...await a(e),[t]:n}};await s(e,JSON.stringify(o,null,2)+`
5
+ `,{mode:f})}catch{}}}}export{q as a,h as b,g as c,a as d,w as e};
6
+ //# sourceMappingURL=tansr-chunk-M774GK3P.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{D as be,G as Ae,ia as Ee,pa as re,wa as Q}from"./tansr-chunk-BX7CF5RQ.mjs";import{a as z,e as xe,f as ie,m as oe}from"./tansr-chunk-QHEQQ2JB.mjs";import{c as Se}from"./tansr-chunk-SJFDQLLC.mjs";import{B as ye,N as A,O as C,T as ve,k as W,s as ge}from"./tansr-chunk-I3TOVAA6.mjs";import{isDeepStrictEqual as _e,types as Oe}from"node:util";function Qe(i,x,S){let u=structuredClone(i),H=!0,O=!1,d;try{let I=S(i,()=>{if(!H||O)throw new Error("Archive governance publication is no longer available");if(O=!0,!_e(i,u))throw new Error("Archive governance candidate changed");return d=x(),d});if(Oe.isPromise(I)&&Promise.prototype.then.call(I,void 0,()=>{}),!O||d===void 0||I!==d||!_e(i,u))throw new Error("Archive governance commit must return its original synchronous publication");return I}finally{H=!1}}import{randomUUID as Te}from"node:crypto";import{closeSync as Be,lstatSync as Le,openSync as He,realpathSync as Me}from"node:fs";import{createRequire as Ne}from"node:module";import{resolve as Ie}from"node:path";import{types as qe}from"node:util";var se=class extends Error{constructor(S){super(`SDK2 host command: ${S}`);this.code=S}code},ke="sdk2-host-commands-v1",X={intent:0,"store-created":1,binding:2,ready:3},Pe=new Set;function c(i){throw new se(i)}function Z(i,x,S){(!Number.isSafeInteger(i)||Object.is(i,-0)||i<x||i>S)&&c("invalid_input")}function ae(i){let x=Me(i),S=Le(i,{bigint:!0});return(S.isSymbolicLink()||!S.isFile()||S.ino===0n||x!==Ie(i))&&c("identity_mismatch"),`${x}\0${S.dev}\0${S.ino}`}function st(i){Z(i.maxCommands,1,65536),Z(i.maxMetadataBytes,1024,67108864),Z(i.controlBytes,1024,262144),Z(i.maxDatabasePages,16,65536),i.mode!=="create"&&i.mode!=="reopen"&&c("invalid_input");let x=A({format:ke,identity:i.identity,maxCommands:i.maxCommands,maxMetadataBytes:i.maxMetadataBytes,controlBytes:i.controlBytes,maxDatabasePages:i.maxDatabasePages}),S=!1,u=!1,H=!1,O=!1,d=null,I=()=>{let t=i.assertAuthorized();qe.isPromise(t)&&W(t),t!==void 0&&c("invalid_input"),u&&c("reentrant")};I();let B=Ie(i.path);if(i.mode==="create"){let t=He(B,"wx",384);Be(t)}let G=ae(B);I();let{DatabaseSync:f}=Ne(import.meta.url)("node:sqlite"),a=new f(B),b=Te(),_=()=>{ae(B)!==G&&c("identity_mismatch"),I()},P=t=>{let e=A(t);return Buffer.byteLength(e)>i.controlBytes&&c("capacity_exceeded"),e},L=t=>{H&&c("closed"),S&&(u=!0,c("reentrant")),O&&c("reconciliation_required"),S=!0,u=!1;try{return _(),t()}finally{S=!1}},R=t=>{let e=a.prepare("SELECT * FROM host_command WHERE command_id=?").get(t);(!e||e.owner!==b)&&c("reconciliation_required");let m=e.stage;return(!Object.hasOwn(X,m)||typeof e.subject_key!="string"||typeof e.intent!="string"||!(e.binding===null||typeof e.binding=="string")||e.digest!==C(A({commandId:t,subjectKey:e.subject_key,intent:e.intent,stage:m,binding:e.binding})))&&c("identity_mismatch"),(Buffer.byteLength(e.intent)>i.controlBytes||Buffer.byteLength(e.binding??"")>i.controlBytes||e.bytes!==Buffer.byteLength(e.intent)+Buffer.byteLength(e.binding??""))&&c("identity_mismatch"),{commandId:t,subjectKey:e.subject_key,intent:e.intent,stage:m,binding:e.binding}},F=t=>{let e=a.prepare(`SELECT
5
+ length(CAST(command_id AS BLOB)) AS command_size, length(CAST(subject_key AS BLOB)) AS subject_size,
6
+ length(CAST(owner AS BLOB)) AS owner_size, length(CAST(stage AS BLOB)) AS stage_size,
7
+ length(CAST(intent AS BLOB)) AS intent_size, length(CAST(binding AS BLOB)) AS binding_size,
8
+ length(CAST(digest AS BLOB)) AS digest_size,
9
+ CASE WHEN bytes BETWEEN 0 AND ? THEN bytes ELSE -1 END AS bytes
10
+ FROM host_command WHERE subject_key=?`).get(i.maxMetadataBytes,t);if(!e)return null;let m=(y,q)=>typeof y=="number"&&Number.isSafeInteger(y)&&y>=0&&y<=q;(e.command_size!==67||e.subject_size!==64||e.owner_size!==36||e.digest_size!==64||!m(e.stage_size,13)||!m(e.intent_size,i.controlBytes)||!(e.binding_size===null||m(e.binding_size,i.controlBytes))||!m(e.bytes,i.maxMetadataBytes)||e.bytes!==e.intent_size+(e.binding_size??0))&&c("identity_mismatch");let o=a.prepare("SELECT command_id,subject_key,owner,intent,stage,binding,bytes,digest FROM host_command WHERE subject_key=?").get(t);(!o||o.subject_key!==t||typeof o.command_id!="string"||typeof o.intent!="string"||typeof o.owner!="string"||!/^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/.test(o.owner)||typeof o.stage!="string"||!Object.hasOwn(X,o.stage)||!(o.binding===null||typeof o.binding=="string"))&&c("identity_mismatch");let l={commandId:o.command_id,subjectKey:t,intent:o.intent,stage:o.stage,binding:o.binding};(o.command_id!==`hc-${C(t+"\0"+o.intent)}`||o.digest!==C(A(l))||o.bytes!==e.bytes||Buffer.byteLength(o.intent)!==e.intent_size||(o.binding===null?null:Buffer.byteLength(o.binding))!==e.binding_size||(l.stage==="binding"||l.stage==="ready")!=(l.binding!==null))&&c("identity_mismatch");try{(A(JSON.parse(l.intent))!==l.intent||l.binding!==null&&A(JSON.parse(l.binding))!==l.binding)&&c("identity_mismatch")}catch{c("identity_mismatch")}return Object.freeze(l)},M=(t,e)=>{d&&c("reconciliation_required"),a.exec("BEGIN IMMEDIATE");let m=!1;try{_();let o=e();return _(),m=!0,a.exec("COMMIT"),o}catch(o){try{a.exec("ROLLBACK")}catch{try{a.exec("BEGIN"),a.exec("ROLLBACK")}catch{O=!0}}throw m&&(d=t,c("commit_unknown")),o}},N=t=>{let e=Buffer.byteLength(t.intent)+Buffer.byteLength(t.binding??""),m=a.prepare("SELECT bytes FROM host_command WHERE command_id=?").get(t.commandId),o=a.prepare("SELECT records,bytes,digest FROM host_command_meta WHERE id=1").get(),l=Number(o.records),y=Number(o.bytes);(!Number.isSafeInteger(l)||!Number.isSafeInteger(y)||l<0||y<0||o.digest!==C(`${l}:${y}`))&&c("identity_mismatch");let q=l+(m?0:1),k=y+e-Number(m?.bytes??0);(!Number.isSafeInteger(k)||k<0||q>i.maxCommands||k>i.maxMetadataBytes)&&c("capacity_exceeded"),a.prepare("INSERT INTO host_command(command_id,subject_key,owner,intent,stage,binding,bytes,digest) VALUES(?,?,?,?,?,?,?,?) ON CONFLICT(command_id) DO UPDATE SET stage=excluded.stage,binding=excluded.binding,bytes=excluded.bytes,digest=excluded.digest").run(t.commandId,t.subjectKey,b,t.intent,t.stage,t.binding,e,C(A(t))),a.prepare("UPDATE host_command_meta SET records=?,bytes=?,digest=? WHERE id=1").run(q,k,C(`${q}:${k}`))};try{if(a.exec("PRAGMA journal_mode=DELETE; PRAGMA synchronous=FULL; PRAGMA foreign_keys=ON; PRAGMA temp_store=MEMORY; PRAGMA busy_timeout=0;"),i.mode==="create"&&a.exec("PRAGMA page_size=4096;"),(a.prepare("PRAGMA page_size").get()?.page_size!==4096||a.prepare(`PRAGMA max_page_count=${i.maxDatabasePages}`).get()?.max_page_count!==i.maxDatabasePages)&&c("capacity_exceeded"),i.mode==="create"){a.exec("BEGIN IMMEDIATE");try{a.exec("CREATE TABLE host_command_meta(id INTEGER PRIMARY KEY CHECK(id=1),config TEXT NOT NULL,records INTEGER NOT NULL CHECK(records>=0),bytes INTEGER NOT NULL CHECK(bytes>=0),digest TEXT NOT NULL) STRICT; CREATE TABLE host_command(command_id TEXT PRIMARY KEY,subject_key TEXT UNIQUE NOT NULL,owner TEXT NOT NULL,intent TEXT NOT NULL,stage TEXT NOT NULL,binding TEXT,bytes INTEGER NOT NULL CHECK(bytes>=0),digest TEXT NOT NULL) STRICT;"),a.prepare("INSERT INTO host_command_meta(id,config,records,bytes,digest) VALUES(1,?,0,0,?)").run(x,C("0:0")),_(),a.exec("COMMIT")}catch(t){try{a.exec("ROLLBACK")}catch{}throw t}}else{let t=a.prepare("SELECT * FROM host_command_meta WHERE id=1").get();(!t||t.config!==x)&&c("identity_mismatch");let e=a.prepare("SELECT count(*) AS records,coalesce(sum(bytes),0) AS bytes FROM host_command").get();(e.records!==t.records||e.bytes!==t.bytes||Number(e.records)>i.maxCommands||Number(e.bytes)>i.maxMetadataBytes||t.digest!==C(`${e.records}:${e.bytes}`))&&c("identity_mismatch")}_()}catch(t){try{a.close()}catch(e){throw Pe.add(a),new AggregateError([t,e],"Host command journal retains unclosed database")}throw t}return{begin(t,e){return L(()=>{/^[a-f0-9]{64}$/.test(t)||c("invalid_input");let m=P(e),o=`hc-${C(t+"\0"+m)}`;d&&d!==o&&c("reconciliation_required");let l=a.prepare("SELECT command_id FROM host_command WHERE subject_key=?").get(t);if(l){l.command_id!==o&&c("operation_conflict");let y=R(o);return _(),y.intent!==m&&c("operation_conflict"),d=null,y}return d===o&&(d=null),M(o,()=>{let y={commandId:o,subjectKey:t,intent:m,stage:"intent",binding:null};return N(y),y})})},advance(t,e,m){return L(()=>{d&&d!==t&&c("reconciliation_required");let o=R(t),l=m===void 0?o.binding:P(m);return(!Object.hasOwn(X,e)||e==="binding"&&l===null||m!==void 0&&e!=="binding"||o.binding!==null&&l!==o.binding)&&c("operation_conflict"),_(),d=null,o.stage===e?o:(X[e]!==X[o.stage]+1&&c("operation_conflict"),M(t,()=>{let y={...o,stage:e,binding:l};return N(y),y}))})},read(t){return L(()=>{d&&d!==t&&c("reconciliation_required");let e=R(t);return _(),d=null,e})},lookup(t){return L(()=>{(typeof t!="string"||!/^[a-f0-9]{64}$/.test(t))&&c("invalid_input"),d&&c("reconciliation_required"),a.exec("BEGIN");let e=!1;try{let m=F(t);return a.exec("ROLLBACK"),e=!0,_(),ae(B)!==G&&c("identity_mismatch"),m}catch(m){if(!e)try{a.exec("ROLLBACK")}catch{try{a.exec("BEGIN"),a.exec("ROLLBACK")}catch{O=!0}}throw m}})},close(){H||(S&&(u=!0,c("reentrant")),_(),a.close(),H=!0)}}}async function je(i){let{openSqliteEventStore:x}=await import("./tansr-sqlite-event-store-UQLSSZKP.mjs");return x(i)}import{types as ce}from"node:util";var de=new WeakMap,ee=(i,x)=>A(i)===A(x);function g(i="reconciliation_required"){throw new z(i)}function De(i){let x=ie(i.maxQueuedOperations,1,65536),S=ie(i.maxSubscriptions,1,4096),u=Object.freeze({...i.installation,slot:Object.freeze({...i.installation.slot})}),{source:H,materials:O,eventStore:d,readAuthority:I,retiredRecovery:B}=i;(typeof I!="function"||ce.isProxy(I))&&g("invalid_input");let G=A(u.slot),f="new",a,b,_,P,L,R,F=!1,M=!1,N=!1,t=!1,e=!1,m,o,l=[],y=new Set,q="",k="",le=null,me=new Map,pe=new Set,ue=r=>A([r.materialRequestId,r.revision]),U=()=>{if((M||t)&&(N=!0,e=!0,g("invalid_input")),f==="failed")throw a;f==="closed"&&g("unavailable")},Re=()=>{M&&(N=!0,g("invalid_input")),M=!0,N=!1;try{let r=I();ce.isPromise(r)&&(W(r),g("invalid_input"));let s=ve(r);return N&&g("invalid_input"),s}finally{M=!1}},fe=r=>{let s=Re(),n=u.control.read(),p=B===void 0?re(u):Ee(B,{spool:u.spool,slot:u.slot,storeIdentity:u.storeIdentity,ownerEpoch:u.ownerEpoch,sessionId:n?.registration.sessionId??""}),h=Q(u.spool,u.slot),v=Ae(p.guard);(!n||n.state==="unbound"||!h||h.ready===null&&v.phase!=="retired"||r&&!(v.phase==="installed"&&v.hasRuntime||v.phase==="retiring"&&v.hasRuntime&&n.state==="closing"||B!==void 0&&v.phase==="retired"&&!v.hasRuntime&&n.state==="closed")||!r&&!["installed","retiring","retired"].includes(v.phase))&&g();let E=h.plan;if((p.physicalPairDigest!==E.physicalPairDigest||p.ownerRootDigest!==E.ownerRootDigest||s.scope.applicationScopeId!==E.scope.applicationScopeId||s.scope.endUserId!==E.scope.endUserId||s.target.sessionId!==E.sessionId||P!==void 0&&P!==E.installationId)&&g("identity_mismatch"),v.phase==="retired"){let w=be({spool:u.spool,control:u.control,slot:u.slot}),T=w.retirement?.record;(n.state!=="closed"||w.writeBarrier!=="clear"||!ee(w.current,n)||!T||T.installationId!==E.installationId||T.ownerRootDigest!==p.ownerRootDigest||T.physicalPairDigest!==p.physicalPairDigest||!ee(T.finalTarget,n.target)||h.ready===null&&T.installedRecordDigest!==null)&&g()}else v.hasRuntime||g();return{view:Se({...E.createResponse,scope:s.scope,target:n.target,revision:n.revision,state:n.state,acceptedCapabilities:n.acceptedCapabilities,archiveAckFormat:n.archiveAckFormat,operationEpoch:n.epoch.active&&s.nowMs<n.epoch.expiresAtMs?{id:n.epoch.id,issuedAt:new Date(n.epoch.issuedAtMs).toISOString(),expiresAt:new Date(n.epoch.expiresAtMs).toISOString(),state:"active"}:null}),plan:E}},te=(r,s)=>{t=!0,e=!1;try{let n=ye({spool:u.spool,source:H,materials:O,...s?{materialOperation:s}:{}},()=>fe(r)),{view:p,plan:h}=n.binding;return(n.archive.bindingId!==h.bindingId||n.archive.sourceId!==h.sourceId||n.archive.sourceGeneration!==h.sourceGeneration||n.archive.revision!==p.revision||!ee(n.archive.generations,p.target.generations)||n.archive.state!==p.state||h.materialBindingId!==null!=(O!==void 0))&&g("identity_mismatch"),e&&g("invalid_input"),n}finally{t=!1}},J=()=>{for(let r of y)r.wake()},$=(r,s)=>{f==="closed"||f==="failed"||(a=r,f="failed",l.length=0,R?.close(),R=void 0,o=s,J(),V())},j=()=>{U(),t=!0,e=!1;try{fe(!1),e&&g("invalid_input")}catch(r){throw $(r,"notification-failure"),r}finally{t=!1}},he=(r,s)=>{let{view:n}=r.binding,p={revision:n.revision,generations:n.target.generations},h=[];!s&&r.archive.publishedThroughSequence!==null&&r.archive.publishedThroughSequence!==le&&h.push({...p,eventType:"archive.records-available",payload:{publishedThroughSequence:r.archive.publishedThroughSequence}}),(s||A(r.archive)!==q)&&h.push({...p,eventType:"archive.status",payload:r.archive}),(s||A(n)!==k)&&h.push({...p,eventType:"binding.status",payload:n});for(let v of r.requests)(s||me.get(v.request.materialRequestId)!==A(v))&&h.push({...p,eventType:"material.request",payload:v.request,issuedAtMs:v.issuedAtMs,deadlineMs:v.deadlineMs});return!s&&r.material&&!pe.has(ue(r.material))&&h.push({...p,eventType:"material.status",payload:r.material}),h},we=r=>{q=A(r.archive),k=A(r.binding.view),le=r.archive.publishedThroughSequence,me=new Map(r.requests.map(s=>[s.request.materialRequestId,A(s)])),r.material&&pe.add(ue(r.material))},ne=(r,s)=>{let n=d.head(b),p=n.state==="rebuilding";L!==void 0&&L!==n.generation&&!p&&g("stream_cursor_expired");let h=he(r,s||p);if(h.length){let v={generation:n.generation,after:n.head,drafts:h};if(p){let E=d.activate(b,v),D=s?[]:he(r,!1).filter(w=>w.eventType==="material.status");D.length&&d.append(b,{generation:n.generation,after:E.last,drafts:D})}else d.append(b,v)}if(f==="failed"||f==="closed")throw a??new z("unavailable");return j(),L=n.generation,we(r),J(),r.binding.view.state==="closed"&&(f="ended",R?.close(),R=void 0,l.length=0,J()),{generation:n.generation,after:n.head}};function V(){m||(m=Promise.resolve().then(()=>{if(o&&b){let r=o;o=void 0,d.retire(b,r)}for(;f==="ready"&&l.length;){let r=l.shift(),s=Q(u.spool,u.slot),n=r.state==="committed"&&r.operation?.bindingId===s?.plan.materialBindingId?r.operation??void 0:void 0;if(!n)for(;l.length&&!(l[0].state==="committed"&&l[0].operation?.bindingId===s?.plan.materialBindingId);)l.shift();ne(te(!1,n),!1)}}).catch(r=>{$(r,"notification-failure")}).finally(()=>{if(m=void 0,o&&b){let r=o;o=void 0;try{d.retire(b,r)}catch(s){a=new AggregateError([a,s],"SDK2 event retirement requires reconciliation")}}J(),f==="ready"&&l.length&&V()}))}return{start:async()=>{if(U(),!(f==="ready"||f==="ended")){f!=="new"&&g("unavailable"),f="starting";try{let r=de.get(u.spool)??new Set;r.has(G)&&g("owner_busy"),r.add(G),de.set(u.spool,r),F=!0,R=ge(u.spool,{committed(p){if(["starting","ready"].includes(f)){if(l.length>=x){$(new z("capacity_exceeded"),"notification-failure");return}l.push(p),V()}},retired(p){$(new z("reconciliation_required"),p)}});let s=te(!0),n=s.binding.plan;P=n.installationId,_=oe({applicationScopeId:n.scope.applicationScopeId,endUserId:n.scope.endUserId,bindingId:n.bindingId}),b=d.ensureStream({scope:_,installationId:P,limits:{eventRetentionMs:n.createResponse.limits.eventRetentionMs,eventRetentionFrames:n.createResponse.limits.eventRetentionFrames,eventRetentionBytes:n.createResponse.limits.eventRetentionBytes}}),d.head(b).state==="ready"&&d.retire(b,"notification-failure"),L=d.head(b).generation,ne(s,!0),f==="starting"&&(f="ready"),V()}catch(r){throw $(r,"notification-failure"),r}}},flush:async()=>{for(U(),(f==="new"||f==="starting")&&g("unavailable");m;)await m;U()},open:async r=>{j(),f!=="ready"&&f!=="ended"&&g("unavailable");let s=xe(r,["scope","signal"],["lastEventId"]);ee(oe(s.scope),_)||g("identity_mismatch");let n=s.signal;(!(n instanceof AbortSignal)||ce.isProxy(n))&&g("invalid_input"),n.throwIfAborted(),y.size>=S&&g("capacity_exceeded");let p=s.lastEventId===void 0?ne(te(!1),!0):d.inspectCursor(b,s.lastEventId);j(),n.throwIfAborted();let h=!1,v=!1,E,D,w=()=>{h=!0,E=void 0,n.removeEventListener("abort",w),y.delete(T),T.wake()},T={close:w,wake(){D?.(),D=void 0}};return y.add(T),n.addEventListener("abort",w,{once:!0}),n.aborted&&w(),{async next(){U(),(v||E)&&g("invalid_input"),v=!0;try{for(;!h;){if(j(),h||n.aborted)return null;let Y=d.head(b),K=d.readPage(b,{generation:p.generation,after:p.after,through:Y.head,maxFrames:1,maxBytes:262317});if(j(),h||n.aborted)return null;if(K.refs.length)return p={generation:p.generation,after:K.after},E=K.refs[0],E;if(f==="ended")return null;await new Promise(Ce=>{D=Ce})}return null}finally{v=!1}},encodeForSend(Y){j(),(h||n.aborted||Y!==E)&&g("identity_mismatch");let K=d.encodeForSend(Y);return j(),(h||n.aborted)&&g("identity_mismatch"),E=void 0,K.sse},close:w}},close:async()=>{if((M||t)&&(N=!0,e=!0,g("invalid_input")),!(f==="closed"&&!F)){R?.close(),R=void 0,l.length=0,f="closed";for(let r of[...y])r.close();m&&await m;try{b&&d.retire(b,"closed")}finally{F&&(de.get(u.spool)?.delete(G),F=!1)}}}}}export{Qe as a,st as b,je as c,De as d};
11
+ //# sourceMappingURL=tansr-chunk-MWHLITGY.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{b as n}from"./tansr-chunk-HQY7FXGU.mjs";import{Vb as s}from"./tansr-chunk-BCOFZJWA.mjs";import i from"node:path";var r={notAbsolute:"cli.cwd.error.not_absolute",notFound:"cli.cwd.error.not_found",notDirectory:"cli.cwd.error.not_directory",notAllowed:"cli.cwd.error.not_allowed"},S=Object.values(r),d={not_absolute:r.notAbsolute,not_found:r.notFound,not_directory:r.notDirectory,not_allowed:r.notAllowed};function a(e,t,o){return i.resolve(t,n(e.trim(),o))}async function f(e){if(e.requested===void 0)return{ok:!0,cwd:e.fallback};let t=a(e.requested,e.fallback,e.homedir),o=await s({requested:t,fallback:e.fallback,policy:{resolve:l=>l}});return o.ok?{ok:!0,cwd:o.cwd}:{ok:!1,reason:o.reason,key:d[o.reason],params:{path:t}}}export{r as a,f as b};
5
+ //# sourceMappingURL=tansr-chunk-MXYVQZY3.mjs.map