@tangle-network/sandbox-cli 0.23.49 → 0.23.51
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-Bvp7ybXe.mjs → account-DpYhbTSh.mjs} +1 -1
- package/dist/{clone-CGZYYIyg.mjs → clone-BRhKd1M8.mjs} +1 -1
- package/dist/{device-BHXfYbhx.mjs → device-tAhoylw1.mjs} +1 -1
- package/dist/dist-BIPLBBqd.mjs +3 -0
- package/dist/graph-CDrrlr4U.mjs +28 -0
- package/dist/graph-knowledge-cloud-C-3SJpFF.mjs +1 -0
- package/dist/graph-learning-XjrAqpQA.mjs +1 -0
- package/dist/graph-operating-evidence-W3dtTQ6O.mjs +2 -0
- package/dist/graph-profile-learning-DaoL53AA.mjs +1 -0
- package/dist/graph-run-input-DKt3kkgz.mjs +1 -0
- package/dist/index.mjs +2 -2
- package/dist/{run-Dqle1Aqw.mjs → run-DCWcknDb.mjs} +1 -1
- package/dist/{solve-checker-20YvRxEl.mjs → solve-checker-D0hUS6c_.mjs} +1 -1
- package/dist/{submit-BdeTE48V.mjs → submit-81-v2Gw0.mjs} +1 -1
- package/dist/{transactions-DFa7N-_-.mjs → transactions-Ba_26pWn.mjs} +1 -1
- package/dist/{workspace-BNZ3MDaM.mjs → workspace-B4tVN1WV.mjs} +1 -1
- package/package.json +8 -8
- package/dist/dist-BBDy-phh.mjs +0 -1
- package/dist/graph-B4DU_AWh.mjs +0 -28
- package/dist/graph-learning-DhfF4qI1.mjs +0 -1
- package/dist/graph-operating-evidence-gLn25LNh.mjs +0 -2
- package/dist/graph-profile-learning-DhkIlCe2.mjs +0 -1
- /package/dist/{api-BGYiAuZk.mjs → api-CvScxXEC.mjs} +0 -0
- /package/dist/{deployment-wpslctFo.mjs → deployment-_Lk0By4d.mjs} +0 -0
- /package/dist/{graph-native-DqMbZ0no.mjs → graph-native-Cdrs4zTi.mjs} +0 -0
- /package/dist/{graph-view-Cl3a9QXl.mjs → graph-view-XAH_4NvF.mjs} +0 -0
- /package/dist/{solve-signer-BAxIt1Qi.mjs → solve-signer-CpH58uD4.mjs} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./rolldown-runtime-CgXYkLm_.mjs";import{a as t}from"./output-COlRi7gh.mjs";import{g as n,r}from"./index.mjs";import{t as i}from"./graph-native-producer-BnDMFjLO.mjs";import{findPackageJSON as a}from"node:module";import{constants as o}from"node:fs";import{basename as s,dirname as c,isAbsolute as l,join as u,relative as ee,resolve as d,sep as te}from"node:path";import{Option as ne}from"commander";import{createHash as re,randomUUID as f}from"node:crypto";import{agentCandidateArtifactRefSchema as p,agentCandidateWorkspaceSnapshotEvidenceSchema as ie,canonicalCandidateDigest as m}from"@tangle-network/agent-interface";import{z as h}from"zod";import{homedir as g}from"node:os";import{graphMcpPolicySchema as ae,graphMcpPolicySchema as _}from"@tangle-network/hub-sdk";import{link as oe,lstat as v,mkdir as y,open as b,readFile as x,realpath as S,rm as C,writeFile as w}from"node:fs/promises";const se=import.meta.url,ce=h.object({schema:h.literal(`cli-bridge.host-policy.v1`),subscriptionsOnly:h.boolean(),bearerRequired:h.boolean(),jail:h.object({mode:h.enum([`off`,`write-jail`,`fs-jail`]),fallback:h.enum([`deny`,`warn`]),network:h.object({default:h.enum([`none`,`router`,`relay`]),ceiling:h.enum([`none`,`router`,`relay`])})}),trustedPorts:h.object({privateMcpSecrets:h.boolean(),hub:h.boolean()})}),le=h.discriminatedUnion(`kind`,[h.strictObject({kind:h.literal(`embedded`),endpoint:h.url()}),h.strictObject({kind:h.literal(`surviving`),endpoint:h.url(),credentialEnv:h.enum([`BRIDGE_BEARER`,`CLI_BRIDGE_BEARER`]),policyDigest:h.string().regex(/^sha256:[a-f0-9]{64}$/)})]);function T(e){throw new n(`GRAPH_HOST_REFUSED`,`The graph host cannot admit this execution`,e,`tangle graph run --help`)}function E(){let e=process.env.CLI_BRIDGE_URL;if(!e)return;let t;try{t=new URL(e)}catch{return T(`CLI_BRIDGE_URL is not a valid loopback HTTP origin`)}(t.protocol!==`http:`||![`localhost`,`127.0.0.1`,`[::1]`].includes(t.hostname)||t.username||t.password||t.search||t.hash||t.pathname!==`/`)&&T(`CLI_BRIDGE_URL must name an explicit loopback HTTP origin on this filesystem`);let n=process.env.BRIDGE_BEARER===void 0?`CLI_BRIDGE_BEARER`:`BRIDGE_BEARER`,r=process.env[n];return(!r||/[\r\n]/u.test(r))&&T(`The configured Bridge bearer environment variable is absent or invalid`),{endpoint:t.origin,credentialEnv:n,bearer:r}}async function ue(e,t){let n=E();if(n&&process.platform!==`linux`&&T(`Surviving native capture requires this Linux filesystem; macOS uses its owned live Bridge`),t?.kind===`embedded`&&T(`The recorded embedded Bridge belonged to the original CLI process; its uncertain native work cannot be relaunched`),!n){t&&T(`Resume requires the recorded surviving Bridge endpoint and bearer environment binding`);return}t&&(n.endpoint!==t.endpoint||n.credentialEnv!==t.credentialEnv)&&T(`The recorded Bridge endpoint or credential environment binding changed`);let r=await fetch(`${n.endpoint}/`,{headers:{authorization:`Bearer ${n.bearer}`},signal:e,redirect:`error`}).catch(()=>(e.throwIfAborted(),T(`The configured Bridge is unavailable; retained native work remains unknown`)));r.ok||T(`The configured Bridge policy lookup failed (HTTP ${r.status})`);let i=h.object({name:h.literal(`cli-bridge`),hostPolicy:ce,capabilities:h.object({nativeCapture:h.literal(`cli-bridge.native-capture.v1`)})}).safeParse(await r.json());i.success||T(`The surviving Bridge does not attest its process policy`);let a=i.data.hostPolicy;(!a.bearerRequired||!a.subscriptionsOnly||a.jail.mode!==`fs-jail`||a.jail.fallback!==`deny`)&&T(`A surviving Graph host must enforce subscriptions-only native admission and a filesystem jail with deny fallback`);let o=m(a);return t&&t.policyDigest!==o&&T(`The recorded Bridge process policy changed`),{...n,policy:a,binding:{kind:`surviving`,endpoint:n.endpoint,credentialEnv:n.credentialEnv,policyDigest:o}}}function de(e){E()&&(e.entry===void 0||e.nodes.some(e=>Object.entries(e.profile.tools??{}).some(([e,t])=>t&&e.startsWith(`agent_runtime_coordination_`))))&&T(`Coordinating execution requires its surviving host-owned listener and signer; this CLI cannot register listeners on an external Bridge`)}function fe(e,t,n){Object.keys(n??{}).length&&T(`A surviving Bridge must resolve private MCP references from its own trusted secret provider; CLI environment bindings cannot be uploaded`);let r={backend:`bridge`,bridgeUrl:e.endpoint,bridgeBearer:e.bearer,cwd:t};return{...r,harnessTranscript:i(r)}}function pe(e){return{authentication:!0,publicUrl(t){t.host!==`127.0.0.1`&&T(`The embedded coordination listener is not bound to its owned IPv4 loopback`);let n=`http://${t.host}:${t.port}/mcp`;return e.registerCoordinationEndpoint({...t,url:n}),n}}}async function me(e,t){let r=e.nodes.some(e=>e.profile.connections?.length);if(r&&E())throw Error(`A surviving Graph host cannot bind CLI-owned Hub connections`);let i=r?await t():void 0;if(r&&!i)throw new n(`AUTH_REQUIRED`,`Hub authentication is required`,`No Tangle credential is configured for this local graph`,`tangle auth login`);return{needsHub:r,client:i}}const he=()=>new ne(`--mcp-secret <key=variable>`,`Private local MCP secret reference binding; repeatable, values are never recorded`).argParser((e,t)=>[...t,e]).default([]);function ge(e=[]){let t=new Map;for(let r of e){let e=r.indexOf(`=`),i=r.slice(0,e).trim(),a=r.slice(e+1).trim();if(e<1||!i||!/^[A-Za-z_][A-Za-z0-9_]*$/.test(a)||t.has(i)&&t.get(i)!==a)throw new n(`GRAPH_MCP_SECRET_BINDING`,`Invalid private MCP credential binding`,`Use one unambiguous key=ENVIRONMENT_VARIABLE per declared secret reference`,`tangle graph run --help`);t.set(i,a)}return Object.fromEntries(t)}async function _e(e){try{return ae.parse(JSON.parse(await x(e,`utf8`)))}catch(e){throw new n(`GRAPH_MCP_POLICY_INVALID`,`The graph MCP policy is invalid`,e instanceof Error?e.message:String(e),`tangle graph run --help`)}}function D(e,t){let n=ee(e,t);return n!==`..`&&!n.startsWith(`..${te}`)&&!l(n)}const O=()=>import(`@tangle-network/agent-eval/campaign`),k=()=>import(`@tangle-network/agent-runtime/candidate-execution`),A=`graph-task-workspaces`,j=h.number().int().positive().max(2**53-1),M=h.strictObject({maxArchiveBytes:j.optional(),maxEmbeddedArtifactBytes:j.optional(),maxFiles:j.optional(),maxFileBytes:j.optional(),maxTotalFileBytes:j.optional(),maxPathBytes:j.optional(),maxRepositoryBundleBytes:j.optional()}),N=ie.shape,P=h.strictObject({snapshot:h.strictObject({kind:N.kind,digest:N.digest,manifest:p,archive:p}).superRefine((e,t)=>{(e.digest!==e.manifest.sha256||!e.manifest.byteLength||!e.archive.byteLength)&&t.addIssue({code:`custom`,message:`The canonical workspace manifest, digest and archive must agree`})}),capture:h.strictObject({mode:h.literal(`git-working-tree`),runtimeVersion:h.string().min(1),limits:M}),gaps:h.tuple([h.literal(`environment-and-toolchain-not-snapshotted`),h.literal(`git-ignored-files-excluded`)])}),F=e=>m(P.parse(e));function I(e){for(let t of[e.snapshot.manifest,e.snapshot.archive])if(t.locator.kind!==`private-cas`||t.locator.namespace!==A)throw Error(`Task workspace artifacts require their original local private CAS; cross-backend activation is unsupported`)}async function L(){let e=u(g(),`.tangle`);return await y(e,{recursive:!0,mode:448}),S(e)}const R=async e=>(await import(`@tangle-network/agent-runtime/kernel`)).createPrivateCasArtifactPort(u(e,`artifacts`),A);async function ve(e){let t=await b(d(e),o.O_RDONLY|o.O_NOFOLLOW);try{if(!(await t.stat()).isFile())throw Error(`Task workspace reference must be a regular file`);let e=P.parse(JSON.parse(await t.readFile(`utf8`)));return I(e),e}finally{await t.close()}}async function ye(e,t={}){t.signal?.throwIfAborted();let n=d(e),r=await v(n);if(!r.isDirectory()||r.isSymbolicLink())throw Error(`Task workspace must be one real repository root`);let i=await S(n),o=await S(g()),s=await L();if(i===o||i===c(i)||D(s,i)||D(i,s))throw Error(`Task workspace capture cannot include the home, filesystem or private evidence root`);let{release:l}=(await O()).acquireSingleRunLock({lockPath:`${i}.graph-workspace.lock`});try{let e=M.parse(t.limits??{}),n=await(await k()).captureAgentWorkspaceSnapshot(i,{includeRepository:!0,repositoryContents:`working-tree`,limits:e,artifactPersistence:{executionId:f(),outputArtifacts:await R(s),signal:t.signal}}),r=a(`@tangle-network/agent-runtime`,import.meta.url);if(!r)throw Error(`Cannot identify the Runtime workspace archive owner`);let o=JSON.parse(await x(r,`utf8`));return P.parse({snapshot:n,capture:{mode:`git-working-tree`,runtimeVersion:o.version,limits:e},gaps:[`environment-and-toolchain-not-snapshotted`,`git-ignored-files-excluded`]})}finally{l()}}async function be(e,t){let n=h.uuid().parse(t.runId),r=P.parse(e);I(r);let i=await L(),a=u(i,`workspaces`);if(await y(a,{recursive:!0,mode:448}),await S(a)!==a)throw Error(`Task workspace allocation root redirects elsewhere`);let o=u(a,n),{release:s}=(await O()).acquireSingleRunLock({lockPath:`${o}.lock`});try{t.signal?.throwIfAborted();let e=`${o}.task-workspace.json`,a;try{a=JSON.parse(await x(e,`utf8`))}catch(e){if(e.code!==`ENOENT`)throw e}let c=F(r);if(a!==void 0){let e=h.strictObject({runId:h.uuid(),identity:h.string()}).parse(a);if(e.runId!==n||e.identity!==c||t.resumeCwd!==void 0&&d(t.resumeCwd)!==o||await S(o)!==o||!(await v(o)).isDirectory())throw Error(`The retained task workspace no longer names this exact native run allocation`)}else{if(t.resumeCwd!==void 0)throw Error(`The retained task workspace allocation receipt is missing`);await(await k()).materializeAgentWorkspaceSnapshot({snapshot:r.snapshot,artifacts:await R(i),destination:o,limits:r.capture.limits,signal:t.signal}),await w(e,JSON.stringify({runId:n,identity:c}),{flag:`wx`,mode:384,flush:!0})}if(!t.validationOnly||a!==void 0)return{cwd:o,release:s};let l=await Promise.all([v(o,{bigint:!0}),v(e,{bigint:!0})]);return{cwd:o,release:async()=>{try{for(let[t,r]of[o,e].entries()){let e=await v(r,{bigint:!0});if(!(t===0?e.isDirectory():e.isFile())||e.dev!==l[t]?.dev||e.ino!==l[t]?.ino||await S(r)!==r)throw Error(`Validation allocation ${n} changed; retained`)}if(m(JSON.parse(await x(e,`utf8`)))!==m({runId:n,identity:c}))throw Error(`Validation allocation ${n} receipt changed; retained`);try{throw await v(u(i,`runs`,n)),Error(`Validation allocation ${n} has run state; retained`)}catch(e){if(e.code!==`ENOENT`)throw e}await C(o,{recursive:!0}),await C(e)}finally{s()}}}}catch(e){throw s(),e}}function xe(e){e.command(`workspace`).description(`Capture immutable local task files for graph replay`).command(`capture <repository>`).description(`Capture Git HEAD, index, tracked and unignored files into private local artifacts`).requiredOption(`--output <file>`,`New reference file outside the source repository`).option(`--limits <file>`,`JSON overrides for the maintained Runtime archive limits`).action(async(e,n)=>{let r=await S(d(e)),i=u(await S(c(d(n.output))),s(d(n.output)));if(D(r,i))throw Error(`The task reference must be written outside the original workspace`);try{throw await v(i),Error(`Task workspace reference already exists; choose a new output file`)}catch(e){if(e.code!==`ENOENT`)throw e}let a=await ye(r,{limits:n.limits?M.parse(JSON.parse(await x(n.limits,`utf8`))):void 0});await w(i,JSON.stringify(a),{flag:`wx`,mode:384,flush:!0}),t(a)})}var Se=e({assertResumeOptions:()=>Te,graphLearningAdmission:()=>V,graphParameterArgs:()=>$,graphResumeRefusal:()=>W,graphRunHostConfiguration:()=>U,graphRunInputModule:()=>z,graphTaskValues:()=>Ee,readGraphRunAdmission:()=>K,readGraphRunInput:()=>G,readGraphRunSource:()=>we,writeGraphRunAdmission:()=>Z,writeGraphRunInput:()=>Ce});const z=import.meta.url,B=h.string().regex(/^[a-f0-9]{64}$/),V=h.strictObject({dataset:h.string().refine(l),domain:h.string().min(1),unit:h.string().min(1),split:h.enum([`train`,`dev`,`test`]),policyDigest:h.string().regex(/^sha256:[a-f0-9]{64}$/)}),H=h.strictObject({version:h.literal(1),runId:h.uuid(),file:h.string().refine(l),cwd:h.string().refine(l),sourceDigest:B,source:h.string().optional(),graphDigest:B,params:h.record(h.string(),h.unknown()),trigger:h.record(h.string(),h.unknown()).optional(),gateChoices:h.record(h.string(),h.string()).optional(),startedAt:h.iso.datetime(),purpose:h.enum([`production`,`evaluation`,`proposal`]).optional(),learning:V.optional(),seat:h.string().optional(),mcpPolicy:_.optional(),taskWorkspace:P.optional(),host:le.optional()});async function U(e){let t=await r(),n=t.graphRegistry(u(g(),`.tangle`,`graph-registry`)),i=await t.loadGraph(n,e.graphDigest);if(!i)throw Error(`Retained execution graph is unavailable; configuration is unknown`);let a=t.validateStoredGraph(i);if(a.digest!==e.graphDigest)throw Error(`Retained execution graph changed its identity`);return m({host:e.host?.kind===`embedded`?{kind:`embedded`}:e.host??null,mcpPolicy:_.parse(e.mcpPolicy??{}),nodes:a.nodes.map(({id:e,profile:t})=>({id:e,harness:t.harness??null,model:t.model??null,seats:t.seats??null,connections:t.connections??null}))})}function W(e){throw new n(`GRAPH_RESUME_REFUSED`,`The graph run cannot be resumed`,e,`tangle graph run --help`)}async function G(e){let t=await J(e,`input.json`),n=await J(e,`admission.json`,!0);return n&&X(t,n),t}async function K(e){return J(e,`admission.json`)}async function q(e){let t=await b(e,o.O_RDONLY|o.O_NOFOLLOW);try{(await t.stat()).isFile()||W(`The run input is not a regular file`);let e=H.parse(JSON.parse(await t.readFile(`utf8`)));return e.source!==void 0&&Q(e,e.source),e}finally{await t.close()}}async function J(e,t,r=!1){h.uuid().safeParse(e).success||W(`Use a recorded graph run ID`);try{let n=u(await S(u(g(),`.tangle`)),`runs`,e);await S(n)!==n&&W(`The run directory redirects elsewhere`);let i=await q(u(n,t)).catch(e=>{if(!(r&&e.code===`ENOENT`))throw e});return i===void 0?void 0:(i.runId!==e&&W(`The recorded run identity changed`),i)}catch(e){if(e instanceof n)throw e;return W(`The private recorded run input is missing or invalid`)}}function Y(e,t){let{host:n,...r}=e,i=e.source??t;return{...r,...i===void 0?{}:{source:i}}}function X(e,t){m(Y(e,t.source))!==m(Y(t,e.source))&&W(`The execution input disagrees with its durable admission`)}async function Z(e,t){let n=t.source??await x(t.file,`utf8`);Q(t,n);let r=H.parse({...t,source:n}),i=Y(r),a=JSON.stringify(i),o=u(e,`admission.json`);try{return await w(o,a,{flag:`wx`,mode:384,flush:!0}),r}catch(e){if(e.code!==`EEXIST`)throw e;let t=await q(o);return X({...r,startedAt:t.startedAt},t),{...Y(t),...r.host===void 0?{}:{host:r.host}}}}async function Ce(e,t){let n=t.source??await x(t.file,`utf8`);Q(t,n);let r=u(e,`input.json`),i=`${r}.${f()}`;await w(i,JSON.stringify({...t,source:n}),{flag:`wx`,mode:384,flush:!0});try{await oe(i,r)}finally{await C(i,{force:!0})}}function Q(e,t){return re(`sha256`).update(t).digest(`hex`)!==e.sourceDigest&&W(`The retained graph source does not match this run`),t}async function we(e){return Q(e,e.source??await x(e.file,`utf8`))}function Te(e,t,n,r,i={}){e.sourceDigest!==n&&W(`The authored graph source changed`),t.cloud&&W(`A local run cannot move to cloud execution`),Object.entries(r).some(([t,n])=>!Object.hasOwn(e.params,t)||m(n)!==m(e.params[t]))&&W(`A recorded graph parameter changed`),Object.entries(i).some(([t,n])=>e.gateChoices?.[t]!==n)&&W(`A recorded gate choice changed`),t.seat!==void 0&&t.seat!==e.seat&&W(`The recorded graph seat override changed`),t.mcpPolicy!==void 0&&(e.mcpPolicy===void 0||m(t.mcpPolicy)!==m(e.mcpPolicy))&&W(`The recorded graph MCP policy changed`)}const Ee=e=>({...e.params,...Object.fromEntries(Object.entries(e.gateChoices??{}).map(([e,t])=>[`gate.${e}`,t]))}),$=e=>Object.entries(e).map(([e,t])=>`${e}=${typeof t==`string`?t:JSON.stringify(t)}`);export{me as A,_e as C,pe as D,E,se as O,he as S,de as T,ve as _,U as a,_ as b,Se as c,we as d,Z as f,P as g,F as h,W as i,fe as j,T as k,K as l,be as m,V as n,z as o,Ce as p,$ as r,Ee as s,Te as t,G as u,xe as v,ue as w,ge as x,D as y};
|