@tansr/cli 0.10.2 → 0.10.3

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 (48) hide show
  1. package/package.json +1 -1
  2. package/tansr-artifacts.json +429 -429
  3. package/{tansr-bg-QY4G2SNZ.mjs → tansr-bg-EAYYM4XW.mjs} +2 -2
  4. package/{tansr-chunk-OB47UYHK.mjs → tansr-chunk-2X337GKC.mjs} +2 -2
  5. package/{tansr-chunk-LSYPDTQG.mjs → tansr-chunk-4LNN4SQL.mjs} +2 -2
  6. package/{tansr-chunk-53SL6W6G.mjs → tansr-chunk-5TJVZSZE.mjs} +2 -2
  7. package/{tansr-chunk-H6JYYWPW.mjs → tansr-chunk-74H5GQTJ.mjs} +2 -2
  8. package/{tansr-chunk-KSBP64Q5.mjs → tansr-chunk-7T6OLLFW.mjs} +2 -2
  9. package/{tansr-chunk-E67N3BDI.mjs → tansr-chunk-CJP7YEGC.mjs} +2 -2
  10. package/{tansr-chunk-UCG4D6ER.mjs → tansr-chunk-D7VSW2LQ.mjs} +2 -2
  11. package/{tansr-chunk-UAEARRRH.mjs → tansr-chunk-DN22GXHD.mjs} +2 -2
  12. package/{tansr-chunk-NCIMR6LB.mjs → tansr-chunk-GDJ5YVNY.mjs} +2 -2
  13. package/{tansr-chunk-J72JGEKH.mjs → tansr-chunk-GMPMRXL4.mjs} +3 -3
  14. package/tansr-chunk-GR6BWQGG.mjs +38 -0
  15. package/{tansr-chunk-S77B4PI7.mjs → tansr-chunk-HHL7HM62.mjs} +2 -2
  16. package/{tansr-chunk-BCOFZJWA.mjs → tansr-chunk-IZICOKKF.mjs} +9 -9
  17. package/{tansr-chunk-Q6MUMULP.mjs → tansr-chunk-J2LWM3S7.mjs} +2 -2
  18. package/{tansr-chunk-ZY3IR67Q.mjs → tansr-chunk-KQVXXXEF.mjs} +2 -2
  19. package/{tansr-chunk-QNHXB55W.mjs → tansr-chunk-M6XHWCMA.mjs} +2 -2
  20. package/{tansr-chunk-TYJWMSVW.mjs → tansr-chunk-N3R2URKL.mjs} +2 -2
  21. package/{tansr-chunk-J2ED6CI4.mjs → tansr-chunk-QUFHVA3F.mjs} +2 -2
  22. package/{tansr-chunk-6OXR4F5Y.mjs → tansr-chunk-X4GLXJ2Z.mjs} +2 -2
  23. package/{tansr-chunk-WGXWBU37.mjs → tansr-chunk-X5REV3T3.mjs} +2 -2
  24. package/{tansr-chunk-CI7LFRTK.mjs → tansr-chunk-ZV3NCXTD.mjs} +2 -2
  25. package/{tansr-main-5V46X7QH.mjs → tansr-main-STVTNYAI.mjs} +3 -3
  26. package/{tansr-run-acp-entry-ANNUR7IB.mjs → tansr-run-acp-entry-6J44XOYJ.mjs} +3 -3
  27. package/{tansr-run-approvals-entry-SLLTFTSX.mjs → tansr-run-approvals-entry-HQWSIW3P.mjs} +2 -2
  28. package/{tansr-run-auth-entry-X3SXNPOI.mjs → tansr-run-auth-entry-7HA4C4NJ.mjs} +2 -2
  29. package/{tansr-run-doctor-RYIQQOOK.mjs → tansr-run-doctor-7T6IAXYE.mjs} +3 -3
  30. package/{tansr-run-headless-entry-I53HJDNX.mjs → tansr-run-headless-entry-XEFQC5LE.mjs} +2 -2
  31. package/{tansr-run-init-entry-USPWKDRI.mjs → tansr-run-init-entry-3VKXS2WK.mjs} +2 -2
  32. package/{tansr-run-logout-entry-KO7ZL2M5.mjs → tansr-run-logout-entry-VNCNNCSS.mjs} +2 -2
  33. package/{tansr-run-mcp-serve-entry-YMQH7WSF.mjs → tansr-run-mcp-serve-entry-5KLWER3G.mjs} +2 -2
  34. package/{tansr-run-orchestrate-entry-YN3M6BWY.mjs → tansr-run-orchestrate-entry-AR57AZLR.mjs} +2 -2
  35. package/{tansr-run-org-entry-STRRZVI4.mjs → tansr-run-org-entry-TJPRLGCL.mjs} +2 -2
  36. package/{tansr-run-policy-entry-4ENHRAMQ.mjs → tansr-run-policy-entry-DHMQ3PAP.mjs} +2 -2
  37. package/{tansr-run-profile-entry-THJMZ7ZA.mjs → tansr-run-profile-entry-LOFPHFG4.mjs} +2 -2
  38. package/tansr-run-serve-entry-CHVKUY5J.mjs +99 -0
  39. package/{tansr-run-sessions-entry-KIT7PALM.mjs → tansr-run-sessions-entry-JOMFB5LJ.mjs} +2 -2
  40. package/{tansr-run-update-entry-HYSKHBB6.mjs → tansr-run-update-entry-XI6KG7UI.mjs} +2 -2
  41. package/{tansr-src-JAODAP53.mjs → tansr-src-A6WDMY6X.mjs} +3 -3
  42. package/{tansr-startup-account-QUJKOV6V.mjs → tansr-startup-account-7ZFSP3FV.mjs} +4 -4
  43. package/{tansr-startup-model-SREG5HNN.mjs → tansr-startup-model-I6LOCFDP.mjs} +3 -3
  44. package/{tansr-tui-DXGFMSII.mjs → tansr-tui-OWG3JNA6.mjs} +5 -5
  45. package/tansr.mjs +1 -1
  46. package/tansrd.mjs +41 -41
  47. package/tansr-chunk-TZJHQ3TT.mjs +0 -38
  48. package/tansr-run-serve-entry-N5PK7ACI.mjs +0 -99
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __tansrCreateRequire } from 'module';const require=__tansrCreateRequire(import.meta.url);
2
2
  import { fileURLToPath as __tansrFileURLToPath } from 'url';import { dirname as __tansrDirname } from 'path';
