@north-light/cli 0.3.789 → 0.3.791

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.
Files changed (109) hide show
  1. package/dist/api/client.d.ts +3 -1
  2. package/dist/api/client.js +1 -1
  3. package/dist/api/contract.d.ts +1 -1
  4. package/dist/api/contract.js +1 -1
  5. package/dist/api/dto/nodes.d.ts +0 -12
  6. package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/memory-slash-commands.ts +3 -2
  7. package/dist/clients/attach/viewer.js +526 -526
  8. package/dist/commands/canvas-history/shared.js +1 -1
  9. package/dist/commands/node/bash.js +1 -1
  10. package/dist/commands/node/create.js +2 -2
  11. package/dist/commands/node/inspect.js +6 -6
  12. package/dist/commands/node/lifecycle.js +4 -4
  13. package/dist/commands/node-context.js +2 -2
  14. package/dist/commands/person-settings.js +1 -1
  15. package/dist/commands/profile/daemon-profiles.js +4 -4
  16. package/dist/commands/sys.js +1 -1
  17. package/dist/core/canvas/history.d.ts +2 -8
  18. package/dist/core/canvas/history.js +9 -9
  19. package/dist/core/canvas/node-agent-paths.d.ts +5 -0
  20. package/dist/core/canvas/node-agent-paths.js +1 -1
  21. package/dist/core/canvas/node-tokens.js +3 -3
  22. package/dist/core/canvas/paths.d.ts +3 -10
  23. package/dist/core/canvas/paths.js +1 -1
  24. package/dist/core/canvas/person-state.d.ts +5 -7
  25. package/dist/core/canvas/person-state.js +1 -1
  26. package/dist/core/canvas/person.d.ts +3 -30
  27. package/dist/core/canvas/person.js +1 -11
  28. package/dist/core/canvas/render-source.js +1 -1
  29. package/dist/core/config.d.ts +4 -1
  30. package/dist/core/config.js +1 -1
  31. package/dist/core/directory/join.d.ts +4 -6
  32. package/dist/core/directory/join.js +1 -1
  33. package/dist/core/grants/sync.js +1 -1
  34. package/dist/core/human/requests.d.ts +11 -1
  35. package/dist/core/human/requests.js +22 -22
  36. package/dist/core/providers/files.js +1 -1
  37. package/dist/core/review/store.js +1 -1
  38. package/dist/core/runtime/bearings-render.d.ts +2 -2
  39. package/dist/core/runtime/bearings-render.js +11 -11
  40. package/dist/core/runtime/bearings.js +1 -1
  41. package/dist/core/runtime/broker/attachments-fetch.js +1 -1
  42. package/dist/core/runtime/broker/bash-job-launch.d.ts +0 -4
  43. package/dist/core/runtime/broker/bash-job-launch.js +1 -1
  44. package/dist/core/runtime/broker/daemon-ops.d.ts +0 -8
  45. package/dist/core/runtime/broker/daemon-ops.js +1 -1
  46. package/dist/core/runtime/broker/frame-dispatch.d.ts +1 -1
  47. package/dist/core/runtime/broker/frame-dispatch.js +1 -1
  48. package/dist/core/runtime/broker/host-path-tokens.d.ts +5 -0
  49. package/dist/core/runtime/broker/host-path-tokens.js +1 -0
  50. package/dist/core/runtime/broker-extension-render.js +2 -2
  51. package/dist/core/runtime/broker.js +1 -1
  52. package/dist/core/runtime/host.js +3 -3
  53. package/dist/core/runtime/kickoff.d.ts +1 -1
  54. package/dist/core/runtime/kickoff.js +12 -12
  55. package/dist/core/runtime/launch-config-worker.js +1 -1
  56. package/dist/core/runtime/launch-target.d.ts +6 -4
  57. package/dist/core/runtime/launch-target.js +1 -1
  58. package/dist/core/runtime/launch.d.ts +5 -1
  59. package/dist/core/runtime/launch.js +2 -2
  60. package/dist/core/runtime/nodes.js +1 -1
  61. package/dist/core/runtime/revive.js +2 -2
  62. package/dist/core/runtime/runner/blaxel/runner.js +2 -2
  63. package/dist/core/runtime/runner/launch-env.d.ts +7 -0
  64. package/dist/core/runtime/runner/launch-env.js +1 -0
  65. package/dist/core/runtime/runner/machine/executor.js +2 -2
  66. package/dist/core/runtime/runner/machine/runner.js +1 -1
  67. package/dist/core/runtime/runner/types.d.ts +1 -0
  68. package/dist/core/runtime/spawn-env-rows.js +1 -1
  69. package/dist/core/runtime/spawn.js +2 -2
  70. package/dist/core/secrets/environment-owner.js +1 -1
  71. package/dist/core/storage/attachments.d.ts +1 -1
  72. package/dist/core/storage/attachments.js +1 -1
  73. package/dist/core/storage/tables.d.ts +6 -2
  74. package/dist/core/storage/tables.js +4 -4
  75. package/dist/core/substrate/delivery/deliver.js +1 -1
  76. package/dist/core/substrate/delivery/render-boot.js +1 -1
  77. package/dist/daemon/api/handlers/bash-jobs.js +3 -3
  78. package/dist/daemon/api/handlers/canvas.js +5 -5
  79. package/dist/daemon/api/handlers/nodes.js +1 -1
  80. package/dist/daemon/api/handlers/profiles.js +1 -1
  81. package/dist/daemon/api/map.d.ts +1 -4
  82. package/dist/daemon/api/map.js +2 -2
  83. package/dist/daemon/cron/lease-recovery.js +1 -1
  84. package/dist/daemon/cron/machine-fire.js +1 -1
  85. package/dist/daemon/human/sweep.js +1 -1
  86. package/dist/daemon/peer/ingress.d.ts +2 -2
  87. package/dist/daemon/reconcilers/bash-deadline.js +1 -1
  88. package/dist/daemon/reconcilers/grove-instance-sweep.js +1 -1
  89. package/dist/daemon/runs/observer.js +6 -5
  90. package/dist/pi-extensions/canvas-bash-valve.js +6 -6
  91. package/dist/pi-extensions/canvas-context-intro.js +2 -2
  92. package/dist/pi-extensions/canvas-inbox-watcher.js +2 -2
  93. package/package.json +3 -3
  94. package/packages/crouter-api/dist/api/client.js +2 -2
  95. package/packages/crouter-api/dist/api/contract.js +1 -1
  96. package/packages/crouter-api/dist/core/canvas/paths.js +4 -13
  97. package/packages/crouter-api/dist/core/canvas/person-state.js +9 -11
  98. package/packages/crouter-api/dist/core/config.js +10 -0
  99. package/packages/crouter-api/dist/core/directory/join.js +11 -45
  100. package/packages/crouter-api/dist/core/runtime/broker/attachments-fetch.js +18 -2
  101. package/packages/crouter-api/dist/core/runtime/broker/daemon-ops.js +0 -10
  102. package/packages/crouter-api/dist/core/runtime/broker/host-path-tokens.js +21 -0
  103. package/packages/crouter-api/package.json +1 -1
  104. package/packages/crouter-identity/package.json +1 -1
  105. package/packages/crouter-plugin/package.json +3 -3
  106. package/runtime.lock.json +14 -14
  107. package/scripts/sandbox-start.mjs +5 -3
  108. package/dist/commands/sys/join.d.ts +0 -3
  109. package/dist/commands/sys/join.js +0 -1
