@north-light/cli 0.3.693 → 0.3.694
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/errors.js +1 -1
- package/dist/cli.js +6 -6
- package/dist/clients/attach/viewer.js +496 -496
- package/dist/commands/node/inspect.js +9 -9
- package/dist/commands/pkg/market-manage.js +1 -1
- package/dist/commands/pkg/plugin-manage.js +1 -1
- package/dist/commands/sys/update.js +1 -1
- package/dist/core/canvas/canvas.js +6 -6
- package/dist/core/config.js +1 -1
- package/dist/core/graph/exposures.js +1 -1
- package/dist/core/graph/watches.js +1 -1
- package/dist/core/installed-plugins.js +1 -1
- package/dist/core/scoped-state/imported-mac-installs.d.ts +12 -0
- package/dist/core/scoped-state/imported-mac-installs.js +2 -0
- package/dist/core/spaces/stop.js +1 -1
- package/dist/daemon/api/server.js +1 -1
- package/dist/shared/env.d.ts +8 -3
- package/dist/shared/env.js +2 -2
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/package.json +3 -3
- package/packages/crouter-api/dist/api/errors.js +1 -1
- package/packages/crouter-api/dist/commands/node/inspect.js +16 -2
- package/packages/crouter-api/dist/commands/pkg/market-manage.js +22 -19
- package/packages/crouter-api/dist/commands/pkg/plugin-manage.js +2 -1
- package/packages/crouter-api/dist/commands/sys/update.js +5 -3
- package/packages/crouter-api/dist/core/canvas/canvas.js +4 -8
- package/packages/crouter-api/dist/core/config.js +10 -3
- package/packages/crouter-api/dist/core/graph/exposures.js +1 -1
- package/packages/crouter-api/dist/core/graph/watches.js +1 -1
- package/packages/crouter-api/dist/core/installed-plugins.js +3 -2
- package/packages/crouter-api/dist/core/scoped-state/imported-mac-installs.js +94 -0
- package/packages/crouter-api/dist/core/spaces/stop.js +2 -2
- package/packages/crouter-api/dist/shared/env.js +15 -4
- package/packages/crouter-api/dist/types.js +1 -1
- package/packages/crouter-api/package.json +1 -1
- package/packages/crouter-identity/package.json +1 -1
- package/packages/crouter-plugin/package.json +3 -3
- package/runtime.lock.json +14 -14
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
var
|
|
2
|
-
`),"leaf")},run:h(async n=>{const e=h(
|
|
3
|
-
`)}},"run"),render:h(n=>{const e=n.node,
|
|
4
|
-
`));const
|
|
5
|
-
`);return`${
|
|
1
|
+
var P=Object.defineProperty;var h=(n,e)=>P(n,"name",{value:e,configurable:!0});import{defineBranch as I,defineLeaf as _}from"../../core/command.js";import{InputError as k}from"../../core/io.js";import{requireScope as O}from"../../core/errors.js";import{isPidAlive as A}from"../../core/canvas/pid.js";import{fullName as $}from"../../core/canvas/labels.js";import{fuzzyMatch as F}from"../../core/tui/fuzzy.js";import{nodeSnapshotLeaf as L}from"../node-snapshot.js";import{nodeTranscriptLeaf as C}from"../node-transcript.js";import{nodeContextLeaf as U}from"../node-context.js";import{ApiError as D}from"../../api/index.js";import{cliClient as x,cliCanvasSource as S,rethrowAsCliError as w}from"../api-client.js";import{RemoteCanvasSource as q}from"../../core/canvas/remote-canvas-source.js";import{kindsStateBlock as E,profilesStateBlock as z,resolveProfileViaDaemon as B}from"../profile/daemon-profiles.js";import{focusViewer as M,nodeInPane as W}from"../surface/node/placement.js";const K=_({name:"list",description:"list nodes on the canvas",whenToUse:"you want a flat roster of the nodes on the canvas, sliced by displayed name, status, kind, mode, lifecycle, profile, cwd, and graph scope (--under a node, for that node plus its subscription descendants). The filters AND together. Use `node inspect show` instead to drill into one node and its spine neighbors, `canvas dashboard` for the tree shape, and `canvas attention` to find nodes blocked on the user",help:{name:"node inspect list",summary:"list nodes on the canvas, filtered by any combination of attribute slices and a graph-scope (--under) that AND together",params:[{kind:"flag",name:"status",type:"string",required:!1,constraint:"Filter status (comma-separated for several; accepted values: active, idle, done, dead, canceled). NOTE: `active` means the engine process is live (never closed), NOT that the node is generating right now \u2014 an active node is usually dormant between turns. To tell working-vs-idle, check the pi session-file mtime or CPU, not status."},{kind:"flag",name:"kind",type:"string",required:!1,constraint:"Filter by persona kind (comma-separated for several). The <kinds> list below names every top-level installable kind; a registered sub-kind filters too by exact path even though it is not listed."},{kind:"flag",name:"mode",type:"string",required:!1,constraint:"Filter by mode (comma-separated for several; accepted values: base, orchestrator)."},{kind:"flag",name:"lifecycle",type:"string",required:!1,constraint:"Filter by lifecycle (comma-separated for several; accepted values: terminal, resident)."},{kind:"flag",name:"profile",type:"string",required:!1,constraint:"Filter by profile. On the local canvas, accepts a profile id or manifest name from the <profiles> list below, or a close-enough name that resolves to the nearest profile. Against a remote canvas, pass the exact profile id carried by its node rows."},{kind:"flag",name:"name",type:"string",required:!1,constraint:"Filter by the displayed node label (handle plus generated description) with the canvas browser\u2019s case-insensitive fuzzy subsequence match."},{kind:"flag",name:"cwd",type:"string",required:!1,constraint:"Filter to nodes pinned to this exact cwd (absolute path). Roster is canvas-wide (all cwds) by default."},{kind:"flag",name:"under",type:"string",required:!1,constraint:'Graph scope: restrict to this node and its subscription descendants (the sub-DAG reachable downward \u2014 its reports, theirs, \u2026). This is "one initiative / my subtree". ANDs with every attribute filter above, narrowing any of them to this subtree.'},{kind:"flag",name:"canvas",type:"string",required:!1,constraint:"Read from the named remote canvas target (see `crtr canvas config list`) instead of the local canvas. Overrides `crtr canvas use`."}],output:[{name:"nodes",type:"object[]",required:!0,constraint:"Rows include {node_id, name, kind, mode, lifecycle, status, cwd, profile_id, parent, created}. `name` is the displayed node label searched by --name and shown in canvas views. `profile_id` is the stable profile-directory id (null only for historical no-profile nodes)."}],outputKind:"object",effects:["Read-only: lists nodes through the daemon API."]},helpState:{leaf:h(async()=>(await Promise.all([E(),z()])).join(`
|
|
2
|
+
`),"leaf")},run:h(async n=>{const e=h(d=>{const b=n[d];return b!==void 0&&b!==""?b.split(",").map(v=>v.trim()).filter(v=>v!==""):void 0},"csv"),o=e("status"),s=e("kind"),u=e("mode"),i=e("lifecycle"),m=n.profile,c=n.name,l=n.cwd,r=n.under,p=S({canvasName:n.canvas}),a=p instanceof q?m:m===void 0?void 0:(await B(m)).id,f=r!==void 0&&r!=="";if(f&&await p.getNode(r).catch(w)===null)throw new k({error:"not_found",message:`no node: ${r}`,next:"List nodes with `crtr node inspect list`, then pass a real id to --under."});return{nodes:(await p.listNodes({...o!==void 0?{status:o}:{},...f?{under:r}:{}}).catch(w)).filter(d=>!(s!==void 0&&!s.includes(d.kind)||u!==void 0&&!u.includes(d.mode)||i!==void 0&&!i.includes(d.lifecycle)||a!==void 0&&d.profile_id!==a||l!==void 0&&l!==""&&d.cwd!==l)).map(d=>({...d,name:$(d)})).filter(d=>c===void 0||c===""||F(c,d.name))}},"run")}),j=new WeakSet,T=new WeakSet;async function N(n,e){const o=await n.getNode(e.node_id).catch(w);return{node_id:e.node_id,name:o?$(o):"(missing)",kind:o?.kind??"?",status:o?o.intent?`${o.status}/${o.intent}`:o.status:"?",active:e.active}}h(N,"enrichNeighbor");const V=_({name:"show",description:"show a node + its spine neighbors and drill-in pointers",whenToUse:"you want one node in depth \u2014 the debugging entrypoint: a glanceable meta slice, named spine neighbors, a pending-cron count, and exact drill-in paths. Use `node inspect list` for the flat roster or `canvas dashboard` for the whole-tree shape",help:{name:"node inspect show",summary:"show a node in depth \u2014 meta slice, named neighbors, pending-cron count, and drill-in pointers",params:[{kind:"positional",name:"node",required:!0,constraint:"Node id."},{kind:"flag",name:"canvas",type:"string",required:!1,constraint:"Read from the named remote canvas target (see `crtr canvas config list`) instead of the local canvas. Overrides `crtr canvas use`."}],output:[{name:"node",type:"object",required:!0,constraint:"The full node meta (system prompt + every telemetry field). The render surfaces a glanceable slice; `--json` carries the complete dump."},{name:"fault",type:"object",required:!0,constraint:"The active runtime fault projection, or null: {link, kind, retry: {disposition}, since}."},{name:"reports",type:"object[]",required:!0,constraint:"Who this node subscribes to (its reports/down), each enriched with {node_id, name, kind, status, active} \u2014 these are typically its spawned children."},{name:"managers",type:"object[]",required:!0,constraint:"Who subscribes to this node (its managers/up), same enriched shape."},{name:"pending_crons",type:"number",required:!0,constraint:"How many pending crons were created by this node. Inspect with `crtr cron list`."},{name:"paths",type:"object",required:!0,constraint:"Resolved on-disk locations: {context_dir, session_file} \u2014 read these directly to debug. Reports are documents: `crtr canvas read <node>/reports/<name>`."},{name:"follow_up",type:"string",required:!0,constraint:"The concrete next commands to drill deeper."}],outputKind:"object",effects:["Read-only: reads the node, its edges, and pending crons through crtrd."],preview:{suppressOutput:!0}},run:h(async n=>{const e=n.node,o=n.canvas,s=S({canvasName:o});if(s instanceof q){const t=await s.rawShow(e);if(t===null)throw new k({error:"not_found",message:`no node: ${e}`,next:"List nodes with `crtr node inspect list --canvas <name>`."});const y={...t};return j.add(y),y}const u=await s.getNode(e).catch(t=>w(t,"List nodes with `crtr node inspect list`."));if(u===null)throw new k({error:"not_found",message:`no node: ${e}`,next:"List nodes with `crtr node inspect list`."});const i=u,m=x(),c=await Promise.all((await s.subscriptionsOf(e)).map(t=>N(s,t))),l=await Promise.all((await s.subscribersOf(e)).map(t=>N(s,t))),r=(await m.listCrons({created_by:e}).catch(w)).filter(t=>t.created_by===e).length,p={context_dir:i.paths.context_dir,...i.pi_session_file!==void 0?{session_file:i.pi_session_file}:{}},a=[];a.push(`List the documents it owns (reports, plans, notes): \`crtr canvas list --owner ${e}\`.`),a.push(`Browse its context dir (and its subscriptions') in nvim: \`crtr node inspect context ${e}\`.`),p.session_file&&a.push(`Read the raw conversation transcript: ${p.session_file}`),a.push(`On-disk context dir (ls/read directly): ${p.context_dir}`),r>0&&a.push(`It created ${r} pending cron(s): \`crtr cron list\`.`),c.length>0&&a.push(`Drill into a child/report: \`crtr node inspect show <node_id>\` (${c.map(t=>t.node_id).join(", ")}).`),a.push(`Full machine dump (system prompt + all telemetry): \`crtr --json node inspect show ${e}\`.`);const f={node:i,fault:i.fault??null,reports:c,managers:l,pending_crons:r,paths:p,follow_up:a.join(`
|
|
3
|
+
`)};return i.profile_id!==null&&await m.getProfileEnvironment(i.profile_id).then(()=>!0,t=>t instanceof D&&t.status===400?!1:w(t))&&T.add(f),f},"run"),render:h(n=>{const e=n.node,o=String(e.node_id),s=e.pi_pid,i=j.has(n)?"remote (liveness not checked locally)":T.has(n)?"in a cloud sandbox (liveness not checked locally)":A(s)?"alive":"dead",m=e.intent?`/${String(e.intent)}`:"",c=n.fault,l=[];l.push(`# ${$(e)} (${o})`);const r=[`- kind/mode/lifecycle: ${e.kind} / ${e.mode} / ${e.lifecycle}`,`- status: ${e.status}${m}`,...c==null?[]:[`- fault: ${String(c.kind)} / ${String(c.retry?.disposition)} since ${String(c.since)}`],`- broker pid: ${s??"(none)"} \u2014 ${i}`,`- cwd: ${e.cwd}`,`- host: ${e.host_kind}`+(e.profile_id?` \xB7 profile ${e.profile_id}`:""),`- cycles: ${e.cycles} \xB7 created ${e.created}`],p=e.machine;p&&r.push(`- machine: ${p.name??p.id}`),e.parent&&r.push(`- parent: ${e.parent}`),r.push(`- creator: ${e.creator??"an external process"}`),e.waiting_for&&r.push(`- waiting for message: ${e.waiting_for}`),l.push(r.join(`
|
|
4
|
+
`));const a=h((f,g)=>{if(g.length===0)return`${f}: none`;const t=["node_id","name","kind","status","active"],y=`| ${t.join(" | ")} |`,d=`| ${t.map(()=>"---").join(" | ")} |`,b=g.map(v=>`| ${t.map(R=>String(v[R]??"").replace(/\|/g,"\\|").replace(/\n/g," ")).join(" | ")} |`).join(`
|
|
5
|
+
`);return`${g.length} ${f}:
|
|
6
6
|
|
|
7
|
-
${
|
|
8
|
-
${
|
|
9
|
-
${
|
|
7
|
+
${y}
|
|
8
|
+
${d}
|
|
9
|
+
${b}`},"table");return l.push(a("reports (down \u2014 subscriptions, usually children)",n.reports)),l.push(a("managers (up \u2014 subscribers)",n.managers)),l.push(`${n.pending_crons} pending cron(s)`),l.push(`Drill deeper:
|
|
10
10
|
${String(n.follow_up)}`),l.join(`
|
|
11
11
|
|
|
12
|
-
`)},"render")}),
|
|
12
|
+
`)},"render")}),de=_({name:"fork",description:"fork a node into an independent idle root with the same conversation and durable context",whenToUse:"a conversation has already accumulated the context you want, and you want a new user-driven branch beside it without sending a prompt or inheriting any graph-management responsibility. This copies the conversation and durable context, then waits for the fork\u2019s first real user message to supply its mandate. Use `node new --fork-from` instead when spawning a managed worker with an immediate task",help:{name:"node fork",summary:"create an independent resident root from a node\u2019s conversation and durable context, with no kickoff prompt or model turn",params:[{kind:"flag",name:"node",type:"string",required:!1,constraint:"Source node id. Mutually exclusive with --pane; one of them is required."},{kind:"flag",name:"pane",type:"string",required:!1,constraint:"tmux pane showing the source node. Mutually exclusive with --node; one of them is required. The prefix menu passes this for you and the new viewer splits beside this pane."}],output:[{name:"node_id",type:"string",required:!0,constraint:"The new independent root id."},{name:"focused",type:"boolean",required:!0,constraint:"True when a new viewer pane opened beside the caller; false outside tmux."},{name:"session",type:"string",required:!1,constraint:"The tmux session containing the new viewer, when one opened."}],outputKind:"object",effects:["Creates a resident base-mode root with the source node\u2019s copied pi conversation, cwd, profile, kind, model override, and durable context files. Top-level initial-prompt.md, yield-message.md, result.json, and the jobs/ folder of background bash jobs are omitted.","Copies no parent, subscriptions, subscribers, children, crons, worktree, situational context, or lifecycle responsibility. Sends no prompt and consumes no model turn; the first real user message becomes the fork\u2019s mandate.","Inside tmux, opens and focuses a surface-attach viewer as an even-horizontal split in the source pane\u2019s window. Outside tmux, the root is still created but no interactive fallback opens."]},run:h(async n=>{O("crtr:act","crtr node fork");const e=n.pane,o=n.node;if(o!==void 0&&e!==void 0)throw new k({error:"conflicting_target",message:"--node and --pane are mutually exclusive",next:"Pass the source node id or its viewer pane, not both."});let s=o;if(s===void 0&&e!==void 0&&(s=W(e)),s===void 0||s==="")throw new k({error:"no_node",message:"no source node was provided or found in the pane",next:"Pass --node <id>, or --pane <pane-id> for a pane showing a node."});const u=await x().forkNode(s).catch(w),i=await M(u.node_id,{cwd:u.cwd,name:u.name,...e!==void 0?{pane:e}:{},newPane:!0});return{node_id:u.node_id,focused:i.focused,session:i.session}},"run"),render:h(n=>{const e=n.focused===!0?` Viewer opened beside the source${n.session?` in session ${n.session}`:""}.`:" No viewer opened because no tmux pane was available.";return`Forked independent idle root ${n.node_id}.${e} It will make no model call until its first real user message.`},"render")}),ce=I({name:"inspect",description:"read one node \u2014 its graph position, conversation, and context dir",whenToUse:"reading everything about ONE node you can name: enumerate the roster (`list`), inspect a node and its spine neighbors (`show`), or browse its on-disk context dir (`context`). The documents a node owns are `crtr canvas list --owner <id>`. Use `canvas dashboard` instead to render the whole tree SHAPE, or `canvas attention` to find which nodes are blocked on the user",help:{name:"node inspect",summary:"read one node (or the roster) \u2014 topology, conversation, and context dir",model:"Inspection is read-only and never revives a node. The roster is the selection surface; one-node metadata points to progressively heavier views: a parsed broker snapshot, rendered conversation, or context browser."},children:[K,V,L,C,U]});export{de as nodeFork,ce as nodeInspect};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var W=Object.defineProperty;var m=(o,n)=>W(o,"name",{value:n,configurable:!0});import{dirname as b,join as h,relative as X,resolve as S}from"node:path";import{renameSync as w}from"node:fs";import{defineLeaf as q}from"../../core/command.js";import{general as j,notFound as d}from"../../core/errors.js";import{listAllMarketplaces as x,listAllPlugins as Y,findMarketplaceByName as y}from"../../core/resolver.js";import{resolveScopeArg as C,requireScopeRoot as R,marketplacesDir as Z,pluginsDir as ee}from"../../core/scope.js";import{installsLiveInAppBlock as L}from"../../shared/env.js";import{addAppMarketplace as te,removeAppMarketplace as oe}from"./app-installs.js";import{updateConfig as D,updateState as G,ensureScopeInitialized as ne,readConfig as re}from"../../core/config.js";import{pathExists as M,ensureDir as _,removePath as f,isSymlink as ae,nowIso as A,readSymlinkTarget as ie}from"../../core/fs-utils.js";import{clone as K,deriveNameFromUrl as se,currentSha as O,gitSync as B,isGitRepo as E}from"../../core/git.js";import{readMarketplaceManifest as P,readPluginManifest as F}from"../../core/manifest.js";import{assertPluginCandidateValid as ce,isMarketplaceRelativeSource as pe}from"./plugin-manage.js";import{resolveInstallScope as le}from"./shared.js";async function ue(o){const{url:n,ref:i,scope:t}=o,s=R(t);await ne(t,s);const l=Z(t);_(l);const c=h(l,`.${se(n)}.${process.pid}.${Date.now()}.candidate`);K(n,c,{depth:1,ref:i!==void 0?i:void 0});const p=P(c);if(!p)throw f(c),d(`marketplace manifest not found at ${c}/.crouter-marketplace/marketplace.json \u2014 not a valid marketplace`);const u=p.name,e=h(l,u),a=i!==void 0?i:"main";try{await D(t,r=>{r.marketplaces[u]={url:n,ref:a,installed_at:A()}})}catch(r){throw f(c),r}return M(e)?H([{active:e,candidate:c,previous:`${c}.previous`}]):w(c,e),{name:u,scope:t,path:e}}m(ue,"addMarketplace");const De=q({name:"add",description:"add a marketplace by git URL",whenToUse:"registering a new marketplace source repo so its plugins appear in marketplace browse output and become installable by marketplace/plugin ref",help:{name:"pkg market add",summary:"add a marketplace by git URL",params:[{kind:"positional",name:"url",type:"string",required:!0,constraint:"Git URL of the marketplace repo."},{kind:"flag",name:"ref",type:"string",required:!1,constraint:"Git ref to track. Default: main."},{kind:"flag",name:"scope",type:"enum",choices:["user","project"],required:!1,constraint:"Default: project if available, else user."}],output:[{name:"name",type:"string",required:!0,constraint:"Marketplace name as declared in marketplace.json."},{name:"scope",type:"string",required:!0,constraint:"Scope the marketplace was added into."},{name:"path",type:"string",required:!0,constraint:"Absolute path to the cloned marketplace directory."}],outputKind:"object",effects:["Clones the marketplace repo. Registers the marketplace in config.json."]},run:m(async o=>{const n=o.url,i=o.ref,t=o.scope;return L()?await te(n,i):ue({url:n,ref:i,scope:le(t)})},"run")}),Ae=q({name:"remove",description:"remove a marketplace",whenToUse:"unregistering a marketplace source: deletes the source clone and any plugins installed from it in the same scope",help:{name:"pkg market remove",summary:"remove a marketplace and its directory",params:[{kind:"positional",name:"name",type:"string",required:!0,constraint:"Marketplace name to remove."},{kind:"flag",name:"scope",type:"enum",choices:["user","project"],required:!1,constraint:"Narrows resolution."}],output:[],outputKind:"object",effects:["Deletes the marketplace directory. Removes the entry from config.json. Removes plugin files and config entries sourced from that marketplace in the same scope."]},run:m(async o=>{const n=o.name;if(L())return await oe(n);const i=o.scope;let t,s;if(i!==void 0){const a=C(i);if(a!=="all"&&a!=="builtin"){const r=a,g=y(n,r);if(!g)throw d(`marketplace not found: ${n} (scope: ${r})`);t=r,s=g.root}else{const r=y(n);if(!r)throw d(`marketplace not found: ${n}`);t=r.scope,s=r.root}}else{const a=y(n);if(!a)throw d(`marketplace not found: ${n}`);t=a.scope,s=a.root}const l=t,c=R(l),p=ee(l),u=re(l),e=[];for(const[a,r]of Object.entries(u.plugins))r.source_marketplace===n&&e.push(a);for(const a of e){const r=h(p,a);f(r)}return f(s),await D(l,a=>{delete a.marketplaces[n];for(const r of e)delete a.plugins[r]}),{}},"run")});function z(o,n,i,t){try{K(o,t,{depth:1,ref:n})}catch(s){throw f(t),s}return{active:i,candidate:t,previous:`${t}.previous`}}m(z,"stageGitRoot");function H(o){const n=[],i=[];try{for(const t of o){if(M(t.previous))throw j(`prior staged backup remains at ${t.previous}`);w(t.active,t.previous),n.push(t)}for(const t of o)w(t.candidate,t.active),i.push(t)}catch(t){for(const s of[...i].reverse())w(s.active,s.candidate);for(const s of[...n].reverse())w(s.previous,s.active);throw t}for(const t of o)f(t.previous)}m(H,"activateStagedRoots");function V(o,n,i){return{plugin:{...o,root:n,manifest:i},scopeRoot:b(b(o.root))}}m(V,"candidatePlugin");async function de(o){const n=O(o.root)??"",i=Y().filter(u=>u.scope===o.scope&&u.sourceMarketplace===o.name),t=[],s=[];let l,c;const p=[];try{if(E(o.root)){const e=h(b(o.root),`.${o.name}.${process.pid}.${Date.now()}.candidate`);c=z(o.url,o.ref,o.root,e),s.push(e);const a=P(e);if(a===null)throw d(`marketplace manifest not found in candidate checkout: ${e}/.crouter-marketplace/marketplace.json`);l=a,t.push(c)}else{const e=P(o.root);if(e===null)throw d(`marketplace manifest not found after refresh: ${o.root}/.crouter-marketplace/marketplace.json`);l=e}for(const e of i){if(ae(e.root)){if(c===void 0)continue;const $=l.plugins.find(Q=>Q.name===e.name);if($===void 0||!pe($.source))throw j(`marketplace candidate removes relative-source plugin "${e.name}" while it is installed`);const I=ie(e.root);if(I===null)throw j(`installed marketplace plugin "${e.name}" has no readable symlink target`);const N=X(o.root,S(b(e.root),I)),k=S(c.candidate,$.source);if(k!==S(c.candidate,N))throw j(`marketplace candidate moves installed relative-source plugin "${e.name}" from ${N} to ${$.source}`);if(!M(k))throw d(`marketplace candidate source path does not exist for plugin "${e.name}": ${k}`);const T=F(k);if(T===null)throw d(`plugin manifest not found in marketplace candidate: ${k}/.crouter-plugin/plugin.json`);p.push(V(e,k,T));continue}if(!M(e.root)||!E(e.root))continue;const a=B(["config","--get","remote.origin.url"],e.root).stdout.trim(),r=B(["symbolic-ref","--short","HEAD"],e.root).stdout.trim();if(a===""||r==="")continue;const g=e.scope==="project"?R("project"):R("user"),v=h(g,"tmp",`${e.name}.${process.pid}.${Date.now()}.candidate`);_(h(g,"tmp"));const J=z(a,r,e.root,v);s.push(v);const U=F(v);if(U===null)throw d(`plugin manifest not found in update candidate: ${v}/.crouter-plugin/plugin.json`);p.push(V(e,v,U)),t.push(J)}for(const e of p)await ce(e.plugin.manifest,e.plugin.root,e.plugin.scope,e.scopeRoot,`${e.plugin.root}/.crouter-plugin/plugin.json`,p);H(t),await G(o.scope,e=>{e.marketplaces[o.name]===void 0&&(e.marketplaces[o.name]={}),e.marketplaces[o.name].last_updated=A()});for(const e of i){const a=l.plugins.find(r=>r.name===e.name);a?.version!==void 0&&await D(e.scope,r=>{r.plugins[e.name]!==void 0&&(r.plugins[e.name].version=a.version)}),await G(e.scope,r=>{r.plugins[e.name]===void 0&&(r.plugins[e.name]={}),r.plugins[e.name].last_updated=A()})}const u=O(o.root)??"";return{name:o.name,updated:n!==u,sha:u}}finally{for(const u of s)f(u)}}m(de,"updateMarketplaceTarget");const Pe=q({name:"update",description:"replace marketplace source with its latest revision",whenToUse:"refreshing one named marketplace source from git, or all registered marketplace sources when no name is given; also updates installed plugins sourced from refreshed marketplaces",help:{name:"pkg market update",summary:"refresh one or all registered marketplaces",params:[{kind:"flag",name:"name",type:"string",required:!1,constraint:"Marketplace name to update. Omit to update all registered marketplaces."},{kind:"flag",name:"scope",type:"enum",choices:["user","project"],required:!1,constraint:"Narrows resolution."}],output:[{name:"updated",type:"object[]",required:!0,constraint:"One entry per marketplace processed: {name, updated, sha}."},{name:"skipped",type:"object[]",required:!1,constraint:"Present when a marketplace checkout has no registered url: {name, reason}. It is not refreshed."}],outputKind:"object",effects:["Stages and validates marketplace and sourced-plugin revisions before atomically activating them, replacing each checkout even at an unchanged revision \u2014 local modifications inside those directories are discarded. `updated` reports whether the revision moved, not whether the checkout was replaced. Updates installed plugin content/version for plugins sourced from refreshed marketplaces."]},run:m(async o=>{const n=o.name,i=o.scope,t=i===void 0?void 0:C(i),s=n===void 0?t===void 0||t==="all"?x():t==="builtin"?[]:x().filter(p=>p.scope===t):(()=>{const p=t===void 0||t==="all"||t==="builtin"?y(n):y(n,t);if(p===null)throw d(`marketplace not found: ${n}${t===void 0||t==="all"||t==="builtin"?"":` (scope: ${t})`}`);return[p]})(),l=[],c=[];for(const p of s){if(p.url===""){c.push({name:p.name,reason:`no url registered for ${p.root}; re-add it with \`crtr pkg market add <url>\``});continue}l.push(await de(p))}return c.length===0?{updated:l}:{updated:l,skipped:c}},"run")});export{ue as addMarketplace,De as marketAdd,Ae as marketRemove,Pe as marketUpdate};
|
|
@@ -16,4 +16,4 @@ ${m.map(h=>`- ${h}`).join(`
|
|
|
16
16
|
${y.map(m=>`- ${m}`).join(`
|
|
17
17
|
`)}`,{issues:y});await Bn(e,n,t,i,o,r);const p=v(n,"memory"),k=on(t,i,{candidate:e});for(const m of nn(p,h=>h.endsWith(".md"),h=>h.startsWith("."))){let h;try{h=cn(Ze(m)).data}catch(R){throw f(`plugin memory document ${_(n,m)} has invalid YAML frontmatter: ${R instanceof Error?R.message.split(`
|
|
18
18
|
`)[0]:String(R)}`)}const w=sn(h);if(w!==null)throw f(`plugin memory document ${_(n,m)} is invalid: ${w}`);for(const R of an(h?.extensions,k))throw f(`plugin memory document ${_(n,m)} is invalid: ${R.path}: ${R.message}`)}return In(e,n,t,o,a)}d(P,"assertPluginCandidateValid");function Dn(e){return{kind:"http",endpoint:new URL(e.endpoint).origin,...e.authEnv!==void 0?{authEnv:e.authEnv}:{}}}d(Dn,"invocationTransport");async function Nn(e,n,t,i,o){const r=await P(o,t,n,i,`${t}/.crouter-plugin/plugin.json`),a={name:e,scope:n,root:t,manifest:o,enabled:!0},[l,c]=await Promise.all([N(),F()]),s=X(a,new Set(D),l,c);if(s.issues.length>0)throw z(`bundle staged package for "${e}" is invalid`,s.issues);return r}d(Nn,"validateStagedBundle");function be(e){return e.sourceMarketplace!==void 0||Q(e.root)||K(e.root)}d(be,"isSourceInstalled");function $e(e){throw f(`HTTP plugin "${e}" uses the removed commands-only endpoint format`,{next:`Run \`crtr pkg plugin remove ${e}\`, then reinstall it with \`crtr pkg plugin install --name ${e} --endpoint <archive-url>\`.`})}d($e,"rejectLegacyHttpPlugin");function Fn(e,n,t){if(!$(t))return;const i=A(e,n);if(i?.manifest.bundle!==void 0)return i;throw i?.manifest.transport?.kind==="http"&&i!==void 0&&!be(i)&&$e(e),f(`plugin "${e}" already exists at ${t}; run \`crtr pkg plugin remove ${e}\` before installing the archive plugin.`)}d(Fn,"existingBundleRoot");function je(e,n,t,i){const o=ke(e,n.endpoint,n.authEnv),r={endpoint:o.endpoint,...o.authEnv!==void 0?{authEnv:o.authEnv}:{}},a=v(C(t),e);return Fn(e,t,a),{bundle:r,transport:Dn(r),scopeRootPath:i,root:a}}d(je,"resolveBundleTarget");function Pe(e,n){return{name:e,endpoint:n.endpoint,...n.authEnv!==void 0?{authEnv:n.authEnv}:{}}}d(Pe,"fetchTarget");const Un=6e4,Vn=1e4;async function Re(e,n,t,i){const o=n==="project"?G():S();return L(v(o,"tmp")),Ye(le(o,e),()=>i(o),{timeoutMs:t,timeoutError:d(()=>f(`timed out waiting for another crtr process to finish replacing plugin "${e}"`,{next:`Re-run once that process has finished, or check for a stalled crtr holding ${le(o,e)}.`}),"timeoutError")})}d(Re,"withBundleSwapLock");async function xe(e,n,t,i){return Re(e,t,Un,async o=>{const r=je(e,n,t,o),a=await he(Pe(e,r.bundle));if(a.status!==200){const l=`HTTP plugin bundle fetch failed for "${e}": ${a.message}`;throw a.status==="auth_env_missing"?b(l):a.status==="cli_unreachable"?Ue(l):f(l)}return Se(e,t,r,a.raw,a.etag,i)})}d(xe,"replaceBundlePlugin");async function Mt(e,n,t,i){return Re(e,t,Vn,async o=>{try{const r=je(e,n,t,o),a=i.conditional?Ke(t).plugins[e]?.etag:void 0,l={...a!==void 0?{ifNoneMatch:a}:{},...i.timeoutMs!==void 0?{timeoutMs:i.timeoutMs}:{}},c=await he(Pe(e,r.bundle),l);if(c.status===304)return;if(c.status!==200)throw f(`HTTP plugin bundle revalidation failed for "${e}": ${c.message}`);const s=vn(c.raw);if(kn(e,t,r.root,s)){await wn(t,e,c.etag,{swapped:!1});return}return await Se(e,t,r,c.raw,c.etag,i,s)}finally{await On(t,e)}})}d(Mt,"revalidateBundlePlugin");async function On(e,n){await O(e,t=>{t.plugins[n]===void 0&&(t.plugins[n]={}),t.plugins[n].checked_at=Y()})}d(On,"recordPluginCheck");async function Se(e,n,t,i,o,r,a){const{bundle:l,transport:c,scopeRootPath:s,root:u}=t,y=await Kn(e,i,{scope:n,scopeRootPath:s,root:u,bundle:l,transport:c,etag:o,enable:r.enable,...a!==void 0?{version:a}:{}}),{validated:p,version:k,staged:m}=y,h=await Z(e,n);if(h===void 0)throw f(`bundle plugin "${e}" has no staged command report`);const w=await ee(e,n);return{name:e,scope:n,path:u,transport:"http",version:k,docs:p.memory.length,kinds:Object.keys(p.kinds??{}).length,pageComponents:(p.page_components??[]).length,objectKinds:Object.keys(p.object_kinds??{}).length,scopes:(p.scopes??[]).length,commands:h,...w!==void 0?{hooks:w}:{},...m!==void 0?{memory:m}:{}}}d(Se,"applyBundleArchive");async function Lt(e){const[n,t]=await Promise.all([N(),F()]);return bn(e,{reservedCoreNames:new Set(D),coreCommandPaths:n,extensibleCoreBranches:t})}d(Lt,"validatePluginArchive");async function Kn(e,n,t){const[i,o]=await Promise.all([N(),F()]);return yn(e,n,{...t,validation:{reservedCoreNames:new Set(D),coreCommandPaths:i,extensibleCoreBranches:o},validateStaged:d((r,a)=>Nn(e,t.scope,r,t.scopeRootPath,a),"validateStaged"),invalid:d((r,a)=>z(r,a),"invalid")})}d(Kn,"installPluginArchive");async function Wn(e,n,t,i){const o=ke(e,n,t);return xe(e,{endpoint:o.endpoint,...o.authEnv!==void 0?{authEnv:o.authEnv}:{}},i,{enable:!0})}d(Wn,"installHttpPlugin");function zn(e){if(e.startsWith("./")||e.startsWith("../")||e.startsWith("/"))return{kind:"local",value:e};if(ve(e))return{kind:"git",value:e};const n=e.split("/");if(n.length===2&&n[0]!==""&&n[1]!=="")return{kind:"marketplace",value:{marketplace:n[0],plugin:n[1]}};throw b(`invalid plugin install ref: ${e}
|
|
19
|
-
Accepted forms: marketplace/plugin, git URL (https://, ssh://, git@, file://, or *.git), or local path starting ./, ../, or /. Bare plugin names are not install refs.`)}d(zn,"classifyInstallRef");function Ee(e){return e.startsWith("./")||e.startsWith("../")||!Be(e)&&!ve(e)}d(Ee,"isMarketplaceRelativeSource");async function Te(e,n,t){const i=n.get(e);if(i!==void 0)return i;const o=Oe(e);if(o===null){if(t.strict)throw g(`marketplace not found: ${e}`);return null}const r=ue(o.root);if(r===null)throw g(`marketplace manifest not found: ${o.root}/.crouter-marketplace/marketplace.json`);if(!Q(o.root)){const s={marketplace:o,manifest:r,pull:{updated:!1,sha:T(o.root)??""}};return n.set(e,s),s}const a=T(o.root),l=v(ie(o.root),`.${e}.${process.pid}.${Date.now()}.candidate`),c=`${l}.previous`;try{W(o.url,l,{ref:o.ref,depth:1});const s=ue(l);if(s===null)throw g(`marketplace manifest not found in candidate checkout: ${l}/.crouter-marketplace/marketplace.json`);const u=ae().filter(p=>p.sourceMarketplace===e&&K(p.root));for(const p of u){const k=s.plugins.find(Me=>Me.name===p.name);if(k===void 0||!Ee(k.source))throw f(`marketplace candidate removes relative-source plugin "${p.name}" while it is installed`);const m=Xe(p.root);if(m===null)throw f(`installed marketplace plugin "${p.name}" has no readable symlink target`);const h=_(o.root,V(ie(p.root),m)),w=V(l,k.source);if(w!==V(l,h))throw f(`marketplace candidate moves installed relative-source plugin "${p.name}" from ${h} to ${k.source}`);if(!$(w))throw g(`marketplace candidate source path does not exist for plugin "${p.name}": ${w}`);const R=x(w);if(R===null)throw g(`plugin manifest not found in marketplace candidate: ${w}/.crouter-plugin/plugin.json`);const Ce=p.scope==="project"?M("project"):S();await P(R,w,p.scope,Ce,`${w}/.crouter-plugin/plugin.json`)}j(o.root,c);try{j(l,o.root)}catch(p){throw j(c,o.root),p}E(c);for(const p of u){const k=s.plugins.find(m=>m.name===p.name);await qe(p.scope,p.name,k.version??p.manifest.version)}await O(o.scope,p=>{p.marketplaces[e]===void 0&&(p.marketplaces[e]={}),p.marketplaces[e].last_updated=Y()});const y={marketplace:o,manifest:s,pull:{updated:a!==T(o.root),sha:T(o.root)??""}};return n.set(e,y),y}finally{E(l),$(c)&&!$(o.root)&&j(c,o.root)}}d(Te,"refreshMarketplace");async function qe(e,n,t){await I(e,i=>{const o=i.plugins[n];o!==void 0?t!==void 0&&(o.version=t):i.plugins[n]={enabled:!0,version:t}}),await O(e,i=>{i.plugins[n]===void 0&&(i.plugins[n]={}),i.plugins[n].last_updated=Y()})}d(qe,"updatePluginVersion");async function Gn(e,n,t){const i=t==="project"?G():S();await J(t,i);const o=C(t),r=tn(e),a=v(i,"tmp",`${r}.${process.pid}.${Date.now()}`);L(v(i,"tmp"));try{W(e,a,{ref:n,depth:1});const l=x(a);if(l===null)throw f(`cloned repo does not contain a valid .crouter-plugin/plugin.json: ${e}`);const c=await P(l,a,t,i,`${e}/.crouter-plugin/plugin.json`),s=v(o,l.name);if($(s))throw f(`plugin "${l.name}" is already installed at ${s}`);return L(o),j(a,s),await I(t,u=>{u.plugins[l.name]={enabled:!0,version:l.version}}),{name:l.name,scope:t,path:s,...c!==void 0?{memory:c}:{}}}finally{E(a)}}d(Gn,"installFromGit");async function Jn(e,n){const t=V(e),i=x(t);if(i===null)throw g(`plugin manifest not found at ${t}/.crouter-plugin/plugin.json`);const o=n==="project"?G():S(),r=await P(i,t,n,o,`${t}/.crouter-plugin/plugin.json`,void 0,"linked");await J(n,o);const a=v(C(n),i.name);if($(a))throw f(`plugin "${i.name}" is already installed at ${a}`);return ce(t,a),await I(n,l=>{l.plugins[i.name]={enabled:!0,version:i.version}}),{name:i.name,scope:n,path:a,...r!==void 0?{memory:r}:{}}}d(Jn,"installFromLocal");async function Yn(e,n){const t=await Te(e.marketplace,new Map,{strict:!0});if(t===null)throw g(`marketplace not found: ${e.marketplace}`);const i=t.manifest.plugins.find(s=>s.name===e.plugin);if(i===void 0)throw g(`plugin "${e.plugin}" not found in marketplace "${e.marketplace}"`);const o=M(n);await J(n,o);const r=v(C(n),e.plugin);if($(r))throw f(`plugin "${e.plugin}" is already installed at ${r}`);let a,l;if(Ee(i.source)){const s=v(t.marketplace.root,i.source);if(!$(s))throw g(`plugin source path does not exist: ${s}`);const u=x(s);if(u===null)throw g(`plugin manifest not found at ${s}/.crouter-plugin/plugin.json`);l=await P(u,s,n,o,`${s}/.crouter-plugin/plugin.json`,void 0,"linked"),ce(s,r),a=u}else{const s=v(o,"tmp",`${e.plugin}.${process.pid}.${Date.now()}`);L(v(o,"tmp"));try{W(i.source,s,{depth:1});const u=x(s);if(u===null)throw g(`plugin manifest not found at ${s}/.crouter-plugin/plugin.json`);l=await P(u,s,n,o,`${s}/.crouter-plugin/plugin.json`),L(C(n)),j(s,r),a=u}finally{E(s)}}const c=i.version??a.version;return await I(n,s=>{const u={enabled:!0,source_marketplace:e.marketplace};c!==void 0&&(u.version=c),s.plugins[e.plugin]=u}),{name:e.plugin,scope:n,path:r,...l!==void 0?{memory:l}:{}}}d(Yn,"installFromMarketplace");async function Qn(e){if(K(e.root)){const l=x(e.root);if(l===null)throw g(`plugin manifest not found at ${e.root}/.crouter-plugin/plugin.json`);const c=e.scope==="project"?M("project"):S(),s=await P(l,e.root,e.scope,c,`${e.root}/.crouter-plugin/plugin.json`,void 0,"linked");return{updated:!1,sha:T(e.root)??"",manifest:l,...s!==void 0?{memory:s}:{}}}if(!Q(e.root)){const l=x(e.root);if(l===null)throw g(`plugin manifest not found at ${e.root}/.crouter-plugin/plugin.json`);const c=e.scope==="project"?M("project"):S(),s=await P(l,e.root,e.scope,c,`${e.root}/.crouter-plugin/plugin.json`);return{updated:!1,sha:"",manifest:l,...s!==void 0?{memory:s}:{}}}const n=de(["config","--get","remote.origin.url"],e.root).stdout.trim();if(n==="")throw f(`plugin "${e.name}" has no origin remote to stage an update from`);const t=de(["symbolic-ref","--short","HEAD"],e.root).stdout.trim();if(t==="")throw f(`plugin "${e.name}" is detached at its installed revision and has no tracked branch to update`);const i=e.scope==="project"?M("project"):S(),o=v(i,"tmp",`${e.name}.${process.pid}.${Date.now()}.candidate`),r=`${o}.previous`,a=T(e.root);L(v(i,"tmp"));try{W(n,o,{ref:t,depth:1});const l=x(o);if(l===null)throw g(`plugin manifest not found in update candidate: ${o}/.crouter-plugin/plugin.json`);const c=await P(l,o,e.scope,i,`${o}/.crouter-plugin/plugin.json`);j(e.root,r);try{j(o,e.root)}catch(u){throw j(r,e.root),u}E(r);const s=T(e.root)??"";return{updated:a!==s,sha:s,manifest:l,...c!==void 0?{memory:c}:{}}}finally{E(o),$(r)&&!$(e.root)&&j(r,e.root)}}d(Qn,"updateGitPluginCandidate");async function Ae(e,n,t){if(e.manifest.provider!==void 0)return{name:e.name,transport:"http",updated:!1,warnings:[`"${e.name}" is a capability provider bundle; the runtime refreshes it on grant sync`]};const i=be(e);if(!i&&e.manifest.bundle!==void 0){const u=await xe(e.name,e.manifest.bundle,e.scope,{enable:e.enabled});return{name:e.name,transport:"http",updated:!0,version:u.version,docs:u.docs,kinds:u.kinds,pageComponents:u.pageComponents,objectKinds:u.objectKinds,scopes:u.scopes,commands:u.commands,...u.hooks!==void 0?{hooks:u.hooks}:{},...u.memory!==void 0?{memory:u.memory}:{}}}e.manifest.transport?.kind==="http"&&!i&&$e(e.name);let o,r=!1;if(e.sourceMarketplace!==void 0){const u=await Te(e.sourceMarketplace,n,t);u!==null&&(o=u.manifest.plugins.find(p=>p.name===e.name)?.version,r=u.pull.updated)}const a=await Qn(e);await qe(e.scope,e.name,o??a.manifest.version);const l=await Z(e.name,e.scope),c=await ee(e.name,e.scope),s=[...we(a.manifest),...await te(a.manifest)];return{name:e.name,...e.manifest.transport!==void 0?{transport:e.manifest.transport.kind==="machine"?"http":e.manifest.transport.kind}:{},updated:r||a.updated,sha:a.sha,...l!==void 0?{commands:l}:{},...c!==void 0?{hooks:c}:{},...a.memory!==void 0?{memory:a.memory}:{},...s.length>0?{warnings:s}:{}}}d(Ae,"updateOnePlugin");async function q(e){const n=await He().documents.reconcilePackages().catch(i=>Ie(i)),t=n.conflicts.find(i=>i.plugin===e);if(t)throw new Ve("conflict",`plugin "${e}" is installed but its documents are not on the canvas: ${t.message}`,En.GENERAL,{plugin:e,next:"Uninstall the other package providing that plugin name, then run `crtr pkg plugin update --name "+e+"`."});return n}d(q,"reconcilePluginDocuments");function Xn(e,n){const t=[...(e.kinds?.refused??[]).filter(o=>o.plugin===n).map(o=>`object kind ${o.kind} not registered: ${o.message}`),...(e.kinds?.invalid??[]).filter(o=>o.plugin===n).map(o=>`object kinds and scopes not applied; the plugin holds no app token until this is fixed: ${o.error}`)],i=e.tokens?.granted.find(o=>o.plugin===n);return{warnings:t,...i!==void 0?{appScopes:i.scopes}:{}}}d(Xn,"pluginObjectReport");function U(e,n,t){const{warnings:i,appScopes:o}=Xn(n,t),a=[...e.warnings??[],...i];return{...e,...a.length>0?{warnings:a}:{},...o!==void 0?{appScopes:o}:{}}}d(U,"withObjectReport");const _t=B({name:"install",description:"install from a ref or HTTP endpoint",whenToUse:"installing one plugin from a marketplace ref, git URL, local path, or an HTTP directory-archive endpoint",help:{name:"pkg plugin install",summary:"install a plugin from a ref or HTTP endpoint",params:[{kind:"positional",name:"install-ref",type:"string",required:!1,constraint:"Plugin install ref. Provide exactly one of INSTALL-REF or --endpoint. Accepted ref forms: marketplace/plugin; git URL starting https://, ssh://, git@, file://, or ending .git; local path starting ./, ../, or /."},{kind:"flag",name:"endpoint",type:"string",required:!1,constraint:"HTTP plugin directory-archive endpoint. Provide exactly one of --endpoint or INSTALL-REF. Must be an absolute https: URL; http: is permitted only for localhost, any *.localhost host, 127.0.0.1, [::1], ::1, or host.docker.internal. Credentials and fragments are rejected."},{kind:"flag",name:"name",type:"string",required:!1,constraint:"Required with --endpoint and rejected without it. Lowercase kebab-case plugin handle."},{kind:"flag",name:"auth-env",type:"string",required:!1,constraint:"Optional environment variable holding the HTTP bearer token. Accepted only with --endpoint; its value is never stored."},{kind:"flag",name:"scope",type:"enum",choices:["user","project"],required:!1,constraint:"Default: project if available, else user."},{kind:"flag",name:"ref",type:"string",required:!1,constraint:"Git ref (branch/tag) for git URL installs. Rejected with --endpoint; ignored for marketplace and local path refs."}],output:[{name:"name",type:"string",required:!0,constraint:"Plugin name as installed."},{name:"scope",type:"string",required:!0,constraint:"Scope the plugin was installed into."},{name:"path",type:"string",required:!0,constraint:"Absolute path to the installed plugin directory."},{name:"transport",type:"string",required:!1,constraint:"exec or http when the plugin declares commands. Always http for an --endpoint install."},{name:"version",type:"string",required:!1,constraint:"First 12 hex characters of the fetched archive SHA-256 for an --endpoint install."},{name:"docs",type:"integer",required:!1,constraint:"Memory document count written from an --endpoint archive."},{name:"kinds",type:"integer",required:!1,constraint:"Kind-registry entry count declared by an --endpoint archive\u2019s bundle.json."},{name:"pageComponents",type:"integer",required:!1,constraint:"Page-component registration count declared by an --endpoint archive\u2019s bundle.json."},{name:"commands",type:"object",required:!1,constraint:"Present only when the plugin declares a command manifest. {mounts: string[] (accepted command paths now live for the next invocation), issues: object[] (typed validation issues that rejected a contribution \u2014 {code, path?, message, received, expected, next})}. Validated statically; commands are never executed."},{name:"hooks",type:"object",required:!1,constraint:"Present only when the plugin declares hooks. {manifestPath?, executablePath?, declarations: {target, phase, op, description, effects}[], lifecycle?: {event, phase, op, description, effects}[], issues: object[], trust: string}. Command targets, lifecycle events, and replacement collisions are validated statically; hook executables are never run."},{name:"objectKinds",type:"integer",required:!1,constraint:"Canvas object kind count declared by an --endpoint archive\u2019s bundle.json `object_kinds` block."},{name:"scopes",type:"integer",required:!1,constraint:"Canvas scope count declared by an --endpoint archive\u2019s bundle.json `scopes` block."},{name:"appScopes",type:"string[]",required:!1,constraint:"Present when the plugin holds an app token after install: the canvas scopes that token carries (the manifest `scopes`; empty for a plugin that declares kinds or serves over HTTP but asks for none)."},{name:"warnings",type:"string[]",required:!1,constraint:"Advisory missing PATH executable requirements declared by the installed plugin, kinds another owner already holds (`object kind <kind> not registered`), and an invalid `object_kinds`/`scopes` block that leaves the plugin without an app token. The install still succeeds and leaves the plugin enabled."},{name:"memory",type:"object",required:!1,constraint:"Present only when the plugin ships documents (its `memory/` folder). {docs: integer (documents checked), linkedSource?: string (the caller-owned directory, present only when the install keeps that directory as a live link)}."}],outputKind:"object",effects:["A ref install clones, links, or copies the plugin into the scope plugins directory and registers it with enabled=true. Marketplace installs refresh the source marketplace before resolving the plugin entry.","An --endpoint install fetches and validates one authenticated uncompressed tar archive before writing. It replaces the complete plugin directory with synthesized provenance and invocation metadata, commands.json, memory docs, and, when declared, hooks.json plus the hooks/ tree; it also copies any kind-registry entries the bundle.json declares (they join the launch registry below this scope\u2019s own config.json kinds), and any page components it declares (they join the active page-component catalog alongside the user config entries); a fetch or validation failure preserves the prior package.","If the plugin declares a command manifest, its commands go live on the next crtr invocation. Exec commands run trusted local code only when explicitly invoked; HTTP commands call their declared endpoint only when explicitly invoked.","Plugin command hooks go live on the next crtr invocation. They run implicitly with caller authority, may receive normalized inputs and after results, may block or replace declared targets, and may transmit received data. Lifecycle hooks run unprompted at every declared event before node launch and may transmit node identity and resolved paths. Hook executables are never run during install or update validation.","A plugin manifest `requires` declaration is checked against the PATH a node bash receives after install. Missing executables emit a warning with the declared install hint but never fail the install, disable the plugin, or remove its bare-binary contributions.","Before activation the candidate\u2019s `memory/` documents are checked for identity findings and refused if it cannot mount; a local path or marketplace-relative source stays a live link, named as `memory.linkedSource`. A refused package installs nothing."]},run:d(async e=>{const n=e.installRef,t=e.endpoint,i=e.name,o=e.authEnv,r=e.scope,a=e.ref;if(H()){if(n===void 0||t!==void 0||i!==void 0||o!==void 0||a!==void 0||r!==void 0)throw b("a sandboxed node installs only INSTALL-REF as marketplace/plugin");return await De(n)}const l=qn(r);if(n===void 0==(t===void 0))throw b("provide exactly one of INSTALL-REF or --endpoint");if(t!==void 0){if(i===void 0)throw b("--name is required with --endpoint");if(a!==void 0)throw b("--ref is only valid with a git INSTALL-REF, not --endpoint");const h=await Wn(i,t,o,l);return U(h,await q(i),i)}if(i!==void 0)throw b("--name is only valid with --endpoint");if(o!==void 0)throw b("--auth-env is only valid with --endpoint");const c=zn(n),s=c.kind==="marketplace"?await Yn(c.value,l):c.kind==="local"?await Jn(c.value,l):await Gn(c.value,a,l),u=A(s.name,s.scope),y=await Z(s.name,s.scope),p=await ee(s.name,s.scope),k=u===null?[]:[...we(u.manifest),...await te(u.manifest)],m=await q(s.name);return U({...s,...u?.manifest.transport!==void 0?{transport:u.manifest.transport.kind}:{},...y!==void 0?{commands:y}:{},...p!==void 0?{hooks:p}:{},...k.length>0?{warnings:k}:{}},m,s.name)},"run")}),Bt=B({name:"remove",description:"remove plugin and directory",whenToUse:"uninstalling a plugin: deletes its directory and removes it from config",help:{name:"pkg plugin remove",summary:"remove a plugin and its directory from the given scope",params:[{kind:"positional",name:"name",type:"string",required:!0,constraint:"Plugin name to remove."},{kind:"flag",name:"scope",type:"enum",choices:["user","project"],required:!1,constraint:"Default: searches every scope."}],output:[{name:"scopes",type:"string[]",required:!0,constraint:"Scopes the plugin was removed from."}],outputKind:"object",effects:["Deletes the plugin directory. Removes the plugin entry from config.json."]},run:d(async e=>{const n=e.name,t=e.scope;if(n==="crtr")throw b('cannot remove builtin plugin "crtr" \u2014 it ships with the binary');if(H())return await Ne(n);let i;if(t!==void 0){const r=re(t);if(r==="builtin")throw b("cannot remove plugins from builtin scope");i=r==="all"?["project","user"].filter(a=>a!=="project"||se()!==null):[r]}else i=["project","user"].filter(r=>r!=="project"||se()!==null);const o=[];for(const r of i){const a=C(r);if(a===null)continue;const l=v(a,n);$(l)&&(E(l),await I(r,c=>{delete c.plugins[n]}),await O(r,c=>{delete c.plugins[n]}),o.push(r))}if(o.length===0)throw g(`plugin not found: ${n}`);return await q(),{scopes:o}},"run")}),Ht=B({name:"enable",description:"enable a plugin",whenToUse:"reactivating a plugin that was previously disabled so its memory docs resolve again",help:{name:"pkg plugin enable",summary:"enable a plugin in the given scope",params:[{kind:"positional",name:"name",type:"string",required:!0,constraint:"Plugin name to enable."},{kind:"flag",name:"scope",type:"enum",choices:["user","project"],required:!1,constraint:"Default: scope where the plugin is installed."}],output:[{name:"scope",type:"string",required:!0,constraint:"Scope the change was applied in."},{name:"memory",type:"object",required:!1,constraint:"Present only when the plugin ships documents (its `memory/` folder). {docs: integer (documents checked), linkedSource?: string (the caller-owned directory, present only for a symlinked install)}."},{name:"appScopes",type:"string[]",required:!1,constraint:"Present when the plugin holds an app token: the canvas scopes it carries."},{name:"warnings",type:"string[]",required:!1,constraint:"Kinds another owner holds, or an invalid `object_kinds`/`scopes` block. Enabling still succeeds."}],outputKind:"object",effects:["Validates the installed package before any config change: its `memory/` documents are checked for identity findings and refused if it cannot mount. A refusal leaves the plugin disabled.","Sets plugin enabled=true in config.json."]},run:d(async e=>{const n=e.name;if(H())return await oe(n,!0);const t=Tn(n,e.scope);if(t===null)throw g(`plugin not found: ${n}`);const i=x(t.root);if(i===null)throw g(`plugin manifest not found at ${t.root}/.crouter-plugin/plugin.json`);const o=t.scope==="project"?M("project"):S(),r=await P(i,t.root,t.scope,o,`${t.root}/.crouter-plugin/plugin.json`,void 0,K(t.root)?"linked":"package"),a=await ye(e,!0),l=await q(n);return U({scope:a.scope,...r!==void 0?{memory:r}:{}},l,n)},"run")}),It=B({name:"disable",description:"disable without removing",whenToUse:"hiding a plugin from resolution without deleting it, so you can re-enable it later",help:{name:"pkg plugin disable",summary:"disable a plugin (keeps files, hides from resolution)",params:[{kind:"positional",name:"name",type:"string",required:!0,constraint:"Plugin name to disable."},{kind:"flag",name:"scope",type:"enum",choices:["user","project"],required:!1,constraint:"Default: scope where the plugin is installed."}],output:[{name:"scope",type:"string",required:!0,constraint:"Scope the change was applied in."}],outputKind:"object",effects:["Sets plugin enabled=false in config.json."]},run:d(async e=>{if(H())return await oe(e.name,!1);const n=await ye(e,!1);return await q(),{scope:n.scope}},"run")}),Dt=B({name:"update",description:"update installed plugin content",whenToUse:"refreshing one named plugin or all installed plugins: archive plugins replace their complete package, while source-installed plugins retain their source update behavior",help:{name:"pkg plugin update",summary:"refresh one or all installed plugins",params:[{kind:"flag",name:"name",type:"string",required:!1,constraint:"Plugin name to update. Omit to update all installed plugins."},{kind:"flag",name:"scope",type:"enum",choices:["user","project"],required:!1,constraint:"Narrows resolution."}],output:[{name:"updated",type:"object[]",required:!0,constraint:"One entry per plugin processed: {name, transport?, updated, sha?, version?, docs?, kinds?, pageComponents?, commands?, hooks?, memory?, warnings?, error?}. memory is present for a plugin shipping documents and reports the same memory check install performs: {docs, linkedSource?}. Archive plugins report transport=http and replace their complete directory after an authenticated refetch; version is the archive content identifier, docs is the written memory-document count, kinds is the declared kind-registry entry count, pageComponents is the declared page-component registration count, objectKinds is the declared canvas object kind count, and scopes is the declared canvas scope count. appScopes lists the scopes the plugin\u2019s app token carries after the update. sha is present for git updates. A bulk update reports and skips a failed archive plugin. commands is present for validated command plugins: {mounts: string[] (accepted command paths), issues: object[]}. hooks is present for plugins declaring hooks: {manifestPath?, executablePath?, declarations: {target, phase, op, description, effects}[], lifecycle?: {event, phase, op, description, effects}[], issues: object[], trust: string}; it is static and never executes hooks. warnings lists advisory PATH requirements that remain absent after update, kinds another owner holds, and an invalid object_kinds/scopes block."}],outputKind:"object",effects:["Archive plugins unconditionally re-fetch, validate, and replace their complete package; a named failure exits nonzero and preserves the prior package. Bulk update reports a failed archive plugin and continues. Source-installed plugins retain their source update, version, and last_updated behavior.","A capability provider bundle (installed by the runtime from the directory) is skipped with a warning: the runtime refreshes it on grant sync.","Each candidate passes the same pre-activation memory check install performs."]},run:d(async e=>{const n=e.name;if(H())return await Fe(n);const t=e.scope,i=t===void 0?void 0:re(t),o=new Map;if(n!==void 0){const c=i===void 0||i==="all"||i==="builtin"?A(n):A(n,i);if(c===null)throw g(`plugin not found: ${n}${i===void 0||i==="all"||i==="builtin"?"":` (scope: ${i})`}`);const s=await Ae(c,o,{strict:!0}),u=await q(n);return{updated:[U(s,u,s.name)]}}const r=ae().filter(c=>c.scope!=="builtin"&&(i===void 0||i==="all"||c.scope===i)),a=[];for(const c of r)try{a.push(await Ae(c,o,{strict:!1}))}catch(s){a.push({name:c.name,...c.manifest.transport!==void 0?{transport:c.manifest.transport.kind}:{},updated:!1,error:s instanceof Error?s.message:String(s)})}const l=await q();return{updated:a.map(c=>c.error===void 0?U(c,l,c.name):c)}},"run")});export{P as assertPluginCandidateValid,Yn as installFromMarketplace,Kn as installPluginArchive,Ee as isMarketplaceRelativeSource,It as pluginDisable,Ht as pluginEnable,_t as pluginInstall,Bt as pluginRemove,Dt as pluginUpdate,Mt as revalidateBundlePlugin,Lt as validatePluginArchive};
|
|
19
|
+
Accepted forms: marketplace/plugin, git URL (https://, ssh://, git@, file://, or *.git), or local path starting ./, ../, or /. Bare plugin names are not install refs.`)}d(zn,"classifyInstallRef");function Ee(e){return e.startsWith("./")||e.startsWith("../")||!Be(e)&&!ve(e)}d(Ee,"isMarketplaceRelativeSource");async function Te(e,n,t){const i=n.get(e);if(i!==void 0)return i;const o=Oe(e);if(o===null){if(t.strict)throw g(`marketplace not found: ${e}`);return null}const r=ue(o.root);if(r===null)throw g(`marketplace manifest not found: ${o.root}/.crouter-marketplace/marketplace.json`);if(!Q(o.root)||o.url===""){const s={marketplace:o,manifest:r,pull:{updated:!1,sha:T(o.root)??""}};return n.set(e,s),s}const a=T(o.root),l=v(ie(o.root),`.${e}.${process.pid}.${Date.now()}.candidate`),c=`${l}.previous`;try{W(o.url,l,{ref:o.ref,depth:1});const s=ue(l);if(s===null)throw g(`marketplace manifest not found in candidate checkout: ${l}/.crouter-marketplace/marketplace.json`);const u=ae().filter(p=>p.sourceMarketplace===e&&K(p.root));for(const p of u){const k=s.plugins.find(Me=>Me.name===p.name);if(k===void 0||!Ee(k.source))throw f(`marketplace candidate removes relative-source plugin "${p.name}" while it is installed`);const m=Xe(p.root);if(m===null)throw f(`installed marketplace plugin "${p.name}" has no readable symlink target`);const h=_(o.root,V(ie(p.root),m)),w=V(l,k.source);if(w!==V(l,h))throw f(`marketplace candidate moves installed relative-source plugin "${p.name}" from ${h} to ${k.source}`);if(!$(w))throw g(`marketplace candidate source path does not exist for plugin "${p.name}": ${w}`);const R=x(w);if(R===null)throw g(`plugin manifest not found in marketplace candidate: ${w}/.crouter-plugin/plugin.json`);const Ce=p.scope==="project"?M("project"):S();await P(R,w,p.scope,Ce,`${w}/.crouter-plugin/plugin.json`)}j(o.root,c);try{j(l,o.root)}catch(p){throw j(c,o.root),p}E(c);for(const p of u){const k=s.plugins.find(m=>m.name===p.name);await qe(p.scope,p.name,k.version??p.manifest.version)}await O(o.scope,p=>{p.marketplaces[e]===void 0&&(p.marketplaces[e]={}),p.marketplaces[e].last_updated=Y()});const y={marketplace:o,manifest:s,pull:{updated:a!==T(o.root),sha:T(o.root)??""}};return n.set(e,y),y}finally{E(l),$(c)&&!$(o.root)&&j(c,o.root)}}d(Te,"refreshMarketplace");async function qe(e,n,t){await I(e,i=>{const o=i.plugins[n];o!==void 0?t!==void 0&&(o.version=t):i.plugins[n]={enabled:!0,version:t}}),await O(e,i=>{i.plugins[n]===void 0&&(i.plugins[n]={}),i.plugins[n].last_updated=Y()})}d(qe,"updatePluginVersion");async function Gn(e,n,t){const i=t==="project"?G():S();await J(t,i);const o=C(t),r=tn(e),a=v(i,"tmp",`${r}.${process.pid}.${Date.now()}`);L(v(i,"tmp"));try{W(e,a,{ref:n,depth:1});const l=x(a);if(l===null)throw f(`cloned repo does not contain a valid .crouter-plugin/plugin.json: ${e}`);const c=await P(l,a,t,i,`${e}/.crouter-plugin/plugin.json`),s=v(o,l.name);if($(s))throw f(`plugin "${l.name}" is already installed at ${s}`);return L(o),j(a,s),await I(t,u=>{u.plugins[l.name]={enabled:!0,version:l.version}}),{name:l.name,scope:t,path:s,...c!==void 0?{memory:c}:{}}}finally{E(a)}}d(Gn,"installFromGit");async function Jn(e,n){const t=V(e),i=x(t);if(i===null)throw g(`plugin manifest not found at ${t}/.crouter-plugin/plugin.json`);const o=n==="project"?G():S(),r=await P(i,t,n,o,`${t}/.crouter-plugin/plugin.json`,void 0,"linked");await J(n,o);const a=v(C(n),i.name);if($(a))throw f(`plugin "${i.name}" is already installed at ${a}`);return ce(t,a),await I(n,l=>{l.plugins[i.name]={enabled:!0,version:i.version}}),{name:i.name,scope:n,path:a,...r!==void 0?{memory:r}:{}}}d(Jn,"installFromLocal");async function Yn(e,n){const t=await Te(e.marketplace,new Map,{strict:!0});if(t===null)throw g(`marketplace not found: ${e.marketplace}`);const i=t.manifest.plugins.find(s=>s.name===e.plugin);if(i===void 0)throw g(`plugin "${e.plugin}" not found in marketplace "${e.marketplace}"`);const o=M(n);await J(n,o);const r=v(C(n),e.plugin);if($(r))throw f(`plugin "${e.plugin}" is already installed at ${r}`);let a,l;if(Ee(i.source)){const s=v(t.marketplace.root,i.source);if(!$(s))throw g(`plugin source path does not exist: ${s}`);const u=x(s);if(u===null)throw g(`plugin manifest not found at ${s}/.crouter-plugin/plugin.json`);l=await P(u,s,n,o,`${s}/.crouter-plugin/plugin.json`,void 0,"linked"),ce(s,r),a=u}else{const s=v(o,"tmp",`${e.plugin}.${process.pid}.${Date.now()}`);L(v(o,"tmp"));try{W(i.source,s,{depth:1});const u=x(s);if(u===null)throw g(`plugin manifest not found at ${s}/.crouter-plugin/plugin.json`);l=await P(u,s,n,o,`${s}/.crouter-plugin/plugin.json`),L(C(n)),j(s,r),a=u}finally{E(s)}}const c=i.version??a.version;return await I(n,s=>{const u={enabled:!0,source_marketplace:e.marketplace};c!==void 0&&(u.version=c),s.plugins[e.plugin]=u}),{name:e.plugin,scope:n,path:r,...l!==void 0?{memory:l}:{}}}d(Yn,"installFromMarketplace");async function Qn(e){if(K(e.root)){const l=x(e.root);if(l===null)throw g(`plugin manifest not found at ${e.root}/.crouter-plugin/plugin.json`);const c=e.scope==="project"?M("project"):S(),s=await P(l,e.root,e.scope,c,`${e.root}/.crouter-plugin/plugin.json`,void 0,"linked");return{updated:!1,sha:T(e.root)??"",manifest:l,...s!==void 0?{memory:s}:{}}}if(!Q(e.root)){const l=x(e.root);if(l===null)throw g(`plugin manifest not found at ${e.root}/.crouter-plugin/plugin.json`);const c=e.scope==="project"?M("project"):S(),s=await P(l,e.root,e.scope,c,`${e.root}/.crouter-plugin/plugin.json`);return{updated:!1,sha:"",manifest:l,...s!==void 0?{memory:s}:{}}}const n=de(["config","--get","remote.origin.url"],e.root).stdout.trim();if(n==="")throw f(`plugin "${e.name}" has no origin remote to stage an update from`);const t=de(["symbolic-ref","--short","HEAD"],e.root).stdout.trim();if(t==="")throw f(`plugin "${e.name}" is detached at its installed revision and has no tracked branch to update`);const i=e.scope==="project"?M("project"):S(),o=v(i,"tmp",`${e.name}.${process.pid}.${Date.now()}.candidate`),r=`${o}.previous`,a=T(e.root);L(v(i,"tmp"));try{W(n,o,{ref:t,depth:1});const l=x(o);if(l===null)throw g(`plugin manifest not found in update candidate: ${o}/.crouter-plugin/plugin.json`);const c=await P(l,o,e.scope,i,`${o}/.crouter-plugin/plugin.json`);j(e.root,r);try{j(o,e.root)}catch(u){throw j(r,e.root),u}E(r);const s=T(e.root)??"";return{updated:a!==s,sha:s,manifest:l,...c!==void 0?{memory:c}:{}}}finally{E(o),$(r)&&!$(e.root)&&j(r,e.root)}}d(Qn,"updateGitPluginCandidate");async function Ae(e,n,t){if(e.manifest.provider!==void 0)return{name:e.name,transport:"http",updated:!1,warnings:[`"${e.name}" is a capability provider bundle; the runtime refreshes it on grant sync`]};const i=be(e);if(!i&&e.manifest.bundle!==void 0){const u=await xe(e.name,e.manifest.bundle,e.scope,{enable:e.enabled});return{name:e.name,transport:"http",updated:!0,version:u.version,docs:u.docs,kinds:u.kinds,pageComponents:u.pageComponents,objectKinds:u.objectKinds,scopes:u.scopes,commands:u.commands,...u.hooks!==void 0?{hooks:u.hooks}:{},...u.memory!==void 0?{memory:u.memory}:{}}}e.manifest.transport?.kind==="http"&&!i&&$e(e.name);let o,r=!1;if(e.sourceMarketplace!==void 0){const u=await Te(e.sourceMarketplace,n,t);u!==null&&(o=u.manifest.plugins.find(p=>p.name===e.name)?.version,r=u.pull.updated)}const a=await Qn(e);await qe(e.scope,e.name,o??a.manifest.version);const l=await Z(e.name,e.scope),c=await ee(e.name,e.scope),s=[...we(a.manifest),...await te(a.manifest)];return{name:e.name,...e.manifest.transport!==void 0?{transport:e.manifest.transport.kind==="machine"?"http":e.manifest.transport.kind}:{},updated:r||a.updated,sha:a.sha,...l!==void 0?{commands:l}:{},...c!==void 0?{hooks:c}:{},...a.memory!==void 0?{memory:a.memory}:{},...s.length>0?{warnings:s}:{}}}d(Ae,"updateOnePlugin");async function q(e){const n=await He().documents.reconcilePackages().catch(i=>Ie(i)),t=n.conflicts.find(i=>i.plugin===e);if(t)throw new Ve("conflict",`plugin "${e}" is installed but its documents are not on the canvas: ${t.message}`,En.GENERAL,{plugin:e,next:"Uninstall the other package providing that plugin name, then run `crtr pkg plugin update --name "+e+"`."});return n}d(q,"reconcilePluginDocuments");function Xn(e,n){const t=[...(e.kinds?.refused??[]).filter(o=>o.plugin===n).map(o=>`object kind ${o.kind} not registered: ${o.message}`),...(e.kinds?.invalid??[]).filter(o=>o.plugin===n).map(o=>`object kinds and scopes not applied; the plugin holds no app token until this is fixed: ${o.error}`)],i=e.tokens?.granted.find(o=>o.plugin===n);return{warnings:t,...i!==void 0?{appScopes:i.scopes}:{}}}d(Xn,"pluginObjectReport");function U(e,n,t){const{warnings:i,appScopes:o}=Xn(n,t),a=[...e.warnings??[],...i];return{...e,...a.length>0?{warnings:a}:{},...o!==void 0?{appScopes:o}:{}}}d(U,"withObjectReport");const _t=B({name:"install",description:"install from a ref or HTTP endpoint",whenToUse:"installing one plugin from a marketplace ref, git URL, local path, or an HTTP directory-archive endpoint",help:{name:"pkg plugin install",summary:"install a plugin from a ref or HTTP endpoint",params:[{kind:"positional",name:"install-ref",type:"string",required:!1,constraint:"Plugin install ref. Provide exactly one of INSTALL-REF or --endpoint. Accepted ref forms: marketplace/plugin; git URL starting https://, ssh://, git@, file://, or ending .git; local path starting ./, ../, or /."},{kind:"flag",name:"endpoint",type:"string",required:!1,constraint:"HTTP plugin directory-archive endpoint. Provide exactly one of --endpoint or INSTALL-REF. Must be an absolute https: URL; http: is permitted only for localhost, any *.localhost host, 127.0.0.1, [::1], ::1, or host.docker.internal. Credentials and fragments are rejected."},{kind:"flag",name:"name",type:"string",required:!1,constraint:"Required with --endpoint and rejected without it. Lowercase kebab-case plugin handle."},{kind:"flag",name:"auth-env",type:"string",required:!1,constraint:"Optional environment variable holding the HTTP bearer token. Accepted only with --endpoint; its value is never stored."},{kind:"flag",name:"scope",type:"enum",choices:["user","project"],required:!1,constraint:"Default: project if available, else user."},{kind:"flag",name:"ref",type:"string",required:!1,constraint:"Git ref (branch/tag) for git URL installs. Rejected with --endpoint; ignored for marketplace and local path refs."}],output:[{name:"name",type:"string",required:!0,constraint:"Plugin name as installed."},{name:"scope",type:"string",required:!0,constraint:"Scope the plugin was installed into."},{name:"path",type:"string",required:!0,constraint:"Absolute path to the installed plugin directory."},{name:"transport",type:"string",required:!1,constraint:"exec or http when the plugin declares commands. Always http for an --endpoint install."},{name:"version",type:"string",required:!1,constraint:"First 12 hex characters of the fetched archive SHA-256 for an --endpoint install."},{name:"docs",type:"integer",required:!1,constraint:"Memory document count written from an --endpoint archive."},{name:"kinds",type:"integer",required:!1,constraint:"Kind-registry entry count declared by an --endpoint archive\u2019s bundle.json."},{name:"pageComponents",type:"integer",required:!1,constraint:"Page-component registration count declared by an --endpoint archive\u2019s bundle.json."},{name:"commands",type:"object",required:!1,constraint:"Present only when the plugin declares a command manifest. {mounts: string[] (accepted command paths now live for the next invocation), issues: object[] (typed validation issues that rejected a contribution \u2014 {code, path?, message, received, expected, next})}. Validated statically; commands are never executed."},{name:"hooks",type:"object",required:!1,constraint:"Present only when the plugin declares hooks. {manifestPath?, executablePath?, declarations: {target, phase, op, description, effects}[], lifecycle?: {event, phase, op, description, effects}[], issues: object[], trust: string}. Command targets, lifecycle events, and replacement collisions are validated statically; hook executables are never run."},{name:"objectKinds",type:"integer",required:!1,constraint:"Canvas object kind count declared by an --endpoint archive\u2019s bundle.json `object_kinds` block."},{name:"scopes",type:"integer",required:!1,constraint:"Canvas scope count declared by an --endpoint archive\u2019s bundle.json `scopes` block."},{name:"appScopes",type:"string[]",required:!1,constraint:"Present when the plugin holds an app token after install: the canvas scopes that token carries (the manifest `scopes`; empty for a plugin that declares kinds or serves over HTTP but asks for none)."},{name:"warnings",type:"string[]",required:!1,constraint:"Advisory missing PATH executable requirements declared by the installed plugin, kinds another owner already holds (`object kind <kind> not registered`), and an invalid `object_kinds`/`scopes` block that leaves the plugin without an app token. The install still succeeds and leaves the plugin enabled."},{name:"memory",type:"object",required:!1,constraint:"Present only when the plugin ships documents (its `memory/` folder). {docs: integer (documents checked), linkedSource?: string (the caller-owned directory, present only when the install keeps that directory as a live link)}."}],outputKind:"object",effects:["A ref install clones, links, or copies the plugin into the scope plugins directory and registers it with enabled=true. Marketplace installs refresh the source marketplace before resolving the plugin entry.","An --endpoint install fetches and validates one authenticated uncompressed tar archive before writing. It replaces the complete plugin directory with synthesized provenance and invocation metadata, commands.json, memory docs, and, when declared, hooks.json plus the hooks/ tree; it also copies any kind-registry entries the bundle.json declares (they join the launch registry below this scope\u2019s own config.json kinds), and any page components it declares (they join the active page-component catalog alongside the user config entries); a fetch or validation failure preserves the prior package.","If the plugin declares a command manifest, its commands go live on the next crtr invocation. Exec commands run trusted local code only when explicitly invoked; HTTP commands call their declared endpoint only when explicitly invoked.","Plugin command hooks go live on the next crtr invocation. They run implicitly with caller authority, may receive normalized inputs and after results, may block or replace declared targets, and may transmit received data. Lifecycle hooks run unprompted at every declared event before node launch and may transmit node identity and resolved paths. Hook executables are never run during install or update validation.","A plugin manifest `requires` declaration is checked against the PATH a node bash receives after install. Missing executables emit a warning with the declared install hint but never fail the install, disable the plugin, or remove its bare-binary contributions.","Before activation the candidate\u2019s `memory/` documents are checked for identity findings and refused if it cannot mount; a local path or marketplace-relative source stays a live link, named as `memory.linkedSource`. A refused package installs nothing."]},run:d(async e=>{const n=e.installRef,t=e.endpoint,i=e.name,o=e.authEnv,r=e.scope,a=e.ref;if(H()){if(n===void 0||t!==void 0||i!==void 0||o!==void 0||a!==void 0||r!==void 0)throw b("a sandboxed node installs only INSTALL-REF as marketplace/plugin");return await De(n)}const l=qn(r);if(n===void 0==(t===void 0))throw b("provide exactly one of INSTALL-REF or --endpoint");if(t!==void 0){if(i===void 0)throw b("--name is required with --endpoint");if(a!==void 0)throw b("--ref is only valid with a git INSTALL-REF, not --endpoint");const h=await Wn(i,t,o,l);return U(h,await q(i),i)}if(i!==void 0)throw b("--name is only valid with --endpoint");if(o!==void 0)throw b("--auth-env is only valid with --endpoint");const c=zn(n),s=c.kind==="marketplace"?await Yn(c.value,l):c.kind==="local"?await Jn(c.value,l):await Gn(c.value,a,l),u=A(s.name,s.scope),y=await Z(s.name,s.scope),p=await ee(s.name,s.scope),k=u===null?[]:[...we(u.manifest),...await te(u.manifest)],m=await q(s.name);return U({...s,...u?.manifest.transport!==void 0?{transport:u.manifest.transport.kind}:{},...y!==void 0?{commands:y}:{},...p!==void 0?{hooks:p}:{},...k.length>0?{warnings:k}:{}},m,s.name)},"run")}),Bt=B({name:"remove",description:"remove plugin and directory",whenToUse:"uninstalling a plugin: deletes its directory and removes it from config",help:{name:"pkg plugin remove",summary:"remove a plugin and its directory from the given scope",params:[{kind:"positional",name:"name",type:"string",required:!0,constraint:"Plugin name to remove."},{kind:"flag",name:"scope",type:"enum",choices:["user","project"],required:!1,constraint:"Default: searches every scope."}],output:[{name:"scopes",type:"string[]",required:!0,constraint:"Scopes the plugin was removed from."}],outputKind:"object",effects:["Deletes the plugin directory. Removes the plugin entry from config.json."]},run:d(async e=>{const n=e.name,t=e.scope;if(n==="crtr")throw b('cannot remove builtin plugin "crtr" \u2014 it ships with the binary');if(H())return await Ne(n);let i;if(t!==void 0){const r=re(t);if(r==="builtin")throw b("cannot remove plugins from builtin scope");i=r==="all"?["project","user"].filter(a=>a!=="project"||se()!==null):[r]}else i=["project","user"].filter(r=>r!=="project"||se()!==null);const o=[];for(const r of i){const a=C(r);if(a===null)continue;const l=v(a,n);$(l)&&(E(l),await I(r,c=>{delete c.plugins[n]}),await O(r,c=>{delete c.plugins[n]}),o.push(r))}if(o.length===0)throw g(`plugin not found: ${n}`);return await q(),{scopes:o}},"run")}),Ht=B({name:"enable",description:"enable a plugin",whenToUse:"reactivating a plugin that was previously disabled so its memory docs resolve again",help:{name:"pkg plugin enable",summary:"enable a plugin in the given scope",params:[{kind:"positional",name:"name",type:"string",required:!0,constraint:"Plugin name to enable."},{kind:"flag",name:"scope",type:"enum",choices:["user","project"],required:!1,constraint:"Default: scope where the plugin is installed."}],output:[{name:"scope",type:"string",required:!0,constraint:"Scope the change was applied in."},{name:"memory",type:"object",required:!1,constraint:"Present only when the plugin ships documents (its `memory/` folder). {docs: integer (documents checked), linkedSource?: string (the caller-owned directory, present only for a symlinked install)}."},{name:"appScopes",type:"string[]",required:!1,constraint:"Present when the plugin holds an app token: the canvas scopes it carries."},{name:"warnings",type:"string[]",required:!1,constraint:"Kinds another owner holds, or an invalid `object_kinds`/`scopes` block. Enabling still succeeds."}],outputKind:"object",effects:["Validates the installed package before any config change: its `memory/` documents are checked for identity findings and refused if it cannot mount. A refusal leaves the plugin disabled.","Sets plugin enabled=true in config.json."]},run:d(async e=>{const n=e.name;if(H())return await oe(n,!0);const t=Tn(n,e.scope);if(t===null)throw g(`plugin not found: ${n}`);const i=x(t.root);if(i===null)throw g(`plugin manifest not found at ${t.root}/.crouter-plugin/plugin.json`);const o=t.scope==="project"?M("project"):S(),r=await P(i,t.root,t.scope,o,`${t.root}/.crouter-plugin/plugin.json`,void 0,K(t.root)?"linked":"package"),a=await ye(e,!0),l=await q(n);return U({scope:a.scope,...r!==void 0?{memory:r}:{}},l,n)},"run")}),It=B({name:"disable",description:"disable without removing",whenToUse:"hiding a plugin from resolution without deleting it, so you can re-enable it later",help:{name:"pkg plugin disable",summary:"disable a plugin (keeps files, hides from resolution)",params:[{kind:"positional",name:"name",type:"string",required:!0,constraint:"Plugin name to disable."},{kind:"flag",name:"scope",type:"enum",choices:["user","project"],required:!1,constraint:"Default: scope where the plugin is installed."}],output:[{name:"scope",type:"string",required:!0,constraint:"Scope the change was applied in."}],outputKind:"object",effects:["Sets plugin enabled=false in config.json."]},run:d(async e=>{if(H())return await oe(e.name,!1);const n=await ye(e,!1);return await q(),{scope:n.scope}},"run")}),Dt=B({name:"update",description:"update installed plugin content",whenToUse:"refreshing one named plugin or all installed plugins: archive plugins replace their complete package, while source-installed plugins retain their source update behavior",help:{name:"pkg plugin update",summary:"refresh one or all installed plugins",params:[{kind:"flag",name:"name",type:"string",required:!1,constraint:"Plugin name to update. Omit to update all installed plugins."},{kind:"flag",name:"scope",type:"enum",choices:["user","project"],required:!1,constraint:"Narrows resolution."}],output:[{name:"updated",type:"object[]",required:!0,constraint:"One entry per plugin processed: {name, transport?, updated, sha?, version?, docs?, kinds?, pageComponents?, commands?, hooks?, memory?, warnings?, error?}. memory is present for a plugin shipping documents and reports the same memory check install performs: {docs, linkedSource?}. Archive plugins report transport=http and replace their complete directory after an authenticated refetch; version is the archive content identifier, docs is the written memory-document count, kinds is the declared kind-registry entry count, pageComponents is the declared page-component registration count, objectKinds is the declared canvas object kind count, and scopes is the declared canvas scope count. appScopes lists the scopes the plugin\u2019s app token carries after the update. sha is present for git updates. A bulk update reports and skips a failed archive plugin. commands is present for validated command plugins: {mounts: string[] (accepted command paths), issues: object[]}. hooks is present for plugins declaring hooks: {manifestPath?, executablePath?, declarations: {target, phase, op, description, effects}[], lifecycle?: {event, phase, op, description, effects}[], issues: object[], trust: string}; it is static and never executes hooks. warnings lists advisory PATH requirements that remain absent after update, kinds another owner holds, and an invalid object_kinds/scopes block."}],outputKind:"object",effects:["Archive plugins unconditionally re-fetch, validate, and replace their complete package; a named failure exits nonzero and preserves the prior package. Bulk update reports a failed archive plugin and continues. Source-installed plugins retain their source update, version, and last_updated behavior.","A capability provider bundle (installed by the runtime from the directory) is skipped with a warning: the runtime refreshes it on grant sync.","Each candidate passes the same pre-activation memory check install performs."]},run:d(async e=>{const n=e.name;if(H())return await Fe(n);const t=e.scope,i=t===void 0?void 0:re(t),o=new Map;if(n!==void 0){const c=i===void 0||i==="all"||i==="builtin"?A(n):A(n,i);if(c===null)throw g(`plugin not found: ${n}${i===void 0||i==="all"||i==="builtin"?"":` (scope: ${i})`}`);const s=await Ae(c,o,{strict:!0}),u=await q(n);return{updated:[U(s,u,s.name)]}}const r=ae().filter(c=>c.scope!=="builtin"&&(i===void 0||i==="all"||c.scope===i)),a=[];for(const c of r)try{a.push(await Ae(c,o,{strict:!1}))}catch(s){a.push({name:c.name,...c.manifest.transport!==void 0?{transport:c.manifest.transport.kind}:{},updated:!1,error:s instanceof Error?s.message:String(s)})}const l=await q();return{updated:a.map(c=>c.error===void 0?U(c,l,c.name):c)}},"run")});export{P as assertPluginCandidateValid,Yn as installFromMarketplace,Kn as installPluginArchive,Ee as isMarketplaceRelativeSource,It as pluginDisable,Ht as pluginEnable,_t as pluginInstall,Bt as pluginRemove,Dt as pluginUpdate,Mt as revalidateBundlePlugin,Lt as validatePluginArchive};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var d=Object.defineProperty;var l=(i,
|
|
1
|
+
var d=Object.defineProperty;var l=(i,s)=>d(i,"name",{value:s,configurable:!0});import{defineLeaf as u}from"../../core/command.js";import{updateState as p}from"../../core/config.js";import{projectScopeRoot as f}from"../../core/scope.js";import{selfCheck as m,selfUpdate as h,contentCheck as g}from"../../core/self-update.js";import{marketUpdate as k}from"../pkg/market-manage.js";import{pluginUpdate as y}from"../pkg/plugin-manage.js";import{nowIso as b}from"../../core/fs-utils.js";import{processLocatedGeneration as w,readPackageVersion as _,runtimeManifest as v,selectedGeneration as j}from"./shared.js";const x=u({name:"update",description:"update binary and content",whenToUse:"upgrading crtr or its installed plugins and marketplaces \u2014 pull the latest binary, refresh installed content, or both, or just check what is out of date without applying anything.",help:{name:"sys update",summary:"update the crtr binary and/or installed plugins and marketplaces",params:[{kind:"flag",name:"target",type:"enum",choices:["self","content","all"],required:!1,constraint:"What to update. Default: all."},{kind:"flag",name:"check",type:"bool",required:!1,constraint:"Check for updates without applying them (bounded, blocking)."}],output:[{name:"target",type:"string",required:!1,constraint:"Present when applying updates: self | content | all."},{name:"status",type:"string",required:!1,constraint:"done | failed when applying updates."},{name:"error",type:"string",required:!1,constraint:"Failure message when status is failed."},{name:"warning",type:"string",required:!1,constraint:"Present when the update was applied but recording the self-check time failed, or a marketplace with no registered url was skipped; status stays done."},{name:"updates",type:"object[]",required:!1,constraint:"Present when --check. Each: {name, current, latest, up_to_date, unreachable, kind}."},{name:"up_to_date",type:"boolean",required:!1,constraint:"Present when --check. True when all items are up to date."}],outputKind:"object",effects:["--check \u2014 read-only, bounded network calls.","Default (no --check) \u2014 launches a background job; returns job handle immediately.","Content update replaces each marketplace and source-installed plugin checkout with a freshly staged revision, discarding local modifications in those directories."]},run:l(async i=>{const s=i.target,c=i.check,n=s!==void 0?s:"all";if(c){const t=[];if(n==="self"||n==="all"){const e=m();e!==null?t.push({name:e.package,kind:"self",current:e.current,latest:e.latest,up_to_date:!e.migrating&&e.current===e.latest,unreachable:!1}):t.push({name:"@north-light/cli",kind:"self",current:null,latest:null,up_to_date:!0,unreachable:!0})}if(n==="content"||n==="all"){const e=g();for(const o of e)t.push({name:o.name,kind:o.kind,current:o.current,latest:o.latest,up_to_date:o.up_to_date,unreachable:o.unreachable})}const r=t.every(e=>e.up_to_date||e.unreachable);return{updates:t,up_to_date:r}}const a=[];try{if(n==="self"||n==="all"){h();const t=["user"];f()&&t.unshift("project");for(const r of t)try{await p(r,e=>{e.last_self_check=b()})}catch(e){a.push(`recording the ${r}-scope self-check failed: ${e instanceof Error?e.message:String(e)}`)}}if(n==="content"||n==="all"){const t=await k.run({});for(const r of t.skipped??[])a.push(`marketplace ${r.name} skipped: ${r.reason}`);await y.run({})}return a.length===0?{target:n,status:"done"}:{target:n,status:"done",warning:a.join("; ")}}catch(t){const r=t instanceof Error?t.message:String(t);return{target:n,status:"failed",error:r}}},"run")}),E=u({name:"version",description:"print installed version",whenToUse:"you need the installed crtr version \u2014 to report it in a bug or confirm an upgrade landed.",help:{name:"sys version",summary:"report selected and process runtime generations",params:[],output:[{name:"version",type:"string",required:!0,constraint:"Version from this process generation manifest; package.json version in a development checkout."},{name:"selected_generation",type:"object",required:!0,constraint:"Selected runtime generation: {id, version, status}; id/version are null when no selection exists."},{name:"process_generation",type:"object",required:!0,constraint:"Generation containing this loaded module: {id, version, status}; id/version are null in a development checkout."},{name:"drift",type:"boolean",required:!0,constraint:"True when selected and process generation ids differ."}],outputKind:"object",effects:["None. Read-only."]},run:l(async i=>{const s=l(a=>{if(a.generation===null)return{id:null,version:null,status:a.error??"no runtime generation"};const{id:t,manifest:r}=a.generation,e=v.validateManifestShape(r,{id:t,entryName:"cli"});return{id:t,version:typeof r.packageVersion=="string"?r.packageVersion:null,status:e.ok?"valid":e.error}},"describe"),c=s(j()),n=s(w());return{version:n.version??_(),selected_generation:c,process_generation:n,drift:c.id!==null&&n.id!==null&&c.id!==n.id}},"run")});export{x as sysUpdateLeaf,E as sysVersionLeaf};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var ce=Object.defineProperty;var i=(e,n)=>ce(e,"name",{value:n,configurable:!0});import{loadExactProfileManifest as le}from"../profiles/manifest.js";import{envNodeId as H}from"../../shared/env.js";import{lstatSync as _e,realpathSync as M,rmdirSync as pe,rmSync as fe,statSync as Ee}from"node:fs";import{basename as we,dirname as P,isAbsolute as ye,join as S,relative as me,resolve as Ne,sep as Re}from"node:path";import{removeTreeBeneath as $}from"../spaces/open-beneath.js";import{emitEvent as Se}from"../events/emit.js";import{deleteNodeSandboxes as q}from"../runtime/runner/delete-sandboxes.js";import{withCanvasWrite as p,openDb as d}from"./db.js";import{conversationStore as he,ConversationNotFoundError as Oe}from"../conversation-store/index.js";import{hasUnseenWakeMail as Le,UNSEEN_WAKE_MAIL_SQL as Te}from"./deliveries.js";import{isAppRun as B}from"./app-run.js";import{registerOutcomeAction as z}from"./outcome-actions.js";import{publish as De}from"../graph/events.js";import{nodeObject as Ae}from"../graph/objects.js";import{findNodeBySessionFileSql as ge}from"./sessions.js";import{hydrateFault as ve}from"./recovery.js";import{hasUnreconciledWorktree as ke,openWorktree as xe,readWorktree as Ue,worktreeFromRow as We}from"./worktrees.js";import{isPidAlive as je,isPidPresent as J,recordedPidLiveness as be}from"./pid.js";import{isCloudRole as Ie}from"./person-state.js";import{ensureHome as Fe,jobDir as Ce,nodeDir as He,nodeRunDir as Y}from"./paths.js";import{appForNode as Me,ensureNodeDirs as Pe,nodeAgentDir as $e}from"./node-agent-paths.js";import{appSpace as T}from"../layout.js";import{createObject as qe,getById as D,ownerForGrantee as Be,setObjectKind as ze,setObjectName as Je}from"../graph/objects.js";import{profileObject as Ye}from"../graph/reader.js";import{writeActsFor as Q}from"../permissions/facts.js";import{CrtrError as Qe}from"../errors.js";import{deleteNodeWithOwned as Ve}from"../graph/deletion.js";import{SUBTREE_ALL_IDS_SQL as Ke,SUBTREE_IDS_SQL as Ge}from"./tree.js";import{filterAsync as y,mapAsync as h}from"../async-array.js";function E(e,n){if(e==null)return null;const t=JSON.stringify(e);if(t===void 0)throw new TypeError(`${n} must be JSON-serializable`);return t}i(E,"jsonValue");async function Fn(e,n){if((await e.prepare("SELECT deleting_at FROM nodes WHERE node_id = ?").get(n))?.deleting_at)throw new Error("run is deleting")}i(Fn,"assertRunNotDeleting");async function V(e,n,t,a){try{return(le(n).manifest.grantee??"app:terminal")!==a?null:await Ye(e,n,t)}catch(r){if(r instanceof Qe&&r.code==="not_found")return null;throw r}}i(V,"profileObjectFor");async function Xe(e,n){const t=await Be(n,e.grantee??"app:terminal"),a=e.profile_id?await V(n,e.profile_id,t,e.grantee??"app:terminal"):null;await qe(n,{id:e.node_id,type:"node",kind:e.kind,owner:(a??t).id,privacy:"public",name:e.name,preview:""}),a===null&&e.sub&&await Q(n,e.node_id,e.sub),await n.prepare(`INSERT INTO nodes (node_id, description, title, icon, cycles, mode, lifecycle, cwd, host_kind, profile_id, parent, spawned_by, creator, fork_from, fork_source_file, created, passive_default, cycle_pending, model_override, persona_ack_json, review_binding_json, launch_config_json, scopes_json, isolated, status, intent, final_report, finalized_at, deadline_at, "window", tmux_session, pane, sub, grant_id, client_id, metadata_json, run_id, event_cursor, usage_json, deleting_at, caused_by, app) VALUES (${Array(42).fill("?").join(", ")})`).run(e.node_id,e.description??null,e.title??null,e.icon??null,e.cycles??null,e.mode,e.lifecycle,e.cwd,e.host_kind??null,e.profile_id??null,e.parent??null,e.spawned_by??null,e.creator??null,e.fork_from??null,e.fork_source_file??null,e.created,e.passive_default===!0?1:0,e.cycle_pending===!0?1:0,e.model_override??null,E(e.persona_ack,"persona_ack"),E(e.review_binding,"review_binding"),E(e.launch,"launch"),E(e.scopes,"scopes"),e.isolated===!0?1:0,e.status??"active",e.intent??null,e.final_report??null,e.finalized_at??null,e.deadline_at??null,e.window??null,e.tmux_session??null,e.pane??null,e.sub??null,e.grant_id??null,e.client_id??null,e.metadata_json??null,e.run_id??null,e.event_cursor??null,e.usage_json??null,e.deleting_at??null,e.caused_by??null,t.id)}i(Xe,"seedRow");function K(e){if(e.fault_id==null)return null;const n=Object.entries(e).filter(([t])=>t.startsWith("fault_")).map(([t,a])=>[t==="fault_id"?t:t.slice(6),a]);return ve(Object.fromEntries(n))}i(K,"faultFrom");const G=i(e=>e.turn_open_at!=null&&e.turn_closed_at==null,"turnOpen"),X=i(e=>e||Ie(),"engineLive");function f(e){const n={node_id:e.node_id,name:e.name,description:e.description??void 0,cycles:e.cycles??void 0,kind:e.kind,mode:e.mode,lifecycle:e.lifecycle,status:e.status,cwd:e.cwd,host_kind:e.host_kind??null,profile_id:e.profile_id??null,scopes:e.scopes_json==null?null:JSON.parse(e.scopes_json),isolated:e.isolated===1,grantee:e.grantee,sub:e.sub??null,grant_id:e.grant_id??null,client_id:e.client_id??null,metadata_json:e.metadata_json??null,run_id:e.run_id??null,event_cursor:e.event_cursor??null,last_activity_at:e.last_activity_at??null,usage_json:e.usage_json??null,caused_by:e.caused_by??null,last_turn_error_json:e.last_turn_error_json??null,deleting_at:e.deleting_at??null,parent:e.parent??null,created:e.created,intent:e.intent??null,frozen_at:e.frozen_at??null,respawn_failures:e.respawn_failures??0,respawn_not_before:e.respawn_not_before??null,launched_at:e.launched_at??null,last_settled_at:e.last_settled_at??null,terminal_reason:e.terminal_reason??null,final_report:e.final_report??null,finalized_at:e.finalized_at??null,outcome_kind:e.outcome_kind??null,outcome_reason:e.outcome_reason??null,outcome_at:e.outcome_at??null,outcome_revision:e.outcome_revision??0,outcome_detail_json:e.outcome_detail_json??null,deadline_at:e.deadline_at??null,telemetry_tokens_in:e.telemetry_tokens_in??null,telemetry_context_tokens:e.telemetry_context_tokens??null,telemetry_last_activity:e.telemetry_last_activity??null,telemetry_updated_at:e.telemetry_updated_at??null,pi_pid:e.pi_pid??null,pi_pid_identity:e.pi_pid_identity??null,window:e.window??null,tmux_session:e.tmux_session??null,pane:e.pane??null,fault:null,streaming:!1},t=J(n.pi_pid),a=K(e);return n.fault=a?.link==="pi\u2192provider"&&a.retry.by==="daemon"&&a.retry.disposition==="auto"&&!t?null:a,n.streaming=G(e)&&X(t),n}i(f,"rowFrom");async function A(e,n){return n??=await Ue(e.node_id),{...f(e),title:e.title??void 0,icon:e.icon??void 0,spawned_by:e.spawned_by??null,creator:e.creator??null,fork_from:e.fork_from??null,fork_source_file:e.fork_source_file??null,passive_default:e.passive_default===1,cycle_pending:e.cycle_pending===1,model_override:e.model_override??null,scopes:e.scopes_json==null?null:JSON.parse(e.scopes_json),persona_ack:e.persona_ack_json==null?void 0:JSON.parse(e.persona_ack_json),review_binding:e.review_binding_json==null?void 0:JSON.parse(e.review_binding_json),launch:e.launch_config_json==null?void 0:JSON.parse(e.launch_config_json),pi_session_id:e.pi_session_id??null,pi_session_file:e.pi_session_file??null,...n===null?{}:{managed_worktree:n}}}i(A,"metaFrom");async function Cn(e,n={}){return Fe(),await p(async t=>{await Xe(e,t),e.managed_worktree!==void 0&&e.managed_worktree!==null&&await xe(e.node_id,e.managed_worktree,t),n.outcomeDelivery!==void 0&&await z(t,e.node_id,n.outcomeDelivery),await n.withinCreate?.(t,e)}),await Pe(e.node_id),await O(e.node_id)}i(Cn,"createNode");async function O(e){const n=await(await d()).prepare("SELECT * FROM node_rows WHERE node_id = ?").get(e);return n===void 0?null:await A(n)}i(O,"getNode");async function Hn(e){if(e.length===0)return[];const n=k.map(r=>`w.${r} AS worktree_${r}`).join(", "),t=await(await d()).prepareUncached(`SELECT n.*, ${n} FROM node_rows n LEFT JOIN worktrees w ON w.node_id = n.node_id WHERE n.node_id IN (${e.map(()=>"?").join(",")})`).all(...e),a=new Map(t.map(r=>[r.node_id,r]));return await h(e.map(r=>a.get(r)).filter(r=>r!==void 0),async r=>await A(r,ee(r)))}i(Hn,"getNodes");const Ze=1440*60*1e3;function Z(e){return{requestKey:e.request_key,nodeId:e.node_id,state:e.state}}i(Z,"createRequestRecord");async function Mn(e){const n=await(await d()).prepareUncached("SELECT request_key, node_id, state FROM create_requests WHERE request_key = ?").get(e);return n===void 0?null:Z(n)}i(Mn,"findCreateRequest");async function Pn(e){return await p(async n=>{const t=Date.now();await n.prepareUncached("DELETE FROM create_requests WHERE expires_at <= ?").run(t),await n.prepareUncached("INSERT INTO create_requests (request_key, node_id, expires_at, state) VALUES (?, NULL, ?, 'reserved') ON CONFLICT (request_key) DO NOTHING").run(e,t+Ze);const a=await n.prepareUncached("SELECT request_key, node_id, state FROM create_requests WHERE request_key = ?").get(e);return Z(a)})}i(Pn,"reserveCreateRequest");async function $n(e=Date.now()){return Number((await(await d()).prepareUncached("DELETE FROM create_requests WHERE expires_at <= ?").run(e)).changes)}i($n,"pruneExpiredCreateRequests");async function qn(e,n){await(await d()).prepareUncached("UPDATE create_requests SET node_id = ?, state = 'complete' WHERE request_key = ?").run(n,e)}i(qn,"recordCreateRequestNode");async function Bn(e,n,t){const a=await d();return await a.prepareUncached("UPDATE create_requests SET node_id = ?, state = 'reserved', lease_owner = ?, lease_expires_at = ? WHERE request_key = ? AND node_id IS NULL").run(n,t,Date.now()+g,e),(await a.prepareUncached("SELECT node_id FROM create_requests WHERE request_key = ?").get(e))?.node_id??null}i(Bn,"reserveCreateRequestNode");const g=3e4,zn=1e4;async function Jn(e,n,t){const a=Date.now(),r=await(await d()).prepareUncached("UPDATE create_requests SET lease_owner = ?, lease_expires_at = ? WHERE request_key = ? AND node_id = ? AND state = 'reserved' AND (lease_expires_at IS NULL OR lease_expires_at <= ?)").run(t,a+g,e,n,a);return Number(r.changes)>0}i(Jn,"claimCreateLease");async function Yn(e,n){await(await d()).prepareUncached("UPDATE create_requests SET lease_expires_at = ? WHERE request_key = ? AND lease_owner = ?").run(Date.now()+g,e,n)}i(Yn,"renewCreateLease");async function Qn(e){const n=await(await d()).prepareUncached("SELECT lease_expires_at FROM create_requests WHERE request_key = ?").get(e);return n?.lease_expires_at!=null&&Number(n.lease_expires_at)>Date.now()}i(Qn,"createLeaseLive");async function Vn(e,n){await(await d()).prepareUncached("UPDATE create_requests SET state = 'complete' WHERE request_key = ? AND node_id = ?").run(e,n)}i(Vn,"completeCreateRequest");async function Kn(e,n){await p(async t=>{if(n===null){await t.prepareUncached("DELETE FROM create_requests WHERE request_key = ? AND node_id IS NULL").run(e);return}await t.prepareUncached("DELETE FROM create_requests WHERE request_key = ? AND node_id = ?").run(e,n)})}i(Kn,"abandonCreateRequest");function Gn(e){return Ne(e)}i(Gn,"canonicalSessionFile");async function Xn(e){const n=await ge(e);return n===null?null:await O(n)}i(Xn,"findNodeBySessionFile");async function Zn(e){const n=await(await d()).prepare("SELECT * FROM node_rows WHERE node_id = ?").get(e);return n?f(n):null}i(Zn,"getRow");async function et(e){const n=await(await d()).prepare("SELECT * FROM node_rows WHERE pane = ?").get(e);return n?f(n):null}i(et,"getRowByPane");async function nt(e){return(await(await d()).prepare(`SELECT * FROM node_rows
|
|
1
|
+
var ce=Object.defineProperty;var i=(e,n)=>ce(e,"name",{value:n,configurable:!0});import{loadExactProfileManifest as le}from"../profiles/manifest.js";import{envNodeId as H}from"../../shared/env.js";import{lstatSync as _e,realpathSync as M,rmdirSync as pe,rmSync as fe,statSync as Ee}from"node:fs";import{basename as we,dirname as P,isAbsolute as ye,join as S,relative as me,resolve as Ne,sep as Re}from"node:path";import{removeTreeBeneath as $}from"../spaces/open-beneath.js";import{emitEvent as Se}from"../events/emit.js";import{deleteNodeSandboxes as q}from"../runtime/runner/delete-sandboxes.js";import{withCanvasWrite as p,openDb as d}from"./db.js";import{conversationStore as he,ConversationNotFoundError as Oe}from"../conversation-store/index.js";import{hasUnseenWakeMail as Le,UNSEEN_WAKE_MAIL_SQL as Te}from"./deliveries.js";import{isAppRun as B}from"./app-run.js";import{registerOutcomeAction as z}from"./outcome-actions.js";import{publish as De}from"../graph/events.js";import{nodeObject as Ae}from"../graph/objects.js";import{findNodeBySessionFileSql as ge}from"./sessions.js";import{hydrateFault as ke}from"./recovery.js";import{hasUnreconciledWorktree as ve,openWorktree as xe,readWorktree as Ue,worktreeFromRow as We}from"./worktrees.js";import{isPidAlive as je,isPidPresent as J,recordedPidLiveness as be}from"./pid.js";import{isCloudRole as Ie}from"./person-state.js";import{ensureHome as Fe,jobDir as Ce,nodeDir as He,nodeRunDir as Y}from"./paths.js";import{appForNode as Me,ensureNodeDirs as Pe,nodeAgentDir as $e}from"./node-agent-paths.js";import{appSpace as T}from"../layout.js";import{createObject as qe,getById as D,ownerForGrantee as Be,setObjectKind as ze,setObjectName as Je}from"../graph/objects.js";import{profileObject as Ye}from"../graph/reader.js";import{writeActsFor as Q}from"../permissions/facts.js";import{CrtrError as Qe}from"../errors.js";import{deleteNodeWithOwned as Ve}from"../graph/deletion.js";import{SUBTREE_ALL_IDS_SQL as Ke,SUBTREE_IDS_SQL as Ge}from"./tree.js";import{filterAsync as y,mapAsync as h}from"../async-array.js";function E(e,n){if(e==null)return null;const t=JSON.stringify(e);if(t===void 0)throw new TypeError(`${n} must be JSON-serializable`);return t}i(E,"jsonValue");async function Fn(e,n){if((await e.prepare("SELECT deleting_at FROM nodes WHERE node_id = ?").get(n))?.deleting_at)throw new Error("run is deleting")}i(Fn,"assertRunNotDeleting");async function V(e,n,t,a){try{return(le(n).manifest.grantee??"app:terminal")!==a?null:await Ye(e,n,t)}catch(r){if(r instanceof Qe&&r.code==="not_found")return null;throw r}}i(V,"profileObjectFor");async function Xe(e,n){const t=await Be(n,e.grantee??"app:terminal"),a=e.profile_id?await V(n,e.profile_id,t,e.grantee??"app:terminal"):null;await qe(n,{id:e.node_id,type:"node",kind:e.kind,owner:(a??t).id,privacy:"public",name:e.name,preview:""}),a===null&&e.sub&&await Q(n,e.node_id,e.sub),await n.prepare(`INSERT INTO nodes (node_id, description, title, icon, cycles, mode, lifecycle, cwd, host_kind, profile_id, parent, spawned_by, creator, fork_from, fork_source_file, created, passive_default, cycle_pending, model_override, persona_ack_json, review_binding_json, launch_config_json, scopes_json, isolated, status, intent, final_report, finalized_at, deadline_at, "window", tmux_session, pane, sub, grant_id, client_id, metadata_json, run_id, event_cursor, usage_json, deleting_at, caused_by, app) VALUES (${Array(42).fill("?").join(", ")})`).run(e.node_id,e.description??null,e.title??null,e.icon??null,e.cycles??null,e.mode,e.lifecycle,e.cwd,e.host_kind??null,e.profile_id??null,e.parent??null,e.spawned_by??null,e.creator??null,e.fork_from??null,e.fork_source_file??null,e.created,e.passive_default===!0?1:0,e.cycle_pending===!0?1:0,e.model_override??null,E(e.persona_ack,"persona_ack"),E(e.review_binding,"review_binding"),E(e.launch,"launch"),E(e.scopes,"scopes"),e.isolated===!0?1:0,e.status??"active",e.intent??null,e.final_report??null,e.finalized_at??null,e.deadline_at??null,e.window??null,e.tmux_session??null,e.pane??null,e.sub??null,e.grant_id??null,e.client_id??null,e.metadata_json??null,e.run_id??null,e.event_cursor??null,e.usage_json??null,e.deleting_at??null,e.caused_by??null,t.id)}i(Xe,"seedRow");function K(e){if(e.fault_id==null)return null;const n=Object.entries(e).filter(([t])=>t.startsWith("fault_")).map(([t,a])=>[t==="fault_id"?t:t.slice(6),a]);return ke(Object.fromEntries(n))}i(K,"faultFrom");const G=i(e=>e.turn_open_at!=null&&e.turn_closed_at==null,"turnOpen"),X=i(e=>e||Ie(),"engineLive");function f(e){const n={node_id:e.node_id,name:e.name,description:e.description??void 0,cycles:e.cycles??void 0,kind:e.kind,mode:e.mode,lifecycle:e.lifecycle,status:e.status,cwd:e.cwd,host_kind:e.host_kind??null,profile_id:e.profile_id??null,scopes:e.scopes_json==null?null:JSON.parse(e.scopes_json),isolated:e.isolated===1,grantee:e.grantee,sub:e.sub??null,grant_id:e.grant_id??null,client_id:e.client_id??null,metadata_json:e.metadata_json??null,run_id:e.run_id??null,event_cursor:e.event_cursor??null,last_activity_at:e.last_activity_at??null,usage_json:e.usage_json??null,caused_by:e.caused_by??null,last_turn_error_json:e.last_turn_error_json??null,deleting_at:e.deleting_at??null,parent:e.parent??null,created:e.created,intent:e.intent??null,frozen_at:e.frozen_at??null,respawn_failures:e.respawn_failures??0,respawn_not_before:e.respawn_not_before??null,launched_at:e.launched_at??null,last_settled_at:e.last_settled_at??null,terminal_reason:e.terminal_reason??null,final_report:e.final_report??null,finalized_at:e.finalized_at??null,outcome_kind:e.outcome_kind??null,outcome_reason:e.outcome_reason??null,outcome_at:e.outcome_at??null,outcome_revision:e.outcome_revision??0,outcome_detail_json:e.outcome_detail_json??null,deadline_at:e.deadline_at??null,telemetry_tokens_in:e.telemetry_tokens_in??null,telemetry_context_tokens:e.telemetry_context_tokens??null,telemetry_last_activity:e.telemetry_last_activity??null,telemetry_updated_at:e.telemetry_updated_at??null,pi_pid:e.pi_pid??null,pi_pid_identity:e.pi_pid_identity??null,window:e.window??null,tmux_session:e.tmux_session??null,pane:e.pane??null,fault:null,streaming:!1},t=J(n.pi_pid),a=K(e);return n.fault=a?.link==="pi\u2192provider"&&a.retry.by==="daemon"&&a.retry.disposition==="auto"&&!t?null:a,n.streaming=G(e)&&X(t),n}i(f,"rowFrom");async function A(e,n){return n??=await Ue(e.node_id),{...f(e),title:e.title??void 0,icon:e.icon??void 0,spawned_by:e.spawned_by??null,creator:e.creator??null,fork_from:e.fork_from??null,fork_source_file:e.fork_source_file??null,passive_default:e.passive_default===1,cycle_pending:e.cycle_pending===1,model_override:e.model_override??null,scopes:e.scopes_json==null?null:JSON.parse(e.scopes_json),persona_ack:e.persona_ack_json==null?void 0:JSON.parse(e.persona_ack_json),review_binding:e.review_binding_json==null?void 0:JSON.parse(e.review_binding_json),launch:e.launch_config_json==null?void 0:JSON.parse(e.launch_config_json),pi_session_id:e.pi_session_id??null,pi_session_file:e.pi_session_file??null,...n===null?{}:{managed_worktree:n}}}i(A,"metaFrom");async function Cn(e,n={}){return Fe(),await p(async t=>{await Xe(e,t),e.managed_worktree!==void 0&&e.managed_worktree!==null&&await xe(e.node_id,e.managed_worktree,t),n.outcomeDelivery!==void 0&&await z(t,e.node_id,n.outcomeDelivery),await n.withinCreate?.(t,e)}),await Pe(e.node_id),await O(e.node_id)}i(Cn,"createNode");async function O(e){const n=await(await d()).prepare("SELECT * FROM node_rows WHERE node_id = ?").get(e);return n===void 0?null:await A(n)}i(O,"getNode");async function Hn(e){if(e.length===0)return[];const n=v.map(r=>`w.${r} AS worktree_${r}`).join(", "),t=await(await d()).prepareUncached(`SELECT n.*, ${n} FROM node_rows n LEFT JOIN worktrees w ON w.node_id = n.node_id WHERE n.node_id IN (${e.map(()=>"?").join(",")})`).all(...e),a=new Map(t.map(r=>[r.node_id,r]));return await h(e.map(r=>a.get(r)).filter(r=>r!==void 0),async r=>await A(r,ee(r)))}i(Hn,"getNodes");const Ze=1440*60*1e3;function Z(e){return{requestKey:e.request_key,nodeId:e.node_id,state:e.state}}i(Z,"createRequestRecord");async function Mn(e){const n=await(await d()).prepareUncached("SELECT request_key, node_id, state FROM create_requests WHERE request_key = ?").get(e);return n===void 0?null:Z(n)}i(Mn,"findCreateRequest");async function Pn(e){return await p(async n=>{const t=Date.now();await n.prepareUncached("DELETE FROM create_requests WHERE expires_at <= ?").run(t),await n.prepareUncached("INSERT INTO create_requests (request_key, node_id, expires_at, state) VALUES (?, NULL, ?, 'reserved') ON CONFLICT (request_key) DO NOTHING").run(e,t+Ze);const a=await n.prepareUncached("SELECT request_key, node_id, state FROM create_requests WHERE request_key = ?").get(e);return Z(a)})}i(Pn,"reserveCreateRequest");async function $n(e=Date.now()){return Number((await(await d()).prepareUncached("DELETE FROM create_requests WHERE expires_at <= ?").run(e)).changes)}i($n,"pruneExpiredCreateRequests");async function qn(e,n){await(await d()).prepareUncached("UPDATE create_requests SET node_id = ?, state = 'complete' WHERE request_key = ?").run(n,e)}i(qn,"recordCreateRequestNode");async function Bn(e,n,t){const a=await d();return await a.prepareUncached("UPDATE create_requests SET node_id = ?, state = 'reserved', lease_owner = ?, lease_expires_at = ? WHERE request_key = ? AND node_id IS NULL").run(n,t,Date.now()+g,e),(await a.prepareUncached("SELECT node_id FROM create_requests WHERE request_key = ?").get(e))?.node_id??null}i(Bn,"reserveCreateRequestNode");const g=3e4,zn=1e4;async function Jn(e,n,t){const a=Date.now(),r=await(await d()).prepareUncached("UPDATE create_requests SET lease_owner = ?, lease_expires_at = ? WHERE request_key = ? AND node_id = ? AND state = 'reserved' AND (lease_expires_at IS NULL OR lease_expires_at <= ?)").run(t,a+g,e,n,a);return Number(r.changes)>0}i(Jn,"claimCreateLease");async function Yn(e,n){await(await d()).prepareUncached("UPDATE create_requests SET lease_expires_at = ? WHERE request_key = ? AND lease_owner = ?").run(Date.now()+g,e,n)}i(Yn,"renewCreateLease");async function Qn(e){const n=await(await d()).prepareUncached("SELECT lease_expires_at FROM create_requests WHERE request_key = ?").get(e);return n?.lease_expires_at!=null&&Number(n.lease_expires_at)>Date.now()}i(Qn,"createLeaseLive");async function Vn(e,n){await(await d()).prepareUncached("UPDATE create_requests SET state = 'complete' WHERE request_key = ? AND node_id = ?").run(e,n)}i(Vn,"completeCreateRequest");async function Kn(e,n){await p(async t=>{if(n===null){await t.prepareUncached("DELETE FROM create_requests WHERE request_key = ? AND node_id IS NULL").run(e);return}await t.prepareUncached("DELETE FROM create_requests WHERE request_key = ? AND node_id = ?").run(e,n)})}i(Kn,"abandonCreateRequest");function Gn(e){return Ne(e)}i(Gn,"canonicalSessionFile");async function Xn(e){const n=await ge(e);return n===null?null:await O(n)}i(Xn,"findNodeBySessionFile");async function Zn(e){const n=await(await d()).prepare("SELECT * FROM node_rows WHERE node_id = ?").get(e);return n?f(n):null}i(Zn,"getRow");async function et(e){const n=await(await d()).prepare("SELECT * FROM node_rows WHERE pane = ?").get(e);return n?f(n):null}i(et,"getRowByPane");async function nt(e){return(await(await d()).prepare(`SELECT * FROM node_rows
|
|
2
2
|
WHERE deadline_at IS NOT NULL AND outcome_at IS NULL
|
|
3
3
|
AND deadline_at <= ? AND status IN ('active','idle') AND kind != 'human'
|
|
4
4
|
ORDER BY deadline_at, created, node_id`).all(e)).map(f)}i(nt,"dueNodeDeadlines");async function tt(e,n){return Number((await(await d()).prepare("UPDATE nodes SET deadline_at = ? WHERE node_id = ?").run(n,e)).changes)===1}i(tt,"setNodeDeadline");async function at(e,n){return!Number.isFinite(n)||n<=0?0:await p(async t=>{const a=await t.prepare(`SELECT node_id, deadline_at FROM nodes
|
|
5
|
-
WHERE profile_id = ? AND deadline_at IS NOT NULL AND status IN ('active', 'idle')`).all(e),r=t.prepare("UPDATE nodes SET deadline_at = ? WHERE node_id = ? AND deadline_at = ?");let o=0;for(const s of a){const c=Date.parse(s.deadline_at);Number.isNaN(c)||(o+=Number((await r.run(new Date(c+n).toISOString(),s.node_id,s.deadline_at)).changes))}return o})}i(at,"shiftProfileNodeDeadlines");function
|
|
5
|
+
WHERE profile_id = ? AND deadline_at IS NOT NULL AND status IN ('active', 'idle')`).all(e),r=t.prepare("UPDATE nodes SET deadline_at = ? WHERE node_id = ? AND deadline_at = ?");let o=0;for(const s of a){const c=Date.parse(s.deadline_at);Number.isNaN(c)||(o+=Number((await r.run(new Date(c+n).toISOString(),s.node_id,s.deadline_at)).changes))}return o})}i(at,"shiftProfileNodeDeadlines");function k(e,n){if(e==null)return null;if(typeof e=="string"||typeof e=="number"||typeof e=="bigint"||e instanceof Uint8Array)return e;throw new TypeError(`${n} must be a SQLite scalar`)}i(k,"sqlInput");async function it(e,n){const t=[],a=i((o,s=o)=>{Object.prototype.hasOwnProperty.call(n,o)&&t.push([s,k(n[o],o)])},"add");if(a("description"),a("title"),a("icon"),a("cycles"),a("mode"),a("lifecycle"),a("cwd"),a("host_kind"),a("profile_id"),a("parent"),a("spawned_by"),a("creator"),a("fork_from"),a("fork_source_file"),a("model_override"),Object.prototype.hasOwnProperty.call(n,"passive_default")&&t.push(["passive_default",n.passive_default===!0?1:0]),Object.prototype.hasOwnProperty.call(n,"cycle_pending")&&t.push(["cycle_pending",n.cycle_pending===!0?1:0]),Object.prototype.hasOwnProperty.call(n,"persona_ack")&&t.push(["persona_ack_json",E(n.persona_ack,"persona_ack")]),Object.prototype.hasOwnProperty.call(n,"review_binding")&&t.push(["review_binding_json",E(n.review_binding,"review_binding")]),Object.prototype.hasOwnProperty.call(n,"isolated"))throw new TypeError("isolated cannot change after node creation");Object.prototype.hasOwnProperty.call(n,"scopes")&&t.push(["scopes_json",E(n.scopes,"scopes")]),Object.prototype.hasOwnProperty.call(n,"launch")&&t.push(["launch_config_json",E(n.launch,"launch")]);const r=i(o=>Object.prototype.hasOwnProperty.call(n,o),"has");return await p(async o=>{const s=await D(o,e);if(s===null||s.type!=="node")throw new Error(`unknown node: ${e}`);if(r("name")&&await Je(o,s,k(n.name,"name")),r("kind")&&await ze(o,s,k(n.kind,"kind")),t.length===0)return;if(r("profile_id")){const u=await o.prepare("SELECT app FROM nodes WHERE node_id = ?").get(e),_=u?.app?await D(o,u.app):null;if(_){const w=n.profile_id?await V(o,n.profile_id,_,`app:${_.name}`):null;await o.prepare("UPDATE objects SET owner = ? WHERE id = ?").run((w??_).id,e);const N=(await o.prepare("SELECT sub FROM nodes WHERE node_id = ?").get(e)).sub;w===null&&N&&await Q(o,e,N)}}if((await o.prepareUncached(`UPDATE nodes SET ${t.map(([u])=>`${u} = ?`).join(", ")} WHERE node_id = ?`).run(...t.map(([,u])=>u),e)).changes!==1)throw new Error(`unknown node: ${e}`)}),await O(e)}i(it,"updateNode");async function rt(e,n){await(await d()).prepare("UPDATE nodes SET status = ? WHERE node_id = ?").run(n,e)}i(rt,"setStatus");async function ot(e,n){await(await d()).prepare("UPDATE nodes SET intent = ? WHERE node_id = ?").run(n??null,e)}i(ot,"setIntent");async function st(e,n,t={}){if(t.outcome===void 0){const r=[],o=[];Object.prototype.hasOwnProperty.call(n,"status")&&(r.push("status = ?"),o.push(n.status??null)),Object.prototype.hasOwnProperty.call(n,"intent")&&(r.push("intent = ?"),o.push(n.intent??null)),Object.prototype.hasOwnProperty.call(n,"terminal_reason")&&(r.push("terminal_reason = ?"),o.push(n.terminal_reason??null));const s=["node_id = ?"];o.push(e),t.fromStatuses!==void 0&&(s.push(`status IN (${t.fromStatuses.map(()=>"?").join(", ")})`),o.push(...t.fromStatuses)),t.requireNoFinalReport===!0&&s.push("final_report IS NULL");const c=await(await d()).prepareUncached(`UPDATE nodes SET ${r.join(", ")} WHERE ${s.join(" AND ")}`).run(...o);return Number(c.changes)}const a=t.outcome;return await p(async r=>{const o=[],s=[];Object.prototype.hasOwnProperty.call(n,"status")&&(o.push("status = ?"),s.push(n.status??null)),Object.prototype.hasOwnProperty.call(n,"intent")&&(o.push("intent = ?"),s.push(n.intent??null)),Object.prototype.hasOwnProperty.call(n,"terminal_reason")&&(o.push("terminal_reason = ?"),s.push(n.terminal_reason??null));const c=i((N,R)=>a.supersede===!0?"?":`CASE WHEN outcome_at IS NULL THEN ? ELSE ${R} END`,"outcomeValue");o.push(`outcome_kind = ${c(a.kind,"outcome_kind")}`,`outcome_reason = ${c(a.reason,"outcome_reason")}`,`outcome_detail_json = ${c(a.detailJson,"outcome_detail_json")}`,`outcome_revision = ${a.supersede===!0?"outcome_revision + 1":"CASE WHEN outcome_at IS NULL THEN outcome_revision + 1 ELSE outcome_revision END"}`,`outcome_at = ${c(a.at,"outcome_at")}`),s.push(a.kind,a.reason,a.detailJson,a.at);const u=["node_id = ?"];s.push(e),t.fromStatuses!==void 0&&(u.push(`status IN (${t.fromStatuses.map(()=>"?").join(", ")})`),s.push(...t.fromStatuses)),t.requireNoFinalReport===!0&&u.push("final_report IS NULL");const _=await r.prepareUncached(`UPDATE nodes SET ${o.join(", ")} WHERE ${u.join(" AND ")}`).run(...s);if(Number(_.changes)===0)return 0;const w=await r.prepare("SELECT outcome_at FROM nodes WHERE node_id = ?").get(e);return(a.supersede===!0||w.outcome_at===a.at)&&a.documentJson!==null&&a.documentJson!==void 0&&await De(r,{event:"outcome",object:await Ae(r,e),actor:null,attrs:{revision:Number((await r.prepare("SELECT outcome_revision FROM nodes WHERE node_id = ?").get(e)).outcome_revision)},messageBody:JSON.parse(a.documentJson)}),Number(_.changes)})}i(st,"transitionStatusIntent");async function dt(e){return(await(await d()).prepare("SELECT final_report FROM nodes WHERE node_id = ?").get(e))?.final_report??null}i(dt,"getFinalReport");async function ut(e,n){return(await(await d()).prepare("UPDATE nodes SET final_report = NULL, finalized_at = NULL WHERE node_id = ? AND final_report = ?").run(e,n)).changes>0}i(ut,"clearFinalReportIfMatches");async function ct(e,n){await(await d()).prepare('UPDATE nodes SET tmux_session = ?, "window" = ?, pane = ? WHERE node_id = ?').run(n.tmux_session??null,n.window??null,n.pane??null,e)}i(ct,"setPresence");async function lt(e,n){await(await d()).prepare("UPDATE nodes SET launched_at = ?, frozen_at = NULL, respawn_not_before = NULL WHERE node_id = ?").run(n,e)}i(lt,"recordLaunch");async function _t(e,n){await(await d()).prepare("UPDATE nodes SET last_settled_at = ? WHERE node_id = ?").run(n,e)}i(_t,"recordSettledTurn");async function pt(e,n){await(await d()).prepare("UPDATE nodes SET frozen_at = ? WHERE node_id = ?").run(n,e)}i(pt,"setFrozen");async function ft(e){await(await d()).prepare("UPDATE nodes SET frozen_at = NULL WHERE node_id = ?").run(e)}i(ft,"clearFrozen");async function Et(e,n){await(await d()).prepare("UPDATE nodes SET respawn_failures = ?, respawn_not_before = ? WHERE node_id = ?").run(n.failures,n.notBefore,e)}i(Et,"recordRespawnAttempt");const m="node_id NOT IN (SELECT node_id FROM warm_pool)",v=["state","cleanup_state","path","branch","repo_root","base_ref","base_sha","created_at","closed_at","next_attempt_at","attempts","quarantined","sweep_reason","sweep_detail","sweep_last_at","sweep_observed_json","abandoned_json","land_intent_json","disposal_json"];function ee(e){return e.worktree_state===null?null:We(Object.fromEntries(v.map(n=>[n,e[`worktree_${n}`]])))}i(ee,"worktreeFromProjection");async function wt(e){const n=v.map(a=>`w.${a} AS worktree_${a}`).join(", "),t=await(await d()).prepareUncached(`SELECT n.*, ${n} FROM node_rows n LEFT JOIN worktrees w ON w.node_id = n.node_id WHERE n.profile_id = ? ORDER BY n.created`).all(e);return await h(t,async a=>await A(a,ee(a)))}i(wt,"listNodesByProfile");async function yt(){return(await(await d()).prepare(`SELECT
|
|
6
6
|
node_id, name, description, kind, mode, lifecycle, status, cwd, profile_id,
|
|
7
7
|
grantee, parent, created, frozen_at, terminal_reason, final_report,
|
|
8
8
|
telemetry_tokens_in, telemetry_updated_at, pi_pid, turn_open_at, turn_closed_at,
|
|
@@ -50,13 +50,13 @@ var ce=Object.defineProperty;var i=(e,n)=>ce(e,"name",{value:n,configurable:!0})
|
|
|
50
50
|
AND EXISTS (SELECT 1 FROM deliveries d WHERE d.destination_id = v.node_id AND ${Te("d")}) AND v.kind != 'human' AND v.node_id NOT IN (SELECT node_id FROM warm_pool)
|
|
51
51
|
ORDER BY v.created`).all()).map(f)}i(Ot,"listParkedResidentsWithWakeMail");async function Lt(e,n){await(await d()).prepare("INSERT INTO warm_pool (node_id, recipe_key, created) VALUES (?, ?, ?) ON CONFLICT (node_id) DO UPDATE SET recipe_key = excluded.recipe_key, created = excluded.created").run(e,n,new Date().toISOString())}i(Lt,"registerWarmSpare");async function Tt(e){return(await(await d()).prepare("DELETE FROM warm_pool WHERE node_id = ?").run(e)).changes>0}i(Tt,"unregisterWarmSpare");async function x(e,n){const t=`SELECT w.node_id AS node_id, w.recipe_key AS recipe_key, w.created AS created,
|
|
52
52
|
n.status AS status, n.pi_pid AS pi_pid, n.pi_pid_identity AS pi_pid_identity
|
|
53
|
-
FROM warm_pool w JOIN node_rows n ON n.node_id = w.node_id`+(n===void 0?"":" WHERE w.recipe_key = ?")+" ORDER BY w.created";return(n===void 0?await e.prepareUncached(t).all():await e.prepareUncached(t).all(n)).map(r=>({node_id:r.node_id,recipe_key:r.recipe_key,created:r.created,status:r.status,pi_pid:r.pi_pid??null,pi_pid_identity:r.pi_pid_identity??null}))}i(x,"warmSpareRowsFor");async function Dt(){return await x(await d())}i(Dt,"listWarmSpares");async function At(e){return await(await d()).prepare("SELECT 1 FROM warm_pool WHERE node_id = ?").get(e)!==void 0}i(At,"isWarmSpare");function te(e){return e.status!=="active"&&e.status!=="idle"?!1:be(e.pi_pid,e.pi_pid_identity)==="alive"}i(te,"spareIsClaimable");async function gt(e,n,t={}){return await p(async a=>{const r=(await x(a,e)).find(te);return r===void 0||t.requestKey!==void 0&&(await a.prepareUncached("UPDATE create_requests SET node_id = ?, state = 'warm_claimed' WHERE request_key = ? AND node_id IS NULL").run(r.node_id,t.requestKey)).changes===0||(await a.prepare("DELETE FROM warm_pool WHERE node_id = ?").run(r.node_id)).changes===0?null:(await a.prepare("UPDATE nodes SET created = ?, deadline_at = ? WHERE node_id = ?").run(n,t.deadlineAt??null,r.node_id),t.outcomeDelivery!==void 0&&await z(a,r.node_id,t.outcomeDelivery),r.node_id)})}i(gt,"claimWarmSpare");async function
|
|
53
|
+
FROM warm_pool w JOIN node_rows n ON n.node_id = w.node_id`+(n===void 0?"":" WHERE w.recipe_key = ?")+" ORDER BY w.created";return(n===void 0?await e.prepareUncached(t).all():await e.prepareUncached(t).all(n)).map(r=>({node_id:r.node_id,recipe_key:r.recipe_key,created:r.created,status:r.status,pi_pid:r.pi_pid??null,pi_pid_identity:r.pi_pid_identity??null}))}i(x,"warmSpareRowsFor");async function Dt(){return await x(await d())}i(Dt,"listWarmSpares");async function At(e){return await(await d()).prepare("SELECT 1 FROM warm_pool WHERE node_id = ?").get(e)!==void 0}i(At,"isWarmSpare");function te(e){return e.status!=="active"&&e.status!=="idle"?!1:be(e.pi_pid,e.pi_pid_identity)==="alive"}i(te,"spareIsClaimable");async function gt(e,n,t={}){return await p(async a=>{const r=(await x(a,e)).find(te);return r===void 0||t.requestKey!==void 0&&(await a.prepareUncached("UPDATE create_requests SET node_id = ?, state = 'warm_claimed' WHERE request_key = ? AND node_id IS NULL").run(r.node_id,t.requestKey)).changes===0||(await a.prepare("DELETE FROM warm_pool WHERE node_id = ?").run(r.node_id)).changes===0?null:(await a.prepare("UPDATE nodes SET created = ?, deadline_at = ? WHERE node_id = ?").run(n,t.deadlineAt??null,r.node_id),t.outcomeDelivery!==void 0&&await z(a,r.node_id,t.outcomeDelivery),r.node_id)})}i(gt,"claimWarmSpare");async function kt(e){return(await x(await d(),e)).filter(te).length}i(kt,"warmSpareCount");async function vt(e){return(await(await d()).prepare("SELECT node_id FROM nodes WHERE parent = ? ORDER BY created").all(e)).map(n=>n.node_id)}i(vt,"childrenOf");async function xt(e){return(await(await d()).prepareUncached(`SELECT node_id, name, kind, mode, lifecycle, status, cwd, host_kind, parent, created, description
|
|
54
54
|
FROM node_rows WHERE ${m}${e===void 0?"":" AND node_id = ANY(?::text[])"} ORDER BY created`).all(...e===void 0?[]:[[...e]])).map(n=>({node_id:n.node_id,name:n.name,kind:n.kind,mode:n.mode,lifecycle:n.lifecycle,status:n.status,cwd:n.cwd,host_kind:n.host_kind??null,parent:n.parent??null,created:n.created,description:n.description??null}))}i(xt,"rosterNodes");async function Ut(e){return(await(await d()).prepareUncached(`SELECT * FROM node_rows
|
|
55
55
|
WHERE parent IS NULL AND kind != 'human'
|
|
56
56
|
AND status IN ('active','idle') AND cwd = ?
|
|
57
57
|
AND ${m}
|
|
58
|
-
ORDER BY created DESC`).all(e)).map(f)}i(Ut,"listResumableRoots");export*from"./tree.js";async function Wt(e,n,t){return await p(async a=>{const r=await a.prepare("SELECT status, final_report, frozen_at FROM nodes WHERE node_id = ? FOR UPDATE").get(e);return r===void 0?{kind:"missing"}:n(r)?{kind:"terminal",status:r.status,final_report:r.final_report}:{kind:"ran",result:await t()}})}i(Wt,"withFreshTerminalGuard");async function L(e){return await
|
|
59
|
-
AND NOT EXISTS (SELECT 1 FROM sessions s WHERE s.node_id = n.node_id) LIMIT 1`);for(const{id:r,path:o,dir:s}of e)if(
|
|
58
|
+
ORDER BY created DESC`).all(e)).map(f)}i(Ut,"listResumableRoots");export*from"./tree.js";async function Wt(e,n,t){return await p(async a=>{const r=await a.prepare("SELECT status, final_report, frozen_at FROM nodes WHERE node_id = ? FOR UPDATE").get(e);return r===void 0?{kind:"missing"}:n(r)?{kind:"terminal",status:r.status,final_report:r.final_report}:{kind:"ran",result:await t()}})}i(Wt,"withFreshTerminalGuard");async function L(e){return await ve(e)}i(L,"hasUnreconciledManagedWorktree");async function ae(e,n={}){return!["done","dead","canceled"].includes(e.status)||e.pi_pid!==null||e.frozen_at!==null||await L(e.node_id)||e.node_id===H()||B(e)?!1:n.pastTtl===!0||!["crashed","stranded",null].includes(e.terminal_reason??null)}i(ae,"isCollectible");async function U(e){if(e.length===0)return[];const n=e.map(()=>"?").join(","),t=await(await d()).prepareUncached(`SELECT s.session_id, s.transcript_path, s.node_id, n.grantee FROM sessions s JOIN node_rows n ON n.node_id = s.node_id WHERE s.node_id IN (${n}) AND s.session_id IS NOT NULL ORDER BY s.created_at, s.seq`).all(...e);return[...new Map(t.map(a=>[a.session_id,{id:a.session_id,path:a.transcript_path,dir:S(T(a.grantee).conversations,a.node_id)}])).values()]}i(U,"nodeConversationIds");async function W(e){const n=await d(),t=n.prepare("SELECT 1 FROM sessions WHERE session_id = ? LIMIT 1"),a=n.prepare(`SELECT 1 FROM nodes n WHERE n.fork_source_file LIKE '%\\_' || ? || '.jsonl' ESCAPE '\\'
|
|
59
|
+
AND NOT EXISTS (SELECT 1 FROM sessions s WHERE s.node_id = n.node_id) LIMIT 1`);for(const{id:r,path:o,dir:s}of e){if(await t.get(r)!==void 0||await a.get(r)!==void 0)continue;const c=o!==null&&_e(o,{throwIfNoEntry:!1})!==void 0&&rn(s,o)?o:void 0;try{await he().delete(r,c)}catch(u){if(!(u instanceof Oe))throw u}}}i(W,"deleteNodeConversations");function rn(e,n){try{const t=me(M(e),S(M(P(n)),we(n)));return t!==""&&t!==".."&&!t.startsWith(`..${Re}`)&&!ye(t)}catch(t){if(t.code==="ENOENT")return!1;throw t}}i(rn,"isBeneath");async function j(e,n){const t=await D(e,n);return t===null||t.deleted_at!==null?!1:(await Ve(e,t),!0)}i(j,"deleteNodeObject");async function b(e){return{nodeId:e,app:await O(e)===null?null:await Me(e)}}i(b,"nodeFiles");async function ie({nodeId:e,app:n}){n!==null&&$(T(n).nodes,await $e(e,n)),$(P(Y(e)),Y(e))}i(ie,"removeNodeAppTrees");function re({nodeId:e}){return[He(e)]}i(re,"nodeOwnedDirs");function oe({nodeId:e,app:n}){if(n!==null)try{pe(S(T(n).conversations,e))}catch(t){if(!["ENOENT","ENOTEMPTY"].includes(t.code??""))throw t}}i(oe,"removeNodeConversationDir");async function I(e){await ie(e);for(const n of re(e))fe(n,{recursive:!0,force:!0});oe(e)}i(I,"removeNodeFiles");async function se(e){const n=await q(e);if(n.length>0)throw new Error(`the sandbox of node(s) ${n.join(", ")} could not be deleted; the node rows are kept`)}i(se,"requireSandboxesDeleted");async function jt(e){if(await L(e))return{deleted:!1};await se([e]);const n=await b(e),t=await U([e]),a=await p(async r=>(await j(r,e),{deleted:!0}));return await W(t),await I(n),a}i(jt,"deleteNode");async function bt(e){const n=[...new Set(e)];if(n.length===0)return[];const t=await y(n,L);if(t.length>0)throw new Error(`refusing to delete nodes with unreconciled managed worktrees: ${t.join(", ")}`);await se(n);const a=await h(n,b),r=await U(n),o=n.map(()=>"?").join(","),s=(await(await d()).prepareUncached(`SELECT node_id FROM nodes WHERE node_id IN (${o}) ORDER BY created`).all(...n)).map(({node_id:u})=>u),c=await y(s,async u=>await p(async _=>await j(_,u)));await W(r);for(const u of c){const _=a[n.indexOf(u)];await C(_,async()=>await I(_))}return c}i(bt,"deleteNodes");async function It(e){const n=e.dryRun??!1,t=e.includeStale??!1,a=Date.now()-e.ttlDays*864e5,r=new Date(a).toISOString(),o=H()??"",s=await d(),c=i(l=>ue(l)<a,"quiet"),u=i(l=>({node_id:l.node_id,status:l.status,created:l.created}),"toPruned"),_=await on(),w=(await y((await s.prepare(`SELECT * FROM node_rows
|
|
60
60
|
WHERE status IN ('dead', 'done', 'canceled') AND created < ?
|
|
61
61
|
ORDER BY created`).all(r)).map(f),async l=>await ae(l,{pastTtl:!0})&&c(l)&&!_.has(l.node_id)&&!await e.held(l.node_id))).map(u),N=t?(await y((await s.prepare(`SELECT * FROM node_rows
|
|
62
62
|
WHERE status IN ('active', 'idle') AND created < ?
|
|
@@ -64,4 +64,4 @@ var ce=Object.defineProperty;var i=(e,n)=>ce(e,"name",{value:n,configurable:!0})
|
|
|
64
64
|
JOIN objects d ON d.id = w.object AND d.type = 'document' AND d.deleted_at IS NULL
|
|
65
65
|
JOIN objects o ON o.id = w.watcher AND o.deleted_at IS NULL
|
|
66
66
|
LEFT JOIN nodes n ON n.node_id = w.watcher
|
|
67
|
-
WHERE w.watcher != d.owner AND d.owner IS NOT NULL AND (n.node_id IS NULL OR n.status IN ('active', 'idle'))`).all();return new Set(e.map(n=>n.owner))}i(on,"ownersOfWatchedDocuments");async function F(e){const t=(await d()).prepare("SELECT node_id FROM nodes WHERE run_id = ? AND node_id != ?"),a=new Set(e.map(r=>r.node_id));return await y(e,async r=>(await t.all(r.node_id,r.node_id)).every(o=>a.has(o.node_id)))}i(F,"retainRunRootsWithMembers");async function de(e,n){const t=new Set(await q(e.map(s=>s.node_id))),a=t.size===0?e:await F(e.filter(s=>!t.has(s.node_id)));if(a.length===0)return[];const r=await h(a,async s=>await b(s.node_id)),o=await U(a.map(s=>s.node_id));for(const s of a)await p(async c=>await j(c,s.node_id));if(await W(o),n!==void 0){for(const s of r)await C(s,async()=>{await ie(s),oe(s)});return n(r.flatMap(re)),a}for(const s of r)await C(s,async()=>await I(s));return a}i(de,"deletePrunedNodes");async function C(e,n){try{await n()}catch(t){Se({level:"error",event:"canvas.node_files.remove_failed",error:t,fields:{node_id:e.nodeId}})}}i(C,"eachNodeBestEffort");function ue(e){let n=0;for(const t of[e.created,e.launched_at,e.last_settled_at,e.finalized_at,e.outcome_at,e.last_activity_at]){if(t==null)continue;const a=Date.parse(t);Number.isFinite(a)&&a>n&&(n=a)}try{const t=Ee(S(Ce(e.node_id),"telemetry.json"),{throwIfNoEntry:!1});t!==void 0&&t.mtimeMs>n&&(n=t.mtimeMs)}catch{}return n}i(ue,"lastActivityMs");async function Ft(e){const n=e.dryRun??!1,t=await en(),a=await y(t,async u=>await ae(u)&&!await e.held(u.node_id)),r=t.length-a.length,o=Math.max(0,e.maxNodes-r),s=a.map(u=>({row:u,recency:ue(u)})).sort((u,_)=>_.recency-u.recency).slice(o).map(({row:u})=>({node_id:u.node_id,status:u.status,created:u.created})),c=await F(s);return n||c.length===0?{pruned:c,dryRun:n}:{pruned:await de(c),dryRun:n}}i(Ft,"pruneToLimit");export{g as CREATE_LEASE_MS,zn as CREATE_LEASE_RENEW_MS,ne as PARKED_RESIDENT_SQL,an as RESUMABLE_NODE_SQL,Kn as abandonCreateRequest,Fn as assertRunNotDeleting,yt as browseNodes,Gn as canonicalSessionFile,
|
|
67
|
+
WHERE w.watcher != d.owner AND d.owner IS NOT NULL AND (n.node_id IS NULL OR n.status IN ('active', 'idle'))`).all();return new Set(e.map(n=>n.owner))}i(on,"ownersOfWatchedDocuments");async function F(e){const t=(await d()).prepare("SELECT node_id FROM nodes WHERE run_id = ? AND node_id != ?"),a=new Set(e.map(r=>r.node_id));return await y(e,async r=>(await t.all(r.node_id,r.node_id)).every(o=>a.has(o.node_id)))}i(F,"retainRunRootsWithMembers");async function de(e,n){const t=new Set(await q(e.map(s=>s.node_id))),a=t.size===0?e:await F(e.filter(s=>!t.has(s.node_id)));if(a.length===0)return[];const r=await h(a,async s=>await b(s.node_id)),o=await U(a.map(s=>s.node_id));for(const s of a)await p(async c=>await j(c,s.node_id));if(await W(o),n!==void 0){for(const s of r)await C(s,async()=>{await ie(s),oe(s)});return n(r.flatMap(re)),a}for(const s of r)await C(s,async()=>await I(s));return a}i(de,"deletePrunedNodes");async function C(e,n){try{await n()}catch(t){Se({level:"error",event:"canvas.node_files.remove_failed",error:t,fields:{node_id:e.nodeId}})}}i(C,"eachNodeBestEffort");function ue(e){let n=0;for(const t of[e.created,e.launched_at,e.last_settled_at,e.finalized_at,e.outcome_at,e.last_activity_at]){if(t==null)continue;const a=Date.parse(t);Number.isFinite(a)&&a>n&&(n=a)}try{const t=Ee(S(Ce(e.node_id),"telemetry.json"),{throwIfNoEntry:!1});t!==void 0&&t.mtimeMs>n&&(n=t.mtimeMs)}catch{}return n}i(ue,"lastActivityMs");async function Ft(e){const n=e.dryRun??!1,t=await en(),a=await y(t,async u=>await ae(u)&&!await e.held(u.node_id)),r=t.length-a.length,o=Math.max(0,e.maxNodes-r),s=a.map(u=>({row:u,recency:ue(u)})).sort((u,_)=>_.recency-u.recency).slice(o).map(({row:u})=>({node_id:u.node_id,status:u.status,created:u.created})),c=await F(s);return n||c.length===0?{pruned:c,dryRun:n}:{pruned:await de(c),dryRun:n}}i(Ft,"pruneToLimit");export{g as CREATE_LEASE_MS,zn as CREATE_LEASE_RENEW_MS,ne as PARKED_RESIDENT_SQL,an as RESUMABLE_NODE_SQL,Kn as abandonCreateRequest,Fn as assertRunNotDeleting,yt as browseNodes,Gn as canonicalSessionFile,vt as childrenOf,Jn as claimCreateLease,gt as claimWarmSpare,ut as clearFinalReportIfMatches,ft as clearFrozen,Vn as completeCreateRequest,Qn as createLeaseLive,Cn as createNode,jt as deleteNode,bt as deleteNodes,nt as dueNodeDeadlines,Mn as findCreateRequest,Xn as findNodeBySessionFile,dt as getFinalReport,O as getNode,Hn as getNodes,Zn as getRow,et as getRowByPane,Nt as graphNodes,ae as isCollectible,At as isWarmSpare,ue as lastActivityMs,en as listNodes,wt as listNodesByProfile,St as listNodesForSupervision,Ot as listParkedResidentsWithWakeMail,Ut as listResumableRoots,Rt as listTerminalPlacementResidue,Dt as listWarmSpares,b as nodeFiles,tn as nodesForSupervisionSql,$n as pruneExpiredCreateRequests,It as pruneNodes,Ft as pruneToLimit,qn as recordCreateRequestNode,lt as recordLaunch,Et as recordRespawnAttempt,_t as recordSettledTurn,Lt as registerWarmSpare,I as removeNodeFiles,Yn as renewCreateLease,Pn as reserveCreateRequest,Bn as reserveCreateRequestNode,ht as resumableNodeCwds,xt as rosterNodes,pt as setFrozen,ot as setIntent,tt as setNodeDeadline,ct as setPresence,rt as setStatus,at as shiftProfileNodeDeadlines,nn as terminalPlacementResidueSql,st as transitionStatusIntent,Tt as unregisterWarmSpare,it as updateNode,mt as updateNodeTelemetry,kt as warmSpareCount,Wt as withFreshTerminalGuard};
|