3
3
  const __filename=__tansrFileURLToPath(import.meta.url);const __dirname=__tansrDirname(__filename);
4
- import{gb as L,sb as j,tb as w,ub as O,vb as E,xb as N}from"./tansr-chunk-BCOFZJWA.mjs";import{m as a}from"./tansr-chunk-NA22YT73.mjs";import{c as f}from"./tansr-chunk-QWGSXFEJ.mjs";var R={rejected:"cli.policy.lifecycle_rejected",verifyRejected:"cli.policy.lifecycle_verify_rejected",lkgFallback:"cli.policy.lifecycle_lkg_fallback",requiredMissing:"cli.policy.lifecycle_required_missing",modeLocked:"cli.policy.mode_locked",refuseLaunch:"cli.policy.refuse_launch",stateWriteFailed:"cli.policy.state_write_failed",stateCorrupted:"cli.policy.state_corrupted",stateCorruptedRefuse:"cli.policy.state_corrupted_refuse",sessionBundleExpired:"cli.policy.session_bundle_expired",sessionRequiredExpired:"cli.policy.session_required_expired"},I=["acceptEdits","auto","bypassPermissions"],$="lkg";function Q(e){return{highWater:{...e.highWater},revoked:Object.fromEntries(Object.entries(e.revoked).map(([o,t])=>[o,[...t]])),lkg:{...e.lkg}}}function C(e){if(e!=="verified")return e==="rejected"?"verify_rejected":e==="unsupported"?"verify_unsupported":"verify_unsigned"}function D(e){let o=e.now??Date.now(),t=e.anchor?.requiredBundles??[],i=[],r=[],n=Q(e.state),s=!1,l=new Map;for(let c of t)l.has(c.id)||l.set(c.id,c);let p=(c,m)=>{let g=O(m);g>(n.highWater[c]??0)&&(n.highWater[c]=g,s=!0);let u=m.meta.revokedSequences??[];if(u.length>0){let P=new Set(n.revoked[c]??[]),k=P.size;for(let S of u)P.add(S);P.size!==k&&(n.revoked[c]=[...P].sort((S,_)=>S-_),s=!0)}},d=[],y=new Map,h=new Map;for(let c of e.groups){if(c.builtin===!0){d.push(c);continue}let m=[];for(let g of c.bundles){let u=g.meta.id;if(y.has(u)){m.push(g);continue}let P=l.get(u),k=E(g,{now:o,...P!==void 0?{anchor:P}:{},...n.highWater[u]!==void 0?{highWater:n.highWater[u]}:{},...n.revoked[u]!==void 0?{revoked:n.revoked[u]}:{}});if(!k.ok){h.has(u)||h.set(u,k.reason),i.push({message:a(R.rejected,{id:u,reason:k.reason}),level:"error"});continue}let S=L(g,e.verify).status;if(P!==void 0){let _=C(S);if(_!==void 0){h.has(u)||h.set(u,_),i.push({message:a(R.verifyRejected,{id:u,reason:_}),level:"error"});continue}}else if(S==="rejected"||S==="unsupported"){m.push(g);continue}m.push(g),y.set(u,g),p(u,g)}m.length>0&&d.push({...c,bundles:m})}let b=[];for(let c of l.values()){let m=y.get(c.id);if(m===void 0){let g=h.get(c.id)??"absent",u=n.lkg[c.id],P=u===void 0?void 0:C(L(u,e.verify).status)??(()=>{let k=E(u,{now:o,anchor:c,...n.highWater[c.id]!==void 0?{highWater:n.highWater[c.id]}:{},...n.revoked[c.id]!==void 0?{revoked:n.revoked[c.id]}:{}});return k.ok?void 0:k.reason})();if(u!==void 0&&P===void 0)b.push(u),m=u,p(c.id,u),i.push({message:a(R.lkgFallback,{id:c.id,sequence:O(u),reason:g}),level:"error"});else{r.push({bundleId:c.id,reason:u!==void 0?P:g}),i.push({message:a(R.requiredMissing,{id:c.id,reason:u!==void 0?P:g}),level:"error"});continue}}JSON.stringify(n.lkg[c.id])!==JSON.stringify(m)&&(n.lkg[c.id]=m,s=!0)}for(let c of Object.keys(n.lkg))l.has(c)||(delete n.lkg[c],s=!0);let B=r.length>0;return B?{groups:d.filter(c=>c.builtin===!0),notices:i,refuseLaunch:B,refusals:r,state:n,stateChanged:s}:(b.length>0&&d.push({dir:$,bundles:b}),{groups:d,notices:i,refuseLaunch:B,refusals:r,state:n,stateChanged:s})}function Re(e,o){return e===void 0||o===void 0||!o.lockedModes.includes(e)?{mode:e}:{mode:"default",lockedMode:e}}function ve(e){return{message:a(R.modeLocked,{mode:e}),level:"error"}}function be(e){let o=e.now??Date.now(),t=new Set((e.anchor?.requiredBundles??[]).map(s=>s.id)),i=[],r=[],n=[];for(let s of e.groups){if(s.builtin===!0){n.push(s);continue}let l=[];for(let p of s.bundles){let d=E(p,{now:o});if(d.ok){l.push(p);continue}let y=p.meta.id;t.has(y)?(r.push({bundleId:y,reason:d.reason}),i.push({message:a(R.sessionRequiredExpired,{id:y,reason:d.reason}),level:"error"})):i.push({message:a(R.sessionBundleExpired,{id:y,reason:d.reason}),level:"error"})}l.length>0&&n.push({...s,bundles:l})}return{groups:n,notices:i,refuseSession:r.length>0,refusals:r}}import z from"node:os";import Y from"node:path";import{randomBytes as H}from"node:crypto";import{mkdir as Z,open as q,readFile as X,rename as ee,rm as ie}from"node:fs/promises";import oe from"node:os";import x from"node:path";var re="policy-state.json";function M(){return{highWater:{},revoked:{},lkg:{}}}function A(e,o=oe.homedir()){let t=e.TANSR_CONFIG_DIR?.trim(),i=t!==void 0&&t!==""?t:x.join(o,".tansr");return x.join(i,re)}function te(e){let o={};if(typeof e!="object"||e===null||Array.isArray(e))return o;for(let[t,i]of Object.entries(e))typeof i=="number"&&Number.isInteger(i)&&i>=0&&(o[t]=i);return o}function ne(e){let o={};if(typeof e!="object"||e===null||Array.isArray(e))return o;for(let[t,i]of Object.entries(e)){if(!Array.isArray(i))continue;let r=i.filter(n=>typeof n=="number"&&Number.isInteger(n)&&n>=0);r.length>0&&(o[t]=[...new Set(r)].sort((n,s)=>n-s))}return o}function se(e){let o={};if(typeof e!="object"||e===null||Array.isArray(e))return o;for(let[t,i]of Object.entries(e)){let r=j(i);r.ok&&r.bundle.meta.id===t&&(o[t]=r.bundle)}return o}async function T(e,o=t=>X(t,"utf8")){let t;try{t=await o(e)}catch{return{state:M(),corrupted:!1}}let i;try{i=JSON.parse(t)}catch{return{state:M(),corrupted:!0}}if(typeof i!="object"||i===null||Array.isArray(i))return{state:M(),corrupted:!0};let r=i;return{state:{highWater:te(r.highWater),revoked:ne(r.revoked),lkg:se(r.lkg)},corrupted:!1}}async function F(e,o,t){let i=`${JSON.stringify(o,null,2)}
4
+ import{gb as L,sb as j,tb as w,ub as O,vb as E,xb as N}from"./tansr-chunk-IZICOKKF.mjs";import{m as a}from"./tansr-chunk-NA22YT73.mjs";import{c as f}from"./tansr-chunk-QWGSXFEJ.mjs";var R={rejected:"cli.policy.lifecycle_rejected",verifyRejected:"cli.policy.lifecycle_verify_rejected",lkgFallback:"cli.policy.lifecycle_lkg_fallback",requiredMissing:"cli.policy.lifecycle_required_missing",modeLocked:"cli.policy.mode_locked",refuseLaunch:"cli.policy.refuse_launch",stateWriteFailed:"cli.policy.state_write_failed",stateCorrupted:"cli.policy.state_corrupted",stateCorruptedRefuse:"cli.policy.state_corrupted_refuse",sessionBundleExpired:"cli.policy.session_bundle_expired",sessionRequiredExpired:"cli.policy.session_required_expired"},I=["acceptEdits","auto","bypassPermissions"],$="lkg";function Q(e){return{highWater:{...e.highWater},revoked:Object.fromEntries(Object.entries(e.revoked).map(([o,t])=>[o,[...t]])),lkg:{...e.lkg}}}function C(e){if(e!=="verified")return e==="rejected"?"verify_rejected":e==="unsupported"?"verify_unsupported":"verify_unsigned"}function D(e){let o=e.now??Date.now(),t=e.anchor?.requiredBundles??[],i=[],r=[],n=Q(e.state),s=!1,l=new Map;for(let c of t)l.has(c.id)||l.set(c.id,c);let p=(c,m)=>{let g=O(m);g>(n.highWater[c]??0)&&(n.highWater[c]=g,s=!0);let u=m.meta.revokedSequences??[];if(u.length>0){let P=new Set(n.revoked[c]??[]),k=P.size;for(let S of u)P.add(S);P.size!==k&&(n.revoked[c]=[...P].sort((S,_)=>S-_),s=!0)}},d=[],y=new Map,h=new Map;for(let c of e.groups){if(c.builtin===!0){d.push(c);continue}let m=[];for(let g of c.bundles){let u=g.meta.id;if(y.has(u)){m.push(g);continue}let P=l.get(u),k=E(g,{now:o,...P!==void 0?{anchor:P}:{},...n.highWater[u]!==void 0?{highWater:n.highWater[u]}:{},...n.revoked[u]!==void 0?{revoked:n.revoked[u]}:{}});if(!k.ok){h.has(u)||h.set(u,k.reason),i.push({message:a(R.rejected,{id:u,reason:k.reason}),level:"error"});continue}let S=L(g,e.verify).status;if(P!==void 0){let _=C(S);if(_!==void 0){h.has(u)||h.set(u,_),i.push({message:a(R.verifyRejected,{id:u,reason:_}),level:"error"});continue}}else if(S==="rejected"||S==="unsupported"){m.push(g);continue}m.push(g),y.set(u,g),p(u,g)}m.length>0&&d.push({...c,bundles:m})}let b=[];for(let c of l.values()){let m=y.get(c.id);if(m===void 0){let g=h.get(c.id)??"absent",u=n.lkg[c.id],P=u===void 0?void 0:C(L(u,e.verify).status)??(()=>{let k=E(u,{now:o,anchor:c,...n.highWater[c.id]!==void 0?{highWater:n.highWater[c.id]}:{},...n.revoked[c.id]!==void 0?{revoked:n.revoked[c.id]}:{}});return k.ok?void 0:k.reason})();if(u!==void 0&&P===void 0)b.push(u),m=u,p(c.id,u),i.push({message:a(R.lkgFallback,{id:c.id,sequence:O(u),reason:g}),level:"error"});else{r.push({bundleId:c.id,reason:u!==void 0?P:g}),i.push({message:a(R.requiredMissing,{id:c.id,reason:u!==void 0?P:g}),level:"error"});continue}}JSON.stringify(n.lkg[c.id])!==JSON.stringify(m)&&(n.lkg[c.id]=m,s=!0)}for(let c of Object.keys(n.lkg))l.has(c)||(delete n.lkg[c],s=!0);let B=r.length>0;return B?{groups:d.filter(c=>c.builtin===!0),notices:i,refuseLaunch:B,refusals:r,state:n,stateChanged:s}:(b.length>0&&d.push({dir:$,bundles:b}),{groups:d,notices:i,refuseLaunch:B,refusals:r,state:n,stateChanged:s})}function Re(e,o){return e===void 0||o===void 0||!o.lockedModes.includes(e)?{mode:e}:{mode:"default",lockedMode:e}}function ve(e){return{message:a(R.modeLocked,{mode:e}),level:"error"}}function be(e){let o=e.now??Date.now(),t=new Set((e.anchor?.requiredBundles??[]).map(s=>s.id)),i=[],r=[],n=[];for(let s of e.groups){if(s.builtin===!0){n.push(s);continue}let l=[];for(let p of s.bundles){let d=E(p,{now:o});if(d.ok){l.push(p);continue}let y=p.meta.id;t.has(y)?(r.push({bundleId:y,reason:d.reason}),i.push({message:a(R.sessionRequiredExpired,{id:y,reason:d.reason}),level:"error"})):i.push({message:a(R.sessionBundleExpired,{id:y,reason:d.reason}),level:"error"})}l.length>0&&n.push({...s,bundles:l})}return{groups:n,notices:i,refuseSession:r.length>0,refusals:r}}import z from"node:os";import Y from"node:path";import{randomBytes as H}from"node:crypto";import{mkdir as Z,open as q,readFile as X,rename as ee,rm as ie}from"node:fs/promises";import oe from"node:os";import x from"node:path";var re="policy-state.json";function M(){return{highWater:{},revoked:{},lkg:{}}}function A(e,o=oe.homedir()){let t=e.TANSR_CONFIG_DIR?.trim(),i=t!==void 0&&t!==""?t:x.join(o,".tansr");return x.join(i,re)}function te(e){let o={};if(typeof e!="object"||e===null||Array.isArray(e))return o;for(let[t,i]of Object.entries(e))typeof i=="number"&&Number.isInteger(i)&&i>=0&&(o[t]=i);return o}function ne(e){let o={};if(typeof e!="object"||e===null||Array.isArray(e))return o;for(let[t,i]of Object.entries(e)){if(!Array.isArray(i))continue;let r=i.filter(n=>typeof n=="number"&&Number.isInteger(n)&&n>=0);r.length>0&&(o[t]=[...new Set(r)].sort((n,s)=>n-s))}return o}function se(e){let o={};if(typeof e!="object"||e===null||Array.isArray(e))return o;for(let[t,i]of Object.entries(e)){let r=j(i);r.ok&&r.bundle.meta.id===t&&(o[t]=r.bundle)}return o}async function T(e,o=t=>X(t,"utf8")){let t;try{t=await o(e)}catch{return{state:M(),corrupted:!1}}let i;try{i=JSON.parse(t)}catch{return{state:M(),corrupted:!0}}if(typeof i!="object"||i===null||Array.isArray(i))return{state:M(),corrupted:!0};let r=i;return{state:{highWater:te(r.highWater),revoked:ne(r.revoked),lkg:se(r.lkg)},corrupted:!1}}async function F(e,o,t){let i=`${JSON.stringify(o,null,2)}
5
5
  `;if(t!==void 0){await t(e,i);return}let r=x.dirname(e);await Z(r,{recursive:!0});let n=`${e}.tmp-${process.pid}-${H(4).toString("hex")}`,s=await q(n,"w");try{await s.writeFile(i,"utf8"),await s.sync()}finally{await s.close()}try{await ee(n,e)}catch(l){throw await ie(n,{force:!0}),l}try{let l=await q(r,"r");try{await l.sync()}finally{await l.close()}}catch{}}var ce="TANSR_RECOMMENDED_RULES",le="tansr-recommended-v1",W={meta:{id:le,version:"1.0.0",issuer:"tansr",issuedAt:"2026-07-29T00:00:00Z"},rules:{ask:["Shell(git push --force *)","Shell(git push *)","Shell(gh pr merge *)","Shell(npm publish *)","Shell(pnpm publish *)","Shell(yarn publish *)","Shell(docker push *)","Shell(git reset --hard *)","Shell(git clean *)","Shell(git stash drop *)"]}};function V(e=process.env,o){let t=e[ce]?.trim();return t!==void 0&&t!==""?t!=="0":o!==!1}var v={loaded:"cli.policy.loaded",sourceError:"cli.policy.source_error",bundleSkipped:"cli.policy.bundle_skipped",invalidRules:"cli.policy.invalid_rules",trustLoaded:"cli.policy.trust_loaded",trustError:"cli.policy.trust_error",trustLoadedManaged:"cli.policy.trust_loaded_managed",trustErrorManaged:"cli.policy.trust_error_managed",sectionIgnored:"cli.policy.section_ignored",trustEnvIgnoredManaged:"cli.policy.trust_env_ignored_managed"},ue="TANSR_POLICY_TRUST",de=f.object({id:f.string().min(1),issuer:f.string().min(1),audience:f.string().min(1).optional(),minSequence:f.number().int().nonnegative().optional()}).strict(),J=f.object({keys:f.record(f.string().min(1)),unsignedPolicy:f.enum(["accept","reject"]).optional(),requiredBundles:f.array(de).optional(),lockedModes:f.array(f.enum(I)).optional(),autoTierCeiling:f.enum(["none","low","medium","high"]).optional(),qualificationRemote:f.object({url:f.string().min(1),required:f.boolean().optional()}).strict().optional(),adjudicatorPool:f.object({url:f.string().min(1),required:f.boolean().optional()}).strict().optional()}).strict(),ae=f.object({trust:J.optional()}).strict(),G={unsignedPolicy:"reject",verifiers:[]};function K(e,o,t){let i;try{i=[N({publicKeys:e.keys})]}catch{return o("trust_key_invalid")}let r=e.requiredBundles!==void 0||e.lockedModes!==void 0||e.autoTierCeiling!==void 0||e.qualificationRemote!==void 0||e.adjudicatorPool!==void 0?{requiredBundles:e.requiredBundles??[],lockedModes:e.lockedModes??[],...e.autoTierCeiling!==void 0?{autoTierCeiling:e.autoTierCeiling}:{},...e.qualificationRemote!==void 0?{qualificationRemote:e.qualificationRemote}:{},...e.adjudicatorPool!==void 0?{adjudicatorPool:e.adjudicatorPool}:{}}:void 0;return{verify:{unsignedPolicy:e.unsignedPolicy??"accept",verifiers:i},...r!==void 0?{anchor:r}:{},trustedKeys:e.keys,notices:[t(Object.keys(e.keys).length)]}}function fe(e){return(e?.ignoredLayers??[]).map(o=>({message:a(v.sectionIgnored,{layer:o}),level:"info"}))}async function ye(e={}){let o=e.env??process.env,t=fe(e.policy),i=s=>({...s,notices:[...t,...s.notices]}),r=o[ue]?.trim(),n=r!==void 0&&r!=="";if(e.policy!==void 0&&"managed"in e.policy){let s=p=>({verify:G,notices:[{message:a(v.trustErrorManaged,{code:p}),level:"error"}]}),l=ae.safeParse(e.policy.managed);if(!l.success)return i(s("trust_shape_invalid"));if(l.data.trust!==void 0){let p=n?[{message:a(v.trustEnvIgnoredManaged,{file:r}),level:"info"}]:[],d=K(l.data.trust,s,y=>({message:a(v.trustLoadedManaged,{count:y}),level:"info"}));return i({...d,notices:[...p,...d.notices]})}}if(n){let s=h=>({verify:G,notices:[{message:a(v.trustError,{code:h,file:r}),level:"error"}]}),l=e.fs?.readFile??pe,p;try{p=await l(r)}catch{return i(s("trust_unreadable"))}let d;try{d=JSON.parse(p)}catch{return i(s("trust_json_invalid"))}let y=J.safeParse(d);return y.success?i(K(y.data,s,h=>({message:a(v.trustLoaded,{count:h}),level:"info"}))):i(s("trust_shape_invalid"))}return{notices:t}}async function pe(e){let{readFile:o}=await import("node:fs/promises");return o(e,"utf8")}function Ae(e){let o=e.verify?.verifiers;if(!(o===void 0||o.length===0))return{verifiers:o}}function ge(e,o=z.homedir()){let t=[],i=e.TANSR_POLICY_DIR?.trim();i!==void 0&&i!==""&&t.push(i);let r=e.TANSR_CONFIG_DIR?.trim(),n=r!==void 0&&r!==""?r:Y.join(o,".tansr");return t.push(Y.join(n,"policies")),t}async function me(e={}){let o=e.env??process.env,t=[],i=[];for(let r of ge(o,e.homedir)){let s=await new w({dir:r,...e.fs!==void 0?{fs:e.fs}:{},onDiagnostic:l=>{l.code!=="dir_missing"&&t.push({message:a(v.sourceError,{code:l.code,file:l.file}),level:l.severity==="error"?"error":"info"})}}).load();s.length>0&&i.push({dir:r,bundles:s})}return V(o,e.recommendedRules)&&i.push({dir:"builtin",bundles:[W],builtin:!0}),{groups:i,notices:t}}function U(e,o,t){let i=[];for(let r of o){let n=e.loadPolicyBundles(r.bundles,{source:r.builtin===!0?"builtin":`localDir:${r.dir}`,...t!==void 0&&r.builtin!==!0?{verify:t}:{}}),s=0;for(let l of n)l.status==="loaded"?s+=1:(r.builtin!==!0||l.reason!=="duplicate_id")&&i.push({message:a(v.bundleSkipped,{id:l.bundleId,reason:l.reason??"unknown"}),level:"error"}),l.invalidRuleCount>0&&i.push({message:a(v.invalidRules,{id:l.bundleId,count:l.invalidRuleCount}),level:"error"});s>0&&r.builtin!==!0&&i.push({message:a(v.loaded,{count:s,dir:r.dir}),level:"info"})}return i}async function Te(e,o={}){let t=o.env??process.env,i=o.trust??await ye(o),{groups:r,notices:n}=await me(o),s=o.statePath??A(t,o.homedir??z.homedir()),l=await T(s,o.fs?.readFile),p=i.anchor?.requiredBundles??[];if(l.corrupted&&p.length>0){let h=p.map(c=>({bundleId:c.id,reason:"state_corrupted"})),b=[...i.notices,...n];b.push({message:a(R.stateCorruptedRefuse,{file:s}),level:"error"});for(let c of h)b.push({message:a(R.requiredMissing,{id:c.bundleId,reason:c.reason}),level:"error"});let B=r.filter(c=>c.builtin===!0);return b.push(...U(e,B,i.verify)),{notices:b,refuseLaunch:!0,refusals:h,...i.anchor!==void 0?{anchor:i.anchor}:{},groups:B}}l.corrupted&&n.push({message:a(R.stateCorrupted,{file:s}),level:"error"});let d=D({groups:r,verify:i.verify,anchor:i.anchor,state:l.state,...o.now!==void 0?{now:o.now}:{}}),y=[...i.notices,...n,...d.notices];if(d.stateChanged)try{await F(s,d.state,o.stateWriteFile)}catch{y.push({message:a(R.stateWriteFailed,{file:s}),level:"error"})}return y.push(...U(e,d.groups,i.verify)),{notices:y,refuseLaunch:d.refuseLaunch,refusals:d.refusals,...i.anchor!==void 0?{anchor:i.anchor}:{},groups:d.groups}}export{R as a,I as b,Re as c,ve as d,be as e,ye as f,Ae as g,ge as h,U as i,Te as j};
6
- //# sourceMappingURL=tansr-chunk-S77B4PI7.mjs.map
6
+ //# sourceMappingURL=tansr-chunk-HHL7HM62.mjs.map