@north-light/cli 0.3.666 → 0.3.667

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.
@@ -1,5 +1,5 @@
1
1
  /** The contract level this build serves and requires. Written by `scripts/contract.mjs release`; never edit by hand. */
2
- export declare const CONTRACT_LEVEL = "1.56";
2
+ export declare const CONTRACT_LEVEL = "1.57";
3
3
  /** Request header naming the one contract level the caller needs, e.g. `1.3`. Optional: absent means no check. */
4
4
  export declare const REQUIRED_CONTRACT_HEADER = "Crouter-Required-Contract";
5
5
  /** Response header listing the contract levels the server serves, comma-separated, one per major, e.g. `1.3`. */
@@ -1 +1 @@
1
- var c=Object.defineProperty;var e=(r,t)=>c(r,"name",{value:t,configurable:!0});const f="1.56",i="Crouter-Required-Contract",p="Crouter-Contract";function l(r){const t=/^(\d+)\.(\d+)$/.exec(r.trim());return t===null?null:{major:Number(t[1]),minor:Number(t[2])}}e(l,"parseContractLevel");function a(r){return r==null?[]:r.split(",").map(t=>l(t)).filter(t=>t!==null)}e(a,"parseServedContracts");function s(r,t){const n=l(r);return n===null?!1:(typeof t=="string"||t===null||t===void 0?a(t):t).some(u=>u.major===n.major&&u.minor>=n.minor)}e(s,"contractSatisfies");function C(r,t,n={}){if(r===void 0)return null;if(l(r)===null)return{status:400,code:"invalid_request",param:i,message:`${i} must be a contract level like 1.0.`};if(s(r,t))return null;const o=r.trim();return{status:426,code:"runtime_version_unsupported",message:t===null||a(t).length===0?`The runtime did not name its contract level; the caller requires contract ${o} or later. Roll the runtime forward.`:`The runtime serves contract ${t}; the caller requires contract ${o} or later within the same major. Roll the runtime forward, or pin an SDK whose crouterContract the runtime serves.`,details:{sdk_version:(n.legacyMinimum??"").trim(),runtime_version:n.runtimeVersion??null,required_contract:o,runtime_contract:t}}}e(C,"contractRefusal");export{p as CONTRACT_HEADER,f as CONTRACT_LEVEL,i as REQUIRED_CONTRACT_HEADER,C as contractRefusal,s as contractSatisfies,l as parseContractLevel,a as parseServedContracts};
1
+ var c=Object.defineProperty;var e=(r,t)=>c(r,"name",{value:t,configurable:!0});const f="1.57",i="Crouter-Required-Contract",p="Crouter-Contract";function l(r){const t=/^(\d+)\.(\d+)$/.exec(r.trim());return t===null?null:{major:Number(t[1]),minor:Number(t[2])}}e(l,"parseContractLevel");function a(r){return r==null?[]:r.split(",").map(t=>l(t)).filter(t=>t!==null)}e(a,"parseServedContracts");function s(r,t){const n=l(r);return n===null?!1:(typeof t=="string"||t===null||t===void 0?a(t):t).some(u=>u.major===n.major&&u.minor>=n.minor)}e(s,"contractSatisfies");function C(r,t,n={}){if(r===void 0)return null;if(l(r)===null)return{status:400,code:"invalid_request",param:i,message:`${i} must be a contract level like 1.0.`};if(s(r,t))return null;const o=r.trim();return{status:426,code:"runtime_version_unsupported",message:t===null||a(t).length===0?`The runtime did not name its contract level; the caller requires contract ${o} or later. Roll the runtime forward.`:`The runtime serves contract ${t}; the caller requires contract ${o} or later within the same major. Roll the runtime forward, or pin an SDK whose crouterContract the runtime serves.`,details:{sdk_version:(n.legacyMinimum??"").trim(),runtime_version:n.runtimeVersion??null,required_contract:o,runtime_contract:t}}}e(C,"contractRefusal");export{p as CONTRACT_HEADER,f as CONTRACT_LEVEL,i as REQUIRED_CONTRACT_HEADER,C as contractRefusal,s as contractSatisfies,l as parseContractLevel,a as parseServedContracts};
@@ -129,6 +129,8 @@ export interface NodeSummaryDTO {
129
129
  telemetry_last_activity?: string | null;
130
130
  /** Timestamp of the latest broker telemetry update. */
131
131
  telemetry_updated_at?: IsoTime | null;
132
+ /** When the node's last turn ended; null before its first turn ends. */
133
+ last_settled_at?: IsoTime | null;
132
134
  outcome: NodeOutcomeSummaryDTO | null;
133
135
  fault?: NodeFaultDTO | null;
134
136
  streaming?: boolean;
@@ -4,7 +4,7 @@ when-and-why-to-read: When a node has no immediate action because it awaits an e
4
4
  rationale: >-
5
5
  "Waiting is a way to end a turn" lived in its own ungated all-node doc until 2026-07-28. Same gate, same audience, never independently readable — so the split bought no routing and cost a stub cross-reference in runtime-base pointing at a section spliced a few hundred tokens later. It now has its own sort position as the turn-lifecycle preamble; split it again only when a section needs its own sort position, incident rationale, or independent deletion/re-gate decision.
6
6
 
7
- "Never end on a promise" exists because deep into long sessions models occasionally end a turn on a text-only statement of intent without the corresponding tool call; the check-your-last-paragraph form is the operational trigger the Fable 5 guidance validated (adopted 2026-08-22, Silas).
7
+ "Never end on a promise" exists because deep into long sessions models occasionally end a turn on a text-only statement of intent without the corresponding tool call; the check-your-last-paragraph form is the operational trigger the Fable 5 guidance validated (adopted 2026-08-22, Silas). The ordinary-obstacles paragraph was added on 2026-11-11 (Silas) from the Fable 5.2 guidance, which reports that model ending turns at errors and timeouts it could have worked through.
8
8
 
9
9
  Yield applies to every node regardless of mode; promotion does not, because only the mode layers own that boundary — 04-base-worker for when a base node should promote, the kernel for how an orchestrator uses promotion — so restating it in the universal layer duplicated the base-worker text for an audience that includes nodes it does not apply to.
10
10
  lint-ignore: length
@@ -24,5 +24,7 @@ When your goal is sound but your next step is blocked on something that has not
24
24
  ## Never end on a promise
25
25
  Before you stop, check your last paragraph. If it is a plan, a list of next steps, or a promise about work you have not done ("I'll now…"), that is not an ending — do that work now with tool calls. End your turn only when the work is complete, you are waiting, or you are blocked on input only a person can provide.
26
26
 
27
+ An error, a timeout, a locked file, an empty result, or a failing tool is not a reason to stop. Diagnose it, then work through it with the access you have: wait and retry, fix the request, or use another tool or source. A blocker that someone put there on purpose — a file marked not to be touched, access that was withheld, a safety guardrail — stays in place: say what you found, and finish the task another way if a safe one exists.
28
+
27
29
  ## Context reminders
28
30
  The runtime sends you private reminders as your context fills. The person can't see your context, so never mention it to them. When you judge a fresh start would help, see `crtr node yield -h`: you revive as the same node with the same mandate, carrying a note to your future self.
@@ -3,11 +3,11 @@ kind: preference
3
3
  when-and-why-to-read: When a node runs in base mode on any kind but explore, this preference should be read so orientation noise lands in a scout's window and comes back as a clean map instead of silting the context this node's real work runs in.
4
4
  gate: {mode: base, not: {kind: explore}}
5
5
  rationale: >-
6
- Split from 04-base-worker: gated {mode: base} alone, this section told an explore base node to spawn an explore scout for its own assignment — circular, and in tension with kinds/explore/base's narrower promote-only rule. The section itself exists because the kernel's "understand before you delegate" line is orchestrator-gated, so base workers had no counterweight to mapping unfamiliar code in their own window: they spent their context on read-only exploration and yielded before the real work. The operative mechanism is context, not model-tier economics (Silas, 2026-08-30): exploration residue — dead ends, half-relevant files — degrades the window it lands in, so the scout's job is to absorb that noise and return a distilled map every later node, the spawner included, loads clean. The body avoids "weigh/consider/decide" verbs deliberately: an instruction to perform a cognitive act gets narrated ("I considered a scout and…"), so the always-consider behavior is carried structurally — spawn is the unmarked default, skip is gated behind an exception test models apply silently.
6
+ Split from 04-base-worker: gated {mode: base} alone, this section told an explore base node to spawn an explore scout for its own assignment — circular, and in tension with kinds/explore/base's narrower promote-only rule. The section itself exists because the kernel's "understand before you delegate" line is orchestrator-gated, so base workers had no counterweight to mapping unfamiliar code in their own window: they spent their context on read-only exploration and yielded before the real work. The operative mechanism is context, not model-tier economics (Silas, 2026-08-30): exploration residue — dead ends, half-relevant files — degrades the window it lands in, so the scout's job is to absorb that noise and return a distilled map every later node, the spawner included, loads clean. The body avoids "weigh/consider/decide" verbs deliberately: an instruction to perform a cognitive act gets narrated ("I considered a scout and…"), so the always-consider behavior is carried structurally — spawn is the unmarked default, skip is gated behind an exception test models apply silently. The exception was widened and the scout's cost stated on 2026-11-11 (Silas), following the Fable 5.2 prompting guidance that standing instructions to delegate make that model start more subagents than the task needs; the unsupported claim that a scout does a more thorough job was removed with it.
7
7
  surfaces:
8
8
  - on: boot
9
9
  at: content
10
10
  ---
11
11
 
12
12
  ## Exploring
13
- Fresh work on a surface you do not yet understand — a codebase, a system, a domain — starts with an `explore` node to chart it (`crtr node -h`), with `--mode orchestrate` when the surface is large or there are multiple questions. Charting it yourself bloats your context window; a scout spends its own window and hands back a distilled map or answer, and it will do a more thorough job. Skip the scout only when you already know the surface or it is small enough to read directly — waiting on one for a two-file change costs more than it saves.
13
+ Fresh work on a surface you do not yet understand and cannot read in a few files — a codebase, a system, a domain — starts with an `explore` node to chart it (`crtr node -h`), with `--mode orchestrate` when the surface is large or there are multiple questions. The dead ends and half-relevant files of exploration stay in the window that read them; a scout keeps them in its own window and hands back a distilled map or answer. A scout costs a full window of tokens and a wait for its report, so read the surface yourself when you already know it, when you can name the files to open, or when the answer sits in a handful of files.
@@ -35,9 +35,17 @@ export interface CanvasPanelLines {
35
35
  /** Actionable cockpit rows. Enter swaps nodes or opens the matching wait detail surface. */
36
36
  items: CanvasPanelItem[];
37
37
  }
38
+ /** What the nodes on the manager and report rows are waiting on. Omitted for a remote attach. */
39
+ export interface OtherNodeWaits {
40
+ /** Every armed cron the caller may see; rows pick theirs by `created_by`. */
41
+ crons: readonly CronDTO[];
42
+ /** Every open review; rows pick theirs by `origin_node_id`. */
43
+ reviews: readonly ReviewDTO[];
44
+ jobsOf(nodeId: string): Promise<readonly BashJobStatus[]>;
45
+ }
38
46
  /** Build the BASE panel line stacks for `nodeId`. `asks` is the per-node
39
47
  * pending human-ticket count map the caller polls (page/review); pass
40
48
  * `{}` to omit the ⚑ badges. `crons` are this node's armed schedules.
41
49
  * `palette`
42
50
  * drives the headers + dim cells; omit it and the panels render uncolored. */
43
- export declare function buildCanvasPanelLines(nodeId: string, asks: Record<string, number>, palette: AttachPalette | undefined, source: CanvasSource, crons?: readonly CronDTO[], jobs?: readonly BashJobStatus[], reviews?: readonly ReviewDTO[]): Promise<CanvasPanelLines>;
51
+ export declare function buildCanvasPanelLines(nodeId: string, asks: Record<string, number>, palette: AttachPalette | undefined, source: CanvasSource, crons?: readonly CronDTO[], jobs?: readonly BashJobStatus[], reviews?: readonly ReviewDTO[], others?: OtherNodeWaits): Promise<CanvasPanelLines>;
@@ -1 +1 @@
1
- var Y=Object.defineProperty;var i=(s,a)=>Y(s,"name",{value:a,configurable:!0});import{navLabel as H,nodeGlyph as Z,truncate as nn,tokensCell as tn,cycleBadge as en,askBadge as on,activityCell as sn,fillWidth as M,RESET as m,DIM as an,GREEN as cn}from"../../../core/canvas/nav-render.js";const rn=34,dn=30,un=40;import{RemoteCanvasSource as ln}from"../../../core/canvas/remote-canvas-source.js";import{cronWaitSummary as fn}from"./cron-wait.js";import{bashJobsWaitSummary as mn}from"./bash-jobs.js";import{reviewWaitSummary as hn}from"./review-wait.js";import{objectWaitSummary as wn}from"./object-wait.js";const $n=12,pn=6,P=22;function D(s,a){return s.length>a?`${s.slice(0,a-1)}\u2026`:s+" ".repeat(a-s.length)}i(D,"nameCell");function gn(s,a){return s.length>=a?s.slice(0,a):" ".repeat(a-s.length)+s}i(gn,"padStartVisible");async function Rn(s,a,c,f,T=[],O=[],F=[]){const R=f instanceof ln,h=await f.panelRoster?.(),$=h===void 0?null:new Map(h.nodes.map(n=>[n.node_id,n])),y=new Map,_=new Map;if(h!==void 0)for(const n of h.edges){const t=y.get(n.from_id)??[];t.push(n.to_id),y.set(n.from_id,t),_.has(n.to_id)||_.set(n.to_id,n.from_id)}const W=new Map,C=new Map,S=new Map,p=i(n=>{const t=W.get(n);if(t!==void 0)return t;const e=$===null?f.getNode(n).catch(()=>null):Promise.resolve($.get(n)??null);return W.set(n,e),e},"node"),G=i(n=>f.getNode(n).catch(()=>null),"detail"),v=i(n=>{const t=C.get(n);if(t!==void 0)return t;const e=(async()=>{const o=$===null?(await f.subscriptionsOf(n).catch(()=>[])).map(r=>r.node_id):y.get(n)??[],l=[];for(const r of o)(await p(r))?.kind!=="human"&&l.push(r);return l})();return C.set(n,e),e},"convoChildIds"),E=i(n=>{const t=S.get(n);if(t!==void 0)return t;const e=$===null?f.subscribersOf(n).then(o=>o[0]?.node_id).catch(()=>{}):Promise.resolve(_.get(n));return S.set(n,e),e},"managerOf"),J=i(async n=>{const t=[];for(const e of await v(n)){const o=(await p(e))?.status;(o==="active"||o==="idle")&&t.push(e)}return t},"liveReports"),K=i(async n=>{let t=n;const e=new Set([t]);for(;;){const o=await E(t);if(o===void 0||e.has(o))break;e.add(o),t=o}return t},"climbRoot"),I=new Map,L=i(async n=>{const t=new Set,e=i(async o=>{const l=(await p(o))?.status==="active";if(t.has(o))return l?1:0;t.add(o);let r=0;for(const k of await v(o))r+=await e(k);return I.set(o,r),r+(l?1:0)},"visit");await e(n)},"computeActivity"),V=i(async n=>{if(n===null||n.mode!=="orchestrator")return"";const t=(await v(n.node_id)).length;return t>0?` ${an}\u2933${t}${m}`:""},"childBadgeFor"),q=i(n=>{if(n===null||n.status==="active")return"";const t=I.get(n.node_id)??0;return t>0?` ${cn}\u21E3${t}${m}`:""},"liveBelowBadgeFor"),w=c?.muted??(n=>n),z=c?.faint??(n=>n);await L(await K(s));const d=await E(s),b=await J(s),g=[...d!==void 0?[d]:[],...b],B=await Promise.all(g.map(async n=>await G(n)??await p(n))),Q=g.length>0?Math.min(P,Math.max(...g.map((n,t)=>H(B[t]??null,n).length))):P,N=i(async(n,t)=>{const e=B[g.indexOf(n)]??null,o=D(H(e,n),Q),l=z(D(e?.kind??"",$n)),r=w(gn(tn(e,R),pn)),k=`${en(e)}${await V(e)}${q(e)}${on(n,a)}${sn(e,R)}`,X=` ${t} ${Z(e)} ${o} ${l} ${r}${k}`;return nn(X)},"row"),U=[...d!==void 0?[d]:[],...b],u=[];d!==void 0&&u.push({key:`node:${d}`,kind:"node",nodeId:d,line:await N(d,"\u2191")});for(const n of b)u.push({key:`node:${n}`,kind:"node",nodeId:n,line:await N(n,"\u2193")});for(const n of F){const t=c?c.info("\u270E"):"\u270E",e=hn(n,Math.max(8,M()-un));u.push({key:`review:${n.review_id}`,kind:"review",companionNodeId:n.companion_node_id,line:` ${t} ${w(`${e} \xB7 \u21B5 companion`)}${m}`})}const j=O.length===1?" \xB7 x stop":"",x=mn(O,Date.now(),M()-(rn+j.length));if(x!==void 0){const n=c?c.info("\u2699"):"\u2699";u.push({key:"bash",kind:"bash",line:` ${n} ${w(`${x} \xB7 \u21B5 details${j}`)}${m}`})}const A=fn(T);if(A!==void 0){const n=c?c.info("\u25F7"):"\u25F7";u.push({key:"crons",kind:"crons",line:` ${n} ${w(`${A} \xB7 \u21B5 details`)}${m}`})}for(const n of h?.object_waits??[]){if(n.node_id!==s)continue;const t=c?c.info("\u25C7"):"\u25C7",e=wn(n,Date.now(),Math.max(8,M()-dn));u.push({key:`object:${n.object_id}`,kind:"object-wait",objectId:n.object_id,line:` ${t} ${w(`${e} \xB7 \u21B5 details`)}${m}`})}return{reports:u.map(n=>n.line),reportIds:U,items:u}}i(Rn,"buildCanvasPanelLines");export{Rn as buildCanvasPanelLines};
1
+ var dn=Object.defineProperty;var i=(s,a)=>dn(s,"name",{value:a,configurable:!0});import{navLabel as K,nodeGlyph as un,truncate as ln,tokensCell as fn,cycleBadge as mn,askBadge as hn,fillWidth as W,RESET as m,DIM as C,GREEN as pn}from"../../../core/canvas/nav-render.js";const wn=34,$n=30,gn=40;import{RemoteCanvasSource as _n}from"../../../core/canvas/remote-canvas-source.js";import{cronWaitSummary as L}from"./cron-wait.js";import{bashJobsWaitSummary as V}from"./bash-jobs.js";import{reviewWaitSummary as yn}from"./review-wait.js";import{objectWaitSummary as q}from"./object-wait.js";import{formatBashElapsed as bn}from"../../../core/bash-jobs.js";const z=i((s,a)=>{const c=s==null?Number.NaN:Date.parse(s);return Number.isNaN(c)?void 0:bn(a-c)},"since"),vn=12,kn=6,Q=22;function U(s,a){return s.length>a?`${s.slice(0,a-1)}\u2026`:s+" ".repeat(a-s.length)}i(U,"nameCell");function Mn(s,a){return s.length>=a?s.slice(0,a):" ".repeat(a-s.length)+s}i(Mn,"padStartVisible");async function Bn(s,a,c,h,X=[],E=[],Y=[],y){const S=h instanceof _n,p=await h.panelRoster?.(),b=p===void 0?null:new Map(p.nodes.map(n=>[n.node_id,n])),M=new Map,N=new Map;if(p!==void 0)for(const n of p.edges){const t=M.get(n.from_id)??[];t.push(n.to_id),M.set(n.from_id,t),N.has(n.to_id)||N.set(n.to_id,n.from_id)}const B=new Map,I=new Map,x=new Map,v=i(n=>{const t=B.get(n);if(t!==void 0)return t;const e=b===null?h.getNode(n).catch(()=>null):Promise.resolve(b.get(n)??null);return B.set(n,e),e},"node"),Z=i(n=>h.getNode(n).catch(()=>null),"detail"),O=i(n=>{const t=I.get(n);if(t!==void 0)return t;const e=(async()=>{const o=b===null?(await h.subscriptionsOf(n).catch(()=>[])).map(r=>r.node_id):M.get(n)??[],d=[];for(const r of o)(await v(r))?.kind!=="human"&&d.push(r);return d})();return I.set(n,e),e},"convoChildIds"),A=i(n=>{const t=x.get(n);if(t!==void 0)return t;const e=b===null?h.subscribersOf(n).then(o=>o[0]?.node_id).catch(()=>{}):Promise.resolve(N.get(n));return x.set(n,e),e},"managerOf"),D=i(async n=>{const t=[];for(const e of await O(n)){const o=(await v(e))?.status;(o==="active"||o==="idle")&&t.push(e)}return t},"liveReports"),nn=i(async n=>{let t=n;const e=new Set([t]);for(;;){const o=await A(t);if(o===void 0||e.has(o))break;e.add(o),t=o}return t},"climbRoot"),H=new Map,tn=i(async n=>{const t=new Set,e=i(async o=>{const d=(await v(o))?.status==="active";if(t.has(o))return d?1:0;t.add(o);let r=0;for(const w of await O(o))r+=await e(w);return H.set(o,r),r+(d?1:0)},"visit");await e(n)},"computeActivity"),en=i(async n=>{if(n===null||n.mode!=="orchestrator")return"";const t=(await O(n.node_id)).length;return t>0?` ${C}\u2933${t}${m}`:""},"childBadgeFor"),on=i(n=>{if(n===null||n.status==="active")return"";const t=H.get(n.node_id)??0;return t>0?` ${pn}\u21E3${t}${m}`:""},"liveBelowBadgeFor"),$=c?.muted??(n=>n),sn=c?.faint??(n=>n);await tn(await nn(s));const l=await A(s),j=await D(s),k=[...l!==void 0?[l]:[],...j],P=await Promise.all(k.map(async n=>await Z(n)??await v(n))),an=k.length>0?Math.min(Q,Math.max(...k.map((n,t)=>K(P[t]??null,n).length))):Q,cn=i(async(n,t)=>{if(S||t===null||t.status!=="active"&&t.status!=="idle")return"";const e=Date.now();if(t.streaming===!0){const g=[(t.telemetry_last_activity??"").trim(),z(t.telemetry_updated_at,e)].filter(_=>_!==void 0&&_!=="");return g.length===0?"":` ${C}\xB7 ${g.join(" \xB7 ")}${m}`}const o=[],d=(await D(n)).length;if(d>0&&o.push(d===1?"1 child":`${d} children`),(a[n]??0)>0&&o.push("you"),y!==void 0){y.reviews.some(R=>R.origin_node_id===n)&&o.push("review");const u=await y.jobsOf(n).catch(()=>null),g=u===null?"bash jobs (could not read)":V(u,e,20);g!==void 0&&o.push(g.replace(/ · /g," "));const _=L(y.crons.filter(R=>R.created_by===n),e);_!==void 0&&o.push(_.replace(/ · /g," "))}for(const u of p?.object_waits??[])u.node_id===n&&o.push(q(u,e,20).replace(/ · /g," "));const r=z(t.last_settled_at,e),w=[r===void 0?void 0:`turn ended ${r} ago`,o.length===0?void 0:`waiting on ${o.join(", ")}`].filter(u=>u!==void 0);return w.length===0?"":` ${C}\xB7 ${w.join(" \xB7 ")}${m}`},"stateCell"),T=i(async(n,t)=>{const e=P[k.indexOf(n)]??null,o=U(K(e,n),an),d=sn(U(e?.kind??"",vn)),r=$(Mn(fn(e,S),kn)),w=`${mn(e)}${await en(e)}${on(e)}${hn(n,a)}${await cn(n,e)}`,u=` ${t} ${un(e)} ${o} ${d} ${r}${w}`;return ln(u)},"row"),rn=[...l!==void 0?[l]:[],...j],f=[];l!==void 0&&f.push({key:`node:${l}`,kind:"node",nodeId:l,line:await T(l,"\u2191")});for(const n of j)f.push({key:`node:${n}`,kind:"node",nodeId:n,line:await T(n,"\u2193")});for(const n of Y){const t=c?c.info("\u270E"):"\u270E",e=yn(n,Math.max(8,W()-gn));f.push({key:`review:${n.review_id}`,kind:"review",companionNodeId:n.companion_node_id,line:` ${t} ${$(`${e} \xB7 \u21B5 companion`)}${m}`})}const F=E.length===1?" \xB7 x stop":"",G=V(E,Date.now(),W()-(wn+F.length));if(G!==void 0){const n=c?c.info("\u2699"):"\u2699";f.push({key:"bash",kind:"bash",line:` ${n} ${$(`${G} \xB7 \u21B5 details${F}`)}${m}`})}const J=L(X);if(J!==void 0){const n=c?c.info("\u25F7"):"\u25F7";f.push({key:"crons",kind:"crons",line:` ${n} ${$(`${J} \xB7 \u21B5 details`)}${m}`})}for(const n of p?.object_waits??[]){if(n.node_id!==s)continue;const t=c?c.info("\u25C7"):"\u25C7",e=q(n,Date.now(),Math.max(8,W()-$n));f.push({key:`object:${n.object_id}`,kind:"object-wait",objectId:n.object_id,line:` ${t} ${$(`${e} \xB7 \u21B5 details`)}${m}`})}return{reports:f.map(n=>n.line),reportIds:rn,items:f}}i(Bn,"buildCanvasPanelLines");export{Bn as buildCanvasPanelLines};
@@ -1,6 +1,6 @@
1
- var q=Object.defineProperty;var s=(y,n)=>q(y,"name",{value:n,configurable:!0});import{execFile as _}from"node:child_process";import{Text as J,decodeKittyPrintable as O,matchesKey as N}from"@earendil-works/pi-tui";import{cliClient as w}from"../../../commands/api-client.js";import{focusNode as H}from"../../../core/runtime/focus-viewer.js";import{daemonErrorMessage as j}from"../../inbox/resolve.js";import{toBashJobStatus as U}from"./bash-jobs.js";import{fillBar as k,fillWidth as X,stripSgr as D,REVERSE as F}from"../../../core/canvas/nav-render.js";import{buildCanvasPanelLines as L}from"./canvas-panels.js";const V=15e3;function oe(y,n){const{editor:S,tui:$,pal:x,nodeId:f,remote:p,role:C,canvasSource:E}=y,I=y.containers.reports;let c=[],o,g=process.env.CRTR_ATTACH_ROSTER;g!==void 0&&delete process.env.CRTR_ATTACH_ROSTER;let u,v;const m=s(()=>{n.syncCursor(),I.clear();for(const e of c){const t=e.key===o;I.addChild(new J(t?k(D(e.line),X(),F):e.line,1,0))}$.requestRender()},"paint"),R=s(async()=>(await w().listBashJobs(f)).map(U),"listJobs"),K=s(async()=>{const e=p?[]:(await w().listCrons({created_by:f})).filter(r=>r.created_by===f),t=p?[]:await R(),d=p?[]:(await w().listReviews({state:"open",origin_node_id:f})).reviews;if(c=(await L(f,n.asks(),x,E,e,t,d)).items,g!==void 0){const r=g;g=void 0;const a=c.find(h=>h.kind==="node"&&h.nodeId===r);a!==void 0&&(o=a.key)}o!==void 0&&!c.some(r=>r.key===o)&&(o=void 0),u!==void 0&&!t.some(r=>r.jobId===u?.jobId)&&b(!0),m()},"refresh"),b=s(e=>{v!==void 0&&(clearTimeout(v),v=void 0),u!==void 0&&(u=void 0,e&&n.setNotice(""))},"disarmKill"),l=s(()=>{b(!0),o!==void 0&&(o=void 0,m())},"exit"),T=s(e=>O(e)??(e.length===1?e:void 0),"typed"),A=s((e,t=40)=>{const d=(e.split(`
2
- `)[0]??"").replace(/\s+/g," ").trim();return d.length>t?`${d.slice(0,t-1)}\u2026`:d},"commandHead"),B=s(async()=>{if(C!=="controller"){n.setNotice("Read-only observer attach \u2014 cannot stop background jobs");return}const e=await R();if(e.length===0){n.setNotice("Background job already finished"),n.requestChromeRefresh();return}if(e.length>1){n.setNotice(`${e.length} background jobs \u2014 press \u21B5 to pick one in the Inspector`);return}const t=e[0];u={jobId:t.jobId,label:A(t.command)},n.setNotice(`Stop \u201C${u.label}\u201D? Press y to confirm.`,{sticky:!0}),v=setTimeout(()=>b(!0),V)},"armKill"),M=s(()=>{const e=u;e!==void 0&&(b(!1),n.setNotice(`Stopping \u201C${e.label}\u201D\u2026`),_("crtr",["node","bash","kill",e.jobId,"--node",f],t=>{n.setNotice(t===null?`Stopped \u201C${e.label}\u201D.`:`Could not stop the job: ${t.message.split(`
3
- `)[0]}`),n.requestChromeRefresh()}))},"confirmKill");S.onCursorDownAtBottom=p?void 0:()=>{o!==void 0||c.length===0||(o=c[0].key,m())};const P=s(()=>{const e=c.find(i=>i.key===o);if(e===void 0||p)return;if(e.kind==="crons"){l(),n.openInspector("schedule");return}if(e.kind==="review"){if(C!=="controller"){n.setNotice("Read-only observer attach \u2014 cannot open the review companion");return}l();const i=process.env.TMUX_PANE;if(i===void 0||i===""){n.setNotice("Could not open the companion: no tmux pane");return}(async()=>{const r=w(),a=await r.getNode(e.companionNodeId);(await H(r,a,{pane:i})).focused||n.setNotice("Could not open the companion")})().catch(r=>n.setNotice(`Could not open the companion: ${j(r).split(`
4
- `)[0]}`));return}if(e.kind==="bash"){R().then(i=>{if(i.length===0){n.setNotice("Background job already finished"),n.requestChromeRefresh();return}l(),n.openInspector("jobs")},i=>n.setNotice(`Could not list background jobs: ${j(i).split(`
5
- `)[0]}`));return}if(e.kind==="object-wait"){l(),n.openObject(e.objectId);return}const t=e.nodeId;if(t===f){l();return}if(C!=="controller"){n.setNotice("Read-only observer attach \u2014 cannot focus nodes");return}const d=process.env.TMUX_PANE;if(d===void 0||d===""){n.setNotice("cannot swap \u2014 no tmux pane");return}_("tmux",["run-shell","-b",`crtr surface node focus ${t} --pane ${d} --in-place >/dev/null 2>&1`],()=>{})},"openSelected");return{refresh:K,handleKey:s(e=>{if(p)return!1;const t=N(e,"down"),d=N(e,"up");if(o===void 0)return!1;const i=c.findIndex(a=>a.key===o),r=c[i];if(u!==void 0){if(T(e)==="y")return M(),!0;b(!0)}return r?.kind==="bash"&&T(e)==="x"?(B().catch(a=>n.setNotice(`Could not list background jobs: ${j(a).split(`
6
- `)[0]}`)),!0):d?(i<=0?l():(o=c[i-1].key,m()),!0):t?(i>=0&&i<c.length-1&&(o=c[i+1].key,m()),!0):N(e,"enter")?(P(),!0):N(e,"escape")?(l(),!0):(l(),!1)},"handleKey"),active:s(()=>o!==void 0,"active"),exit:l}}s(oe,"createRoster");export{oe as createRoster};
1
+ var U=Object.defineProperty;var r=(v,n)=>U(v,"name",{value:n,configurable:!0});import{execFile as $}from"node:child_process";import{Text as k,decodeKittyPrintable as X,matchesKey as N}from"@earendil-works/pi-tui";import{cliClient as g}from"../../../commands/api-client.js";import{focusNode as D}from"../../../core/runtime/focus-viewer.js";import{daemonErrorMessage as j}from"../../inbox/resolve.js";import{toBashJobStatus as x}from"./bash-jobs.js";import{fillBar as F,fillWidth as L,stripSgr as V,REVERSE as W}from"../../../core/canvas/nav-render.js";import{buildCanvasPanelLines as z}from"./canvas-panels.js";const G=15e3;function ce(v,n){const{editor:E,tui:K,pal:A,nodeId:m,remote:f,role:R,canvasSource:B}=v,I=v.containers.reports;let s=[],o,w=process.env.CRTR_ATTACH_ROSTER;w!==void 0&&delete process.env.CRTR_ATTACH_ROSTER;let u,h;const b=r(()=>{n.syncCursor(),I.clear();for(const e of s){const i=e.key===o;I.addChild(new k(i?F(V(e.line),L(),W):e.line,1,0))}K.requestRender()},"paint"),C=r(async()=>(await g().listBashJobs(m)).map(x),"listJobs"),M=r(async()=>{const e=f?[]:await g().listCrons(),i=e.filter(d=>d.created_by===m),c=f?[]:await C(),t=f?[]:(await g().listReviews({state:"open"})).reviews,a=t.filter(d=>d.origin_node_id===m),p=f?void 0:{crons:e,reviews:t,jobsOf:r(async d=>(await g().listBashJobs(d)).map(x),"jobsOf")};if(s=(await z(m,n.asks(),A,B,i,c,a,p)).items,w!==void 0){const d=w;w=void 0;const S=s.find(_=>_.kind==="node"&&_.nodeId===d);S!==void 0&&(o=S.key)}o!==void 0&&!s.some(d=>d.key===o)&&(o=void 0),u!==void 0&&!c.some(d=>d.jobId===u?.jobId)&&y(!0),b()},"refresh"),y=r(e=>{h!==void 0&&(clearTimeout(h),h=void 0),u!==void 0&&(u=void 0,e&&n.setNotice(""))},"disarmKill"),l=r(()=>{y(!0),o!==void 0&&(o=void 0,b())},"exit"),T=r(e=>X(e)??(e.length===1?e:void 0),"typed"),P=r((e,i=40)=>{const c=(e.split(`
2
+ `)[0]??"").replace(/\s+/g," ").trim();return c.length>i?`${c.slice(0,i-1)}\u2026`:c},"commandHead"),J=r(async()=>{if(R!=="controller"){n.setNotice("Read-only observer attach \u2014 cannot stop background jobs");return}const e=await C();if(e.length===0){n.setNotice("Background job already finished"),n.requestChromeRefresh();return}if(e.length>1){n.setNotice(`${e.length} background jobs \u2014 press \u21B5 to pick one in the Inspector`);return}const i=e[0];u={jobId:i.jobId,label:P(i.command)},n.setNotice(`Stop \u201C${u.label}\u201D? Press y to confirm.`,{sticky:!0}),h=setTimeout(()=>y(!0),G)},"armKill"),O=r(()=>{const e=u;e!==void 0&&(y(!1),n.setNotice(`Stopping \u201C${e.label}\u201D\u2026`),$("crtr",["node","bash","kill",e.jobId,"--node",m],i=>{n.setNotice(i===null?`Stopped \u201C${e.label}\u201D.`:`Could not stop the job: ${i.message.split(`
3
+ `)[0]}`),n.requestChromeRefresh()}))},"confirmKill");E.onCursorDownAtBottom=f?void 0:()=>{o!==void 0||s.length===0||(o=s[0].key,b())};const q=r(()=>{const e=s.find(t=>t.key===o);if(e===void 0||f)return;if(e.kind==="crons"){l(),n.openInspector("schedule");return}if(e.kind==="review"){if(R!=="controller"){n.setNotice("Read-only observer attach \u2014 cannot open the review companion");return}l();const t=process.env.TMUX_PANE;if(t===void 0||t===""){n.setNotice("Could not open the companion: no tmux pane");return}(async()=>{const a=g(),p=await a.getNode(e.companionNodeId);(await D(a,p,{pane:t})).focused||n.setNotice("Could not open the companion")})().catch(a=>n.setNotice(`Could not open the companion: ${j(a).split(`
4
+ `)[0]}`));return}if(e.kind==="bash"){C().then(t=>{if(t.length===0){n.setNotice("Background job already finished"),n.requestChromeRefresh();return}l(),n.openInspector("jobs")},t=>n.setNotice(`Could not list background jobs: ${j(t).split(`
5
+ `)[0]}`));return}if(e.kind==="object-wait"){l(),n.openObject(e.objectId);return}const i=e.nodeId;if(i===m){l();return}if(R!=="controller"){n.setNotice("Read-only observer attach \u2014 cannot focus nodes");return}const c=process.env.TMUX_PANE;if(c===void 0||c===""){n.setNotice("cannot swap \u2014 no tmux pane");return}$("tmux",["run-shell","-b",`crtr surface node focus ${i} --pane ${c} --in-place >/dev/null 2>&1`],()=>{})},"openSelected");return{refresh:M,handleKey:r(e=>{if(f)return!1;const i=N(e,"down"),c=N(e,"up");if(o===void 0)return!1;const t=s.findIndex(p=>p.key===o),a=s[t];if(u!==void 0){if(T(e)==="y")return O(),!0;y(!0)}return a?.kind==="bash"&&T(e)==="x"?(J().catch(p=>n.setNotice(`Could not list background jobs: ${j(p).split(`
6
+ `)[0]}`)),!0):c?(t<=0?l():(o=s[t-1].key,b()),!0):i?(t>=0&&t<s.length-1&&(o=s[t+1].key,b()),!0):N(e,"enter")?(q(),!0):N(e,"escape")?(l(),!0):(l(),!1)},"handleKey"),active:r(()=>o!==void 0,"active"),exit:l}}r(ce,"createRoster");export{ce as createRoster};