@north-light/cli 0.3.652 → 0.3.653
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/build-root.js +1 -1
- package/dist/core/canvas/managed-worktree-sweep-candidates.d.ts +2 -1
- package/dist/core/canvas/managed-worktree-sweep-candidates.js +1 -1
- package/dist/core/canvas/schema-pg/017-machine-worktree-ops.sql +7 -0
- package/dist/core/canvas/schema-version.d.ts +1 -1
- package/dist/core/canvas/schema-version.js +1 -1
- package/dist/core/command-plugins/compose.d.ts +5 -1
- package/dist/core/command-plugins/compose.js +1 -1
- package/dist/core/runtime/runner/machine/call.d.ts +2 -1
- package/dist/core/runtime/runner/machine/call.js +2 -2
- package/dist/core/runtime/runner/machine/executor.d.ts +1 -1
- package/dist/core/runtime/runner/machine/ops.d.ts +59 -1
- package/dist/core/runtime/runner/machine/ops.js +1 -1
- package/dist/core/runtime/spawn.js +2 -2
- package/dist/core/worktree-close.d.ts +27 -0
- package/dist/core/worktree-close.js +6 -6
- package/dist/core/worktree-machine.d.ts +27 -0
- package/dist/core/worktree-machine.js +1 -0
- package/dist/core/worktree-mutation-async.d.ts +31 -0
- package/dist/core/worktree-mutation-async.js +7 -7
- package/dist/daemon/api/handlers/human-requests.js +1 -1
- package/dist/daemon/api/handlers/nodes.js +1 -1
- package/dist/daemon/api/handlers/reports.js +5 -5
- package/dist/daemon/api/handlers/worktree.js +1 -1
- package/dist/daemon/machine-daemon.js +1 -1
- package/package.json +2 -2
- package/packages/crouter-identity/package.json +1 -1
- package/runtime.lock.json +13 -13
package/dist/build-root.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var J=Object.defineProperty;var n=(e,t)=>J(e,"name",{value:t,configurable:!0});import{defineBranch as W,defineRoot as S,GLOBAL_TOKENS as E}from"./core/command.js";import{createCoreHookCatalog as P}from"./core/command-hooks/catalog.js";import{composeCoreHooks as N}from"./core/command-hooks/compose.js";import{mark as h}from"./core/timing.js";import{ApiError as $}from"./api/errors.js";import{CrtrError as K}from"./core/errors.js";import{envNodeId as X,envScopes as Y,isSandboxedNode as B,providerProjectionOverBrokerRelay as Q,scopeAllowed as V}from"./shared/env.js";const b="crtr: agentic runtime.",C=[{name:"--json",desc:"stdout as the leaf's declared outputs in raw JSON instead of prose \u2014 for scripts (a cron's bash, external tooling) that must branch on canvas state; prose stays the contract for what you read yourself."}],O=Object.assign(Object.create(null),{doc:n(async()=>(await import("./commands/doc.js")).registerDoc(),"doc"),"custom-object":n(async()=>(await import("./commands/custom-object.js")).registerCustomObject(),"custom-object"),profile:n(async()=>(await import("./commands/profile.js")).registerProfile(),"profile"),pkg:n(async()=>(await import("./commands/pkg.js")).registerPkg(),"pkg"),human:n(async()=>(await import("./commands/human.js")).registerHuman(),"human"),sys:n(async()=>(await import("./commands/sys.js")).registerSys(),"sys"),node:n(async()=>(await import("./commands/node.js")).registerNode(),"node"),push:n(async()=>(await import("./commands/push.js")).registerPush(),"push"),cron:n(async()=>(await import("./commands/cron.js")).registerCron(),"cron"),canvas:n(async()=>(await import("./commands/canvas.js")).registerCanvas(),"canvas"),surface:n(async()=>(await import("./commands/surface.js")).registerSurface(),"surface")}),m=Object.freeze(Object.keys(O)),Z={human:["crtr:act"],cron:["crtr:schedule"],doc:["crtr:memory:read:user","crtr:memory:rw:user"]};function L(e){const t=Y();return t===null?e:e.filter(r=>{const o=Z[r.name];return o===void 0||o.some(s=>V(t,s))||r.name==="doc"&&process.env.CRTR_GRANTEE?.startsWith("app:")===!0})}n(L,"allowedSubtrees");const M=new Map;function T(e){let t=M.get(e);return t===void 0&&(t=O[e](),M.set(e,t)),t}n(T,"loadSubtree");function k(e){return Promise.all(m.filter(t=>e.has(t)).map(T))}n(k,"loadCoreSubtreesNamed");function x(){return k(new Set(m))}n(x,"loadCoreSubtrees");function R(e){const t=new Set;for(const r of e){const o=r.split(" ")[0];m.includes(o)&&t.add(o)}return t}n(R,"subtreesNamedBy");let A;function he(){return h("cli.hooks.catalog"),A??=x().then(P),A}n(he,"coreHookCatalog");function _(){let e;return()=>(e??=(async()=>{const{compileHookRegistry:t,declaredCommandHookTargets:r,effectiveHookPlugins:o}=await import("./core/command-hooks/discovery.js"),s=o(),a=B()&&X()!==void 0?await(await import("./core/command-hooks/transport/plan.js")).remoteHookPlan(process.cwd()):[];if(h("cli.hooks.effective_plugins",{count:s.length+a.length}),s.length===0&&a.length===0)return h("cli.hooks.empty_registry"),t(P([]),[]);const u=B()?s.filter(l=>l.scope==="project"):s,i=R([...r(u),...a.map(l=>l.target)]);return h("cli.hooks.catalog",{subtrees:[...i].join(",")}),t(P(await k(i)),u,a)})(),e)}n(_,"hookRegistryLoader");function y(e){const t=new Set,r=n((o,s)=>{if(!(o.kind==="branch"&&o.passthrough!==void 0)&&(t.add(s),o.kind==="branch"))for(const a of o.children)r(a,`${s} ${a.name}`)},"visit");for(const o of e)r(o,o.name);return t}n(y,"commandPathsFor");async function we(){return y(await x())}n(we,"coreCommandPaths");async function ye(e){return y(await k(R(e)))}n(ye,"coreCommandPathsCovering");function ee(e){const t=[],r=n((o,s)=>{o.extensible===!0&&t.push(s);for(const a of o.children)a.kind==="branch"&&r(a,[...s,a.name])},"visit");for(const o of e)r(o,[o.name]);return t}n(ee,"extensibleBranchPaths");const te=Object.freeze(["human","sys tutorial"]);async function I(){return new Set(te)}n(I,"extensibleCoreBranches");async function ve(){return new Set(ee(await x()).map(e=>e.join(" ")))}n(ve,"declaredExtensibleCoreBranches");function ne(e,t){const{listing:r,...o}=e.help;return W({name:e.name,description:e.description,whenToUse:e.whenToUse,tier:e.tier,help:o,rootEntry:e.rootEntry,extensible:e.extensible,plugin:e.plugin,slash:e.slash,passthrough:e.passthrough,children:t})}n(ne,"rebuildBranch");async function H(e,t,r){if(t.size===0)return e;const[{buildExternalCommandSnapshot:o},{composeCoreBranchMounts:s}]=await Promise.all([import("./core/command-plugins/discovery.js"),import("./core/command-plugins/compose.js")]),a=o(new Set(m),void 0,void 0,r,t),u=n((i,l)=>{let f=!1;const g=i.children.map(p=>{if(p.kind!=="branch")return p;const d=u(p,[...l,p.name]);return d!==p&&(f=!0),d}),w=i.extensible===!0?s(a.coreMounts,l):[];return f||w.length>0?ne(i,[...g,...w]):i},"composeBranch");return e.map(i=>u(i,[i.name]))}n(H,"composeCorePluginMounts");async function oe(e,t){const{validateEffectiveCommandPlugins:r}=await import("./core/command-plugins/discovery.js"),s=r(new Set(m),void 0,void 0,void 0,t).flatMap(u=>u.manifest===void 0?[]:[u.manifest]).filter(u=>u.coreMounts.some(i=>i.parent[0]===e));if(s.length===0)return null;const a=R(s.flatMap(u=>[...u.coreMounts.map(i=>i.parent.join(" ")),...Object.keys(u.helpAddenda??{})]));return a.add(e),y(await k(a))}n(oe,"dispatchCommandPaths");function v(e,t){const r=e.slice(2).filter(o=>!E.has(o));return r[0]==="sys"&&r[1]===t}n(v,"isSysInvocation");const re=[["surface"],["sys"],["pkg"],["profile","default"],["canvas","chord"],["canvas","config"],["canvas","use"],["canvas","browse"],["canvas","issue"]],se=[["sys","feedback"],["pkg","plugin"],["pkg","market"]];function D(e,t){return t.every((r,o)=>e[o]===r)}n(D,"startsWithPath");function Se(e){const t=e.slice(2).filter(o=>!E.has(o));if(se.some(o=>D(t,o)))return null;const r=re.find(o=>D(t,o));return r===void 0?null:r.join(" ")}n(Se,"personOnlyInvocation");function be(e){return v(e,"daemon")}n(be,"isDaemonControlInvocation");function Ce(e){const t=e.slice(2).filter(r=>!E.has(r));return t[0]==="pkg"&&(t[1]==="plugin"||t[1]==="market")}n(Ce,"isPkgInstallInvocation");function ke(e){return v(e,"signin")||v(e,"signout")}n(ke,"isSignInInvocation");function xe(e){return v(e,"join")}n(xe,"isJoinInvocation");function Ee(e){return v(e,"migrate")}n(Ee,"isLayoutMigrationInvocation");async function Pe(){const{registerDaemonControlSys:e}=await import("./commands/sys/daemon.js");return S({tagline:b,globals:C,subtrees:[e()]})}n(Pe,"resolveDaemonControlRoot");async function Be(){const[{defineSysBranch:e},{sysMigrateLeaf:t}]=await Promise.all([import("./commands/sys/branch.js"),import("./commands/sys/migrate.js")]);return S({tagline:b,globals:C,subtrees:[e([t])]})}n(Be,"resolveLayoutMigrationRoot");async function Oe(e){return(e!==void 0?await ae(e):null)??ie()}n(Oe,"resolveRoot");async function ae(e){if(O[e]===void 0)return null;const t=await T(e),r=await I(),o=[...r].some(a=>a.split(" ")[0]===e)?await oe(e,r):null,s=L(o===null?[t]:await H([t],r,o));return s.length>0?S({tagline:b,globals:C,subtrees:N(s,_())}):null}n(ae,"resolveCoreRoot");async function ie(){const e=await x(),[{buildExternalCommandSnapshot:t},{composeExternalSubtrees:r,composeSandboxProviderSubtrees:o},{qualifiedTopLevelCommandName:s}]=await Promise.all([import("./core/command-plugins/discovery.js"),import("./core/command-plugins/compose.js"),import("./core/command-manifests/registry.js")]),a=await I(),u=await H(e,a,y(e)),i=t(new Set(m),void 0,void 0,y(e),a);let l=r(i);const f=(await import("./daemon/machine-link/config.js")).readMachineConfig()!==void 0;let g;if(B()||Q()||f){const{cliClient:p}=await import("./commands/api-client.js");h("cli.providers.request");let d=[];try{d=(await p().request("GET","/v1/providers/tools")).providers}catch(c){if(!f||!(c instanceof $||c instanceof K))throw c;g=c}h("cli.providers.fetched",{providers:d.length});const j=o(d,new Set(m)),G=new Set(j.map(c=>c.name)),U=new Map(d.map(c=>[c.provider,new Set(c.groups.flatMap(z=>z.leaves.map(F=>F.tool)))])),q=n(async c=>U.get(c)??new Set,"fromCatalog");l=[...j,...r({...i,contributions:i.contributions.map(c=>G.has(c.node.name)?{...c,node:{...c.node,name:s(c.contributor,c.node.name)}}:c)},g===void 0?q:void 0)]}if(!f){const{previewBranches:p}=await import("./core/northlight/previews.js");l=[...l,...p(process.platform,new Set(l.map(d=>d.name)))]}const w=S({tagline:b,globals:C,subtrees:[...N(L(u),_()),...l]});return g===void 0?w:{...w,providerCatalogFailure:g}}n(ie,"buildRoot");export{te as EXTENSIBLE_CORE_BRANCHES,m as SUBTREE_NAMES,ie as buildRoot,we as coreCommandPaths,ye as coreCommandPathsCovering,he as coreHookCatalog,ve as declaredExtensibleCoreBranches,I as extensibleCoreBranches,be as isDaemonControlInvocation,xe as isJoinInvocation,Ee as isLayoutMigrationInvocation,Ce as isPkgInstallInvocation,ke as isSignInInvocation,Se as personOnlyInvocation,ae as resolveCoreRoot,Pe as resolveDaemonControlRoot,Be as resolveLayoutMigrationRoot,Oe as resolveRoot};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** Find only terminal nodes with an unreconciled, explicitly disposable worktree. A node that ever ran in a Blaxel sandbox
|
|
2
|
-
* is never a candidate: its sandbox is its worktree and the control plane has no checkout to sweep (D102).
|
|
2
|
+
* is never a candidate: its sandbox is its worktree and the control plane has no checkout to sweep (D102). Nor is a node that
|
|
3
|
+
* ever ran on an imported Mac: its checkout is on that Mac, and the sweep runs Git on this host.
|
|
3
4
|
* Keep due-time parsing in JS: Date.parse accepts more than SQLite's date
|
|
4
5
|
* functions, and malformed dates are due rather than permanently skipped. */
|
|
5
6
|
export declare function managedWorktreeSweepCandidates(now: number): Promise<string[]>;
|
|
@@ -5,7 +5,7 @@ var d=Object.defineProperty;var s=(t,o)=>d(t,"name",{value:o,configurable:!0});i
|
|
|
5
5
|
JOIN nodes n ON n.node_id = w.node_id
|
|
6
6
|
WHERE n.status IN ('done', 'dead', 'canceled')
|
|
7
7
|
AND n.node_id NOT IN (SELECT node_id FROM warm_pool)
|
|
8
|
-
AND NOT EXISTS (SELECT 1 FROM executions e WHERE e.node_id = n.node_id AND e.runner
|
|
8
|
+
AND NOT EXISTS (SELECT 1 FROM executions e WHERE e.node_id = n.node_id AND e.runner IN ('blaxel', 'machine'))
|
|
9
9
|
AND w.state IN ('open', 'closed')
|
|
10
10
|
AND (w.state = 'open' OR w.cleanup_state IS NULL OR w.cleanup_state != 'complete')
|
|
11
11
|
AND (w.state = 'closed' OR (n.status = 'done' AND n.final_report IS NOT NULL))
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
-- 017-machine-worktree-ops.sql — the managed-worktree ops a control plane sends an imported Mac over its link (`worktree.create`,
|
|
2
|
+
-- `worktree.rollback`, `worktree.close`, `worktree.abandon`, `worktree.finalize`). One transaction, additions only: `schema_min_reader`
|
|
3
|
+
-- is not touched, so the previous release (version 16) still opens the result. Widening a CHECK is rollback-safe (008 did the same for
|
|
4
|
+
-- `executions_runner_check`): the previous build never writes these ops.
|
|
5
|
+
ALTER TABLE machine_calls DROP CONSTRAINT IF EXISTS machine_calls_op_check;
|
|
6
|
+
ALTER TABLE machine_calls ADD CONSTRAINT machine_calls_op_check CHECK (op IN ('start', 'wake', 'stop', 'status', 'delete', 'viewer', 'cron.run', 'cron.cancel',
|
|
7
|
+
'worktree.create', 'worktree.rollback', 'worktree.close', 'worktree.abandon', 'worktree.finalize'));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** The canvas schema version this build supports: the number of the highest delta in `schema-pg/` (the baseline
|
|
2
2
|
* `schema-pg.sql` is version 1). `scripts/install-runtime.mjs` reads this module from a candidate generation to refuse
|
|
3
3
|
* one below the live database's `schema_min_reader`. */
|
|
4
|
-
export declare const CANVAS_SCHEMA_VERSION =
|
|
4
|
+
export declare const CANVAS_SCHEMA_VERSION = 17;
|
|
5
5
|
/** The Postgres schema holding the canvas tables: `CRTR_DATABASE_SCHEMA` (`crtr` in the cloud deploy). Unset or empty
|
|
6
6
|
* means the role's own search_path (`public` on a Mac and on a VM). A name that is not a plain identifier is an error:
|
|
7
7
|
* it is put in a `search_path` connection option. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var m=Object.defineProperty;var r=(n,e)=>m(n,"name",{value:e,configurable:!0});const A=
|
|
1
|
+
var m=Object.defineProperty;var r=(n,e)=>m(n,"name",{value:e,configurable:!0});const A=17;function _(n=process.env){const e=n.CRTR_DATABASE_SCHEMA?.trim();if(e){if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(e))throw new Error(`CRTR_DATABASE_SCHEMA must be a plain identifier (letters, digits, underscore); got ${JSON.stringify(e)}`);return e}}r(_,"canvasDatabaseSchema");function h(n=process.env){return n.CRTR_SCHEMA_DATABASE_URL?.trim()||void 0}r(h,"canvasSchemaDatabaseUrl");function E(n=process.env){const e=_(n);return e===void 0?void 0:`-c search_path=${e}`}r(E,"canvasSearchPathOptions");async function v(n,e){const t=e===void 0?"canvas_meta":`"${e.replace(/"/g,'""')}".canvas_meta`;if((await n.query(`SELECT to_regclass('${t.replace(/'/g,"''")}') IS NOT NULL AS found`)).rows[0].found!==!0)return;const u=(await n.query(`SELECT key, value FROM ${t} WHERE key IN ('schema_version', 'schema_min_reader')`)).rows,o=r(c=>{const i=u.find(f=>f.key===c);if(i===void 0)return;const d=Number(i.value);if(!Number.isSafeInteger(d))throw new Error(`canvas_meta.${c} is not an integer: ${String(i.value)}`);return d},"value"),s=o("schema_version");return s===void 0?void 0:{version:s,minReader:o("schema_min_reader")??s}}r(v,"readStoredVersions");async function l(n,e,t){const a=await v(n,t);if(a!==void 0&&a.minReader>e)throw new Error(`refusing to select runtime with canvas schema ${e}: the live database requires readers at version ${a.minReader} or above (it is at ${a.version}); install a descendant build instead`)}r(l,"assertCandidateMayOpen");export{A as CANVAS_SCHEMA_VERSION,l as assertCandidateMayOpen,_ as canvasDatabaseSchema,h as canvasSchemaDatabaseUrl,E as canvasSearchPathOptions,v as readStoredVersions};
|
|
@@ -7,5 +7,9 @@ import type { ValidatedContribution, ValidatedCoreMount } from './discovery.js';
|
|
|
7
7
|
export declare function composeSandboxProviderSubtrees(providers: readonly (ProviderToolDescription | UnavailableProviderToolDescription)[], reserved: ReadonlySet<string>): BranchDef[];
|
|
8
8
|
export declare function adaptPluginContributions(contributions: ValidatedContribution[]): CommandRegistrySnapshot;
|
|
9
9
|
export declare function adaptPluginCoreMounts(mounts: ValidatedCoreMount[]): CoreBranchMount[];
|
|
10
|
-
|
|
10
|
+
/** The tools a provider's help lists, by provider id. */
|
|
11
|
+
export type ProviderToolsLookup = (providerId: string) => Promise<ReadonlySet<string>>;
|
|
12
|
+
/** `allowedTools` replaces the per-provider `GET /v1/providers/<id>/tools` behind each provider branch's help, for a caller that
|
|
13
|
+
* already holds the provider catalog (`GET /v1/providers/tools`) from this invocation. */
|
|
14
|
+
export declare function composeExternalSubtrees(snapshot: CommandRegistrySnapshot, allowedTools?: ProviderToolsLookup): BranchDef[];
|
|
11
15
|
export declare function composeCoreBranchMounts(mounts: readonly CoreBranchMount[], parent: string[]): (BranchDef | LeafDef)[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var _=Object.defineProperty;var u=(n,e)=>_(n,"name",{value:e,configurable:!0});import{resolve as j}from"node:path";import{ExitCode as A}from"../../types.js";import{envNodeId as L}from"../../shared/env.js";import{cliClient as f}from"../../commands/api-client.js";import{apiErrorToCliError as h}from"../io.js";import{ApiError as l}from"../../api/index.js";import{defineBranch as y,defineLeaf as M}from"../command.js";import{qualifiedTopLevelCommandName as N,resolveCommandRegistry as S}from"../command-manifests/registry.js";import{executeExternalLeaf as U}from"./transport/exec-invoke.js";import{invokeHttpLeaf as P}from"./transport/http-invoke.js";import{readPathParam as H}from"./transport/http-plan.js";import{sha256Hex as R,signedHeaderDigest as K}from"./transport/sign.js";import{needsAppToken as $}from"../plugin-objects-manifest.js";async function E(n){const e=await f().request("GET",`/v1/providers/${encodeURIComponent(n)}/tools`);return new Set(e.groups.flatMap(a=>a.leaves.map(t=>t.tool)))}u(E,"allowedProviderTools");function g(n,e,a){return n.children.some(t=>t.kind==="leaf"?a.has([...e,t.name].join(" ")):g(t,[...e,t.name],a))}u(g,"hasAllowedLeaf");function I(n,e,a){return n.children.filter(t=>t.tier!=="hidden"&&(t.kind==="leaf"?a.has([...e,t.name].join(" ")):g(t,[...e,t.name],a))).length}u(I,"visibleChildCount");function w(n,e,a){return async()=>{if(!L())return n.help;const t=await a();return{...n.help,listing:n.help.listing?.flatMap(d=>{const i=n.children.find(c=>c.name===d.name);if(i?.kind==="leaf")return t.has([...e,i.name].join(" "))?[d]:[];if(i?.kind!=="branch")return[];const o=[...e,i.name];if(!g(i,o,t))return[];const s=I(i,o,t);return[{...d,...d.subCount!==void 0?{subCount:s}:{}}]})}}}u(w,"providerHelp");const O="Runs on one of your devices. Add `--machine <machine_id>` to pick which; without it the call goes to your only device, and with several the answer is `machine_required` listing each one's machine_id. The `runtime:` prefix on the id is optional.";function k(n,e,a,t=!1){return{outputKind:"object",...t?{machineSelector:!0}:{},run:u(async(d,i)=>{const o={...d};for(const s of a.params){if(!("type"in s))continue;const c=s.name.replace(/-([a-z])/g,(p,m)=>m.toUpperCase()),r=o[c];s.type==="file"&&typeof r=="string"?o[c]=j(r):s.type==="path"&&r!==void 0&&(o[c]=H(`provider command \`${n} ${e}\``,s,r))}try{return await f({timeoutMs:0}).request("POST","/v1/provider/call",{provider:n,tool:e,arguments:o,...i?.machine===void 0?{}:{machine:i.machine}},{timeout:0})}catch(s){throw s instanceof l?h(s,void 0,{providerCall:!0}):s}},"run")}}u(k,"providerLeafAdapter");function x(n,e){return/^[A-Za-z0-9_-]{1,64}$/.test(n)&&n!=="crtr"&&!e.has(n)}u(x,"validRootName");function re(n,e){const a=[],t=[];for(const i of n){const{provider:o,commands:s}=i;if(!Array.isArray(s)||i.status!=="available"&&!x(o,e))continue;if(i.status!=="available"){const r=i.error??"bundle installation pending",p=`Unavailable (${i.status}): ${r}`,m=y({name:o,rootEntry:{concept:i.display_name,desc:p,useWhen:p},help:{name:o,summary:p},children:[],refusal:{code:"provider_unavailable",message:p,exit:A.NETWORK,next:"The daemon retries bundle installation on grant sync; retry after the provider becomes available."}});t.push(m);continue}const c=u(r=>r.kind==="branch"?{...r,children:r.children.map(c)}:{...r,rest:{method:"GET",path:"/",params:{}}},"helpNode");for(const r of s){if(r.kind!=="branch"||!Array.isArray(r.children)||!x(r.name,e))continue;const p=c(r);a.push({contributor:{name:o,scope:"user"},manifestName:r.name,node:i.groups.length===0?{...p,rootEntry:void 0}:p,adaptLeaf:u((m,b)=>k(o,b.slice(1).join(" "),m,i.transport==="machine"),"adaptLeaf")})}}const d=D(S(a,e));for(const i of d){const o=n.find(r=>r.status==="available"&&r.commands.some(p=>p.name===i.name||N({name:r.provider},p.name)===i.name));if(o?.status!=="available")continue;const s=new Set(o.groups.flatMap(r=>r.leaves.map(p=>p.tool))),c=u((r,p)=>{r.effectiveHelp=w(r,p,async()=>s);for(const m of r.children)m.kind==="branch"&&c(m,[...p,m.name])},"attachHelp");c(i,[])}return[...d,...t]}u(re,"composeSandboxProviderSubtrees");async function q(n){try{const{token:e,socket:a}=await f().plugins.appToken(n);return{CRTR_APP_TOKEN:e,CRTR_DAEMON_SOCKET:a}}catch(e){if(e instanceof l&&(e.status===404||e.status===403))return;throw e instanceof l?h(e):e}}u(q,"appEnvFor");function C(n,e){return(a,t)=>{const d=n.transport,i=e(t);if(n.provider!==void 0)return k(n.provider.id,i.slice(1).join(" "),a,d.kind==="machine");if(d.kind==="exec"){const s=d.executable;if(s===void 0)throw new Error(`exec plugin "${n.plugin.name}" has an executable leaf without transport.executable`);return{outputKind:"object",run:u(async c=>{const r=$(n.plugin.manifest)?await q(n.plugin.name):void 0;return U({plugin:n.plugin,executable:s,commandPath:i,output:a.output,...r!==void 0?{appEnv:r}:{}},c)},"run")}}if(d.kind==="machine")throw new Error(`machine plugin "${n.plugin.name}" is not a capability provider`);const o=a;return{outputKind:o.rest.streaming===!0?"jsonl":"object",run:u((s,c)=>P({registration:{name:n.plugin.name,endpoint:d.endpoint,...d.authEnv!==void 0?{authEnv:d.authEnv}:{}},...n.manifest?.baseUrl!==void 0?{baseUrl:n.manifest.baseUrl}:{},...n.manifest?.timeouts!==void 0?{timeouts:n.manifest.timeouts}:{},params:o.params,rest:o.rest,output:o.output,commandPath:i},s,c,{callHeaders:u(r=>f().plugins.callHeaders(n.plugin.name,{method:r.method,url:r.url.href,body_sha256:R(r.body),...K(r.headers)}).then(p=>p.headers,p=>{throw p instanceof l?h(p):p}),"callHeaders")}),"run")}}}u(C,"adaptLeaf");function te(n){return{contributions:n.map(e=>({contributor:{name:e.plugin.name,scope:e.plugin.scope,sourceMarketplace:e.plugin.sourceMarketplace},node:e.node,manifestName:e.manifestName,adaptLeaf:C(e,a=>[e.manifestName,...a.slice(1)]),...e.provider!==void 0?{provider:e.provider}:{}})),coreMounts:[],issues:[]}}u(te,"adaptPluginContributions");function ie(n){return n.map(e=>({parent:e.parent,plugin:e.plugin.name,contributor:{name:e.plugin.name,scope:e.plugin.scope,sourceMarketplace:e.plugin.sourceMarketplace},node:e.node,...e.provider!==void 0?{provider:e.provider}:{},adaptLeaf:C({...e,manifestName:e.node.name},a=>e.provider===void 0?[...a]:[e.provider.id,...a.slice(e.parent.length)])}))}u(ie,"adaptPluginCoreMounts");function D(n,e=E){return n.contributions.map(a=>v(a,a.node,[a.node.name],1,e))}u(D,"composeExternalSubtrees");function se(n,e){return n.filter(a=>a.parent.join("\0")===e.join("\0")).map(a=>a.node.kind==="branch"?v(a,a.node,[...e,a.node.name],a.provider===void 0?1:e.length):T(a,a.node,[...e,a.node.name]))}u(se,"composeCoreBranchMounts");function v(n,e,a,t=1,d=E){const i=e.rootEntry===void 0?void 0:{concept:e.rootEntry.concept,desc:e.rootEntry.description,useWhen:e.rootEntry.whenToUse},o=y({name:e.name,description:e.description,whenToUse:e.whenToUse,...e.tier!==void 0?{tier:e.tier}:{},...n.plugin!==void 0?{plugin:n.plugin}:{},...i!==void 0?{rootEntry:i}:{},help:{name:a.join(" "),summary:e.summary,...e.model!==void 0?{model:e.model}:{},...a.length===1&&n.extensionIssue!==void 0?{extensionIssue:n.extensionIssue}:{}},...e.passthrough!==void 0?{passthrough:e.passthrough}:{},children:e.children.map(s=>s.kind==="branch"?v(n,s,[...a,s.name],t,d):T(n,s,[...a,s.name]))});return n.provider!==void 0&&(o.effectiveHelp=w(o,a.slice(t),()=>d(n.provider.id))),o}u(v,"buildBranch");function T(n,e,a){const t=n.adaptLeaf(e,a);return M({name:e.name,description:e.description,whenToUse:e.whenToUse,...e.tier!==void 0?{tier:e.tier}:{},...n.plugin!==void 0?{plugin:n.plugin}:{},...t.machineSelector===!0?{machineSelector:!0}:{},help:{name:a.join(" "),summary:e.summary,...t.machineSelector===!0?{guide:O}:{},params:e.params,output:e.output,outputKind:t.outputKind,effects:[...e.effects]},run:t.run})}u(T,"buildLeaf");export{te as adaptPluginContributions,ie as adaptPluginCoreMounts,se as composeCoreBranchMounts,D as composeExternalSubtrees,re as composeSandboxProviderSubtrees};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type MachineOp, type MachineOpTable } from './ops.js';
|
|
2
|
-
/** Seconds a caller waits: `start` 60, every other op 15 (design).
|
|
2
|
+
/** Seconds a caller waits: `start` 60, every other op 15 (design). The `worktree.*` ops run Git under a repository lock that waits up to
|
|
3
|
+
* 25 s, so they get 60 too (`worktree.finalize` also asks origin, bounded at 10 s). */
|
|
3
4
|
export declare const MACHINE_CALL_TIMEOUT_S: Record<MachineOp, number>;
|
|
4
5
|
export interface CallMachineOptions {
|
|
5
6
|
timeoutMs?: number;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var d=Object.defineProperty;var
|
|
1
|
+
var d=Object.defineProperty;var o=(e,n)=>d(e,"name",{value:n,configurable:!0});import{randomUUID as E}from"node:crypto";import{openDb as f,withCanvasWrite as h}from"../../../canvas/db.js";import{MachineCallFailedError as p,MachineLostError as l,MachineOfflineError as s}from"./ops.js";const S={start:60,wake:15,stop:15,status:15,delete:15,viewer:15,"cron.run":15,"cron.cancel":15,"worktree.create":60,"worktree.rollback":60,"worktree.close":60,"worktree.abandon":60,"worktree.finalize":60},m=1e3;async function T(e,n,r,c={}){const i=E(),w=new Date().toISOString();if(!await h(async a=>await a.prepare("SELECT 1 AS live FROM machine_links WHERE environment = ? AND lease_expires_at > ?").get(e,w)===void 0?!1:(await a.prepare("INSERT INTO machine_calls (call_id, environment, op, args_json, created_at) VALUES (?, ?, ?, ?, ?)").run(i,e,n,JSON.stringify(r),w),await a.prepare("SELECT pg_notify(?, ?)").get("crtr_signal",`machine:${e}`),!0)))throw new s(e,"no live link");const _=Date.now()+(c.timeoutMs??S[n]*1e3);for(;;){const a=await(await f()).prepare("SELECT state, result_json, lease_expires_at, claimed_generation FROM machine_calls WHERE call_id = ?").get(i);if(a===void 0)throw new l(e,i);if(a.state==="done")return a.result_json===null?null:JSON.parse(a.result_json);if(a.state==="failed"){const t=a.result_json===null?{}:JSON.parse(a.result_json);throw t.code==="machine_offline"?new s(e,t.message,t.sent===!0):t.code==="machine_lost"?new l(e,i):new p(e,n,t.message??"unknown")}if(a.claimed_generation!==null&&a.lease_expires_at!==null&&a.lease_expires_at<=new Date().toISOString()){if(await u(i,"lease expired")===void 0)continue;throw new l(e,i)}if(Date.now()>=_){const t=await u(i,"timed out");if(t===void 0)continue;throw t===null?new s(e,"no holder claimed the call"):new l(e,i)}await new Promise(t=>setTimeout(t,c.rereadMs??m))}}o(T,"callMachine");async function u(e,n){const r=await(await f()).prepare(`UPDATE machine_calls SET state = 'failed', finished_at = ?,
|
|
2
2
|
result_json = CASE WHEN claimed_generation IS NULL THEN ? ELSE ? END
|
|
3
|
-
WHERE call_id = ? AND state IN ('pending', 'sent') RETURNING claimed_generation`).get(new Date().toISOString(),JSON.stringify({code:"machine_offline",message:n,sent:!1}),JSON.stringify({code:"machine_lost",message:n}),e);return r===void 0?void 0:r.claimed_generation===null?null:Number(r.claimed_generation)}
|
|
3
|
+
WHERE call_id = ? AND state IN ('pending', 'sent') RETURNING claimed_generation`).get(new Date().toISOString(),JSON.stringify({code:"machine_offline",message:n,sent:!1}),JSON.stringify({code:"machine_lost",message:n}),e);return r===void 0?void 0:r.claimed_generation===null?null:Number(r.claimed_generation)}o(u,"failOpenCall");export{S as MACHINE_CALL_TIMEOUT_S,T as callMachine};
|
|
@@ -38,5 +38,5 @@ export declare function machineBrokerEnv(bundle: StartBundleDTO, deps: Pick<Mach
|
|
|
38
38
|
* SIGKILL, so the caller never reports stopped while something of this home may still run. */
|
|
39
39
|
export declare function stopAllBrokers(graceMs?: number): Promise<void>;
|
|
40
40
|
export declare function createMachineExecutor(deps: MachineExecutorDeps): {
|
|
41
|
-
[O in Exclude<keyof MachineOpTable, 'cron.run' | 'cron.cancel'
|
|
41
|
+
[O in Exclude<keyof MachineOpTable, 'cron.run' | 'cron.cancel' | `worktree.${string}`>]: (args: MachineOpTable[O]['args'], signal?: AbortSignal) => Promise<MachineOpTable[O]['result']>;
|
|
42
42
|
};
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import type { ManagedWorktree } from '../../../canvas/types.js';
|
|
2
|
+
import type { AutoDroppedWorktree, AbandonManagedWorktreeResult } from '../../../worktree.js';
|
|
3
|
+
import type { CloseOnHostOutcome } from '../../../worktree-close.js';
|
|
4
|
+
import type { AbandonOutcome, FinalizeWorktreeOutcome } from '../../../worktree-mutation-async.js';
|
|
1
5
|
import type { RunnerExecution, RunnerStartInput, RunnerStatus, RunnerStopOptions, RunnerStopResult, RunnerViewerAddress, RunnerWakeResult } from '../types.js';
|
|
2
|
-
export declare const MACHINE_OPS: readonly ["start", "wake", "stop", "status", "delete", "viewer", "cron.run", "cron.cancel"];
|
|
6
|
+
export declare const MACHINE_OPS: readonly ["start", "wake", "stop", "status", "delete", "viewer", "cron.run", "cron.cancel", "worktree.create", "worktree.rollback", "worktree.close", "worktree.abandon", "worktree.finalize"];
|
|
3
7
|
export type MachineOp = (typeof MACHINE_OPS)[number];
|
|
4
8
|
/** A `start` call carries the whole start input and the node token the control plane minted: the Mac has no database, so it cannot mint one.
|
|
5
9
|
* The token sits in `machine_calls.args_json` until the row is deleted a day after it finishes; the execution's token row holds its hash. */
|
|
@@ -61,6 +65,40 @@ export interface MachineCronCancelArgs {
|
|
|
61
65
|
export interface MachineCronCancelResult {
|
|
62
66
|
canceled: boolean;
|
|
63
67
|
}
|
|
68
|
+
/** A `worktree.*` op's answer: its value, or the typed refusal (a `WorktreeError`) the Mac raised. A refusal travels as data because
|
|
69
|
+
* a failed call carries only a message, and the caller needs the refusal's code, next step and Git detail. */
|
|
70
|
+
export type MachineWorktreeAnswer<T> = {
|
|
71
|
+
value: T;
|
|
72
|
+
} | {
|
|
73
|
+
refused: {
|
|
74
|
+
code: string;
|
|
75
|
+
message: string;
|
|
76
|
+
next: string;
|
|
77
|
+
detail?: string;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
export interface MachineWorktreeCreateArgs {
|
|
81
|
+
cwd: string;
|
|
82
|
+
nodeId: string;
|
|
83
|
+
baseRef?: string;
|
|
84
|
+
}
|
|
85
|
+
export interface MachineWorktreeRollbackArgs {
|
|
86
|
+
worktree: ManagedWorktree;
|
|
87
|
+
}
|
|
88
|
+
export interface MachineWorktreeCloseArgs {
|
|
89
|
+
nodeId: string;
|
|
90
|
+
worktree: ManagedWorktree;
|
|
91
|
+
}
|
|
92
|
+
export interface MachineWorktreeAbandonArgs {
|
|
93
|
+
nodeId: string;
|
|
94
|
+
worktree: ManagedWorktree;
|
|
95
|
+
by: string;
|
|
96
|
+
}
|
|
97
|
+
export interface MachineWorktreeFinalizeArgs {
|
|
98
|
+
nodeId: string;
|
|
99
|
+
worktree: ManagedWorktree;
|
|
100
|
+
}
|
|
101
|
+
export type { AutoDroppedWorktree, AbandonManagedWorktreeResult };
|
|
64
102
|
export interface MachineOpTable {
|
|
65
103
|
start: {
|
|
66
104
|
args: MachineStartArgs;
|
|
@@ -96,6 +134,26 @@ export interface MachineOpTable {
|
|
|
96
134
|
args: MachineCronCancelArgs;
|
|
97
135
|
result: MachineCronCancelResult;
|
|
98
136
|
};
|
|
137
|
+
'worktree.create': {
|
|
138
|
+
args: MachineWorktreeCreateArgs;
|
|
139
|
+
result: MachineWorktreeAnswer<ManagedWorktree>;
|
|
140
|
+
};
|
|
141
|
+
'worktree.rollback': {
|
|
142
|
+
args: MachineWorktreeRollbackArgs;
|
|
143
|
+
result: MachineWorktreeAnswer<null>;
|
|
144
|
+
};
|
|
145
|
+
'worktree.close': {
|
|
146
|
+
args: MachineWorktreeCloseArgs;
|
|
147
|
+
result: MachineWorktreeAnswer<CloseOnHostOutcome>;
|
|
148
|
+
};
|
|
149
|
+
'worktree.abandon': {
|
|
150
|
+
args: MachineWorktreeAbandonArgs;
|
|
151
|
+
result: MachineWorktreeAnswer<AbandonOutcome>;
|
|
152
|
+
};
|
|
153
|
+
'worktree.finalize': {
|
|
154
|
+
args: MachineWorktreeFinalizeArgs;
|
|
155
|
+
result: MachineWorktreeAnswer<FinalizeWorktreeOutcome>;
|
|
156
|
+
};
|
|
99
157
|
}
|
|
100
158
|
/** No live link row for the environment: the caller leaves its work pending and retries on its own backoff. */
|
|
101
159
|
export declare class MachineOfflineError extends Error {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var s=Object.defineProperty;var n=(t,e)=>s(t,"name",{value:e,configurable:!0});const i=["start","wake","stop","status","delete","viewer","cron.run","cron.cancel","worktree.create","worktree.rollback","worktree.close","worktree.abandon","worktree.finalize"];class c extends Error{static{n(this,"MachineOfflineError")}environmentId;sent;code="machine_offline";constructor(e,r,o=!1){super(`machine ${e} is offline${r?`: ${r}`:""}`),this.environmentId=e,this.sent=o}}class l extends c{static{n(this,"MachineLaunchUncertainError")}uncertain=!0;constructor(e,r){super(e,r,!0)}}class h extends Error{static{n(this,"MachineLostError")}environmentId;callId;code="machine_lost";constructor(e,r){super(`call ${r} to machine ${e} was lost`),this.environmentId=e,this.callId=r}}class d extends Error{static{n(this,"MachineCallFailedError")}environmentId;op;code="machine_call_failed";constructor(e,r,o){super(`${r} on machine ${e} failed: ${o}`),this.environmentId=e,this.op=r}}export{i as MACHINE_OPS,d as MachineCallFailedError,l as MachineLaunchUncertainError,h as MachineLostError,c as MachineOfflineError};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var me=Object.defineProperty;var d=(e,o)=>me(e,"name",{value:o,configurable:!0});import{accessSync as he,constants as pe}from"node:fs";import{isAbsolute as _e,resolve as ke,join as ve}from"node:path";import{appSpace as ge}from"../layout.js";import{ApiError as ne}from"../../api/errors.js";import{spawnNode as ye,forkSourceNode as be,currentNodeContext as xe,rootOfSpine as $e,newNodeId as Se,preflightNodeId as Ce}from"./nodes.js";import{resolveProfileOperand as Ee}from"../profiles/manifest.js";import{selectProfileForCwd as Re,selectProfileForCwdReadOnly as Oe}from"../profiles/select.js";import{buildLaunchSpecAsync as oe,buildPiArgv as Ie}from"./launch.js";import{runsOnBlaxel as Fe,sandboxWorktreeRequest as Pe}from"../../daemon/api/environment-of.js";import{createManagedWorktreeAsync as Be,rollbackManagedWorktreeAsync as De}from"../worktree-mutation-async.js";import{usage as w,brokerLaunchFailed as D}from"../errors.js";import{writeGoal as Ne}from"./kickoff.js";import{appendSituationalContext as Le,formatSituationalProse as Me}from"./situational-context.js";import{ensureRoadmap as Te}from"./roadmap.js";import{buildWakeBearings as Ae}from"./bearings.js";import{encodeKickoffOrigin as We,KICKOFF_ORIGIN_ENV as je}from"./stamp/protocol.js";import{carryInitialInput as ze}from"../runs/initial-input.js";import{ExecutionCapReached as He,beginExecution as Ke,crtrHome as Ge,getNode as u,fullName as re,jobDir as Ue,recordExecutionPid as Ve,abortExecution as j,setFrozen as z}from"../canvas/index.js";import{contextDir as H,nodeAgentDir as K}from"../canvas/node-agent-paths.js";import{copyTreeBeneath as Xe}from"../spaces/open-beneath.js";import{conversationIdFromPath as N,conversationStore as S}from"../conversation-store/index.js";import{appMemoryTooSmall as qe,boundFleet as Ye,brokerThresholdsForDaemon as te}from"./fleet.js";import{admitBrokerMemory as Je}from"./memory-admission.js";import{emitEvent as L}from"../events/emit.js";import{remoteEnvironmentOf as Qe}from"./blaxel-environment.js";import{openViewerWindow as Ze,focusOf as en,windowOfPane as nn}from"./placement.js";import{awaitBrokerViewSocket as on}from"./view-socket.js";import{readLogSnapshot as rn}from"../events/read.js";import{transition as v}from"./lifecycle.js";import{beginBootFaultAttempt as tn}from"../canvas/recovery.js";import{headlessBrokerHost as G}from"./host.js";import{ensureDaemon as an}from"../../daemon/manage.js";import{readConfig as dn}from"../config.js";import{modelRequestFromConfig as sn,unregisteredConcreteModel as ln,unroutableConcreteModel as cn}from"../model-routes.js";import{openModelRegistry as un}from"./model-registry.js";import{MODEL_SPEC_NEXT as fn}from"./model-selection.js";import{forkNodeLedger as wn}from"./ledger.js";import{appRungForGrant as mn}from"../llm/app-rungs.js";import{APP_FAMILY as U}from"../model-routes.js";import{discoverLifecycleHookRegistry as hn}from"../command-hooks/discovery.js";import{invokeLifecycleHooks as pn}from"../command-hooks/transport/exec-lifecycle.js";import{someAsync as _n}from"../async-array.js";import{checkStart as kn}from"./start-check.js";function g(e){return{detail:{schema:"crtr.node-outcome-detail/v1",message:e instanceof Error?e.message:String(e)}}}d(g,"launchFailureOutcome");async function vn(e,o,a){try{return await G.launch(e,o,a)}catch(r){try{await v(e,"crash",{reason:"launch_failed",outcome:g(r)})}catch{}const t=r.message;throw D(t.startsWith("[broker]")?t:`[broker] refusing to launch ${e}: ${t}`,"Inspect the cause above, fix the launch recipe or environment, then retry.")}}d(vn,"launchBrokerOrCrash");function gn(e){return rn({nodeId:e,component:"broker",pattern:"broker.startup."},!1).items.flatMap(a=>a.kind==="event"&&a.envelope.event.startsWith("broker.startup.")&&a.envelope.event!=="broker.startup.warning"?[a.envelope.event.slice(15)]:[]).at(-1)??null}d(gn,"lastStartupStep");function yn(e,o){const a=gn(e),r=a===null?"it had logged no startup step":`the last startup step it logged was \`${a}\``;if(o.reason==="exited"){const{code:t,signal:s}=o.status;return{text:`exited (code ${t??"null"}, signal ${s??"null"}) before binding its view socket; ${r}`,fields:{reason:"exited",code:t,signal:s,last_startup_step:a}}}return{text:`was still starting after ${Math.round(o.waitedMs/1e3)} s without binding its view socket, so the launcher stopped it; ${r}`,fields:{reason:"timeout",waited_ms:o.waitedMs,last_startup_step:a}}}d(yn,"notReadyDescription");async function bn(e,o){try{await v(e,"crash",{reason:"launch_failed",outcome:g(o)})}catch{}try{G.teardown(e)}catch{}}d(bn,"crashAndTearDown");async function xn(e){const o=(await S().list()).map(({conversation_id:t,path:s})=>({id:t,path:s})),a=o.filter(t=>t.id===e),r=a.length>0?a:o.filter(t=>t.id.startsWith(e));if(r.length===0)throw w(`--fork-from '${e}': no pi session with that id found.`,{next:"Pass a live node id, a real session uuid/prefix, or an absolute .jsonl session path."});if(r.length>1)throw w(`--fork-from '${e}': ambiguous \u2014 ${r.length} sessions match that id prefix; pass the full id or the .jsonl path.`,{next:"Pass the full session uuid or an absolute .jsonl path to disambiguate."});return r[0].path}d(xn,"resolveSessionUuid");async function ie(e){const o=e.trim();if(o==="")throw w("--fork-from requires a node id, session file, or session uuid.",{next:"Pass a live node id, an absolute .jsonl session path, or a session uuid/prefix."});if(o.includes("/")||o.endsWith(".jsonl")){const r=N(_e(o)?o:ke(process.cwd(),o));if(r===null)throw w(`--fork-from '${o}': invalid conversation path.`,{next:"Pass a conversation file path or id."});return(await S().header(r)).path}const a=await u(o);if(a!==null){const r=a.pi_session_file;if(r==null||r==="")throw w(`node ${o} has no pi session yet \u2014 it has not captured a session FILE to fork from (the broker forks a .jsonl path, not a bare id).`,{next:"Pick a node that has captured a session, or drop --fork-from."});const t=N(r);if(t===null)throw w(`node ${o} has no valid conversation id.`,{next:"Pick a node with a captured conversation."});return(await S().header(t)).path}return await xn(o)}d(ie,"resolveForkSource");async function $n(e,o,a,r={}){return e===null?null:e!==void 0&&e!==""?Ee(e).profileId:o!==null?(await u(o))?.profile_id??null:r.readOnlySelection===!0?Oe(a):Re(a)}d($n,"resolveProfileId");function ae(e){const o=e.modelIntent===void 0?void 0:`${e.modelIntent.family}/${e.modelIntent.strength}`;return sn(e.model,o,e.modelExact===!0)}d(ae,"requestFromLaunch");async function de(e,o,a){const r=a??(e.modelIntent?`${e.modelIntent.family}/${e.modelIntent.strength}`:e.model),t=await mn(o,r,e.modelExact===!0);if(t===null)return e;const{CRTR_MODEL_INTENT:s,...l}=e.env??{};return{...e,model:t.model,modelIntent:{family:U,strength:t.strength},modelExact:void 0,env:{...l,CRTR_MODEL_INTENT:`${U}/${t.strength}`}}}d(de,"appPaidLaunch");async function se(e,o,a){if(e===void 0||e.kind==="logical"&&e.family!==U)return;const r=await ln(e.kind==="logical"?{kind:"concrete",spec:e.spec}:e,a??await un(),o);if(r!==void 0)throw w(`model '${r.request.spec}' is not registered in this daemon.`,{received:r.request.spec,next:fn});const t=await cn(e,o);if(t!==void 0)throw w(`model '${t.spec}' is registered but no configured model route offers it, so no turn could be served.`,{received:t.spec,next:"Pick a model from your configured routes (`crtr sys config get modelLadders`), or add this one to a ladder or route."})}d(se,"assertLaunchModelRegistered");function Sn(e,o,a){const r=e??o??null;if(!a&&r===null)throw new Error("spawnChild requires a calling node (CRTR_NODE_ID) or an explicit parent");return r}d(Sn,"resolveSpawner");async function le(e,o,a){try{an()}catch{}const r=xe(),t=e.root===!0,s=Sn(e.parent,r.nodeId??null,t),l=e.mode??"base",y=e.rootLifecycle??(t?"resident":"terminal"),ce=t&&y==="resident",R=s===null?null:await u(s),V=e.creator===void 0||e.creator===null?null:await u(e.creator);e.nodeId!==void 0&&await Ce(e.nodeId);const b=e.forkFrom!==void 0?await ie(e.forkFrom):void 0,M=b===void 0?null:await be(b),T=await _n([R,V,M],async f=>f?.isolated===!0||f?.run_id!=null&&(await u(f.run_id))?.isolated===!0);if(T&&e.isolated===!1)throw new ne(403,"isolated_run","isolation cannot be turned off under an isolated run",{param:"isolated"});const O=T||e.isolated===!0;if(O&&e.worktree===!0)throw new ne(400,"invalid_request","isolated nodes cannot use a worktree",{param:"worktree"});const C=e.worktree===!0,m=O||C?e.nodeId??await Se():e.nodeId,I=O?e.run!==void 0&&t&&!T?e.cwd:ve(ge(e.run?.grantee??R?.grantee??"app:terminal").nodes,m):e.cwd,h=await $n(e.profile,s,I),X=e.run?.grant_id??R?.grant_id??null,E=e.run??V??R??M,q=await de((await oe(e.kind,l,{lifecycle:y,hasManager:!t,model:e.model,modelOverride:e.model!==void 0,cwd:I,profileId:h,app:E?.grantee??"app:terminal"})).launch,X,e.model);await se(ae(q),{cwd:I,profileId:h}),await kn({grantee:E?.grantee??"app:terminal",sub:E?.sub,grant_id:E?.grant_id});const Y=M?.node_id??null;let x,F=I;const A=C&&await Fe(h)?await Pe(h,e.worktreeCwd??e.cwd,m,e.worktreeBase):void 0;try{C&&A===void 0&&(x=await Be(e.worktreeCwd??e.cwd,m,e.worktreeBase),F=x.path);const f=C?await de((await oe(e.kind,l,{lifecycle:y,hasManager:!t,model:e.model,modelOverride:e.model!==void 0,cwd:F,profileId:h,app:E?.grantee??"app:terminal"})).launch,X,e.model):q;A!==void 0&&(f.worktree=A),C&&await se(ae(f),{cwd:F,profileId:h});const n=await ye({kind:e.kind,mode:l,lifecycle:y,cwd:F,name:e.name??e.kind,description:e.description,parent:t?null:s,creator:e.creator,...e.actor===void 0?{}:{actor:e.actor},forkSourceNode:Y,spawnedBy:t?s??void 0:void 0,profile_id:h,...e.scopes===void 0?{}:{scopes:e.scopes},isolated:O,...e.run===void 0?{}:{run:e.run},...e.causedBy===void 0?{}:{causedBy:e.causedBy},...e.withinCreate===void 0?{}:{withinCreate:e.withinCreate},forkFrom:e.forkFrom,forkSourceFile:b,modelOverride:e.model===void 0?void 0:f.model,...x!==void 0?{managedWorktree:x}:{},...m!==void 0?{nodeId:m}:{},...e.reviewBinding===void 0?{}:{reviewBinding:e.reviewBinding},...e.deadlineAt===void 0?{}:{deadlineAt:e.deadlineAt},...e.outcomeDelivery===void 0?{}:{outcomeDelivery:e.outcomeDelivery},launch:f});if(a?.(n.node_id),e.forkFrom!==void 0)try{await wn(n.node_id,Y??null)}catch(i){throw await v(n.node_id,"crash",{reason:"launch_failed",outcome:g(i)}),i}if(await Ne(n.node_id,e.prompt),e.situationalContext!==void 0&&await Le(n.node_id,Me(e.situationalContext)),o!==void 0)try{o(n.node_id)}catch(i){throw await v(n.node_id,"crash",{reason:"launch_failed",outcome:g(i)}),i}const W=e.prompt!=="",ue=`${W&&e.wakeOrigin!==void 0?`${Ae(e.wakeOrigin)}
|
|
1
|
+
var he=Object.defineProperty;var d=(e,o)=>he(e,"name",{value:o,configurable:!0});import{accessSync as pe,constants as ke}from"node:fs";import{isAbsolute as _e,resolve as ve,join as ge}from"node:path";import{appSpace as ye}from"../layout.js";import{ApiError as oe}from"../../api/errors.js";import{spawnNode as be,forkSourceNode as xe,currentNodeContext as $e,rootOfSpine as Ce,newNodeId as Se,preflightNodeId as Oe}from"./nodes.js";import{resolveProfileOperand as Ee}from"../profiles/manifest.js";import{selectProfileForCwd as Re,selectProfileForCwdReadOnly as Ie}from"../profiles/select.js";import{buildLaunchSpecAsync as re,buildPiArgv as Fe}from"./launch.js";import{runsOnBlaxel as Me,sandboxWorktreeRequest as Be}from"../../daemon/api/environment-of.js";import{createManagedWorktreeAsync as Pe,rollbackManagedWorktreeAsync as De}from"../worktree-mutation-async.js";import{createManagedWorktreeOnMachine as Ne,rollbackManagedWorktreeOnMachine as Le,worktreeMachineOf as Te}from"../worktree-machine.js";import{usage as w,brokerLaunchFailed as N}from"../errors.js";import{writeGoal as Ae}from"./kickoff.js";import{appendSituationalContext as We,formatSituationalProse as je}from"./situational-context.js";import{ensureRoadmap as ze}from"./roadmap.js";import{buildWakeBearings as He}from"./bearings.js";import{encodeKickoffOrigin as Ke,KICKOFF_ORIGIN_ENV as Ge}from"./stamp/protocol.js";import{carryInitialInput as Ue}from"../runs/initial-input.js";import{ExecutionCapReached as Ve,beginExecution as Xe,crtrHome as qe,getNode as u,fullName as te,jobDir as Ye,recordExecutionPid as Je,abortExecution as z,setFrozen as H}from"../canvas/index.js";import{contextDir as K,nodeAgentDir as G}from"../canvas/node-agent-paths.js";import{copyTreeBeneath as Qe}from"../spaces/open-beneath.js";import{conversationIdFromPath as L,conversationStore as S}from"../conversation-store/index.js";import{appMemoryTooSmall as Ze,boundFleet as en,brokerThresholdsForDaemon as ie}from"./fleet.js";import{admitBrokerMemory as nn}from"./memory-admission.js";import{emitEvent as T}from"../events/emit.js";import{remoteEnvironmentOf as on}from"./blaxel-environment.js";import{openViewerWindow as rn,focusOf as tn,windowOfPane as an}from"./placement.js";import{awaitBrokerViewSocket as dn}from"./view-socket.js";import{readLogSnapshot as sn}from"../events/read.js";import{transition as g}from"./lifecycle.js";import{beginBootFaultAttempt as ln}from"../canvas/recovery.js";import{headlessBrokerHost as U}from"./host.js";import{ensureDaemon as cn}from"../../daemon/manage.js";import{readConfig as un}from"../config.js";import{modelRequestFromConfig as fn,unregisteredConcreteModel as wn,unroutableConcreteModel as mn}from"../model-routes.js";import{openModelRegistry as hn}from"./model-registry.js";import{MODEL_SPEC_NEXT as pn}from"./model-selection.js";import{forkNodeLedger as kn}from"./ledger.js";import{appRungForGrant as _n}from"../llm/app-rungs.js";import{APP_FAMILY as V}from"../model-routes.js";import{discoverLifecycleHookRegistry as vn}from"../command-hooks/discovery.js";import{invokeLifecycleHooks as gn}from"../command-hooks/transport/exec-lifecycle.js";import{someAsync as yn}from"../async-array.js";import{checkStart as bn}from"./start-check.js";function y(e){return{detail:{schema:"crtr.node-outcome-detail/v1",message:e instanceof Error?e.message:String(e)}}}d(y,"launchFailureOutcome");async function xn(e,o,a){try{return await U.launch(e,o,a)}catch(r){try{await g(e,"crash",{reason:"launch_failed",outcome:y(r)})}catch{}const t=r.message;throw N(t.startsWith("[broker]")?t:`[broker] refusing to launch ${e}: ${t}`,"Inspect the cause above, fix the launch recipe or environment, then retry.")}}d(xn,"launchBrokerOrCrash");function $n(e){return sn({nodeId:e,component:"broker",pattern:"broker.startup."},!1).items.flatMap(a=>a.kind==="event"&&a.envelope.event.startsWith("broker.startup.")&&a.envelope.event!=="broker.startup.warning"?[a.envelope.event.slice(15)]:[]).at(-1)??null}d($n,"lastStartupStep");function Cn(e,o){const a=$n(e),r=a===null?"it had logged no startup step":`the last startup step it logged was \`${a}\``;if(o.reason==="exited"){const{code:t,signal:s}=o.status;return{text:`exited (code ${t??"null"}, signal ${s??"null"}) before binding its view socket; ${r}`,fields:{reason:"exited",code:t,signal:s,last_startup_step:a}}}return{text:`was still starting after ${Math.round(o.waitedMs/1e3)} s without binding its view socket, so the launcher stopped it; ${r}`,fields:{reason:"timeout",waited_ms:o.waitedMs,last_startup_step:a}}}d(Cn,"notReadyDescription");async function Sn(e,o){try{await g(e,"crash",{reason:"launch_failed",outcome:y(o)})}catch{}try{U.teardown(e)}catch{}}d(Sn,"crashAndTearDown");async function On(e){const o=(await S().list()).map(({conversation_id:t,path:s})=>({id:t,path:s})),a=o.filter(t=>t.id===e),r=a.length>0?a:o.filter(t=>t.id.startsWith(e));if(r.length===0)throw w(`--fork-from '${e}': no pi session with that id found.`,{next:"Pass a live node id, a real session uuid/prefix, or an absolute .jsonl session path."});if(r.length>1)throw w(`--fork-from '${e}': ambiguous \u2014 ${r.length} sessions match that id prefix; pass the full id or the .jsonl path.`,{next:"Pass the full session uuid or an absolute .jsonl path to disambiguate."});return r[0].path}d(On,"resolveSessionUuid");async function ae(e){const o=e.trim();if(o==="")throw w("--fork-from requires a node id, session file, or session uuid.",{next:"Pass a live node id, an absolute .jsonl session path, or a session uuid/prefix."});if(o.includes("/")||o.endsWith(".jsonl")){const r=L(_e(o)?o:ve(process.cwd(),o));if(r===null)throw w(`--fork-from '${o}': invalid conversation path.`,{next:"Pass a conversation file path or id."});return(await S().header(r)).path}const a=await u(o);if(a!==null){const r=a.pi_session_file;if(r==null||r==="")throw w(`node ${o} has no pi session yet \u2014 it has not captured a session FILE to fork from (the broker forks a .jsonl path, not a bare id).`,{next:"Pick a node that has captured a session, or drop --fork-from."});const t=L(r);if(t===null)throw w(`node ${o} has no valid conversation id.`,{next:"Pick a node with a captured conversation."});return(await S().header(t)).path}return await On(o)}d(ae,"resolveForkSource");async function En(e,o,a,r={}){return e===null?null:e!==void 0&&e!==""?Ee(e).profileId:o!==null?(await u(o))?.profile_id??null:r.readOnlySelection===!0?Ie(a):Re(a)}d(En,"resolveProfileId");function de(e){const o=e.modelIntent===void 0?void 0:`${e.modelIntent.family}/${e.modelIntent.strength}`;return fn(e.model,o,e.modelExact===!0)}d(de,"requestFromLaunch");async function se(e,o,a){const r=a??(e.modelIntent?`${e.modelIntent.family}/${e.modelIntent.strength}`:e.model),t=await _n(o,r,e.modelExact===!0);if(t===null)return e;const{CRTR_MODEL_INTENT:s,...l}=e.env??{};return{...e,model:t.model,modelIntent:{family:V,strength:t.strength},modelExact:void 0,env:{...l,CRTR_MODEL_INTENT:`${V}/${t.strength}`}}}d(se,"appPaidLaunch");async function le(e,o,a){if(e===void 0||e.kind==="logical"&&e.family!==V)return;const r=await wn(e.kind==="logical"?{kind:"concrete",spec:e.spec}:e,a??await hn(),o);if(r!==void 0)throw w(`model '${r.request.spec}' is not registered in this daemon.`,{received:r.request.spec,next:pn});const t=await mn(e,o);if(t!==void 0)throw w(`model '${t.spec}' is registered but no configured model route offers it, so no turn could be served.`,{received:t.spec,next:"Pick a model from your configured routes (`crtr sys config get modelLadders`), or add this one to a ladder or route."})}d(le,"assertLaunchModelRegistered");function Rn(e,o,a){const r=e??o??null;if(!a&&r===null)throw new Error("spawnChild requires a calling node (CRTR_NODE_ID) or an explicit parent");return r}d(Rn,"resolveSpawner");async function ce(e,o,a){try{cn()}catch{}const r=$e(),t=e.root===!0,s=Rn(e.parent,r.nodeId??null,t),l=e.mode??"base",b=e.rootLifecycle??(t?"resident":"terminal"),ue=t&&b==="resident",E=s===null?null:await u(s),X=e.creator===void 0||e.creator===null?null:await u(e.creator);e.nodeId!==void 0&&await Oe(e.nodeId);const x=e.forkFrom!==void 0?await ae(e.forkFrom):void 0,A=x===void 0?null:await xe(x),W=await yn([E,X,A],async f=>f?.isolated===!0||f?.run_id!=null&&(await u(f.run_id))?.isolated===!0);if(W&&e.isolated===!1)throw new oe(403,"isolated_run","isolation cannot be turned off under an isolated run",{param:"isolated"});const R=W||e.isolated===!0;if(R&&e.worktree===!0)throw new oe(400,"invalid_request","isolated nodes cannot use a worktree",{param:"worktree"});const $=e.worktree===!0,m=R||$?e.nodeId??await Se():e.nodeId,I=R?e.run!==void 0&&t&&!W?e.cwd:ge(ye(e.run?.grantee??E?.grantee??"app:terminal").nodes,m):e.cwd,h=await En(e.profile,s,I),q=e.run?.grant_id??E?.grant_id??null,O=e.run??X??E??A,Y=await se((await re(e.kind,l,{lifecycle:b,hasManager:!t,model:e.model,modelOverride:e.model!==void 0,cwd:I,profileId:h,app:O?.grantee??"app:terminal"})).launch,q,e.model);await le(de(Y),{cwd:I,profileId:h}),await bn({grantee:O?.grantee??"app:terminal",sub:O?.sub,grant_id:O?.grant_id});const J=A?.node_id??null;let p,F=I;const M=$&&await Me(h)?await Be(h,e.worktreeCwd??e.cwd,m,e.worktreeBase):void 0,B=$&&M===void 0?await Te(h):null;try{$&&M===void 0&&(p=B!==null?await Ne(B,e.worktreeCwd??e.cwd,m,e.worktreeBase):await Pe(e.worktreeCwd??e.cwd,m,e.worktreeBase),F=p.path);const f=$?await se((await re(e.kind,l,{lifecycle:b,hasManager:!t,model:e.model,modelOverride:e.model!==void 0,cwd:F,profileId:h,app:O?.grantee??"app:terminal"})).launch,q,e.model):Y;M!==void 0&&(f.worktree=M),$&&await le(de(f),{cwd:F,profileId:h});const n=await be({kind:e.kind,mode:l,lifecycle:b,cwd:F,name:e.name??e.kind,description:e.description,parent:t?null:s,creator:e.creator,...e.actor===void 0?{}:{actor:e.actor},forkSourceNode:J,spawnedBy:t?s??void 0:void 0,profile_id:h,...e.scopes===void 0?{}:{scopes:e.scopes},isolated:R,...e.run===void 0?{}:{run:e.run},...e.causedBy===void 0?{}:{causedBy:e.causedBy},...e.withinCreate===void 0?{}:{withinCreate:e.withinCreate},forkFrom:e.forkFrom,forkSourceFile:x,modelOverride:e.model===void 0?void 0:f.model,...p!==void 0?{managedWorktree:p}:{},...m!==void 0?{nodeId:m}:{},...e.reviewBinding===void 0?{}:{reviewBinding:e.reviewBinding},...e.deadlineAt===void 0?{}:{deadlineAt:e.deadlineAt},...e.outcomeDelivery===void 0?{}:{outcomeDelivery:e.outcomeDelivery},launch:f});if(a?.(n.node_id),e.forkFrom!==void 0)try{await kn(n.node_id,J??null)}catch(i){throw await g(n.node_id,"crash",{reason:"launch_failed",outcome:y(i)}),i}if(await Ae(n.node_id,e.prompt),e.situationalContext!==void 0&&await We(n.node_id,je(e.situationalContext)),o!==void 0)try{o(n.node_id)}catch(i){throw await g(n.node_id,"crash",{reason:"launch_failed",outcome:y(i)}),i}const j=e.prompt!=="",fe=`${j&&e.wakeOrigin!==void 0?`${He(e.wakeOrigin)}
|
|
2
2
|
|
|
3
|
-
`:""}${e.prompt}`;l==="orchestrator"&&await
|
|
3
|
+
`:""}${e.prompt}`;l==="orchestrator"&&await ze(n.node_id,{goal:e.prompt.trim()}),await In(n);let Q;if(x!==void 0)try{const i=L(x);if(i===null)throw new Error(`invalid fork source ${x}`);const c=await S().fork(i,n.node_id);Q=(await S().header(c)).path}catch(i){throw await g(n.node_id,"crash",{reason:"launch_failed",outcome:y(i)}),i}const k=Fe(n,{prompt:fe,resumeSessionPath:Q});if(k.env={...k.env,CRTR_SUBTREE:await Ce(n.node_id)},j){const i=e.wakeOrigin!==void 0?{type:"runtime",kind:"wake",wake:e.wakeOrigin}:{type:"runtime",kind:"kickoff",...n.spawned_by!=null&&n.spawned_by!==""?{spawnedBy:n.spawned_by}:{}};k.env[Ge]=Ke(i),await Ue(k,n)}const _=en();if(await on(n.profile_id??null)!==null)return await H(n.node_id,new Date().toISOString()),T({level:"info",event:"broker.frozen",node_id:n.node_id,fields:{reason:"remote_environment"}}),{node:await u(n.node_id),frozen:!0,window:null,session:null};const Z=await _.reserveSlot(n.node_id),v=Z?await nn(n.node_id):null;if(v?.verdict==="too_small"){_.releaseReservation(n.node_id);const i=Ze(v);throw await g(n.node_id,"crash",{reason:"launch_failed",outcome:y(i)}),i}if(!Z||v?.verdict==="denied")return v?.verdict==="denied"&&_.releaseReservation(n.node_id),await H(n.node_id,new Date().toISOString()),T({level:"info",event:"broker.frozen",node_id:n.node_id,fields:v?.verdict==="denied"?{reason:"app_memory",free_bytes:v.free_bytes,needed_bytes:v.needed_bytes}:{reason:"broker_cap",live_count:await _.occupancy(),hard_cap:ie().automaticReviveCap}}),{node:await u(n.node_id),frozen:!0,window:null,session:null};const we=await ln(n.node_id),{automaticReviveCap:me}=ie();let C;try{C=await Xe(n.node_id,{daemonEpoch:_.epoch(),cap:me})}catch(i){if(!(i instanceof Ve))throw i;return _.releaseReservation(n.node_id),await H(n.node_id,new Date().toISOString()),T({level:"info",event:"broker.frozen",node_id:n.node_id,fields:{reason:"broker_cap",live_count:i.live,hard_cap:i.cap}}),{node:await u(n.node_id),frozen:!0,window:null,session:null}}k.env={...k.env,CRTR_EXECUTION_ID:C};let P;try{P=await xn(n.node_id,k,{cwd:n.cwd,name:te(n),resuming:!1})}catch(i){throw await z(C,{reason:"launch_failed"}),i}finally{_.releaseReservation(n.node_id)}if(P.pid===null){const i=new Error(`broker host returned no pid for ${n.node_id}`);throw await z(C,{reason:"launch_failed"}),await g(n.node_id,"crash",{reason:"launch_failed",outcome:y(i)}),N(`failed to launch the broker engine for ${n.node_id} (${n.name}) \u2014 the node was not started.`,`Inspect canonical event diagnostics with \`crtr sys logs --node ${n.node_id}\`, then verify the pi engine can start in this environment.`)}if(await Je(C,n.node_id,P.pid)==="shutdown")throw await z(C,{reason:"superseded"}),U.teardown(n.node_id),N(`broker execution was superseded for ${n.node_id}`,"Retry spawning the node.");if(ue&&e.readiness==="await"){const i=await dn(n.node_id,P.exited);if(!i.ready){const c=Cn(n.node_id,i);T({level:"error",event:"broker.launch.not_ready",node_id:n.node_id,fields:c.fields});const D=await we.explanation();throw await Sn(n.node_id,new Error(D??c.text)),N(D!==null?`the root broker ${n.node_id} could not start \u2014 ${D}`:`the root broker ${n.node_id} ${c.text} \u2014 it was not started.`,D!==null?"Resolve the cause named above, then retry.":`Inspect canonical event diagnostics with \`crtr sys logs --node ${n.node_id}\`, then retry.`)}}let ee=null,ne=null;if(!t&&s!==null&&un("user").auto_open_child_viewers)try{const i=await tn(s);if(i!==null&&i.pane!==null&&i.pane!==""){const c=await rn(n.node_id,i.session??"",{name:te(n),cwd:e.cwd,besidePane:i.pane,waitForBroker:!0,initialWhip:j});c!==null&&c.pane!==null&&c.pane!==""&&(ne=c.session,ee=an(c.pane))}}catch{}return{node:await u(n.node_id),frozen:!1,window:ee,session:ne}}catch(f){throw p!==void 0&&m!==void 0&&await u(m)===null&&(B!==null?await Le(B,p):await De(p)),f}}d(ce,"spawnChildPrepared");async function So(e){return ce(e)}d(So,"spawnChild");async function In(e){const o=vn(e.cwd,e.profile_id).plans.get("node:start")??[];await gn(o,{node:{id:e.node_id,name:e.name,kind:e.kind,mode:e.mode,lifecycle:e.lifecycle,cwd:e.cwd,nodeDir:await G(e.node_id),contextDir:await K(e.node_id),jobDir:Ye(e.node_id)},runtime:{isBirth:!0,canvasHome:qe(),profile:e.profile_id??null}})}d(In,"invokeBirthLifecycleHooks");const Fn=new Set(["initial-prompt.md","yield-message.md","result.json","jobs"]);async function Oo(e,o,a){const r=await u(e);if(r===null)throw w(`unknown node: ${e}`,{received:e,next:"List nodes and pass the id of a node with a captured pi session."});const t=await ae(e),s=await K(e);try{await S().header(L(t)),pe(s,ke.R_OK)}catch(l){throw new Error(`cannot fork ${e}: its conversation or context is unreadable \u2014 ${l.message}`)}return ce({kind:r.kind,mode:"base",cwd:r.cwd,prompt:"",root:!0,readiness:"await",forkFrom:e,...a===void 0?{}:{actor:a},profile:r.profile_id,model:r.model_override??void 0,...o===void 0?{}:{scopes:o}},async l=>{const b=await K(l);Qe(await G(e),s,await G(l),b,Fn)})}d(Oo,"forkNode");export{se as appPaidLaunch,le as assertLaunchModelRegistered,Oo as forkNode,In as invokeBirthLifecycleHooks,ae as resolveForkSource,En as resolveProfileId,Rn as resolveSpawner,So as spawnChild,ce as spawnChildPrepared};
|
|
@@ -1,4 +1,31 @@
|
|
|
1
|
+
import { type ManagedWorktree } from './canvas/index.js';
|
|
2
|
+
import { type AbsentWorktreeConclusion } from './worktree-mutation-async.js';
|
|
1
3
|
import { type CloseManagedWorktreeResult } from './worktree.js';
|
|
4
|
+
/** What an explicit close decided, without the database. `closed`: persist the record closed with cleanup pending (after recording
|
|
5
|
+
* `disposal` when present) and answer `result`. `blocked`: the rebase succeeded but the base could not be fast-forwarded; record the
|
|
6
|
+
* land intent `blocked`, then throw `land_base_failed`. Plain data: the outcome crosses the machine link. */
|
|
7
|
+
export type CloseOutcome = {
|
|
8
|
+
kind: 'closed';
|
|
9
|
+
result: CloseManagedWorktreeResult;
|
|
10
|
+
disposal?: NonNullable<ManagedWorktree['disposal']>;
|
|
11
|
+
} | {
|
|
12
|
+
kind: 'blocked';
|
|
13
|
+
blocked: string;
|
|
14
|
+
next: string;
|
|
15
|
+
detail: string;
|
|
16
|
+
};
|
|
17
|
+
/** Apply a close decision to the canvas: the one place close writes rows. */
|
|
18
|
+
export declare function persistCloseOutcome(nodeId: string, wt: ManagedWorktree, outcome: CloseOutcome): Promise<CloseManagedWorktreeResult>;
|
|
2
19
|
/** Async daemon executor for explicit close. The lock wait and every Git
|
|
3
20
|
* subprocess yield to the daemon event loop. */
|
|
4
21
|
export declare function closeManagedWorktreeAsync(nodeId: string): Promise<CloseManagedWorktreeResult>;
|
|
22
|
+
/** What a close on the computer that holds the checkout (an imported Mac) did: `concluded` when the checkout path was gone and its
|
|
23
|
+
* branch is proven delivered (persist cleanup `complete`, answer from `conclusion`), else the close decision. */
|
|
24
|
+
export type CloseOnHostOutcome = {
|
|
25
|
+
kind: 'concluded';
|
|
26
|
+
conclusion: AbsentWorktreeConclusion;
|
|
27
|
+
} | CloseOutcome;
|
|
28
|
+
/** {@link closeManagedWorktreeAsync}'s Git work with no database: the control plane sent the open record and persists the outcome. */
|
|
29
|
+
export declare function closeManagedWorktreeOnHost(nodeId: string, wt: ManagedWorktree): Promise<CloseOnHostOutcome>;
|
|
30
|
+
/** The result `closeManagedWorktreeAsync` answers for a concluded absent checkout. */
|
|
31
|
+
export declare function concludedCloseResult(nodeId: string, conclusion: AbsentWorktreeConclusion): CloseManagedWorktreeResult;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var P=Object.defineProperty;var
|
|
2
|
-
process error: ${
|
|
3
|
-
stderr: ${
|
|
4
|
-
`))if(
|
|
5
|
-
`).map(_=>_.trim()).filter(_=>_!==""),
|
|
6
|
-
${
|
|
1
|
+
var P=Object.defineProperty;var s=(t,e)=>P(t,"name",{value:e,configurable:!0});import{existsSync as b,realpathSync as q}from"node:fs";import{resolve as I}from"node:path";import{getNode as $,recordDisposalGrant as B,recordLandIntent as F}from"./canvas/index.js";import{withExclusiveDirectoryLockAsync as H}from"./exclusive-lock.js";import{gitAsync as i}from"./git.js";import{proveBranchContained as S}from"./worktree-containment.js";import{concludeAbsentManagedWorktreeAsync as G,concludeAbsentManagedWorktreeOnHost as T}from"./worktree-mutation-async.js";import{parseStatusPorcelain as N,planLandIntoCheckout as j}from"./worktree-landing.js";import{WORKTREE_LOCK_WAIT_MS as W,checkoutPathForBranchInList as K,missingWorktreeRecoveryHint as z,persistClosedWorktreeState as Q,samePath as C,worktreeLockPathForCommonDir as L,WorktreeError as l}from"./worktree.js";import{shellQuote as D}from"../shared/shell-quote.js";function u(t){return(t.stderr.trim()||t.stdout.trim()).trim()}s(u,"detailOf");async function d(t,e,a,r){const n=await i(e,t);if(n.status!==0)throw new l(a,`git ${e.join(" ")} failed`,r,u(n));return n.stdout.trim()}s(d,"runGit");async function E(t){const e=await d(t,["rev-parse","--git-common-dir"],"git_common_dir_failed","Inspect the repository git metadata, then retry.");return q(I(t,e))}s(E,"commonGitDir");async function J(t,e){const a=`refs/heads/${e}`,r=await i(["show-ref","--verify","--quiet",a],t);if(r.status===1&&r.executionFailed!==!0)throw new l("missing_base_branch",`managed worktree base '${e}' does not name an existing local branch`,"The base must be a local branch that landing can fast-forward \u2014 freshen your local branch from origin first (rebase-not-merge), then base on it.");if(r.status!==0){const n=r.processError===void 0?"":`
|
|
2
|
+
process error: ${r.processError}`;throw new l("base_branch_inspection_failed",`could not inspect local base branch '${e}' (git show-ref exited with status ${r.status})`,"Inspect the repository and its Git metadata, then retry.",`status: ${r.status}
|
|
3
|
+
stderr: ${r.stderr.trim()||"<empty>"}${n}`)}return d(t,["rev-parse","--verify",a],"base_branch_resolve_failed","Inspect the local base branch, then retry.")}s(J,"resolveLandableBase");async function U(t){for(const e of["rebase-merge","rebase-apply"]){const a=await d(t,["rev-parse","--git-path",e],"git_path_failed","Inspect the worktree manually, then retry.");if(b(a))return!0}return!1}s(U,"rebaseInProgress");async function M(t,e,a){const r=await i(["worktree","list","--porcelain"],t);if(r.status!==0)return!1;let n=null;for(const c of r.stdout.split(`
|
|
4
|
+
`))if(c.startsWith("worktree "))n=c.slice(9).trim();else if(n!==null&&C(n,e)&&c===`branch refs/heads/${a}`)return!0;return!1}s(M,"registeredWorktree");function v(t){return{worktree_removed:!1,worktree_remove_error:`cleanup pending: the caller checkout at ${t.path} remains intact. After its node exits, run \`git -C ${D(t.repo_root)} worktree remove ${D(t.path)}\` after confirming it is safe to delete.`,branch_deleted:!1,branch_delete_error:`cleanup pending: local branch ${t.branch} remains checked out at ${t.path}; delete it only after that checkout is removed and its landed commit is still contained in ${t.base_ref}.`}}s(v,"deferredCleanupResult");async function O(t,e){const a=await i(["rev-parse","--verify","--quiet","refs/stash"],t);a.status===0&&a.stdout.trim()===e&&await i(["stash","drop"],t)}s(O,"dropStashIfStillTip");async function V(t,e,a,r){const n=await i(["status","--porcelain"],t);if(n.status!==0)return{ok:!1,detail:u(n)};const c=await i(["diff","--name-only",a,r],t);if(c.status!==0)return{ok:!1,detail:u(c)};const y=c.stdout.split(`
|
|
5
|
+
`).map(_=>_.trim()).filter(_=>_!==""),f=j(N(n.stdout),y);if(f.kind==="refuse")return{ok:!1,detail:`untracked files in ${t} would be overwritten by the incoming commits: ${f.collisions.join(", ")}`};const p=s(async()=>{const _=await i(["merge","--ff-only",r],t);return _.status===0?{ok:!0}:{ok:!1,detail:u(_)}},"merge");if(f.kind==="direct")return p();const w=await i(["rev-parse","--verify","--quiet","refs/stash"],t),A=w.status===0?w.stdout.trim():null,m=await i(["stash","push","--message",`crtr landing ${e}`],t);if(m.status!==0)return{ok:!1,detail:u(m)};const k=await i(["rev-parse","--verify","--quiet","refs/stash"],t),o=k.status===0?k.stdout.trim():null;if(o===null||o===A)return p();const h=`local changes from ${t} are retained in stash ${o}; recover them with \`git -C ${D(t)} stash apply ${o}\` and resolve any conflict.`,g=await p();return g.ok?(await i(["stash","apply",o],t)).status===0?(await O(t,o),{ok:!0}):(await i(["reset","--hard",r],t),{ok:!0,stash:`the shared base checkout was reset to landed commit ${r} because local changes conflicted with it. ${h}`}):(await i(["stash","apply",o],t)).status===0?(await O(t,o),g):{ok:!1,detail:`${g.detail}
|
|
6
|
+
${h}`}}s(V,"landIntoBaseCheckout");async function x(t){const e=await $(t);if(e===null)throw new l("unknown_node",`unknown node: ${t}`,"Run this from a live node, or pass a real node id once that command supports it.");const a=e?.managed_worktree?.state==="open"?e.managed_worktree:null;if(a===null)throw new l("no_managed_worktree",`node ${t} has no open managed worktree`,"Nothing to close for this node.");return X(t,a,await R(t,a))}s(x,"closeLocked");async function X(t,e,a){if(a.kind==="blocked"){const r=(await $(t))?.managed_worktree;throw r!=null&&r.state==="open"&&await F(t,{at:new Date().toISOString(),blocked:a.blocked}),new l("land_base_failed",a.blocked,a.next,a.detail)}return a.disposal!==void 0&&await B(t,a.disposal),await Q(t,e,"pending"),a.result}s(X,"persistCloseOutcome");async function R(t,e){if(!b(e.path))throw new l("worktree_missing",`managed worktree path is missing: ${e.path}`,z(e));if(await U(e.path))throw new l("rebase_in_progress","this managed worktree is mid-rebase",`Resolve conflicts in ${e.path}, run \`git rebase --continue\` there, then rerun \`crtr node worktree close\`.`);if(await d(e.path,["status","--porcelain"],"status_failed","Inspect the worktree manually, then retry.")!=="")throw new l("dirty_worktree","managed worktree has uncommitted changes",`Commit the work in ${e.path}, then rerun \`crtr node worktree close\`.`);const r=await d(e.path,["rev-parse","--abbrev-ref","HEAD"],"branch_check_failed","Inspect the worktree manually, then retry."),n=await d(e.path,["rev-parse","HEAD"],"landed_sha_failed","Inspect the worktree checkout manually, then rerun `crtr node worktree close`.");if(r!==e.branch){if((await i(["show-ref","--verify","--quiet",`refs/heads/${e.branch}`],e.path)).status===0||r==="HEAD"||!await M(e.repo_root,e.path,r))throw new l("wrong_branch",`managed worktree is not on its recorded branch (expected ${e.branch}, found ${r==="HEAD"?"detached HEAD":r})`,`Inspect ${e.path}, then rerun \`crtr node worktree close\`.`);if(await S(e.path,e,n)===null)throw new l("branch_moved_unlanded",`managed worktree's recorded branch ${e.branch} no longer exists; its checkout is now on ${r} at ${n}, which carries content local base branch '${e.base_ref}' does not yet contain`,`Land or push ${r} through its own workflow before closing.`);const h=await E(e.path);if(!await M(e.repo_root,e.path,r)||await d(e.path,["rev-parse","--abbrev-ref","HEAD"],"branch_check_failed","Inspect the worktree manually, then retry.")!==r||await d(e.path,["rev-parse","HEAD"],"branch_check_failed","Inspect the worktree manually, then retry.")!==n)throw new l("wrong_branch",`managed worktree at ${e.path} changed while closing`,`Inspect ${e.path}, then rerun \`crtr node worktree close\`.`);return{kind:"closed",disposal:{observed_branch:r,observed_sha:n,common_dir:h,authorized:new Date().toISOString()},result:{node_id:t,branch:r,worktree_path:e.path,landed_sha:n,...v(e),branch_delete_error:`${r} is not a crtr-managed branch and will never be deleted automatically; it is preserved once the checkout above is removed.`}}}if(await S(e.path,e,n)!==null)return{kind:"closed",result:{node_id:t,branch:e.branch,worktree_path:e.path,landed_sha:n,...v(e)}};let c;try{c=await J(e.path,e.base_ref)}catch(o){if(!(o instanceof l)||o.code!=="missing_base_branch"||n!==e.base_sha)throw o;return{kind:"closed",result:{node_id:t,branch:e.branch,worktree_path:e.path,landed_sha:e.base_sha,...v(e)}}}const y=await i(["rebase",c],e.path);if(y.status!==0)throw new l("rebase_failed",`rebase onto local base branch '${e.base_ref}' did not complete`,`Resolve conflicts in ${e.path}, run \`git rebase --continue\` there, then rerun \`crtr node worktree close\`.`,u(y));const f=await d(e.path,["rev-parse","HEAD"],"landed_sha_failed","Inspect the worktree checkout manually, then rerun `crtr node worktree close`."),p=s((o,h,g)=>({kind:"blocked",blocked:o,next:h,detail:g}),"blocked"),w=await i(["merge-base","--is-ancestor",c,f],e.path);if(w.status!==0)return p(`rebased worktree is not a fast-forward of local base branch '${e.base_ref}'`,"Ask the user how to land this managed worktree.",u(w));const A=await d(e.path,["worktree","list","--porcelain"],"worktree_list_failed","Inspect the repository worktrees manually, then retry."),m=K(A,e.base_ref);let k;if(m!==null){const o=await i(["rev-parse","HEAD"],m);if(o.status!==0||o.stdout.trim()!==c)return p(`local base branch '${e.base_ref}' changed while this worktree was closing`,`Reconcile the base checkout at ${m}, then rerun \`crtr node worktree close\`.`,o.status!==0?u(o):`expected ${c}, found ${o.stdout.trim()}`);const h=await V(m,e.branch,c,f);if(!h.ok)return p(`could not fast-forward local base branch '${e.base_ref}' to this worktree`,`Local base branch '${e.base_ref}' is checked out at ${m} in a state that blocks a fast-forward.`,h.detail);k=h.stash}else{const o=await i(["update-ref",`refs/heads/${e.base_ref}`,f,c],e.path);if(o.status!==0)return p(`could not fast-forward local base branch '${e.base_ref}' to this worktree`,"Ask the user how to land this managed worktree.",u(o))}return{kind:"closed",result:{node_id:t,branch:e.branch,worktree_path:e.path,landed_sha:f,...v(e),...k===void 0?{}:{base_checkout_stash:k}}}}s(R,"closeOutcome");async function he(t){const e=(await $(t))?.managed_worktree;if(e==null||e.state!=="open")return x(t);if(!b(e.path)){const c=await G(t);if(c!==null)return Y(t,c)}const a=(await $(t))?.managed_worktree;if(a==null||a.state!=="open")return x(t);const r=b(a.path)?a.path:a.repo_root,n=await E(r);return H(L(n),()=>x(t),{timeoutMs:Math.min(W,25e3),timeoutError:s(()=>new l("worktree_lock_timeout",`timed out waiting to create a managed worktree in ${n}`,"Wait for the other managed-worktree operation to finish, then retry."),"timeoutError")})}s(he,"closeManagedWorktreeAsync");async function de(t,e){if(!b(e.path)){const r=await T(t,e);if(r!==null)return{kind:"concluded",conclusion:r}}const a=await E(b(e.path)?e.path:e.repo_root);return H(L(a),()=>R(t,e),{timeoutMs:Math.min(W,25e3),timeoutError:s(()=>new l("worktree_lock_timeout",`timed out waiting to create a managed worktree in ${a}`,"Wait for the other managed-worktree operation to finish, then retry."),"timeoutError")})}s(de,"closeManagedWorktreeOnHost");function Y(t,e){return{node_id:t,branch:e.dropped.branch,worktree_path:e.dropped.worktree_path,landed_sha:e.landedSha,worktree_removed:!0,branch_deleted:e.dropped.branch_deleted,...e.dropped.branch_delete_error===void 0?{}:{branch_delete_error:e.dropped.branch_delete_error}}}s(Y,"concludedCloseResult");export{he as closeManagedWorktreeAsync,de as closeManagedWorktreeOnHost,Y as concludedCloseResult,X as persistCloseOutcome};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type ManagedWorktree } from './canvas/index.js';
|
|
2
|
+
import type { MachineOp, MachineOpTable } from './runtime/runner/machine/ops.js';
|
|
3
|
+
import { type AbandonManagedWorktreeResult, type AutoDroppedWorktree, type CloseManagedWorktreeResult } from './worktree.js';
|
|
4
|
+
type WorktreeOp = Extract<MachineOp, `worktree.${string}`>;
|
|
5
|
+
/** The handlers a machine-role crtrd registers on its link for the `worktree.*` ops. Each reads no database. */
|
|
6
|
+
export declare const machineWorktreeHandlers: {
|
|
7
|
+
[O in WorktreeOp]: (args: MachineOpTable[O]['args']) => Promise<MachineOpTable[O]['result']>;
|
|
8
|
+
};
|
|
9
|
+
/** The machine environment that holds a node's checkouts: on a cloud role, the one its profile points at; else null (Git runs here). */
|
|
10
|
+
export declare function worktreeMachineOf(profileId: string | null | undefined): Promise<string | null>;
|
|
11
|
+
export declare function createManagedWorktreeOnMachine(environmentId: string, cwd: string, nodeId: string, baseRef?: string): Promise<ManagedWorktree>;
|
|
12
|
+
export declare function rollbackManagedWorktreeOnMachine(environmentId: string, worktree: ManagedWorktree): Promise<void>;
|
|
13
|
+
export declare function closeManagedWorktreeOnMachine(environmentId: string, nodeId: string): Promise<CloseManagedWorktreeResult>;
|
|
14
|
+
/** The running check stays here, on the node's row: the broker's pid is a process on the Mac, not on this host. */
|
|
15
|
+
export declare function abandonManagedWorktreeOnMachine(environmentId: string, nodeId: string, by: string): Promise<AbandonManagedWorktreeResult>;
|
|
16
|
+
/** The push-final guard for a node on a machine: `dropped` (record closed), `pushed` (finish, checkout kept), or `open` (refuse). */
|
|
17
|
+
export declare function finalizeManagedWorktreeOnMachine(environmentId: string, nodeId: string): Promise<{
|
|
18
|
+
kind: 'dropped';
|
|
19
|
+
dropped: AutoDroppedWorktree;
|
|
20
|
+
} | {
|
|
21
|
+
kind: 'pushed';
|
|
22
|
+
} | {
|
|
23
|
+
kind: 'open';
|
|
24
|
+
missing: boolean;
|
|
25
|
+
worktree: ManagedWorktree;
|
|
26
|
+
}>;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var k=Object.defineProperty;var o=(e,r)=>k(e,"name",{value:r,configurable:!0});import{abandonWorktreeAndRepoint as f,getNode as w}from"./canvas/index.js";import{isCloudRole as p}from"./canvas/person-state.js";import{callMachine as m}from"./runtime/runner/machine/call.js";import{machineEnvironmentOfProfile as h}from"./runtime/runner/machine/environment.js";import{closeManagedWorktreeOnHost as M,concludedCloseResult as g,persistCloseOutcome as W}from"./worktree-close.js";import{abandonManagedWorktreeOnHost as b,createManagedWorktreeAsync as y,finalizeManagedWorktreeOnHost as O,rollbackManagedWorktreeAsync as x}from"./worktree-mutation-async.js";import{persistClosedWorktreeState as d,WorktreeError as a}from"./worktree.js";async function i(e){try{return{value:await e()}}catch(r){if(!(r instanceof a))throw r;return{refused:{code:r.code,message:r.message,next:r.next,...r.detail===void 0?{}:{detail:r.detail}}}}}o(i,"answer");const E={"worktree.create":o(e=>i(()=>y(e.cwd,e.nodeId,e.baseRef)),"worktree.create"),"worktree.rollback":o(e=>i(async()=>(await x(e.worktree),null)),"worktree.rollback"),"worktree.close":o(e=>i(()=>M(e.nodeId,e.worktree)),"worktree.close"),"worktree.abandon":o(e=>i(()=>b(e.nodeId,e.worktree,e.by)),"worktree.abandon"),"worktree.finalize":o(e=>i(()=>O(e.nodeId,e.worktree)),"worktree.finalize")};async function N(e){return e==null||!p()?null:h(e)}o(N,"worktreeMachineOf");async function c(e,r,t){const n=await m(e,r,t);if("refused"in n)throw new a(n.refused.code,n.refused.message,n.refused.next,n.refused.detail);return n.value}o(c,"callWorktree");function q(e,r,t,n){return c(e,"worktree.create",{cwd:r,nodeId:t,...n===void 0?{}:{baseRef:n}})}o(q,"createManagedWorktreeOnMachine");async function F(e,r){await c(e,"worktree.rollback",{worktree:r})}o(F,"rollbackManagedWorktreeOnMachine");async function l(e,r){const t=await w(e);if(t===null)throw new a("unknown_node",`unknown node: ${e}`,"Run this from a live node, or pass a real node id once that command supports it.");const n=t.managed_worktree;if(n==null||n.state!=="open")throw new a("no_managed_worktree",`node ${e} has no open managed worktree`,`Nothing to ${r} for this node.`);return n}o(l,"openWorktree");async function P(e,r){const t=await l(r,"close"),n=await c(e,"worktree.close",{nodeId:r,worktree:t});return n.kind==="concluded"?(await d(r,t,"complete"),g(r,n.conclusion)):W(r,t,n)}o(P,"closeManagedWorktreeOnMachine");async function S(e,r,t){const n=await l(r,"abandon"),u=(await w(r))?.status;if(u==="active"||u==="idle")throw new a("node_running",`node ${r} is still running`,"Abandon requires a stopped node with no live broker process. From the running owner, use `crtr node worktree close` to land locally, or make the checkout clean, push its current tip to origin, and rerun `crtr push final`.");const s=await c(e,"worktree.abandon",{nodeId:r,worktree:n,by:t});return s.persist.kind==="closed"?await d(r,n,"complete"):await f(r,{cwd:n.repo_root,abandoned:s.persist.abandoned}),s.result}o(S,"abandonManagedWorktreeOnMachine");async function j(e,r){const t=await l(r,"close"),n=await c(e,"worktree.finalize",{nodeId:r,worktree:t});return n.kind==="dropped"?(await d(r,t,n.cleanup),{kind:"dropped",dropped:n.dropped}):n.kind==="open"?{...n,worktree:t}:n}o(j,"finalizeManagedWorktreeOnMachine");export{S as abandonManagedWorktreeOnMachine,P as closeManagedWorktreeOnMachine,q as createManagedWorktreeOnMachine,j as finalizeManagedWorktreeOnMachine,E as machineWorktreeHandlers,F as rollbackManagedWorktreeOnMachine,N as worktreeMachineOf};
|
|
@@ -19,5 +19,36 @@ export interface AbsentWorktreeConclusion {
|
|
|
19
19
|
/** Conclude an absent checkout only from the same branch-delivery proof used by
|
|
20
20
|
* push-final and explicit close. */
|
|
21
21
|
export declare function concludeAbsentManagedWorktreeAsync(nodeId: string): Promise<AbsentWorktreeConclusion | null>;
|
|
22
|
+
/** {@link concludeAbsentManagedWorktreeAsync} on the computer that holds the checkout (an imported Mac), with no database: the
|
|
23
|
+
* control plane sent the recorded worktree and persists cleanup `complete` for a non-null result. */
|
|
24
|
+
export declare function concludeAbsentManagedWorktreeOnHost(nodeId: string, wt: ManagedWorktree): Promise<AbsentWorktreeConclusion | null>;
|
|
22
25
|
export declare function autoDropCleanManagedWorktreeAsync(nodeId: string): Promise<AutoDroppedWorktree | null>;
|
|
26
|
+
/** What `push final` may do with an open managed worktree, decided on the computer that holds it: `dropped` closes the record with
|
|
27
|
+
* `cleanup`, `pushed` lets the node finish with its checkout kept, `open` refuses (`missing`: the checkout path is gone). */
|
|
28
|
+
export type FinalizeWorktreeOutcome = {
|
|
29
|
+
kind: 'dropped';
|
|
30
|
+
dropped: AutoDroppedWorktree;
|
|
31
|
+
cleanup: 'pending' | 'complete';
|
|
32
|
+
} | {
|
|
33
|
+
kind: 'pushed';
|
|
34
|
+
} | {
|
|
35
|
+
kind: 'open';
|
|
36
|
+
missing: boolean;
|
|
37
|
+
};
|
|
38
|
+
/** The push-final guard's Git work on the computer that holds the checkout (an imported Mac), with no database. */
|
|
39
|
+
export declare function finalizeManagedWorktreeOnHost(nodeId: string, wt: ManagedWorktree): Promise<FinalizeWorktreeOutcome>;
|
|
40
|
+
/** What an abandon did to the checkout and how its record is persisted: `closed` (cleanup complete) when the branch was deleted,
|
|
41
|
+
* else `abandoned` with the retained tip. */
|
|
42
|
+
export interface AbandonOutcome {
|
|
43
|
+
result: AbandonManagedWorktreeResult;
|
|
44
|
+
persist: {
|
|
45
|
+
kind: 'closed';
|
|
46
|
+
} | {
|
|
47
|
+
kind: 'abandoned';
|
|
48
|
+
abandoned: NonNullable<ManagedWorktree['abandoned']>;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
23
51
|
export declare function abandonManagedWorktreeAsync(nodeId: string, by: string): Promise<AbandonManagedWorktreeResult>;
|
|
52
|
+
/** {@link abandonManagedWorktreeAsync}'s Git work on the computer that holds the checkout (an imported Mac), with no database: the
|
|
53
|
+
* control plane checked the node is stopped, sent the recorded worktree, and persists the returned outcome. */
|
|
54
|
+
export declare function abandonManagedWorktreeOnHost(nodeId: string, wt: ManagedWorktree, by: string): Promise<AbandonOutcome>;
|