@tangle-network/sandbox-cli 0.23.9 → 0.23.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{account-BaGFNxyq.mjs → account-Bklwl_Tx.mjs} +1 -1
- package/dist/{credential-store-Bpw_4ZTQ.mjs → credential-store-DysDRcD-.mjs} +1 -1
- package/dist/{device-i0PzYisd.mjs → device-D6rmGHLz.mjs} +1 -1
- package/dist/graph-native-B8Vtf07K.mjs +1 -0
- package/dist/index.mjs +34 -34
- package/dist/{run-BSXC2ytE.mjs → run-BxATA6T4.mjs} +1 -1
- package/dist/{solve-signer--UaZcdFY.mjs → solve-signer-D6EYGOv9.mjs} +1 -1
- package/dist/{submit-D2jvFJtX.mjs → submit-BCCjJAeU.mjs} +1 -1
- package/package.json +5 -5
- package/dist/graph-native-CmG9wDbX.mjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,o as t}from"./output-BqCeTtw4.mjs";import{n,t as r}from"./solve-signer
|
|
1
|
+
import{a as e,o as t}from"./output-BqCeTtw4.mjs";import{n,t as r}from"./solve-signer-D6EYGOv9.mjs";function i(i){let a=i.create?r():n();if(!a)throw Error("No Solve device signer found. Run `tangle solve account --create`");i.json?e({address:a.account.address,source:a.source}):t({Address:a.account.address,Source:a.source})}export{i as showSolveAccount};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"node:
|
|
1
|
+
import*as e from"node:fs";import*as t from"node:path";import{randomUUID as n}from"node:crypto";import*as r from"node:os";import{execFileSync as i}from"node:child_process";import{lockSync as a}from"proper-lockfile";const o=t.join(r.homedir(),`.tangle`),s=t.join(o,`credentials.json`),c=`tangle-sandbox-cli`,l=new Int32Array(new SharedArrayBuffer(4));var u=class extends Error{constructor(e,t){super(`Credentials file at ${e} is corrupted and cannot be parsed. Inspect or remove it manually before retrying — refusing to overwrite it automatically.`),this.filePath=e,this.name=`CredentialsFileCorruptedError`,t&&(this.cause=t)}},d=class extends Error{constructor(e){super(`Credential storage preflight failed: ${e}`),this.name=`CredentialStorageProbeError`}},f=class extends Error{constructor(e){super(`Credential storage is busy. Wait a moment and retry.`),this.name=`CredentialsFileLockedError`,e&&(this.cause=e)}};function p(e){let t=v(e);if(t)return{value:t,source:`keychain`};let n=x(e);return n?{value:n,source:`file`}:{source:`none`}}function m(e,t){return y(e,t)?(C(e),`keychain`):(S(e,t),`file`)}function h(){let e=`credential-write-probe:${process.pid}:${n()}`,t=n();if(y(e,t)){let n=v(e);if(!b(e))throw new d(`the OS keychain accepted a test credential but the CLI could not remove it`);if(n!==t)throw new d(`the OS keychain accepted a test credential but the CLI could not read it back`);return`keychain`}return D(e),`file`}function g(e){b(e),C(e)}function _(e,t){let n=process.platform;if(n!==`darwin`&&n!==`linux`)return;let r=n===`darwin`?`security`:`secret-tool`;try{return i(r,e[n],{encoding:`utf8`,input:t,stdio:[t===void 0?`ignore`:`pipe`,`pipe`,`ignore`],timeout:n===`linux`?1e4:void 0}).trim()}catch{return}}function v(e){let t=k(e);return _({darwin:[`find-generic-password`,`-s`,c,`-a`,t,`-w`],linux:[`lookup`,`service`,c,`account`,t]})}function y(e,t){let n=k(e),r=[`add-generic-password`,`-U`,`-s`,c,`-a`],i=[`store`,`--label=Tangle Sandbox CLI`,`service`];return _({darwin:[...r,n,`-w`,t],linux:[...i,c,`account`,n]},process.platform===`linux`?t:void 0)!==void 0}function b(e){let t=k(e);return _({darwin:[`delete-generic-password`,`-s`,c,`-a`,t],linux:[`clear`,`service`,c,`account`,t]})!==void 0}function x(e){return T()[e]}function S(e,t){w(()=>{let n=T();n[e]=t,E(n)})}function C(e){return w(()=>{let t;try{t=T()}catch(e){if(e instanceof u)return!1;throw e}return e in t?(delete t[e],E(t),x(e)===void 0):!0})}function w(e){O();let t=Date.now()+2e3,n,r;for(;!n;)try{n=a(s,{realpath:!1,stale:5e3})}catch(e){if(r=e instanceof Error?e:void 0,!e||typeof e!=`object`||!(`code`in e)||e.code!==`ELOCKED`)throw e;if(Date.now()>=t)throw new f(r);Atomics.wait(l,0,0,20)}try{return e()}finally{n()}}function T(){let t;try{t=e.readFileSync(s,`utf8`)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return{};throw e}try{let e=JSON.parse(t);if(typeof e!=`object`||!e||Array.isArray(e))throw new u(s);let n={};for(let[t,r]of Object.entries(e))typeof r==`string`&&(n[t]=r);return n}catch(e){throw e instanceof u?e:new u(s,e instanceof Error?e:void 0)}}function E(t){if(O(),Object.keys(t).length===0){e.existsSync(s)&&e.unlinkSync(s);return}let n=`${s}.${process.pid}.tmp`;e.writeFileSync(n,`${JSON.stringify(t,null,2)}\n`,{mode:384}),e.renameSync(n,s)}function D(e){let t=n(),r=!1,i;try{if(S(e,t),r=!0,x(e)!==t)throw new d(`the credentials file did not return the value just written`)}catch(e){i=e}finally{if(r)try{!C(e)&&!i&&(i=new d(`the credentials file accepted a test credential but the CLI could not remove it`))}catch(e){i??=e}}if(i)throw i}function O(){if(!e.existsSync(o)){e.mkdirSync(o,{mode:448,recursive:!0});return}if(process.platform!==`win32`)try{(e.statSync(o).mode&511)!=448&&e.chmodSync(o,448)}catch{}}function k(e){return`profile:${e}`}export{m as i,g as n,p as r,h as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,f as t,i as n,p as r,r as i}from"./output-BqCeTtw4.mjs";import{p as a,y as o}from"./index.mjs";import{n as s,r as c}from"./solve-signer
|
|
1
|
+
import{a as e,f as t,i as n,p as r,r as i}from"./output-BqCeTtw4.mjs";import{p as a,y as o}from"./index.mjs";import{n as s,r as c}from"./solve-signer-D6EYGOv9.mjs";import{n as l,r as u,t as d}from"./api-COxVvwlJ.mjs";import{t as f}from"./deployment-t_Jhgj4Q.mjs";import{n as p,o as m,v as h,x as g}from"./transactions-C3dKwqB0.mjs";import{createPublicClient as _,getAddress as v,http as y,isAddress as b}from"viem";import{tempoModerato as x}from"viem/chains";const S={...f,chainName:`Tempo Moderato`,nativeSymbol:`TNT`},C={async read(e){let t=_({chain:x,transport:y(S.rpcUrl,{timeout:15e3})}),n=e=>e.catch(()=>null),r=await Promise.all(e.map(async e=>{let[r,i]=await Promise.all([n(t.readContract({address:S.tangleAddress,abi:g,functionName:`isPermittedCaller`,args:[S.serviceId,e]})),n(t.readContract({address:S.managerAddress,abi:h,functionName:`isDeviceRevoked`,args:[e]}))]);return[e.toLowerCase(),{permitted:r,revoked:i}]}));return new Map(r)},async revokeSelf(e){return p(await m(S,e),S)}},w={permitted:null,revoked:null};function T(e){return e.revoked?`revoked`:e.permitted===null?`unknown`:e.permitted?`permitted`:`not permitted`}async function E(t,r=C){try{let{devices:i}=await l({apiUrl:t.apiUrl,profile:t.profile}),a=s()?.account.address.toLowerCase(),o=i.map(e=>({...e,local:e.address===a,status:e.revokedAt?`revoked`:`active`}));a&&!o.some(e=>e.local)&&o.push({address:a,local:!0,status:`unbound`,boundAt:null,lastUsedAt:null,revokedAt:null,revocationMethod:null,revocationReason:null});let c=await r.read(o.map(e=>v(e.address))),u=o.map(e=>({...e,onChain:c.get(e.address)??w}));if(t.json){e({serviceId:S.serviceId.toString(),devices:u});return}n([`Address`,`Status`,`Local`,`Service ${S.serviceId}`,`Last used`,`Revoked`],u.map(e=>[e.address,e.status,e.local?`yes`:``,T(e.onChain),e.lastUsedAt??``,e.revokedAt?`${e.revokedAt} (${e.revocationMethod})`:``]))}catch(e){o(e,t.json)}}async function D(n,l,f=C){try{if(!b(n))throw Error(`${n} is not an EVM address`);let o=v(n),p=s(),m=p?.account.address===o;if(!l.yes){if(!process.stdin.isTTY)throw Error(`Revoking a device is permanent. Re-run with --yes to confirm`);if(!await a(`Permanently revoke Solve device ${o}${m?` (this machine's device)`:``}? [y/N] `,`--yes`)){i(`Revocation cancelled`);return}}let h;if(p&&m){let e=await d({deviceAddress:o,purpose:`revoke`,apiUrl:l.apiUrl,profile:l.profile});h={challengeId:e.challengeId,signature:await p.account.signMessage({message:e.message})}}let g=await u({deviceAddress:o,reason:l.reason,...h,apiUrl:l.apiUrl,profile:l.profile}),_=o.toLowerCase(),y=(await f.read([o])).get(_)??w,x;if(p&&m&&!y.revoked){try{x=await f.revokeSelf(p.account)}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`The Solve API revoked ${o}, but the on-chain revocation failed and the local key was kept: ${t}. Run the command again to retry`)}y=(await f.read([o])).get(_)??w}let C=p&&m&&y.revoked?c(p):void 0;if(l.json){e({...g,serviceId:S.serviceId.toString(),onChain:y,...x?{revocationTransaction:x}:{},localKeyRetired:!!C});return}t(g.alreadyRevoked?`${o} was already revoked in the Solve API`:`Revoked ${o}; the Solve API refuses its signatures`),x&&t(`Revoked on Tempo in ${x}; service ${S.serviceId} refuses its jobs`),C&&i("The local device key was moved aside because its address may still hold stake or rewards. Run `tangle solve account --create` for a new device"),!m&&y.permitted&&r(`The device can still submit jobs to service ${S.serviceId}. Only its key, or the Solve blueprint owner, can revoke it on chain`)}catch(e){o(e,l.json)}}export{E as listSolveDevices,D as revokeSolveDevice};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{constants as e}from"node:fs";import{isAbsolute as t,join as n,relative as r}from"node:path";import{createHash as i}from"node:crypto";import{z as a}from"zod";import{open as o,opendir as s,realpath as c}from"node:fs/promises";import*as l from"@tangle-network/agent-runtime/kernel";import{CODEX_HOME_RULE as u,STORES as d,claudeCodeRefForFile as f,codexRefForFile as p,readSessionInput as m,storeGlob as h,withinPath as g}from"@tangle-network/harness-sessions";const _=a.object({harness:a.enum([`codex`,`claude-code`]),root:a.string().refine(t),basis:a.literal(`host-jail`),nativeSessionId:a.string().min(1),runId:a.string().min(1),requestDigest:a.string().regex(/^sha256:[a-f0-9]{64}$/)}),v=a.object({externalId:a.string(),internalId:a.string(),backend:a.enum([`codex`,`claude-code`]),cwd:a.string(),metadata:a.object({effective_native_store:_,agent_profile_binding:a.object({effectiveProfileDigest:a.string()})})});function y(){let e=new Map;return{observe(t){e.set(`${t.runId}:${t.requestDigest}`,t)},close(){e.clear()},redact(t,n){for(let n of t.runs){let r=e.get(`${n.runId}:${n.requestDigest}`);if(!r||r.sessionId!==t.sessionId||r.profileDigest!==t.profileDigest||r.cwd!==t.cwd)throw Error(`Exact native execution has no trusted redaction authority`)}if(!t.runs.length)throw Error(`Native redaction requires an exact execution binding`);let r=n;for(let n of e.values())n.sessionId===t.sessionId&&n.profileDigest===t.profileDigest&&n.cwd===t.cwd&&(r=n.redact(r));return r}}}function b(e,t){if(e===`codex`)return p(t);let n=t.split(`/`),r=n.indexOf(`subagents`,3);return f(t,r>0?n[r-1]??null:null)}async function x(e,t,i){let a=[],o=d[`claude-code.projects-jsonl`],f=n(t,...o.root.split(`/`).slice(1)),p=e===`codex`?u.sessionDirs.map(e=>n(t,e)):[f],m=e===`codex`?[h(u.rollout)]:o.files.map(e=>h(e)),_=0;for(;p.length;){i.throwIfAborted();let o=p.shift();if(o===void 0)break;let u;try{u=await c(o)}catch(e){if(e.code===`ENOENT`)continue;throw e}if(!g(u,t))throw Error(`Native inventory escaped its attested store`);let d=await s(u);for await(let o of d){if(i.throwIfAborted(),++_>l.HARNESS_TRANSCRIPT_READ_LIMITS.maxFiles)throw Error(`Native inventory exceeds the capture bound`);let s=n(d.path,o.name);o.isDirectory()?p.push(s):o.isFile()&&m.some(t=>t.test(e===`codex`?o.name:r(f,s)))&&a.push({path:r(t,s),nativeSessionId:b(e,r(t,s)).nativeSessionId})}}return a}function S(t){return async r=>{if(![`codex`,`claude-code`].includes(r.harness))return{status:`unavailable`,reason:`unknown-harness`,skipped:[{path:r.harness,reason:`Native transcript capture is not configured for this harness`}]};let s=await fetch(`${t.bridgeUrl}/v1/sessions?session_id=${encodeURIComponent(r.sessionId)}&backend=${r.harness}`,{headers:{authorization:`Bearer ${t.bridgeBearer}`},signal:r.signal});if(!s.ok)throw Error(`Bridge session lookup failed (HTTP ${s.status})`);let u=a.object({data:a.tuple([v])}).parse(await s.json()).data[0],d=u.metadata.effective_native_store,f=await c(d.root);if(u.backend!==r.harness||d.harness!==r.harness||u.externalId!==r.sessionId||u.internalId!==d.nativeSessionId||u.cwd!==t.cwd||r.cwd!==t.cwd||u.metadata.agent_profile_binding.effectiveProfileDigest!==r.profileDigest||f!==d.root||!g(f,n(t.cwd,`.agent-home`))||!r.runs.some(e=>e.runId===d.runId&&e.requestDigest===d.requestDigest))throw Error(`Bridge native binding does not match this execution`);let p=[],h=[...new Set(t.privateMcpSecrets?.()??[])].flatMap(e=>[e,JSON.stringify(e).slice(1,-1)]).filter(Boolean).sort((e,t)=>t.length-e.length),_=await l.captureBoundHarnessTranscript({harness:r.harness,binding:{kind:`bridge`,sessionId:r.sessionId,nativeSessionId:d.nativeSessionId,profileDigest:r.profileDigest,runs:r.runs,...r.node===void 0?{}:{node:r.node}},nativeSessionId:d.nativeSessionId,files:await x(r.harness,f,r.signal),signal:r.signal,parse:(e,t)=>m(r.harness,{text:e},{...b(r.harness,t.path),label:t.path},{corruption:`strict`}),read:async(a,s)=>{let u=await c(n(f,a.path));if(!g(u,f))throw Error(`Native session escaped its attested store`);let d=await o(u,e.O_RDONLY|e.O_NOFOLLOW);try{let e=await d.stat();if(!e.isFile()||e.size>l.HARNESS_TRANSCRIPT_READ_LIMITS.maxFileBytes)throw Error(`Native session is not a bounded regular file`);s?.throwIfAborted();let n=await d.readFile();if(s?.throwIfAborted(),!t.redact)throw Error(`The native host did not supply private redaction authority`);let o=t.redact(r,n),c=new TextDecoder(`utf-8`,{fatal:!0}).decode(o);for(let e of h)c=c.split(e).join(`[redacted:MCP]`);let u=Buffer.from(c,`utf8`);return u.equals(n)||p.push({path:a.path,reason:`Original bytes withheld for private MCP credential redaction; source sha256:${i(`sha256`).update(n).digest(`hex`)}; retained copy is redacted`}),u}finally{await d.close()}}});return _.status!==`captured`||!p.length?_:{..._,artifact:{..._.artifact,skipped:[..._.artifact.skipped,...p]},skippedCount:_.skippedCount+p.length,coverageComplete:!1,missing:[`private-mcp-secret-original-bytes`]}}}const C=async(e,t)=>{if(![`codex`,`claude-code`].includes(e.harness)||e.binding?.kind!==`bridge`)throw Error(`Native transcript reader is not configured for this capture`);return(await l.readBoundHarnessSessions({nativeSessionId:e.binding.nativeSessionId,files:e.files.map(t=>({path:t.path,nativeSessionId:b(e.harness,t.path).nativeSessionId,byteLength:t.bytes})),read:async t=>{let n=e.files.find(e=>e.path===t.path);if(!n)throw Error(`Retained native file is absent`);return Buffer.from(n.content,`utf8`)},parse:(t,n)=>m(e.harness,{text:t},{...b(e.harness,n.path),label:n.path},{corruption:`strict`}),signal:t})).sessions};export{S as graphNativeCapture,y as graphNativeRedaction,C as readGraphSessions};
|