@@ -1 +1 @@
1
- var g=Object.defineProperty;var d=(e,n)=>g(e,"name",{value:n,configurable:!0});import{usage as t}from"../../core/errors.js";const u=["transcript","inbox"],f=["human","inbox","wake","revive","restart-continuation","stop-guard","park","recovery","context-nudge","kickoff","unknown"],m=["user","assistant","toolResult"],w=["advisor","developer","spec","design","review","explore","plan","general"],y=["active","idle","done","dead","canceled"],v={s:1e3,m:6e4,h:36e5,d:864e5,w:6048e5,mo:2592e6,y:31536e6};function p(e,n){const r=n.match(/^(\d+)(mo|[smhdwy])$/);if(r!==null)return Date.now()-Number(r[1])*v[r[2]];const s=Date.parse(n);if(!Number.isNaN(s))return s;throw t(`--${e} must be ISO 8601 (2026-06-01) or relative (7d, 2w, 1mo); received: ${n}`)}d(p,"parseWhen");function a(e){if(!(e===void 0||e===""))return e.split(",").map(n=>n.trim()).filter(n=>n!=="")}d(a,"splitCsv");const k=[{kind:"flag",name:"cwd",type:"path",required:!1,constraint:"Search another project's record. Default: the calling node's cwd (process cwd when not a node). Mutually exclusive with --all-cwds."},{kind:"flag",name:"all-cwds",type:"bool",required:!1,constraint:"Search every cwd on the canvas. Mutually exclusive with --cwd."},{kind:"flag",name:"under",type:"string",required:!1,constraint:"Restrict to a node and its subscription descendants (one initiative / sub-DAG)."},{kind:"flag",name:"node",type:"string",required:!1,constraint:"Restrict to specific node ids. Comma-separated for several."},{kind:"flag",name:"type",type:"string",required:!1,constraint:`Corpus to search; comma-separated for both. One of: ${u.join(", ")}. inbox = every delivery a node received, with un-clipped message bodies; transcript = the conversation itself, message by message. Default: inbox.`},{kind:"flag",name:"kind",type:"string",required:!1,constraint:`Node kind; comma-separated for several. One of: ${w.join(", ")}.`},{kind:"flag",name:"status",type:"string",required:!1,constraint:`Node lifecycle status; comma-separated for several. One of: ${y.join(", ")} (e.g. done = completed work only).`},{kind:"flag",name:"since",type:"string",required:!1,constraint:"Lower bound on artifact timestamp. ISO 8601 (2026-06-01) or relative (7d, 2w, 1mo)."},{kind:"flag",name:"until",type:"string",required:!1,constraint:"Upper bound on artifact timestamp. ISO 8601 or relative."},{kind:"flag",name:"origin",type:"string",required:!1,constraint:`What drove a message to arrive; comma-separated for several. One of: ${f.join(", ")}. Applies to transcript + inbox artifacts, which are the only ones that arrive \u2014 passing it therefore excludes every generated turn on its own. \`unknown\` is a message carrying no stamp, and is its own bucket rather than a fallback.`},{kind:"flag",name:"role",type:"string",required:!1,constraint:`Transcript message role; comma-separated for several. One of: ${m.join(", ")}.`},{kind:"flag",name:"from",type:"string",required:!1,constraint:"Case-insensitive substring against sender attribution \u2014 the node that sent a delivery. Applies to transcript + inbox artifacts."}];function x(e){const n=e.cwd,r=e.allCwds===!0;if(n!==void 0&&r)throw t("--cwd and --all-cwds are mutually exclusive.");const s=a(e.type);if(s!==void 0){const i=s.find(o=>!u.includes(o));if(i!==void 0)throw t(`--type must be one of: ${u.join(", ")}; received: ${i}`)}const c=a(e.origin);if(c!==void 0){const i=c.find(o=>!f.includes(o));if(i!==void 0)throw t(`--origin must be one of: ${f.join(", ")}; received: ${i}`)}const l=a(e.role);if(l!==void 0){const i=l.find(o=>!m.includes(o));if(i!==void 0)throw t(`--role must be one of: ${m.join(", ")}; received: ${i}`)}if(s!==void 0&&s.includes("transcript")&&!(e.node!==void 0||e.under!==void 0||e.since!==void 0))throw t("--type transcript needs a narrowing flag: pass --node, --under, or --since.",{next:"Transcripts are the full conversation corpus \u2014 scanning every node in a cwd reads every session file. Narrow first."});return{cwd:n,allCwds:r,under:e.under,nodes:a(e.node),types:s,kinds:a(e.kind),statuses:a(e.status),sinceMs:e.since!==void 0?p("since",e.since):void 0,untilMs:e.until!==void 0?p("until",e.until):void 0,origins:c,roles:l,from:e.from}}d(x,"parseFilters");function _(e,n){n.cwd!==void 0&&(e.cwd=n.cwd),n.allCwds&&(e.all_cwds=!0),n.under!==void 0&&(e.under=n.under),n.nodes!==void 0&&(e.nodes=n.nodes),n.types!==void 0&&(e.types=n.types),n.kinds!==void 0&&(e.kinds=n.kinds),n.statuses!==void 0&&(e.statuses=n.statuses),n.sinceMs!==void 0&&(e.since_ms=n.sinceMs),n.untilMs!==void 0&&(e.until_ms=n.untilMs),n.origins!==void 0&&(e.origins=n.origins),n.roles!==void 0&&(e.roles=n.roles),n.from!==void 0&&(e.from=n.from)}d(_,"applyFilters");export{w as NODE_KINDS,f as ORIGINS,m as ROLES,y as STATUSES,u as TYPES,_ as applyFilters,k as filterParams,x as parseFilters,p as parseWhen,a as splitCsv};
1
+ var g=Object.defineProperty;var a=(n,e)=>g(n,"name",{value:e,configurable:!0});import{usage as t}from"../../core/errors.js";import{envNodeId as w}from"../../shared/env.js";const u=["transcript","inbox"],f=["human","inbox","wake","revive","restart-continuation","stop-guard","park","recovery","context-nudge","kickoff","unknown"],p=["user","assistant","toolResult"],y=["advisor","developer","spec","design","review","explore","plan","general"],v=["active","idle","done","dead","canceled"],h={s:1e3,m:6e4,h:36e5,d:864e5,w:6048e5,mo:2592e6,y:31536e6};function m(n,e){const r=e.match(/^(\d+)(mo|[smhdwy])$/);if(r!==null)return Date.now()-Number(r[1])*h[r[2]];const i=Date.parse(e);if(!Number.isNaN(i))return i;throw t(`--${n} must be ISO 8601 (2026-06-01) or relative (7d, 2w, 1mo); received: ${e}`)}a(m,"parseWhen");function d(n){if(!(n===void 0||n===""))return n.split(",").map(e=>e.trim()).filter(e=>e!=="")}a(d,"splitCsv");const _=[{kind:"flag",name:"cwd",type:"path",required:!1,constraint:"Search another project's record. Default: the calling node's cwd (process cwd when not a node). Mutually exclusive with --all-cwds."},{kind:"flag",name:"all-cwds",type:"bool",required:!1,constraint:"Search every cwd on the canvas. Mutually exclusive with --cwd."},{kind:"flag",name:"under",type:"string",required:!1,constraint:"Restrict to a node and its subscription descendants (one initiative / sub-DAG)."},{kind:"flag",name:"node",type:"string",required:!1,constraint:"Restrict to specific node ids. Comma-separated for several."},{kind:"flag",name:"type",type:"string",required:!1,constraint:`Corpus to search; comma-separated for both. One of: ${u.join(", ")}. inbox = every delivery a node received, with un-clipped message bodies; transcript = the conversation itself, message by message. Default: inbox.`},{kind:"flag",name:"kind",type:"string",required:!1,constraint:`Node kind; comma-separated for several. One of: ${y.join(", ")}.`},{kind:"flag",name:"status",type:"string",required:!1,constraint:`Node lifecycle status; comma-separated for several. One of: ${v.join(", ")} (e.g. done = completed work only).`},{kind:"flag",name:"since",type:"string",required:!1,constraint:"Lower bound on artifact timestamp. ISO 8601 (2026-06-01) or relative (7d, 2w, 1mo)."},{kind:"flag",name:"until",type:"string",required:!1,constraint:"Upper bound on artifact timestamp. ISO 8601 or relative."},{kind:"flag",name:"origin",type:"string",required:!1,constraint:`What drove a message to arrive; comma-separated for several. One of: ${f.join(", ")}. Applies to transcript + inbox artifacts, which are the only ones that arrive \u2014 passing it therefore excludes every generated turn on its own. \`unknown\` is a message carrying no stamp, and is its own bucket rather than a fallback.`},{kind:"flag",name:"role",type:"string",required:!1,constraint:`Transcript message role; comma-separated for several. One of: ${p.join(", ")}.`},{kind:"flag",name:"from",type:"string",required:!1,constraint:"Case-insensitive substring against sender attribution \u2014 the node that sent a delivery. Applies to transcript + inbox artifacts."}];function $(n){const e=n.cwd,r=n.allCwds===!0;if(e!==void 0&&r)throw t("--cwd and --all-cwds are mutually exclusive.");const i=d(n.type);if(i!==void 0){const s=i.find(o=>!u.includes(o));if(s!==void 0)throw t(`--type must be one of: ${u.join(", ")}; received: ${s}`)}const c=d(n.origin);if(c!==void 0){const s=c.find(o=>!f.includes(o));if(s!==void 0)throw t(`--origin must be one of: ${f.join(", ")}; received: ${s}`)}const l=d(n.role);if(l!==void 0){const s=l.find(o=>!p.includes(o));if(s!==void 0)throw t(`--role must be one of: ${p.join(", ")}; received: ${s}`)}if(i!==void 0&&i.includes("transcript")&&!(n.node!==void 0||n.under!==void 0||n.since!==void 0))throw t("--type transcript needs a narrowing flag: pass --node, --under, or --since.",{next:"Transcripts are the full conversation corpus \u2014 scanning every node in a cwd reads every session file. Narrow first."});return{cwd:e,allCwds:r,under:n.under,nodes:d(n.node),types:i,kinds:d(n.kind),statuses:d(n.status),sinceMs:n.since!==void 0?m("since",n.since):void 0,untilMs:n.until!==void 0?m("until",n.until):void 0,origins:c,roles:l,from:n.from}}a($,"parseFilters");function S(n,e){const r=e.allCwds||e.under!==void 0||e.nodes!==void 0&&e.nodes.length>0,i=e.cwd??(r||w()!==void 0?void 0:process.cwd());i!==void 0&&(n.cwd=i),e.allCwds&&(n.all_cwds=!0),e.under!==void 0&&(n.under=e.under),e.nodes!==void 0&&(n.nodes=e.nodes),e.types!==void 0&&(n.types=e.types),e.kinds!==void 0&&(n.kinds=e.kinds),e.statuses!==void 0&&(n.statuses=e.statuses),e.sinceMs!==void 0&&(n.since_ms=e.sinceMs),e.untilMs!==void 0&&(n.until_ms=e.untilMs),e.origins!==void 0&&(n.origins=e.origins),e.roles!==void 0&&(n.roles=e.roles),e.from!==void 0&&(n.from=e.from)}a(S,"applyFilters");export{y as NODE_KINDS,f as ORIGINS,p as ROLES,v as STATUSES,u as TYPES,S as applyFilters,_ as filterParams,$ as parseFilters,m as parseWhen,d as splitCsv};
@@ -1,4 +1,4 @@
1
- var q=Object.defineProperty;var i=(e,t)=>q(e,"name",{value:t,configurable:!0});import{envNodeId as j}from"../../shared/env.js";import{defineBranch as T,defineLeaf as h}from"../../core/command.js";import{InputError as r}from"../../core/io.js";import{ExitCode as R}from"../../types.js";import{existsSync as D,mkdirSync as E,rmSync as I,writeFileSync as w}from"node:fs";import{backgroundRunningBashJobs as N,bashJobCommandLine as B,bashJobPaths as y,formatBashElapsed as k,isSafeBashJobId as g,jobStartedAtMs as M,newBashJobId as L,tailJobLog as S}from"../../core/bash-jobs.js";import{parseDurationMs as U}from"../../core/wake.js";import{cliClient as u,getNodeOrNull as c}from"../api-client.js";import{ApiError as x}from"../../api/index.js";import{PREVIEW_RESULT_PATH_ENV as C}from"../../core/preview-result-path.js";import{contextDir as v}from"../../core/canvas/paths.js";import{nodeInPane as A}from"../surface/node/placement.js";function b(e,t){const n=e.pane??process.env.TMUX_PANE;let o=e.node;if((o===void 0||o==="")&&(o=A(n)),(o===void 0||o==="")&&(o=j()),o===void 0||o==="")throw new r({error:"no_node",message:t,next:"Run from inside a node, pass --node <id>, or --pane <pane>."});return{id:o,pane:n}}i(b,"resolveBashTarget");async function _(e,t,n){try{await u().patchBashJob(e,t,n)}catch(o){throw o instanceof x&&(o.status===404||o.status===409)?new r({error:"not_running",message:`background job ${t} for ${e} is not running`,next:"List live jobs with `crtr node bash list`."}):o}}i(_,"patchRunningJob");const J=h({name:"run",description:"start a shell command as a background job and return at once",whenToUse:"a command needs longer than one tool call \u2014 a test lane, a build, a soak \u2014 and you should be woken with its exit code instead of waiting, backgrounding with `&`, or polling a log",tier:"normal",help:{name:"node bash run",summary:"start one shell command as a background job owned by the calling node and return before it finishes",params:[{kind:"positional",name:"command",required:!0,constraint:"The shell command, run by bash from the current directory with this process\u2019s environment. The same refusals apply as for a bash tool call, judged on this command."},{kind:"flag",name:"quiet-ok",type:"bool",required:!1,constraint:"Pass for a job that legitimately sits idle \u2014 `gh run watch`, `sleep`, waiting on a lock, a `docker build` whose work runs outside the process tree \u2014 so it gets no silence messages. Omit it for anything that should be making progress."}],output:[{name:"job_id",type:"string",required:!0,constraint:"The job object\u2019s id; read or watch it with `crtr canvas`, stop it with `node bash kill`."},{name:"log_path",type:"string",required:!0,constraint:"File receiving the command\u2019s combined stdout and stderr, capped at 10 MiB."}],outputKind:"object",effects:["Works only inside a node\u2019s bash tool call; the job belongs to the calling node.","Starts the command detached from this call, so it keeps running after the call and the turn end. A `timeout` around this leaf bounds only the launch, not the job.","Records the job as a canvas object; when the command exits, its watchers (the calling node by default) get an urgent `exited` push with the exit code and log path.","Sets no cancel deadline: the job runs to completion unless stopped with `node bash kill`.","A job whose processes use almost no CPU and write to no open file for 15 minutes messages the calling node about it, again at 30 and 60 minutes, then hourly; activity restarts the schedule and nothing is stopped. `--quiet-ok` turns these messages off.","Fails, with the job id and log path, if the job could not be recorded; the command is then running but will not message the node when it exits."]},run:i(async e=>{const t=e.command,n=j(),o=process.env.CRTR_CONTEXT_DIR;if(n===void 0||n===""||o===void 0||o==="")throw new r({error:"no_node",message:"`node bash run` starts a job for the calling node and works only inside a node\u2019s bash tool",next:"Run it from a node\u2019s bash tool call."});const s=process.cwd(),{destructiveCommandRefusal:d}=await import("../../core/bash-guard.js"),l=d(t,s);if(l!==null)throw new r({error:"refused",message:l,next:"Run a different command."});const a=y(o,L());E(a.dir,{recursive:!0}),w(a.cmdSh,t),w(a.jobLog,""),w(a.jobBg,"");const{launchBashJobSupervisor:m}=await import("../../core/runtime/broker/bash-job-launch.js"),{[C]:p,...$}=process.env;try{await m(n,a,o,s,$)}catch(f){throw I(a.dir,{recursive:!0,force:!0}),f}try{await u().recordBackgroundedJob(n,a.jobId,{command:t}),e.quietOk===!0&&await u().patchBashJob(n,a.jobId,{quiet_ok:!0})}catch(f){throw new r({error:"job_not_recorded",message:`job ${a.jobId} is running but could not be recorded (${f.message}); it will NOT message you when it exits. Log: ${a.jobLog}`,next:`Watch it with \`tail -f ${a.jobLog}\`, or stop it with \`crtr node bash kill ${a.jobId}\`.`},R.GENERAL)}return{job_id:a.jobId,log_path:a.jobLog}},"run"),render:i(e=>`[backgrounded as job ${e.job_id}. It will interrupt you with a message when it exits. Watch: tail -f ${e.log_path} ; stop: crtr node bash kill ${e.job_id}]`,"render")}),P=h({name:"background",description:"hand the focused node\u2019s running bash command to its background job system",whenToUse:"the tmux prefix menu invokes this when a foreground bash command should stop blocking the agent immediately but keep running as a file-backed background job",tier:"hidden",help:{name:"node bash background",summary:"hand every running foreground bash command for one node to its file-backed background job system",params:[{kind:"flag",name:"node",type:"string",required:!1,constraint:"Node whose running bash command to background. Defaults to the node in --pane, else the caller (CRTR_NODE_ID)."},{kind:"flag",name:"pane",type:"string",required:!1,constraint:"tmux pane showing the target node, when --node is omitted. Defaults to $TMUX_PANE. The prefix menu passes this for you."}],output:[{name:"node_id",type:"string",required:!0,constraint:"The target node."},{name:"jobs",type:"object[]",required:!0,constraint:"Per handed-off job {job_id, elapsed_ms} \u2014 the foreground elapsed time in milliseconds at the moment of handoff."}],outputKind:"object",effects:["Signals every foreground bash command currently running for the node to return from its tool call immediately while its detached supervisor keeps the command running.","Each handed-off command retains its log under the node context jobs directory and becomes a job object; when it exits, the job\u2019s watchers (its node by default) get an urgent `exited` push carrying the exit code and log path."]},run:i(async e=>{const{id:t}=b(e,"no node found for the bash handoff"),n=await c(t);if(n===null)throw new r({error:"not_found",message:`no node: ${t}`,next:"List nodes with `crtr node inspect list`."});const o=N(v(n.node_id,n.grantee)),s=Date.now(),d=o.map(l=>({job_id:l.jobId,elapsed_ms:s-(M(l.jobId)??s)}));return{node_id:t,jobs:d}},"run"),render:i(e=>{const t=e.jobs;if(t.length===0)return`No foreground bash command is running for ${e.node_id}.`;const n=Math.max(...t.map(o=>o.elapsed_ms));return`Handed ${t.length} bash command(s) to the background job system for ${e.node_id} \xB7 ran ${k(n)} in the foreground.`},"render")}),O=h({name:"list",description:"list a node\u2019s live background bash jobs",whenToUse:"you need the ids, commands, and ages of your jobs that are still running",help:{name:"node bash list",summary:"read every still-running background bash job owned by one node",params:[{kind:"flag",name:"node",type:"string",required:!1,constraint:"Node whose background jobs to list. Defaults to the node in --pane, else the caller (CRTR_NODE_ID)."},{kind:"flag",name:"pane",type:"string",required:!1,constraint:"tmux pane showing the target node, when --node is omitted. Defaults to $TMUX_PANE."},{kind:"flag",name:"tail",type:"int",required:!1,default:0,constraint:"Include this many trailing log lines per job (0 = none). Read from the local log file, so it is available only on the machine that runs the job; elsewhere log_tail is null \u2014 use `node bash log` there."}],output:[{name:"node_id",type:"string",required:!0,constraint:"The target node."},{name:"jobs",type:"object[]",required:!0,constraint:"Oldest-first {job_id, command, purpose, started_at, elapsed_ms, deadline_at, output_key, log_path, pgid, log_tail} for every live background job; log_path and log_tail are null when the job\u2019s log is not on this machine (a job running in a sandbox, listed from outside it), and no tail is available from here (`node bash log` reads its stored output); purpose is a human-readable label or null; deadline_at is the auto-cancel time or null for a job that runs to completion."}],outputKind:"object",effects:["Reads the node\u2019s running job rows and, for log_tail, the local log files. Changes nothing."]},run:i(async e=>{const{id:t}=b(e,"no node found for the bash job list"),n=await c(t);if(n===null)throw new r({error:"not_found",message:`no node: ${t}`,next:"List nodes with `crtr node inspect list`."});const o=Date.now(),s=Math.max(0,Math.trunc(Number(e.tail??0))),d=[n.paths.context_dir,v(n.node_id,n.grantee)],l=(await u().listBashJobs(n.node_id)).map(a=>{const m=d.map(p=>y(p,a.job_id).jobLog).find(p=>D(p))??null;return{job_id:a.job_id,command:a.command,purpose:a.purpose,started_at:a.started_at,elapsed_ms:a.elapsed_ms,deadline_at:a.deadline_at,output_key:a.output_key,log_path:m,pgid:a.pgid,log_tail:m===null?null:S(m,s)}});return{node_id:n.node_id,jobs:l}},"run"),render:i(e=>{const t=e.jobs;return t.length===0?`No background bash jobs for ${e.node_id}.`:t.map(n=>`${n.job_id} \xB7 ${k(n.elapsed_ms)} \xB7 ${B(n.command)}${n.purpose===null?"":`
1
+ var q=Object.defineProperty;var i=(e,t)=>q(e,"name",{value:t,configurable:!0});import{envNodeId as j}from"../../shared/env.js";import{defineBranch as T,defineLeaf as h}from"../../core/command.js";import{InputError as r}from"../../core/io.js";import{ExitCode as R}from"../../types.js";import{existsSync as D,mkdirSync as E,rmSync as I,writeFileSync as w}from"node:fs";import{backgroundRunningBashJobs as N,bashJobCommandLine as B,bashJobPaths as y,formatBashElapsed as k,isSafeBashJobId as g,jobStartedAtMs as M,newBashJobId as L,tailJobLog as S}from"../../core/bash-jobs.js";import{parseDurationMs as U}from"../../core/wake.js";import{cliClient as u,getNodeOrNull as c}from"../api-client.js";import{ApiError as x}from"../../api/index.js";import{PREVIEW_RESULT_PATH_ENV as C}from"../../core/preview-result-path.js";import{contextDir as v}from"../../core/canvas/paths.js";import{nodeInPane as A}from"../surface/node/placement.js";function b(e,t){const n=e.pane??process.env.TMUX_PANE;let o=e.node;if((o===void 0||o==="")&&(o=A(n)),(o===void 0||o==="")&&(o=j()),o===void 0||o==="")throw new r({error:"no_node",message:t,next:"Run from inside a node, pass --node <id>, or --pane <pane>."});return{id:o,pane:n}}i(b,"resolveBashTarget");async function _(e,t,n){try{await u().patchBashJob(e,t,n)}catch(o){throw o instanceof x&&(o.status===404||o.status===409)?new r({error:"not_running",message:`background job ${t} for ${e} is not running`,next:"List live jobs with `crtr node bash list`."}):o}}i(_,"patchRunningJob");const J=h({name:"run",description:"start a shell command as a background job and return at once",whenToUse:"a command needs longer than one tool call \u2014 a test lane, a build, a soak \u2014 and you should be woken with its exit code instead of waiting, backgrounding with `&`, or polling a log",tier:"normal",help:{name:"node bash run",summary:"start one shell command as a background job owned by the calling node and return before it finishes",params:[{kind:"positional",name:"command",required:!0,constraint:"The shell command, run by bash from the current directory with this process\u2019s environment. The same refusals apply as for a bash tool call, judged on this command."},{kind:"flag",name:"quiet-ok",type:"bool",required:!1,constraint:"Pass for a job that legitimately sits idle \u2014 `gh run watch`, `sleep`, waiting on a lock, a `docker build` whose work runs outside the process tree \u2014 so it gets no silence messages. Omit it for anything that should be making progress."}],output:[{name:"job_id",type:"string",required:!0,constraint:"The job object\u2019s id; read or watch it with `crtr canvas`, stop it with `node bash kill`."},{name:"log_path",type:"string",required:!0,constraint:"File receiving the command\u2019s combined stdout and stderr, capped at 10 MiB."}],outputKind:"object",effects:["Works only inside a node\u2019s bash tool call; the job belongs to the calling node.","Starts the command detached from this call, so it keeps running after the call and the turn end. A `timeout` around this leaf bounds only the launch, not the job.","Records the job as a canvas object; when the command exits, its watchers (the calling node by default) get an urgent `exited` push with the exit code and log path.","Sets no cancel deadline: the job runs to completion unless stopped with `node bash kill`.","A job whose processes use almost no CPU and write to no open file for 15 minutes messages the calling node about it, again at 30 and 60 minutes, then hourly; activity restarts the schedule and nothing is stopped. `--quiet-ok` turns these messages off.","Fails, with the job id and log path, if the job could not be recorded; the command is then running but will not message the node when it exits."]},run:i(async e=>{const t=e.command,n=j(),o=process.env.CRTR_CONTEXT_DIR;if(n===void 0||n===""||o===void 0||o==="")throw new r({error:"no_node",message:"`node bash run` starts a job for the calling node and works only inside a node\u2019s bash tool",next:"Run it from a node\u2019s bash tool call."});const s=process.cwd(),{destructiveCommandRefusal:d}=await import("../../core/bash-guard.js"),l=d(t,s);if(l!==null)throw new r({error:"refused",message:l,next:"Run a different command."});const a=y(o,L());E(a.dir,{recursive:!0}),w(a.cmdSh,t),w(a.jobLog,""),w(a.jobBg,"");const{launchBashJobSupervisor:m}=await import("../../core/runtime/broker/bash-job-launch.js"),{[C]:p,...$}=process.env;try{await m(n,a,o,s,$)}catch(f){throw I(a.dir,{recursive:!0,force:!0}),f}try{await u().recordBackgroundedJob(n,a.jobId,{command:t}),e.quietOk===!0&&await u().patchBashJob(n,a.jobId,{quiet_ok:!0})}catch(f){throw new r({error:"job_not_recorded",message:`job ${a.jobId} is running but could not be recorded (${f.message}); it will NOT message you when it exits. Log: ${a.jobLog}`,next:`Watch it with \`tail -f ${a.jobLog}\`, or stop it with \`crtr node bash kill ${a.jobId}\`.`},R.GENERAL)}return{job_id:a.jobId,log_path:a.jobLog}},"run"),render:i(e=>`[backgrounded as job ${e.job_id}. It will interrupt you with a message when it exits. Watch: tail -f ${e.log_path} ; stop: crtr node bash kill ${e.job_id}]`,"render")}),P=h({name:"background",description:"hand the focused node\u2019s running bash command to its background job system",whenToUse:"the tmux prefix menu invokes this when a foreground bash command should stop blocking the agent immediately but keep running as a file-backed background job",tier:"hidden",help:{name:"node bash background",summary:"hand every running foreground bash command for one node to its file-backed background job system",params:[{kind:"flag",name:"node",type:"string",required:!1,constraint:"Node whose running bash command to background. Defaults to the node in --pane, else the caller (CRTR_NODE_ID)."},{kind:"flag",name:"pane",type:"string",required:!1,constraint:"tmux pane showing the target node, when --node is omitted. Defaults to $TMUX_PANE. The prefix menu passes this for you."}],output:[{name:"node_id",type:"string",required:!0,constraint:"The target node."},{name:"jobs",type:"object[]",required:!0,constraint:"Per handed-off job {job_id, elapsed_ms} \u2014 the foreground elapsed time in milliseconds at the moment of handoff."}],outputKind:"object",effects:["Signals every foreground bash command currently running for the node to return from its tool call immediately while its detached supervisor keeps the command running.","Each handed-off command retains its log under the node context jobs directory and becomes a job object; when it exits, the job\u2019s watchers (its node by default) get an urgent `exited` push carrying the exit code and log path."]},run:i(async e=>{const{id:t}=b(e,"no node found for the bash handoff"),n=await c(t);if(n===null)throw new r({error:"not_found",message:`no node: ${t}`,next:"List nodes with `crtr node inspect list`."});const o=N(v(n.node_id,n.grantee)),s=Date.now(),d=o.map(l=>({job_id:l.jobId,elapsed_ms:s-(M(l.jobId)??s)}));return{node_id:t,jobs:d}},"run"),render:i(e=>{const t=e.jobs;if(t.length===0)return`No foreground bash command is running for ${e.node_id}.`;const n=Math.max(...t.map(o=>o.elapsed_ms));return`Handed ${t.length} bash command(s) to the background job system for ${e.node_id} \xB7 ran ${k(n)} in the foreground.`},"render")}),O=h({name:"list",description:"list a node\u2019s live background bash jobs",whenToUse:"you need the ids, commands, and ages of your jobs that are still running",help:{name:"node bash list",summary:"read every still-running background bash job owned by one node",params:[{kind:"flag",name:"node",type:"string",required:!1,constraint:"Node whose background jobs to list. Defaults to the node in --pane, else the caller (CRTR_NODE_ID)."},{kind:"flag",name:"pane",type:"string",required:!1,constraint:"tmux pane showing the target node, when --node is omitted. Defaults to $TMUX_PANE."},{kind:"flag",name:"tail",type:"int",required:!1,default:0,constraint:"Include this many trailing log lines per job (0 = none). Read from the local log file, so it is available only on the machine that runs the job; elsewhere log_tail is null \u2014 use `node bash log` there."}],output:[{name:"node_id",type:"string",required:!0,constraint:"The target node."},{name:"jobs",type:"object[]",required:!0,constraint:"Oldest-first {job_id, command, purpose, started_at, elapsed_ms, deadline_at, output_key, log_path, pgid, log_tail} for every live background job; log_path and log_tail are null when the job\u2019s log is not on this machine (a job running in a sandbox, listed from outside it), and no tail is available from here (`node bash log` reads its stored output); purpose is a human-readable label or null; deadline_at is the auto-cancel time or null for a job that runs to completion."}],outputKind:"object",effects:["Reads the node\u2019s running job rows and, for log_tail, the local log files. Changes nothing."]},run:i(async e=>{const{id:t}=b(e,"no node found for the bash job list"),n=await c(t);if(n===null)throw new r({error:"not_found",message:`no node: ${t}`,next:"List nodes with `crtr node inspect list`."});const o=Date.now(),s=Math.max(0,Math.trunc(Number(e.tail??0))),d=[v(n.node_id,n.grantee)],l=(await u().listBashJobs(n.node_id)).map(a=>{const m=d.map(p=>y(p,a.job_id).jobLog).find(p=>D(p))??null;return{job_id:a.job_id,command:a.command,purpose:a.purpose,started_at:a.started_at,elapsed_ms:a.elapsed_ms,deadline_at:a.deadline_at,output_key:a.output_key,log_path:m,pgid:a.pgid,log_tail:m===null?null:S(m,s)}});return{node_id:n.node_id,jobs:l}},"run"),render:i(e=>{const t=e.jobs;return t.length===0?`No background bash jobs for ${e.node_id}.`:t.map(n=>`${n.job_id} \xB7 ${k(n.elapsed_ms)} \xB7 ${B(n.command)}${n.purpose===null?"":`
2
2
  purpose: ${n.purpose}`}${n.deadline_at===null?"":`
3
3
  cancels at: ${n.deadline_at}`}
4
4
  ${n.log_path===null?`log: not on this machine (its job files are not under this machine\u2019s crtr home \u2014 a sandbox or another computer); read its output with \`crtr node bash log ${n.job_id} --node ${e.node_id}\``:`log: ${n.log_path}`}`).join(`
@@ -1,2 +1,2 @@
1
- var G=Object.defineProperty;var s=(e,n)=>G(e,"name",{value:n,configurable:!0});import{envNodeId as V}from"../../shared/env.js";import{defineLeaf as X}from"../../core/command.js";import{InputError as o}from"../../core/io.js";import{requireScope as Q}from"../../core/errors.js";import{mark as N}from"../../core/timing.js";import{OUTPUT_SCHEMA_CONSTRAINTS as Z,OUTPUT_SCHEMA_TRANSPORT as ee,parseOutputSchemaValue as te}from"../../core/runtime/structured-output.js";import{MODEL_SPEC_FORMS as oe,MODEL_SPEC_NEXT as ne}from"../../core/runtime/model-selection.js";import{parseDurationMs as re}from"../../core/wake.js";import{kindsStateBlock as ae,profilesStateBlock as ie,resolveProfileViaDaemon as se}from"../profile/daemon-profiles.js";import{cliClient as H,getNodeOrNull as de,rethrowAsCliError as $}from"../api-client.js";import{inTmux as z}from"../../core/runtime/placement-tmux.js";import{openSpawnViewer as ce}from"../surface/node/placement.js";import{randomUUID as le}from"node:crypto";import{resolve as ue}from"node:path";import{isDaemonTransportApiError as W}from"../../api/errors.js";import{ExitCode as he}from"../../types.js";const fe=1e5,B='--output-schema records the accepted result on the node\u2019s structured request and pushes it as the node\u2019s final report; a node that cannot honestly satisfy the schema declines with `crtr push result --decline "<reason>" --code <token>`, which finishes it with a failure outcome (reason `declined`) whose `declined` field carries { reason, code, retryable } and no result. Name the code tokens you accept in the prompt; crouter carries the code verbatim and you validate it.',K=["A resident is told never to push a final, so the spawner gets no report wake when the work is done.","If it stops mid-task, nothing prompts it to continue.","After 15 unattended minutes it is concluded with only a deferred update, which does not wake the spawner."],J="To re-task a terminal child after its final, use `crtr node message send --reopen`; to make an existing node resident later, use `crtr node config --lifecycle resident`.",T="Do not wait, poll, or duplicate this child's assignment in your own context \u2014 there is no result to await, stopping will not strand you, and duplicated work wastes the delegated context. You're auto-subscribed, so its finish wakes you on its own. Two moves only: do other independent work right now, or stop and end your turn \u2014 the wake brings you back.";async function me(e){if(e===void 0||e==="")return T;const n=await de(e);if(n===null||n.mode!=="orchestrator")return T;const t=n.context_tokens??null;return t===null||t<fe?T:`Child spawned \u2014 you're auto-subscribed, so its finish wakes you on its own; never wait, poll, or duplicate the child's assignment in your own context. But you're an orchestrator already carrying ~${Math.round(t/1e3)}k of context: rather than hold this window open for the result, bring your document \`roadmap\` current (\`crtr doc edit roadmap\`) and \`crtr node yield\` now. Yielding ends this turn, and the child's completion then revives you fresh against your roadmap \u2014 let that clean revive absorb the result instead of this bloated context.`}s(me,"childFollowUp");function pe(e,n){throw W(e)||$(e),new o({error:"node_create_effect_unknown",message:`Node creation did not receive an acknowledgement after automatic recovery with request key ${n}; its effect is unknown.`,next:"Do not create a replacement node until the daemon is reachable and this request can be recovered."},he.NETWORK)}s(pe,"createTransportFailure");function we(){return[{kind:"stdin",name:"prompt",required:!1,constraint:"First user message."},{kind:"flag",name:"kind",type:"string",required:!1,constraint:"Persona kind. Defaults to the profile's default kind; `general` when the profile has none. The <kinds> list below names every top-level installable kind."},{kind:"flag",name:"mode",type:"enum",choices:["base","orchestrator"],required:!1,default:"base",constraint:"Persona mode. base for one hands-on unit; orchestrator when the unit itself needs decomposition across children. When you hold several parallel units of one kind, spawn ONE orchestrator child of that kind to own the fan-out rather than spawning the units yourself \u2014 unless you are already an orchestrator of that kind, whose job is exactly that fan-out."},{kind:"flag",name:"cwd",type:"path",required:!1,constraint:"Pin the node to this directory. Without --worktree, defaults to the spawner\u2019s directory for a managed child and the invocation directory for a root. With --worktree, selects the repository used for creation, defaulting to the invocation directory; the child runs in the new checkout."},{kind:"flag",name:"name",type:"string",required:!1,constraint:"Display name."},{kind:"flag",name:"parent",type:"string",required:!1,constraint:"Parent node id. Defaults to the calling node."},{kind:"flag",name:"node-id",type:"string",required:!1,constraint:"Exact id for the new node; lowercase letters, digits, and hyphens only, at most 128 characters. Rejected if already present."},{kind:"flag",name:"root",type:"bool",required:!1,constraint:"Spawn an independent root with no parent or subscription. Mutually exclusive with --worktree."},{kind:"flag",name:"resident",type:"bool",required:!1,constraint:"Birth the node as resident, a conversation partner for a person rather than a worker. Omit unless the user explicitly asks for a node they can talk with back and forth.",focusedHelp:{whenToUse:"Pass it ONLY when the user explicitly asks for a node they can talk with back and forth. Never infer it from task size, from expecting the user to look at the node, or from wanting to follow up later. "+J,value:"Boolean. Roots default to resident, so with --root it changes nothing. Managed children default to terminal; for a managed child the command first refuses, explains the cost, and says how to confirm.",effects:[...K,"It ends by going dormant or by being closed."]}},{kind:"flag",name:"terminal",type:"bool",required:!1,constraint:"Birth the node as terminal: it finalizes when its work is done and leaves nothing wakeable behind. Only meaningful with --root, whose default is resident; managed children are already terminal. Pass it for bounded programmatic work no one will open a viewer on. Mutually exclusive with --resident."},{kind:"flag",name:"force",type:"bool",required:!1,default:!1,hidden:!0,constraint:"Confirm a resident managed child (--resident without --root) after the user explicitly asked for one."},{kind:"flag",name:"worktree",type:"string",required:!1,constraint:"Existing local base branch for this child\u2019s managed worktree. When invoking from a managed worktree, also pass --cwd pointing at the repository\u2019s primary checkout; keep --worktree set to the desired parent branch. Mutually exclusive with --root."},{kind:"flag",name:"fork-from",type:"string",required:!1,constraint:"Fork the new node from an existing node id, absolute session path, or partial pi session uuid."},{kind:"flag",name:"model",type:"string",required:!1,constraint:"Durable model override. Omit unless the task or governing guidance requires a specific model.",focusedHelp:{whenToUse:"Use only when the user, task, or governing agent guidance already requires a specific provider, model, capability tier, or family. Omit it for routine delegation: the selected persona kind and profile own normal model selection, and review personas may enforce a quality floor.",value:`Accepted forms: ${oe}. Concrete provider/id requests must be registered. Portable provider/tier, bare-tier, and family-alias requests resolve through the configured model ladders.`,effects:["The resolved concrete model is stored on the node and in its launch recipe.","A concrete provider/id runs exactly that model on every launch and revive. A portable provider/tier, bare tier, or family alias keeps its tier: when that model's provider is rate-limited or rejects its credential, the node moves to the next model in its route: another provider's model at the same tier first, then the configured fallback tier (strong by default).","A persona quality floor may raise a weaker request before its resolved model is stored."]}},{kind:"flag",name:"profile",type:"string",required:!1,constraint:"Profile override. Use only when the task needs different project purview, owned documents, or environment; otherwise omit for normal inheritance or selection.",focusedHelp:{whenToUse:"Use only when the work must run under a different profile because it needs that profile\u2019s project purview, owned documents, stored environment, or defaults. Do not use it merely to change the working directory, persona kind, model, or graph ownership; those have separate parameters.",value:"Pass a profile id or name from the <profiles> list below; a close-enough name resolves to the nearest profile and the choice is reported on stderr. Omit it inside a node to inherit the caller\u2019s profile; outside a node, omission runs normal cwd-based profile selection.",effects:["The selected profile id is stored on the node and supplies its profile-scoped config, documents, environment, and injected bearings.","It does not change the parent or subscription; --cwd separately pins the working directory."]}},{kind:"flag",name:"situational-context",type:"string",required:!1,constraint:"Hidden ambient context appended to injected bearings, never visible chat."},{kind:"flag",name:"no-kickoff",type:"bool",required:!1,hidden:!0,constraint:"With --root, start the broker and session idle without a first message or model turn. Mutually exclusive with a prompt and --mode orchestrator."},{kind:"flag",name:"scopes",type:"string",required:!1,constraint:"Comma-separated scope allow-list for the node and every descendant (they inherit it and cannot widen it), e.g. `crtr:llm,crtr:act,device:shell,device:messages_read`. A provider-group call (`crtr device messages send` needs `device:messages_send`) is refused with scope_missing before any request leaves the machine when the group is absent. Must be a subset of what you hold; `crtr:act` requires `crtr:llm`. Enforced on the broker route (the node's own `crtr` calls); on an unsandboxed host a same-UID process can bypass it by calling the daemon socket directly (crouter#146), so it guards against a mistaken call, not a hostile node. Keep the list short: it travels in a request header on every device call (crouter#147)."},{kind:"flag",name:"deadline",type:"string",required:!1,constraint:"Positive, representable wall-clock duration from spawn. Grammar: one or more positive integer-unit parts; units: s, m, h, d; adjacent parts are summed. Omit for no deadline."},{kind:"flag",name:"outcome-action",type:"string",required:!1,constraint:"Declared human-action name that receives the node outcome. Grammar: 1\u2013128 ASCII letters, digits, dots, underscores, or hyphens; starts with a letter or digit. Omit when no external delivery target is needed."},{kind:"flag",name:"outcome-payload",type:"string",required:!1,constraint:"JSON value, serialized at most 64 KiB, frozen and echoed to --outcome-action. Requires --outcome-action."},{kind:"flag",name:"output-schema",type:"string",required:!1,constraint:"Replace prose completion with a schema-constrained final result. Use only when its consumer requires fixed fields.",focusedHelp:{whenToUse:"Use only when the node\u2019s consumer needs a machine-checkable final object with fixed fields. Omit it for ordinary delegation or when a prose report is enough; structured output replaces the completion protocol, and an over-constrained schema can force retries.",value:`Pass the JSON Schema the result must satisfy. ${ee} ${Z}`,effects:["The node must answer with `crtr push result` and cannot finish until the result is accepted; a plain `crtr push final` is blocked while the request is pending.",B,"The managed parent wakes through its existing subscription when the final report arrives; an independent root has no subscriber to wake.","An accepted result, or a decline, removes the request and terminates the node."]}}]}s(we,"nodeNewParams");function ye(){return[{name:"node_id",type:"string",required:!0,constraint:"New node id."},{name:"name",type:"string",required:!0,constraint:"Display name."},{name:"frozen_at",type:"string",required:!1,constraint:"Present when a managed child exists but capacity deferred its broker start."},...z()?[{name:"window",type:"string",required:!1,constraint:"tmux window id when a viewer opens."},{name:"session",type:"string",required:!1,constraint:"tmux session when a viewer opens."}]:[],{name:"follow_up",type:"string",required:!0,constraint:"Managed child: continue unrelated work or stop; its final report wakes you. Root: hand it off; no report wakes you."}]}s(ye,"nodeNewOutput");function ke(){return["Creates nodes/<id>/ in the canvas home, indexes the node in canvas.db, and starts its detached broker engine.","A managed child creates an active parent subscription; its pushes wake the parent. --root creates an independent node with spawned_by provenance and no parent subscription.","--worktree creates a managed worktree at ~/.crouter/canvas/worktrees/<node-id>/ on a new crtr/<node-id> branch.",B,"--deadline persists a wall-clock deadline from spawn; expiry cancels the node and records a failure outcome with reason deadline_exceeded.","--outcome-action registers one resolved local human-action target. When the node settles, crouter retries delivery of its outcome document until the target accepts it or permanently rejects it; --outcome-payload is frozen and echoed in that document.",...z()?["--root opens a viewer for the new node in the current tmux session."]:[]]}s(ke,"nodeNewEffects");async function ge(e){Q("crtr:act","crtr node new");const n=e.prompt??"",t=e.noKickoff===!0;if(!t&&n.trim()==="")throw new o({error:"empty_prompt",message:"a prompt is required (stdin or positional)",next:"Pipe a task on stdin or pass it as an argument, or pass --no-kickoff to spawn an idle node with none."});if(t&&n.trim()!=="")throw new o({error:"no_kickoff_with_prompt",message:"--no-kickoff cannot be combined with a prompt",field:"no-kickoff",next:"Drop --no-kickoff, or drop the prompt."});const l=e.kind,O=e.mode??"base",u=e.cwd?.trim(),h=u!==void 0&&u!==""?ue(u):void 0,S=e.name,Y=e.parent,a=e.root===!0,f=e.resident===!0,P=e.terminal===!0;if(f&&P)throw new o({error:"lifecycle_conflict",message:"--resident and --terminal cannot both be passed",field:"terminal",next:"Pass the one birth lifecycle you want, or neither to take the default (resident for --root, terminal for a managed child)."});if(f&&!a&&e.force!==!0)throw new o({error:"resident_child_requires_force",message:`--resident on a managed child makes it a conversation partner for a person, not a worker that reports back. ${K.join(" ")}`,field:"resident",next:`If the user did not explicitly ask for a node they can talk with back and forth, drop --resident; a terminal child's final report wakes you. ${J} If the user did explicitly ask for one, re-run with --force.`});const m=e.worktree;if(m!==void 0&&m.trim()==="")throw new o({error:"worktree_base_required",message:"--worktree requires a base branch",field:"worktree",next:"Pass an existing local branch that landing can fast-forward."});const p=m?.trim(),E=e.forkFrom,w=e.model?.trim();if(w==="")throw new o({error:"empty_spec",message:"a model spec is required",field:"model",next:`Run \`crtr node new --model -h\` and read the focused contract. ${ne}`});const D=e.profile,C=D===void 0?void 0:(await se(D)).id,y=e.situationalContext?.trim(),A=y!==void 0&&y!==""?y:void 0,U=te(e.outputSchema),I=U!==null?JSON.stringify(U):null,d=e.deadline;if(d!==void 0){const r=re(d),q=r===null?Number.NaN:new Date(Date.now()+r).getTime();if(r===null||!Number.isFinite(r)||r<=0||!Number.isFinite(q))throw new o({error:"invalid_deadline",message:"--deadline must be a positive representable duration",field:"deadline",next:"Pass positive integer-unit parts using s, m, h, or d."})}const k=e.outcomeAction,g=e.outcomePayload;if(g!==void 0&&k===void 0)throw new o({error:"outcome_payload_requires_action",message:"--outcome-payload requires --outcome-action",field:"outcome-payload",next:"Pass the declared delivery action with --outcome-action."});let v;if(g!==void 0)try{v=JSON.parse(g)}catch{throw new o({error:"invalid_outcome_payload",message:"--outcome-payload must be valid JSON",field:"outcome-payload",next:"Pass one valid JSON value."})}const R=e.scopes,c=R===void 0?void 0:R.split(",").map(r=>r.trim()).filter(r=>r!=="");if(c!==void 0&&c.length===0)throw new o({error:"empty_scopes",message:"--scopes names no scope",field:"scopes",next:"Pass a comma-separated list such as crtr:llm,crtr:act, or omit --scopes to inherit."});const b=e.nodeId?.trim();if(a&&p!==void 0)throw new o({error:"worktree_root_conflict",message:"--worktree is mutually exclusive with --root",field:"worktree",next:"Drop either --root or --worktree."});if(t&&!a)throw new o({error:"no_kickoff_requires_root",message:"--no-kickoff is only valid with --root",field:"no-kickoff",next:"Add --root, or drop --no-kickoff and provide a prompt."});if(t&&O==="orchestrator")throw new o({error:"no_kickoff_orchestrator_unsupported",message:"--no-kickoff cannot be combined with --mode orchestrator",field:"no-kickoff",next:"Drop --no-kickoff and provide a prompt, or spawn in base mode."});const _=V(),M=Y??_;N("node_new.create_start",{root:a});const L=le(),j={...l!==void 0?{kind:l}:{},mode:O,cwd:process.cwd(),...h!==void 0&&h!==""?{pin_cwd:h}:{},...S!==void 0?{name:S}:{},prompt:n,...a?{root:!0}:{parent:M??null},..._!==void 0?{creator:_}:{},...f?{root_lifecycle:"resident"}:{},...P?{root_lifecycle:"terminal"}:{},...p!==void 0?{worktree:p}:{},...E!==void 0?{fork_from:E}:{},...w!==void 0?{model:w}:{},...C!==void 0?{profile:C}:{},...A!==void 0?{situational_context:A}:{},...t?{no_kickoff:!0}:{},...I!==null?{output_schema:I}:{},...c!==void 0?{scopes:c}:{},...d!==void 0?{deadline:d}:{},...k!==void 0?{outcome_delivery:{action:k,...v===void 0?{}:{payload:v}}}:{},...b!==void 0&&b!==""?{node_id:b}:{},...a?{prefer_warm:!0}:{},request_key:L};let i;try{i=await H().createNode(j)}catch(r){W(r)||$(r);try{i=await H().createNode(j)}catch(q){pe(q,L)}}N("node_new.node_created",{node:i.node_id});let x={};a&&(x=ce(i.node_id,i.cwd,i.name)),a&&N("node_new.viewer_window_opened");const F=!a&&i.frozen_at!==null;return{node_id:i.node_id,name:i.name,...F?{frozen_at:i.frozen_at}:{},window:x.window,session:x.session,follow_up:a?t?"Independent root spawned idle. No kickoff turn ran; hand it off or attach and prompt it. No report wakes you.":"Independent root spawned. You are not subscribed, so its finish does not wake you; hand it off and move on.":F?"Child row exists and is frozen: its broker has not started yet. A node whose environment is remote (an imported Mac, a Blaxel sandbox) is always born frozen until the cloud launches it; a local node waits here because capacity (broker slots or the app's memory) is full and launches when it frees. Its final report wakes you then.":await me(M)}}s(ge,"runNodeCreation");const Le=X({name:"new",description:"create and start a node immediately",whenToUse:"a unit of work is genuinely separable from what you are doing: a bounded subtask you would otherwise grind out inline, several independent units worth running in parallel (usually via one orchestrator child of the matching kind rather than a flat fan-out from you), a scouting pass over unfamiliar code, a change that wants its own git worktree, or an answer you need in a fixed shape rather than as prose",tier:"important",help:{name:"node new",summary:"create a node immediately and start its detached broker",guide:"The prompt is the child\u2019s entire brief: it wakes with this prompt, its persona, and ambient bearings \u2014 none of your conversation carries over. State the outcome and constraints. Pass an implementation plan only when it is already settled or necessary to preserve an approved decision; otherwise, let the child investigate and choose how. Give the reason along with the request: the larger goal this serves and what the child's output enables, so the child resolves ambiguity toward your intent instead of guessing. Point at every document the task depends on (a spec, an explore map, an earlier child's findings) as `[[<node-id>/<name>]]`, or `[[name]]` for a repo, profile or user document; the child reads each with `crtr canvas read` and receives nothing the prompt does not point at. Name every file or directory as an absolute host path, never `~`-relative: the child's `~` is its own HOME, not yours, and a hook cwd outside its mounts (e.g. `/tmp`) is refused. When the report must carry something specific\u2014findings inline, or pointers to documents it wrote\u2014say so in the prompt.",params:we(),output:ye(),outputKind:"object",effects:ke()},helpState:{leaf:ae,flags:{profile:ie}},run:s(e=>ge(e),"run"),render:s(e=>{const n=e.window?` in window ${e.window}`:"",t=[`Spawned "${e.name}" (${e.node_id})${n}.`];return e.session&&t.push(`- session: ${e.session}`),t.push("",String(e.follow_up)),t.join(`
2
- `)},"render")});export{me as childFollowUp,Le as nodeNew};
1
+ var X=Object.defineProperty;var s=(e,r)=>X(e,"name",{value:r,configurable:!0});import{envNodeId as Q,envProfileId as Z}from"../../shared/env.js";import{readMergedLaunchConfig as ee}from"../../core/config.js";import{defineLeaf as te}from"../../core/command.js";import{InputError as t}from"../../core/io.js";import{requireScope as oe}from"../../core/errors.js";import{mark as O}from"../../core/timing.js";import{OUTPUT_SCHEMA_CONSTRAINTS as ne,OUTPUT_SCHEMA_TRANSPORT as re,parseOutputSchemaValue as ie}from"../../core/runtime/structured-output.js";import{MODEL_SPEC_FORMS as ae,MODEL_SPEC_NEXT as se}from"../../core/runtime/model-selection.js";import{parseDurationMs as de}from"../../core/wake.js";import{kindsStateBlock as ce,profilesStateBlock as le,resolveProfileViaDaemon as ue}from"../profile/daemon-profiles.js";import{cliClient as S,getNodeOrNull as he,rethrowAsCliError as z}from"../api-client.js";import{inTmux as W}from"../../core/runtime/placement-tmux.js";import{openSpawnViewer as fe}from"../surface/node/placement.js";import{randomUUID as me}from"node:crypto";import{resolve as pe}from"node:path";import{isDaemonTransportApiError as B}from"../../api/errors.js";import{ExitCode as we}from"../../types.js";const ke=1e5,K='--output-schema records the accepted result on the node\u2019s structured request and pushes it as the node\u2019s final report; a node that cannot honestly satisfy the schema declines with `crtr push result --decline "<reason>" --code <token>`, which finishes it with a failure outcome (reason `declined`) whose `declined` field carries { reason, code, retryable } and no result. Name the code tokens you accept in the prompt; crouter carries the code verbatim and you validate it.',J=["A resident is told never to push a final, so the spawner gets no report wake when the work is done.","If it stops mid-task, nothing prompts it to continue.","After 15 unattended minutes it is concluded with only a deferred update, which does not wake the spawner."],V="To re-task a terminal child after its final, use `crtr node message send --reopen`; to make an existing node resident later, use `crtr node config --lifecycle resident`.",T="Do not wait, poll, or duplicate this child's assignment in your own context \u2014 there is no result to await, stopping will not strand you, and duplicated work wastes the delegated context. You're auto-subscribed, so its finish wakes you on its own. Two moves only: do other independent work right now, or stop and end your turn \u2014 the wake brings you back.";async function ye(e){if(e===void 0||e==="")return T;const r=await he(e);if(r===null||r.mode!=="orchestrator")return T;const o=r.context_tokens??null;return o===null||o<ke?T:`Child spawned \u2014 you're auto-subscribed, so its finish wakes you on its own; never wait, poll, or duplicate the child's assignment in your own context. But you're an orchestrator already carrying ~${Math.round(o/1e3)}k of context: rather than hold this window open for the result, bring your document \`roadmap\` current (\`crtr doc edit roadmap\`) and \`crtr node yield\` now. Yielding ends this turn, and the child's completion then revives you fresh against your roadmap \u2014 let that clean revive absorb the result instead of this bloated context.`}s(ye,"childFollowUp");function ge(e,r){throw B(e)||z(e),new t({error:"node_create_effect_unknown",message:`Node creation did not receive an acknowledgement after automatic recovery with request key ${r}; its effect is unknown.`,next:"Do not create a replacement node until the daemon is reachable and this request can be recovered."},we.NETWORK)}s(ge,"createTransportFailure");function ve(){return[{kind:"stdin",name:"prompt",required:!1,constraint:"First user message."},{kind:"flag",name:"kind",type:"string",required:!1,constraint:"Persona kind. Defaults to the profile's default kind; `general` when the profile has none. The <kinds> list below names every top-level installable kind."},{kind:"flag",name:"mode",type:"enum",choices:["base","orchestrator"],required:!1,default:"base",constraint:"Persona mode. base for one hands-on unit; orchestrator when the unit itself needs decomposition across children. When you hold several parallel units of one kind, spawn ONE orchestrator child of that kind to own the fan-out rather than spawning the units yourself \u2014 unless you are already an orchestrator of that kind, whose job is exactly that fan-out."},{kind:"flag",name:"cwd",type:"path",required:!1,constraint:"Pin the node to this directory. Without --worktree, defaults to the spawner\u2019s directory for a managed child and the invocation directory for a root. With --worktree, selects the repository used for creation, defaulting to the invocation directory; the child runs in the new checkout."},{kind:"flag",name:"name",type:"string",required:!1,constraint:"Display name."},{kind:"flag",name:"parent",type:"string",required:!1,constraint:"Parent node id. Defaults to the calling node."},{kind:"flag",name:"node-id",type:"string",required:!1,constraint:"Exact id for the new node; lowercase letters, digits, and hyphens only, at most 128 characters. Rejected if already present."},{kind:"flag",name:"root",type:"bool",required:!1,constraint:"Spawn an independent root with no parent or subscription. Mutually exclusive with --worktree."},{kind:"flag",name:"resident",type:"bool",required:!1,constraint:"Birth the node as resident, a conversation partner for a person rather than a worker. Omit unless the user explicitly asks for a node they can talk with back and forth.",focusedHelp:{whenToUse:"Pass it ONLY when the user explicitly asks for a node they can talk with back and forth. Never infer it from task size, from expecting the user to look at the node, or from wanting to follow up later. "+V,value:"Boolean. Roots default to resident, so with --root it changes nothing. Managed children default to terminal; for a managed child the command first refuses, explains the cost, and says how to confirm.",effects:[...J,"It ends by going dormant or by being closed."]}},{kind:"flag",name:"terminal",type:"bool",required:!1,constraint:"Birth the node as terminal: it finalizes when its work is done and leaves nothing wakeable behind. Only meaningful with --root, whose default is resident; managed children are already terminal. Pass it for bounded programmatic work no one will open a viewer on. Mutually exclusive with --resident."},{kind:"flag",name:"force",type:"bool",required:!1,default:!1,hidden:!0,constraint:"Confirm a resident managed child (--resident without --root) after the user explicitly asked for one."},{kind:"flag",name:"worktree",type:"string",required:!1,constraint:"Existing local base branch for this child\u2019s managed worktree. When invoking from a managed worktree, also pass --cwd pointing at the repository\u2019s primary checkout; keep --worktree set to the desired parent branch. Mutually exclusive with --root."},{kind:"flag",name:"fork-from",type:"string",required:!1,constraint:"Fork the new node from an existing node id, absolute session path, or partial pi session uuid."},{kind:"flag",name:"model",type:"string",required:!1,constraint:"Durable model override. Omit unless the task or governing guidance requires a specific model.",focusedHelp:{whenToUse:"Use only when the user, task, or governing agent guidance already requires a specific provider, model, capability tier, or family. Omit it for routine delegation: the selected persona kind and profile own normal model selection, and review personas may enforce a quality floor.",value:`Accepted forms: ${ae}. Concrete provider/id requests must be registered. Portable provider/tier, bare-tier, and family-alias requests resolve through the configured model ladders.`,effects:["The resolved concrete model is stored on the node and in its launch recipe.","A concrete provider/id runs exactly that model on every launch and revive. A portable provider/tier, bare tier, or family alias keeps its tier: when that model's provider is rate-limited or rejects its credential, the node moves to the next model in its route: another provider's model at the same tier first, then the configured fallback tier (strong by default).","A persona quality floor may raise a weaker request before its resolved model is stored."]}},{kind:"flag",name:"profile",type:"string",required:!1,constraint:"Profile override. Use only when the task needs different project purview, owned documents, or environment; otherwise omit for normal inheritance or selection.",focusedHelp:{whenToUse:"Use only when the work must run under a different profile because it needs that profile\u2019s project purview, owned documents, stored environment, or defaults. Do not use it merely to change the working directory, persona kind, model, or graph ownership; those have separate parameters.",value:"Pass a profile id or name from the <profiles> list below; a close-enough name resolves to the nearest profile and the choice is reported on stderr. Omit it inside a node to inherit the caller\u2019s profile; outside a node, omission runs normal cwd-based profile selection.",effects:["The selected profile id is stored on the node and supplies its profile-scoped config, documents, environment, and injected bearings.","It does not change the parent or subscription; --cwd separately pins the working directory."]}},{kind:"flag",name:"situational-context",type:"string",required:!1,constraint:"Hidden ambient context appended to injected bearings, never visible chat."},{kind:"flag",name:"no-kickoff",type:"bool",required:!1,hidden:!0,constraint:"With --root, start the broker and session idle without a first message or model turn. Mutually exclusive with a prompt and --mode orchestrator."},{kind:"flag",name:"scopes",type:"string",required:!1,constraint:"Comma-separated scope allow-list for the node and every descendant (they inherit it and cannot widen it), e.g. `crtr:llm,crtr:act,device:shell,device:messages_read`. A provider-group call (`crtr device messages send` needs `device:messages_send`) is refused with scope_missing before any request leaves the machine when the group is absent. Must be a subset of what you hold; `crtr:act` requires `crtr:llm`. Enforced on the broker route (the node's own `crtr` calls); on an unsandboxed host a same-UID process can bypass it by calling the daemon socket directly (crouter#146), so it guards against a mistaken call, not a hostile node. Keep the list short: it travels in a request header on every device call (crouter#147)."},{kind:"flag",name:"deadline",type:"string",required:!1,constraint:"Positive, representable wall-clock duration from spawn. Grammar: one or more positive integer-unit parts; units: s, m, h, d; adjacent parts are summed. Omit for no deadline."},{kind:"flag",name:"outcome-action",type:"string",required:!1,constraint:"Declared human-action name that receives the node outcome. Grammar: 1\u2013128 ASCII letters, digits, dots, underscores, or hyphens; starts with a letter or digit. Omit when no external delivery target is needed."},{kind:"flag",name:"outcome-payload",type:"string",required:!1,constraint:"JSON value, serialized at most 64 KiB, frozen and echoed to --outcome-action. Requires --outcome-action."},{kind:"flag",name:"output-schema",type:"string",required:!1,constraint:"Replace prose completion with a schema-constrained final result. Use only when its consumer requires fixed fields.",focusedHelp:{whenToUse:"Use only when the node\u2019s consumer needs a machine-checkable final object with fixed fields. Omit it for ordinary delegation or when a prose report is enough; structured output replaces the completion protocol, and an over-constrained schema can force retries.",value:`Pass the JSON Schema the result must satisfy. ${re} ${ne}`,effects:["The node must answer with `crtr push result` and cannot finish until the result is accepted; a plain `crtr push final` is blocked while the request is pending.",K,"The managed parent wakes through its existing subscription when the final report arrives; an independent root has no subscriber to wake.","An accepted result, or a decline, removes the request and terminates the node."]}}]}s(ve,"nodeNewParams");function be(){return[{name:"node_id",type:"string",required:!0,constraint:"New node id."},{name:"name",type:"string",required:!0,constraint:"Display name."},{name:"frozen_at",type:"string",required:!1,constraint:"Present when a managed child exists but capacity deferred its broker start."},...W()?[{name:"window",type:"string",required:!1,constraint:"tmux window id when a viewer opens."},{name:"session",type:"string",required:!1,constraint:"tmux session when a viewer opens."}]:[],{name:"follow_up",type:"string",required:!0,constraint:"Managed child: continue unrelated work or stop; its final report wakes you. Root: hand it off; no report wakes you."}]}s(be,"nodeNewOutput");function _e(){return["Creates nodes/<id>/ in the canvas home, indexes the node in canvas.db, and starts its detached broker engine.","A managed child creates an active parent subscription; its pushes wake the parent. --root creates an independent node with spawned_by provenance and no parent subscription.","--worktree creates a managed worktree at ~/.crouter/canvas/worktrees/<node-id>/ on a new crtr/<node-id> branch.",K,"--deadline persists a wall-clock deadline from spawn; expiry cancels the node and records a failure outcome with reason deadline_exceeded.","--outcome-action registers one resolved local human-action target. When the node settles, crouter retries delivery of its outcome document until the target accepts it or permanently rejects it; --outcome-payload is frozen and echoed in that document.",...W()?["--root opens a viewer for the new node in the current tmux session."]:[]]}s(_e,"nodeNewEffects");async function xe(e){oe("crtr:act","crtr node new");const r=e.prompt??"",o=e.noKickoff===!0;if(!o&&r.trim()==="")throw new t({error:"empty_prompt",message:"a prompt is required (stdin or positional)",next:"Pipe a task on stdin or pass it as an argument, or pass --no-kickoff to spawn an idle node with none."});if(o&&r.trim()!=="")throw new t({error:"no_kickoff_with_prompt",message:"--no-kickoff cannot be combined with a prompt",field:"no-kickoff",next:"Drop --no-kickoff, or drop the prompt."});const d=e.kind,P=e.mode??"base",p=e.cwd?.trim(),l=p!==void 0&&p!==""?pe(p):void 0,E=e.name,Y=e.parent,i=e.root===!0,w=e.resident===!0,D=e.terminal===!0;if(w&&D)throw new t({error:"lifecycle_conflict",message:"--resident and --terminal cannot both be passed",field:"terminal",next:"Pass the one birth lifecycle you want, or neither to take the default (resident for --root, terminal for a managed child)."});if(w&&!i&&e.force!==!0)throw new t({error:"resident_child_requires_force",message:`--resident on a managed child makes it a conversation partner for a person, not a worker that reports back. ${J.join(" ")}`,field:"resident",next:`If the user did not explicitly ask for a node they can talk with back and forth, drop --resident; a terminal child's final report wakes you. ${V} If the user did explicitly ask for one, re-run with --force.`});const k=e.worktree;if(k!==void 0&&k.trim()==="")throw new t({error:"worktree_base_required",message:"--worktree requires a base branch",field:"worktree",next:"Pass an existing local branch that landing can fast-forward."});const y=k?.trim(),C=e.forkFrom,g=e.model?.trim();if(g==="")throw new t({error:"empty_spec",message:"a model spec is required",field:"model",next:`Run \`crtr node new --model -h\` and read the focused contract. ${se}`});const A=e.profile,u=A===void 0?void 0:(await ue(A)).id,v=e.situationalContext?.trim(),I=v!==void 0&&v!==""?v:void 0,U=ie(e.outputSchema),R=U!==null?JSON.stringify(U):null,h=e.deadline;if(h!==void 0){const n=de(h),c=n===null?Number.NaN:new Date(Date.now()+n).getTime();if(n===null||!Number.isFinite(n)||n<=0||!Number.isFinite(c))throw new t({error:"invalid_deadline",message:"--deadline must be a positive representable duration",field:"deadline",next:"Pass positive integer-unit parts using s, m, h, or d."})}const b=e.outcomeAction,_=e.outcomePayload;if(_!==void 0&&b===void 0)throw new t({error:"outcome_payload_requires_action",message:"--outcome-payload requires --outcome-action",field:"outcome-payload",next:"Pass the declared delivery action with --outcome-action."});let x;if(_!==void 0)try{x=JSON.parse(_)}catch{throw new t({error:"invalid_outcome_payload",message:"--outcome-payload must be valid JSON",field:"outcome-payload",next:"Pass one valid JSON value."})}const M=e.scopes,f=M===void 0?void 0:M.split(",").map(n=>n.trim()).filter(n=>n!=="");if(f!==void 0&&f.length===0)throw new t({error:"empty_scopes",message:"--scopes names no scope",field:"scopes",next:"Pass a comma-separated list such as crtr:llm,crtr:act, or omit --scopes to inherit."});const q=e.nodeId?.trim();if(i&&y!==void 0)throw new t({error:"worktree_root_conflict",message:"--worktree is mutually exclusive with --root",field:"worktree",next:"Drop either --root or --worktree."});if(o&&!i)throw new t({error:"no_kickoff_requires_root",message:"--no-kickoff is only valid with --root",field:"no-kickoff",next:"Add --root, or drop --no-kickoff and provide a prompt."});if(o&&P==="orchestrator")throw new t({error:"no_kickoff_orchestrator_unsupported",message:"--no-kickoff cannot be combined with --mode orchestrator",field:"no-kickoff",next:"Drop --no-kickoff and provide a prompt, or spawn in base mode."});const m=Q();if(d!==void 0&&m===void 0){const n=Object.keys(ee(l??process.cwd(),u??(Z()||null)).kinds),c=(await S().listKinds({profile:u})).kinds.map(G=>G.kind),H=[...new Set([...n,...c])];if(!H.includes(d))throw new t({error:"unknown_kind",message:`unknown kind: ${d}`,field:"kind",received:d,next:`Valid kinds: ${H.sort().join(", ")}.`})}const j=Y??m;O("node_new.create_start",{root:i});const L=me(),$={...d!==void 0?{kind:d}:{},mode:P,cwd:process.cwd(),...l!==void 0&&l!==""?{pin_cwd:l}:{},...E!==void 0?{name:E}:{},prompt:r,...i?{root:!0}:{parent:j??null},...m!==void 0?{creator:m}:{},...w?{root_lifecycle:"resident"}:{},...D?{root_lifecycle:"terminal"}:{},...y!==void 0?{worktree:y}:{},...C!==void 0?{fork_from:C}:{},...g!==void 0?{model:g}:{},...u!==void 0?{profile:u}:{},...I!==void 0?{situational_context:I}:{},...o?{no_kickoff:!0}:{},...R!==null?{output_schema:R}:{},...f!==void 0?{scopes:f}:{},...h!==void 0?{deadline:h}:{},...b!==void 0?{outcome_delivery:{action:b,...x===void 0?{}:{payload:x}}}:{},...q!==void 0&&q!==""?{node_id:q}:{},...i?{prefer_warm:!0}:{},request_key:L};let a;try{a=await S().createNode($)}catch(n){B(n)||z(n);try{a=await S().createNode($)}catch(c){ge(c,L)}}O("node_new.node_created",{node:a.node_id});let N={};i&&(N=fe(a.node_id,a.cwd,a.name)),i&&O("node_new.viewer_window_opened");const F=!i&&a.frozen_at!==null;return{node_id:a.node_id,name:a.name,...F?{frozen_at:a.frozen_at}:{},window:N.window,session:N.session,follow_up:i?o?"Independent root spawned idle. No kickoff turn ran; hand it off or attach and prompt it. No report wakes you.":"Independent root spawned. You are not subscribed, so its finish does not wake you; hand it off and move on.":F?"Child row exists and is frozen: its broker has not started yet. A node whose environment is remote (an imported Mac, a Blaxel sandbox) is always born frozen until the cloud launches it; a local node waits here because capacity (broker slots or the app's memory) is full and launches when it frees. Its final report wakes you then.":await ye(j)}}s(xe,"runNodeCreation");const ze=te({name:"new",description:"create and start a node immediately",whenToUse:"a unit of work is genuinely separable from what you are doing: a bounded subtask you would otherwise grind out inline, several independent units worth running in parallel (usually via one orchestrator child of the matching kind rather than a flat fan-out from you), a scouting pass over unfamiliar code, a change that wants its own git worktree, or an answer you need in a fixed shape rather than as prose",tier:"important",help:{name:"node new",summary:"create a node immediately and start its detached broker",guide:"The prompt is the child\u2019s entire brief: it wakes with this prompt, its persona, and ambient bearings \u2014 none of your conversation carries over. State the outcome and constraints. Pass an implementation plan only when it is already settled or necessary to preserve an approved decision; otherwise, let the child investigate and choose how. Give the reason along with the request: the larger goal this serves and what the child's output enables, so the child resolves ambiguity toward your intent instead of guessing. Point at every document the task depends on (a spec, an explore map, an earlier child's findings) as `[[<node-id>/<name>]]`, or `[[name]]` for a repo, profile or user document; the child reads each with `crtr canvas read` and receives nothing the prompt does not point at. Name every file or directory as an absolute host path, never `~`-relative: the child's `~` is its own HOME, not yours, and a hook cwd outside its mounts (e.g. `/tmp`) is refused. When the report must carry something specific\u2014findings inline, or pointers to documents it wrote\u2014say so in the prompt.",params:ve(),output:be(),outputKind:"object",effects:_e()},helpState:{leaf:ce,flags:{profile:le}},run:s(e=>xe(e),"run"),render:s(e=>{const r=e.window?` in window ${e.window}`:"",o=[`Spawned "${e.name}" (${e.node_id})${r}.`];return e.session&&o.push(`- session: ${e.session}`),o.push("",String(e.follow_up)),o.join(`
2
+ `)},"render")});export{ye as childFollowUp,ze as nodeNew};
@@ -1,12 +1,12 @@
1
- var A=Object.defineProperty;var h=(n,e)=>A(n,"name",{value:e,configurable:!0});import{defineBranch as P,defineLeaf as $}from"../../core/command.js";import{InputError as k}from"../../core/io.js";import{requireScope as I}from"../../core/errors.js";import{isPidAlive as L}from"../../core/canvas/pid.js";import{fullName as x}from"../../core/canvas/labels.js";import{fuzzyMatch as F}from"../../core/tui/fuzzy.js";import{nodeSnapshotLeaf as O}from"../node-snapshot.js";import{nodeTranscriptLeaf as C}from"../node-transcript.js";import{nodeContextLeaf as U}from"../node-context.js";import{ApiError as E}from"../../api/index.js";import{describeVendorLimit as D}from"../../core/provider-failure.js";import{cliClient as _,cliCanvasSource as S,rethrowAsCliError as w}from"../api-client.js";import{RemoteCanvasSource as q}from"../../core/canvas/remote-canvas-source.js";import{kindsStateBlock as z,profilesStateBlock as M,resolveProfileViaDaemon as B}from"../profile/daemon-profiles.js";import{focusViewer as V,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. Against the default account 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 default account 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([z(),M()])).join(`
2
- `),"leaf")},run:h(async n=>{const e=h(c=>{const b=n[c];return b!==void 0&&b!==""?b.split(",").map(v=>v.trim()).filter(v=>v!==""):void 0},"csv"),o=e("status"),s=e("kind"),p=e("mode"),i=e("lifecycle"),f=n.profile,r=n.name,l=n.cwd,a=n.under,u=S({canvasName:n.canvas}),d=u instanceof q?f:f===void 0?void 0:(await B(f)).id,m=a!==void 0&&a!=="";if(m&&await u.getNode(a).catch(w)===null)throw new k({error:"not_found",message:`no node: ${a}`,next:"List nodes with `crtr node inspect list`, then pass a real id to --under."});return{nodes:(await u.listNodes({...o!==void 0?{status:o}:{},...m?{under:a}:{}}).catch(w)).filter(c=>!(s!==void 0&&!s.includes(c.kind)||p!==void 0&&!p.includes(c.mode)||i!==void 0&&!i.includes(c.lifecycle)||d!==void 0&&c.profile_id!==d||l!==void 0&&l!==""&&c.cwd!==l)).map(c=>({...c,name:x(c)})).filter(c=>r===void 0||r===""||F(r,c.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?x(o):"(missing)",kind:o?.kind??"?",status:o?o.intent?`${o.status}/${o.intent}`:o.status:"?",active:e.active}}h(N,"enrichNeighbor");const G=$({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 default account 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 p=await s.getNode(e).catch(t=>w(t,"List nodes with `crtr node inspect list`."));if(p===null)throw new k({error:"not_found",message:`no node: ${e}`,next:"List nodes with `crtr node inspect list`."});const i=p,f=_(),r=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))),a=(await f.listCrons({created_by:e}).catch(w)).filter(t=>t.created_by===e).length,u={context_dir:i.paths.context_dir,...i.pi_session_file!==void 0?{session_file:i.pi_session_file}:{}},d=[];d.push(`List the documents it owns (reports, plans, notes): \`crtr canvas list --owner ${e}\`.`),d.push(`Browse its context dir (and its subscriptions') in nvim: \`crtr node inspect context ${e}\`.`),u.session_file&&d.push(`Read the raw conversation transcript: ${u.session_file}`),d.push(`On-disk context dir (ls/read directly): ${u.context_dir}`),a>0&&d.push(`It created ${a} pending cron(s): \`crtr cron list\`.`),r.length>0&&d.push(`Drill into a child/report: \`crtr node inspect show <node_id>\` (${r.map(t=>t.node_id).join(", ")}).`),d.push(`Full machine dump (system prompt + all telemetry): \`crtr --json node inspect show ${e}\`.`);const m={node:i,fault:i.fault??null,reports:r,managers:l,pending_crons:a,paths:u,follow_up:d.join(`
3
- `)};return(i.runner==="blaxel"||i.profile_id!==null&&await f.getProfileEnvironment(i.profile_id).then(()=>!0,t=>t instanceof E&&(t.status===400||t.status===404)?!1:w(t)))&&T.add(m),m},"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)":e.runner==="machine"?"on a Mac (liveness not checked locally)":T.has(n)?"in a cloud sandbox (liveness not checked locally)":L(s)?"alive":"dead",f=e.intent?`/${String(e.intent)}`:"",r=n.fault,l=[];l.push(`# ${x(e)} (${o})`);const a=[`- kind/mode/lifecycle: ${e.kind} / ${e.mode} / ${e.lifecycle}`,`- status: ${e.status}${f}`,...r==null?[]:[`- fault: ${String(r.kind)} / ${String(r.retry?.disposition)} since ${String(r.since)}${r.retry?.nextAt===void 0?"":`. Next router probe: ${r.retry.nextAt}.`}${D(r.providerError)}`],`- 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}`],u=e.machine;u&&a.push(`- machine: ${u.name??u.id}`),e.parent&&a.push(`- parent: ${e.parent}`),a.push(`- creator: ${e.creator??"an external process"}`),e.waiting_for&&a.push(`- waiting for message: ${e.waiting_for}`),l.push(a.join(`
4
- `));const d=h((m,g)=>{if(g.length===0)return`${m}: none`;const t=["node_id","name","kind","status","active"],y=`| ${t.join(" | ")} |`,c=`| ${t.map(()=>"---").join(" | ")} |`,b=g.map(v=>`| ${t.map(R=>String(v[R]??"").replace(/\|/g,"\\|").replace(/\n/g," ")).join(" | ")} |`).join(`
5
- `);return`${g.length} ${m}:
1
+ var A=Object.defineProperty;var h=(n,e)=>A(n,"name",{value:e,configurable:!0});import{contextDir as P}from"../../core/canvas/paths.js";import{defineBranch as I,defineLeaf as $}from"../../core/command.js";import{InputError as k}from"../../core/io.js";import{requireScope as L}from"../../core/errors.js";import{isPidAlive as F}from"../../core/canvas/pid.js";import{fullName as x}from"../../core/canvas/labels.js";import{fuzzyMatch as O}from"../../core/tui/fuzzy.js";import{nodeSnapshotLeaf as C}from"../node-snapshot.js";import{nodeTranscriptLeaf as U}from"../node-transcript.js";import{nodeContextLeaf as D}from"../node-context.js";import{ApiError as E}from"../../api/index.js";import{describeVendorLimit as z}from"../../core/provider-failure.js";import{cliClient as _,cliCanvasSource as S,rethrowAsCliError as w}from"../api-client.js";import{RemoteCanvasSource as q}from"../../core/canvas/remote-canvas-source.js";import{kindsStateBlock as M,profilesStateBlock as B,resolveProfileViaDaemon as V}from"../profile/daemon-profiles.js";import{focusViewer as W,nodeInPane as K}from"../surface/node/placement.js";const G=$({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. Against the default account 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 default account 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([M(),B()])).join(`
2
+ `),"leaf")},run:h(async n=>{const e=h(c=>{const b=n[c];return b!==void 0&&b!==""?b.split(",").map(v=>v.trim()).filter(v=>v!==""):void 0},"csv"),o=e("status"),s=e("kind"),p=e("mode"),i=e("lifecycle"),m=n.profile,r=n.name,l=n.cwd,a=n.under,u=S({canvasName:n.canvas}),d=u instanceof q?m:m===void 0?void 0:(await V(m)).id,f=a!==void 0&&a!=="";if(f&&await u.getNode(a).catch(w)===null)throw new k({error:"not_found",message:`no node: ${a}`,next:"List nodes with `crtr node inspect list`, then pass a real id to --under."});return{nodes:(await u.listNodes({...o!==void 0?{status:o}:{},...f?{under:a}:{}}).catch(w)).filter(c=>!(s!==void 0&&!s.includes(c.kind)||p!==void 0&&!p.includes(c.mode)||i!==void 0&&!i.includes(c.lifecycle)||d!==void 0&&c.profile_id!==d||l!==void 0&&l!==""&&c.cwd!==l)).map(c=>({...c,name:x(c)})).filter(c=>r===void 0||r===""||O(r,c.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?x(o):"(missing)",kind:o?.kind??"?",status:o?o.intent?`${o.status}/${o.intent}`:o.status:"?",active:e.active}}h(N,"enrichNeighbor");const H=$({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 default account 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 p=await s.getNode(e).catch(t=>w(t,"List nodes with `crtr node inspect list`."));if(p===null)throw new k({error:"not_found",message:`no node: ${e}`,next:"List nodes with `crtr node inspect list`."});const i=p,m=_(),r=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))),a=(await m.listCrons({created_by:e}).catch(w)).filter(t=>t.created_by===e).length,u={context_dir:P(e,i.grantee),...i.pi_session_file!==void 0?{session_file:i.pi_session_file}:{}},d=[];d.push(`List the documents it owns (reports, plans, notes): \`crtr canvas list --owner ${e}\`.`),d.push(`Browse its context dir (and its subscriptions') in nvim: \`crtr node inspect context ${e}\`.`),u.session_file&&d.push(`Read the raw conversation transcript: ${u.session_file}`),d.push(`On-disk context dir (ls/read directly): ${u.context_dir}`),a>0&&d.push(`It created ${a} pending cron(s): \`crtr cron list\`.`),r.length>0&&d.push(`Drill into a child/report: \`crtr node inspect show <node_id>\` (${r.map(t=>t.node_id).join(", ")}).`),d.push(`Full machine dump (system prompt + all telemetry): \`crtr --json node inspect show ${e}\`.`);const f={node:i,fault:i.fault??null,reports:r,managers:l,pending_crons:a,paths:u,follow_up:d.join(`
3
+ `)};return(i.runner==="blaxel"||i.profile_id!==null&&await m.getProfileEnvironment(i.profile_id).then(()=>!0,t=>t instanceof E&&(t.status===400||t.status===404)?!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)":e.runner==="machine"?"on a Mac (liveness not checked locally)":T.has(n)?"in a cloud sandbox (liveness not checked locally)":F(s)?"alive":"dead",m=e.intent?`/${String(e.intent)}`:"",r=n.fault,l=[];l.push(`# ${x(e)} (${o})`);const a=[`- kind/mode/lifecycle: ${e.kind} / ${e.mode} / ${e.lifecycle}`,`- status: ${e.status}${m}`,...r==null?[]:[`- fault: ${String(r.kind)} / ${String(r.retry?.disposition)} since ${String(r.since)}${r.retry?.nextAt===void 0?"":`. Next router probe: ${r.retry.nextAt}.`}${z(r.providerError)}`],`- 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}`],u=e.machine;u&&a.push(`- machine: ${u.name??u.id}`),e.parent&&a.push(`- parent: ${e.parent}`),a.push(`- creator: ${e.creator??"an external process"}`),e.waiting_for&&a.push(`- waiting for message: ${e.waiting_for}`),l.push(a.join(`
4
+ `));const d=h((f,g)=>{if(g.length===0)return`${f}: none`;const t=["node_id","name","kind","status","active"],y=`| ${t.join(" | ")} |`,c=`| ${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
7
  ${y}
8
8
  ${c}
9
9
  ${b}`},"table");return l.push(d("reports (down \u2014 subscriptions, usually children)",n.reports)),l.push(d("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")}),le=$({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=>{I("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 p=await _().forkNode(s).catch(w),i=await V(p.node_id,{cwd:p.cwd,name:p.name,...e!==void 0?{pane:e}:{},newPane:!0});return{node_id:p.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")}),ue=P({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,G,O,C,U]});export{le as nodeFork,ue as nodeInspect};
12
+ `)},"render")}),pe=$({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=>{L("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=K(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 p=await _().forkNode(s).catch(w),i=await W(p.node_id,{cwd:p.cwd,name:p.name,...e!==void 0?{pane:e}:{},newPane:!0});return{node_id:p.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")}),he=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:[G,H,C,U,D]});export{pe as nodeFork,he as nodeInspect};
@@ -1,4 +1,4 @@
1
- var B=Object.defineProperty;var u=(e,t)=>B(e,"name",{value:t,configurable:!0});import{readFileSync as W}from"node:fs";import{envNodeId as D}from"../../shared/env.js";import{defineBranch as H,defineLeaf as E}from"../../core/command.js";import{InputError as r}from"../../core/io.js";import{cliClient as w,getNodeOrNull as K,rethrowAsCliError as y}from"../api-client.js";import{DEFAULT_BASH_NICENESS as F,MAX_BASH_NICENESS as N,writeBashNiceness as X}from"../../core/bash-jobs.js";import{nodeReviveLeaf as Y}from"../node-lifecycle-revive.js";import{kindsStateBlock as C}from"../profile/daemon-profiles.js";import{MODEL_SPEC_FORMS as J}from"../../core/runtime/model-selection.js";import{closePane as z,paneExists as G,respawnPaneSync as V,viewerEnv as Q,viewerPaneOf as Z,nodeInPane as I}from"../surface/node/placement.js";const ee=E({name:"recycle",description:"finish the agent in your pane + recycle it into a fresh root",whenToUse:"you are at an agent's pane and done with it: finish it cleanly and recycle the pane in one move \u2014 push its last message as a final report to everyone waiting on it, mark it done, then boot a fresh crtr root in the same pane to keep working. The hands-on way to end an agent and immediately start over in place. Use `node lifecycle demote` instead to put it on a finishing track IN PLACE (flip terminal, keep it running) without ending it now, `node lifecycle close` to tear a node and its subtree down WITHOUT finishing (no report, revivable), and `push final` when the agent should finish ITSELF from inside its own turn",help:{name:"node lifecycle recycle",summary:"finish the agent in your current pane and recycle the pane \u2014 push its last message as a final report to everyone waiting on it, mark it done, then boot a fresh crtr root in the same pane",params:[{kind:"flag",name:"node",type:"string",required:!1,constraint:"Node to finish. Defaults to the node occupying --pane (or your current pane)."},{kind:"flag",name:"pane",type:"string",required:!1,constraint:"tmux pane id to recycle. Defaults to $TMUX_PANE / your current pane. The Alt+C menu passes this for you."}],output:[{name:"recycled",type:"boolean",required:!0,constraint:"True when the pane was recycled into a fresh root."},{name:"node_id",type:"string",required:!1,constraint:"The finished node."},{name:"new_root",type:"string",required:!1,constraint:"The fresh root node booted into the pane."}],outputKind:"object",effects:["Pushes a final report from the node (fans out to all subscribers) and marks it done.","Kills the agent's pi and respawns a fresh resident root in the same tmux pane."]},run:u(async e=>{const t=e.pane??process.env.TMUX_PANE;let n=e.node;if((n===void 0||n==="")&&(n=I(t)),n===void 0||n==="")throw new r({error:"no_node",message:"no node found in this pane to finish",next:"Pass --node <id>, or run from inside the agent's pane."});const i=await w().getNode(n).catch(f=>y(f,"List nodes with `crtr node inspect list`.")),o=(await w().recycleNode(n).catch(y)).node_id;let h=!1;return t!==void 0&&t!==""&&(h=V({pane:t,cwd:i.cwd,env:Q(),command:"crtr"})),{recycled:h,node_id:n,new_root:o}},"run"),render:u(e=>{if(e.recycled!==!0)return e.new_root?`Finished ${e.node_id} and spawned a fresh broker root (${e.new_root}), but its viewer did not attach \u2014 the new broker did not come up. Re-focus the root to view it.`:`Recycle failed for ${e.node_id??"?"} \u2014 not in tmux, or no agent in this pane.`;const t=[`Recycled the pane \u2014 finished ${e.node_id}.`];return e.new_root&&t.push(`- new root: ${e.new_root}`),t.join(`
2
- `)},"render")}),ne=E({name:"close",description:"close a node + cascade-cancel its exclusive subtree",whenToUse:"you want to tear a node down WITHOUT finishing it, cascade-cancelling every descendant it exclusively owns: abandoning a line of work, killing a stuck or wrong-turn subtree, clearing a branch you no longer need. A node that never produced substantive assistant output is deleted and cannot be revived; streaming nodes and nodes with an open managed worktree are retained. Other closed nodes keep their pi session and can be revived later (`node lifecycle revive`). Use `node lifecycle recycle` instead to FINISH the agent in your pane with a final report, and `push final` when a worker should end its own work normally (Alt+C \u2192 x)",help:{name:"node lifecycle close",summary:"close a node and cascade-cancel its subtree \u2014 kill its tmux window plus those of every descendant it EXCLUSIVELY owns (down the subscription spine \u2014 the watches each manager holds on its children), mark retained nodes canceled, and leave them a notice they read on resume. A descendant still subscribed to by a manager outside the subtree is left running. A node that never produced substantive assistant output is deleted and cannot be revived; streaming nodes and nodes with an open managed worktree are retained. Other closed nodes keep their pi session and can be revived later (`crtr node lifecycle revive`)",params:[{kind:"flag",name:"node",type:"string",required:!1,constraint:"Node to close. Defaults to the node occupying --pane (or your current pane)."},{kind:"flag",name:"pane",type:"string",required:!1,constraint:"tmux pane id whose node to close. Defaults to $TMUX_PANE / your current pane. The Alt+C menu passes this for you."}],output:[{name:"node_id",type:"string",required:!1,constraint:"The node that was closed \u2014 the cascade root."},{name:"count",type:"number",required:!1,constraint:"How many nodes were closed (root + cascaded descendants)."},{name:"closed_ids",type:"string[]",required:!1,constraint:"All closed node ids, kill order (leaves first, root last)."},{name:"spared",type:"string[]",required:!1,constraint:"Descendants left alive because a manager outside the subtree still subscribes to them."}],outputKind:"object",effects:["Marks retained nodes and their exclusive descendants `canceled` and clears intent (the daemon never revives a canceled node).","Deletes a non-streaming node with no substantive assistant output unless it has an open managed worktree; a deleted node cannot be revived.","Kills each closed node's tmux window; retained nodes keep their pi sessions and canvas edges for a later revive.","Appends a cancellation notice to each retained node's inbox, surfaced on its next resume."]},run:u(async e=>{const t=e.pane??process.env.TMUX_PANE;let n=e.node;if((n===void 0||n==="")&&(n=I(t)),n===void 0||n==="")throw new r({error:"no_node",message:"no node found in this pane to close",next:"Pass --node <id>, or run from inside the agent's pane."});const i=await w().closeNode(n,process.ppid>0?{caller_pid:process.ppid}:{}).catch(d=>y(d,"List nodes with `crtr node inspect list`."));return{node_id:i.root,count:i.closed.length,closed_ids:i.closed,spared:i.spared}},"run"),render:u(e=>{const t=e.spared?.length??0;return`Closed ${e.node_id} and its exclusive subtree \u2014 ${e.count} node(s) closed${t>0?`, ${t} spared (still managed from outside the subtree)`:""}.`},"render")}),j="Model change first: a running broker, including one still starting right after `node new`, switches over its socket; a dormant node persists the durable model override and launch recipe for its next revive.",pe=E({name:"config",description:"reconfigure a node's settings headlessly \u2014 model, lifecycle (terminal/resident), kind, mode, name; repair a missing cwd",whenToUse:"you want to reconfigure a node's settings headlessly after spawn \u2014 swap its model/provider, flip it terminal\u2194resident (interactable), respecialize its kind, switch base\u2194orchestrator mode, or rename it \u2014 without opening its viewer. It also repairs a dormant node whose recorded cwd is gone, starting its next revive in a fresh conversation. The durable attribute setter; reuses the same recipes a revive reads. Use `node promote` for the opinionated self-promotion path, and `node lifecycle` for teardown actions (recycle/close/demote).",help:{name:"node config",summary:"reconfigure a node's settings headlessly \u2014 model, lifecycle, kind, mode, name; repair a missing cwd",params:[{kind:"flag",name:"node",type:"string",required:!1,repeatable:!0,constraint:"Target node id. Defaults to the node in --pane, else CRTR_NODE_ID. Repeat it, or use --nodes-from, to apply a --profile or --cwd change to many nodes; a bulk run reports each node and keeps going past a failure."},{kind:"flag",name:"nodes-from",type:"string",required:!1,constraint:"File of node ids, one per line (blank lines and #-comments ignored), or `-` for stdin. Bulk form of --node; only with --profile or --cwd."},{kind:"flag",name:"pane",type:"string",required:!1,constraint:"tmux pane id to resolve the node from. Defaults to $TMUX_PANE."},{kind:"flag",name:"model",type:"string",required:!1,constraint:"Durable model change. Omit unless the task or governing guidance requires a different model.",focusedHelp:{whenToUse:"Use only when intentionally changing this node\u2019s durable model because the user, task, or governing agent guidance requires a specific provider, model, capability tier, or family. Omit it to keep the current model; do not use it merely to inspect available models or experiment with a live node.",value:`Accepted durable forms: ${J}. A live broker also accepts a free-text substring matched against its loaded model registry; a dormant node cannot resolve a substring and requires a durable form.`,effects:[j,"A concrete provider/id runs exactly that model on every launch and revive. A portable provider/tier, bare tier, or family alias keeps its tier: when that model's provider is rate-limited or rejects its credential, the node moves to the next model in its route: another provider's model at the same tier first, then the configured fallback tier (strong by default)."]}},{kind:"flag",name:"lifecycle",type:"enum",choices:["terminal","resident"],required:!1,constraint:"Set lifecycle headlessly without closing the viewer. terminal owes a final and reaps when done; resident stays interactable while attached or awaiting something live."},{kind:"flag",name:"kind",type:"string",required:!1,constraint:"Persona kind. The <kinds> list below names every top-level installable kind and when to use each; a registered sub-kind is valid too by exact path but not listed here."},{kind:"flag",name:"mode",type:"enum",choices:["base","orchestrator"],required:!1,constraint:"Set persona mode headlessly. base is hands-on; orchestrator holds a roadmap and delegates. orchestrator creates your document `roadmap` if absent."},{kind:"flag",name:"name",type:"string",required:!1,constraint:"Rename the node; if the node has a live window, also rename that viewer window."},{kind:"flag",name:"nice",type:"int",required:!1,constraint:`Scheduler niceness every command this node's bash tool starts at, 0\u2013${N} (default ${F}). ${F} keeps the node's builds and test suites below the daemon, the brokers, the viewers, and the person's own shell; 0 lets them compete on equal terms with everything else on the host; ${N} makes them yield to it. Applies to the node's very next command, foreground and background alike.`},{kind:"flag",name:"listen",type:"string",required:!1,constraint:`The node's default listening configuration, as JSON mapping an event level ("1".."10") to how events at or above it reach the node: interrupt, steer, after-turn, or next-turn (e.g. '{"3":"next-turn"}' \u2014 events of level 3+ wait for its next turn and never wake it). Applies to every watch with no configuration of its own. Pass \`null\` to reset to the global default.`},{kind:"flag",name:"cwd",type:"string",required:!1,constraint:"Replacement launch directory (absolute, existing). Alone, or with --keep-session / --restart. Without --keep-session it is a repair: only a dormant, non-forked node with no open managed worktree whose recorded cwd is gone, and it clears the saved Pi session (next revive starts fresh). When the new path is the same directory as the recorded one (a symlink alias) it relocates and keeps the conversation automatically \u2014 see --keep-session."},{kind:"flag",name:"keep-session",type:"bool",required:!1,constraint:"With --cwd: assert the new path is the SAME directory as the recorded cwd and relocate WITHOUT clearing the Pi session. Needed only when the recorded path is already gone (e.g. the symlink was deleted); while it still exists the daemon verifies by realpath and refuses a different directory. Allowed for live, idle, dormant and finished nodes, forks included. Rewrites the recorded cwd and the cwd in the node's transcript header so a later resume finds it. Refused while the node owns an open managed worktree."},{kind:"flag",name:"rewrite-prefix",type:"string",required:!1,constraint:'Bulk cwd form, `OLD=NEW` (absolute paths): with several nodes, each node\'s recorded cwd that equals OLD or lies beneath it is relocated to the same place under NEW, keeping its session (as --keep-session); nodes whose cwd is elsewhere are reported as failed "not under OLD". Use instead of --cwd when the nodes sit in different subdirectories.'},{kind:"flag",name:"profile",type:"string",required:!1,constraint:"Reassign the node to this profile (id or exact name; must be an active profile of the node's app that defines the node's kind). Works for live, idle, dormant, finished and profile-less (detached) nodes. Used alone, or with --restart."},{kind:"flag",name:"restart",type:"bool",required:!1,constraint:"With --profile, or --cwd on a live node: after the change, SIGTERM the node's live broker so crtrd resumes it from the same transcript (continuing an interrupted turn) with the new profile/cwd. No effect on a node with no live broker."}],output:[{name:"node_id",type:"string",required:!1,constraint:"The reconfigured node, present for ordinary config changes."},{name:"model",type:"string",required:!1,constraint:"The resolved model, present only when --model changed it."},{name:"lifecycle",type:"string",required:!1,constraint:"The new lifecycle, present only when --lifecycle changed it."},{name:"kind",type:"string",required:!1,constraint:"The new kind, present only when --kind changed it."},{name:"mode",type:"string",required:!1,constraint:"The new mode, present only when --mode changed it."},{name:"name",type:"string",required:!1,constraint:"The new name, present only when --name changed it."},{name:"nice",type:"number",required:!1,constraint:"The new bash niceness, present only when --nice changed it."},{name:"listen",type:"object",required:!1,constraint:"The new default listening configuration (null = global default), present only when --listen changed it."},{name:"cwd",type:"string",required:!1,constraint:"The resolved replacement directory, present only after a cwd change."},{name:"session_kept",type:"boolean",required:!1,constraint:"With a cwd change: true when the node still has its Pi session bound (conversation preserved)."},{name:"profile",type:"string",required:!1,constraint:"The node's profile id after --profile."},{name:"bulk",type:"boolean",required:!1,constraint:"True for a multi-node run."},{name:"applied",type:"number",required:!1,constraint:"Bulk: nodes changed (or already in the requested state)."},{name:"failed",type:"number",required:!1,constraint:"Bulk: nodes that errored; the exit code is 1 when any did."},{name:"results",type:"array",required:!1,constraint:"Bulk: one {node_id, ok, error?} per node, in input order."}],outputKind:"object",effects:[j,"Kind, mode, and lifecycle changes rebuild the launch spec from the fresh node meta; setting mode to orchestrator creates your document `roadmap` if absent.","Name changes update the row and, when the node already has a live window, rename that viewer window to the new full name.","A cwd repair (gone recorded cwd, no --keep-session) writes only the lexically resolved cwd and clears saved Pi session pointers; the old transcript and durable node work remain untouched.","A session-keeping cwd relocation (--keep-session, or --cwd naming a symlink alias of the recorded directory) rewrites the recorded cwd and the cwd line in the header of each of the node's transcripts; the Pi session stays bound and the next revive resumes the same conversation. A LIVE broker keeps the old cwd string in its environment and tools until it restarts: it keeps working while the old path exists, so pass --restart (or revive it) BEFORE deleting an old symlink.","A profile reassignment rewrites the node's profile and rebuilds its launch recipe. Profile env, documents delivered at boot, purview and bearings are read at launch, so a LIVE broker keeps the old profile until it next restarts; --restart bounces it now. Dormant or finished nodes simply carry the new profile into their next revive. The node's deadlines and profile pause follow the new profile immediately.","A niceness change is stored with the node's own bash-job state, so it takes effect on the next command without a revive and survives one.","A listen change sets the node's default listening configuration; it never changes which watches it holds.","Every successful change publishes a `configured` event on the node (level 1) naming the changed settings, so its watchers can see it."]},helpState:{leaf:C},run:u(async e=>{const t=e.pane??process.env.TMUX_PANE,n=e.node,i=Array.isArray(n)?n:n===void 0?[]:[n],d=e.nodesFrom;if(d!==void 0){const a=d==="-"?W(0,"utf8"):W(d,"utf8");for(const A of a.split(`
3
- `)){const b=A.replace(/#.*/,"").trim();b!==""&&i.push(b)}}const o=e.profile,h=e.cwd,f=e.rewritePrefix;if(i.length>1||d!==void 0||f!==void 0){if(i.length===0)throw new r({error:"no_nodes",message:"bulk config needs at least one node",next:"Pass --node ID (repeatable) or --nodes-from FILE|-."});if(o===void 0&&h===void 0&&f===void 0)throw new r({error:"bulk_unsupported",message:"several nodes are accepted only with --profile, --cwd or --rewrite-prefix",next:"Pass --profile <profile>, --cwd <dir> or --rewrite-prefix OLD=NEW with the node list."});let a;if(f!==void 0){const p=f.indexOf("="),c=p<0?"":f.slice(0,p).replace(/\/+$/,""),m=p<0?"":f.slice(p+1).replace(/\/+$/,"");if(!c.startsWith("/")||!m.startsWith("/"))throw new r({error:"bad_rewrite_prefix",message:`--rewrite-prefix must be OLD=NEW with absolute paths: ${f}`,field:"rewrite-prefix",next:"Pass e.g. --rewrite-prefix /Users/me/Code/northlight=/Users/me/Code/northlight-systems."});a=[c,m]}const A=w(),b=[];for(const p of[...new Set(i)])try{const c=o!==void 0?{profile:o}:{cwd:h??""};if(a!==void 0){const m=(await A.getNode(p)).cwd;if(m!==a[0]&&!m.startsWith(`${a[0]}/`))throw new Error(`cwd ${m} is not under ${a[0]}`);c.cwd=a[1]+m.slice(a[0].length),c.keep_session=!0}e.keepSession===!0&&(c.keep_session=!0),e.restart===!0&&(c.restart=!0),await A.patchConfig(p,c),b.push({node_id:p,ok:!0})}catch(c){let m=c instanceof Error?c.message:String(c);try{y(c)}catch(U){U instanceof Error&&(m=U.message)}b.push({node_id:p,ok:!1,error:m})}const P=b.filter(p=>!p.ok).length;return P>0&&(process.exitCode=1),{bulk:!0,applied:b.length-P,failed:P,results:b}}const _=await M({...e,node:i[0]},t),x=h;if(x!==void 0&&["model","kind","lifecycle","mode","name","nice","listen","profile"].some(a=>e[a]!==void 0))throw new r({error:"cwd_not_exclusive",message:"cwd cannot be combined with another config flag except --keep-session and --restart",field:"cwd",next:"Pass --cwd alone (plus --keep-session / --restart)."});if(o!==void 0&&["model","kind","lifecycle","mode","name","nice","listen"].some(a=>e[a]!==void 0))throw new r({error:"profile_not_exclusive",message:"profile cannot be combined with another config flag except --restart",field:"profile",next:"Pass --profile alone (plus --restart)."});if(e.keepSession===!0&&x===void 0)throw new r({error:"keep_session_needs_cwd",message:"--keep-session only applies with --cwd",field:"keep-session",next:"Pass --cwd <dir> --keep-session."});if(e.restart===!0&&x===void 0&&o===void 0)throw new r({error:"restart_needs_change",message:"--restart only applies with --profile or --cwd",field:"restart",next:"Pass --profile <profile> or --cwd <dir> with --restart."});const S=e.model?.trim();if(S==="")throw new r({error:"empty_spec",message:"a model spec is required",field:"model",next:"Run `crtr node config --model -h` and read the focused contract before retrying."});const O=e.kind?.trim(),T=e.lifecycle?.trim(),q=e.mode?.trim(),L=e.name,v=e.nice,$=e.listen?.trim();let R;if($!==void 0)try{R=JSON.parse($)}catch{throw new r({error:"invalid_listen",message:`--listen is not JSON: ${$}`,field:"listen",next:`Pass a JSON object such as '{"3":"next-turn"}', or null.`})}if(v!==void 0&&(v<0||v>N))throw new r({error:"bad_nice",message:`niceness must be between 0 and ${N}: ${v}`,field:"nice",next:`A negative niceness needs root, so pass 0\u2013${N}.`});if(T!==void 0&&T.toLowerCase()!=="terminal"&&T.toLowerCase()!=="resident")throw new r({error:"bad_lifecycle",message:`invalid lifecycle: ${T}`,field:"lifecycle",next:"Pass `terminal` or `resident`."});if(q!==void 0&&q.toLowerCase()!=="base"&&q.toLowerCase()!=="orchestrator")throw new r({error:"bad_mode",message:`invalid mode: ${q}`,field:"mode",next:"Pass `base` or `orchestrator`."});const s=[],l={};if(S!==void 0&&(l.model=S,s.push("model")),O!==void 0&&(l.kind=O,s.push("kind")),T!==void 0&&(l.lifecycle=T.toLowerCase(),s.push("lifecycle")),q!==void 0&&(l.mode=q.toLowerCase(),s.push("mode")),L!==void 0&&(l.name=L,s.push("name")),x!==void 0&&(l.cwd=x,s.push("cwd"),e.keepSession===!0&&(l.keep_session=!0),e.restart===!0&&(l.restart=!0)),o!==void 0&&(l.profile=o,s.push("profile"),e.restart===!0&&(l.restart=!0)),$!==void 0&&(l.listen=R??null,s.push("listen")),v!==void 0){const a=await w().getNode(_).catch(A=>y(A));if(X(a.paths.context_dir,v),s.push("nice"),s.length===1)return{node_id:_,nice:v}}if(s.length===0)throw new r({error:"no_change",message:"no config changes requested",next:"Pass at least one of --model, --lifecycle, --kind, --mode, --name, --nice, --listen, --cwd."});const g=await w().patchConfig(_,l).catch(a=>y(a,"List nodes with `crtr node inspect list`."));if(x!==void 0)return{cwd:g.cwd,node_id:_,...l.keep_session===!0||g.pi_session_id!=null?{session_kept:g.pi_session_id!=null}:{}};if(o!==void 0)return{node_id:_,profile:g.profile_id??null};const k={node_id:_};return s.includes("model")&&(k.model=g.model_override??S),s.includes("lifecycle")&&(k.lifecycle=g.lifecycle),s.includes("kind")&&(k.kind=g.kind),s.includes("mode")&&(k.mode=g.mode),s.includes("name")&&(k.name=g.name),s.includes("nice")&&(k.nice=v),s.includes("listen")&&(k.listen=l.listen),k},"run"),render:u(e=>{if(e.bulk===!0){const n=e.results;return[`Applied to ${e.applied} node(s), ${e.failed} failed.`,...n.filter(i=>!i.ok).map(i=>` FAILED ${i.node_id}: ${i.error}`)].join(`
4
- `)}if(e.cwd!==void 0)return`Set cwd of ${e.node_id}: ${e.cwd}${e.session_kept===!0?" (conversation kept)":""}.`;if(e.profile!==void 0)return`Reassigned ${e.node_id} to profile ${e.profile}.`;const t=[];return e.model!==void 0&&t.push(`model=${e.model}`),e.lifecycle!==void 0&&t.push(`lifecycle=${e.lifecycle}`),e.kind!==void 0&&t.push(`kind=${e.kind}`),e.mode!==void 0&&t.push(`mode=${e.mode}`),e.name!==void 0&&t.push(`name=${e.name}`),e.nice!==void 0&&t.push(`nice=${e.nice}`),e.listen!==void 0&&t.push(`listen=${JSON.stringify(e.listen)}`),`Configured ${e.node_id} \u2014 ${t.join(", ")}`},"render")}),me=E({name:"promote",description:"become an orchestrator of a chosen kind",whenToUse:"the remaining work contains independent units that can run in parallel, and the task is large enough that coordinating and integrating them will materially improve intelligence, productivity, or elapsed throughput. Become a long-lived, roadmap-holding orchestrator whose primary job is steering those children across refreshes (`node yield`). Keep sequential or tightly coupled work in base mode even when it spans phases or context windows; spawning one helper does not itself require promotion",tier:"important",help:{name:"node promote",summary:"promote yourself to an orchestrator when worthwhile parallel delegation should make coordination your primary job; task duration, sequential phases, or one helper do not qualify. Mode only \u2014 lifecycle stays as-is unless you pass --resident",params:[{kind:"flag",name:"kind",type:"string",required:!1,constraint:"Specialize as this kind of orchestrator. The <kinds> list below names every top-level installable kind and when to use each; a registered sub-kind is valid too by exact path but not listed here. For an exact composed persona list, use `crtr sys context prompt-review --list --kind <kind>` with the target kind. Defaults to your current kind. Promoting from a generic kind? CHOOSE a concrete one \u2014 it sets the orchestrator persona you revive into."},{kind:"flag",name:"resident",type:"bool",required:!1,constraint:"ALSO flip lifecycle\u2192resident: make the node interactable \u2014 it is never forced to submit a final, and unattended grace parks it after a summary turn instead, leaving it revivable fresh against its goal and roadmap. Omit to stay terminal/orchestrator (delegates + holds a roadmap, but still owes a final up the spine and reaps when done)."},{kind:"flag",name:"model",type:"enum",choices:["ultra","strong"],required:!1,constraint:"Change the model you run on, by capability tier: `ultra` (frontier \u2014 reserve for high-taste judgment or enormous work: speccing, planning something large, e2e-testing something hard to test) or `strong` (opus \u2014 regular dev work). Omit to keep your current model. An orchestrator steering work is never weaker than opus, so these are the only two choices; the change is durable across future revives."},{kind:"flag",name:"node",type:"string",required:!1,constraint:"Node to promote. Defaults to the caller (CRTR_NODE_ID)."}],output:[{name:"node_id",type:"string",required:!0,constraint:"The promoted node."},{name:"kind",type:"string",required:!0,constraint:"The kind it now orchestrates as."},{name:"model",type:"string",required:!1,constraint:"The model tier it now runs on, present only when you changed it with --model."},{name:"lifecycle",type:"string",required:!0,constraint:'"resident" if you passed --resident, else unchanged (typically "terminal").'},{name:"roadmap_written",type:"boolean",required:!0,constraint:"True if the `roadmap` document was created by this call."},{name:"roadmap_ref",type:"string",required:!0,constraint:"Your roadmap document (`<node>/roadmap`) \u2014 author your plan with `crtr doc edit roadmap`."},{name:"goal_path",type:"string",required:!0,constraint:"Absolute path to your goal doc (context/initial-prompt.md) \u2014 the mandate you were spawned with."}],outputKind:"object",effects:["Flips mode\u2192orchestrator + kind\u2192chosen (lifecycle unchanged unless --resident, which also flips lifecycle\u2192resident); --model durably sets the model; rewrites the launch spec to that kind's orchestrator persona; creates your document `roadmap` (rule `on: boot`, `deliver: content`) if absent.","The next model request is gated on appending and persisting your new-role guidance. If a fresh context starts first, its rebuilt baseline carries the new role."]},helpState:{leaf:C},run:u(async e=>{const t=e.node??D();if(t===void 0||t==="")throw new r({error:"no_node",message:"no node to promote (set CRTR_NODE_ID or pass --node)",next:"Run from inside a node, or pass --node <id>."});const n=e.kind,i=e.model,d=e.resident===!0,o=await w().promoteNode(t,{...n!==void 0?{kind:n}:{},...d?{resident:!0}:{},...i!==void 0?{model:i}:{}}).catch(h=>y(h));return{node_id:o.node_id,kind:o.kind,lifecycle:o.lifecycle,...i!==void 0&&o.model_override!=null?{model:o.model_override}:{},roadmap_written:o.roadmap_written??!1,roadmap_ref:o.roadmap_ref??"",goal_path:o.goal_path??""}},"run")});async function M(e,t){let n=e.node;if((n===void 0||n==="")&&(n=I(t)),(n===void 0||n==="")&&(n=D()),n===void 0||n==="")throw new r({error:"no_node",message:"no node (set CRTR_NODE_ID, pass --node, or run from the agent's pane)",next:"Run from inside a node, pass --node <id>, or --pane <pane>."});if(await K(n)===null)throw new r({error:"not_found",message:`no node: ${n}`,next:"List nodes with `crtr node inspect list`."});return n}u(M,"resolveLifecycleNode");const te=E({name:"demote",description:"demote a node to terminal in place; it stays focused and running but now owes a final; --detach also closes its viewer (broker keeps running off-screen)",whenToUse:"you are watching a resident/interactive node and want to put it on a finishing track WITHOUT disturbing it: flip it terminal IN PLACE \u2014 it keeps its viewer and your focus, keeps running, but now owes a final report up the spine and reaps when done. The friendly counterpart to `node promote`. You can also let go entirely and close its viewer so the agent finishes off-screen on its broker. Use `node lifecycle recycle` instead to FINISH it now and reboot a fresh root in its pane, and `node config --lifecycle` for the orthogonal low-level flip (incl. terminal\u2192resident)",help:{name:"node lifecycle demote",summary:"demote a node to terminal IN PLACE \u2014 it stays focused and running but now owes a final up the spine and reaps when done. Pairs with `node promote` (mode\u2191); `--detach` also closes its viewer (the broker engine keeps running off-screen)",params:[{kind:"flag",name:"node",type:"string",required:!1,constraint:"Node to demote. Defaults to the node in --pane, else the caller (CRTR_NODE_ID)."},{kind:"flag",name:"pane",type:"string",required:!1,constraint:"tmux pane id whose node to demote, when --node is omitted. Defaults to $TMUX_PANE. The Alt+C menu passes this for you."},{kind:"flag",name:"detach",type:"bool",required:!1,constraint:"After flipping terminal, stop foregrounding the agent by closing its viewer pane. The broker engine keeps generating off-screen and \u2014 now terminal \u2014 pushes a final up the spine when done; a later `focus` reattaches a viewer. The Alt+C \u2192 D move."}],output:[{name:"node_id",type:"string",required:!0,constraint:"The demoted node."},{name:"detached",type:"boolean",required:!1,constraint:"True when --detach closed the agent's viewer pane (broker keeps running)."}],outputKind:"object",effects:["Flips the node's lifecycle\u2192terminal and rebuilds its launch spec so a future revive boots terminal \u2014 it stays focused and running, now owing a final up the spine.","The next model request is gated on appending and persisting the role transition. If a fresh context starts first, its rebuilt baseline carries the new lifecycle.","With --detach: closes the agent's viewer pane WITHOUT touching the broker engine \u2014 it keeps generating off-screen, reconnectable by a later `focus`."]},run:u(async e=>{const t=e.pane??process.env.TMUX_PANE,n=await M(e,t),i=await w().patchConfig(n,{lifecycle:"terminal"}).catch(o=>y(o));let d=!1;if(e.detach===!0){const o=Z(n)??t;o!==void 0&&o!==""&&G(o)&&(d=z(o))}return{node_id:i.node_id,detached:d}},"run"),render:u(e=>`Demoted ${e.node_id} \u2014 lifecycle now terminal (in place)${e.detached===!0?", viewer closed (broker still running off-screen)":""}.`,"render")}),ge=H({name:"lifecycle",description:"lifecycle actions \u2014 recycle, close, demote, or revive a node",whenToUse:"you are ending, transitioning, or bringing back one node you can name: finish the agent in your pane and reboot a fresh root (`recycle`), tear a node + its exclusive subtree down without finishing (`close`), flip a node onto a finishing track in place (`demote`), or bring a dormant node back (`revive`). To merely SET the terminal/resident attribute headlessly use `node config --lifecycle`; to FINISH from inside a node's own turn use `crtr push final`; to mass-reconnect EVERY disconnected node at once use `canvas revive --all`.",help:{name:"node lifecycle",summary:"end, transition, or revive a node \u2014 recycle the pane, close + cascade-cancel a subtree, demote to terminal in place, or revive a dormant node",model:"Lifecycle actions preserve or replace an existing node identity. Finishing is permanent, closing is revivable, demotion changes the completion obligation in place, and revival relaunches a dormant broker. Teardown cascades only through descendants exclusively managed by the affected subtree."},children:[ee,ne,te,Y]}),we=E({name:"yield",description:"refresh your context, same mode, against your roadmap or goal",whenToUse:"your context is filling but the mandate remains; refresh in the same mode, or combine the refresh with promotion when meaningful independent work can run in parallel and coordinating it should become your primary job",help:{name:"node yield",summary:"request a fresh context window against your roadmap or original goal; mode stays unchanged unless --promote is passed",guide:"The yield aborts your turn the instant this command returns: no text or tool call you planned after it will run. So anything the user is owed \u2014 an answer, a status \u2014 must already be a visible message in the conversation before you call it; never plan to reply after yielding. Before invoking: (1) If you hold a document `roadmap`, bring it current (`crtr doc edit roadmap`). It, not the yield note, carries your task into the fresh window. It has four sections: Goal (its first line is also the roadmap\u2019s preview, so set it with `--preview` whenever the goal changes), Exit criteria, Where things stand, and Working set. Keep it at your own level of abstraction. Detail below your level belongs to the node or document that holds it: link to it, don\u2019t copy it. Where things stand is present tense; delete what is done instead of marking it. Name units by what they are and how they fit, never by child node id or status: your bearings already list your children with their status. Working set holds `[[links]]`. Their previews load with the roadmap, so write no note beside a link. When a unit lands, delete its links: its evidence belongs in its report. (2) Give content its own document when it lives on a different timescale from the roadmap (exploration that outlives the current work), goes to a different reader (a brief for a child), or matters only when something specific happens. Link each such document from the Working set. Anything you had to re-derive in this window that a future window will need again belongs in a document: one you own for this task, `--owner repo` for lessons that would help others in the repo. A document that only points at other documents is not worth the extra hop. (3) Actions waiting on one specific event (\u201Cwhen X reports, send Y first\u201D) go in the yield note, not the roadmap. They are spent once they fire. (4) Send any pending human question; asks already in flight survive the refresh.",params:[{kind:"flag",name:"promote",type:"bool",required:!1,constraint:"Also become an orchestrator as you refresh. Pass only when (1) the remaining work contains independent units that can run in parallel and (2) the task is large enough that parallel execution will materially improve intelligence, productivity, or elapsed throughput after coordination and synthesis. Task length, context exhaustion, sequential phases, or one helper are not enough; keep hands-on work in base mode and yield again as needed. Promote when coordinating and integrating children becomes your primary job. Already an orchestrator? This is not an error: your mode stays orchestrator and a missing roadmap is seeded."},{kind:"flag",name:"kind",type:"string",required:!1,constraint:"Respecialize as you refresh. The <kinds> list below names every top-level available kind and when to choose it; a registered sub-kind is valid too by exact path but not listed here. Defaults to your current kind. With --promote it sets the orchestrator kind you become; without --promote it changes the kind while preserving your current mode."},{kind:"flag",name:"model",type:"enum",choices:["ultra","strong"],required:!1,constraint:"Change the model your fresh revive runs on, by capability tier: `ultra` (frontier \u2014 reserve for high-taste judgment or enormous work: speccing, planning something large, e2e-testing something hard to test) or `strong` (opus \u2014 regular dev work). Omit to keep your current model. A node steering work is never weaker than opus, so these are the only two choices; the change is durable across future revives."},{kind:"stdin",name:"message",required:!0,constraint:"A note to your future self \u2014 what you just tried, where things stand, the first move on waking, and any action waiting on a specific event: enough to continue efficiently, no more. Never describe a reply as sent unless it is visible in the conversation above this call. Your task and its state belong in the roadmap. Surfaced as <yield-message> in the next revive. Pass as a positional or pipe via heredoc."}],output:[{name:"node_id",type:"string",required:!0,constraint:"The yielding node."},{name:"model",type:"string",required:!1,constraint:"The model tier your fresh revive will run on, present only when you changed it with --model."}],outputKind:"object",effects:["Aborts your current turn as soon as this command returns \u2014 nothing after it runs \u2014 then the daemon revives the node fresh.","--kind and/or --model durably reshape the node (kind respecialization, model change) before the refresh-revive; --promote additionally flips mode\u2192orchestrator and creates your document `roadmap` \u2014 mode is otherwise left exactly as it was."]},helpState:{leaf:C},run:u(async e=>{const t=D();if(t===void 0||t==="")throw new r({error:"no_node",message:"no node to yield (CRTR_NODE_ID unset)",next:"Run from inside a node."});const n=e.kind,i=e.model,d=e.promote===!0,o=typeof e.message=="string"?e.message.trim():"";if(o==="")throw new r({error:"empty_message",message:"a yield message is required (stdin or positional)",next:"Pass a note to your future self as an argument or pipe it on stdin."});const h=await w().yieldNode(t,{note:o,...n!==void 0?{kind:n}:{},...i!==void 0?{model:i}:{},...d?{promote:!0}:{}}).catch(f=>y(f));return{node_id:h.node_id,...i!==void 0&&h.model_override!=null?{model:h.model_override}:{}}},"run")});export{pe as nodeConfig,ge as nodeLifecycle,me as nodePromote,we as nodeYield};
1
+ var H=Object.defineProperty;var u=(e,t)=>H(e,"name",{value:t,configurable:!0});import{contextDir as B}from"../../core/canvas/paths.js";import{readFileSync as W}from"node:fs";import{envNodeId as D}from"../../shared/env.js";import{defineBranch as K,defineLeaf as E}from"../../core/command.js";import{InputError as r}from"../../core/io.js";import{cliClient as w,getNodeOrNull as X,rethrowAsCliError as y}from"../api-client.js";import{DEFAULT_BASH_NICENESS as F,MAX_BASH_NICENESS as N,writeBashNiceness as Y}from"../../core/bash-jobs.js";import{nodeReviveLeaf as J}from"../node-lifecycle-revive.js";import{kindsStateBlock as C}from"../profile/daemon-profiles.js";import{expandHostPathTokens as z}from"../../core/runtime/broker/host-path-tokens.js";import{MODEL_SPEC_FORMS as G}from"../../core/runtime/model-selection.js";import{closePane as V,paneExists as Q,respawnPaneSync as Z,viewerEnv as ee,viewerPaneOf as ne,nodeInPane as I}from"../surface/node/placement.js";const te=E({name:"recycle",description:"finish the agent in your pane + recycle it into a fresh root",whenToUse:"you are at an agent's pane and done with it: finish it cleanly and recycle the pane in one move \u2014 push its last message as a final report to everyone waiting on it, mark it done, then boot a fresh crtr root in the same pane to keep working. The hands-on way to end an agent and immediately start over in place. Use `node lifecycle demote` instead to put it on a finishing track IN PLACE (flip terminal, keep it running) without ending it now, `node lifecycle close` to tear a node and its subtree down WITHOUT finishing (no report, revivable), and `push final` when the agent should finish ITSELF from inside its own turn",help:{name:"node lifecycle recycle",summary:"finish the agent in your current pane and recycle the pane \u2014 push its last message as a final report to everyone waiting on it, mark it done, then boot a fresh crtr root in the same pane",params:[{kind:"flag",name:"node",type:"string",required:!1,constraint:"Node to finish. Defaults to the node occupying --pane (or your current pane)."},{kind:"flag",name:"pane",type:"string",required:!1,constraint:"tmux pane id to recycle. Defaults to $TMUX_PANE / your current pane. The Alt+C menu passes this for you."}],output:[{name:"recycled",type:"boolean",required:!0,constraint:"True when the pane was recycled into a fresh root."},{name:"node_id",type:"string",required:!1,constraint:"The finished node."},{name:"new_root",type:"string",required:!1,constraint:"The fresh root node booted into the pane."}],outputKind:"object",effects:["Pushes a final report from the node (fans out to all subscribers) and marks it done.","Kills the agent's pi and respawns a fresh resident root in the same tmux pane."]},run:u(async e=>{const t=e.pane??process.env.TMUX_PANE;let n=e.node;if((n===void 0||n==="")&&(n=I(t)),n===void 0||n==="")throw new r({error:"no_node",message:"no node found in this pane to finish",next:"Pass --node <id>, or run from inside the agent's pane."});const i=await w().getNode(n).catch(f=>y(f,"List nodes with `crtr node inspect list`.")),o=(await w().recycleNode(n).catch(y)).node_id;let h=!1;return t!==void 0&&t!==""&&(h=Z({pane:t,cwd:i.cwd,env:ee(),command:"crtr"})),{recycled:h,node_id:n,new_root:o}},"run"),render:u(e=>{if(e.recycled!==!0)return e.new_root?`Finished ${e.node_id} and spawned a fresh broker root (${e.new_root}), but its viewer did not attach \u2014 the new broker did not come up. Re-focus the root to view it.`:`Recycle failed for ${e.node_id??"?"} \u2014 not in tmux, or no agent in this pane.`;const t=[`Recycled the pane \u2014 finished ${e.node_id}.`];return e.new_root&&t.push(`- new root: ${e.new_root}`),t.join(`
2
+ `)},"render")}),oe=E({name:"close",description:"close a node + cascade-cancel its exclusive subtree",whenToUse:"you want to tear a node down WITHOUT finishing it, cascade-cancelling every descendant it exclusively owns: abandoning a line of work, killing a stuck or wrong-turn subtree, clearing a branch you no longer need. A node that never produced substantive assistant output is deleted and cannot be revived; streaming nodes and nodes with an open managed worktree are retained. Other closed nodes keep their pi session and can be revived later (`node lifecycle revive`). Use `node lifecycle recycle` instead to FINISH the agent in your pane with a final report, and `push final` when a worker should end its own work normally (Alt+C \u2192 x)",help:{name:"node lifecycle close",summary:"close a node and cascade-cancel its subtree \u2014 kill its tmux window plus those of every descendant it EXCLUSIVELY owns (down the subscription spine \u2014 the watches each manager holds on its children), mark retained nodes canceled, and leave them a notice they read on resume. A descendant still subscribed to by a manager outside the subtree is left running. A node that never produced substantive assistant output is deleted and cannot be revived; streaming nodes and nodes with an open managed worktree are retained. Other closed nodes keep their pi session and can be revived later (`crtr node lifecycle revive`)",params:[{kind:"flag",name:"node",type:"string",required:!1,constraint:"Node to close. Defaults to the node occupying --pane (or your current pane)."},{kind:"flag",name:"pane",type:"string",required:!1,constraint:"tmux pane id whose node to close. Defaults to $TMUX_PANE / your current pane. The Alt+C menu passes this for you."}],output:[{name:"node_id",type:"string",required:!1,constraint:"The node that was closed \u2014 the cascade root."},{name:"count",type:"number",required:!1,constraint:"How many nodes were closed (root + cascaded descendants)."},{name:"closed_ids",type:"string[]",required:!1,constraint:"All closed node ids, kill order (leaves first, root last)."},{name:"spared",type:"string[]",required:!1,constraint:"Descendants left alive because a manager outside the subtree still subscribes to them."}],outputKind:"object",effects:["Marks retained nodes and their exclusive descendants `canceled` and clears intent (the daemon never revives a canceled node).","Deletes a non-streaming node with no substantive assistant output unless it has an open managed worktree; a deleted node cannot be revived.","Kills each closed node's tmux window; retained nodes keep their pi sessions and canvas edges for a later revive.","Appends a cancellation notice to each retained node's inbox, surfaced on its next resume."]},run:u(async e=>{const t=e.pane??process.env.TMUX_PANE;let n=e.node;if((n===void 0||n==="")&&(n=I(t)),n===void 0||n==="")throw new r({error:"no_node",message:"no node found in this pane to close",next:"Pass --node <id>, or run from inside the agent's pane."});const i=await w().closeNode(n,process.ppid>0?{caller_pid:process.ppid}:{}).catch(d=>y(d,"List nodes with `crtr node inspect list`."));return{node_id:i.root,count:i.closed.length,closed_ids:i.closed,spared:i.spared}},"run"),render:u(e=>{const t=e.spared?.length??0;return`Closed ${e.node_id} and its exclusive subtree \u2014 ${e.count} node(s) closed${t>0?`, ${t} spared (still managed from outside the subtree)`:""}.`},"render")}),j="Model change first: a running broker, including one still starting right after `node new`, switches over its socket; a dormant node persists the durable model override and launch recipe for its next revive.",ye=E({name:"config",description:"reconfigure a node's settings headlessly \u2014 model, lifecycle (terminal/resident), kind, mode, name; repair a missing cwd",whenToUse:"you want to reconfigure a node's settings headlessly after spawn \u2014 swap its model/provider, flip it terminal\u2194resident (interactable), respecialize its kind, switch base\u2194orchestrator mode, or rename it \u2014 without opening its viewer. It also repairs a dormant node whose recorded cwd is gone, starting its next revive in a fresh conversation. The durable attribute setter; reuses the same recipes a revive reads. Use `node promote` for the opinionated self-promotion path, and `node lifecycle` for teardown actions (recycle/close/demote).",help:{name:"node config",summary:"reconfigure a node's settings headlessly \u2014 model, lifecycle, kind, mode, name; repair a missing cwd",params:[{kind:"flag",name:"node",type:"string",required:!1,repeatable:!0,constraint:"Target node id. Defaults to the node in --pane, else CRTR_NODE_ID. Repeat it, or use --nodes-from, to apply a --profile or --cwd change to many nodes; a bulk run reports each node and keeps going past a failure."},{kind:"flag",name:"nodes-from",type:"string",required:!1,constraint:"File of node ids, one per line (blank lines and #-comments ignored), or `-` for stdin. Bulk form of --node; only with --profile or --cwd."},{kind:"flag",name:"pane",type:"string",required:!1,constraint:"tmux pane id to resolve the node from. Defaults to $TMUX_PANE."},{kind:"flag",name:"model",type:"string",required:!1,constraint:"Durable model change. Omit unless the task or governing guidance requires a different model.",focusedHelp:{whenToUse:"Use only when intentionally changing this node\u2019s durable model because the user, task, or governing agent guidance requires a specific provider, model, capability tier, or family. Omit it to keep the current model; do not use it merely to inspect available models or experiment with a live node.",value:`Accepted durable forms: ${G}. A live broker also accepts a free-text substring matched against its loaded model registry; a dormant node cannot resolve a substring and requires a durable form.`,effects:[j,"A concrete provider/id runs exactly that model on every launch and revive. A portable provider/tier, bare tier, or family alias keeps its tier: when that model's provider is rate-limited or rejects its credential, the node moves to the next model in its route: another provider's model at the same tier first, then the configured fallback tier (strong by default)."]}},{kind:"flag",name:"lifecycle",type:"enum",choices:["terminal","resident"],required:!1,constraint:"Set lifecycle headlessly without closing the viewer. terminal owes a final and reaps when done; resident stays interactable while attached or awaiting something live."},{kind:"flag",name:"kind",type:"string",required:!1,constraint:"Persona kind. The <kinds> list below names every top-level installable kind and when to use each; a registered sub-kind is valid too by exact path but not listed here."},{kind:"flag",name:"mode",type:"enum",choices:["base","orchestrator"],required:!1,constraint:"Set persona mode headlessly. base is hands-on; orchestrator holds a roadmap and delegates. orchestrator creates your document `roadmap` if absent."},{kind:"flag",name:"name",type:"string",required:!1,constraint:"Rename the node; if the node has a live window, also rename that viewer window."},{kind:"flag",name:"nice",type:"int",required:!1,constraint:`Scheduler niceness every command this node's bash tool starts at, 0\u2013${N} (default ${F}). ${F} keeps the node's builds and test suites below the daemon, the brokers, the viewers, and the person's own shell; 0 lets them compete on equal terms with everything else on the host; ${N} makes them yield to it. Applies to the node's very next command, foreground and background alike.`},{kind:"flag",name:"listen",type:"string",required:!1,constraint:`The node's default listening configuration, as JSON mapping an event level ("1".."10") to how events at or above it reach the node: interrupt, steer, after-turn, or next-turn (e.g. '{"3":"next-turn"}' \u2014 events of level 3+ wait for its next turn and never wake it). Applies to every watch with no configuration of its own. Pass \`null\` to reset to the global default.`},{kind:"flag",name:"cwd",type:"string",required:!1,constraint:"Replacement launch directory (absolute, existing). Alone, or with --keep-session / --restart. Without --keep-session it is a repair: only a dormant, non-forked node with no open managed worktree whose recorded cwd is gone, and it clears the saved Pi session (next revive starts fresh). When the new path is the same directory as the recorded one (a symlink alias) it relocates and keeps the conversation automatically \u2014 see --keep-session."},{kind:"flag",name:"keep-session",type:"bool",required:!1,constraint:"With --cwd: assert the new path is the SAME directory as the recorded cwd and relocate WITHOUT clearing the Pi session. Needed only when the recorded path is already gone (e.g. the symlink was deleted); while it still exists the daemon verifies by realpath and refuses a different directory. Allowed for live, idle, dormant and finished nodes, forks included. Rewrites the recorded cwd and the cwd in the node's transcript header so a later resume finds it. Refused while the node owns an open managed worktree."},{kind:"flag",name:"rewrite-prefix",type:"string",required:!1,constraint:'Bulk cwd form, `OLD=NEW` (absolute paths): with several nodes, each node\'s recorded cwd that equals OLD or lies beneath it is relocated to the same place under NEW, keeping its session (as --keep-session); nodes whose cwd is elsewhere are reported as failed "not under OLD". Use instead of --cwd when the nodes sit in different subdirectories.'},{kind:"flag",name:"profile",type:"string",required:!1,constraint:"Reassign the node to this profile (id or exact name; must be an active profile of the node's app that defines the node's kind). Works for live, idle, dormant, finished and profile-less (detached) nodes. Used alone, or with --restart."},{kind:"flag",name:"restart",type:"bool",required:!1,constraint:"With --profile, or --cwd on a live node: after the change, SIGTERM the node's live broker so crtrd resumes it from the same transcript (continuing an interrupted turn) with the new profile/cwd. No effect on a node with no live broker."}],output:[{name:"node_id",type:"string",required:!1,constraint:"The reconfigured node, present for ordinary config changes."},{name:"model",type:"string",required:!1,constraint:"The resolved model, present only when --model changed it."},{name:"lifecycle",type:"string",required:!1,constraint:"The new lifecycle, present only when --lifecycle changed it."},{name:"kind",type:"string",required:!1,constraint:"The new kind, present only when --kind changed it."},{name:"mode",type:"string",required:!1,constraint:"The new mode, present only when --mode changed it."},{name:"name",type:"string",required:!1,constraint:"The new name, present only when --name changed it."},{name:"nice",type:"number",required:!1,constraint:"The new bash niceness, present only when --nice changed it."},{name:"listen",type:"object",required:!1,constraint:"The new default listening configuration (null = global default), present only when --listen changed it."},{name:"cwd",type:"string",required:!1,constraint:"The resolved replacement directory, present only after a cwd change."},{name:"session_kept",type:"boolean",required:!1,constraint:"With a cwd change: true when the node still has its Pi session bound (conversation preserved)."},{name:"profile",type:"string",required:!1,constraint:"The node's profile id after --profile."},{name:"bulk",type:"boolean",required:!1,constraint:"True for a multi-node run."},{name:"applied",type:"number",required:!1,constraint:"Bulk: nodes changed (or already in the requested state)."},{name:"failed",type:"number",required:!1,constraint:"Bulk: nodes that errored; the exit code is 1 when any did."},{name:"results",type:"array",required:!1,constraint:"Bulk: one {node_id, ok, error?} per node, in input order."}],outputKind:"object",effects:[j,"Kind, mode, and lifecycle changes rebuild the launch spec from the fresh node meta; setting mode to orchestrator creates your document `roadmap` if absent.","Name changes update the row and, when the node already has a live window, rename that viewer window to the new full name.","A cwd repair (gone recorded cwd, no --keep-session) writes only the lexically resolved cwd and clears saved Pi session pointers; the old transcript and durable node work remain untouched.","A session-keeping cwd relocation (--keep-session, or --cwd naming a symlink alias of the recorded directory) rewrites the recorded cwd and the cwd line in the header of each of the node's transcripts; the Pi session stays bound and the next revive resumes the same conversation. A LIVE broker keeps the old cwd string in its environment and tools until it restarts: it keeps working while the old path exists, so pass --restart (or revive it) BEFORE deleting an old symlink.","A profile reassignment rewrites the node's profile and rebuilds its launch recipe. Profile env, documents delivered at boot, purview and bearings are read at launch, so a LIVE broker keeps the old profile until it next restarts; --restart bounces it now. Dormant or finished nodes simply carry the new profile into their next revive. The node's deadlines and profile pause follow the new profile immediately.","A niceness change is stored with the node's own bash-job state, so it takes effect on the next command without a revive and survives one.","A listen change sets the node's default listening configuration; it never changes which watches it holds.","Every successful change publishes a `configured` event on the node (level 1) naming the changed settings, so its watchers can see it."]},helpState:{leaf:C},run:u(async e=>{const t=e.pane??process.env.TMUX_PANE,n=e.node,i=Array.isArray(n)?n:n===void 0?[]:[n],d=e.nodesFrom;if(d!==void 0){const a=d==="-"?W(0,"utf8"):W(d,"utf8");for(const A of a.split(`
3
+ `)){const b=A.replace(/#.*/,"").trim();b!==""&&i.push(b)}}const o=e.profile,h=e.cwd,f=e.rewritePrefix;if(i.length>1||d!==void 0||f!==void 0){if(i.length===0)throw new r({error:"no_nodes",message:"bulk config needs at least one node",next:"Pass --node ID (repeatable) or --nodes-from FILE|-."});if(o===void 0&&h===void 0&&f===void 0)throw new r({error:"bulk_unsupported",message:"several nodes are accepted only with --profile, --cwd or --rewrite-prefix",next:"Pass --profile <profile>, --cwd <dir> or --rewrite-prefix OLD=NEW with the node list."});let a;if(f!==void 0){const p=f.indexOf("="),c=p<0?"":f.slice(0,p).replace(/\/+$/,""),m=p<0?"":f.slice(p+1).replace(/\/+$/,"");if(!c.startsWith("/")||!m.startsWith("/"))throw new r({error:"bad_rewrite_prefix",message:`--rewrite-prefix must be OLD=NEW with absolute paths: ${f}`,field:"rewrite-prefix",next:"Pass e.g. --rewrite-prefix /Users/me/Code/northlight=/Users/me/Code/northlight-systems."});a=[c,m]}const A=w(),b=[];for(const p of[...new Set(i)])try{const c=o!==void 0?{profile:o}:{cwd:h??""};if(a!==void 0){const m=(await A.getNode(p)).cwd;if(m!==a[0]&&!m.startsWith(`${a[0]}/`))throw new Error(`cwd ${m} is not under ${a[0]}`);c.cwd=a[1]+m.slice(a[0].length),c.keep_session=!0}e.keepSession===!0&&(c.keep_session=!0),e.restart===!0&&(c.restart=!0),await A.patchConfig(p,c),b.push({node_id:p,ok:!0})}catch(c){let m=c instanceof Error?c.message:String(c);try{y(c)}catch(U){U instanceof Error&&(m=U.message)}b.push({node_id:p,ok:!1,error:m})}const P=b.filter(p=>!p.ok).length;return P>0&&(process.exitCode=1),{bulk:!0,applied:b.length-P,failed:P,results:b}}const _=await M({...e,node:i[0]},t),x=h;if(x!==void 0&&["model","kind","lifecycle","mode","name","nice","listen","profile"].some(a=>e[a]!==void 0))throw new r({error:"cwd_not_exclusive",message:"cwd cannot be combined with another config flag except --keep-session and --restart",field:"cwd",next:"Pass --cwd alone (plus --keep-session / --restart)."});if(o!==void 0&&["model","kind","lifecycle","mode","name","nice","listen"].some(a=>e[a]!==void 0))throw new r({error:"profile_not_exclusive",message:"profile cannot be combined with another config flag except --restart",field:"profile",next:"Pass --profile alone (plus --restart)."});if(e.keepSession===!0&&x===void 0)throw new r({error:"keep_session_needs_cwd",message:"--keep-session only applies with --cwd",field:"keep-session",next:"Pass --cwd <dir> --keep-session."});if(e.restart===!0&&x===void 0&&o===void 0)throw new r({error:"restart_needs_change",message:"--restart only applies with --profile or --cwd",field:"restart",next:"Pass --profile <profile> or --cwd <dir> with --restart."});const S=e.model?.trim();if(S==="")throw new r({error:"empty_spec",message:"a model spec is required",field:"model",next:"Run `crtr node config --model -h` and read the focused contract before retrying."});const O=e.kind?.trim(),T=e.lifecycle?.trim(),q=e.mode?.trim(),L=e.name,v=e.nice,$=e.listen?.trim();let R;if($!==void 0)try{R=JSON.parse($)}catch{throw new r({error:"invalid_listen",message:`--listen is not JSON: ${$}`,field:"listen",next:`Pass a JSON object such as '{"3":"next-turn"}', or null.`})}if(v!==void 0&&(v<0||v>N))throw new r({error:"bad_nice",message:`niceness must be between 0 and ${N}: ${v}`,field:"nice",next:`A negative niceness needs root, so pass 0\u2013${N}.`});if(T!==void 0&&T.toLowerCase()!=="terminal"&&T.toLowerCase()!=="resident")throw new r({error:"bad_lifecycle",message:`invalid lifecycle: ${T}`,field:"lifecycle",next:"Pass `terminal` or `resident`."});if(q!==void 0&&q.toLowerCase()!=="base"&&q.toLowerCase()!=="orchestrator")throw new r({error:"bad_mode",message:`invalid mode: ${q}`,field:"mode",next:"Pass `base` or `orchestrator`."});const s=[],l={};if(S!==void 0&&(l.model=S,s.push("model")),O!==void 0&&(l.kind=O,s.push("kind")),T!==void 0&&(l.lifecycle=T.toLowerCase(),s.push("lifecycle")),q!==void 0&&(l.mode=q.toLowerCase(),s.push("mode")),L!==void 0&&(l.name=L,s.push("name")),x!==void 0&&(l.cwd=x,s.push("cwd"),e.keepSession===!0&&(l.keep_session=!0),e.restart===!0&&(l.restart=!0)),o!==void 0&&(l.profile=o,s.push("profile"),e.restart===!0&&(l.restart=!0)),$!==void 0&&(l.listen=R??null,s.push("listen")),v!==void 0){const a=await w().getNode(_).catch(A=>y(A));if(Y(B(_,a.grantee),v),s.push("nice"),s.length===1)return{node_id:_,nice:v}}if(s.length===0)throw new r({error:"no_change",message:"no config changes requested",next:"Pass at least one of --model, --lifecycle, --kind, --mode, --name, --nice, --listen, --cwd."});const g=await w().patchConfig(_,l).catch(a=>y(a,"List nodes with `crtr node inspect list`."));if(x!==void 0)return{cwd:g.cwd,node_id:_,...l.keep_session===!0||g.pi_session_id!=null?{session_kept:g.pi_session_id!=null}:{}};if(o!==void 0)return{node_id:_,profile:g.profile_id??null};const k={node_id:_};return s.includes("model")&&(k.model=g.model_override??S),s.includes("lifecycle")&&(k.lifecycle=g.lifecycle),s.includes("kind")&&(k.kind=g.kind),s.includes("mode")&&(k.mode=g.mode),s.includes("name")&&(k.name=g.name),s.includes("nice")&&(k.nice=v),s.includes("listen")&&(k.listen=l.listen),k},"run"),render:u(e=>{if(e.bulk===!0){const n=e.results;return[`Applied to ${e.applied} node(s), ${e.failed} failed.`,...n.filter(i=>!i.ok).map(i=>` FAILED ${i.node_id}: ${i.error}`)].join(`
4
+ `)}if(e.cwd!==void 0)return`Set cwd of ${e.node_id}: ${e.cwd}${e.session_kept===!0?" (conversation kept)":""}.`;if(e.profile!==void 0)return`Reassigned ${e.node_id} to profile ${e.profile}.`;const t=[];return e.model!==void 0&&t.push(`model=${e.model}`),e.lifecycle!==void 0&&t.push(`lifecycle=${e.lifecycle}`),e.kind!==void 0&&t.push(`kind=${e.kind}`),e.mode!==void 0&&t.push(`mode=${e.mode}`),e.name!==void 0&&t.push(`name=${e.name}`),e.nice!==void 0&&t.push(`nice=${e.nice}`),e.listen!==void 0&&t.push(`listen=${JSON.stringify(e.listen)}`),`Configured ${e.node_id} \u2014 ${t.join(", ")}`},"render")}),ve=E({name:"promote",description:"become an orchestrator of a chosen kind",whenToUse:"the remaining work contains independent units that can run in parallel, and the task is large enough that coordinating and integrating them will materially improve intelligence, productivity, or elapsed throughput. Become a long-lived, roadmap-holding orchestrator whose primary job is steering those children across refreshes (`node yield`). Keep sequential or tightly coupled work in base mode even when it spans phases or context windows; spawning one helper does not itself require promotion",tier:"important",help:{name:"node promote",summary:"promote yourself to an orchestrator when worthwhile parallel delegation should make coordination your primary job; task duration, sequential phases, or one helper do not qualify. Mode only \u2014 lifecycle stays as-is unless you pass --resident",params:[{kind:"flag",name:"kind",type:"string",required:!1,constraint:"Specialize as this kind of orchestrator. The <kinds> list below names every top-level installable kind and when to use each; a registered sub-kind is valid too by exact path but not listed here. For an exact composed persona list, use `crtr sys context prompt-review --list --kind <kind>` with the target kind. Defaults to your current kind. Promoting from a generic kind? CHOOSE a concrete one \u2014 it sets the orchestrator persona you revive into."},{kind:"flag",name:"resident",type:"bool",required:!1,constraint:"ALSO flip lifecycle\u2192resident: make the node interactable \u2014 it is never forced to submit a final, and unattended grace parks it after a summary turn instead, leaving it revivable fresh against its goal and roadmap. Omit to stay terminal/orchestrator (delegates + holds a roadmap, but still owes a final up the spine and reaps when done)."},{kind:"flag",name:"model",type:"enum",choices:["ultra","strong"],required:!1,constraint:"Change the model you run on, by capability tier: `ultra` (frontier \u2014 reserve for high-taste judgment or enormous work: speccing, planning something large, e2e-testing something hard to test) or `strong` (opus \u2014 regular dev work). Omit to keep your current model. An orchestrator steering work is never weaker than opus, so these are the only two choices; the change is durable across future revives."},{kind:"flag",name:"node",type:"string",required:!1,constraint:"Node to promote. Defaults to the caller (CRTR_NODE_ID)."}],output:[{name:"node_id",type:"string",required:!0,constraint:"The promoted node."},{name:"kind",type:"string",required:!0,constraint:"The kind it now orchestrates as."},{name:"model",type:"string",required:!1,constraint:"The model tier it now runs on, present only when you changed it with --model."},{name:"lifecycle",type:"string",required:!0,constraint:'"resident" if you passed --resident, else unchanged (typically "terminal").'},{name:"roadmap_written",type:"boolean",required:!0,constraint:"True if the `roadmap` document was created by this call."},{name:"roadmap_ref",type:"string",required:!0,constraint:"Your roadmap document (`<node>/roadmap`) \u2014 author your plan with `crtr doc edit roadmap`."},{name:"goal_path",type:"string",required:!0,constraint:"Absolute path to your goal doc (context/initial-prompt.md) \u2014 the mandate you were spawned with."}],outputKind:"object",effects:["Flips mode\u2192orchestrator + kind\u2192chosen (lifecycle unchanged unless --resident, which also flips lifecycle\u2192resident); --model durably sets the model; rewrites the launch spec to that kind's orchestrator persona; creates your document `roadmap` (rule `on: boot`, `deliver: content`) if absent.","The next model request is gated on appending and persisting your new-role guidance. If a fresh context starts first, its rebuilt baseline carries the new role."]},helpState:{leaf:C},run:u(async e=>{const t=e.node??D();if(t===void 0||t==="")throw new r({error:"no_node",message:"no node to promote (set CRTR_NODE_ID or pass --node)",next:"Run from inside a node, or pass --node <id>."});const n=e.kind,i=e.model,d=e.resident===!0,o=await w().promoteNode(t,{...n!==void 0?{kind:n}:{},...d?{resident:!0}:{},...i!==void 0?{model:i}:{}}).catch(h=>y(h));return{node_id:o.node_id,kind:o.kind,lifecycle:o.lifecycle,...i!==void 0&&o.model_override!=null?{model:o.model_override}:{},roadmap_written:o.roadmap_written??!1,roadmap_ref:o.roadmap_ref??"",goal_path:z(o.goal_path??"")}},"run")});async function M(e,t){let n=e.node;if((n===void 0||n==="")&&(n=I(t)),(n===void 0||n==="")&&(n=D()),n===void 0||n==="")throw new r({error:"no_node",message:"no node (set CRTR_NODE_ID, pass --node, or run from the agent's pane)",next:"Run from inside a node, pass --node <id>, or --pane <pane>."});if(await X(n)===null)throw new r({error:"not_found",message:`no node: ${n}`,next:"List nodes with `crtr node inspect list`."});return n}u(M,"resolveLifecycleNode");const ie=E({name:"demote",description:"demote a node to terminal in place; it stays focused and running but now owes a final; --detach also closes its viewer (broker keeps running off-screen)",whenToUse:"you are watching a resident/interactive node and want to put it on a finishing track WITHOUT disturbing it: flip it terminal IN PLACE \u2014 it keeps its viewer and your focus, keeps running, but now owes a final report up the spine and reaps when done. The friendly counterpart to `node promote`. You can also let go entirely and close its viewer so the agent finishes off-screen on its broker. Use `node lifecycle recycle` instead to FINISH it now and reboot a fresh root in its pane, and `node config --lifecycle` for the orthogonal low-level flip (incl. terminal\u2192resident)",help:{name:"node lifecycle demote",summary:"demote a node to terminal IN PLACE \u2014 it stays focused and running but now owes a final up the spine and reaps when done. Pairs with `node promote` (mode\u2191); `--detach` also closes its viewer (the broker engine keeps running off-screen)",params:[{kind:"flag",name:"node",type:"string",required:!1,constraint:"Node to demote. Defaults to the node in --pane, else the caller (CRTR_NODE_ID)."},{kind:"flag",name:"pane",type:"string",required:!1,constraint:"tmux pane id whose node to demote, when --node is omitted. Defaults to $TMUX_PANE. The Alt+C menu passes this for you."},{kind:"flag",name:"detach",type:"bool",required:!1,constraint:"After flipping terminal, stop foregrounding the agent by closing its viewer pane. The broker engine keeps generating off-screen and \u2014 now terminal \u2014 pushes a final up the spine when done; a later `focus` reattaches a viewer. The Alt+C \u2192 D move."}],output:[{name:"node_id",type:"string",required:!0,constraint:"The demoted node."},{name:"detached",type:"boolean",required:!1,constraint:"True when --detach closed the agent's viewer pane (broker keeps running)."}],outputKind:"object",effects:["Flips the node's lifecycle\u2192terminal and rebuilds its launch spec so a future revive boots terminal \u2014 it stays focused and running, now owing a final up the spine.","The next model request is gated on appending and persisting the role transition. If a fresh context starts first, its rebuilt baseline carries the new lifecycle.","With --detach: closes the agent's viewer pane WITHOUT touching the broker engine \u2014 it keeps generating off-screen, reconnectable by a later `focus`."]},run:u(async e=>{const t=e.pane??process.env.TMUX_PANE,n=await M(e,t),i=await w().patchConfig(n,{lifecycle:"terminal"}).catch(o=>y(o));let d=!1;if(e.detach===!0){const o=ne(n)??t;o!==void 0&&o!==""&&Q(o)&&(d=V(o))}return{node_id:i.node_id,detached:d}},"run"),render:u(e=>`Demoted ${e.node_id} \u2014 lifecycle now terminal (in place)${e.detached===!0?", viewer closed (broker still running off-screen)":""}.`,"render")}),ke=K({name:"lifecycle",description:"lifecycle actions \u2014 recycle, close, demote, or revive a node",whenToUse:"you are ending, transitioning, or bringing back one node you can name: finish the agent in your pane and reboot a fresh root (`recycle`), tear a node + its exclusive subtree down without finishing (`close`), flip a node onto a finishing track in place (`demote`), or bring a dormant node back (`revive`). To merely SET the terminal/resident attribute headlessly use `node config --lifecycle`; to FINISH from inside a node's own turn use `crtr push final`; to mass-reconnect EVERY disconnected node at once use `canvas revive --all`.",help:{name:"node lifecycle",summary:"end, transition, or revive a node \u2014 recycle the pane, close + cascade-cancel a subtree, demote to terminal in place, or revive a dormant node",model:"Lifecycle actions preserve or replace an existing node identity. Finishing is permanent, closing is revivable, demotion changes the completion obligation in place, and revival relaunches a dormant broker. Teardown cascades only through descendants exclusively managed by the affected subtree."},children:[te,oe,ie,J]}),be=E({name:"yield",description:"refresh your context, same mode, against your roadmap or goal",whenToUse:"your context is filling but the mandate remains; refresh in the same mode, or combine the refresh with promotion when meaningful independent work can run in parallel and coordinating it should become your primary job",help:{name:"node yield",summary:"request a fresh context window against your roadmap or original goal; mode stays unchanged unless --promote is passed",guide:"The yield aborts your turn the instant this command returns: no text or tool call you planned after it will run. So anything the user is owed \u2014 an answer, a status \u2014 must already be a visible message in the conversation before you call it; never plan to reply after yielding. Before invoking: (1) If you hold a document `roadmap`, bring it current (`crtr doc edit roadmap`). It, not the yield note, carries your task into the fresh window. It has four sections: Goal (its first line is also the roadmap\u2019s preview, so set it with `--preview` whenever the goal changes), Exit criteria, Where things stand, and Working set. Keep it at your own level of abstraction. Detail below your level belongs to the node or document that holds it: link to it, don\u2019t copy it. Where things stand is present tense; delete what is done instead of marking it. Name units by what they are and how they fit, never by child node id or status: your bearings already list your children with their status. Working set holds `[[links]]`. Their previews load with the roadmap, so write no note beside a link. When a unit lands, delete its links: its evidence belongs in its report. (2) Give content its own document when it lives on a different timescale from the roadmap (exploration that outlives the current work), goes to a different reader (a brief for a child), or matters only when something specific happens. Link each such document from the Working set. Anything you had to re-derive in this window that a future window will need again belongs in a document: one you own for this task, `--owner repo` for lessons that would help others in the repo. A document that only points at other documents is not worth the extra hop. (3) Actions waiting on one specific event (\u201Cwhen X reports, send Y first\u201D) go in the yield note, not the roadmap. They are spent once they fire. (4) Send any pending human question; asks already in flight survive the refresh.",params:[{kind:"flag",name:"promote",type:"bool",required:!1,constraint:"Also become an orchestrator as you refresh. Pass only when (1) the remaining work contains independent units that can run in parallel and (2) the task is large enough that parallel execution will materially improve intelligence, productivity, or elapsed throughput after coordination and synthesis. Task length, context exhaustion, sequential phases, or one helper are not enough; keep hands-on work in base mode and yield again as needed. Promote when coordinating and integrating children becomes your primary job. Already an orchestrator? This is not an error: your mode stays orchestrator and a missing roadmap is seeded."},{kind:"flag",name:"kind",type:"string",required:!1,constraint:"Respecialize as you refresh. The <kinds> list below names every top-level available kind and when to choose it; a registered sub-kind is valid too by exact path but not listed here. Defaults to your current kind. With --promote it sets the orchestrator kind you become; without --promote it changes the kind while preserving your current mode."},{kind:"flag",name:"model",type:"enum",choices:["ultra","strong"],required:!1,constraint:"Change the model your fresh revive runs on, by capability tier: `ultra` (frontier \u2014 reserve for high-taste judgment or enormous work: speccing, planning something large, e2e-testing something hard to test) or `strong` (opus \u2014 regular dev work). Omit to keep your current model. A node steering work is never weaker than opus, so these are the only two choices; the change is durable across future revives."},{kind:"stdin",name:"message",required:!0,constraint:"A note to your future self \u2014 what you just tried, where things stand, the first move on waking, and any action waiting on a specific event: enough to continue efficiently, no more. Never describe a reply as sent unless it is visible in the conversation above this call. Your task and its state belong in the roadmap. Surfaced as <yield-message> in the next revive. Pass as a positional or pipe via heredoc."}],output:[{name:"node_id",type:"string",required:!0,constraint:"The yielding node."},{name:"model",type:"string",required:!1,constraint:"The model tier your fresh revive will run on, present only when you changed it with --model."}],outputKind:"object",effects:["Aborts your current turn as soon as this command returns \u2014 nothing after it runs \u2014 then the daemon revives the node fresh.","--kind and/or --model durably reshape the node (kind respecialization, model change) before the refresh-revive; --promote additionally flips mode\u2192orchestrator and creates your document `roadmap` \u2014 mode is otherwise left exactly as it was."]},helpState:{leaf:C},run:u(async e=>{const t=D();if(t===void 0||t==="")throw new r({error:"no_node",message:"no node to yield (CRTR_NODE_ID unset)",next:"Run from inside a node."});const n=e.kind,i=e.model,d=e.promote===!0,o=typeof e.message=="string"?e.message.trim():"";if(o==="")throw new r({error:"empty_message",message:"a yield message is required (stdin or positional)",next:"Pass a note to your future self as an argument or pipe it on stdin."});const h=await w().yieldNode(t,{note:o,...n!==void 0?{kind:n}:{},...i!==void 0?{model:i}:{},...d?{promote:!0}:{}}).catch(f=>y(f));return{node_id:h.node_id,...i!==void 0&&h.model_override!=null?{model:h.model_override}:{}}},"run")});export{ye as nodeConfig,ke as nodeLifecycle,ve as nodePromote,be as nodeYield};
@@ -1,2 +1,2 @@
1
- var m=Object.defineProperty;var s=(o,t)=>m(o,"name",{value:t,configurable:!0});import{envNodeId as p}from"../shared/env.js";import{spawnSync as f}from"node:child_process";import{existsSync as u,mkdirSync as h,mkdtempSync as v,rmSync as x,symlinkSync as b}from"node:fs";import{tmpdir as y}from"node:os";import{dirname as g,join as d}from"node:path";import{defineLeaf as w}from"../core/command.js";import{InputError as a}from"../core/io.js";import{nvimArgs as T,nvimAvailable as S}from"../core/nvim-launch.js";import{cliClient as $,rethrowAsCliError as R}from"./api-client.js";function l(o){return o.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"node"}s(l,"sanitize");async function _(o){const t=await $().getContext(o),n=[];for(const e of t.roots){const r=e.dir,i=e.node_id.slice(0,8),c=e.self?`self-${l(e.label)}`:`${l(e.label)}-${i}`;n.push({nodeId:e.node_id,label:c,dir:g(r),self:e.self,fileCount:e.files,contextDir:r})}return n}s(_,"resolveRoots");function C(o){const t=v(d(y(),"crtr-context-"));for(const n of o){const e=n.self?`0-${n.label}`:n.label,r=d(t,e);h(r,{recursive:!0});try{u(n.contextDir)&&b(n.contextDir,d(r,"context"),"dir")}catch{}}return t}s(C,"buildSymlinkTree");const P=w({name:"context",description:"browse this node + its subscriptions\u2019 context dirs in an nvim popup",whenToUse:"you want to SEE what the nodes you subscribe to have written \u2014 open a read-only nvim file explorer over this node\u2019s context dir and every subscribed node\u2019s context dir at once (reports are documents: `crtr canvas read <node>/reports/<name>`). The /context popup shells this. Piped it prints the roster instead",help:{name:"node inspect context",summary:"open a read-only nvim file explorer over this node\u2019s context dir and those of every node it subscribes to",params:[{kind:"flag",name:"node",type:"string",required:!1,constraint:"Node id to root on. Defaults to $CRTR_NODE_ID (the calling node)."}],output:[{name:"roots",type:"object[]",required:!0,constraint:"Resolved browse roots: {node_id, label, dir, self, files}. Returned on the piped/non-TTY path."}],outputKind:"object",effects:["TTY: builds a temp dir of labelled node dirs, symlinking each available `context` dir inside it, then execs `nvim -R` on the tree; the temp links are removed on exit (real dirs untouched).","Requires nvim on PATH (a crtr strong dependency). Missing nvim -> error with an install hint.","Non-TTY / piped: prints the resolved roster and exits 0; opens nothing."]},run:s(async o=>{const t=o.node?.trim()||p();if(t===void 0||t==="")throw new a({error:"no_node",message:"no current node: $CRTR_NODE_ID is unset and --node was not given",field:"node",next:"Run this from inside a canvas node (the /context popup does), or pass --node <id>."});let n;try{n=await _(t)}catch(i){R(i)}const e=n.map(i=>({node_id:i.nodeId,label:i.label,dir:i.dir,self:i.self,files:i.fileCount}));if(!process.stdout.isTTY)return{roots:e};if(!S())throw new a({error:"nvim_missing",message:"nvim is not on PATH \u2014 `crtr node inspect context` opens the context explorer in nvim",next:"Install Neovim (macOS: `brew install neovim`; Debian/Ubuntu: `apt install neovim`), then retry."});const r=C(n);try{f("nvim",[...T("readonly"),"."],{cwd:r,stdio:"inherit"})}finally{x(r,{recursive:!0,force:!0})}return{roots:e}},"run"),render:s(o=>{const t=o.roots??[];if(t.length===0)return"No node dirs to show (no subscriptions with written context or reports, and this node\u2019s own context dir is empty/absent).";const n=t.map(e=>{const r=e.self===!0?" (self)":"";return` ${String(e.label)}${r} ${String(e.files)} files ${String(e.dir)}`});return[`Context roots (${t.length}):`,...n].join(`
2
- `)},"render")});export{P as nodeContextLeaf};
1
+ var f=Object.defineProperty;var s=(o,n)=>f(o,"name",{value:n,configurable:!0});import{envNodeId as h}from"../shared/env.js";import{spawnSync as x}from"node:child_process";import{existsSync as l,mkdirSync as v,mkdtempSync as b,readdirSync as y,rmSync as g,symlinkSync as w}from"node:fs";import{contextDir as T}from"../core/canvas/paths.js";import{tmpdir as _}from"node:os";import{dirname as S,join as a}from"node:path";import{defineLeaf as $}from"../core/command.js";import{InputError as m}from"../core/io.js";import{nvimArgs as D,nvimAvailable as R}from"../core/nvim-launch.js";import{cliClient as p,rethrowAsCliError as C}from"./api-client.js";function u(o){return o.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"node"}s(u,"sanitize");async function I(o){const n=await p().getContext(o),t=[];for(const e of n.roots){const r=await p().getNode(e.node_id).catch(()=>null),i=e.node_id.slice(0,8),c=e.self?`self-${u(e.label)}`:`${u(e.label)}-${i}`,d=r===null?"":T(e.node_id,r.grantee);if(!l(d)){t.push({nodeId:e.node_id,label:c,dir:`${e.node_id}/context (not on this machine)`,self:e.self,fileCount:0,contextDir:""});continue}t.push({nodeId:e.node_id,label:c,dir:S(d),self:e.self,fileCount:(()=>{try{return y(d).length}catch{return 0}})(),contextDir:d})}return t}s(I,"resolveRoots");function N(o){const n=b(a(_(),"crtr-context-"));for(const t of o){const e=t.self?`0-${t.label}`:t.label,r=a(n,e);v(r,{recursive:!0});try{l(t.contextDir)&&w(t.contextDir,a(r,"context"),"dir")}catch{}}return n}s(N,"buildSymlinkTree");const U=$({name:"context",description:"browse this node + its subscriptions\u2019 context dirs in an nvim popup",whenToUse:"you want to SEE what the nodes you subscribe to have written \u2014 open a read-only nvim file explorer over this node\u2019s context dir and every subscribed node\u2019s context dir at once (reports are documents: `crtr canvas read <node>/reports/<name>`). The /context popup shells this. Piped it prints the roster instead",help:{name:"node inspect context",summary:"open a read-only nvim file explorer over this node\u2019s context dir and those of every node it subscribes to",params:[{kind:"flag",name:"node",type:"string",required:!1,constraint:"Node id to root on. Defaults to $CRTR_NODE_ID (the calling node)."}],output:[{name:"roots",type:"object[]",required:!0,constraint:"Resolved browse roots: {node_id, label, dir, self, files}. Returned on the piped/non-TTY path."}],outputKind:"object",effects:["TTY: builds a temp dir of labelled node dirs, symlinking each available `context` dir inside it, then execs `nvim -R` on the tree; the temp links are removed on exit (real dirs untouched).","Requires nvim on PATH (a crtr strong dependency). Missing nvim -> error with an install hint.","Non-TTY / piped: prints the resolved roster and exits 0; opens nothing."]},run:s(async o=>{const n=o.node?.trim()||h();if(n===void 0||n==="")throw new m({error:"no_node",message:"no current node: $CRTR_NODE_ID is unset and --node was not given",field:"node",next:"Run this from inside a canvas node (the /context popup does), or pass --node <id>."});let t;try{t=await I(n)}catch(i){C(i)}const e=t.map(i=>({node_id:i.nodeId,label:i.label,dir:i.dir,self:i.self,files:i.fileCount}));if(!process.stdout.isTTY)return{roots:e};if(!R())throw new m({error:"nvim_missing",message:"nvim is not on PATH \u2014 `crtr node inspect context` opens the context explorer in nvim",next:"Install Neovim (macOS: `brew install neovim`; Debian/Ubuntu: `apt install neovim`), then retry."});const r=N(t);try{x("nvim",[...D("readonly"),"."],{cwd:r,stdio:"inherit"})}finally{g(r,{recursive:!0,force:!0})}return{roots:e}},"run"),render:s(o=>{const n=o.roots??[];if(n.length===0)return"No node dirs to show (no subscriptions with written context or reports, and this node\u2019s own context dir is empty/absent).";const t=n.map(e=>{const r=e.self===!0?" (self)":"";return` ${String(e.label)}${r} ${String(e.files)} files ${String(e.dir)}`});return[`Context roots (${n.length}):`,...t].join(`
2
+ `)},"render")});export{U as nodeContextLeaf};
@@ -1 +1 @@
1
- var a=Object.defineProperty;var n=(t,e)=>a(t,"name",{value:e,configurable:!0});import{ApiError as p}from"../api/index.js";import{personId as c,setPersonId as f}from"../core/canvas/person-state.js";import{currentSnapshot as g,installPersonSnapshot as S,setSettingsReloader as m,setSettingsTransport as l,SettingsRevisionConflictError as u}from"../core/scoped-state/person-store.js";import{cliClient as r}from"./api-client.js";const s=n(t=>t.snapshot,"fromDto");function A(){return{person:c(),snapshot:g()}}n(A,"loadedPersonSettings");async function C(){h(await r().getSettings())}n(C,"loadPersonSettingsViaApi");function h(t){f(t.person),S(t.person,s(t)),m(async()=>s(await r().getSettings())),l(async(e,i)=>{try{return s(await r().putSettings({ops:i}))}catch(o){throw o instanceof p&&o.status===409?new u:o}})}n(h,"installPersonSettingsDto");export{h as installPersonSettingsDto,C as loadPersonSettingsViaApi,A as loadedPersonSettings};
1
+ var a=Object.defineProperty;var n=(t,e)=>a(t,"name",{value:e,configurable:!0});import{ApiError as p}from"../api/index.js";import{personId as c,bindClientPerson as f}from"../core/canvas/person-state.js";import{currentSnapshot as g,installPersonSnapshot as S,setSettingsReloader as l,setSettingsTransport as m,SettingsRevisionConflictError as u}from"../core/scoped-state/person-store.js";import{cliClient as r}from"./api-client.js";const s=n(t=>t.snapshot,"fromDto");function d(){return{person:c(),snapshot:g()}}n(d,"loadedPersonSettings");async function A(){h(await r().getSettings())}n(A,"loadPersonSettingsViaApi");function h(t){f(t.person),S(t.person,s(t)),l(async()=>s(await r().getSettings())),m(async(e,i)=>{try{return s(await r().putSettings({ops:i}))}catch(o){throw o instanceof p&&o.status===409?new u:o}})}n(h,"installPersonSettingsDto");export{h as installPersonSettingsDto,A as loadPersonSettingsViaApi,d as loadedPersonSettings};
@@ -1,4 +1,4 @@
1
- var a=Object.defineProperty;var i=(t,n)=>a(t,"name",{value:n,configurable:!0});import{stateBlock as r}from"../../core/help.js";import{matchProfileOperand as f}from"../../core/profiles/manifest.js";import{localClient as m}from"../../api/node-transport.js";import{cliClient as p}from"../api-client.js";const c=i(()=>m({autostart:!1}),"helpClient"),u=i(t=>({profileId:t.id,name:t.name}),"profileKey");async function k(t){return f(await p().listProfiles(),t,u)}i(k,"resolveProfileViaDaemon");async function x(){const t=await c().listProfiles(),n=20,l=t.slice(0,n).map(e=>`${e.id} \u2014 ${e.name}`).join(`
2
- `),o=t.length>n?`${l}
3
- \u2026 ${t.length-n} more; use crtr profile list`:l;return r("profiles",{count:t.length},o)}i(x,"profilesStateBlock");async function P(){const{kinds:t}=await c().listKinds(),n=t.filter(({kind:o,available_to:e})=>{const s=o.indexOf("/");return s===-1||(e??[o.slice(0,s)]).includes("*")}),l=n.map(({kind:o,when_to_use:e})=>e?`${o} \u2014 ${e}`:o).join(`
4
- `);return r("kinds",{count:n.length},l)}i(P,"kindsStateBlock");export{P as kindsStateBlock,x as profilesStateBlock,k as resolveProfileViaDaemon};
1
+ var d=Object.defineProperty;var i=(n,o)=>d(n,"name",{value:o,configurable:!0});import{stateBlock as c}from"../../core/help.js";import{matchProfileOperand as p}from"../../core/profiles/manifest.js";import{localClient as u}from"../../api/node-transport.js";import{cliClient as h}from"../api-client.js";import{readMergedLaunchConfig as k}from"../../core/config.js";import{envProfileId as f}from"../../shared/env.js";const m=i(()=>u({autostart:!1}),"helpClient"),g=i(n=>({profileId:n.id,name:n.name}),"profileKey");async function C(n){return p(await h().listProfiles(),n,g)}i(C,"resolveProfileViaDaemon");async function j(){const n=await m().listProfiles(),o=20,r=n.slice(0,o).map(s=>`${s.id} \u2014 ${s.name}`).join(`
2
+ `),l=n.length>o?`${r}
3
+ \u2026 ${n.length-o} more; use crtr profile list`:r;return c("profiles",{count:n.length},l)}i(j,"profilesStateBlock");async function B(){const n=(await m().listKinds({profile:f()||void 0})).kinds,o=k(process.cwd(),f()||null).kinds,l=[...n,...Object.keys(o).filter(e=>!n.some(t=>t.kind===e)).map(e=>({kind:e,when_to_use:o[e]?.whenToUse??null,available_to:o[e]?.availableTo??null}))].filter(({kind:e,available_to:t})=>{const a=e.indexOf("/");return a===-1||(t??[e.slice(0,a)]).includes("*")}),s=l.map(({kind:e,when_to_use:t})=>t?`${e} \u2014 ${t}`:e).join(`
4
+ `);return c("kinds",{count:l.length},s)}i(B,"kindsStateBlock");export{B as kindsStateBlock,j as profilesStateBlock,C as resolveProfileViaDaemon};
@@ -1 +1 @@
1
- var m=Object.defineProperty;var r=(o,s)=>m(o,"name",{value:s,configurable:!0});import{defineSysBranch as t}from"./sys/branch.js";import{configBranch as f}from"./sys/config.js";import{sysEnvBranch as i}from"./sys/env.js";import{daemonBranch as e}from"./sys/daemon.js";import{sysDoctorLeaf as a}from"./sys/doctor.js";import{sysFeedbackLeaf as p}from"./sys/feedback.js";import{sysLogsLeaf as n}from"./sys/logs.js";import{sysRetryDeliveryLeaf as y}from"./sys/retry-delivery.js";import{sysWorktreesLeaf as c}from"./sys/worktrees.js";import{sysSpacesLeaf as L}from"./sys/spaces.js";import{sysLimitsBranch as h}from"./sys/limits.js";import{sysSpendBranch as B}from"./sys/spend.js";import{sysSettingsLeaf as S}from"./sys/settings.js";import{sysSetupLeaf as g}from"./sys/setup.js";import{tutorialBranch as u}from"./sys/tutorial/branch.js";import{supportBranch as d}from"./sys/support.js";import{contextBranch as k}from"./sys/context.js";import{sysSyncBranch as D}from"./sys/sync.js";import{sysJoinLeaf as l}from"./sys/join.js";import{sysMachineBranch as v}from"./sys/machine/rotate.js";import{sysDesktopBranch as x}from"./sys/desktop.js";import{sysSigninLeaf as b,sysSignoutLeaf as E}from"./sys/signin.js";import{sysUpdateLeaf as F,sysVersionLeaf as J}from"./sys/update.js";function $(){return t([S,f,i,g,u,a,k,p,n,c,y,L,h,B,d,F,J,l,D,v,b,E,x,e])}r($,"registerSys");export{$ as registerSys};
1
+ var m=Object.defineProperty;var r=(o,s)=>m(o,"name",{value:s,configurable:!0});import{defineSysBranch as t}from"./sys/branch.js";import{configBranch as f}from"./sys/config.js";import{sysEnvBranch as i}from"./sys/env.js";import{daemonBranch as e}from"./sys/daemon.js";import{sysDoctorLeaf as a}from"./sys/doctor.js";import{sysFeedbackLeaf as p}from"./sys/feedback.js";import{sysLogsLeaf as n}from"./sys/logs.js";import{sysRetryDeliveryLeaf as y}from"./sys/retry-delivery.js";import{sysWorktreesLeaf as c}from"./sys/worktrees.js";import{sysSpacesLeaf as L}from"./sys/spaces.js";import{sysLimitsBranch as h}from"./sys/limits.js";import{sysSpendBranch as B}from"./sys/spend.js";import{sysSettingsLeaf as S}from"./sys/settings.js";import{sysSetupLeaf as g}from"./sys/setup.js";import{tutorialBranch as u}from"./sys/tutorial/branch.js";import{supportBranch as d}from"./sys/support.js";import{contextBranch as k}from"./sys/context.js";import{sysSyncBranch as D}from"./sys/sync.js";import{sysMachineBranch as l}from"./sys/machine/rotate.js";import{sysDesktopBranch as v}from"./sys/desktop.js";import{sysSigninLeaf as x,sysSignoutLeaf as b}from"./sys/signin.js";import{sysUpdateLeaf as E,sysVersionLeaf as F}from"./sys/update.js";function Z(){return t([S,f,i,g,u,a,k,p,n,c,y,L,h,B,d,E,F,D,l,x,b,v,e])}r(Z,"registerSys");export{Z as registerSys};