@tangle-network/sandbox-cli 0.23.136 → 0.23.137
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/SKILL.md +1 -0
- package/dist/graph-KZkapIfX.mjs +29 -0
- package/dist/{graph-learning-UUZAlGAw.mjs → graph-learning-B0-0ikO9.mjs} +1 -1
- package/dist/{graph-operating-evidence-E8Z7cefD.mjs → graph-operating-evidence-De3zyZzs.mjs} +1 -1
- package/dist/{graph-profile-learning-DNUh5er7.mjs → graph-profile-learning-BweZyC2r.mjs} +1 -1
- package/dist/index.mjs +2 -2
- package/hub-reference.md +2 -0
- package/package.json +7 -7
- package/dist/graph-x45OtpHj.mjs +0 -28
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,p as c,r as l,s as u,t as d,u as f}from"./output-BRdLZpee.mjs";import{i as p,n as m,r as h,t as g}from"./credential-store-D4y6Kuec.mjs";import{createRequire as ee}from"node:module";import*as _ from"node:fs";import{chmodSync as v,existsSync as y,lstatSync as te,mkdirSync as b,readFileSync as x,realpathSync as ne,renameSync as re,writeFileSync as S}from"node:fs";import{ALL_BACKEND_TYPES as ie,AuthError as C,InteractiveSessionNotRunningError as ae,NetworkError as w,NotFoundError as oe,PublicTemplatePublishError as se,QuotaError as ce,SANDBOX_RUNTIMES as le,Sandbox as ue,SandboxError as de,ServerError as fe,StateError as pe,TimeoutError as me,ValidationError as he,createAgentRunOutcomeTracker as ge,createConfidentialSandbox as _e,generateAttestationNonce as ve,parseBackendType as ye,parseSSEStream as be,validateBatchRunRequest as xe}from"@tangle-network/sandbox";import T from"chalk";import*as Se from"node:path";import{basename as Ce,dirname as we,extname as Te,join as E,resolve as Ee,sep as De,win32 as Oe}from"node:path";import{Command as D,Option as ke}from"commander";import{createHash as Ae,randomBytes as je,randomUUID as Me}from"node:crypto";import{setTimeout as Ne}from"node:timers/promises";import{ProxySecretsSchema as Pe,REASONING_EFFORTS as Fe,agentInteractiveSessionRunRef as Ie,agentProfileSchema as Le,canonicalAgentProfileDigest as Re,modelProvider as ze}from"@tangle-network/agent-interface";import{z as O}from"zod";import{shellQuote as Be}from"@tangle-network/sdk-cli-runner";import*as Ve from"node:os";import{homedir as He,tmpdir as Ue}from"node:os";import{execFileSync as We,spawn as Ge}from"node:child_process";import{HubClient as Ke,resolveConnectionReferenceFrom as qe,resolveConnectionReferenceFrom as Je}from"@tangle-network/hub-sdk";import{createInterface as Ye}from"node:readline";import{Writable as Xe}from"node:stream";import{buffer as Ze}from"node:stream/consumers";import{CONTENT_COMPLETION_KEY as Qe,CONTENT_PROMPT_KEY as $e,CONTENT_TOOL_ARGS_KEY as et,CONTENT_TOOL_NAME_KEY as tt,CONTENT_TOOL_RESULT_KEY as nt,TANGLE_SUBJECT_KEY as rt,asContentField as k,asContentString as it}from"@tangle-network/agent-core/telemetry";import{open as at,readFile as ot}from"node:fs/promises";import{ensureAgentPreview as st,publishAgentPreview as ct,resolveSelfSandbox as lt}from"@tangle-network/sandbox/preview";import{fileURLToPath as ut}from"node:url";import{createIntelligenceClient as dt}from"@tangle-network/sandbox/intelligence";var A=class extends Error{constructor(e,t,n,r,i){super(t),this.code=e,this.cause=n,this.fix=r,this.alternatives=i,this.name=`ActionableCliError`}};const ft=new Set([`AUTH_EXPIRED`,`CREDENTIAL_ADDRESS_MISMATCH`,`SANDBOX_CREDENTIAL_REFUSED`,`AUTH_WRONG_AUDIENCE`,`SEAT_NONE_DETECTED`,`SEAT_NOT_LOGGED_IN`,`SEAT_NOT_ENROLLED`,`HUB_NOT_CONNECTED`,`HUB_RECONNECT`,`HUB_APP_NOT_INSTALLED`,`HUB_APPROVAL_REQUIRED`]),pt=new Set([`GRAPH_INVALID`,`STEP_REF`,`PROFILE_INVALID`,`UNKNOWN_HARNESS`,`HUB_TOOL_UNKNOWN`,`TRIGGER_INVALID`,`WORKFLOW_INPUT_FILE_INVALID`,`VALIDATION_ERROR`]),mt=new Set([`UNKNOWN_COMMAND`,`GRAPH_PARAM_MISSING`,`GRAPH_PARAM_UNKNOWN`,`SEAT_SYNTAX`,`HUB_PROVIDER_UNKNOWN`,`USAGE_INVALID`]),ht=new Set([`SUBSCRIPTION_REQUIRED`,`MODEL_NOT_FOUND`,`MODEL_PROVIDER_MISMATCH`,`MCP_BLOCKED`,`CLOUD_SEAT_UNSUPPORTED`,`SCHEDULE_AUTHORITY`]);function j(e){return typeof e==`object`&&e?e:{}}function M(e){return typeof e==`string`&&e.length>0?e:void 0}function gt(e){let t=M(e);return t&&/^[a-z0-9][a-z0-9_-]*$/i.test(t)?t:void 0}function _t(e){let t,n=e;for(let e=0;n instanceof Error&&e<5;e++,n=n.cause){let e=n.message||(n instanceof AggregateError?n.errors.map(e=>e instanceof Error?e.message:String(e)).join(`; `):``),r=M(j(n).code);(e||r)&&(t=r?`${r}${e?`: ${e}`:``}`:e)}return t}function vt(e){return e.code===`credential-refused`&&e.owner===`caller`&&e.providerCode===`subscription_required`?j(e.remediation):{}}function yt(e){let t=j(e),n=Array.isArray(t.runtimeFailures)?t.runtimeFailures.map(j):[],r=n.find(e=>M(vt(j(e.failure)).fix))??n[0],i=j(r?.failure??t.runtimeFailure),a=vt(i),o=j(t.details),s=gt(t.provider??o.provider??o.providerId),c=j(e instanceof A?{alternatives:e.alternatives}:t.fix??o.fix),l=M(t.code)??`CLI_ERROR`,u=M(t.message)??String(e),d=M(i.cause)??M(t.cause)??M(o.reason)??u,f=`tangle --help`,p=typeof o.providerRetryable==`boolean`?o.providerRetryable:typeof t.retryable==`boolean`?t.retryable:null;if(e instanceof C||l===`HUB_UNAUTHENTICATED`||t.status===401)l=`AUTH_EXPIRED`,u=`Authentication failed`,f=`tangle auth login`;else if(t.status===403&&u.startsWith(`Sandbox runtime creden`))l=`SANDBOX_CREDENTIAL_REFUSED`,u=`This sandbox's own TANGLE_API_KEY may call Hub endpoints only`,f=`export TANGLE_API_KEY=<owner or workspace sk-tan- key> (or pass --api-key), or run outside the sandbox`;else if([`HUB_CONNECTION_MISSING`,`HUB_CONNECTION_REVOKED`,`HUB_CONNECTION_UNHEALTHY`,`HUB_RECONNECT_REQUIRED`,`CONNECTION_REQUIRED`].includes(l))l=[`HUB_CONNECTION_MISSING`,`CONNECTION_REQUIRED`].includes(l)?`HUB_NOT_CONNECTED`:`HUB_RECONNECT`,f=s?`tangle hub connect ${s}`:`tangle hub connections --json`;else if(l===`HUB_APPROVAL_REQUIRED`){let e=gt(j(o.approval).id);f=e?`tangle hub approvals approve ${e}`:`tangle hub approvals list --json`}else l===`HUB_PROVIDER_REJECTED`?(f=`tangle hub status --json`,o.providerRetryable===!1&&(d+=`. Change the request before retrying`)):l===`provider_quota_exhausted`||l===`SEAT_LIMIT`?(l=`SEAT_LIMIT`,f=`tangle auth status`,p=!0):e instanceof ce?f=`tangle usage --json`:e instanceof w?(l=`NETWORK_UNAVAILABLE`,u=`Network error: ${u}`,d=_t(e.cause)??`No response arrived`,f=`tangle auth status --json`):e instanceof me?(l=`TIMEOUT`,f=`tangle sandbox list --json`):e instanceof he?(l=`VALIDATION_ERROR`,u=`Invalid input`):e instanceof oe||e instanceof pe?f=`tangle sandbox list --json`:l===`commander.unknownCommand`?(l=`UNKNOWN_COMMAND`,f=u.includes(`'graph'`)?`npm install -g @tangle-network/sandbox-cli@latest`:`tangle --help`):l.startsWith(`commander.`)?l=`USAGE_INVALID`:(l===`ENOENT`||l===`EACCES`)&&(l=`INPUT_UNAVAILABLE`);e instanceof A&&(f=e.fix,p=!1),M(a.fix)&&(l=a.cause===`not_authenticated`?`SEAT_NOT_LOGGED_IN`:`SUBSCRIPTION_REQUIRED`),e instanceof se&&f===`tangle --help`&&(f=`tangle template publish --help`),f=M(a.fix)??M(c.command)??(l===`HUB_NOT_CONNECTED`?void 0:M(t.fixCommand))??f,ft.has(l)&&f===`tangle --help`&&(f=`tangle auth login`);let m=j(t.subject??o.subject??{node:r?.node??t.node,seat:t.seat??a.harness}),h=e instanceof w||e instanceof Error&&`batchCustody`in e?t.batchCustody:void 0;h&&(d=`Batch acceptance: ${h.acceptance}; retirement receipt ${h.cleanup?.mode===`release`&&h.cleanup.isComplete?`proved`:`unproved`}.`,p=!1,f=`tangle batch run --help`);let g=M(t.resumeAt??o.resumeAt??o.resetAt);return{code:l,...h?{batchCustody:h}:{},catalogCode:M(t.catalogCode),message:M(t.nextStep)&&M(t.message),nextStep:M(t.nextStep),subject:{...M(m.node)?{node:String(m.node)}:{},...M(m.seat)?{seat:String(m.seat)}:{}},what:u,cause:d,fix:{command:f,...Array.isArray(c.alternatives)&&c.alternatives.every(e=>typeof e==`string`)?{alternatives:c.alternatives}:{},...c.edit===void 0?{}:{edit:c.edit},...M(c.url)?{url:String(c.url)}:{}},retryable:p,...g&&Number.isFinite(Date.parse(g))?{resumeAt:g}:{},...M(t.runId)?{runId:String(t.runId)}:{},...M(t.requestId)?{requestId:String(t.requestId)}:{},...typeof t.status==`number`?{status:t.status}:{},...M(i.code)&&M(i.owner)?{runtimeFailure:{code:String(i.code),owner:String(i.owner),cause:typeof i.cause==`string`?i.cause:d,...M(i.providerCode)?{providerCode:String(i.providerCode)}:{},...typeof i.providerStatus==`number`?{providerStatus:i.providerStatus}:{},...typeof i.retryAfterMs==`number`?{retryAfterMs:i.retryAfterMs}:{},...Object.keys(a).length?{remediation:a}:{}}}:{},...e instanceof se&&e.job?{job:e.job}:{}}}function bt(e){let t=[e.subject.node&&`node ${e.subject.node}`,e.subject.seat].filter(Boolean).join(` · `);return`✗ ${`${t?`${t}: `:``}${e.what}${e.status?` (HTTP ${e.status})`:``}`}${e.cause===e.what?``:` — ${e.cause}`}${e.nextStep?`\n → next: ${e.nextStep}`:``}\n → run: ${e.fix.command}`+(e.runtimeFailure?`\n runtime: ${e.runtimeFailure.code} · ${e.runtimeFailure.owner}${e.runtimeFailure.providerCode?` · ${e.runtimeFailure.providerCode}`:``}${e.runtimeFailure.providerStatus===void 0?``:` · HTTP ${e.runtimeFailure.providerStatus}`}${e.runtimeFailure.retryAfterMs===void 0?``:` · retry-after ${e.runtimeFailure.retryAfterMs} ms`}`:``)+(e.fix.alternatives?.map(e=>`\n or: ${e}`).join(``)??``)+(e.resumeAt?`\n resumes ${e.resumeAt}${e.subject.seat?` on ${e.subject.seat}`:``}`:``)}function xt(e){return bt(yt(e))}function N(t,r=!1){n();let i=yt(t);r?e({ok:!1,error:i}):console.error(T.red(bt(i)));let a=1;ft.has(i.code)?a=77:pt.has(i.code)?a=65:mt.has(i.code)?a=64:ht.has(i.code)?a=78:[`SEAT_LIMIT`,`RATE_LIMITED`].includes(i.code)?a=75:[`HARNESS_NOT_INSTALLED`,`MCP_UNREACHABLE`,`NETWORK_UNAVAILABLE`].includes(i.code)?a=69:i.code===`RUN_STOPPED`&&(a=130),process.exit(a)}const St={OPENCODE:`opencode`,CLAUDE_CODE:`claude-code`,KIMI_CODE:`kimi-code`,CODEX:`codex`,AMP:`amp`,FACTORY_DROIDS:`factory-droids`,PI:`pi`,PRIME:`prime`,HERMES:`hermes`,OPENCLAW:`openclaw`,NANOCLAW:`nanoclaw`,NANOCODE:`nanocode`,EXO:`exo`,ACP:`acp`,CURSOR:`cursor`,GROK:`grok`,CLI_BASE:`cli-base`},Ct=Object.values(St);O.enum(Ct);const wt=new Set([St.OPENCODE,St.CLAUDE_CODE,St.KIMI_CODE,St.CODEX,St.PI,St.HERMES]);O.string().regex(/^[A-Za-z0-9_.:@-]{1,256}$/);const Tt=new Set(Ct);function Et(e){return Tt.has(e)}function Dt(e){if(e.startsWith(`github:`)){let[t,n]=e.slice(7).split(`@`,2),r=t.split(`/`).filter(Boolean);if(r.length<3)throw Error(`invalid github ref "${e}": expected github:<owner>/<repo>/<path>[@<ref>]`);let i=`${r[0]}/${r[1]}`,a=r.slice(2).join(`/`);return{kind:`github`,repository:i,path:a,...n?{ref:n}:{},name:Ce(a)}}let t;try{t=x(e,`utf8`)}catch{throw Error(`cannot read skill/tool "${e}": not a readable file and not a github: ref`)}return{kind:`inline`,name:Ce(e),content:t}}function Ot(e){let t=(e.skills??[]).map(Dt),n=(e.tools??[]).map(Dt),r=t.length>0||n.length>0;if(!(!e.model&&!e.systemPrompt&&!r))return{...e.model?{model:{default:e.model}}:{},...e.systemPrompt?{prompt:{systemPrompt:e.systemPrompt}}:{},...r?{resources:{...t.length>0?{skills:t}:{},...n.length>0?{tools:n}:{}}}:{}}}async function kt(e){let t;if(e.startsWith(`github:`)){let[n,r]=e.slice(7).split(`@`,2),i=n.split(`/`).filter(Boolean);if(i.length<3)throw Error(`invalid --profile github ref "${e}": expected github:<owner>/<repo>/<path>[@<ref>]`);let a=r??`main`;t=await jt(`https://raw.githubusercontent.com/${i[0]}/${i[1]}/${a}/${i.slice(2).join(`/`)}`)}else t=/^https?:\/\//.test(e)?await jt(e):x(e,`utf8`);let n;try{n=JSON.parse(t)}catch{throw new A(`PROFILE_INVALID`,`Profile '${e}' is invalid`,`Expected a JSON AgentProfile`,`tangle agent profile create --name my-agent --json`)}return At(n,e)}function At(e,t){let n=Le.safeParse(e);if(!n.success)throw new A(`PROFILE_INVALID`,`Profile '${t}' is invalid`,n.error.issues.map(e=>`${e.path.join(`.`)||`(root)`}: ${e.message}`).join(`; `),`tangle agent profile create --name my-agent --json`);return e}async function jt(e){let t=await fetch(e);if(!t.ok)throw Error(`failed to fetch ${e} (${t.status})`);return t.text()}async function Mt(e){let t=e.profileSource?await kt(e.profileSource):void 0,n=Ot(e);return t?n?{...t,...n,...n.resources?{resources:{...t.resources,...n.resources}}:{}}:t:n}const Nt=Se.join(Ve.homedir(),`.tangle`),Pt=Se.join(Nt,`config.json`),Ft=`https://id.tangle.tools`,It=`https://solve.tangle.tools/api/solve`,Lt=`default`;function Rt(){return{tangleBaseUrl:process.env.TANGLE_BASE_URL,sandboxBaseUrl:process.env.SANDBOX_BASE_URL,hubUrl:process.env.TANGLE_HUB_URL}}function zt(e,t){let n=F(t??(e===`solve`?`solve`:void 0));if(e===`solve`){if(n!==`solve`)throw Error(`The solve app cannot use profile '${n}'. Use the reserved 'solve' profile.`);return n}if(e===`sandbox`&&!t&&n===`solve`)return Lt;if(new Set([`solve`]).has(n))throw Error(`The ${e} app cannot use the reserved '${n}' profile. Use the '${e}' profile or choose a custom profile.`);return n}function Bt(){_.existsSync(Nt)||_.mkdirSync(Nt,{mode:448,recursive:!0})}function Vt(e,t){Bt();let n=`${e}.${process.pid}.tmp`;_.writeFileSync(n,t,{mode:384}),_.renameSync(n,e)}function Ht(e){return e.startsWith(`sk_`)||e.startsWith(`sk-tan-`)}function P(){try{if(_.existsSync(Pt))return JSON.parse(_.readFileSync(Pt,`utf-8`))}catch{}return{}}function Ut(e){let t=Sn(P(),e);Vt(Pt,`${JSON.stringify(t,null,2)}\n`)}function F(e){return Cn(e||process.env.TANGLE_PROFILE||process.env.SANDBOX_PROFILE||P().activeProfile||Lt)}function Wt(e){Ut({activeProfile:Cn(e)})}function Gt(){return{token:process.env.TANGLE_LINE_TOKEN,baseUrl:process.env.TANGLE_HUB_URL}}function Kt(){return process.env.TANGLE_SANDBOX||P().currentSandbox||void 0}function qt(e){Ut({currentSandbox:e})}function Jt(){let e=P();delete e.currentSandbox,Vt(Pt,`${JSON.stringify(e,null,2)}\n`)}function Yt(){let e=P().deviceId;if(e&&/^[A-Za-z0-9_.-]{1,64}$/.test(e))return e;let t=Ve.hostname().replace(/[^A-Za-z0-9_.-]/g,`-`).replace(/^-+|-+$/g,``).slice(0,32),n=je(4).toString(`hex`),r=`${t?`${t}-`:`device-`}${n}`;return Ut({deviceId:r}),r}function Xt(){let e=P(),t=F(),n=new Set([Lt,...Object.keys(e.profiles??{})]);return e.activeProfile&&n.add(Cn(e.activeProfile)),[...n].map(e=>{let n=h(e).source;return{name:e,active:e===t,hasApiKey:n!==`none`,baseUrl:ln(void 0,e),apiKeySource:n}}).sort((e,t)=>e.name.localeCompare(t.name))}function Zt(e){let t=F(e);return{name:t,active:t===F(),baseUrl:ln(void 0,t),credentialSource:h(t).source}}function Qt(e,t){let n=Cn(e),r=P(),i=xn(n,r),a={},o=t.baseUrl??i.baseUrl;o&&(a.baseUrl=o);let s=t.platformUrl===void 0?i.platformUrl:t.platformUrl;s&&(a.platformUrl=s);let c=t.activeTeamId??i.activeTeamId;c&&(a.activeTeamId=c);let l=t.activeTeamName??i.activeTeamName;l&&(a.activeTeamName=l);let u={...r.profiles??{}};a.baseUrl||a.platformUrl||a.activeTeamId||a.activeTeamName?u[n]=a:delete u[n];let d;return t.apiKey&&(d=p(n,t.apiKey)),Ut({profiles:Object.keys(u).length>0?u:{}}),d}function $t(e){let t=F(e),n={...P().profiles??{}},r=n[t];if(r){let e={...r};e.baseUrl||e.platformUrl||e.activeTeamId||e.activeTeamName?n[t]=e:delete n[t]}Ut({profiles:n}),m(t)}function en(){let e=process.env.TANGLE_API_KEY_FILE;if(e){let t=_.readFileSync(e,`utf8`).trim();if(!t.startsWith(`sk-tan-`))throw Error(`Invalid sandbox credential file`);return t}return process.env.TANGLE_API_KEY}const tn={intelligence:`https://intelligence.tangle.tools`,router:`https://router.tangle.tools/v1`};function nn(e,t,n){return rn(`sandbox`,ln(n,t),e,t)}function rn(e,t,n,r){if(n)return n;let i=en();if(i)return i;let a=h(zt(`sandbox`,r)).value;return a&&t!==void 0&&an(e,t,r),a}function an(e,t,n){let r=e===`sandbox`?dn(n):e===`platform`?mn(n)??Ft:tn[e],i=e=>{try{let t=new URL(e.trim()).origin;return t===`null`?void 0:t}catch{return}},a=t=>e===`sandbox`?t.trim().replace(/\/+$/,``).toLowerCase():i(t),o=a(t);if(o!==void 0&&o===a(r))return;let s={sandbox:`unset ${process.env.SANDBOX_BASE_URL&&!process.env.TANGLE_BASE_URL?`SANDBOX_BASE_URL`:`TANGLE_BASE_URL`} or drop --base-url`,platform:`unset TANGLE_PLATFORM_URL and TANGLE_HUB_URL, or drop --base-url and --platform-url`,intelligence:`unset TANGLE_INTELLIGENCE_BASE_URL, or drop --base-url and --endpoint`,router:`unset TANGLE_ROUTER_URL`}[e],c={sandbox:`if you run your own install at ${t}: tangle auth login --base-url ${t}`,platform:`if you run your own install at ${t}: TANGLE_PLATFORM_URL=${t} tangle auth login`,intelligence:`pass the key for ${t} with --api-key or TANGLE_API_KEY`,router:`pass the key for ${t} with --api-key or TANGLE_API_KEY`}[e];throw new A(`CREDENTIAL_ADDRESS_MISMATCH`,`The stored credential is for ${r}, not ${t}, so it was not sent`,`a flag or the environment named that address`,s,[c])}function on(e,t){return e||(process.env.TANGLE_SOLVE_API_KEY?process.env.TANGLE_SOLVE_API_KEY:h(zt(`solve`,t)).value)}function sn(e,t){let n=zt(`sandbox`,t);return e?`flag`:process.env.TANGLE_API_KEY_FILE||process.env.TANGLE_API_KEY?`env`:h(n).source}function cn(e,t){return e?`flag`:process.env.TANGLE_SOLVE_API_KEY?`env`:h(zt(`solve`,t)).source}function ln(e,t){return un(e)||dn(t)}function un(e){return e||process.env.TANGLE_BASE_URL||process.env.SANDBOX_BASE_URL||void 0}function dn(e){let t=F(e),n=P(),r=xn(t,n);return r.baseUrl?r.baseUrl:(t===Lt||t===`sandbox`)&&n.baseUrl?n.baseUrl:`https://sandbox.tangle.tools`}function fn(e){if(e)return e.replace(/\/v1\/hub\/?$/,``)}function I(e){return e?.trim().replace(/\/+$/,``)||void 0}function pn(e){return I(e?.flag)??hn()??I(e?.cachedPlatformUrl?.())??I(mn(e?.profile))??Ft}function mn(e){return xn(F(e),P()).platformUrl}function hn(){return I(fn(I(process.env.TANGLE_HUB_URL)))??I(process.env.TANGLE_PLATFORM_URL)}function gn(e){let t=I(e)??I(process.env.TANGLE_SOLVE_API_URL);if(t&&t!==It)throw Error(`Solve credentials may only be sent to ${It}`);return It}function _n(e){let t=I(e);if(t&&t!==Ft)throw Error(`Solve credentials may only be sent to ${Ft}`);return Ft}function L(e){let t=zt(`sandbox`,e.profile),n=nn(e.apiKey,t,e.baseUrl);if(!n)throw Error(`No API key found for profile '${t}'. Set TANGLE_API_KEY or run: tangle auth login${t===Lt?``:` --profile ${t}`}`);return{apiKey:n,baseUrl:ln(e.baseUrl,t),timeout:e.timeout??3e4,profile:t,...vn(t)}}function vn(e){let t=P(),n=xn(F(e),t);return{activeTeamId:n.activeTeamId,activeTeamName:n.activeTeamName}}function yn(e,t){Qt(F(t),{activeTeamId:e.id,activeTeamName:e.name})}function bn(e){let t=F(e),n=P(),r={...n.profiles??{}},i=xn(t,n),a={baseUrl:i.baseUrl,platformUrl:i.platformUrl};a.baseUrl||a.platformUrl?r[t]=a:delete r[t],Ut({profiles:r})}function xn(e,t=P()){let n=Cn(e);return{...n===Lt?{baseUrl:t.baseUrl,activeTeamId:t.profiles?.[Lt]?.activeTeamId,activeTeamName:t.profiles?.[Lt]?.activeTeamName}:{},...t.profiles?.[n]??{}}}function Sn(e,t){let n=t.profiles===void 0?{...e.profiles??{}}:Object.fromEntries(Object.entries(t.profiles).filter(([,e])=>!!(e.apiKey||e.baseUrl||e.platformUrl||e.activeTeamId||e.activeTeamName)));return{...e,...t,profiles:Object.keys(n).length>0?n:void 0}}function Cn(e){let t=e.trim().toLowerCase();if(!t)throw Error(`Profile name cannot be empty`);if(!/^[a-z0-9][a-z0-9._-]*$/.test(t))throw Error(`Profile names may only contain lowercase letters, numbers, dots, underscores, and hyphens`);return t}let wn=null,Tn=null;function R(e){if(!e&&wn)return wn;let t=e??L({});return(!wn||!Tn||Tn.apiKey!==t.apiKey||Tn.baseUrl!==t.baseUrl||Tn.timeout!==t.timeout)&&(wn=new ue({apiKey:t.apiKey,baseUrl:t.baseUrl,timeoutMs:t.timeout}),Tn=t),wn}function En(){wn=null,Tn=null}function z(e){let t=L({apiKey:e.apiKey,baseUrl:e.baseUrl});return{context:t,client:R(t)}}async function Dn(e,t){let n=t.trim();if(n.length===0)throw Error(`Connection reference is empty.`);if(n.startsWith(`hubconn_`))return n;let{connections:r}=await e.connections.list();return qe(r,n)}function On(e,t){return[...t,e]}async function kn(e,t){let n=e.map(e=>{let t=e.trim(),n=t.indexOf(`:`);return n===-1?{raw:e,ref:null,tail:null}:{raw:e,ref:t.slice(0,n).trim(),tail:t.slice(n+1)}});if(!n.some(e=>e.ref!==null&&e.ref!==`*`&&!e.ref.startsWith(`hubconn_`)))return[...e];let{connections:r}=await(await t()).connections.list();return n.map(e=>e.ref===null||e.ref===`*`||e.ref.startsWith(`hubconn_`)?e.raw:`${Je(r,e.ref)}:${e.tail}`)}function An(e){let t=new Map,n=[];for(let r of e){let e=r.trim(),i=e.indexOf(`:`);if(i===-1)throw Error(`Invalid --connection "${r}": expected <connectionId>:<capability>[,<capability>]. List connection ids with \`tangle hub connections\` and capability paths with \`tangle hub tools search <keyword>\`.`);let a=e.slice(0,i).trim();if(a.length===0)throw Error(`Invalid --connection "${r}": connection id is empty. Use <connectionId>:<capability> — list ids with \`tangle hub connections\`.`);let o=e.slice(i+1).split(`,`).map(e=>e.trim()).filter(e=>e.length>0);if(o.length===0)throw Error(`Invalid --connection "${r}": grant at least one capability, e.g. ${a}:gmail.messages.list. Discover paths with \`tangle hub tools search <keyword>\`.`);if(o.includes(`*`)&&o.length>1)throw Error(`Invalid --connection "${r}": "*" grants all capabilities and can't be combined with specific paths. Use <connectionId>:* alone, or list explicit paths.`);if(a===`*`&&!(o.length===1&&o[0]===`*`))throw Error(`Invalid --connection "${r}": a "*" connection is only valid as "*:*" (all connections, all capabilities). Name a connection id for specific paths.`);let s=t.get(a);s===void 0&&(s=new Set,t.set(a,s),n.push(a));for(let e of o)s.add(e)}return n.map(e=>{let n=t.get(e),r=n?[...n]:[];if(r.includes(`*`)&&r.length>1)throw Error(`Invalid --connection for "${e}": "*" can't be combined with specific capability paths across repeated --connection flags.`);return{connectionId:e,capabilities:r}})}const jn=15e3,Mn=RegExp(`\x1BP[^\x1B]*\x1B\\\\|\x1B\\][^\\u0007\x1B]*(?:\\u0007|\x1B\\\\)|\x1B\\[[?>][\\d;]*c|\x1B\\[\\d+;\\d+R|\x1B\\[\\d+(?:;\\d+)*t`,`g`),Nn=e=>e.replace(Mn,``)===``?e.match(Mn)?.length??0:0,Pn=RegExp(`\x1B\\[>0?q|\x1B\\[[>=]?0?c|\x1B\\[6n|\x1B\\]1\\d;\\?`,`g`);async function Fn(e,t){let n=process.stdin,r=process.stdout,i=null,a=!1,o=!1,s=!1,c=!1,u,d=!1,f=0,p,m,h=0,g,ee=new Promise(e=>{g=e}),_=()=>{try{n.setRawMode(!1)}catch{}n.pause()},v=()=>{a||(a=!0,clearTimeout(p),clearTimeout(m),clearTimeout(w),_(),n.off(`data`,se),process.off(`SIGWINCH`,te),process.off(`SIGINT`,y),process.off(`SIGTERM`,y),process.off(`exit`,_),g())},y=e=>{c=!0,Promise.resolve(i?.close()).finally(()=>{v(),process.exit(e===`SIGTERM`?143:130)})},te=()=>{i?.isOpen&&!s&&i.resize(r.columns||80,r.rows||24)},b=[],x=e=>{if(e.length!==0){try{if(!s&&i?.isOpen)return i.write(e)}catch{}b.push(e),S()}},ne=()=>{clearTimeout(p);let e=i?.authorityLifetimeMs;e!==void 0&&(p=setTimeout(()=>void S(),Math.max(jn,e*.8)))},re=async e=>{for(let t=1;;t++)try{return await e.reconnect({cols:r.columns||80,rows:r.rows||24})}catch(e){if(t>=3||e instanceof ae)throw e;await new Promise(e=>setTimeout(e,500*2**t))}},S=async()=>{let e=i;if(!(s||a||o||!e)){s=!0,clearTimeout(p);try{await e.close(),i=await re(e);for(let e of b.splice(0))i.write(e)}catch(t){a||(u=t instanceof ae?`the session ended`:`could not reattach: ${t.message}`),s=!1,i!==e&&await i?.close(),v();return}if(s=!1,a){await i.close();return}te(),ne()}},ie=()=>{clearTimeout(m),!a&&(m=setTimeout(()=>{d=!0,c=!0,u=`no agent output or input for ${t} ms (--timeout); the session keeps running`,Promise.resolve(i?.close()).finally(v)},t))},C=0,w,oe=e=>{let t=Buffer.from(e).toString(`latin1`).match(Pn);t&&(C+=t.length,clearTimeout(w),w=setTimeout(()=>{C=0},2e3))},se=e=>{if(!i)return;let t=Nn(e.toString(`latin1`));if(t>0){C>0?C=Math.max(0,C-t):x(e);return}ie();let n=e.indexOf(29);if(n===-1){x(e);return}x(e.subarray(0,n)),c=!0,i.close().finally(v)},ce=e=>r.write(Buffer.from(e.buffer,e.byteOffset,e.byteLength));if(i=await e.attach({cols:r.columns||80,rows:r.rows||24,handlers:{onReady:e=>{i===null&&(h=Math.max(h,e.cursors?.latest??0))},onOutput:(e,t)=>{if(ce(t),e<=h)return oe(t);h=e,ie()},onData:e=>{ce(e),ie()},onExit:e=>{o=!0;let t=e.exitCode===void 0?``:` (code ${e.exitCode})`;r.write(`\r\n[interactive session exited${t}]\r\n`),i?.close().finally(v)},onError:e=>{r.write(`\r\n[terminal stream error: ${e.message}]\r\n`)},onClose:()=>{if(s||a)return;let e=Date.now();c||o?v():e-f<jn?(u=`the connection keeps closing`,v()):(f=e,S())}}}),ne(),ie(),n.setRawMode(!0),n.resume(),n.on(`data`,se),process.on(`SIGWINCH`,te),process.on(`SIGINT`,y),process.on(`SIGTERM`,y),process.on(`exit`,_),await ee,console.log(),o){l(`Interactive session ended.`);return}l(`Detached — ${u??`the session keeps running`}.`),d&&(process.exitCode=1)}function In(e){throw new A(`USAGE_INVALID`,e,e,`tangle --help`)}function B(e,t){let n=/^\d+$/.test(e.trim())?Number(e):NaN;return(!Number.isSafeInteger(n)||n<=0)&&In(`${t} must be a positive integer`),n}const Ln={ms:1,s:1e3,m:6e4,h:36e5};function V(e,t,n=`s`,r=1){let i=/^(\d+)(ms|s|m|h)?$/.exec(e.trim()),a=i?Number(i[1]):-1,o=i?.[2],s=o?a*Ln[o]:0,c=o?n===`ms`?s:s/1e3:a;return(!Number.isSafeInteger(c)||c<r)&&In(`${t} must be ${r?`a positive`:`0 or a`} number of ${n===`ms`?`milliseconds`:`seconds`} or a duration like 60m`),c}function Rn(e){if(e<60||e%60)return`${e} s`;let t=e/60;if(t<60)return`${t} min`;let n=t%60;return`${Math.floor(t/60)} h${n?` ${n} min`:``}`}function zn(e,t){return Ae(`sha256`).update(`${e}\0${t}`).digest(`hex`).slice(0,32)}function Bn(e){return`${e}:hub`}function Vn(e){let{value:t}=h(Bn(e));if(!t)return null;try{let e=JSON.parse(t);if(typeof e.key==`string`&&typeof e.expiresAt==`string`&&typeof e.platformUrl==`string`&&typeof e.sessionFingerprint==`string`)return{key:e.key,expiresAt:e.expiresAt,platformUrl:e.platformUrl,sessionFingerprint:e.sessionFingerprint}}catch{}return null}function Hn(e,t){try{p(Bn(e),JSON.stringify(t))}catch{}}async function Un(e,t,n,r){let i=`${e.replace(/\/+$/,``)}/auth/cli/hub-key`,a;try{a=await fetch(i,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${t}`},body:JSON.stringify({device_id:n}),signal:r})}catch(e){throw Error(`Could not reach ${i} to mint a platform key: ${e instanceof Error?e.message:String(e)}`)}let o=await a.text(),s;try{s=JSON.parse(o)}catch{s=null}if(!a.ok||!s?.success){let e=typeof s?.error?.message==`string`?s.error.message:`HTTP ${a.status}`;throw Error(`Platform key minting failed: ${e}. Your sandbox session may have expired — run \`tangle auth login\`.`)}let c=s.data;if(typeof c?.api_key!=`string`||typeof c?.expires_at!=`string`||typeof c?.platform_url!=`string`)throw Error(`Platform key minting returned an unexpected response shape.`);return{key:c.api_key,expiresAt:c.expires_at,platformUrl:c.platform_url}}var Wn=class{cache;fingerprint;constructor(e,t,n,r,i){this.profile=e,this.sandboxBaseUrl=t,this.sessionToken=n,this.deviceId=r,this.signal=i,this.fingerprint=zn(t,n);let a=Vn(e);this.cache=a&&a.sessionFingerprint===this.fingerprint?a:null}isFresh(e){return e!==null&&Date.parse(e.expiresAt)-Date.now()>6e4}async ensure(e=!1){if(this.signal?.throwIfAborted(),!e&&this.isFresh(this.cache))return this.cache;let t={...await Un(this.sandboxBaseUrl,this.sessionToken,this.deviceId,this.signal),sessionFingerprint:this.fingerprint};return this.cache=t,Hn(this.profile,t),t}};function Gn(e){if(!e)return!1;let t=e.trim().toLowerCase();return t===`1`||t===`true`||t===`yes`}function Kn(e,t){return pn({flag:e.baseUrl,profile:t,...e.useCachedPlatformUrl?{cachedPlatformUrl:()=>Vn(t)?.platformUrl}:{}})}function qn(e,t){let n=zt(`sandbox`,e.profile),r=nn(e.apiKey,n,e.sandboxBaseUrl),i=sn(e.apiKey,n),a=e.allowHubCapabilityToken&&process.env.TANGLE_HUB_CAPABILITY_TOKEN?.trim()||void 0;if(a&&i===`env`)throw Error(`Set exactly one of TANGLE_API_KEY or TANGLE_HUB_CAPABILITY_TOKEN, not both`);let o=i===`flag`&&r?r:a??r;if(!o)throw Error(`No API key found for profile '${n}'. Set TANGLE_API_KEY or run: tangle auth login${n===`default`?``:` --profile ${n}`}`);let s=o===r&&(i===`keychain`||i===`file`);if((i===`flag`||i===`env`)&&r||a||o.startsWith(`sk-tan-`)||t){let t=Kn(e,n);return s&&(e.baseUrl??hn())!==void 0&&an(`platform`,t,n),{kind:`static`,apiKey:o,baseUrl:t}}return s&&e.baseUrl&&an(`platform`,e.baseUrl,n),{kind:`managed`,profile:n,sandboxBaseUrl:ln(e.sandboxBaseUrl,n),sessionToken:o,deviceId:Yt(),baseUrlOverride:e.baseUrl}}async function Jn(e={}){let t=qn(e,e.hubKey===!1||Gn(process.env.TANGLE_SKIP_HUB_KEY));if(t.kind===`static`)return{token:t.apiKey,baseUrl:t.baseUrl,minted:!1};let n=new Wn(t.profile,t.sandboxBaseUrl,t.sessionToken,t.deviceId,e.signal),r=await n.ensure();return{token:r.key,baseUrl:t.baseUrlOverride??r.platformUrl,refresh:async()=>(await n.ensure(!0)).key,minted:!0}}async function Yn(e,t,n={}){let r=e=>{let r=new Headers(n.headers);return r.set(`Authorization`,`Bearer ${e}`),fetch(t,{...n,headers:r})},i=await r(e.token);return i.status!==401||!e.refresh?i:r(await e.refresh())}async function Xn(e={}){let t;try{t=await Jn(e)}catch(e){return{reachable:!1,reason:e instanceof Error?e.message:String(e),refused:!0}}try{let e=await Yn(t,`${t.baseUrl.replace(/\/+$/,``)}/v1/plans/current`);if(e.ok)return{reachable:!0,baseUrl:t.baseUrl};let n=e.status===401||e.status===403;return{reachable:!1,baseUrl:t.baseUrl,reason:n?`the platform refused this credential (HTTP ${e.status})`:`the platform answered HTTP ${e.status}`,refused:n}}catch(e){return{reachable:!1,baseUrl:t.baseUrl,reason:`could not reach ${t.baseUrl}: ${e instanceof Error?e.message:String(e)}`,refused:!1}}}async function Zn(e){let t=e.signal,n=t?(e,n)=>{let r=n?.signal??(e instanceof Request?e.signal:void 0);return fetch(e,{...n,signal:r?AbortSignal.any([r,t]):t})}:fetch.bind(globalThis),r=qn(e,e.hubKey===!1||Gn(process.env.TANGLE_SKIP_HUB_KEY));if(r.kind===`static`){let t=!e.apiKey&&process.env.TANGLE_API_KEY_FILE&&!process.env.TANGLE_HUB_CAPABILITY_TOKEN;return new Ke({baseUrl:r.baseUrl,fetch:n,authHeaders:()=>({Authorization:`Bearer ${t?en():r.apiKey}`})})}let i=new Wn(r.profile,r.sandboxBaseUrl,r.sessionToken,r.deviceId,e.signal),a=await i.ensure();return new Ke({baseUrl:r.baseUrlOverride??a.platformUrl,authHeaders:async()=>({Authorization:`Bearer ${(await i.ensure()).key}`}),fetch:async(e,t)=>{let r=await n(e,t);if(r.status!==401)return r;let a=await i.ensure(!0),o=new Headers(t?.headers);return o.set(`Authorization`,`Bearer ${a.key}`),n(e,{...t,headers:o})}})}function Qn(e={}){return Zn(e)}function H(e={}){return Zn({...e,useCachedPlatformUrl:!0,allowHubCapabilityToken:!0})}function $n(e,t){return`Sandbox name is ambiguous: ${e}. Use a sandbox id instead.\n${t.map(e=>`- ${e.id} (status: ${e.status}, created: ${e.createdAt.toISOString()})`).join(`
|
|
1
|
+
import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,p as c,r as l,s as u,t as d,u as f}from"./output-BRdLZpee.mjs";import{i as p,n as m,r as h,t as g}from"./credential-store-D4y6Kuec.mjs";import{createRequire as ee}from"node:module";import*as _ from"node:fs";import{chmodSync as v,existsSync as y,lstatSync as te,mkdirSync as b,readFileSync as x,realpathSync as ne,renameSync as re,writeFileSync as S}from"node:fs";import{ALL_BACKEND_TYPES as ie,AuthError as C,InteractiveSessionNotRunningError as ae,NetworkError as w,NotFoundError as oe,PublicTemplatePublishError as se,QuotaError as ce,SANDBOX_RUNTIMES as le,Sandbox as ue,SandboxError as de,ServerError as fe,StateError as pe,TimeoutError as me,ValidationError as he,createAgentRunOutcomeTracker as ge,createConfidentialSandbox as _e,generateAttestationNonce as ve,parseBackendType as ye,parseSSEStream as be,validateBatchRunRequest as xe}from"@tangle-network/sandbox";import T from"chalk";import*as Se from"node:path";import{basename as Ce,dirname as we,extname as Te,join as E,resolve as Ee,sep as De,win32 as Oe}from"node:path";import{Command as D,Option as ke}from"commander";import{createHash as Ae,randomBytes as je,randomUUID as Me}from"node:crypto";import{setTimeout as Ne}from"node:timers/promises";import{ProxySecretsSchema as Pe,REASONING_EFFORTS as Fe,agentInteractiveSessionRunRef as Ie,agentProfileSchema as Le,canonicalAgentProfileDigest as Re,modelProvider as ze}from"@tangle-network/agent-interface";import{z as O}from"zod";import{shellQuote as Be}from"@tangle-network/sdk-cli-runner";import*as Ve from"node:os";import{homedir as He,tmpdir as Ue}from"node:os";import{execFileSync as We,spawn as Ge}from"node:child_process";import{HubClient as Ke,resolveConnectionReferenceFrom as qe,resolveConnectionReferenceFrom as Je}from"@tangle-network/hub-sdk";import{createInterface as Ye}from"node:readline";import{Writable as Xe}from"node:stream";import{buffer as Ze}from"node:stream/consumers";import{CONTENT_COMPLETION_KEY as Qe,CONTENT_PROMPT_KEY as $e,CONTENT_TOOL_ARGS_KEY as et,CONTENT_TOOL_NAME_KEY as tt,CONTENT_TOOL_RESULT_KEY as nt,TANGLE_SUBJECT_KEY as rt,asContentField as k,asContentString as it}from"@tangle-network/agent-core/telemetry";import{open as at,readFile as ot}from"node:fs/promises";import{ensureAgentPreview as st,publishAgentPreview as ct,resolveSelfSandbox as lt}from"@tangle-network/sandbox/preview";import{fileURLToPath as ut}from"node:url";import{createIntelligenceClient as dt}from"@tangle-network/sandbox/intelligence";var A=class extends Error{constructor(e,t,n,r,i){super(t),this.code=e,this.cause=n,this.fix=r,this.alternatives=i,this.name=`ActionableCliError`}};const ft=new Set([`AUTH_EXPIRED`,`CREDENTIAL_ADDRESS_MISMATCH`,`SANDBOX_CREDENTIAL_REFUSED`,`AUTH_WRONG_AUDIENCE`,`SEAT_NONE_DETECTED`,`SEAT_NOT_LOGGED_IN`,`SEAT_NOT_ENROLLED`,`HUB_NOT_CONNECTED`,`HUB_RECONNECT`,`HUB_APP_NOT_INSTALLED`,`HUB_APPROVAL_REQUIRED`]),pt=new Set([`GRAPH_INVALID`,`STEP_REF`,`PROFILE_INVALID`,`UNKNOWN_HARNESS`,`HUB_TOOL_UNKNOWN`,`TRIGGER_INVALID`,`WORKFLOW_INPUT_FILE_INVALID`,`VALIDATION_ERROR`]),mt=new Set([`UNKNOWN_COMMAND`,`GRAPH_PARAM_MISSING`,`GRAPH_PARAM_UNKNOWN`,`SEAT_SYNTAX`,`HUB_PROVIDER_UNKNOWN`,`USAGE_INVALID`]),ht=new Set([`SUBSCRIPTION_REQUIRED`,`MODEL_NOT_FOUND`,`MODEL_PROVIDER_MISMATCH`,`MCP_BLOCKED`,`CLOUD_SEAT_UNSUPPORTED`,`SCHEDULE_AUTHORITY`]);function j(e){return typeof e==`object`&&e?e:{}}function M(e){return typeof e==`string`&&e.length>0?e:void 0}function gt(e){let t=M(e);return t&&/^[a-z0-9][a-z0-9_-]*$/i.test(t)?t:void 0}function _t(e){let t,n=e;for(let e=0;n instanceof Error&&e<5;e++,n=n.cause){let e=n.message||(n instanceof AggregateError?n.errors.map(e=>e instanceof Error?e.message:String(e)).join(`; `):``),r=M(j(n).code);(e||r)&&(t=r?`${r}${e?`: ${e}`:``}`:e)}return t}function vt(e){return e.code===`credential-refused`&&e.owner===`caller`&&e.providerCode===`subscription_required`?j(e.remediation):{}}function yt(e){let t=j(e),n=Array.isArray(t.runtimeFailures)?t.runtimeFailures.map(j):[],r=n.find(e=>M(vt(j(e.failure)).fix))??n[0],i=j(r?.failure??t.runtimeFailure),a=vt(i),o=j(t.details),s=gt(t.provider??o.provider??o.providerId),c=j(e instanceof A?{alternatives:e.alternatives}:t.fix??o.fix),l=M(t.code)??`CLI_ERROR`,u=M(t.message)??String(e),d=M(i.cause)??M(t.cause)??M(o.reason)??u,f=`tangle --help`,p=typeof o.providerRetryable==`boolean`?o.providerRetryable:typeof t.retryable==`boolean`?t.retryable:null;if(e instanceof C||l===`HUB_UNAUTHENTICATED`||t.status===401)l=`AUTH_EXPIRED`,u=`Authentication failed`,f=`tangle auth login`;else if(t.status===403&&u.startsWith(`Sandbox runtime creden`))l=`SANDBOX_CREDENTIAL_REFUSED`,u=`This sandbox's own TANGLE_API_KEY may call Hub endpoints only`,f=`export TANGLE_API_KEY=<owner or workspace sk-tan- key> (or pass --api-key), or run outside the sandbox`;else if([`HUB_CONNECTION_MISSING`,`HUB_CONNECTION_REVOKED`,`HUB_CONNECTION_UNHEALTHY`,`HUB_RECONNECT_REQUIRED`,`CONNECTION_REQUIRED`].includes(l))l=[`HUB_CONNECTION_MISSING`,`CONNECTION_REQUIRED`].includes(l)?`HUB_NOT_CONNECTED`:`HUB_RECONNECT`,f=s?`tangle hub connect ${s}`:`tangle hub connections --json`;else if(l===`HUB_APPROVAL_REQUIRED`){let e=gt(j(o.approval).id);f=e?`tangle hub approvals approve ${e}`:`tangle hub approvals list --json`}else l===`HUB_PROVIDER_REJECTED`?(f=`tangle hub status --json`,o.providerRetryable===!1&&(d+=`. Change the request before retrying`)):l===`provider_quota_exhausted`||l===`SEAT_LIMIT`?(l=`SEAT_LIMIT`,f=`tangle auth status`,p=!0):e instanceof ce?f=`tangle usage --json`:e instanceof w?(l=`NETWORK_UNAVAILABLE`,u=`Network error: ${u}`,d=_t(e.cause)??`No response arrived`,f=`tangle auth status --json`):e instanceof me?(l=`TIMEOUT`,f=`tangle sandbox list --json`):e instanceof he?(l=`VALIDATION_ERROR`,u=`Invalid input`):e instanceof oe||e instanceof pe?f=`tangle sandbox list --json`:l===`commander.unknownCommand`?(l=`UNKNOWN_COMMAND`,f=u.includes(`'graph'`)?`npm install -g @tangle-network/sandbox-cli@latest`:`tangle --help`):l.startsWith(`commander.`)?l=`USAGE_INVALID`:(l===`ENOENT`||l===`EACCES`)&&(l=`INPUT_UNAVAILABLE`);e instanceof A&&(f=e.fix,p=!1),M(a.fix)&&(l=a.cause===`not_authenticated`?`SEAT_NOT_LOGGED_IN`:`SUBSCRIPTION_REQUIRED`),e instanceof se&&f===`tangle --help`&&(f=`tangle template publish --help`),f=M(a.fix)??M(c.command)??(l===`HUB_NOT_CONNECTED`?void 0:M(t.fixCommand))??f,ft.has(l)&&f===`tangle --help`&&(f=`tangle auth login`);let m=j(t.subject??o.subject??{node:r?.node??t.node,seat:t.seat??a.harness}),h=e instanceof w||e instanceof Error&&`batchCustody`in e?t.batchCustody:void 0;h&&(d=`Batch acceptance: ${h.acceptance}; retirement receipt ${h.cleanup?.mode===`release`&&h.cleanup.isComplete?`proved`:`unproved`}.`,p=!1,f=`tangle batch run --help`);let g=M(t.resumeAt??o.resumeAt??o.resetAt);return{code:l,...h?{batchCustody:h}:{},catalogCode:M(t.catalogCode),message:M(t.nextStep)&&M(t.message),nextStep:M(t.nextStep),subject:{...M(m.node)?{node:String(m.node)}:{},...M(m.seat)?{seat:String(m.seat)}:{}},what:u,cause:d,fix:{command:f,...Array.isArray(c.alternatives)&&c.alternatives.every(e=>typeof e==`string`)?{alternatives:c.alternatives}:{},...c.edit===void 0?{}:{edit:c.edit},...M(c.url)?{url:String(c.url)}:{}},retryable:p,...g&&Number.isFinite(Date.parse(g))?{resumeAt:g}:{},...M(t.runId)?{runId:String(t.runId)}:{},...M(t.requestId)?{requestId:String(t.requestId)}:{},...typeof t.status==`number`?{status:t.status}:{},...M(i.code)&&M(i.owner)?{runtimeFailure:{code:String(i.code),owner:String(i.owner),cause:typeof i.cause==`string`?i.cause:d,...M(i.providerCode)?{providerCode:String(i.providerCode)}:{},...typeof i.providerStatus==`number`?{providerStatus:i.providerStatus}:{},...typeof i.retryAfterMs==`number`?{retryAfterMs:i.retryAfterMs}:{},...Object.keys(a).length?{remediation:a}:{}}}:{},...e instanceof se&&e.job?{job:e.job}:{},...e instanceof A&&Array.isArray(t.failures)?{failures:t.failures.map(e=>{let{node:t,code:n,requirement:r,fix:i}=j(e);return{node:String(t),...M(n)?{code:String(n)}:{},requirement:String(r),fix:String(i)}})}:{}}}function bt(e){let t=[e.subject.node&&`node ${e.subject.node}`,e.subject.seat].filter(Boolean).join(` · `);return`✗ ${`${t?`${t}: `:``}${e.what}${e.status?` (HTTP ${e.status})`:``}`}${e.cause===e.what?``:` — ${e.cause}`}${e.nextStep?`\n → next: ${e.nextStep}`:``}\n → run: ${e.fix.command}`+(e.runtimeFailure?`\n runtime: ${e.runtimeFailure.code} · ${e.runtimeFailure.owner}${e.runtimeFailure.providerCode?` · ${e.runtimeFailure.providerCode}`:``}${e.runtimeFailure.providerStatus===void 0?``:` · HTTP ${e.runtimeFailure.providerStatus}`}${e.runtimeFailure.retryAfterMs===void 0?``:` · retry-after ${e.runtimeFailure.retryAfterMs} ms`}`:``)+(e.fix.alternatives?.map(e=>`\n or: ${e}`).join(``)??``)+(e.resumeAt?`\n resumes ${e.resumeAt}${e.subject.seat?` on ${e.subject.seat}`:``}`:``)}function xt(e){return bt(yt(e))}function N(t,r=!1){n();let i=yt(t);r?e({ok:!1,error:i}):console.error(T.red(bt(i)));let a=1;ft.has(i.code)?a=77:pt.has(i.code)?a=65:mt.has(i.code)?a=64:ht.has(i.code)?a=78:[`SEAT_LIMIT`,`RATE_LIMITED`].includes(i.code)?a=75:[`HARNESS_NOT_INSTALLED`,`MCP_UNREACHABLE`,`NETWORK_UNAVAILABLE`].includes(i.code)?a=69:i.code===`RUN_STOPPED`&&(a=130),process.exit(a)}const St={OPENCODE:`opencode`,CLAUDE_CODE:`claude-code`,KIMI_CODE:`kimi-code`,CODEX:`codex`,AMP:`amp`,FACTORY_DROIDS:`factory-droids`,PI:`pi`,PRIME:`prime`,HERMES:`hermes`,OPENCLAW:`openclaw`,NANOCLAW:`nanoclaw`,NANOCODE:`nanocode`,EXO:`exo`,ACP:`acp`,CURSOR:`cursor`,GROK:`grok`,CLI_BASE:`cli-base`},Ct=Object.values(St);O.enum(Ct);const wt=new Set([St.OPENCODE,St.CLAUDE_CODE,St.KIMI_CODE,St.CODEX,St.PI,St.HERMES]);O.string().regex(/^[A-Za-z0-9_.:@-]{1,256}$/);const Tt=new Set(Ct);function Et(e){return Tt.has(e)}function Dt(e){if(e.startsWith(`github:`)){let[t,n]=e.slice(7).split(`@`,2),r=t.split(`/`).filter(Boolean);if(r.length<3)throw Error(`invalid github ref "${e}": expected github:<owner>/<repo>/<path>[@<ref>]`);let i=`${r[0]}/${r[1]}`,a=r.slice(2).join(`/`);return{kind:`github`,repository:i,path:a,...n?{ref:n}:{},name:Ce(a)}}let t;try{t=x(e,`utf8`)}catch{throw Error(`cannot read skill/tool "${e}": not a readable file and not a github: ref`)}return{kind:`inline`,name:Ce(e),content:t}}function Ot(e){let t=(e.skills??[]).map(Dt),n=(e.tools??[]).map(Dt),r=t.length>0||n.length>0;if(!(!e.model&&!e.systemPrompt&&!r))return{...e.model?{model:{default:e.model}}:{},...e.systemPrompt?{prompt:{systemPrompt:e.systemPrompt}}:{},...r?{resources:{...t.length>0?{skills:t}:{},...n.length>0?{tools:n}:{}}}:{}}}async function kt(e){let t;if(e.startsWith(`github:`)){let[n,r]=e.slice(7).split(`@`,2),i=n.split(`/`).filter(Boolean);if(i.length<3)throw Error(`invalid --profile github ref "${e}": expected github:<owner>/<repo>/<path>[@<ref>]`);let a=r??`main`;t=await jt(`https://raw.githubusercontent.com/${i[0]}/${i[1]}/${a}/${i.slice(2).join(`/`)}`)}else t=/^https?:\/\//.test(e)?await jt(e):x(e,`utf8`);let n;try{n=JSON.parse(t)}catch{throw new A(`PROFILE_INVALID`,`Profile '${e}' is invalid`,`Expected a JSON AgentProfile`,`tangle agent profile create --name my-agent --json`)}return At(n,e)}function At(e,t){let n=Le.safeParse(e);if(!n.success)throw new A(`PROFILE_INVALID`,`Profile '${t}' is invalid`,n.error.issues.map(e=>`${e.path.join(`.`)||`(root)`}: ${e.message}`).join(`; `),`tangle agent profile create --name my-agent --json`);return e}async function jt(e){let t=await fetch(e);if(!t.ok)throw Error(`failed to fetch ${e} (${t.status})`);return t.text()}async function Mt(e){let t=e.profileSource?await kt(e.profileSource):void 0,n=Ot(e);return t?n?{...t,...n,...n.resources?{resources:{...t.resources,...n.resources}}:{}}:t:n}const Nt=Se.join(Ve.homedir(),`.tangle`),Pt=Se.join(Nt,`config.json`),Ft=`https://id.tangle.tools`,It=`https://solve.tangle.tools/api/solve`,Lt=`default`;function Rt(){return{tangleBaseUrl:process.env.TANGLE_BASE_URL,sandboxBaseUrl:process.env.SANDBOX_BASE_URL,hubUrl:process.env.TANGLE_HUB_URL}}function zt(e,t){let n=F(t??(e===`solve`?`solve`:void 0));if(e===`solve`){if(n!==`solve`)throw Error(`The solve app cannot use profile '${n}'. Use the reserved 'solve' profile.`);return n}if(e===`sandbox`&&!t&&n===`solve`)return Lt;if(new Set([`solve`]).has(n))throw Error(`The ${e} app cannot use the reserved '${n}' profile. Use the '${e}' profile or choose a custom profile.`);return n}function Bt(){_.existsSync(Nt)||_.mkdirSync(Nt,{mode:448,recursive:!0})}function Vt(e,t){Bt();let n=`${e}.${process.pid}.tmp`;_.writeFileSync(n,t,{mode:384}),_.renameSync(n,e)}function Ht(e){return e.startsWith(`sk_`)||e.startsWith(`sk-tan-`)}function P(){try{if(_.existsSync(Pt))return JSON.parse(_.readFileSync(Pt,`utf-8`))}catch{}return{}}function Ut(e){let t=Sn(P(),e);Vt(Pt,`${JSON.stringify(t,null,2)}\n`)}function F(e){return Cn(e||process.env.TANGLE_PROFILE||process.env.SANDBOX_PROFILE||P().activeProfile||Lt)}function Wt(e){Ut({activeProfile:Cn(e)})}function Gt(){return{token:process.env.TANGLE_LINE_TOKEN,baseUrl:process.env.TANGLE_HUB_URL}}function Kt(){return process.env.TANGLE_SANDBOX||P().currentSandbox||void 0}function qt(e){Ut({currentSandbox:e})}function Jt(){let e=P();delete e.currentSandbox,Vt(Pt,`${JSON.stringify(e,null,2)}\n`)}function Yt(){let e=P().deviceId;if(e&&/^[A-Za-z0-9_.-]{1,64}$/.test(e))return e;let t=Ve.hostname().replace(/[^A-Za-z0-9_.-]/g,`-`).replace(/^-+|-+$/g,``).slice(0,32),n=je(4).toString(`hex`),r=`${t?`${t}-`:`device-`}${n}`;return Ut({deviceId:r}),r}function Xt(){let e=P(),t=F(),n=new Set([Lt,...Object.keys(e.profiles??{})]);return e.activeProfile&&n.add(Cn(e.activeProfile)),[...n].map(e=>{let n=h(e).source;return{name:e,active:e===t,hasApiKey:n!==`none`,baseUrl:ln(void 0,e),apiKeySource:n}}).sort((e,t)=>e.name.localeCompare(t.name))}function Zt(e){let t=F(e);return{name:t,active:t===F(),baseUrl:ln(void 0,t),credentialSource:h(t).source}}function Qt(e,t){let n=Cn(e),r=P(),i=xn(n,r),a={},o=t.baseUrl??i.baseUrl;o&&(a.baseUrl=o);let s=t.platformUrl===void 0?i.platformUrl:t.platformUrl;s&&(a.platformUrl=s);let c=t.activeTeamId??i.activeTeamId;c&&(a.activeTeamId=c);let l=t.activeTeamName??i.activeTeamName;l&&(a.activeTeamName=l);let u={...r.profiles??{}};a.baseUrl||a.platformUrl||a.activeTeamId||a.activeTeamName?u[n]=a:delete u[n];let d;return t.apiKey&&(d=p(n,t.apiKey)),Ut({profiles:Object.keys(u).length>0?u:{}}),d}function $t(e){let t=F(e),n={...P().profiles??{}},r=n[t];if(r){let e={...r};e.baseUrl||e.platformUrl||e.activeTeamId||e.activeTeamName?n[t]=e:delete n[t]}Ut({profiles:n}),m(t)}function en(){let e=process.env.TANGLE_API_KEY_FILE;if(e){let t=_.readFileSync(e,`utf8`).trim();if(!t.startsWith(`sk-tan-`))throw Error(`Invalid sandbox credential file`);return t}return process.env.TANGLE_API_KEY}const tn={intelligence:`https://intelligence.tangle.tools`,router:`https://router.tangle.tools/v1`};function nn(e,t,n){return rn(`sandbox`,ln(n,t),e,t)}function rn(e,t,n,r){if(n)return n;let i=en();if(i)return i;let a=h(zt(`sandbox`,r)).value;return a&&t!==void 0&&an(e,t,r),a}function an(e,t,n){let r=e===`sandbox`?dn(n):e===`platform`?mn(n)??Ft:tn[e],i=e=>{try{let t=new URL(e.trim()).origin;return t===`null`?void 0:t}catch{return}},a=t=>e===`sandbox`?t.trim().replace(/\/+$/,``).toLowerCase():i(t),o=a(t);if(o!==void 0&&o===a(r))return;let s={sandbox:`unset ${process.env.SANDBOX_BASE_URL&&!process.env.TANGLE_BASE_URL?`SANDBOX_BASE_URL`:`TANGLE_BASE_URL`} or drop --base-url`,platform:`unset TANGLE_PLATFORM_URL and TANGLE_HUB_URL, or drop --base-url and --platform-url`,intelligence:`unset TANGLE_INTELLIGENCE_BASE_URL, or drop --base-url and --endpoint`,router:`unset TANGLE_ROUTER_URL`}[e],c={sandbox:`if you run your own install at ${t}: tangle auth login --base-url ${t}`,platform:`if you run your own install at ${t}: TANGLE_PLATFORM_URL=${t} tangle auth login`,intelligence:`pass the key for ${t} with --api-key or TANGLE_API_KEY`,router:`pass the key for ${t} with --api-key or TANGLE_API_KEY`}[e];throw new A(`CREDENTIAL_ADDRESS_MISMATCH`,`The stored credential is for ${r}, not ${t}, so it was not sent`,`a flag or the environment named that address`,s,[c])}function on(e,t){return e||(process.env.TANGLE_SOLVE_API_KEY?process.env.TANGLE_SOLVE_API_KEY:h(zt(`solve`,t)).value)}function sn(e,t){let n=zt(`sandbox`,t);return e?`flag`:process.env.TANGLE_API_KEY_FILE||process.env.TANGLE_API_KEY?`env`:h(n).source}function cn(e,t){return e?`flag`:process.env.TANGLE_SOLVE_API_KEY?`env`:h(zt(`solve`,t)).source}function ln(e,t){return un(e)||dn(t)}function un(e){return e||process.env.TANGLE_BASE_URL||process.env.SANDBOX_BASE_URL||void 0}function dn(e){let t=F(e),n=P(),r=xn(t,n);return r.baseUrl?r.baseUrl:(t===Lt||t===`sandbox`)&&n.baseUrl?n.baseUrl:`https://sandbox.tangle.tools`}function fn(e){if(e)return e.replace(/\/v1\/hub\/?$/,``)}function I(e){return e?.trim().replace(/\/+$/,``)||void 0}function pn(e){return I(e?.flag)??hn()??I(e?.cachedPlatformUrl?.())??I(mn(e?.profile))??Ft}function mn(e){return xn(F(e),P()).platformUrl}function hn(){return I(fn(I(process.env.TANGLE_HUB_URL)))??I(process.env.TANGLE_PLATFORM_URL)}function gn(e){let t=I(e)??I(process.env.TANGLE_SOLVE_API_URL);if(t&&t!==It)throw Error(`Solve credentials may only be sent to ${It}`);return It}function _n(e){let t=I(e);if(t&&t!==Ft)throw Error(`Solve credentials may only be sent to ${Ft}`);return Ft}function L(e){let t=zt(`sandbox`,e.profile),n=nn(e.apiKey,t,e.baseUrl);if(!n)throw Error(`No API key found for profile '${t}'. Set TANGLE_API_KEY or run: tangle auth login${t===Lt?``:` --profile ${t}`}`);return{apiKey:n,baseUrl:ln(e.baseUrl,t),timeout:e.timeout??3e4,profile:t,...vn(t)}}function vn(e){let t=P(),n=xn(F(e),t);return{activeTeamId:n.activeTeamId,activeTeamName:n.activeTeamName}}function yn(e,t){Qt(F(t),{activeTeamId:e.id,activeTeamName:e.name})}function bn(e){let t=F(e),n=P(),r={...n.profiles??{}},i=xn(t,n),a={baseUrl:i.baseUrl,platformUrl:i.platformUrl};a.baseUrl||a.platformUrl?r[t]=a:delete r[t],Ut({profiles:r})}function xn(e,t=P()){let n=Cn(e);return{...n===Lt?{baseUrl:t.baseUrl,activeTeamId:t.profiles?.[Lt]?.activeTeamId,activeTeamName:t.profiles?.[Lt]?.activeTeamName}:{},...t.profiles?.[n]??{}}}function Sn(e,t){let n=t.profiles===void 0?{...e.profiles??{}}:Object.fromEntries(Object.entries(t.profiles).filter(([,e])=>!!(e.apiKey||e.baseUrl||e.platformUrl||e.activeTeamId||e.activeTeamName)));return{...e,...t,profiles:Object.keys(n).length>0?n:void 0}}function Cn(e){let t=e.trim().toLowerCase();if(!t)throw Error(`Profile name cannot be empty`);if(!/^[a-z0-9][a-z0-9._-]*$/.test(t))throw Error(`Profile names may only contain lowercase letters, numbers, dots, underscores, and hyphens`);return t}let wn=null,Tn=null;function R(e){if(!e&&wn)return wn;let t=e??L({});return(!wn||!Tn||Tn.apiKey!==t.apiKey||Tn.baseUrl!==t.baseUrl||Tn.timeout!==t.timeout)&&(wn=new ue({apiKey:t.apiKey,baseUrl:t.baseUrl,timeoutMs:t.timeout}),Tn=t),wn}function En(){wn=null,Tn=null}function z(e){let t=L({apiKey:e.apiKey,baseUrl:e.baseUrl});return{context:t,client:R(t)}}async function Dn(e,t){let n=t.trim();if(n.length===0)throw Error(`Connection reference is empty.`);if(n.startsWith(`hubconn_`))return n;let{connections:r}=await e.connections.list();return qe(r,n)}function On(e,t){return[...t,e]}async function kn(e,t){let n=e.map(e=>{let t=e.trim(),n=t.indexOf(`:`);return n===-1?{raw:e,ref:null,tail:null}:{raw:e,ref:t.slice(0,n).trim(),tail:t.slice(n+1)}});if(!n.some(e=>e.ref!==null&&e.ref!==`*`&&!e.ref.startsWith(`hubconn_`)))return[...e];let{connections:r}=await(await t()).connections.list();return n.map(e=>e.ref===null||e.ref===`*`||e.ref.startsWith(`hubconn_`)?e.raw:`${Je(r,e.ref)}:${e.tail}`)}function An(e){let t=new Map,n=[];for(let r of e){let e=r.trim(),i=e.indexOf(`:`);if(i===-1)throw Error(`Invalid --connection "${r}": expected <connectionId>:<capability>[,<capability>]. List connection ids with \`tangle hub connections\` and capability paths with \`tangle hub tools search <keyword>\`.`);let a=e.slice(0,i).trim();if(a.length===0)throw Error(`Invalid --connection "${r}": connection id is empty. Use <connectionId>:<capability> — list ids with \`tangle hub connections\`.`);let o=e.slice(i+1).split(`,`).map(e=>e.trim()).filter(e=>e.length>0);if(o.length===0)throw Error(`Invalid --connection "${r}": grant at least one capability, e.g. ${a}:gmail.messages.list. Discover paths with \`tangle hub tools search <keyword>\`.`);if(o.includes(`*`)&&o.length>1)throw Error(`Invalid --connection "${r}": "*" grants all capabilities and can't be combined with specific paths. Use <connectionId>:* alone, or list explicit paths.`);if(a===`*`&&!(o.length===1&&o[0]===`*`))throw Error(`Invalid --connection "${r}": a "*" connection is only valid as "*:*" (all connections, all capabilities). Name a connection id for specific paths.`);let s=t.get(a);s===void 0&&(s=new Set,t.set(a,s),n.push(a));for(let e of o)s.add(e)}return n.map(e=>{let n=t.get(e),r=n?[...n]:[];if(r.includes(`*`)&&r.length>1)throw Error(`Invalid --connection for "${e}": "*" can't be combined with specific capability paths across repeated --connection flags.`);return{connectionId:e,capabilities:r}})}const jn=15e3,Mn=RegExp(`\x1BP[^\x1B]*\x1B\\\\|\x1B\\][^\\u0007\x1B]*(?:\\u0007|\x1B\\\\)|\x1B\\[[?>][\\d;]*c|\x1B\\[\\d+;\\d+R|\x1B\\[\\d+(?:;\\d+)*t`,`g`),Nn=e=>e.replace(Mn,``)===``?e.match(Mn)?.length??0:0,Pn=RegExp(`\x1B\\[>0?q|\x1B\\[[>=]?0?c|\x1B\\[6n|\x1B\\]1\\d;\\?`,`g`);async function Fn(e,t){let n=process.stdin,r=process.stdout,i=null,a=!1,o=!1,s=!1,c=!1,u,d=!1,f=0,p,m,h=0,g,ee=new Promise(e=>{g=e}),_=()=>{try{n.setRawMode(!1)}catch{}n.pause()},v=()=>{a||(a=!0,clearTimeout(p),clearTimeout(m),clearTimeout(w),_(),n.off(`data`,se),process.off(`SIGWINCH`,te),process.off(`SIGINT`,y),process.off(`SIGTERM`,y),process.off(`exit`,_),g())},y=e=>{c=!0,Promise.resolve(i?.close()).finally(()=>{v(),process.exit(e===`SIGTERM`?143:130)})},te=()=>{i?.isOpen&&!s&&i.resize(r.columns||80,r.rows||24)},b=[],x=e=>{if(e.length!==0){try{if(!s&&i?.isOpen)return i.write(e)}catch{}b.push(e),S()}},ne=()=>{clearTimeout(p);let e=i?.authorityLifetimeMs;e!==void 0&&(p=setTimeout(()=>void S(),Math.max(jn,e*.8)))},re=async e=>{for(let t=1;;t++)try{return await e.reconnect({cols:r.columns||80,rows:r.rows||24})}catch(e){if(t>=3||e instanceof ae)throw e;await new Promise(e=>setTimeout(e,500*2**t))}},S=async()=>{let e=i;if(!(s||a||o||!e)){s=!0,clearTimeout(p);try{await e.close(),i=await re(e);for(let e of b.splice(0))i.write(e)}catch(t){a||(u=t instanceof ae?`the session ended`:`could not reattach: ${t.message}`),s=!1,i!==e&&await i?.close(),v();return}if(s=!1,a){await i.close();return}te(),ne()}},ie=()=>{clearTimeout(m),!a&&(m=setTimeout(()=>{d=!0,c=!0,u=`no agent output or input for ${t} ms (--timeout); the session keeps running`,Promise.resolve(i?.close()).finally(v)},t))},C=0,w,oe=e=>{let t=Buffer.from(e).toString(`latin1`).match(Pn);t&&(C+=t.length,clearTimeout(w),w=setTimeout(()=>{C=0},2e3))},se=e=>{if(!i)return;let t=Nn(e.toString(`latin1`));if(t>0){C>0?C=Math.max(0,C-t):x(e);return}ie();let n=e.indexOf(29);if(n===-1){x(e);return}x(e.subarray(0,n)),c=!0,i.close().finally(v)},ce=e=>r.write(Buffer.from(e.buffer,e.byteOffset,e.byteLength));if(i=await e.attach({cols:r.columns||80,rows:r.rows||24,handlers:{onReady:e=>{i===null&&(h=Math.max(h,e.cursors?.latest??0))},onOutput:(e,t)=>{if(ce(t),e<=h)return oe(t);h=e,ie()},onData:e=>{ce(e),ie()},onExit:e=>{o=!0;let t=e.exitCode===void 0?``:` (code ${e.exitCode})`;r.write(`\r\n[interactive session exited${t}]\r\n`),i?.close().finally(v)},onError:e=>{r.write(`\r\n[terminal stream error: ${e.message}]\r\n`)},onClose:()=>{if(s||a)return;let e=Date.now();c||o?v():e-f<jn?(u=`the connection keeps closing`,v()):(f=e,S())}}}),ne(),ie(),n.setRawMode(!0),n.resume(),n.on(`data`,se),process.on(`SIGWINCH`,te),process.on(`SIGINT`,y),process.on(`SIGTERM`,y),process.on(`exit`,_),await ee,console.log(),o){l(`Interactive session ended.`);return}l(`Detached — ${u??`the session keeps running`}.`),d&&(process.exitCode=1)}function In(e){throw new A(`USAGE_INVALID`,e,e,`tangle --help`)}function B(e,t){let n=/^\d+$/.test(e.trim())?Number(e):NaN;return(!Number.isSafeInteger(n)||n<=0)&&In(`${t} must be a positive integer`),n}const Ln={ms:1,s:1e3,m:6e4,h:36e5};function V(e,t,n=`s`,r=1){let i=/^(\d+)(ms|s|m|h)?$/.exec(e.trim()),a=i?Number(i[1]):-1,o=i?.[2],s=o?a*Ln[o]:0,c=o?n===`ms`?s:s/1e3:a;return(!Number.isSafeInteger(c)||c<r)&&In(`${t} must be ${r?`a positive`:`0 or a`} number of ${n===`ms`?`milliseconds`:`seconds`} or a duration like 60m`),c}function Rn(e){if(e<60||e%60)return`${e} s`;let t=e/60;if(t<60)return`${t} min`;let n=t%60;return`${Math.floor(t/60)} h${n?` ${n} min`:``}`}function zn(e,t){return Ae(`sha256`).update(`${e}\0${t}`).digest(`hex`).slice(0,32)}function Bn(e){return`${e}:hub`}function Vn(e){let{value:t}=h(Bn(e));if(!t)return null;try{let e=JSON.parse(t);if(typeof e.key==`string`&&typeof e.expiresAt==`string`&&typeof e.platformUrl==`string`&&typeof e.sessionFingerprint==`string`)return{key:e.key,expiresAt:e.expiresAt,platformUrl:e.platformUrl,sessionFingerprint:e.sessionFingerprint}}catch{}return null}function Hn(e,t){try{p(Bn(e),JSON.stringify(t))}catch{}}async function Un(e,t,n,r){let i=`${e.replace(/\/+$/,``)}/auth/cli/hub-key`,a;try{a=await fetch(i,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${t}`},body:JSON.stringify({device_id:n}),signal:r})}catch(e){throw Error(`Could not reach ${i} to mint a platform key: ${e instanceof Error?e.message:String(e)}`)}let o=await a.text(),s;try{s=JSON.parse(o)}catch{s=null}if(!a.ok||!s?.success){let e=typeof s?.error?.message==`string`?s.error.message:`HTTP ${a.status}`;throw Error(`Platform key minting failed: ${e}. Your sandbox session may have expired — run \`tangle auth login\`.`)}let c=s.data;if(typeof c?.api_key!=`string`||typeof c?.expires_at!=`string`||typeof c?.platform_url!=`string`)throw Error(`Platform key minting returned an unexpected response shape.`);return{key:c.api_key,expiresAt:c.expires_at,platformUrl:c.platform_url}}var Wn=class{cache;fingerprint;constructor(e,t,n,r,i){this.profile=e,this.sandboxBaseUrl=t,this.sessionToken=n,this.deviceId=r,this.signal=i,this.fingerprint=zn(t,n);let a=Vn(e);this.cache=a&&a.sessionFingerprint===this.fingerprint?a:null}isFresh(e){return e!==null&&Date.parse(e.expiresAt)-Date.now()>6e4}async ensure(e=!1){if(this.signal?.throwIfAborted(),!e&&this.isFresh(this.cache))return this.cache;let t={...await Un(this.sandboxBaseUrl,this.sessionToken,this.deviceId,this.signal),sessionFingerprint:this.fingerprint};return this.cache=t,Hn(this.profile,t),t}};function Gn(e){if(!e)return!1;let t=e.trim().toLowerCase();return t===`1`||t===`true`||t===`yes`}function Kn(e,t){return pn({flag:e.baseUrl,profile:t,...e.useCachedPlatformUrl?{cachedPlatformUrl:()=>Vn(t)?.platformUrl}:{}})}function qn(e,t){let n=zt(`sandbox`,e.profile),r=nn(e.apiKey,n,e.sandboxBaseUrl),i=sn(e.apiKey,n),a=e.allowHubCapabilityToken&&process.env.TANGLE_HUB_CAPABILITY_TOKEN?.trim()||void 0;if(a&&i===`env`)throw Error(`Set exactly one of TANGLE_API_KEY or TANGLE_HUB_CAPABILITY_TOKEN, not both`);let o=i===`flag`&&r?r:a??r;if(!o)throw Error(`No API key found for profile '${n}'. Set TANGLE_API_KEY or run: tangle auth login${n===`default`?``:` --profile ${n}`}`);let s=o===r&&(i===`keychain`||i===`file`);if((i===`flag`||i===`env`)&&r||a||o.startsWith(`sk-tan-`)||t){let t=Kn(e,n);return s&&(e.baseUrl??hn())!==void 0&&an(`platform`,t,n),{kind:`static`,apiKey:o,baseUrl:t}}return s&&e.baseUrl&&an(`platform`,e.baseUrl,n),{kind:`managed`,profile:n,sandboxBaseUrl:ln(e.sandboxBaseUrl,n),sessionToken:o,deviceId:Yt(),baseUrlOverride:e.baseUrl}}async function Jn(e={}){let t=qn(e,e.hubKey===!1||Gn(process.env.TANGLE_SKIP_HUB_KEY));if(t.kind===`static`)return{token:t.apiKey,baseUrl:t.baseUrl,minted:!1};let n=new Wn(t.profile,t.sandboxBaseUrl,t.sessionToken,t.deviceId,e.signal),r=await n.ensure();return{token:r.key,baseUrl:t.baseUrlOverride??r.platformUrl,refresh:async()=>(await n.ensure(!0)).key,minted:!0}}async function Yn(e,t,n={}){let r=e=>{let r=new Headers(n.headers);return r.set(`Authorization`,`Bearer ${e}`),fetch(t,{...n,headers:r})},i=await r(e.token);return i.status!==401||!e.refresh?i:r(await e.refresh())}async function Xn(e={}){let t;try{t=await Jn(e)}catch(e){return{reachable:!1,reason:e instanceof Error?e.message:String(e),refused:!0}}try{let e=await Yn(t,`${t.baseUrl.replace(/\/+$/,``)}/v1/plans/current`);if(e.ok)return{reachable:!0,baseUrl:t.baseUrl};let n=e.status===401||e.status===403;return{reachable:!1,baseUrl:t.baseUrl,reason:n?`the platform refused this credential (HTTP ${e.status})`:`the platform answered HTTP ${e.status}`,refused:n}}catch(e){return{reachable:!1,baseUrl:t.baseUrl,reason:`could not reach ${t.baseUrl}: ${e instanceof Error?e.message:String(e)}`,refused:!1}}}async function Zn(e){let t=e.signal,n=t?(e,n)=>{let r=n?.signal??(e instanceof Request?e.signal:void 0);return fetch(e,{...n,signal:r?AbortSignal.any([r,t]):t})}:fetch.bind(globalThis),r=qn(e,e.hubKey===!1||Gn(process.env.TANGLE_SKIP_HUB_KEY));if(r.kind===`static`){let t=!e.apiKey&&process.env.TANGLE_API_KEY_FILE&&!process.env.TANGLE_HUB_CAPABILITY_TOKEN;return new Ke({baseUrl:r.baseUrl,fetch:n,authHeaders:()=>({Authorization:`Bearer ${t?en():r.apiKey}`})})}let i=new Wn(r.profile,r.sandboxBaseUrl,r.sessionToken,r.deviceId,e.signal),a=await i.ensure();return new Ke({baseUrl:r.baseUrlOverride??a.platformUrl,authHeaders:async()=>({Authorization:`Bearer ${(await i.ensure()).key}`}),fetch:async(e,t)=>{let r=await n(e,t);if(r.status!==401)return r;let a=await i.ensure(!0),o=new Headers(t?.headers);return o.set(`Authorization`,`Bearer ${a.key}`),n(e,{...t,headers:o})}})}function Qn(e={}){return Zn(e)}function H(e={}){return Zn({...e,useCachedPlatformUrl:!0,allowHubCapabilityToken:!0})}function $n(e,t){return`Sandbox name is ambiguous: ${e}. Use a sandbox id instead.\n${t.map(e=>`- ${e.id} (status: ${e.status}, created: ${e.createdAt.toISOString()})`).join(`
|
|
2
2
|
`)}`}function er(e){return e.activeTeamId?`team:${e.activeTeamId}`:void 0}async function U(e,t,n,r={}){if(!r.nameOnly){let t=await e.get(n);if(t)return t;if(or(n))throw Error(`Sandbox not found: ${n}`)}let i=(await e.list({scope:er(t)})).filter(e=>e.name?.toLowerCase()===n.toLowerCase());if(i.length===0){let e=Error(`Sandbox not found: ${n}`),t=/^[\w.-]+$/.test(n)?n:JSON.stringify(n);throw r.toRun?Object.assign(e,{fix:{command:`tangle sandbox create --name ${t}`}}):e}if(i.length>1)throw Error($n(n,i));return i[0]}function tr(e,t){return e.create({...t,maxLifetimeSeconds:t.maxLifetimeSeconds??3600,idleTimeoutSeconds:t.idleTimeoutSeconds??900}).catch(e=>{throw t.egressPolicy?nr(e,`tangle sandbox create --help`):e})}function nr(e,t){if(e.code!==`UNSUPPORTED_EGRESS_POLICY`)return e;let n=`--allow-domain: ${e.message}; pass a bare hostname such as api.example.com`;return new A(`USAGE_INVALID`,n,n,t)}const rr=[`failed`,`expired`,`deleted`];async function ir(e,t,n){if(n){let r=await U(e,t,n).catch(e=>{if(e.message!==`Sandbox not found: ${n}`)throw e});if(r&&!rr.includes(r.status))return r;Jt(),l(`The active sandbox ${r?.name??n} cannot run again (${r?.status??`not found`}), so it is no longer the active one.`)}let r=Ce(process.cwd()).toLowerCase().replace(/[^a-z0-9]+/g,`-`).slice(0,40).replace(/^-+|-+$/g,``)||`sandbox`,i=(await e.list({scope:er(t)})).filter(e=>e.name?.toLowerCase()===r&&!rr.includes(e.status)).sort((e,t)=>t.createdAt.getTime()-e.createdAt.getTime())[0];if(i)return qt(i.id),l(`Using ${r}, now the active sandbox.`),i;l(`No active sandbox: creating ${r} and making it active. It is billed while it runs; delete it with: tangle sandbox delete ${r}`);let a=await tr(e,{name:r,...t.activeTeamId?{teamId:t.activeTeamId}:{}}).catch(e=>{let t=e.allocationId;throw typeof t==`string`&&(qt(t),c(`${r} was created but did not start, and it still exists. Delete it with: tangle sandbox delete ${t}`)),e});return qt(a.id),a}const ar=/^sandbox-(?:(?:(?:[a-z][a-z0-9-]*)-)?(?:[a-v0-9]{12}|[a-f0-9]{8}-[a-f0-9]{3})|l[0-9a-z]{1,8}-[0-9a-f]{8})(?:-branch-[a-z0-9]+-[0-9]+)*$/;function or(e){return ar.test(e)}async function sr(e,t,n,r={}){let i=n;try{let a=await U(e,t,n,{nameOnly:r.name});i=a.id,await r.beforeDelete?.(a)}catch(e){if(!(e instanceof Error&&e.message===`Sandbox not found: ${n}`)||r.name||!r.retryCleanup&&!or(n))throw e}let a=await e.delete(i,{until:r.until}).catch(e=>{throw e instanceof de&&e.method&&e.endpoint&&(e.message=`${e.method} ${e.endpoint}: ${e.message}`),e});if(r.until===`removed`&&a.removal!==`complete`)throw Error(`Sandbox removal is unconfirmed for ${i}: ${a.removal??`unknown`}`);let o=P().currentSandbox;return(o===i||o===n)&&Jt(),a.outcome}async function W(e,t){if(e.status!==`stopped`)return e;let n=t?.resumeTimeoutMs??12e4;l(`Sandbox ${e.id} is stopped. Resuming...`);try{await e.resume({timeoutMs:n}),await e.waitFor(`running`,{timeoutMs:n})}catch(t){let r=t instanceof Error?t.message:String(t);throw Error(`Failed to resume sandbox ${e.id}: ${r}. Run \`tangle sandbox resume ${e.id} --timeout ${n}\` and retry.`)}return e}const cr=[`anthropic`,`openai`,`vercel-ai`,`mastra`,`mcp-local`,`claude-desktop`,`cursor`,`zed`];function lr(e,t,n){switch(e){case`anthropic`:return`// pnpm add @anthropic-ai/sdk @tangle-network/sandbox
|
|
3
3
|
import Anthropic from "@anthropic-ai/sdk";
|
|
4
4
|
import { Sandbox } from "@tangle-network/sandbox";
|
|
@@ -166,4 +166,4 @@ fetch(url, { signal: AbortSignal.timeout(30000) })
|
|
|
166
166
|
.then((v) => record(${nu}.test(v) ? v : null), () => {});`,su=(e,t)=>e.localeCompare(t,`en`,{numeric:!0})>0;function cu(e,t){let n=iu(e);if(n===void 0||!process.stderr.isTTY||process.env.CI)return;let r=E(Nt,`update-check.json`),i=Math.floor(Date.now()/864e5);try{let e=y(r)?JSON.parse(x(r,`utf8`)):{},a=e.checked!==i,o=nu.test(e.latest)&&su(e.latest,t);if(!a&&(!o||e.shown===i))return;b(Nt,{mode:448,recursive:!0});let s={...e,checked:i,shown:o?i:e.shown};S(r,JSON.stringify(s)),a&&Ge(process.execPath,[`-e`,ou,r,au()],{detached:!0,stdio:`ignore`}).unref(),o&&e.shown!==i&&console.error(`tangle ${t} is installed; ${e.latest} is latest.${n&&` Run: ${n}`}`)}catch{}}function lu(e,t){return new D(`update`).description(`Install the latest published CLI`).action(async()=>{let n=iu(e);if(n!==`tangle update`)throw new A(`UPDATE_ELSEWHERE`,`install.sh did not install this tangle`,n===void 0?`it runs from source`:`another tool owns it`,n||tu);let r=(await fetch(au(),{signal:AbortSignal.timeout(1e4)}).then(e=>e.json()).catch(()=>({}))).version??``;if(!nu.test(r))throw new A(`NETWORK_UNAVAILABLE`,`the npm registry gave no version`,`no published version was read`,`tangle update`);if(!su(r,t))return console.error(`tangle ${t} is already current`);try{We(`bash`,[`-c`,`set -o pipefail; ${tu}`],{stdio:[`ignore`,`ignore`,`inherit`],env:{...process.env,TANGLE_CLI_VERSION:void 0}})}catch{throw new A(`UPDATE_INSTALL_FAILED`,`install.sh failed`,`its error is above`,tu)}let i=E(ru(),`current`,`node_modules`,eu),a=JSON.parse(x(E(y(i)?i:e,`package.json`),`utf8`));console.error(`tangle updated ${t} -> ${a.version}`)})}function uu(){return new D(`usage`).description(`Show account usage and billing information`).action(async t=>{let{client:n}=z(t),r=t.json?null:f(`Fetching usage...`);r?.start();let[i,a]=await Promise.all([n.usage(),n.subscription().catch(()=>null)]);r?.stop(),t.json?e({...i,subscription:a}):(console.log(),console.log(`Account Usage`),console.log(`─`.repeat(40)),s({"Active Sandboxes":i.activeSandboxes,"Total Sandboxes":i.totalSandboxes,"Compute Minutes":du(i.computeMinutes),"GPU Seconds":i.gpuSeconds,"GPU Spend":fu(i.gpuCostUsd)}),a&&(console.log(),console.log(`Subscription`),console.log(`─`.repeat(40)),s({Plan:a.plan,Status:a.status,"Credits Available":fu(a.creditsAvailableUsd),"Credits Used":fu(a.creditsUsedUsd),"Monthly Balance":fu(a.monthlyBalanceUsd)})),console.log(),console.log(`Billing Period`),console.log(`─`.repeat(40)),s({Start:i.periodStart.toLocaleDateString(),End:i.periodEnd.toLocaleDateString()}),console.log())})}function du(e){if(e===void 0)return`-`;if(e<60)return`${e} min`;let t=Math.floor(e/60),n=e%60;return n===0?`${t} hr`:`${t} hr ${n} min`}function fu(e){return e<0?`-$${(-e).toFixed(2)}`:`$${e.toFixed(2)}`}function pu(){return new D(`use`).description(`Set or show the active sandbox (used when a command omits the id)`).argument(`[id]`,`Sandbox id to make active`).option(`--clear`,`Clear the active sandbox`).action((e,t)=>{if(t.clear){Jt(),l(`Cleared the active sandbox.`);return}if(e){qt(e),l(`Active sandbox set to ${e}. Commands now default to it; override with --box or TANGLE_SANDBOX.`);return}let n=Kt();l(n?`Active sandbox: ${n}`:"No active sandbox. Set one with `tangle use <id>`.")})}function $(e){return Qn({signal:e.signal,...e.apiKey===void 0?{}:{apiKey:e.apiKey},...e.baseUrl===void 0?{}:{baseUrl:e.baseUrl}})}function mu(e){t(e,[{key:`id`,header:`ID`},{key:`nodeId`,header:`Node`},{key:`name`,header:`Name`},{key:`contentType`,header:`Content Type`},{key:`byteSize`,header:`Bytes`},{key:`createdAt`,header:`Created`}])}function hu(t){t.command(`artifacts`).description(`List a run's artifact metadata (never the bytes)`).argument(`<id>`,`Workflow ID`).argument(`<runId>`,`Run ID`).action(async(t,n,r)=>{let i=await(await $(r)).workflows.listArtifacts(t,n);if(r.json)return e(i);mu(i.artifacts)}),t.command(`artifact-download`).description(`Download one run artifact's bytes to a file`).argument(`<id>`,`Workflow ID`).argument(`<runId>`,`Run ID`).argument(`<artifactId>`,`Artifact ID`).option(`--out <file>`,`Destination file (defaults to the artifact ID)`).action(async(t,n,r,i)=>{let a=await(await $(i)).workflows.downloadArtifact(t,n,r),o=i.out??r;try{S(o,a.bytes)}catch(e){throw Error(`Could not write artifact to "${o}": ${e instanceof Error?e.message:String(e)}`)}if(i.json)return e({file:o,contentType:a.contentType,bytes:a.bytes.length});l(`Wrote ${o} (${a.bytes.length} bytes, ${a.contentType}).`)})}function gu(e){t(e.map(e=>({id:e.id,run:e.runId,title:e.title,options:e.options.join(`, `),requested:e.requestedAt,expires:e.expiresAt??``})),[{key:`id`,header:`ID`},{key:`run`,header:`Run`},{key:`title`,header:`Title`},{key:`options`,header:`Options`},{key:`requested`,header:`Requested`},{key:`expires`,header:`Expires`}])}function _u(t){t.command(`decisions`).description(`List a workflow's pending human decisions`).argument(`<id>`,`Workflow ID`).action(async(t,n)=>{let r=(await(await $(n)).workflows.listPendingDecisions()).decisions.filter(e=>e.workflowId===t);if(n.json)return e({decisions:r});gu(r)}),t.command(`decision-resolve`).description(`Answer the decision a run is parked on and resume it`).argument(`<id>`,`Workflow ID`).argument(`<runId>`,`Run ID`).requiredOption(`--choice <choice>`,`The option to resolve with (one of the decision's options)`).action(async(t,n,r)=>{let i=await $(r),a=await i.workflows.getRunDecision(t,n),o=await i.workflows.resolveRunDecision(t,n,{decisionId:a.id,choice:r.choice});if(r.json)return e(o);if(o.resumed){l(`Resolved decision ${o.decisionId} with "${o.choice}" — run ${o.runId} resumed.`);return}l(`Resolved decision ${o.decisionId} with "${o.choice}", but run ${o.runId} had already finished — nothing to resume.`)})}function vu(e){try{return x(e,`utf8`)}catch(t){throw Error(`Could not read workflow file "${e}": ${t instanceof Error?t.message:String(t)}`)}}function yu(e){t(e.map(e=>({id:e.id,name:e.name,enabled:e.enabled?`yes`:`no`,issues:e.validationErrors.length,updated:e.updatedAt})),[{key:`id`,header:`ID`},{key:`name`,header:`Name`},{key:`enabled`,header:`Enabled`},{key:`issues`,header:`Issues`},{key:`updated`,header:`Updated`}])}function bu(e){let n=e.workflows.filter(e=>e.failed>0).length,r=e.workflows.filter(e=>e.failed===0&&e.waiting>0).length,i=e.workflows.filter(e=>e.failed===0&&e.waiting===0&&e.runsInWindow>0).length;l(`${n} failing · ${r} waiting · ${i} healthy · ${e.workflows.length} total over ${e.window}`),t(e.workflows.map(e=>({id:e.id,name:e.name,enabled:e.enabled?`yes`:`no`,runs:e.runsInWindow,failed:e.failed,waiting:e.waiting,success:e.successRate===null?`—`:`${Math.round(e.successRate*100)}%`,lastRun:e.lastRunStatus??`—`,lastRunAt:e.lastRunAt??`—`})),[{key:`id`,header:`ID`},{key:`name`,header:`Name`},{key:`enabled`,header:`Enabled`},{key:`runs`,header:`Runs`},{key:`failed`,header:`Failed`},{key:`waiting`,header:`Waiting`},{key:`success`,header:`Success`},{key:`lastRun`,header:`Last Run`},{key:`lastRunAt`,header:`Last Run At`}])}function xu(e){if(s({ID:e.id,Name:e.name,Description:e.description??``,Enabled:e.enabled?`yes`:`no`,Actions:e.actions.length}),e.triggers&&e.triggers.length>0&&(l(`Triggers`),Su(e.triggers)),e.validationErrors.length>0){l(`Validation issues`);for(let t of e.validationErrors)console.log(` ${t.path}: ${t.message}`)}}function Su(e){t(e.map(e=>({id:e.id,kind:e.kind,enabled:e.enabled?`yes`:`no`,detail:e.kind===`schedule`?`${e.cron??``} (${e.timezone??``})`:`${e.provider??``}:${e.eventFilter?.event??``}${e.eventFilter?.action?`.${e.eventFilter.action}`:``}`})),[{key:`id`,header:`ID`},{key:`kind`,header:`Kind`},{key:`enabled`,header:`Enabled`},{key:`detail`,header:`Detail`}])}function Cu(t){t.command(`list`).description(`List your workflows`).action(async t=>{let n=await(await $(t)).workflows.list();if(t.json)return e(n);yu(n)}),t.command(`fleet`).description(`Fleet overview: every workflow's run tallies over a trailing window, failing-first`).option(`--window <window>`,`Trailing window: 24h, 7d, or 30d`,`7d`).action(async t=>{let n=await(await $(t)).workflows.fleetInsights({window:t.window});if(t.json)return e(n);bu(n)}),t.command(`get`).description(`Show a workflow's definition and compiled triggers`).argument(`<id>`,`Workflow ID`).option(`--yaml`,`Print only the raw definition YAML (the export path — pipe to a file)`).action(async(t,n)=>{let r=await(await $(n)).workflows.get(t);if(n.yaml){if(r.definitionYaml===null)throw Error(`Workflow ${r.id} has no stored definition YAML to export`);process.stdout.write(r.definitionYaml.endsWith(`
|
|
167
167
|
`)?r.definitionYaml:`${r.definitionYaml}\n`);return}if(n.json)return e(r);xu(r)}),t.command(`create`).description(`Create a workflow from a YAML file`).argument(`<file>`,`Path to the workflow YAML`).action(async(t,n)=>{let r=vu(t),i=await(await $(n)).workflows.create(r);if(n.json)return e(i);l(`Created workflow ${i.id} (${i.name}).`),xu(i)}),t.command(`apply`).description(`Create or update a workflow idempotently, matched by the definition's name`).argument(`<file>`,`Path to the workflow YAML`).action(async(t,n)=>{let r=vu(t),i=await $(n),a=await i.workflows.validate(r,{structural:!0});if(!a.valid){if(process.exitCode=1,n.json)return e(a);l(`Invalid workflow:`);for(let e of a.errors)console.log(` ${e.path}: ${e.message}`);return}let o=(await i.workflows.list()).find(e=>e.name===a.name);if(o){let t=await i.workflows.update(o.id,r);if(n.json)return e({action:`updated`,workflow:t});l(`Updated workflow ${t.id} (${t.name}) — matched by name.`),xu(t);return}let s=await i.workflows.create(r);if(n.json)return e({action:`created`,workflow:s});l(`Created workflow ${s.id} (${s.name}).`),xu(s)}),t.command(`update`).description(`Replace a workflow's definition from a YAML file`).argument(`<id>`,`Workflow ID`).argument(`<file>`,`Path to the workflow YAML`).option(`--note <note>`,`Revision note recorded on the appended revision (why this change)`).action(async(t,n,r)=>{let i=vu(n),a=await(await $(r)).workflows.update(t,i,{...r.note===void 0?{}:{note:r.note}});if(r.json)return e(a);l(`Updated workflow ${a.id} (${a.name}).`),xu(a)}),t.command(`delete`).description(`Delete a workflow and its triggers`).argument(`<id>`,`Workflow ID`).option(`--force`,`Skip confirmation prompt`).action(async(t,n)=>{if(!n.force&&!await G(`Delete workflow ${t}? `,`--force`)){l(`Delete cancelled.`);return}if(await(await $(n)).workflows.delete(t),n.json)return e({deleted:!0,id:t});l(`Deleted workflow ${t}.`)}),t.command(`validate`).description(`Validate a workflow YAML file without saving it`).argument(`<file>`,`Path to the workflow YAML`).option(`--structural`,`CI mode: compile + capability checks only, no connection resolution — the verdict is the same regardless of connected providers`).action(async(t,n)=>{let r=vu(t),i=await(await $(n)).workflows.validate(r,{...n.structural?{structural:!0}:{}});if(n.json)return e(i);if(i.valid)l(`Valid: ${i.name} (${i.actionCount} action(s), ${i.triggerCount} trigger(s)).`);else{l(`Invalid workflow:`);for(let e of i.errors)console.log(` ${e.path}: ${e.message}`);process.exitCode=1}}),t.command(`schema`).description(`Print the JSON Schema for the workflow YAML`).action(async t=>{e(await(await $(t)).workflows.schema())})}const wu=1e3;function Tu(e,t){return[...t,e]}function Eu(e,t=`input`,n){if(n===void 0&&!e?.length)return;let r={};if(n!==void 0)try{if(r=JSON.parse(x(n,`utf8`)),!r||typeof r!=`object`||Array.isArray(r)||Object.entries(r).some(([e,t])=>!e.length||typeof t!=`string`))throw Error(`Invalid input map`)}catch{throw new A(`WORKFLOW_INPUT_FILE_INVALID`,`Could not load --input-file '${n}'`,`Expected a readable JSON object with nonempty keys and string values`,`tangle workflows run --help`)}let i=Object.entries(r);for(let n of e??[]){let e=n.indexOf(`=`);if(e<=0)throw Error(`Invalid --${t} "${n}": expected key=value (e.g. pull_request.number=123)`);i.push([n.slice(0,e),n.slice(e+1)])}return Object.fromEntries(i)}function Du(e){t(e.map(e=>({id:e.id,status:e.status,attempts:e.attempts,created:e.createdAt,completed:e.completedAt??``})),[{key:`id`,header:`Run ID`},{key:`status`,header:`Status`},{key:`attempts`,header:`Attempts`},{key:`created`,header:`Created`},{key:`completed`,header:`Completed`}])}function Ou(e){if(s({"Run ID":e.id,Workflow:e.workflowId,Status:e.status,Error:e.error??``,Attempts:e.attempts,Created:e.createdAt,Started:e.startedAt??``,Completed:e.completedAt??``}),e.actionResults.length>0){l(`Actions`);let n=e.actionResults.some(e=>e.nodeId!==void 0||e.visit!==void 0);t(e.actionResults.map(e=>({index:e.index,...n?{node:e.nodeId??``,visit:e.visit??``}:{},kind:e.kind,status:e.status,error:e.error??``,cost:e.costUsd??``})),[{key:`index`,header:`#`},...n?[{key:`node`,header:`Node`},{key:`visit`,header:`Visit`}]:[],{key:`kind`,header:`Kind`},{key:`status`,header:`Status`},{key:`error`,header:`Error`},{key:`cost`,header:`Cost (USD)`}])}e.graph&&(l(`Graph`),s({Nodes:e.graph.nodes.length,Edges:e.graph.edges.length,"Max node visits":e.graph.maxNodeVisits}),t(e.graph.edges.map(e=>({from:e.from,to:e.to,guard:e.when===void 0?``:JSON.stringify(e.when)})),[{key:`from`,header:`From`},{key:`to`,header:`To`},{key:`guard`,header:`Guard`}])),e.edgeVerdicts&&e.edgeVerdicts.length>0&&(l(`Edge verdicts`),t(e.edgeVerdicts.flatMap(e=>Object.entries(e.verdicts).map(([t,n])=>({node:e.nodeId,edge:t,verdict:n?`taken`:`not taken`}))),[{key:`node`,header:`Node`},{key:`edge`,header:`Edge`},{key:`verdict`,header:`Verdict`}]))}function ku(e){if(e.status===`cancelled`){l(`Cancelled run ${e.runId}.`);return}if(e.signalled){l(`Cancelling run ${e.runId} — signalled the worker; it will stop shortly.`);return}l(`Requested cancellation of run ${e.runId}, but couldn't confirm it — the run may have just finished, or it's running on another instance and will stop on its own.`)}function Au(e){switch(e.type){case`snapshot`:l(`snapshot: ${e.run.status} (${e.run.actionResults.length} action(s))`);break;case`action.started`:console.log(`→ action[${e.index}] ${e.kind} started`);break;case`action.finished`:{let t=e.status===`succeeded`?`✓`:e.status===`skipped`?`⊘`:`✗`;console.log(`${t} action[${e.index}] ${e.kind} ${e.status}${e.error?`: ${e.error}`:``}`);break}case`iteration.started`:console.log(` · action[${e.actionIndex}] iteration ${e.iterationIndex} started`);break;case`iteration.ended`:console.log(` · action[${e.actionIndex}] iteration ${e.iterationIndex} ${e.status}`);break;case`token`:typeof e.delta==`string`&&process.stdout.write(e.delta);break;case`ping`:break;case`run.done`:console.log(`\nrun.done: ${e.status}${e.error?`: ${e.error}`:``}`);break;case`run.waiting`:console.log(`\nrun.waiting: parked on a human decision (${e.decisionId}) — resolve it to resume`);break}}function ju(t){t.command(`run`).description(`Trigger an immediate run of a workflow`).argument(`<id>`,`Workflow ID`).option(`--input-file <file>`,`Trigger inputs from a flat JSON string map; --input overrides its keys`).option(`--input <key=value>`,`Trigger input as key=value (e.g. pull_request.number=123). Repeatable.`,Tu,[]).option(`--wait`,`Wait for the run to finish and print its result`).option(`--timeout <ms>`,`With --wait, fail if the run has not finished after this many milliseconds`).option(`--poll-interval <ms>`,`With --wait, how often to poll for completion (default 2000)`).action(async(t,n)=>{let r=Eu(n.input,`input`,n.inputFile),i=n.timeout===void 0?void 0:B(n.timeout,`--timeout`),a=n.pollInterval===void 0?void 0:B(n.pollInterval,`--poll-interval`),o=await $(n),{runId:s}=await o.workflows.run(t,r);if(!n.wait){if(n.json)return e({runId:s});l(`Started run ${s} for workflow ${t}.`),l(`Inspect it with: tangle workflows run-detail ${t} ${s}`);return}let c=n.json?null:f(`Waiting for run ${s} to finish...`).start(),u;try{u=await o.workflows.waitForRun(t,s,{...i===void 0?{}:{timeoutMs:i},...a===void 0?{}:{pollIntervalMs:a}})}finally{c?.stop()}if(u.status===`failed`&&(process.exitCode=1),n.json)return e(u);Ou(u)}),t.command(`runs`).description(`List a workflow's run history (newest first)`).argument(`<id>`,`Workflow ID`).option(`--limit <n>`,`Runs per page (1-100)`).option(`--cursor <cursor>`,`Pagination cursor from a previous page`).option(`--all`,`Fetch every page, not just the first`).action(async(t,n)=>{let r=await $(n),i=n.limit===void 0?void 0:B(n.limit,`--limit`);if(n.all){let a=[],o=n.cursor,s=0,c=null;for(;;){let e=await r.workflows.listRuns(t,{...i===void 0?{}:{limit:i},...o===void 0?{}:{cursor:o}});if(a.push(...e.runs),s+=1,!e.nextCursor)break;if(s>=wu){c=e.nextCursor,n.json||l(`Stopped after ${wu} pages (${a.length} runs); more may exist — resume with --cursor ${e.nextCursor}`);break}o=e.nextCursor}if(n.json)return e({runs:a,nextCursor:c});Du(a);return}let a=await r.workflows.listRuns(t,{...i===void 0?{}:{limit:i},...n.cursor===void 0?{}:{cursor:n.cursor}});if(n.json)return e(a);Du(a.runs),a.nextCursor&&l(`More runs available — next page: --cursor ${a.nextCursor}`)}),t.command(`run-detail`).description(`Show a single run's detail (per-action output and errors)`).argument(`<id>`,`Workflow ID`).argument(`<runId>`,`Run ID`).action(async(t,n,r)=>{let i=await(await $(r)).workflows.getRun(t,n);if(r.json)return e(i);Ou(i)}),t.command(`cancel`).description(`Cancel a queued or in-progress run`).argument(`<id>`,`Workflow ID`).argument(`<runId>`,`Run ID`).action(async(t,n,r)=>{let i=await(await $(r)).workflows.cancel(t,n);if(r.json)return e(i);ku(i)}),t.command(`retry`).description(`Re-run a failed or cancelled run (a fresh run with the same trigger context)`).argument(`<id>`,`Workflow ID`).argument(`<runId>`,`Run ID of the failed/cancelled run to retry`).option(`--wait`,`Wait for the new run to finish and print its result`).option(`--timeout <ms>`,`With --wait, fail if the run has not finished after this many milliseconds`).option(`--poll-interval <ms>`,`With --wait, how often to poll for completion (default 2000)`).action(async(t,n,r)=>{let i=r.timeout===void 0?void 0:B(r.timeout,`--timeout`),a=r.pollInterval===void 0?void 0:B(r.pollInterval,`--poll-interval`),o=await $(r),s=await o.workflows.retryRun(t,n);if(!r.wait){if(r.json)return e(s);l(`Started run ${s.runId} (retry of ${n}).`),l(`Inspect it with: tangle workflows run-detail ${t} ${s.runId}`);return}let c=r.json?null:f(`Waiting for run ${s.runId} to finish...`).start(),u;try{u=await o.workflows.waitForRun(t,s.runId,{...i===void 0?{}:{timeoutMs:i},...a===void 0?{}:{pollIntervalMs:a}})}finally{c?.stop()}if(u.status===`failed`&&(process.exitCode=1),r.json)return e(u);Ou(u)}),t.command(`events`).description(`Tail a run's live progress events until it finishes`).argument(`<id>`,`Workflow ID`).argument(`<runId>`,`Run ID`).action(async(e,t,n)=>{let r=await $(n);for await(let i of r.workflows.watchRun(e,t))n.json?console.log(JSON.stringify(i)):Au(i),i.type===`run.done`&&i.status===`failed`&&(process.exitCode=1)})}async function Mu(t,n,r){let i=await(await $(r)).workflows.setEnabled(t,n);if(r.json)return e(i);l(`${n?`Enabled`:`Disabled`} workflow ${i.id}.`),xu(i)}function Nu(e,t){try{return JSON.parse(e)}catch{throw Error(`Invalid ${t}: not valid JSON`)}}function Pu(e,t){try{S(e,t,`utf8`)}catch(t){throw Error(`Could not write workflow file "${e}": ${t instanceof Error?t.message:String(t)}`)}}function Fu(e){t(e.map(e=>({id:e.id,name:e.name,category:e.category,providers:e.providers.join(`, `),summary:e.summary})),[{key:`id`,header:`ID`},{key:`name`,header:`Name`},{key:`category`,header:`Category`},{key:`providers`,header:`Providers`},{key:`summary`,header:`Summary`}])}function Iu(e,t){let n=e.kind===`github_app`,r=n?`${e.provider} (App installation)`:e.provider,i=e.connectUrl?` — ${n?`install`:`connect`}: ${e.connectUrl}`:``,a=e.prerequisite;return`${r}${i}${a&&t.some(e=>e.provider===a.provider&&e.kind===a.kind&&!e.connected)?` (after connecting ${a.provider})`:``}`}function Lu(t){t.command(`enable`).description(`Enable a workflow so its triggers and manual runs fire`).argument(`<id>`,`Workflow ID`).action(async(e,t)=>{await Mu(e,!0,t)}),t.command(`disable`).description(`Disable a workflow (pause its triggers and manual runs)`).argument(`<id>`,`Workflow ID`).action(async(e,t)=>{await Mu(e,!1,t)}),t.command(`templates`).description(`List the curated starter workflow templates`).action(async t=>{let n=await(await $(t)).workflows.listTemplates();if(t.json)return e(n);Fu(n)}),t.command(`init`).description(`Create a workflow from a gallery template and print (or save) its YAML`).argument(`<template-id>`,"Template ID from `workflows templates`").option(`--param <key=value>`,`Template parameter value. Repeatable.`,Tu,[]).option(`--file <out>`,`Write the instantiated workflow YAML to this file instead of stdout`).action(async(t,n)=>{let r=Eu(n.param,`param`)??{},i=await(await $(n)).workflows.instantiateTemplate(t,r);if(n.json)return e(i);if(!i.created){l(`Template ${t} needs provider connections before it can run:`);for(let e of i.connectionRequirements)console.log(` ${e.connected?`✓`:`✗`} ${Iu(e,i.connectionRequirements)}`);process.exitCode=1;return}let{workflow:a}=i;if(a.definitionYaml===null)throw Error(`Workflow ${a.id} was created but the server returned no definition YAML`);if(l(`Created workflow ${a.id} (${a.name}).`),n.file){Pu(n.file,a.definitionYaml),l(`Wrote ${n.file}.`);return}process.stdout.write(a.definitionYaml.endsWith(`
|
|
168
168
|
`)?a.definitionYaml:`${a.definitionYaml}\n`)})}function Ru(e){t(e,[{key:`key`,header:`Key`},{key:`version`,header:`Version`},{key:`updatedAt`,header:`Updated`}])}function zu(t){s({Key:t.key,Version:t.version,Updated:t.updatedAt}),l(`Value`),e(t.value)}function Bu(t){let n=t.command(`kv`).description(`Read and write a workflow's cross-run KV state`);n.command(`list`).description(`List every KV entry of a workflow`).argument(`<id>`,`Workflow ID`).action(async(t,n)=>{let r=await(await $(n)).workflows.listKv(t);if(n.json)return e(r);Ru(r.entries)}),n.command(`get`).description(`Show one KV entry (value and version)`).argument(`<id>`,`Workflow ID`).argument(`<key>`,`KV key`).action(async(t,n,r)=>{let i=await(await $(r)).workflows.getKv(t,n);if(r.json)return e(i);zu(i)}),n.command(`set`).description(`Write a KV entry from a JSON value`).argument(`<id>`,`Workflow ID`).argument(`<key>`,`KV key`).argument(`<json>`,`Value as JSON (e.g. '{"cursor":123}' or '"abc"')`).option(`--cas <version>`,`Compare-and-swap: write only if the stored version still equals this`).action(async(t,n,r,i)=>{let a=Nu(r,`<json>`),o=i.cas===void 0?void 0:B(i.cas,`--cas`),s=await $(i),c=o===void 0?await s.workflows.putKv(t,n,a):await s.workflows.casKv(t,n,o,a);if(i.json)return e(c);zu(c)}),n.command(`delete`).description(`Delete a KV entry (idempotent)`).argument(`<id>`,`Workflow ID`).argument(`<key>`,`KV key`).action(async(t,n,r)=>{let i=await(await $(r)).workflows.deleteKv(t,n);if(r.json)return e(i);l(i.deleted?`Deleted KV entry "${n}" of workflow ${t}.`:`No KV entry "${n}" on workflow ${t}.`)})}function Vu(e){t(e.map(e=>({rev:e.rev,created:e.createdAt,by:e.createdBy,source:e.source,note:e.note??``})),[{key:`rev`,header:`Rev`},{key:`created`,header:`Created`},{key:`by`,header:`Created By`},{key:`source`,header:`Source`},{key:`note`,header:`Note`}])}function Hu(t){t.command(`revisions`).description(`List a workflow's definition revision history (newest first)`).argument(`<id>`,`Workflow ID`).action(async(t,n)=>{let r=await(await $(n)).workflows.listRevisions(t);if(n.json)return e(r);Vu(r)}),t.command(`revision`).description(`Show one revision's metadata and definition YAML`).argument(`<id>`,`Workflow ID`).argument(`<rev>`,`Revision number`).action(async(t,n,r)=>{let i=B(n,`<rev>`),a=await(await $(r)).workflows.getRevision(t,i);if(r.json)return e(a);s({Revision:a.rev,Created:a.createdAt,"Created by":a.createdBy,Source:a.source,Note:a.note??``}),process.stdout.write(a.yaml.endsWith(`
|
|
169
|
-
`)?a.yaml:`${a.yaml}\n`)}),t.command(`rollback`).description(`Restore a prior revision's definition as a NEW head revision (re-validated)`).argument(`<id>`,`Workflow ID`).argument(`<rev>`,`Revision number to restore`).action(async(t,n,r)=>{let i=B(n,`<rev>`),a=await(await $(r)).workflows.rollback(t,i);if(r.json)return e(a);l(`Rolled back workflow ${a.id} to rev ${i}.`),xu(a)})}function Uu(){let e=new D(`workflows`).description(`Create and manage Tangle workflows`);return Cu(e),ju(e),Lu(e),Hu(e),Bu(e),hu(e),_u(e),e}function Wu(e){for(let[t,n]of Object.entries(e.optsWithGlobals()))e.getOptionValue(t)===void 0&&n!==void 0&&e.setOptionValue(t,n)}const Gu=ee(import.meta.url),Ku=Gu(`../package.json`),qu=we(Gu.resolve(`../package.json`)),Ju=Ku.version??`0.0.0`;function Yu(){let e=new D,t=lu(qu,Ju);e.name(`tangle`).description(`CLI for Tangle Sandbox operations`).version(Ju).option(`--json`,`Output JSON where supported, including errors`).option(`--api-key <key>`,`API key (or set TANGLE_API_KEY)`).option(`--base-url <url>`,`API base URL`),e.hook(`preAction`,(e,n)=>{Wu(n);let r=n.opts(),i=r.json===!0||r.ndjson===!0;a(i),n!==t&&!i&&cu(qu,Ju)}),e.addCommand(ei()),e.addCommand(Zc()),e.addCommand(pu()),e.addCommand($c()),e.addCommand(Dc()),e.addCommand(Fc()),e.addCommand(Ic()),e.addCommand(wo()),e.addCommand(gl()),e.addCommand(_l()),e.addCommand(yl()),e.addCommand(Mr()),e.addCommand(nl()),e.addCommand(ks()),e.addCommand(uu()),e.addCommand(jl()),e.addCommand(Il()),e.addCommand(ui()),e.addCommand(xi()),e.addCommand(Wc()),e.addCommand(As()),e.addCommand(Ns());let n=new D(`graph`).description(`Build and run portable agent graphs`);e.addCommand(n);let r=async()=>{n.commands.length||(await import(`./graph-
|
|
169
|
+
`)?a.yaml:`${a.yaml}\n`)}),t.command(`rollback`).description(`Restore a prior revision's definition as a NEW head revision (re-validated)`).argument(`<id>`,`Workflow ID`).argument(`<rev>`,`Revision number to restore`).action(async(t,n,r)=>{let i=B(n,`<rev>`),a=await(await $(r)).workflows.rollback(t,i);if(r.json)return e(a);l(`Rolled back workflow ${a.id} to rev ${i}.`),xu(a)})}function Uu(){let e=new D(`workflows`).description(`Create and manage Tangle workflows`);return Cu(e),ju(e),Lu(e),Hu(e),Bu(e),hu(e),_u(e),e}function Wu(e){for(let[t,n]of Object.entries(e.optsWithGlobals()))e.getOptionValue(t)===void 0&&n!==void 0&&e.setOptionValue(t,n)}const Gu=ee(import.meta.url),Ku=Gu(`../package.json`),qu=we(Gu.resolve(`../package.json`)),Ju=Ku.version??`0.0.0`;function Yu(){let e=new D,t=lu(qu,Ju);e.name(`tangle`).description(`CLI for Tangle Sandbox operations`).version(Ju).option(`--json`,`Output JSON where supported, including errors`).option(`--api-key <key>`,`API key (or set TANGLE_API_KEY)`).option(`--base-url <url>`,`API base URL`),e.hook(`preAction`,(e,n)=>{Wu(n);let r=n.opts(),i=r.json===!0||r.ndjson===!0;a(i),n!==t&&!i&&cu(qu,Ju)}),e.addCommand(ei()),e.addCommand(Zc()),e.addCommand(pu()),e.addCommand($c()),e.addCommand(Dc()),e.addCommand(Fc()),e.addCommand(Ic()),e.addCommand(wo()),e.addCommand(gl()),e.addCommand(_l()),e.addCommand(yl()),e.addCommand(Mr()),e.addCommand(nl()),e.addCommand(ks()),e.addCommand(uu()),e.addCommand(jl()),e.addCommand(Il()),e.addCommand(ui()),e.addCommand(xi()),e.addCommand(Wc()),e.addCommand(As()),e.addCommand(Ns());let n=new D(`graph`).description(`Build and run portable agent graphs`);e.addCommand(n);let r=async()=>{n.commands.length||(await import(`./graph-KZkapIfX.mjs`)).registerGraphCommands(n)};e.hook(`preSubcommand`,async(e,t)=>{t===n&&await r()});let i=e.parseAsync.bind(e);e.parseAsync=async(e,t)=>{let n=(e??process.argv).slice(t?.from===`user`?0:2);return n[0]===`help`&&n[1]===`graph`&&await r(),i(e,t)},e.addCommand(Ls()),e.addCommand(Uu()),e.addCommand(oo()),e.addCommand(Qc()),e.addCommand(ol()),e.addCommand(tl()),e.addCommand(Si()),e.addCommand(Hc()),e.addCommand(cc()),e.addCommand($a()),e.addCommand(eo()),e.addCommand(Xc()),e.addCommand(Lc()),e.addCommand(Ll()),e.addCommand(Al()),e.addCommand(t);function o(e){e.configureHelp({showGlobalOptions:!0}),e.configureOutput({writeErr:()=>{}}),e.exitOverride(t=>{t.exitCode===0&&process.exit(0),N(t,e.optsWithGlobals().json===!0)});for(let t of e.commands)o(t)}return o(e),e}try{let e=te(`.env`),t=e.isFile()&&e.size<=65536?x(`.env`,`utf8`):``;/^\s*(export\s+)?(TANGLE|SANDBOX)_\w*\s*=/m.test(t)&&console.error(`The CLI no longer reads .env; export its TANGLE_ and SANDBOX_ variables in your shell.`)}catch{}const Xu=Yu();Xu.parseAsync(process.argv).catch(e=>{N(e,Xu.opts().json===!0)});export{xt as _,Ps as a,Lr as c,Jn as d,on as f,A as g,gn as h,El as i,G as l,zt as m,$ as n,Is as o,P as p,Ol as r,Wr as s,Eu as t,K as u,N as v};
|
package/hub-reference.md
CHANGED
|
@@ -91,6 +91,8 @@ Repeat `--scope <scope>` to request a narrower OAuth grant within the host's all
|
|
|
91
91
|
|
|
92
92
|
Graph nodes may use `needs: [{ provider: gmail, account: research, capabilities: [gmail.list_messages], alias: mail }]`. The account matches the provider's stable account ID or its displayed account name. Both local and cloud runs bind it to the current owner's connection; a bare provider is refused when ambiguous. A string need such as `needs: [gmail]` retains all tools of its host binding.
|
|
93
93
|
|
|
94
|
+
`graph run` and `graph preflight <name-or-file>` check every node before a run exists: a seat source for each authored seat, `BRIDGE_PROXY_SECRET_COMMAND` and `BRIDGE_IRON_PROXY_BIN` for nodes that declare `proxySecrets`, and one test mint and revoke per secret key. Every unmet prerequisite prints as one line (node, requirement, fix), and `--json` returns them as `error.failures`; the minted secret is never printed.
|
|
95
|
+
|
|
94
96
|
Custom MCP remains the canonical `profile.mcp` declaration. `graph run --mcp-policy <file>` admits it with a separate host-owned JSON policy such as `{"allowLocalMcp":true,"allowedMcpHosts":["tools.example.test"]}`. The defaults deny stdio and remote MCP; hooks remain refused. The policy is retained with a local run or cloud deployment revision and cannot change on resume. Executables and scripts must exist in the run's workspace or selected sandbox environment. Hub connections provide credential-backed tools. The local Bridge refuses custom MCP secret references until its private secret resolver is wired; never put tokens in graph source.
|
|
95
97
|
|
|
96
98
|
```json
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/sandbox-cli",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.137",
|
|
4
4
|
"description": "CLI for Tangle Sandbox operations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@tangle-network/agent-runtime": "^10.0.12",
|
|
27
27
|
"@tangle-network/harness-sessions": "^1.0.13",
|
|
28
28
|
"@tangle-network/hub-sdk": "1.0.33",
|
|
29
|
-
"@tangle-network/sandbox": "^1.0.
|
|
29
|
+
"@tangle-network/sandbox": "^1.0.566",
|
|
30
30
|
"@tangle-network/sdk-cli-runner": "^0.3.17",
|
|
31
31
|
"chalk": "^5.6.2",
|
|
32
32
|
"cli-bridge": "https://codeload.github.com/drewstone/cli-bridge/tar.gz/88adb1d1b332a86c63a002169264bf47709663d1",
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
"tsx": "^4.23.15",
|
|
61
61
|
"typescript": "^6.0.3",
|
|
62
62
|
"vitest": "^4.1.12",
|
|
63
|
-
"@
|
|
64
|
-
"@repo/knowledge-host": "0.0.0",
|
|
63
|
+
"@repo/shared": "0.0.0",
|
|
65
64
|
"@tangle-network/runtime-contracts": "0.20.0",
|
|
66
|
-
"@
|
|
65
|
+
"@tangle-network/sdk-session-persistence": "0.7.0",
|
|
66
|
+
"@repo/knowledge-host": "0.0.0"
|
|
67
67
|
},
|
|
68
68
|
"publishConfig": {
|
|
69
69
|
"access": "public",
|
|
@@ -87,8 +87,8 @@
|
|
|
87
87
|
"author": "Tangle Network",
|
|
88
88
|
"license": "MIT",
|
|
89
89
|
"tangleRelease": {
|
|
90
|
-
"sourceSha": "
|
|
91
|
-
"mergedAt": "2026-11-
|
|
90
|
+
"sourceSha": "44a81e293a9c623d4deb16bcb2f5327b1e8ff733",
|
|
91
|
+
"mergedAt": "2026-11-23T11:42:59-08:00"
|
|
92
92
|
},
|
|
93
93
|
"scripts": {
|
|
94
94
|
"build": "tsdown",
|