@north-light/cli 0.3.721 → 0.3.723

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 (49) hide show
  1. package/dist/api/dto/recovery.d.ts +2 -0
  2. package/dist/builtin-memory/internal/plugins.md +3 -3
  3. package/dist/clients/attach/viewer.js +1 -1
  4. package/dist/commands/node/inspect.js +7 -7
  5. package/dist/commands/pkg/browse/model.d.ts +1 -1
  6. package/dist/commands/profile/environment.js +2 -2
  7. package/dist/commands/sys/setup-core.d.ts +1 -1
  8. package/dist/commands/sys/setup-core.js +6 -6
  9. package/dist/commands/sys/setup.js +1 -1
  10. package/dist/core/canvas/schema-pg/032-model-cooldown-vendor-limit.sql +4 -0
  11. package/dist/core/canvas/schema-version.d.ts +1 -1
  12. package/dist/core/canvas/schema-version.js +1 -1
  13. package/dist/core/environment-starter-script.d.ts +1 -0
  14. package/dist/core/environment-starter-script.js +58 -0
  15. package/dist/core/llm/run.js +2 -2
  16. package/dist/core/managed-providers.d.ts +9 -1
  17. package/dist/core/preview-registry.js +3 -3
  18. package/dist/core/provider-failure.d.ts +2 -0
  19. package/dist/core/provider-failure.js +1 -1
  20. package/dist/core/runtime/broker/model-adapter.js +3 -3
  21. package/dist/core/runtime/revive.d.ts +2 -0
  22. package/dist/core/runtime/revive.js +2 -2
  23. package/dist/core/runtime/runner/blaxel/image-build.d.ts +3 -0
  24. package/dist/core/runtime/runner/blaxel/image-build.js +6 -6
  25. package/dist/core/subscription-state.d.ts +4 -4
  26. package/dist/core/subscription-state.js +1 -1
  27. package/dist/daemon/api/handlers/messages.js +2 -2
  28. package/dist/daemon/api/handlers/nodes.js +1 -1
  29. package/dist/daemon/reconcilers/broker-supervision.js +3 -3
  30. package/package.json +3 -3
  31. package/packages/crouter-api/dist/commands/node/inspect.js +2 -1
  32. package/packages/crouter-api/dist/commands/pkg/browse/model.js +1 -1
  33. package/packages/crouter-api/dist/commands/profile/environment.js +23 -5
  34. package/packages/crouter-api/dist/commands/sys/setup-core.js +2 -10
  35. package/packages/crouter-api/dist/commands/sys/setup.js +1 -1
  36. package/packages/crouter-api/dist/core/canvas/schema-version.js +1 -1
  37. package/packages/crouter-api/dist/core/environment-starter-script.js +61 -0
  38. package/packages/crouter-api/dist/core/llm/run.js +13 -2
  39. package/packages/crouter-api/dist/core/preview-registry.js +1 -5
  40. package/packages/crouter-api/dist/core/provider-failure.js +9 -0
  41. package/packages/crouter-api/dist/core/runtime/broker/model-adapter.js +3 -1
  42. package/packages/crouter-api/dist/core/runtime/revive.js +11 -0
  43. package/packages/crouter-api/dist/core/runtime/runner/blaxel/image-build.js +16 -1
  44. package/packages/crouter-api/dist/core/subscription-state.js +26 -10
  45. package/packages/crouter-api/dist/daemon/reconcilers/broker-supervision.js +3 -1
  46. package/packages/crouter-api/package.json +1 -1
  47. package/packages/crouter-identity/package.json +1 -1
  48. package/packages/crouter-plugin/package.json +3 -3
  49. package/runtime.lock.json +14 -14
@@ -1,3 +1,4 @@
1
+ import type { PaymentRefusalDTO } from './charges.js';
1
2
  export type FaultLink = 'pi→provider' | 'viewer↔broker' | 'relay↔broker' | 'viewer↔crtrd' | 'daemon→node' | 'crtr→pi';
2
3
  export type FaultKind = 'rate-limit' | 'overloaded' | 'connection' | 'auth' | 'protocol' | 'context-overflow' | 'other' | 'wedged' | 'model-not-found';
3
4
  export interface FaultRetry {
@@ -28,6 +29,7 @@ export interface FaultProviderError {
28
29
  model?: string;
29
30
  headers: Record<string, string>;
30
31
  };
32
+ payment?: PaymentRefusalDTO;
31
33
  }
32
34
  export interface RecoveryFaultDTO {
33
35
  fault_id: string;
@@ -100,11 +100,11 @@ A local plugin runs as its caller's app, with no plugin identity or home of its
100
100
 
101
101
  ```json
102
102
  "env": {
103
- "EXA_API_KEY": {
104
- "description": "Exa API key used for every exa-search call.",
103
+ "ACME_API_KEY": {
104
+ "description": "Acme API key used for every acme call.",
105
105
  "required": true,
106
106
  "secret": true,
107
- "url": "https://dashboard.exa.ai/api-keys"
107
+ "url": "https://acme.example/api-keys"
108
108
  }
109
109
  }
110
110
  ```
@@ -1592,7 +1592,7 @@ ${n}`),this.name="DaemonExitedBeforeReadyError",this.stderrTail=n}},Gpe=class ex
1592
1592
  ${s}`}catch{return}finally{if(t!==void 0)try{Lai(t)}catch{}}}var zai=()=>!process.env.CRTR_API_SOCKET&&!!process.env.CRTR_API_URL&&!!process.env.CRTR_API_TOKEN?.startsWith(Hai);function Vai(){if(process.env.CRTR_API_SOCKET)return;let t=process.env.CRTR_API_TOKEN,e=process.env.CRTR_API_URL;if(zai()&&t&&e)return{client:o=>new Tg({baseUrl:e,headers:{authorization:`Bearer ${t}`},...o!==void 0?{timeoutMs:o}:{}})};let n=yw();if(n===void 0)return;if(Z9e()===void 0)throw Ppe("this computer is imported into Northlight, so crtr needs your sign-in");let r=ggn(n.directoryUrl,n.apiUrl),i=(o,s)=>r(o,s).catch(a=>{throw a instanceof os?Hgn(a):a});return{client:o=>Yai(new Tg({baseUrl:n.apiUrl,fetch:i,...o!==void 0?{timeoutMs:o}:{}}),n.apiUrl)}}function Kai(){return!!process.env.CRTR_API_SOCKET&&(yw()!==void 0||QYe())}function Yai(t,e){return new Proxy(t,{get(n,r){let i=Reflect.get(n,r,n);return typeof i!="function"?i:(...o)=>{let s=i.apply(n,o);return s instanceof Promise?s.catch(a=>{throw a instanceof sn&&a.code==="request_timeout"?Hgn(j3(a,e)):a}):s}}})}function Hgn(t){let e=typeof t.details?.next=="string"?t.details.next:void 0;return new sn(t.exitCode===ji.NETWORK?503:401,t.code,t.message,{error:t.code,message:t.message,...e===void 0?{}:{next:e}})}function Jai(){return Vtt()?Ktt():void 0}function en(t){if(t?.local!==!0){let r=Jai();if(r!==void 0)throw r}if(t?.local===!0&&Kai())throw new os("no_local_daemon","this node reaches Northlight's shared control plane, not a daemon on this computer",ji.USAGE,{next:"Ask the person to run this in their own terminal on this computer."});let e=t?.local===!0?void 0:Vai();if(e!==void 0)return e.client(t?.timeoutMs);let n=process.env.CRTR_API_SOCKET;if(n){let r=()=>{if(!Qai(n))try{let o=$ai(n),s=Wgn(uKe(o,sZe),"utf8"),a=Wgn(uKe(o,aZe),"utf8");if(s===a&&s!=="")return new sn(503,"broker_released","This node's broker has been released, so crtr commands from its background jobs are not available.")}catch(o){if(o.code!=="ENOENT")throw o}},i=r();if(i!==void 0)throw z3(i,"Run the command from the node's own turn instead.");return fw({autostart:!1,availabilityFailure:r,coldStartPollWindowMs:(qpe()?WYe():void 0)??3e5,...t?.timeoutMs!==void 0?{timeoutMs:t.timeoutMs}:{}})}return qpe()?fw({autostart:!1,...t?.timeoutMs!==void 0?{timeoutMs:t.timeoutMs}:{}}):fw({...t?.timeoutMs!==void 0?{timeoutMs:t.timeoutMs}:{},onColdSocket:async()=>{Ogn()},coldStartDiagnostic:jai,coldStartFailure:Qgn,coldStartPollWindowMs:3e5})}var Xai=2e3,NO=class{client;rosterCache=null;rosterInFlight=null;constructor(e=en()){this.client=e}async roster(){let e=Date.now();return this.rosterCache!==null&&e-this.rosterCache.at<Xai?this.rosterCache.index:this.rosterInFlight!==null?this.rosterInFlight:(this.rosterInFlight=this.client.canvasRoster().then(n=>{let r={snapshot:n,subscriptions:new Map,subscribers:new Map};for(let i of n.edges){let o={node_id:i.to_id,active:i.active,created:i.created},s={node_id:i.from_id,active:i.active,created:i.created},a=r.subscriptions.get(i.from_id);a===void 0?r.subscriptions.set(i.from_id,[o]):a.push(o);let c=r.subscribers.get(i.to_id);c===void 0?r.subscribers.set(i.to_id,[s]):c.push(s)}return this.rosterCache={at:Date.now(),index:r},r}).finally(()=>{this.rosterInFlight=null}),this.rosterInFlight)}async orNull(e){try{return await e()}catch(n){if(n instanceof sn&&n.status===404)return null;throw n}}async getNode(e){let n=await this.orNull(()=>this.client.getNode(e));return n===null?null:Vpe(n)}async getRow(e){let n=await this.orNull(()=>this.client.getNode(e));return n===null?null:Vpe(n)}async listNodes(e){let n=e?.status,r=e?.under===void 0?{}:{under:e.under,under_inclusive:!0},i;if(Array.isArray(n)){let o=new Set(n);i=(await this.client.listNodes(r)).filter(a=>o.has(a.status))}else i=await this.client.listNodes({...n!==void 0?{status:n}:{},...r});return i.map(o=>Vpe(o))}async browseSnapshot(){let e=await this.client.canvasBrowseCompressed(),n=JSON.parse(Wai(e).toString("utf8")),r={subscriptions:new Map,subscribers:new Map};for(let i of n.edges){let o=r.subscriptions.get(i.from_id)??[];o.push({node_id:i.to_id,active:i.active,created:i.created}),r.subscriptions.set(i.from_id,o);let s=r.subscribers.get(i.to_id)??[];s.push({node_id:i.from_id,active:i.active,created:i.created}),r.subscribers.set(i.to_id,s)}return this.rosterCache={at:Date.now(),index:r},n.nodes.map(i=>Vpe(i))}async panelView(e){return await this.client.canvasView(e)}async panelRoster(){let e=await this.roster();return e.snapshot!==void 0?e.snapshot:(this.rosterCache=null,(await this.roster()).snapshot)}async subscriptionsOf(e){return this.roster().then(n=>n.subscriptions.get(e)??[])}async subscribersOf(e){return this.roster().then(n=>n.subscribers.get(e)??[])}async view(e){let n=new Set([e]),r=[],i=(await this.subscriptionsOf(e)).map(o=>o.node_id);for(;i.length>0;){let o=i.shift();if(!n.has(o)){n.add(o),r.push(o);for(let s of await this.subscriptionsOf(o))n.has(s.node_id)||i.push(s.node_id)}}return r}async ticketCountsForNodes(e){return(await this.client.attentionCounts([...e])).counts}async ticketCountsForView(e){return this.ticketCountsForNodes([e,...await this.view(e)])}async newestReport(e){return(await this.client.getReports(e,{limit:1}))[0]??null}async hasActiveLiveSubscription(e){let n=(await this.subscriptionsOf(e)).filter(r=>r.active);for(let r of n){let i=await this.getRow(r.node_id);if(i&&(i.status==="active"||i.status==="idle"))return!0}return!1}};function Ggn(t,e=DI()){let n=t?.scope??"user";if(e){if(t?.canvasName!==void 0)throw wXe("--canvas selects the person's remote canvas targets, which an app's node cannot reach","Omit --canvas; this node reads its own runtime's canvas.");return new NO}let r=t?.canvasName??Nnt(n).activeCanvas??null;if(!r)return new NO;let{previewEndpoint:i,relayToken:o}=jpe(r,n);return new yI(i,o)}function Zai(t){return{dir:t.request_dir,id:t.request_id,inboxTicketId:t.ticket_id,kind:"page",title:t.title,subtitle:t.subtitle??"",dialect:t.dialect,placement:t.placement,inbox:t.inbox,steps:t.steps,slotKinds:t.slot_kinds,awaitsResponse:t.awaits_response,source:t.source,emittedAt:t.emitted_at,recommendedOptions:(t.recommended_options??[]).map(e=>({slotId:e.slot_id,optionId:e.option_id,label:e.label})),...t.fast_action===void 0?{}:{fastAction:{kind:t.fast_action.kind,responses:t.fast_action.responses}},state:t.state,...t.answer_digest===void 0?{}:{answerDigest:t.answer_digest}}}function eci(t){return{dir:t.request_dir,id:t.request_id,inboxTicketId:t.ticket_id,kind:"review",title:t.title,subtitle:t.subtitle,blockedSince:t.blocked_since,source:t.source,...t.url===void 0?{}:{url:t.url}}}function wg(t){return t.kind==="page"?Zai(t):eci(t)}function AR(t){return{manifest:mR(t.page),document:t.source_document,progress:t.progress===null?null:t.progress.responses,state:t.state,revision:t.revision}}function qgn(t){let e=t.result;if(!(e===null||e.kind!=="page"))return e.summary.replace(/\s+/g," ").trim()}function LO(t){let e=t.result;return e!==null&&e.kind==="canceled"?"ticket was already canceled":e!==null&&e.kind==="page"?"ticket was already resolved: page submitted":"ticket was already resolved"}function EI(t,e){let n=r=>r.kind==="page"?r.emittedAt:r.blockedSince;return n(e).localeCompare(n(t))||t.id.localeCompare(e.id)}var tci=new Set(["c","r","e","a","n","p","q","j","k","u","d"," "]);function QO(t){let e=t.config.label;return typeof e=="string"&&e!==""?e:t.unvalidated===!0?t.kind:t.kind==="options"?"Options":t.kind==="text"?"Text":t.kind==="table"?"Table":t.kind==="cards"?"Cards":t.kind==="chart"?"Chart":t.kind}function Xp(t){return!(t.unvalidated===!0||t.kind==="cards"&&t.config.cards===void 0)}function OO(t){if(!Xp(t))return[];let e=[];if(t.kind==="options"){let r=t.config;e=r.options.map(i=>({kind:"select",group:"option",id:i.id,label:i.label,...i.description===void 0?{}:{description:i.description},mode:r.mode})),r.allowFreetext===!0&&e.push({kind:"freetext",label:r.freetextLabel??"Something else"})}else if(t.kind==="cards"){let r=t.config;e=(r.cards??[]).map(i=>({kind:"select",group:"card",id:i.id,label:i.subtitle===void 0?i.title:`${i.title} \u2014 ${i.subtitle}`,...i.body===void 0?{}:{description:i.body},mode:r.mode}))}else if(t.kind==="text")e.push({kind:"edit",label:"Edit"}),e.push({kind:"accept",label:"Accept as-is"});else if(t.kind==="table"){let r=t.config;if(r.rowSelect!=="none"){let i=r.columns[0];e.push(...(r.rows??[]).map(o=>({kind:"select",group:"row",id:o.id,label:i===void 0?o.id:String(o.cells[i.id]??o.id),mode:r.rowSelect})))}r.columnSelect!=="none"&&e.push(...r.columns.map(i=>({kind:"select",group:"column",id:i.id,label:i.label,mode:r.columnSelect})))}let n=new Set;return e.map(r=>{if(r.kind!=="select")return r;let i;for(let o of[...r.label.toLowerCase()].filter(s=>/[a-z]/.test(s)))if(!n.has(o)&&!tci.has(o)){i=o;break}if(i===void 0){for(let o=1;o<=9;o++)if(!n.has(String(o))){i=String(o);break}}return i!==void 0&&n.add(i),{...r,...i===void 0?{}:{shortcut:i}}})}function jgn(t,e=!1){if(t==null)return"";let n=String(t).replaceAll("|","\\|").replaceAll(`
1593
1593
  `,"<br>");return e&&n!==""?`\`${n.replaceAll("`","\\`")}\``:n}function Kpe(t){let e=`| ${t.columns.map(r=>jgn(r.label)).join(" | ")} |`,n=`| ${t.columns.map(r=>r.align==="right"?"---:":"---").join(" | ")} |`;return[e,n,...(t.rows??[]).map(r=>`| ${t.columns.map(i=>jgn(r.cells[i.id],i.mono===!0)).join(" | ")} |`)].join(`
1594
1594
  `)}function dKe(t,e,n){if(e.id===void 0)return!1;try{return ngn(t.manifest,{[e.id]:n}),!0}catch{return!1}}function JE(t,e){return!Xp(e)||e.id===void 0||!t.responses.has(e.id)?!1:dKe(t,e,t.responses.get(e.id))}function wI(t){if(t.manifest.slots.some(e=>Rc(e)&&!Xp(e)))return!1;try{return tgn(t.manifest,Object.fromEntries(t.responses)),!0}catch{return!1}}function FO(t){switch(t.kind){case"option":return`option:${t.optionId}`;case"row":return`row:${t.rowId}`}}function UO(t){return Xp(t)?t.kind==="options"?t.config.options.map(e=>({kind:"option",optionId:e.id})):t.kind==="table"?(t.config.rows??[]).map(e=>({kind:"row",rowId:e.id})):[]:[]}Je();var B0="\x1B[",Xe=`${B0}0m`,Qu=`${B0}1m`,Ct=`${B0}2m`,Vgn=`${B0}3m`,Kgn=`${B0}31m`,xI=`${B0}32m`,eh=`${B0}33m`,th=`${B0}36m`,Ype=`${B0}90m`,mKe=`${B0}7m`,nci=/\x1b\[[0-9;?]*[a-zA-Z]|\x1b[@-_]|[\x00-\x08\x0B\x0E-\x1F\x7F-\x9F]/g;function Hi(t){return typeof t!="string"?"":t.replace(nci,"")}function Ml(t){return Hi(t).replace(/\s+/g," ").trim()}function yR(t,e="\u2500"){return t<1?"":e.repeat(t)}function XE(t,e){if(e<1)return"";if(Ha(t)<=e)return t;let n=[...t],r=0,i="";for(let o of n){let s=Ha(o);if(r+s+1>e)break;i+=o,r+=s}return i+"\u2026"}function Jpe(t,e){let n=t.replace(/\n/g," ").replace(/✅/g,"\u2713").replace(/❌/g,"\u2717").replace(new RegExp("\\p{Emoji_Presentation}","gu"),"");if(e<4)return n.slice(0,e);if(Ha(n)<=e)return n;let i=n;for(;Ha(i)>e-1&&i.length>0;){let o=i.lastIndexOf(" ",i.length-2);o>e*.4?i=i.slice(0,o):i=i.slice(0,i.length-1)}return i+"\u2026"}function rci(t,e){let n=0,r="";for(let i of t){let o=Ha(i);if(n+o>e)break;r+=i,n+=o}return r===""&&t.length>0&&(r=[...t][0]),r}function nu(t,e){if(e<1)return[t];let n=[],r=t.split(`
1595
- `);for(let i=0;i<r.length;i++){let o=r[i];if(o===""){n.push("");continue}let s=o.split(/[ \t]+/).filter(Boolean),a="";for(let c of s){for(;Ha(c)>e;){a&&(n.push(a),a="");let l=rci(c,e);n.push(l),c=c.slice(l.length)}let u=a?`${a} ${c}`:c;Ha(u)<=e?a=u:(a&&n.push(a),a=c)}a&&n.push(a)}return n.length>0?n:[""]}function fKe(t,e,n){let r=Math.max(0,Math.floor((e-n)/2));if(r===0)return t;let i=" ".repeat(r);return t.map(o=>o===""?"":i+o)}function Zp(t){return Te(t)}var pKe=/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)|\x1b_[^\x07\x1b]*(?:\x07|\x1b\\)|\x1b\[[0-9;?]*[a-zA-Z]|\x1b[@-^]/g,hKe=/\x1b\]8;[^;\x07\x1b]*;([^\x07\x1b]*)(\x07|\x1b\\)/g,zgn=new Intl.Segmenter(void 0,{granularity:"grapheme"});function ici(t){let e=[],n=0;pKe.lastIndex=0;for(let r=pKe.exec(t);r!==null;r=pKe.exec(t)){for(let i of zgn.segment(t.slice(n,r.index)))e.push({ansi:!1,text:i.segment,width:Zp(i.segment)});e.push({ansi:!0,text:r[0]}),n=r.index+r[0].length}for(let r of zgn.segment(t.slice(n)))e.push({ansi:!1,text:r.segment,width:Zp(r.segment)});return e}function Ygn(t,e,n){if(n<1)return"";let r=Math.max(0,e),i=r+n,o="",s="",a=!1,c=0;for(let l of ici(t)){if(l.ansi){c<r?o+=l.text:(s+=l.text,a=!0);continue}if(c>=i)break;let d=l.width;if(d===0){c>=r&&(s+=l.text);continue}if(c+d<=r){c+=d;continue}if(c<r){s+=" ".repeat(c+d-r),c+=d;continue}if(c+d>i){s+=" ".repeat(i-c),c=i;break}s+=l.text,c+=d}if(s==="")return"";o!==""&&(s=o+s,a=!0);let u=oci(s);return a?s+u+Xe:s}function oci(t){let e="";hKe.lastIndex=0;for(let n=hKe.exec(t);n!==null;n=hKe.exec(t))e=n[1]===""?"":`\x1B]8;;${n[2]}`;return e}function D0(t,e){return e<1?"":Zp(t)<=e?t:Ygn(t,0,e)}function Jgn(t,e,n){if(n<1)return"";let r=Zp(t);if(r<=n)return t;let i=r-n,o=Math.max(0,Math.min(e,i)),s=o>0,a=o<i,c=n-(s?1:0)-(a?1:0),u=c>0?Ygn(t,o+(s?1:0),c):"";return`${s?`${Ct}\u2039${Xe}`:""}${u}${a?`${Ct}\u203A${Xe}`:""}`}function Xpe(t,e,n,r){let i=s=>wle(ble(s),n,r);if(t.dialect==="html")return e===""?[`${Ct}HTML page \u2014 open in Northlight to read this${Xe}`]:i(e);let o=e===""?[]:i(e);for(let s of t.slots){o.length>0&&o.push("");for(let c of nu(Ml(QO(s)),n))o.push(`${Qu}${c}${Xe}`);let a=s.config.body;if(typeof a=="string"&&a!==""&&o.push(...i(a)),!Xp(s)){o.push(`${Ct}${Hi(s.kind)} \u2014 open in Northlight to answer this${Xe}`);continue}if(s.kind==="text")o.push(...i(s.config.initialText));else if(s.kind==="table")o.push(...i(Kpe(s.config)));else if(s.kind==="cards"){for(let c of s.config.cards??[])if(o.push(` \u2022 ${XE(Hi(Ml(c.subtitle===void 0?c.title:`${c.title} \u2014 ${c.subtitle}`)),Math.max(10,n-4))}`),c.body!==void 0)for(let u of nu(Hi(c.body),Math.max(10,n-6)))o.push(` ${Ct}${u}${Xe}`)}else if(s.kind==="options"){for(let c of s.config.options)if(o.push(` \u2022 ${XE(Hi(Ml(c.label)),Math.max(10,n-4))}`),c.description!==void 0)for(let u of nu(Hi(c.description),Math.max(10,n-6)))o.push(` ${Ct}${u}${Xe}`)}else if(s.kind==="chart"){let c=s.config,u=c.title??`${c.x??""} vs ${(c.y??[]).map(l=>l.label??l.field).join(", ")}`;o.push(`${Ct}chart \u2014 ${Hi(c.kind??"chart")}: ${Hi(u)}${Xe}`)}}return o}var Xgn=16;function Zgn(t){if(t===null||typeof t!="object")return;let e=t.details;if(e===null||typeof e!="object")return;let n=e.crtrPreview;if(n===null||typeof n!="object")return;let r=n;if(r.path!=="human send")return;let i=r.result;if(i===null||typeof i!="object")return;let o=i,s=o.page_id;if(typeof s=="string"&&o.placement==="inline")return{pageId:s}}function sci(t){return t.document_media_type==="text/html"?RO(t.source_document):TO(t.source_document,t.page)}var Zpe=class{constructor(e,n){this.pageId=e;this.openHint=n}pageId;openHint;expanded=!1;generation=0;stamp;snapshot;status="loading";cache;get settled(){return this.snapshot?.state==="resolved"||this.snapshot?.state==="canceled"}async refresh(){let e;try{e=(await en().getHumanRequest(this.pageId)).page}catch{e=void 0}if(e===void 0)return this.settle("unavailable",void 0,void 0);let n=`${e.revision}|${e.state}`;if(this.status==="ready"&&n===this.stamp)return!1;let r;try{r={manifest:e.page,displayMarkdown:sci(e),state:e.state,...e.state==="resolved"?aci(qgn(e)):{}}}catch{return this.settle("unavailable",void 0,n)}return this.settle("ready",r,n)}setExpanded(e){e!==this.expanded&&(this.expanded=e,this.cache=void 0)}render(e){let n=e>0?e:80,r=this.cache;if(r!==void 0&&r.width===n&&r.generation===this.generation&&r.expanded===this.expanded)return r.lines;let i=this.compose(n);return this.cache={width:n,generation:this.generation,expanded:this.expanded,lines:i},i}invalidate(){this.cache=void 0}settle(e,n,r){return e===this.status&&e==="unavailable"?!1:(this.status=e,this.snapshot=n,this.stamp=r,this.generation++,this.cache=void 0,!0)}compose(e){let n=this.snapshot;if(n===void 0){let a=this.status==="loading"?"[page] loading\u2026":"[page] no longer available";return["",` ${Ct}${a}${Xe}`,""]}let r=Math.min(Math.max(20,e-4),100),i=["",` ${Qu}${th}${XE(Hi(Ml(n.manifest.title)),r)}${Xe}`];if(n.manifest.subtitle)for(let a of nu(Hi(n.manifest.subtitle),r))i.push(` ${Ct}${a}${Xe}`);let o=Xpe(n.manifest,n.displayMarkdown,r,Math.max(20,e-4));if(o.length>0){i.push("");let a=this.expanded||o.length<=Xgn?o:o.slice(0,Xgn);for(let c of a)i.push(` ${c}`);a.length<o.length&&i.push(` ${Ct}\u2026 +${o.length-a.length} lines \u2014 ctrl+o to expand${Xe}`)}let s=this.footerLine(n,r);return s!==void 0&&i.push("",` ${s}`),i.push(""),i}footerLine(e,n){switch(e.state){case"pending":return Bpe(e.manifest)?`${eh}\u25B8 awaiting your answer${Xe} ${Ct}\u2014 ${Hi(this.openHint())}${Xe}`:`${Ct}\u25E6 queued in your inbox \u2014 ${Hi(this.openHint())}${Xe}`;case"resolved":return e.answerDigest===void 0?`${xI}\u2713 answered${Xe}`:`${xI}\u2713 answered${Xe} ${Ct}\u2014 ${XE(Hi(e.answerDigest),Math.max(10,n-12))}${Xe}`;case"canceled":return`${Ct}\u2298 canceled${Xe}`;case"passive":return}}};function aci(t){return t===void 0?{}:{answerDigest:t}}Wa();Je();var cci=new Set(["canvas roster","canvas snapshot","node inspect snapshot","node inspect show","sys context sysprompt"]);function tAn(t){for(let e of cci){let n=e.split(" ");if(n.length<=t.length&&n.every((r,i)=>t[i]===r))return!0}return!1}var uci=61529,nAn=String.fromCodePoint(uci),Hm={bash:String.fromCodePoint(61728),read:String.fromCodePoint(61788),write:String.fromCodePoint(61639),edit:String.fromCodePoint(61508)},lci={canvas:61672,capture:61501,device:61705,doc:61485,human:61447,node:61842,pkg:61874,profile:62141,push:61678,"exa-search":61442,surface:61704,sys:61459},dci={"canvas dashboard":61668,"canvas snapshot":61488,"canvas browse":61774,"canvas attention count":62098,"canvas attention list":61498,"canvas attention map":62073,"canvas revive":61473,"node lifecycle revive":61473,"canvas list":61498,"canvas read":61485,"canvas search":61442,"canvas history search":61442,"canvas history grep":61616,"sys daemon start":61515,"sys daemon status":61713,"sys daemon stop":61517,"canvas chord":61441,"surface tmux-spread":61449,"canvas issue new":61832,"canvas prune":61636,"human send":61529,"human review":61508,"human show":61704,"human cancel":61453,"human list":61498,"human resolve":61452,"doc write":61504,"doc edit":61508,"doc history":61914,"doc lint":61770,"node new":61543,"node message send":61664,"node message request":61664,"cron add":61463,"node wait deadline":61463,"node subscription add":61683,"node subscription remove":61942,"node promote":61698,"node yield":62093,"surface node focus":61531,"surface node cycle":61473,"node inspect list":61498,"node inspect show":61550,"node inspect snapshot":61488,"node inspect context":61564,"node lifecycle recycle":61880,"node lifecycle close":61453,"node lifecycle demote":61699,"node config":61459,"cron list":61463,"cron cancel":61534,"pkg plugin install":61465,"pkg plugin remove":61460,"pkg plugin enable":61452,"pkg plugin disable":61534,"pkg plugin update":61473,"pkg plugin list":61498,"pkg plugin show":61550,"pkg market add":61543,"pkg market remove":61460,"pkg market update":61473,"pkg market list":61498,"pkg market browse":61774,"push update":61587,"push final":61726,"exa-search web":61612,"exa-search answer":61557,"exa-search contents":61686,"surface attach to":61926,"sys config get":61465,"sys config set":61504,"sys config path":61563,"sys settings":61459,"sys setup":61613,"sys doctor":61681,"sys context sysprompt":61788,"sys context prompt-review":61442,"sys feedback":61557,"sys update":61473,"sys version":61483,"sys sync":61561};function rAn(t){let e;for(let[r,i]of Object.entries(dci)){let o=r.split(" ");o.length<=t.length&&o.every((s,a)=>t[a]===s)&&(e===void 0||o.length>e.words)&&(e={words:o.length,cp:i})}if(e!==void 0)return String.fromCodePoint(e.cp);let n=t.length>0?lci[t[0]]:void 0;return n!==void 0?String.fromCodePoint(n):"\u25C6"}function $O(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:void 0}function ehe(t){let e=$O($O(t)?.details);if(e===void 0)return[];let n=e.crtrPreviews;return(Array.isArray(n)?n:[e.crtrPreview]).flatMap(i=>{let o=$O(i);if(o===void 0||typeof o.path!="string")return[];let s=o.jsonl;return[{path:o.path,result:$O(o.result),jsonl:Array.isArray(s)?s.flatMap(a=>{let c=$O(a);return c===void 0?[]:[c]}):void 0,error:$O(o.error)}]})}var pci=4;function bI(t){return t.result}function Wm(t,e){let n=t[e];return typeof n=="string"&&n!==""?n:void 0}function AKe(t,e){return typeof t[e]=="boolean"?t[e]:void 0}function ER(t,e){return typeof t[e]=="number"&&Number.isFinite(t[e])?t[e]:void 0}function hci(t,e){let n=t[e];return Array.isArray(n)&&n.every(r=>r!==null&&typeof r=="object"&&!Array.isArray(r))?n:void 0}function mci(t,e){return t.length>e?`${t.slice(0,e).trimEnd()}\u2026`:t}function fci(t,e,n=5){let r=t.map(s=>Wm(s,e));if(r.some(s=>s===void 0))return;let i=r.slice(0,n),o=r.length-i.length;return o>0?`${i.join(", ")}, \u2026 ${o} more`:i.join(", ")}function gci(t){let e=t.error;if(e===void 0)return null;let n=Wm(e,"error"),r=Wm(e,"message");return n===void 0||r===void 0?null:[{text:n,tone:"error"},{text:mci(r,160),tone:"muted"}]}function Aci(t){let e=bI(t);if(e===void 0)return null;let n=Wm(e,"deleted")??Wm(e,"remote");if(n!==void 0)return[{text:n.trim().split(`
1595
+ `);for(let i=0;i<r.length;i++){let o=r[i];if(o===""){n.push("");continue}let s=o.split(/[ \t]+/).filter(Boolean),a="";for(let c of s){for(;Ha(c)>e;){a&&(n.push(a),a="");let l=rci(c,e);n.push(l),c=c.slice(l.length)}let u=a?`${a} ${c}`:c;Ha(u)<=e?a=u:(a&&n.push(a),a=c)}a&&n.push(a)}return n.length>0?n:[""]}function fKe(t,e,n){let r=Math.max(0,Math.floor((e-n)/2));if(r===0)return t;let i=" ".repeat(r);return t.map(o=>o===""?"":i+o)}function Zp(t){return Te(t)}var pKe=/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)|\x1b_[^\x07\x1b]*(?:\x07|\x1b\\)|\x1b\[[0-9;?]*[a-zA-Z]|\x1b[@-^]/g,hKe=/\x1b\]8;[^;\x07\x1b]*;([^\x07\x1b]*)(\x07|\x1b\\)/g,zgn=new Intl.Segmenter(void 0,{granularity:"grapheme"});function ici(t){let e=[],n=0;pKe.lastIndex=0;for(let r=pKe.exec(t);r!==null;r=pKe.exec(t)){for(let i of zgn.segment(t.slice(n,r.index)))e.push({ansi:!1,text:i.segment,width:Zp(i.segment)});e.push({ansi:!0,text:r[0]}),n=r.index+r[0].length}for(let r of zgn.segment(t.slice(n)))e.push({ansi:!1,text:r.segment,width:Zp(r.segment)});return e}function Ygn(t,e,n){if(n<1)return"";let r=Math.max(0,e),i=r+n,o="",s="",a=!1,c=0;for(let l of ici(t)){if(l.ansi){c<r?o+=l.text:(s+=l.text,a=!0);continue}if(c>=i)break;let d=l.width;if(d===0){c>=r&&(s+=l.text);continue}if(c+d<=r){c+=d;continue}if(c<r){s+=" ".repeat(c+d-r),c+=d;continue}if(c+d>i){s+=" ".repeat(i-c),c=i;break}s+=l.text,c+=d}if(s==="")return"";o!==""&&(s=o+s,a=!0);let u=oci(s);return a?s+u+Xe:s}function oci(t){let e="";hKe.lastIndex=0;for(let n=hKe.exec(t);n!==null;n=hKe.exec(t))e=n[1]===""?"":`\x1B]8;;${n[2]}`;return e}function D0(t,e){return e<1?"":Zp(t)<=e?t:Ygn(t,0,e)}function Jgn(t,e,n){if(n<1)return"";let r=Zp(t);if(r<=n)return t;let i=r-n,o=Math.max(0,Math.min(e,i)),s=o>0,a=o<i,c=n-(s?1:0)-(a?1:0),u=c>0?Ygn(t,o+(s?1:0),c):"";return`${s?`${Ct}\u2039${Xe}`:""}${u}${a?`${Ct}\u203A${Xe}`:""}`}function Xpe(t,e,n,r){let i=s=>wle(ble(s),n,r);if(t.dialect==="html")return e===""?[`${Ct}HTML page \u2014 open in Northlight to read this${Xe}`]:i(e);let o=e===""?[]:i(e);for(let s of t.slots){o.length>0&&o.push("");for(let c of nu(Ml(QO(s)),n))o.push(`${Qu}${c}${Xe}`);let a=s.config.body;if(typeof a=="string"&&a!==""&&o.push(...i(a)),!Xp(s)){o.push(`${Ct}${Hi(s.kind)} \u2014 open in Northlight to answer this${Xe}`);continue}if(s.kind==="text")o.push(...i(s.config.initialText));else if(s.kind==="table")o.push(...i(Kpe(s.config)));else if(s.kind==="cards"){for(let c of s.config.cards??[])if(o.push(` \u2022 ${XE(Hi(Ml(c.subtitle===void 0?c.title:`${c.title} \u2014 ${c.subtitle}`)),Math.max(10,n-4))}`),c.body!==void 0)for(let u of nu(Hi(c.body),Math.max(10,n-6)))o.push(` ${Ct}${u}${Xe}`)}else if(s.kind==="options"){for(let c of s.config.options)if(o.push(` \u2022 ${XE(Hi(Ml(c.label)),Math.max(10,n-4))}`),c.description!==void 0)for(let u of nu(Hi(c.description),Math.max(10,n-6)))o.push(` ${Ct}${u}${Xe}`)}else if(s.kind==="chart"){let c=s.config,u=c.title??`${c.x??""} vs ${(c.y??[]).map(l=>l.label??l.field).join(", ")}`;o.push(`${Ct}chart \u2014 ${Hi(c.kind??"chart")}: ${Hi(u)}${Xe}`)}}return o}var Xgn=16;function Zgn(t){if(t===null||typeof t!="object")return;let e=t.details;if(e===null||typeof e!="object")return;let n=e.crtrPreview;if(n===null||typeof n!="object")return;let r=n;if(r.path!=="human send")return;let i=r.result;if(i===null||typeof i!="object")return;let o=i,s=o.page_id;if(typeof s=="string"&&o.placement==="inline")return{pageId:s}}function sci(t){return t.document_media_type==="text/html"?RO(t.source_document):TO(t.source_document,t.page)}var Zpe=class{constructor(e,n){this.pageId=e;this.openHint=n}pageId;openHint;expanded=!1;generation=0;stamp;snapshot;status="loading";cache;get settled(){return this.snapshot?.state==="resolved"||this.snapshot?.state==="canceled"}async refresh(){let e;try{e=(await en().getHumanRequest(this.pageId)).page}catch{e=void 0}if(e===void 0)return this.settle("unavailable",void 0,void 0);let n=`${e.revision}|${e.state}`;if(this.status==="ready"&&n===this.stamp)return!1;let r;try{r={manifest:e.page,displayMarkdown:sci(e),state:e.state,...e.state==="resolved"?aci(qgn(e)):{}}}catch{return this.settle("unavailable",void 0,n)}return this.settle("ready",r,n)}setExpanded(e){e!==this.expanded&&(this.expanded=e,this.cache=void 0)}render(e){let n=e>0?e:80,r=this.cache;if(r!==void 0&&r.width===n&&r.generation===this.generation&&r.expanded===this.expanded)return r.lines;let i=this.compose(n);return this.cache={width:n,generation:this.generation,expanded:this.expanded,lines:i},i}invalidate(){this.cache=void 0}settle(e,n,r){return e===this.status&&e==="unavailable"?!1:(this.status=e,this.snapshot=n,this.stamp=r,this.generation++,this.cache=void 0,!0)}compose(e){let n=this.snapshot;if(n===void 0){let a=this.status==="loading"?"[page] loading\u2026":"[page] no longer available";return["",` ${Ct}${a}${Xe}`,""]}let r=Math.min(Math.max(20,e-4),100),i=["",` ${Qu}${th}${XE(Hi(Ml(n.manifest.title)),r)}${Xe}`];if(n.manifest.subtitle)for(let a of nu(Hi(n.manifest.subtitle),r))i.push(` ${Ct}${a}${Xe}`);let o=Xpe(n.manifest,n.displayMarkdown,r,Math.max(20,e-4));if(o.length>0){i.push("");let a=this.expanded||o.length<=Xgn?o:o.slice(0,Xgn);for(let c of a)i.push(` ${c}`);a.length<o.length&&i.push(` ${Ct}\u2026 +${o.length-a.length} lines \u2014 ctrl+o to expand${Xe}`)}let s=this.footerLine(n,r);return s!==void 0&&i.push("",` ${s}`),i.push(""),i}footerLine(e,n){switch(e.state){case"pending":return Bpe(e.manifest)?`${eh}\u25B8 awaiting your answer${Xe} ${Ct}\u2014 ${Hi(this.openHint())}${Xe}`:`${Ct}\u25E6 queued in your inbox \u2014 ${Hi(this.openHint())}${Xe}`;case"resolved":return e.answerDigest===void 0?`${xI}\u2713 answered${Xe}`:`${xI}\u2713 answered${Xe} ${Ct}\u2014 ${XE(Hi(e.answerDigest),Math.max(10,n-12))}${Xe}`;case"canceled":return`${Ct}\u2298 canceled${Xe}`;case"passive":return}}};function aci(t){return t===void 0?{}:{answerDigest:t}}Wa();Je();var cci=new Set(["canvas roster","canvas snapshot","node inspect snapshot","node inspect show","sys context sysprompt"]);function tAn(t){for(let e of cci){let n=e.split(" ");if(n.length<=t.length&&n.every((r,i)=>t[i]===r))return!0}return!1}var uci=61529,nAn=String.fromCodePoint(uci),Hm={bash:String.fromCodePoint(61728),read:String.fromCodePoint(61788),write:String.fromCodePoint(61639),edit:String.fromCodePoint(61508)},lci={canvas:61672,capture:61501,device:61705,doc:61485,human:61447,node:61842,pkg:61874,profile:62141,push:61678,surface:61704,sys:61459},dci={"canvas dashboard":61668,"canvas snapshot":61488,"canvas browse":61774,"canvas attention count":62098,"canvas attention list":61498,"canvas attention map":62073,"canvas revive":61473,"node lifecycle revive":61473,"canvas list":61498,"canvas read":61485,"canvas search":61442,"canvas history search":61442,"canvas history grep":61616,"sys daemon start":61515,"sys daemon status":61713,"sys daemon stop":61517,"canvas chord":61441,"surface tmux-spread":61449,"canvas issue new":61832,"canvas prune":61636,"human send":61529,"human review":61508,"human show":61704,"human cancel":61453,"human list":61498,"human resolve":61452,"doc write":61504,"doc edit":61508,"doc history":61914,"doc lint":61770,"node new":61543,"node message send":61664,"node message request":61664,"cron add":61463,"node wait deadline":61463,"node subscription add":61683,"node subscription remove":61942,"node promote":61698,"node yield":62093,"surface node focus":61531,"surface node cycle":61473,"node inspect list":61498,"node inspect show":61550,"node inspect snapshot":61488,"node inspect context":61564,"node lifecycle recycle":61880,"node lifecycle close":61453,"node lifecycle demote":61699,"node config":61459,"cron list":61463,"cron cancel":61534,"pkg plugin install":61465,"pkg plugin remove":61460,"pkg plugin enable":61452,"pkg plugin disable":61534,"pkg plugin update":61473,"pkg plugin list":61498,"pkg plugin show":61550,"pkg market add":61543,"pkg market remove":61460,"pkg market update":61473,"pkg market list":61498,"pkg market browse":61774,"push update":61587,"push final":61726,"surface attach to":61926,"sys config get":61465,"sys config set":61504,"sys config path":61563,"sys settings":61459,"sys setup":61613,"sys doctor":61681,"sys context sysprompt":61788,"sys context prompt-review":61442,"sys feedback":61557,"sys update":61473,"sys version":61483,"sys sync":61561};function rAn(t){let e;for(let[r,i]of Object.entries(dci)){let o=r.split(" ");o.length<=t.length&&o.every((s,a)=>t[a]===s)&&(e===void 0||o.length>e.words)&&(e={words:o.length,cp:i})}if(e!==void 0)return String.fromCodePoint(e.cp);let n=t.length>0?lci[t[0]]:void 0;return n!==void 0?String.fromCodePoint(n):"\u25C6"}function $O(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:void 0}function ehe(t){let e=$O($O(t)?.details);if(e===void 0)return[];let n=e.crtrPreviews;return(Array.isArray(n)?n:[e.crtrPreview]).flatMap(i=>{let o=$O(i);if(o===void 0||typeof o.path!="string")return[];let s=o.jsonl;return[{path:o.path,result:$O(o.result),jsonl:Array.isArray(s)?s.flatMap(a=>{let c=$O(a);return c===void 0?[]:[c]}):void 0,error:$O(o.error)}]})}var pci=4;function bI(t){return t.result}function Wm(t,e){let n=t[e];return typeof n=="string"&&n!==""?n:void 0}function AKe(t,e){return typeof t[e]=="boolean"?t[e]:void 0}function ER(t,e){return typeof t[e]=="number"&&Number.isFinite(t[e])?t[e]:void 0}function hci(t,e){let n=t[e];return Array.isArray(n)&&n.every(r=>r!==null&&typeof r=="object"&&!Array.isArray(r))?n:void 0}function mci(t,e){return t.length>e?`${t.slice(0,e).trimEnd()}\u2026`:t}function fci(t,e,n=5){let r=t.map(s=>Wm(s,e));if(r.some(s=>s===void 0))return;let i=r.slice(0,n),o=r.length-i.length;return o>0?`${i.join(", ")}, \u2026 ${o} more`:i.join(", ")}function gci(t){let e=t.error;if(e===void 0)return null;let n=Wm(e,"error"),r=Wm(e,"message");return n===void 0||r===void 0?null:[{text:n,tone:"error"},{text:mci(r,160),tone:"muted"}]}function Aci(t){let e=bI(t);if(e===void 0)return null;let n=Wm(e,"deleted")??Wm(e,"remote");if(n!==void 0)return[{text:n.trim().split(`
1596
1596
  `)[0]??"",tone:"warning"}];let r=Wm(e,"readMetadata")??Wm(e,"object");if(r===void 0)return null;let i=r.split(`
1597
1597
  `).filter(o=>o.trim()!==""&&!o.startsWith("<auto-loaded-context")&&!o.startsWith("</auto-loaded-context"));return i.length===0?null:[{text:i[0]},...i.slice(1,pci).map(o=>({text:o,tone:"muted"}))]}function yci(t,e=!1){return n=>{let r=bI(n),i=r===void 0?void 0:ER(r,"count")??ER(r,"total");return i===void 0?null:i===0&&e?[{text:`PASS \xB7 no ${t}`,tone:"success"}]:[{text:`${i} ${t}`,tone:i===0?"muted":"plain"}]}}function ZE(t,e="items"){return n=>{let r=bI(n);if(r===void 0)return null;let i=hci(r,e),o=ER(r,"total")??i?.length;if(i===void 0||o===void 0)return null;let s=[{text:`${o} ${t}`,tone:o===0?"muted":"plain"}],a=fci(i,"name");return a!==void 0&&a!==""&&s.push({text:a,tone:"muted"}),s}}function Eci(t){let n=bI(t)?.counts;if(n===null||typeof n!="object"||Array.isArray(n))return null;let r=Object.entries(n);if(r.some(([,s])=>typeof s!="number"))return null;let i=r.reduce((s,[,a])=>s+a,0);if(i===0)return[{text:"PASS \xB7 no pending asks",tone:"success"}];let o=r.filter(([,s])=>s>0).sort((s,a)=>a[1]-s[1])[0];return o===void 0?null:[{text:`${i} asks`,tone:"warning"},{text:`hottest: ${o[0]} (${o[1]})`,tone:"muted"}]}function gKe(t,e,n){return r=>{let i=bI(r);if(i===void 0)return null;let o=AKe(i,t);if(o===void 0)return null;let s=ER(i,"pid")??ER(i,"existing_pid");return[{text:o?`${e}${s===void 0?"":` \xB7 pid ${s}`}`:n,tone:o?"success":"muted"}]}}function wci(t){let e=bI(t);if(e===void 0||Wm(e,"page_id")===void 0)return null;let n=AKe(e,"reply");return n===void 0?null:[{text:n?"page sent \u2192 waiting on human":"announcement sent",tone:n?"accent":"success"}]}function xci(t){let e=bI(t);if(e===void 0)return null;let n=AKe(e,"resolved"),r=Wm(e,"job_id");return n===void 0||r===void 0?null:[{text:`${n?"resolved":"not resolved"} ${r}`,tone:n?"success":"warning"}]}function eAn(t){let e=bI(t);if(e===void 0)return null;let n=Wm(e,"status");return n===void 0?null:[{text:n,tone:["done","success","submitted","filed"].includes(n)?"success":n==="failed"?"error":"plain"}]}function bci(t){let e=t.jsonl;if(e===void 0)return null;let n=e.filter(r=>Wm(r,"name")!==void 0&&ER(r,"projects_count")!==void 0);return n.length===0&&e.length>0?null:[{text:`${n.length} profile${n.length===1?"":"s"}`},...n.slice(0,5).map(r=>({text:`${Wm(r,"name")} \xB7 ${ER(r,"projects_count")} projects`,tone:"muted"}))]}var Cci=[{path:"canvas read",run:Aci},{path:"canvas list",run:ZE("objects")},{path:"canvas search",run:ZE("hits")},{path:"canvas attention count",run:yci("pending asks",!0)},{path:"canvas attention list",run:ZE("pending asks")},{path:"canvas attention map",run:Eci},{path:"human send",run:wci},{path:"human list",run:ZE("pending")},{path:"human resolve",run:xci},{path:"pkg plugin list",run:ZE("plugins")},{path:"pkg market list",run:ZE("marketplaces")},{path:"pkg market browse",run:ZE("plugins")},{path:"canvas dashboard",run:ZE("nodes","rows")},{path:"node inspect list",run:ZE("nodes","nodes")},{path:"sys daemon start",run:gKe("started","started","already running")},{path:"sys daemon status",run:gKe("running","running","not running")},{path:"sys daemon stop",run:gKe("stopped","stopped","was not running")},{path:"sys update",run:eAn},{path:"sys feedback",run:eAn},{path:"profile list",run:bci}];function iAn(t,e=[]){let n=gci(t);return n!==null?n:Cci.find(({path:i})=>i===t.path)?.run(t,e)??null}Wa();Je();import{homedir as _ci}from"node:os";import{isAbsolute as kci,resolve as Tci}from"node:path";import{pathToFileURL as Rci}from"node:url";import{loadLinuxNative as vci}from"../../native/linux.js";var eGs=vci();_F();var Sci=280;function oAn(t){if(typeof t!="string"||/[\p{Cc}\p{Cf}]/u.test(t))return null;let e=t.trim();return e===""?null:Buffer.byteLength(e,"utf8")<=Sci?e:null}function wR(t){let e=Math.max(0,Math.floor(t/1e3));if(e<60)return`${e}s`;let n=Math.floor(e/60),r=e%60;if(n<60)return`${n}m ${String(r).padStart(2,"0")}s`;let i=Math.floor(n/60),o=n%60;return`${i}h ${String(o).padStart(2,"0")}m`}function sAn(t){return(t.split(`
1598
1598
  `).map(n=>n.trim()).find(n=>n!=="")??"").replace(/\s+/g," ")}var aAn=/^cd\s+(?:"[^"]*"|'[^']*'|\S+)\s*(?:&&|;)\s*/;function cAn(t){let e=t;for(;aAn.test(e);)e=e.replace(aAn,"");return e}function the(t){return typeof t=="string"?t:""}var Bci=5e3;function Dci(t,e,n,r){if(e===void 0||Date.now()-e<Bci)return[];let i=n?.()??null;return i===null?[]:[st(` ${t.fg("muted",`\u29D7 ${i}`)}`,r,"\u2026")]}var xg=class{folded=!1;component;setFolded(e){this.folded=e}capture(e){return this.component=e,e}callComponent(){return this.component}};function Mci(t){return t.length===0?0:(t.match(/\n/g)?.length??0)+(t.endsWith(`
@@ -1,12 +1,12 @@
1
- var P=Object.defineProperty;var h=(n,e)=>P(n,"name",{value:e,configurable:!0});import{defineBranch as I,defineLeaf as _}from"../../core/command.js";import{InputError as k}from"../../core/io.js";import{requireScope as O}from"../../core/errors.js";import{isPidAlive as A}from"../../core/canvas/pid.js";import{fullName as $}from"../../core/canvas/labels.js";import{fuzzyMatch as F}from"../../core/tui/fuzzy.js";import{nodeSnapshotLeaf as L}from"../node-snapshot.js";import{nodeTranscriptLeaf as C}from"../node-transcript.js";import{nodeContextLeaf as U}from"../node-context.js";import{ApiError as D}from"../../api/index.js";import{cliClient as x,cliCanvasSource as S,rethrowAsCliError as w}from"../api-client.js";import{RemoteCanvasSource as q}from"../../core/canvas/remote-canvas-source.js";import{kindsStateBlock as E,profilesStateBlock as z,resolveProfileViaDaemon as M}from"../profile/daemon-profiles.js";import{focusViewer as B,nodeInPane as W}from"../surface/node/placement.js";const K=_({name:"list",description:"list nodes on the canvas",whenToUse:"you want a flat roster of the nodes on the canvas, sliced by displayed name, status, kind, mode, lifecycle, profile, cwd, and graph scope (--under a node, for that node plus its subscription descendants). The filters AND together. Use `node inspect show` instead to drill into one node and its spine neighbors, `canvas dashboard` for the tree shape, and `canvas attention` to find nodes blocked on the user",help:{name:"node inspect list",summary:"list nodes on the canvas, filtered by any combination of attribute slices and a graph-scope (--under) that AND together",params:[{kind:"flag",name:"status",type:"string",required:!1,constraint:"Filter status (comma-separated for several; accepted values: active, idle, done, dead, canceled). NOTE: `active` means the engine process is live (never closed), NOT that the node is generating right now \u2014 an active node is usually dormant between turns. To tell working-vs-idle, check the pi session-file mtime or CPU, not status."},{kind:"flag",name:"kind",type:"string",required:!1,constraint:"Filter by persona kind (comma-separated for several). The <kinds> list below names every top-level installable kind; a registered sub-kind filters too by exact path even though it is not listed."},{kind:"flag",name:"mode",type:"string",required:!1,constraint:"Filter by mode (comma-separated for several; accepted values: base, orchestrator)."},{kind:"flag",name:"lifecycle",type:"string",required:!1,constraint:"Filter by lifecycle (comma-separated for several; accepted values: terminal, resident)."},{kind:"flag",name:"profile",type:"string",required:!1,constraint:"Filter by profile. On the local canvas, accepts a profile id or manifest name from the <profiles> list below, or a close-enough name that resolves to the nearest profile. Against a remote canvas, pass the exact profile id carried by its node rows."},{kind:"flag",name:"name",type:"string",required:!1,constraint:"Filter by the displayed node label (handle plus generated description) with the canvas browser\u2019s case-insensitive fuzzy subsequence match."},{kind:"flag",name:"cwd",type:"string",required:!1,constraint:"Filter to nodes pinned to this exact cwd (absolute path). Roster is canvas-wide (all cwds) by default."},{kind:"flag",name:"under",type:"string",required:!1,constraint:'Graph scope: restrict to this node and its subscription descendants (the sub-DAG reachable downward \u2014 its reports, theirs, \u2026). This is "one initiative / my subtree". ANDs with every attribute filter above, narrowing any of them to this subtree.'},{kind:"flag",name:"canvas",type:"string",required:!1,constraint:"Read from the named remote canvas target (see `crtr canvas config list`) instead of the local canvas. Overrides `crtr canvas use`."}],output:[{name:"nodes",type:"object[]",required:!0,constraint:"Rows include {node_id, name, kind, mode, lifecycle, status, cwd, profile_id, parent, created}. `name` is the displayed node label searched by --name and shown in canvas views. `profile_id` is the stable profile-directory id (null only for historical no-profile nodes)."}],outputKind:"object",effects:["Read-only: lists nodes through the daemon API."]},helpState:{leaf:h(async()=>(await Promise.all([E(),z()])).join(`
2
- `),"leaf")},run:h(async n=>{const e=h(d=>{const b=n[d];return b!==void 0&&b!==""?b.split(",").map(v=>v.trim()).filter(v=>v!==""):void 0},"csv"),o=e("status"),s=e("kind"),p=e("mode"),i=e("lifecycle"),m=n.profile,c=n.name,l=n.cwd,r=n.under,u=S({canvasName:n.canvas}),a=u instanceof q?m:m===void 0?void 0:(await M(m)).id,f=r!==void 0&&r!=="";if(f&&await u.getNode(r).catch(w)===null)throw new k({error:"not_found",message:`no node: ${r}`,next:"List nodes with `crtr node inspect list`, then pass a real id to --under."});return{nodes:(await u.listNodes({...o!==void 0?{status:o}:{},...f?{under:r}:{}}).catch(w)).filter(d=>!(s!==void 0&&!s.includes(d.kind)||p!==void 0&&!p.includes(d.mode)||i!==void 0&&!i.includes(d.lifecycle)||a!==void 0&&d.profile_id!==a||l!==void 0&&l!==""&&d.cwd!==l)).map(d=>({...d,name:$(d)})).filter(d=>c===void 0||c===""||F(c,d.name))}},"run")}),j=new WeakSet,T=new WeakSet;async function N(n,e){const o=await n.getNode(e.node_id).catch(w);return{node_id:e.node_id,name:o?$(o):"(missing)",kind:o?.kind??"?",status:o?o.intent?`${o.status}/${o.intent}`:o.status:"?",active:e.active}}h(N,"enrichNeighbor");const V=_({name:"show",description:"show a node + its spine neighbors and drill-in pointers",whenToUse:"you want one node in depth \u2014 the debugging entrypoint: a glanceable meta slice, named spine neighbors, a pending-cron count, and exact drill-in paths. Use `node inspect list` for the flat roster or `canvas dashboard` for the whole-tree shape",help:{name:"node inspect show",summary:"show a node in depth \u2014 meta slice, named neighbors, pending-cron count, and drill-in pointers",params:[{kind:"positional",name:"node",required:!0,constraint:"Node id."},{kind:"flag",name:"canvas",type:"string",required:!1,constraint:"Read from the named remote canvas target (see `crtr canvas config list`) instead of the local canvas. Overrides `crtr canvas use`."}],output:[{name:"node",type:"object",required:!0,constraint:"The full node meta (system prompt + every telemetry field). The render surfaces a glanceable slice; `--json` carries the complete dump."},{name:"fault",type:"object",required:!0,constraint:"The active runtime fault projection, or null: {link, kind, retry: {disposition}, since}."},{name:"reports",type:"object[]",required:!0,constraint:"Who this node subscribes to (its reports/down), each enriched with {node_id, name, kind, status, active} \u2014 these are typically its spawned children."},{name:"managers",type:"object[]",required:!0,constraint:"Who subscribes to this node (its managers/up), same enriched shape."},{name:"pending_crons",type:"number",required:!0,constraint:"How many pending crons were created by this node. Inspect with `crtr cron list`."},{name:"paths",type:"object",required:!0,constraint:"Resolved on-disk locations: {context_dir, session_file} \u2014 read these directly to debug. Reports are documents: `crtr canvas read <node>/reports/<name>`."},{name:"follow_up",type:"string",required:!0,constraint:"The concrete next commands to drill deeper."}],outputKind:"object",effects:["Read-only: reads the node, its edges, and pending crons through crtrd."],preview:{suppressOutput:!0}},run:h(async n=>{const e=n.node,o=n.canvas,s=S({canvasName:o});if(s instanceof q){const t=await s.rawShow(e);if(t===null)throw new k({error:"not_found",message:`no node: ${e}`,next:"List nodes with `crtr node inspect list --canvas <name>`."});const y={...t};return j.add(y),y}const 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=x(),c=await Promise.all((await s.subscriptionsOf(e)).map(t=>N(s,t))),l=await Promise.all((await s.subscribersOf(e)).map(t=>N(s,t))),r=(await m.listCrons({created_by:e}).catch(w)).filter(t=>t.created_by===e).length,u={context_dir:i.paths.context_dir,...i.pi_session_file!==void 0?{session_file:i.pi_session_file}:{}},a=[];a.push(`List the documents it owns (reports, plans, notes): \`crtr canvas list --owner ${e}\`.`),a.push(`Browse its context dir (and its subscriptions') in nvim: \`crtr node inspect context ${e}\`.`),u.session_file&&a.push(`Read the raw conversation transcript: ${u.session_file}`),a.push(`On-disk context dir (ls/read directly): ${u.context_dir}`),r>0&&a.push(`It created ${r} pending cron(s): \`crtr cron list\`.`),c.length>0&&a.push(`Drill into a child/report: \`crtr node inspect show <node_id>\` (${c.map(t=>t.node_id).join(", ")}).`),a.push(`Full machine dump (system prompt + all telemetry): \`crtr --json node inspect show ${e}\`.`);const f={node:i,fault:i.fault??null,reports:c,managers:l,pending_crons:r,paths:u,follow_up:a.join(`
3
- `)};return(i.runner==="blaxel"||i.profile_id!==null&&await m.getProfileEnvironment(i.profile_id).then(()=>!0,t=>t instanceof D&&(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)":A(s)?"alive":"dead",m=e.intent?`/${String(e.intent)}`:"",c=n.fault,l=[];l.push(`# ${$(e)} (${o})`);const r=[`- kind/mode/lifecycle: ${e.kind} / ${e.mode} / ${e.lifecycle}`,`- status: ${e.status}${m}`,...c==null?[]:[`- fault: ${String(c.kind)} / ${String(c.retry?.disposition)} since ${String(c.since)}`],`- broker pid: ${s??"(none)"} \u2014 ${i}`,`- cwd: ${e.cwd}`,`- host: ${e.host_kind}`+(e.profile_id?` \xB7 profile ${e.profile_id}`:""),`- cycles: ${e.cycles} \xB7 created ${e.created}`],u=e.machine;u&&r.push(`- machine: ${u.name??u.id}`),e.parent&&r.push(`- parent: ${e.parent}`),r.push(`- creator: ${e.creator??"an external process"}`),e.waiting_for&&r.push(`- waiting for message: ${e.waiting_for}`),l.push(r.join(`
4
- `));const a=h((f,g)=>{if(g.length===0)return`${f}: none`;const t=["node_id","name","kind","status","active"],y=`| ${t.join(" | ")} |`,d=`| ${t.map(()=>"---").join(" | ")} |`,b=g.map(v=>`| ${t.map(R=>String(v[R]??"").replace(/\|/g,"\\|").replace(/\n/g," ")).join(" | ")} |`).join(`
1
+ var P=Object.defineProperty;var h=(n,e)=>P(n,"name",{value:e,configurable:!0});import{defineBranch as A,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 O}from"../../core/tui/fuzzy.js";import{nodeSnapshotLeaf as F}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. On the local canvas, accepts a profile id or manifest name from the <profiles> list below, or a close-enough name that resolves to the nearest profile. Against a remote canvas, pass the exact profile id carried by its node rows."},{kind:"flag",name:"name",type:"string",required:!1,constraint:"Filter by the displayed node label (handle plus generated description) with the canvas browser\u2019s case-insensitive fuzzy subsequence match."},{kind:"flag",name:"cwd",type:"string",required:!1,constraint:"Filter to nodes pinned to this exact cwd (absolute path). Roster is canvas-wide (all cwds) by default."},{kind:"flag",name:"under",type:"string",required:!1,constraint:'Graph scope: restrict to this node and its subscription descendants (the sub-DAG reachable downward \u2014 its reports, theirs, \u2026). This is "one initiative / my subtree". ANDs with every attribute filter above, narrowing any of them to this subtree.'},{kind:"flag",name:"canvas",type:"string",required:!1,constraint:"Read from the named remote canvas target (see `crtr canvas config list`) instead of the local canvas. Overrides `crtr canvas use`."}],output:[{name:"nodes",type:"object[]",required:!0,constraint:"Rows include {node_id, name, kind, mode, lifecycle, status, cwd, profile_id, parent, created}. `name` is the displayed node label searched by --name and shown in canvas views. `profile_id` is the stable profile-directory id (null only for historical no-profile nodes)."}],outputKind:"object",effects:["Read-only: lists nodes through the daemon API."]},helpState:{leaf:h(async()=>(await Promise.all([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"),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 B(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 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 local canvas. Overrides `crtr canvas use`."}],output:[{name:"node",type:"object",required:!0,constraint:"The full node meta (system prompt + every telemetry field). The render surfaces a glanceable slice; `--json` carries the complete dump."},{name:"fault",type:"object",required:!0,constraint:"The active runtime fault projection, or null: {link, kind, retry: {disposition}, since}."},{name:"reports",type:"object[]",required:!0,constraint:"Who this node subscribes to (its reports/down), each enriched with {node_id, name, kind, status, active} \u2014 these are typically its spawned children."},{name:"managers",type:"object[]",required:!0,constraint:"Who subscribes to this node (its managers/up), same enriched shape."},{name:"pending_crons",type:"number",required:!0,constraint:"How many pending crons were created by this node. Inspect with `crtr cron list`."},{name:"paths",type:"object",required:!0,constraint:"Resolved on-disk locations: {context_dir, session_file} \u2014 read these directly to debug. Reports are documents: `crtr canvas read <node>/reports/<name>`."},{name:"follow_up",type:"string",required:!0,constraint:"The concrete next commands to drill deeper."}],outputKind:"object",effects:["Read-only: reads the node, its edges, and pending crons through crtrd."],preview:{suppressOutput:!0}},run:h(async n=>{const e=n.node,o=n.canvas,s=S({canvasName:o});if(s instanceof q){const t=await s.rawShow(e);if(t===null)throw new k({error:"not_found",message:`no node: ${e}`,next:"List nodes with `crtr node inspect list --canvas <name>`."});const y={...t};return j.add(y),y}const 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: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 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)":L(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}.`}${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((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
5
  `);return`${g.length} ${f}:
6
6
 
7
7
  ${y}
8
- ${d}
9
- ${b}`},"table");return l.push(a("reports (down \u2014 subscriptions, usually children)",n.reports)),l.push(a("managers (up \u2014 subscribers)",n.managers)),l.push(`${n.pending_crons} pending cron(s)`),l.push(`Drill deeper:
8
+ ${c}
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")}),de=_({name:"fork",description:"fork a node into an independent idle root with the same conversation and durable context",whenToUse:"a conversation has already accumulated the context you want, and you want a new user-driven branch beside it without sending a prompt or inheriting any graph-management responsibility. This copies the conversation and durable context, then waits for the fork\u2019s first real user message to supply its mandate. Use `node new --fork-from` instead when spawning a managed worker with an immediate task",help:{name:"node fork",summary:"create an independent resident root from a node\u2019s conversation and durable context, with no kickoff prompt or model turn",params:[{kind:"flag",name:"node",type:"string",required:!1,constraint:"Source node id. Mutually exclusive with --pane; one of them is required."},{kind:"flag",name:"pane",type:"string",required:!1,constraint:"tmux pane showing the source node. Mutually exclusive with --node; one of them is required. The prefix menu passes this for you and the new viewer splits beside this pane."}],output:[{name:"node_id",type:"string",required:!0,constraint:"The new independent root id."},{name:"focused",type:"boolean",required:!0,constraint:"True when a new viewer pane opened beside the caller; false outside tmux."},{name:"session",type:"string",required:!1,constraint:"The tmux session containing the new viewer, when one opened."}],outputKind:"object",effects:["Creates a resident base-mode root with the source node\u2019s copied pi conversation, cwd, profile, kind, model override, and durable context files. Top-level initial-prompt.md, yield-message.md, result.json, and the jobs/ folder of background bash jobs are omitted.","Copies no parent, subscriptions, subscribers, children, crons, worktree, situational context, or lifecycle responsibility. Sends no prompt and consumes no model turn; the first real user message becomes the fork\u2019s mandate.","Inside tmux, opens and focuses a surface-attach viewer as an even-horizontal split in the source pane\u2019s window. Outside tmux, the root is still created but no interactive fallback opens."]},run:h(async n=>{O("crtr:act","crtr node fork");const e=n.pane,o=n.node;if(o!==void 0&&e!==void 0)throw new k({error:"conflicting_target",message:"--node and --pane are mutually exclusive",next:"Pass the source node id or its viewer pane, not both."});let s=o;if(s===void 0&&e!==void 0&&(s=W(e)),s===void 0||s==="")throw new k({error:"no_node",message:"no source node was provided or found in the pane",next:"Pass --node <id>, or --pane <pane-id> for a pane showing a node."});const p=await x().forkNode(s).catch(w),i=await B(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")}),ce=I({name:"inspect",description:"read one node \u2014 its graph position, conversation, and context dir",whenToUse:"reading everything about ONE node you can name: enumerate the roster (`list`), inspect a node and its spine neighbors (`show`), or browse its on-disk context dir (`context`). The documents a node owns are `crtr canvas list --owner <id>`. Use `canvas dashboard` instead to render the whole tree SHAPE, or `canvas attention` to find which nodes are blocked on the user",help:{name:"node inspect",summary:"read one node (or the roster) \u2014 topology, conversation, and context dir",model:"Inspection is read-only and never revives a node. The roster is the selection surface; one-node metadata points to progressively heavier views: a parsed broker snapshot, rendered conversation, or context browser."},children:[K,V,L,C,U]});export{de as nodeFork,ce as nodeInspect};
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=A({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,F,C,U]});export{le as nodeFork,ue as nodeInspect};
@@ -64,7 +64,7 @@ export interface CommandNode {
64
64
  streaming: boolean;
65
65
  };
66
66
  }
67
- /** `crtr exa-search web` — how a user types the command a node names. The one place
67
+ /** `crtr capture shot` — how a user types the command a node names. The one place
68
68
  * a command path becomes a label, so no corner of the page invents its own. */
69
69
  export declare function commandLabel(node: CommandNode): string;
70
70
  /** Every node in a command forest, parents before their children. */
@@ -1,2 +1,2 @@
1
- var g=Object.defineProperty;var i=(e,r)=>g(e,"name",{value:r,configurable:!0});import{readFileSync as y}from"node:fs";import{resolve as w}from"node:path";import{defineLeaf as p,defineBranch as b}from"../../core/command.js";import{usage as u}from"../../core/errors.js";import{cliClient as m}from"../api-client.js";import{resolveProfileViaDaemon as c}from"./daemon-profiles.js";const d={kind:"flag",name:"profile",type:"string",required:!0,constraint:"Profile id or manifest name; a close-enough name resolves to the nearest profile, reported on stderr."},f=[{name:"profile_id",type:"string",required:!0,constraint:"Stable profile id."},{name:"repositories",type:"string[]",required:!0,constraint:"`owner/name` in checkout order; the first is where nodes start (`/work/<name>`)."},{name:"setup_script",type:"string",required:!1,constraint:"The script the image build runs; null when none."},{name:"pi_packages",type:"string",required:!1,constraint:"pi package sources, one per line; null when none."},{name:"memory_mb",type:"number",required:!0,constraint:"Memory of new sandboxes: 2048, 4096 or 8192."},{name:"allow_pull_request_write",type:"boolean",required:!0,constraint:"Whether sandboxes may open and merge pull requests: their GitHub credential carries pull_requests write besides contents write. On by default."},{name:"recipe_revision",type:"number",required:!0,constraint:"Raised by one each time the recipe changes."},{name:"image_revision",type:"number",required:!1,constraint:"The recipe revision the current image was built from; the image is ready when it equals recipe_revision. Null before the first build."},{name:"image_error",type:"string",required:!1,constraint:"Why the last image build failed; null when it did not."}];function h(e){const{environment_id:r,...n}=e;return n}i(h,"output");const k=p({name:"show",description:"show a cloud profile's recipe, memory and image state",whenToUse:"checking what a dev profile builds and runs in, or whether the image for its latest recipe is ready (`image_revision` equals `recipe_revision`).",help:{name:"profile environment show",summary:"a cloud profile's environment: repositories, setup script, pi packages, memory and image build state",params:[d],output:[...f],outputKind:"object",effects:["Read-only. Refuses a profile that does not run in a cloud environment."]},run:i(async e=>{const{id:r}=await c(e.profile);return h(await m().getProfileEnvironment(r))},"run")}),q=p({name:"set",description:"change a cloud profile's repositories, setup script, pi packages, memory or pull request merging",whenToUse:"a dev profile needs other repositories, a setup script for its image (run as root in the build, working directory `/work`), pi packages, or more memory. A flag left out keeps its value.",help:{name:"profile environment set",summary:"change a cloud profile's environment recipe or memory",params:[d,{kind:"flag",name:"repo",type:"string",required:!1,repeatable:!0,constraint:"GitHub repository `owner/name` (repeat per repository); replaces the whole list. The GitHub App must be installed on each."},{kind:"flag",name:"setup-script-file",type:"path",required:!1,constraint:"File holding the setup script the image build runs as root."},{kind:"flag",name:"pi-package",type:"string",required:!1,repeatable:!0,constraint:"pi package source (repeat per package); replaces the whole list."},{kind:"flag",name:"allow-pull-request-write",type:"bool",required:!1,constraint:"On by default: sandboxes may open and merge pull requests (their GitHub credential carries pull_requests write). `--no-allow-pull-request-write` drops to contents write only, so sandboxes can push branches but not open pull requests. Takes effect on the next credential a sandbox fetches; builds no image."},{kind:"flag",name:"memory",type:"int",required:!1,constraint:"Sandbox memory in GB: 2, 4 or 8. Reaches sandboxes created after the change; a running sandbox keeps its memory."}],output:[...f],outputKind:"object",effects:["A changed recipe raises `recipe_revision`, and the daemon builds a new image for it; check `profile environment show`. A recipe identical to the stored one changes nothing."]},run:i(async e=>{const{id:r}=await c(e.profile),n=e.repo,s=e.setupScriptFile,o=e.piPackage,t=e.memory,a=e.allowPullRequestWrite;if(t!==void 0&&![2,4,8].includes(t))throw u("`--memory` is 2, 4 or 8 (GB).");const l={...n!==void 0&&n.length>0?{repositories:n}:{},...s!==void 0?{setup_script:y(w(s),"utf8")}:{},...o!==void 0&&o.length>0?{pi_packages:o.join(`
2
- `)}:{},...t!==void 0?{memory_mb:t*1024}:{},...a!==void 0?{allow_pull_request_write:a}:{}};if(Object.keys(l).length===0)throw u("pass at least one of `--repo`, `--setup-script-file`, `--pi-package`, `--memory`, `--allow-pull-request-write`.");return h(await m().setProfileEnvironment(r,l))},"run")}),A=b({name:"environment",description:"a cloud profile's recipe (repositories, setup script, pi packages) and sandbox memory",whenToUse:"viewing or changing what a cloud dev profile's sandboxes are built from and how much memory they get.",help:{name:"profile environment",summary:"a cloud profile's environment recipe and memory",model:"A cloud profile runs its nodes in Blaxel sandboxes. Its environment holds the recipe the sandbox image is built from; changing the recipe makes the daemon build a new image, and new sandboxes use it. Memory applies to new sandboxes only."},children:[k,q]});export{A as environmentBranch};
1
+ var g=Object.defineProperty;var n=(e,r)=>g(e,"name",{value:r,configurable:!0});import{readFileSync as y}from"node:fs";import{resolve as w}from"node:path";import{defineLeaf as s,defineBranch as b}from"../../core/command.js";import{usage as c}from"../../core/errors.js";import{cliClient as m}from"../api-client.js";import{STARTER_SETUP_SCRIPT as v}from"../../core/environment-starter-script.js";import{resolveProfileViaDaemon as d}from"./daemon-profiles.js";const u={kind:"flag",name:"profile",type:"string",required:!0,constraint:"Profile id or manifest name; a close-enough name resolves to the nearest profile, reported on stderr."},h=[{name:"profile_id",type:"string",required:!0,constraint:"Stable profile id."},{name:"repositories",type:"string[]",required:!0,constraint:"`owner/name` in checkout order; the first is where nodes start (`/work/<name>`)."},{name:"setup_script",type:"string",required:!1,constraint:"The script the image build runs; null when none."},{name:"pi_packages",type:"string",required:!1,constraint:"pi package sources, one per line; null when none."},{name:"memory_mb",type:"number",required:!0,constraint:"Memory of new sandboxes: 2048, 4096 or 8192."},{name:"allow_pull_request_write",type:"boolean",required:!0,constraint:"Whether sandboxes may open and merge pull requests: their GitHub credential carries pull_requests write besides contents write. On by default."},{name:"recipe_revision",type:"number",required:!0,constraint:"Raised by one each time the recipe changes."},{name:"image_revision",type:"number",required:!1,constraint:"The recipe revision the current image was built from; the image is ready when it equals recipe_revision. Null before the first build."},{name:"image_error",type:"string",required:!1,constraint:"Why the last image build failed; null when it did not."}];function f(e){const{environment_id:r,...t}=e;return t}n(f,"output");const k=s({name:"show",description:"show a cloud profile's recipe, memory and image state",whenToUse:"checking what a dev profile builds and runs in, or whether the image for its latest recipe is ready (`image_revision` equals `recipe_revision`).",help:{name:"profile environment show",summary:"a cloud profile's environment: repositories, setup script, pi packages, memory and image build state",params:[u],output:[...h],outputKind:"object",effects:["Read-only. Refuses a profile that does not run in a cloud environment."]},run:n(async e=>{const{id:r}=await d(e.profile);return f(await m().getProfileEnvironment(r))},"run")}),q=s({name:"starter",description:"print a commented starter setup script to copy and fill in",whenToUse:"writing the first setup script for a cloud profile, or looking up what the image build already does and where secrets go.",help:{name:"profile environment starter",summary:"print a commented starter setup script with example sections",params:[],output:[],outputKind:"object",effects:["Prints the script as-is to stdout: redirect it to a file (`> setup.sh`), edit it, pass it to `profile environment set --setup-script-file`. Read-only; changes no profile and builds no image."]},run:n(async()=>{process.stdout.write(v)},"run")}),_=s({name:"set",description:"change a cloud profile's repositories, setup script, pi packages, memory or pull request merging",whenToUse:"a dev profile needs other repositories, a setup script for its image, pi packages, or more memory. A flag left out keeps its value. For a first setup script, start from `crtr profile environment starter`.",help:{name:"profile environment set",summary:"change a cloud profile's environment recipe or memory",params:[u,{kind:"flag",name:"repo",type:"string",required:!1,repeatable:!0,constraint:"GitHub repository `owner/name` (repeat per repository); replaces the whole list. The GitHub App must be installed on each."},{kind:"flag",name:"setup-script-file",type:"path",required:!1,constraint:"File holding the setup script. The image build runs it once as root in `/work` on Alpine (apk), after checking out the repositories into `/work/<name>` and downloading every pnpm-lock.yaml repository's packages into a shared pnpm store; output lands in `/work/.crtr/setup.log`, and a non-zero exit stops sandboxes from starting. `crtr profile environment starter` prints a commented template."},{kind:"flag",name:"pi-package",type:"string",required:!1,repeatable:!0,constraint:"pi package source (repeat per package); replaces the whole list."},{kind:"flag",name:"allow-pull-request-write",type:"bool",required:!1,constraint:"On by default: sandboxes may open and merge pull requests (their GitHub credential carries pull_requests write). `--no-allow-pull-request-write` drops to contents write only, so sandboxes can push branches but not open pull requests. Takes effect on the next credential a sandbox fetches; builds no image."},{kind:"flag",name:"memory",type:"int",required:!1,constraint:"Sandbox memory in GB: 2, 4 or 8. Reaches sandboxes created after the change; a running sandbox keeps its memory."}],output:[...h],outputKind:"object",effects:["A changed recipe raises `recipe_revision`, and the daemon builds a new image for it; check `profile environment show`. A recipe identical to the stored one changes nothing.","Secrets never go in the setup script, because it is baked into the image: store them with `crtr profile env set <profile> --name <NAME>` and every sandbox gets them as environment variables."]},run:n(async e=>{const{id:r}=await d(e.profile),t=e.repo,a=e.setupScriptFile,o=e.piPackage,i=e.memory,p=e.allowPullRequestWrite;if(i!==void 0&&![2,4,8].includes(i))throw c("`--memory` is 2, 4 or 8 (GB).");const l={...t!==void 0&&t.length>0?{repositories:t}:{},...a!==void 0?{setup_script:y(w(a),"utf8")}:{},...o!==void 0&&o.length>0?{pi_packages:o.join(`
2
+ `)}:{},...i!==void 0?{memory_mb:i*1024}:{},...p!==void 0?{allow_pull_request_write:p}:{}};if(Object.keys(l).length===0)throw c("pass at least one of `--repo`, `--setup-script-file`, `--pi-package`, `--memory`, `--allow-pull-request-write`.");return f(await m().setProfileEnvironment(r,l))},"run")}),U=b({name:"environment",description:"a cloud profile's recipe (repositories, setup script, pi packages) and sandbox memory",whenToUse:"viewing or changing what a cloud dev profile's sandboxes are built from and how much memory they get.",help:{name:"profile environment",summary:"a cloud profile's environment recipe and memory",model:"A cloud profile runs its nodes in Blaxel sandboxes. Its environment holds the recipe the sandbox image is built from: repositories, a setup script and pi packages. Changing the recipe makes the daemon build a new image, and new sandboxes use it. Memory applies to new sandboxes only. The build always checks out the repositories into `/work/<name>`, installs git, gh, Node and pnpm, and downloads each pnpm repository's packages into a shared store; the setup script adds the rest (`starter` prints a template). API keys and other secrets live in `crtr profile env`, never in the recipe."},children:[k,q,_]});export{U as environmentBranch};
@@ -4,7 +4,7 @@ import { type TerminalConfigEdit } from './terminal-option.js';
4
4
  export declare const OFFICIAL_MARKETPLACE_NAME = "crouter-official-marketplace";
5
5
  export declare const OFFICIAL_MARKETPLACE_URL = "https://github.com/crouton-labs/crouter-official-marketplace.git";
6
6
  export declare const OFFICIAL_MARKETPLACE_REF = "main";
7
- export type SetupPackageId = 'official-marketplace' | 'crtr-extensions' | 'oauth-adapter' | 'capture-plugin' | 'exa-search-plugin' | 'dev-plugin';
7
+ export type SetupPackageId = 'official-marketplace' | 'crtr-extensions' | 'oauth-adapter' | 'capture-plugin' | 'dev-plugin';
8
8
  /** `nerd-font` is not a command on PATH like the other two — it is an installed
9
9
  * font face, detected by fontconfig/font-directory scan. The viewer renders
10
10
  * every tool and command icon with Nerd Font codepoints, so without it a fresh
@@ -1,9 +1,9 @@
1
- var re=Object.defineProperty;var a=(e,t)=>re(e,"name",{value:t,configurable:!0});import{spawn as ie,spawnSync as se}from"node:child_process";import{homedir as x,tmpdir as ae}from"node:os";import{mkdtempSync as oe,rmSync as ce}from"node:fs";import{piAgentDir as P}from"../../core/runtime/package-health.js";import{basename as le,dirname as _,join as m,relative as ue,resolve as de}from"node:path";import{isDeepStrictEqual as w}from"node:util";import{BINDING_CATALOG as pe,normalizeGesture as fe,splitGestureExpression as he,inboxShortcut as me,resolveKeybindings as S}from"../../core/keybindings/index.js";import{runtimeManifest as ge}from"./shared.js";import{atomicWriteJson as ke,readJsonIfExists as ve,readJsonOrNull as L}from"../../core/fs-utils.js";import{resolveBundledPiCliPath as we}from"../../core/runtime/pi-cli.js";import{crtrVersion as xe}from"../../shared/crtr-version.js";import{installTmuxBindings as be}from"../../core/runtime/tmux-chrome.js";import{normalizeTmuxPassthrough as ye}from"../../core/config.js";import{detectNerdFont as Ie,nerdFontInstallCommand as Pe,createCurlPercentReader as Se,NERD_FONT_MANUAL_LINUX_COMMAND as Ce,NERD_FONT_SELECT_HINT as Ee}from"../../core/runtime/nerd-font.js";import{startProgressBar as Ae}from"../../core/runtime/progress-bar.js";import{ensureRenderer as $e,isRendererReady as K}from"../../core/termrender/termrender.js";import{installFromMarketplace as Re,isMarketplaceRelativeSource as De}from"../pkg/plugin-manage.js";import{requiredPluginEnv as Me}from"../../core/plugin-env.js";import{readPluginManifest as Ne}from"../../core/manifest.js";import{addMarketplace as j}from"../pkg/market-manage.js";import{clone as Te}from"../../core/git.js";import{readMarketplaceManifest as Oe}from"../../core/manifest.js";import{findPluginByName as F,findMarketplaceByName as C}from"../../core/resolver.js";import{expandTilde as _e}from"../../core/fs-utils.js";import{applyTerminalEdit as Le}from"./terminal-option.js";const E="crouter-official-marketplace",A="https://github.com/crouton-labs/crouter-official-marketplace.git",$="main";function It(e){const t=[],n=new Set,r=new Map;try{for(const o of e){if(o.sourceKind!=="marketplace-plugin")continue;const[l,c]=o.installSource.split("/");if(!l||!c)continue;const u=F(c,"user")?.manifest;let d=C(l,"user");if(!d&&!u&&l===E)try{let i=r.get(l);i||(i=oe(m(ae(),"crtr-setup-market-")),r.set(l,i),Te(A,m(i,"checkout"),{ref:$,depth:1}));const p=m(i,"checkout"),v=Oe(p);v&&(d={root:p,manifest:v})}catch{}const h=d?.manifest.plugins.find(i=>i.name===c)?.source,f=h&&De(h)?Ne(m(d.root,h))??u:u;if(f)for(const i of Me(f.env))n.has(i)||(n.add(i),t.push({name:i,plugin:c,declaration:f.env[i]}))}}finally{for(const o of r.values())ce(o,{recursive:!0,force:!0})}return t}a(It,"setupPluginEnvFields");function G(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}a(G,"isKeybindingsObject");function g(e){return G(e)?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Array.isArray(n)?[...n]:n])):{}}a(g,"cloneKeybindings");class Pt{static{a(this,"SetupKeybindingsDraft")}expected;baseline;current;baselineInvalidRoot;invalidRoot;resolutionCache;expectedPassthrough;baselinePassthrough;currentPassthrough;constructor(t,n=void 0){this.expected=t,this.baseline=g(t),this.current=g(t),this.baselineInvalidRoot=t!==void 0&&!G(t)?t:void 0,this.invalidRoot=this.baselineInvalidRoot,this.expectedPassthrough=n,this.baselinePassthrough=ye(n),this.currentPassthrough=[...this.baselinePassthrough]}get dirty(){return!w(this.current,this.baseline)||!w(this.invalidRoot,this.baselineInvalidRoot)||!w(this.currentPassthrough,this.baselinePassthrough)}overrides(){return g(this.current)}expectedKeybindings(){return this.expected}tmuxPassthrough(){return[...this.currentPassthrough]}expectedTmuxPassthrough(){return this.expectedPassthrough}usesTmuxPassthrough(t){return this.currentPassthrough.includes(t)}toggleTmuxPassthrough(t){this.currentPassthrough=this.currentPassthrough.includes(t)?this.currentPassthrough.filter(n=>n!==t):[...this.currentPassthrough,t]}resolution(){return this.resolutionCache===void 0&&(this.resolutionCache=S(this.invalidRoot===void 0?this.current:this.invalidRoot)),this.resolutionCache}hasInvalidRoot(){return this.invalidRoot!==void 0}expression(t){return this.resolution().gestures(t).join(", ")}edit(t,n){if(this.invalidRoot!==void 0)return{ok:!1,diagnostics:[{severity:"error",code:"invalid-keybindings",offendingValue:this.invalidRoot,message:"Reset all before editing: the saved keybindings root is invalid."}]};const r=pe.find(f=>f.id===t);let o;try{o=n.trim()===""?[]:he(n).map(f=>fe(f.trim(),r))}catch(f){return{ok:!1,diagnostics:[{severity:"error",code:"invalid-override",bindingId:t,offendingValue:n,message:f instanceof Error?f.message:String(f)}]}}const l=[...new Set(o)],c={...this.current};delete c[t];const u=[...S(c).gestures(t)],s=w(l,u)?c:{...this.current,[t]:l},d=S(s),h=d.diagnostics.filter(f=>f.bindingId===t||f.relatedBindingIds?.includes(t));return h.length>0?{ok:!1,diagnostics:h}:(this.current=s,this.resolutionCache=void 0,{ok:!0,diagnostics:d.diagnostics})}unbind(t){return this.edit(t,"")}resetRow(t){delete this.current[t],this.resolutionCache=void 0}resetAll(){this.current={},this.currentPassthrough=[],this.invalidRoot=void 0,this.resolutionCache=void 0}discard(){this.current=g(this.baseline),this.currentPassthrough=[...this.baselinePassthrough],this.invalidRoot=this.baselineInvalidRoot,this.resolutionCache=void 0}markSaved(t,n=[]){this.expected=Object.keys(t).length===0?void 0:g(t),this.baseline=g(t),this.current=g(t),this.expectedPassthrough=[...n],this.baselinePassthrough=[...n],this.currentPassthrough=[...n],this.baselineInvalidRoot=void 0,this.invalidRoot=void 0,this.resolutionCache=void 0}}const Ke={"official-marketplace":{name:E,shortDescription:"the official crtr plugin catalog \u2014 registered as a source so its plugins are installable by ref.",longDescription:"Shallow-clones github.com/crouton-labs/crouter-official-marketplace into the user scope and registers it, which is what makes `crtr pkg plugin install crouter-official-marketplace/<name>` resolve and what fills `crtr pkg market browse`. Registering the source installs no plugin by itself. Uncheck it on a machine that should reach no external catalog \u2014 a plugin selected below still registers the marketplace it comes from, because its ref cannot resolve otherwise."},"crtr-extensions":{name:"pi-crtr-extensions",shortDescription:"crtr companion extensions \u2014 command palette, help gating, subscription/OAuth rotation, nested context.",longDescription:"Bundles the extensions built for crtr: a crtr slash-command palette, crtr/crouter help gating, surfacing of Claude Code marketplace plugin commands, nested AGENTS.md/CLAUDE.md loading, OAuth login + rotation across multiple Claude subscriptions (provider-rotation), and system-prompt trimming. The OAuth/rotation piece is what lets crtr authenticate your Claude account."},"oauth-adapter":{name:"pi-claude-oauth-adapter",shortDescription:"Anthropic OAuth / Claude Code credential compatibility for pi.",longDescription:"Third-party adapter (minzique/dotfiles-agents) letting pi authenticate with Claude using Claude Code OAuth credentials. Installed from npm, pinned to 0.2.2."},"capture-plugin":{name:"capture",shortDescription:"crtr plugin mounting `crtr capture` \u2014 browser automation and UI measurement over CDP.",longDescription:"Installs the `capture` plugin from the official crtr marketplace. It mounts `crtr capture` as a transparent passthrough to the external Capture CLI (`npm install -g @crouton-kit/capture`) for CDP screenshots, rendered-geometry measurement, HAR, accessibility trees, and JS execution against a live page. Uncheck it on a machine where agents never drive a browser \u2014 the command then costs nothing in their root prompt."},"exa-search-plugin":{name:"exa-search",shortDescription:"crtr plugin mounting `crtr exa-search` \u2014 public-web discovery, grounded answers, and content extraction.",longDescription:"Installs the `exa-search` plugin from the official crtr marketplace. It mounts `crtr exa-search` and calls Exa directly with EXA_API_KEY, collected during install or set through `crtr sys env set --name EXA_API_KEY` in the app env store. Uncheck it on a machine whose agents get web search from somewhere else, such as a Northlight home where the platform serves `crtr search` from its own plugin."},"dev-plugin":{name:"dev",shortDescription:"crtr plugin mounting the development workflow \u2014 repository setup, worktrees, pull requests, and a dev track in the tutorial.",longDescription:"Installs the dev plugin from the official crtr marketplace. It adds the /dev: workflow commands (init, spec, design, plan, pr-loop), mounts crtr dev for a repository's own lifecycle commands and Grove instances, and contributes the crtr sys tutorial dev track. Uncheck it on a machine whose agents do not work in source repositories."}},R={"official-marketplace":{kind:"marketplace-source",source:A},"crtr-extensions":{kind:"local-path",source:U("pi-crtr-extensions")},"oauth-adapter":{kind:"npm",source:"npm:pi-claude-oauth-adapter@0.2.2"},"capture-plugin":{kind:"marketplace-plugin",source:"crouter-official-marketplace/capture"},"exa-search-plugin":{kind:"marketplace-plugin",source:"crouter-official-marketplace/exa-search"},"dev-plugin":{kind:"marketplace-plugin",source:"crouter-official-marketplace/dev"}},B=["extensions/*.ts","extensions/*/index.ts","!extensions/**/*.d.ts"],je={"official-marketplace":[],"crtr-extensions":["pi-crtr-extensions"],"oauth-adapter":[],"capture-plugin":[],"exa-search-plugin":[],"dev-plugin":[]};function U(e){return m(ge.runtimeHome(),"selected","dist","builtin-pi-packages",e)}a(U,"selectedPiPackageDir");function D(e=U){return["official-marketplace","crtr-extensions","oauth-adapter","capture-plugin","exa-search-plugin","dev-plugin"].map(t=>{const n=Ke[t],r=R[t].kind==="local-path"?e(n.name):R[t].source;return{id:t,name:n.name,sourceKind:R[t].kind,installSource:r,shortDescription:n.shortDescription,longDescription:n.longDescription}})}a(D,"buildSetupManifest");function St(e){switch(e.sourceKind){case"marketplace-source":return`clone + register ${e.installSource}`;case"marketplace-plugin":return`crtr pkg plugin install ${e.installSource}`;default:return`pi install ${e.installSource}`}}a(St,"packagePlanAction");function Fe(e){if(!e.startsWith("npm:"))return null;const t=e.slice(4),n=t.startsWith("@")?t.indexOf("@",1):t.lastIndexOf("@");return n>0?t.slice(0,n):t}a(Fe,"npmPackageName");function b(e,t,n){const r=Fe(e);if(r!==null)return`npm:${r}`;const o=_e(e,n);return de(t,o)}a(b,"normalizePackageIdentity");function y(e){return`package:${e}`}a(y,"packageNameIdentity");function Y(e){return e.startsWith("npm:")?[]:[y(le(e))]}a(Y,"localPackageNameIdentities");function Ge(e,t,n){const r=[b(e.installSource,t,n)];if(e.sourceKind==="local-path"){r.push(y(e.name));for(const o of je[e.id])r.push(y(o))}return r}a(Ge,"manifestIdentities");function z(e,t=D(),n=m(P(),"settings.json"),r=x()){const o=_(n),l=new Set,c=new Map;for(const s of t)for(const d of Ge(s,o,r))c.set(d,s.id);const u=e&&typeof e=="object"?e.packages:void 0;if(!Array.isArray(u))return l;for(const s of u){const d=typeof s=="string"?s:s&&typeof s=="object"&&typeof s.source=="string"?s.source:null;if(d===null)continue;const h=[b(d,o,r),...Y(d)];for(const f of h){const i=c.get(f);if(i==="crtr-extensions"){const p=t.find(v=>v.id===i);if(b(d,o,r)!==b(p.installSource,o,r)||!s||typeof s!="object"||!w(s.extensions,B))continue}i!==void 0&&l.add(i)}}return l}a(z,"detectInstalledSetupPackageIds");function k(e){return se("sh",["-lc",`command -v ${e} >/dev/null 2>&1`],{stdio:"ignore"}).status===0}a(k,"detectCommandOnPath");function Be(e=process.platform,t=k){switch(e){case"darwin":return t("brew")?"brew":"manual";case"linux":return t("apt-get")?"apt-get":t("dnf")?"dnf":t("pacman")?"pacman":"manual";default:return"manual"}}a(Be,"detectPackageManager");function Ue(e,t,n=k){if(e==="nerd-font"?Ie().installed:n(e))return{tool:e,installed:!0,command:null,hint:"already installed",autoInstall:!1};if(e==="nerd-font"){const l=Pe(t);return{tool:e,installed:!1,command:l.command,hint:`${l.hint} \u2014 ${Ee}`,autoInstall:l.autoInstall}}const o=e==="nvim"?"neovim":"tmux";switch(t){case"brew":return{tool:e,installed:!1,command:`brew install ${o}`,hint:"Homebrew install",autoInstall:!0};case"apt-get":return{tool:e,installed:!1,command:`sudo apt-get update && sudo apt-get install -y ${o}`,hint:"apt-get install",autoInstall:!0};case"dnf":return{tool:e,installed:!1,command:`sudo dnf install -y ${o}`,hint:"dnf install",autoInstall:!0};case"pacman":return{tool:e,installed:!1,command:`sudo pacman -S --noconfirm ${o}`,hint:"pacman install",autoInstall:!0};default:return{tool:e,installed:!1,command:null,hint:`manual install required for ${e}`,autoInstall:!1}}}a(Ue,"buildSystemInstallPlan");function M(e=x()){return m(e===x()?P():m(e,".pi","agent"),"settings.json")}a(M,"resolveSettingsPath");function Ct(e={}){const t=e.homeDir??x(),n=e.settingsPath??M(t),r=e.manifest??D(),o=ve(n),l=z(o,r,n,t);for(const d of V(r))l.add(d);const c=e.commandExists??k,u=e.packageManager??Be(process.platform,c),s=["tmux","nvim","nerd-font"].map(d=>Ue(d,u,c));return{manifest:r,installedPackageIds:l,systemPlans:s}}a(Ct,"buildSetupInitialState");function Et(e){const t=e.manifest.map(r=>{const o=e.installedPackageIds.has(r.id)?"installed":"not installed";return`- ${r.name} \u2014 ${r.shortDescription} (${o})`}),n=e.systemPlans.map(r=>r.installed?`- ${r.tool}: \u2713 installed`:r.command?`- ${r.tool}: ${r.command}`:`- ${r.tool}: ${r.hint}`);return["crtr sys setup (non-interactive)","","Provider login: open the wizard in a TTY and use the Providers tab (same flow as /login) to authenticate a model provider.","","Packages:",...t,"","System deps:",...n,"",`Inbox: the inbox-toggle key (${me()??"disabled"}) is a crouter keybinding \u2014 view or rebind it in \`crtr sys settings\`; it is installed on the same tmux server as every other crouter binding.`,"Run `crtr sys setup` in a TTY to open the wizard."].join(`
1
+ var re=Object.defineProperty;var a=(e,t)=>re(e,"name",{value:t,configurable:!0});import{spawn as ie,spawnSync as se}from"node:child_process";import{homedir as w,tmpdir as ae}from"node:os";import{mkdtempSync as oe,rmSync as ce}from"node:fs";import{piAgentDir as I}from"../../core/runtime/package-health.js";import{basename as ue,dirname as _,join as h,relative as le,resolve as de}from"node:path";import{isDeepStrictEqual as b}from"node:util";import{BINDING_CATALOG as pe,normalizeGesture as fe,splitGestureExpression as me,inboxShortcut as he,resolveKeybindings as S}from"../../core/keybindings/index.js";import{runtimeManifest as ge}from"./shared.js";import{atomicWriteJson as ke,readJsonIfExists as ve,readJsonOrNull as L}from"../../core/fs-utils.js";import{resolveBundledPiCliPath as be}from"../../core/runtime/pi-cli.js";import{crtrVersion as we}from"../../shared/crtr-version.js";import{installTmuxBindings as ye}from"../../core/runtime/tmux-chrome.js";import{normalizeTmuxPassthrough as xe}from"../../core/config.js";import{detectNerdFont as Pe,nerdFontInstallCommand as Ie,createCurlPercentReader as Se,NERD_FONT_MANUAL_LINUX_COMMAND as Ce,NERD_FONT_SELECT_HINT as Ee}from"../../core/runtime/nerd-font.js";import{startProgressBar as $e}from"../../core/runtime/progress-bar.js";import{ensureRenderer as Ae,isRendererReady as K}from"../../core/termrender/termrender.js";import{installFromMarketplace as Re,isMarketplaceRelativeSource as De}from"../pkg/plugin-manage.js";import{requiredPluginEnv as Me}from"../../core/plugin-env.js";import{readPluginManifest as Te}from"../../core/manifest.js";import{addMarketplace as j}from"../pkg/market-manage.js";import{clone as Ne}from"../../core/git.js";import{readMarketplaceManifest as Oe}from"../../core/manifest.js";import{findPluginByName as F,findMarketplaceByName as C}from"../../core/resolver.js";import{expandTilde as _e}from"../../core/fs-utils.js";import{applyTerminalEdit as Le}from"./terminal-option.js";const E="crouter-official-marketplace",$="https://github.com/crouton-labs/crouter-official-marketplace.git",A="main";function Pt(e){const t=[],n=new Set,r=new Map;try{for(const o of e){if(o.sourceKind!=="marketplace-plugin")continue;const[u,c]=o.installSource.split("/");if(!u||!c)continue;const l=F(c,"user")?.manifest;let d=C(u,"user");if(!d&&!l&&u===E)try{let i=r.get(u);i||(i=oe(h(ae(),"crtr-setup-market-")),r.set(u,i),Ne($,h(i,"checkout"),{ref:A,depth:1}));const p=h(i,"checkout"),v=Oe(p);v&&(d={root:p,manifest:v})}catch{}const m=d?.manifest.plugins.find(i=>i.name===c)?.source,f=m&&De(m)?Te(h(d.root,m))??l:l;if(f)for(const i of Me(f.env))n.has(i)||(n.add(i),t.push({name:i,plugin:c,declaration:f.env[i]}))}}finally{for(const o of r.values())ce(o,{recursive:!0,force:!0})}return t}a(Pt,"setupPluginEnvFields");function G(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}a(G,"isKeybindingsObject");function g(e){return G(e)?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Array.isArray(n)?[...n]:n])):{}}a(g,"cloneKeybindings");class It{static{a(this,"SetupKeybindingsDraft")}expected;baseline;current;baselineInvalidRoot;invalidRoot;resolutionCache;expectedPassthrough;baselinePassthrough;currentPassthrough;constructor(t,n=void 0){this.expected=t,this.baseline=g(t),this.current=g(t),this.baselineInvalidRoot=t!==void 0&&!G(t)?t:void 0,this.invalidRoot=this.baselineInvalidRoot,this.expectedPassthrough=n,this.baselinePassthrough=xe(n),this.currentPassthrough=[...this.baselinePassthrough]}get dirty(){return!b(this.current,this.baseline)||!b(this.invalidRoot,this.baselineInvalidRoot)||!b(this.currentPassthrough,this.baselinePassthrough)}overrides(){return g(this.current)}expectedKeybindings(){return this.expected}tmuxPassthrough(){return[...this.currentPassthrough]}expectedTmuxPassthrough(){return this.expectedPassthrough}usesTmuxPassthrough(t){return this.currentPassthrough.includes(t)}toggleTmuxPassthrough(t){this.currentPassthrough=this.currentPassthrough.includes(t)?this.currentPassthrough.filter(n=>n!==t):[...this.currentPassthrough,t]}resolution(){return this.resolutionCache===void 0&&(this.resolutionCache=S(this.invalidRoot===void 0?this.current:this.invalidRoot)),this.resolutionCache}hasInvalidRoot(){return this.invalidRoot!==void 0}expression(t){return this.resolution().gestures(t).join(", ")}edit(t,n){if(this.invalidRoot!==void 0)return{ok:!1,diagnostics:[{severity:"error",code:"invalid-keybindings",offendingValue:this.invalidRoot,message:"Reset all before editing: the saved keybindings root is invalid."}]};const r=pe.find(f=>f.id===t);let o;try{o=n.trim()===""?[]:me(n).map(f=>fe(f.trim(),r))}catch(f){return{ok:!1,diagnostics:[{severity:"error",code:"invalid-override",bindingId:t,offendingValue:n,message:f instanceof Error?f.message:String(f)}]}}const u=[...new Set(o)],c={...this.current};delete c[t];const l=[...S(c).gestures(t)],s=b(u,l)?c:{...this.current,[t]:u},d=S(s),m=d.diagnostics.filter(f=>f.bindingId===t||f.relatedBindingIds?.includes(t));return m.length>0?{ok:!1,diagnostics:m}:(this.current=s,this.resolutionCache=void 0,{ok:!0,diagnostics:d.diagnostics})}unbind(t){return this.edit(t,"")}resetRow(t){delete this.current[t],this.resolutionCache=void 0}resetAll(){this.current={},this.currentPassthrough=[],this.invalidRoot=void 0,this.resolutionCache=void 0}discard(){this.current=g(this.baseline),this.currentPassthrough=[...this.baselinePassthrough],this.invalidRoot=this.baselineInvalidRoot,this.resolutionCache=void 0}markSaved(t,n=[]){this.expected=Object.keys(t).length===0?void 0:g(t),this.baseline=g(t),this.current=g(t),this.expectedPassthrough=[...n],this.baselinePassthrough=[...n],this.currentPassthrough=[...n],this.baselineInvalidRoot=void 0,this.invalidRoot=void 0,this.resolutionCache=void 0}}const Ke={"official-marketplace":{name:E,shortDescription:"the official crtr plugin catalog \u2014 registered as a source so its plugins are installable by ref.",longDescription:"Shallow-clones github.com/crouton-labs/crouter-official-marketplace into the user scope and registers it, which is what makes `crtr pkg plugin install crouter-official-marketplace/<name>` resolve and what fills `crtr pkg market browse`. Registering the source installs no plugin by itself. Uncheck it on a machine that should reach no external catalog \u2014 a plugin selected below still registers the marketplace it comes from, because its ref cannot resolve otherwise."},"crtr-extensions":{name:"pi-crtr-extensions",shortDescription:"crtr companion extensions \u2014 command palette, help gating, subscription/OAuth rotation, nested context.",longDescription:"Bundles the extensions built for crtr: a crtr slash-command palette, crtr/crouter help gating, surfacing of Claude Code marketplace plugin commands, nested AGENTS.md/CLAUDE.md loading, OAuth login + rotation across multiple Claude subscriptions (provider-rotation), and system-prompt trimming. The OAuth/rotation piece is what lets crtr authenticate your Claude account."},"oauth-adapter":{name:"pi-claude-oauth-adapter",shortDescription:"Anthropic OAuth / Claude Code credential compatibility for pi.",longDescription:"Third-party adapter (minzique/dotfiles-agents) letting pi authenticate with Claude using Claude Code OAuth credentials. Installed from npm, pinned to 0.2.2."},"capture-plugin":{name:"capture",shortDescription:"crtr plugin mounting `crtr capture` \u2014 browser automation and UI measurement over CDP.",longDescription:"Installs the `capture` plugin from the official crtr marketplace. It mounts `crtr capture` as a transparent passthrough to the external Capture CLI (`npm install -g @crouton-kit/capture`) for CDP screenshots, rendered-geometry measurement, HAR, accessibility trees, and JS execution against a live page. Uncheck it on a machine where agents never drive a browser \u2014 the command then costs nothing in their root prompt."},"dev-plugin":{name:"dev",shortDescription:"crtr plugin mounting the development workflow \u2014 repository setup, worktrees, pull requests, and a dev track in the tutorial.",longDescription:"Installs the dev plugin from the official crtr marketplace. It adds the /dev: workflow commands (init, spec, design, plan, pr-loop), mounts crtr dev for a repository's own lifecycle commands and Grove instances, and contributes the crtr sys tutorial dev track. Uncheck it on a machine whose agents do not work in source repositories."}},R={"official-marketplace":{kind:"marketplace-source",source:$},"crtr-extensions":{kind:"local-path",source:U("pi-crtr-extensions")},"oauth-adapter":{kind:"npm",source:"npm:pi-claude-oauth-adapter@0.2.2"},"capture-plugin":{kind:"marketplace-plugin",source:"crouter-official-marketplace/capture"},"dev-plugin":{kind:"marketplace-plugin",source:"crouter-official-marketplace/dev"}},B=["extensions/*.ts","extensions/*/index.ts","!extensions/**/*.d.ts"],je={"official-marketplace":[],"crtr-extensions":["pi-crtr-extensions"],"oauth-adapter":[],"capture-plugin":[],"dev-plugin":[]};function U(e){return h(ge.runtimeHome(),"selected","dist","builtin-pi-packages",e)}a(U,"selectedPiPackageDir");function D(e=U){return["official-marketplace","crtr-extensions","oauth-adapter","capture-plugin","dev-plugin"].map(t=>{const n=Ke[t],r=R[t].kind==="local-path"?e(n.name):R[t].source;return{id:t,name:n.name,sourceKind:R[t].kind,installSource:r,shortDescription:n.shortDescription,longDescription:n.longDescription}})}a(D,"buildSetupManifest");function St(e){switch(e.sourceKind){case"marketplace-source":return`clone + register ${e.installSource}`;case"marketplace-plugin":return`crtr pkg plugin install ${e.installSource}`;default:return`pi install ${e.installSource}`}}a(St,"packagePlanAction");function Fe(e){if(!e.startsWith("npm:"))return null;const t=e.slice(4),n=t.startsWith("@")?t.indexOf("@",1):t.lastIndexOf("@");return n>0?t.slice(0,n):t}a(Fe,"npmPackageName");function y(e,t,n){const r=Fe(e);if(r!==null)return`npm:${r}`;const o=_e(e,n);return de(t,o)}a(y,"normalizePackageIdentity");function x(e){return`package:${e}`}a(x,"packageNameIdentity");function z(e){return e.startsWith("npm:")?[]:[x(ue(e))]}a(z,"localPackageNameIdentities");function Ge(e,t,n){const r=[y(e.installSource,t,n)];if(e.sourceKind==="local-path"){r.push(x(e.name));for(const o of je[e.id])r.push(x(o))}return r}a(Ge,"manifestIdentities");function Y(e,t=D(),n=h(I(),"settings.json"),r=w()){const o=_(n),u=new Set,c=new Map;for(const s of t)for(const d of Ge(s,o,r))c.set(d,s.id);const l=e&&typeof e=="object"?e.packages:void 0;if(!Array.isArray(l))return u;for(const s of l){const d=typeof s=="string"?s:s&&typeof s=="object"&&typeof s.source=="string"?s.source:null;if(d===null)continue;const m=[y(d,o,r),...z(d)];for(const f of m){const i=c.get(f);if(i==="crtr-extensions"){const p=t.find(v=>v.id===i);if(y(d,o,r)!==y(p.installSource,o,r)||!s||typeof s!="object"||!b(s.extensions,B))continue}i!==void 0&&u.add(i)}}return u}a(Y,"detectInstalledSetupPackageIds");function k(e){return se("sh",["-lc",`command -v ${e} >/dev/null 2>&1`],{stdio:"ignore"}).status===0}a(k,"detectCommandOnPath");function Be(e=process.platform,t=k){switch(e){case"darwin":return t("brew")?"brew":"manual";case"linux":return t("apt-get")?"apt-get":t("dnf")?"dnf":t("pacman")?"pacman":"manual";default:return"manual"}}a(Be,"detectPackageManager");function Ue(e,t,n=k){if(e==="nerd-font"?Pe().installed:n(e))return{tool:e,installed:!0,command:null,hint:"already installed",autoInstall:!1};if(e==="nerd-font"){const u=Ie(t);return{tool:e,installed:!1,command:u.command,hint:`${u.hint} \u2014 ${Ee}`,autoInstall:u.autoInstall}}const o=e==="nvim"?"neovim":"tmux";switch(t){case"brew":return{tool:e,installed:!1,command:`brew install ${o}`,hint:"Homebrew install",autoInstall:!0};case"apt-get":return{tool:e,installed:!1,command:`sudo apt-get update && sudo apt-get install -y ${o}`,hint:"apt-get install",autoInstall:!0};case"dnf":return{tool:e,installed:!1,command:`sudo dnf install -y ${o}`,hint:"dnf install",autoInstall:!0};case"pacman":return{tool:e,installed:!1,command:`sudo pacman -S --noconfirm ${o}`,hint:"pacman install",autoInstall:!0};default:return{tool:e,installed:!1,command:null,hint:`manual install required for ${e}`,autoInstall:!1}}}a(Ue,"buildSystemInstallPlan");function M(e=w()){return h(e===w()?I():h(e,".pi","agent"),"settings.json")}a(M,"resolveSettingsPath");function Ct(e={}){const t=e.homeDir??w(),n=e.settingsPath??M(t),r=e.manifest??D(),o=ve(n),u=Y(o,r,n,t);for(const d of X(r))u.add(d);const c=e.commandExists??k,l=e.packageManager??Be(process.platform,c),s=["tmux","nvim","nerd-font"].map(d=>Ue(d,l,c));return{manifest:r,installedPackageIds:u,systemPlans:s}}a(Ct,"buildSetupInitialState");function Et(e){const t=e.manifest.map(r=>{const o=e.installedPackageIds.has(r.id)?"installed":"not installed";return`- ${r.name} \u2014 ${r.shortDescription} (${o})`}),n=e.systemPlans.map(r=>r.installed?`- ${r.tool}: \u2713 installed`:r.command?`- ${r.tool}: ${r.command}`:`- ${r.tool}: ${r.hint}`);return["crtr sys setup (non-interactive)","","Provider login: open the wizard in a TTY and use the Providers tab (same flow as /login) to authenticate a model provider.","","Packages:",...t,"","System deps:",...n,"",`Inbox: the inbox-toggle key (${he()??"disabled"}) is a crouter keybinding \u2014 view or rebind it in \`crtr sys settings\`; it is installed on the same tmux server as every other crouter binding.`,"Run `crtr sys setup` in a TTY to open the wizard."].join(`
2
2
  `)+`
3
- `}a(Et,"renderSetupStaticInstructions");class I extends Error{static{a(this,"SetupCommandError")}output;constructor(t,n){super(t),this.output=n}}function At(e){return`${e.stdout?.toString()??""}${e.stderr?.toString()??""}`}a(At,"commandOutput");function q(e,t,n,r=process.env){return new Promise((o,l)=>{const c=ie(e,t,{stdio:["ignore","pipe","pipe"],env:r});let u="";c.stdout.setEncoding("utf8"),c.stderr.setEncoding("utf8"),c.stdout.on("data",s=>{u+=s}),c.stderr.on("data",s=>{u+=s,n?.(s)}),c.on("error",s=>l(new I(`${e} failed: ${s.message}`,u))),c.on("close",s=>{s===0?o():l(new I(`${e} failed with status ${s??"unknown"}`,u))})})}a(q,"runCapturedCommand");function N(e,t){return q("sh",["-lc",e],t)}a(N,"runShellCommand");function Ye(e,t=we()){return q(process.execPath,[t,"install",e],void 0,{...process.env,PI_CODING_AGENT_DIR:P()})}a(Ye,"installPiPackage");async function W(){k("capture")||await N("npm install -g @crouton-kit/capture")}a(W,"installCaptureCliIfMissing");function H(e){return e instanceof I?e.output:void 0}a(H,"capturedFailureOutput");function ze(e){const n=H(e)?.split(/\r?\n/).find(r=>r.trim()!=="");return n!==void 0?n.trim():e instanceof Error?e.message:String(e)}a(ze,"firstFailureLine");function qe(e){const t=H(e);t===void 0||t.length===0||process.stderr.write(t.endsWith(`
3
+ `}a(Et,"renderSetupStaticInstructions");class P extends Error{static{a(this,"SetupCommandError")}output;constructor(t,n){super(t),this.output=n}}function $t(e){return`${e.stdout?.toString()??""}${e.stderr?.toString()??""}`}a($t,"commandOutput");function q(e,t,n,r=process.env){return new Promise((o,u)=>{const c=ie(e,t,{stdio:["ignore","pipe","pipe"],env:r});let l="";c.stdout.setEncoding("utf8"),c.stderr.setEncoding("utf8"),c.stdout.on("data",s=>{l+=s}),c.stderr.on("data",s=>{l+=s,n?.(s)}),c.on("error",s=>u(new P(`${e} failed: ${s.message}`,l))),c.on("close",s=>{s===0?o():u(new P(`${e} failed with status ${s??"unknown"}`,l))})})}a(q,"runCapturedCommand");function T(e,t){return q("sh",["-lc",e],t)}a(T,"runShellCommand");function ze(e,t=be()){return q(process.execPath,[t,"install",e],void 0,{...process.env,PI_CODING_AGENT_DIR:I()})}a(ze,"installPiPackage");async function W(){k("capture")||await T("npm install -g @crouton-kit/capture")}a(W,"installCaptureCliIfMissing");function H(e){return e instanceof P?e.output:void 0}a(H,"capturedFailureOutput");function Ye(e){const n=H(e)?.split(/\r?\n/).find(r=>r.trim()!=="");return n!==void 0?n.trim():e instanceof Error?e.message:String(e)}a(Ye,"firstFailureLine");function qe(e){const t=H(e);t===void 0||t.length===0||process.stderr.write(t.endsWith(`
4
4
  `)?t:`${t}
5
- `)}a(qe,"printCapturedFailure");class We{static{a(this,"SetupProgress")}interactive;bar=null;constructor(t=!!process.stdout.isTTY){this.interactive=t}start(t){return this.interactive?(this.bar=Ae(`Installing ${t}\u2026`),this.bar):null}async clear(){await this.bar?.stop(),this.bar=null}async succeed(t){await this.clear(),this.interactive&&process.stdout.write(`\r\x1B[2K\u2713 ${t}
6
- `)}async fail(t,n){await this.clear(),this.interactive&&process.stdout.write(`\r\x1B[2K\u2717 ${t} \u2014 ${ze(n)}
7
- `),qe(n)}async run(t,n){const r=this.start(t);try{const o=await n(r);return await this.succeed(t),o}catch(o){throw await this.fail(t,o),o}}}function X(e,t){return K()?"current":(e?.(),$e(t),K()?"provisioned":"unavailable")}a(X,"ensureManagedRenderer");async function He(){try{be()}catch{}}a(He,"reconcileInboxFrontDoor");function J(e,t){return t.length===0?[`${e}: none`]:[`${e}:`,...t.map(n=>` - ${n}`)]}a(J,"summarySection");function $t(e){return["crtr sys setup complete",...J("installed",e.installed),...J("skipped",e.skipped),"New to crouter? Ask for the tutorial in your first conversation, or run /tutorial any time."].join(`
5
+ `)}a(qe,"printCapturedFailure");class We{static{a(this,"SetupProgress")}interactive;bar=null;constructor(t=!!process.stdout.isTTY){this.interactive=t}start(t){return this.interactive?(this.bar=$e(`Installing ${t}\u2026`),this.bar):null}async clear(){await this.bar?.stop(),this.bar=null}async succeed(t){await this.clear(),this.interactive&&process.stdout.write(`\r\x1B[2K\u2713 ${t}
6
+ `)}async fail(t,n){await this.clear(),this.interactive&&process.stdout.write(`\r\x1B[2K\u2717 ${t} \u2014 ${Ye(n)}
7
+ `),qe(n)}async run(t,n){const r=this.start(t);try{const o=await n(r);return await this.succeed(t),o}catch(o){throw await this.fail(t,o),o}}}function J(e,t){return K()?"current":(e?.(),Ae(t),K()?"provisioned":"unavailable")}a(J,"ensureManagedRenderer");async function He(){try{ye()}catch{}}a(He,"reconcileInboxFrontDoor");function V(e,t){return t.length===0?[`${e}: none`]:[`${e}:`,...t.map(n=>` - ${n}`)]}a(V,"summarySection");function At(e){return["crtr sys setup complete",...V("installed",e.installed),...V("skipped",e.skipped),"New to crouter? Ask for the tutorial in your first conversation, or run /tutorial any time."].join(`
8
8
  `)+`
9
- `}a($t,"formatSetupExecutionSummary");function V(e,t){const n=[];for(const r of e)try{r.sourceKind==="marketplace-source"?C(r.name,t)!==null&&n.push(r.id):r.sourceKind==="marketplace-plugin"&&F(r.name,t)!==null&&n.push(r.id)}catch{}return n}a(V,"detectInstalledMarketplaceEntries");async function Xe(e,t="user"){if(C(e,t)!==null)return null;if(e!==E)throw new Error(`marketplace not registered: ${e}`);return await j({url:A,ref:$,scope:t}),e}a(Xe,"ensureMarketplaceRegistered");function Je(e){const t=M(),n=L(t);if(!n||typeof n!="object"||Array.isArray(n))throw new Error(`invalid pi settings: ${t}`);const r=n.packages;if(!Array.isArray(r))throw new Error(`invalid pi packages: ${t}`);const o=a(u=>{const s=typeof u=="string"?u:u&&typeof u=="object"?u.source:void 0;return typeof s=="string"&&Y(s).includes(y("pi-crtr-extensions"))},"isCrtrExtensions"),l=r.findIndex(o),c=r.filter(u=>!o(u));c.splice(l<0?c.length:l,0,{source:ue(_(t),e),extensions:B}),ke(t,{...n,packages:c})}a(Je,"configureCrtrExtensions");const Q="git is not installed \u2014 install it (Debian/Ubuntu: apt-get install git), then run `crtr sys setup`";function Z(e){return e.sourceKind==="marketplace-source"||e.sourceKind==="marketplace-plugin"}a(Z,"isMarketplaceEntry");async function ee(e){if(e.sourceKind==="marketplace-source")return await j({url:e.installSource,ref:$,scope:"user"}),[e.name];if(e.sourceKind==="marketplace-plugin"){const[t,n]=e.installSource.split("/"),r=await Xe(t);return await Re({marketplace:t,plugin:n},"user"),e.id==="capture-plugin"&&await W(),r===null?[e.name]:[r,e.name]}return await Ye(e.installSource),e.id==="crtr-extensions"&&Je(e.installSource),[e.name]}a(ee,"installSetupPackage");async function Rt(e,t=k){const n=D(),r=z(L(M()),n);for(const s of V(n,"user"))r.add(s);const o=new Map(n.map(s=>[s.id,s])),l=process.stdin.isTTY&&process.stdout.isTTY?["crtr-extensions","official-marketplace","oauth-adapter","capture-plugin","exa-search-plugin"]:["crtr-extensions","official-marketplace","capture-plugin","exa-search-plugin"];let c,u=!1;for(const s of l){const d=o.get(s);if(!r.has(s)){if(Z(d)&&(c??=!t("git"),c)){u||e("marketplace packages",new Error(Q)),u=!0;continue}try{await ee(d)}catch(h){e(d.name,h)}}}try{X(void 0,()=>{})==="unavailable"&&e("termrender renderer",new Error("unavailable \u2014 install uv"))}catch(s){e("termrender renderer",s)}return xe()}a(Rt,"reconcileFirstRun");async function Dt(e,t=k){const n=[],r=[],o=[],l=[],c=new We;let u,s=!1;for(const i of e.packages){if(e.installedPackageIds.has(i.id)){if(r.push(`${i.name} (already installed)`),i.id==="capture-plugin"&&!k("capture"))try{await c.run("Capture CLI",()=>W()),n.push("Capture CLI")}catch(p){r.push(`Capture CLI (${p instanceof Error?p.message:String(p)})`)}continue}if(Z(i)&&(u??=!t("git"),u)){s||r.push(`marketplace packages (${Q})`),s=!0;continue}try{n.push(...await c.run(i.name,()=>ee(i)))}catch(p){if(i.sourceKind!=="marketplace-source"&&i.sourceKind!=="marketplace-plugin")throw p;r.push(`${i.name} (${p instanceof Error?p.message:String(p)})`)}}for(const i of e.systemDeps){if(i.installed){l.push(`${i.tool} (already installed)`);continue}if(!i.autoInstall||!i.command){l.push(`${i.tool} (${i.hint})`);continue}const p=i.command,v=p===Ce;await c.run(i.tool,T=>{if(!v||T===null)return N(p);const te=Se();return N(p,ne=>{const O=te(ne);O!==null&&T.setFraction(O/100)})}),o.push(i.tool)}const d=[];let h=!1,f;try{f=X(()=>{h=!0,c.start("termrender renderer")},i=>d.push(i))}catch(i){throw h&&await c.fail("termrender renderer",i),i}switch(f){case"provisioned":h&&await c.succeed("termrender renderer"),n.push("termrender renderer");break;case"current":r.push("termrender renderer (current)");break;case"unavailable":{const i=new I("unavailable \u2014 install uv",d.join(""));h&&await c.fail("termrender renderer",i),r.push("termrender renderer (unavailable \u2014 install uv)");break}}if(e.terminalEdit!==void 0){const i=`Option as Alt (${e.terminalEdit.path})`,p=Le(e.terminalEdit);p.ok?n.push(`${i} \u2014 ${e.terminalEdit.reload}`):r.push(`${i} (${p.message})`)}return await He(),{installed:[...n,...o],skipped:[...r,...l]}}a(Dt,"executeSetupSubmission");export{E as OFFICIAL_MARKETPLACE_NAME,$ as OFFICIAL_MARKETPLACE_REF,A as OFFICIAL_MARKETPLACE_URL,Pt as SetupKeybindingsDraft,Ct as buildSetupInitialState,D as buildSetupManifest,Ue as buildSystemInstallPlan,k as detectCommandOnPath,z as detectInstalledSetupPackageIds,Be as detectPackageManager,Dt as executeSetupSubmission,$t as formatSetupExecutionSummary,b as normalizePackageIdentity,St as packagePlanAction,Rt as reconcileFirstRun,He as reconcileInboxFrontDoor,Et as renderSetupStaticInstructions,M as resolveSettingsPath,It as setupPluginEnvFields};
9
+ `}a(At,"formatSetupExecutionSummary");function X(e,t){const n=[];for(const r of e)try{r.sourceKind==="marketplace-source"?C(r.name,t)!==null&&n.push(r.id):r.sourceKind==="marketplace-plugin"&&F(r.name,t)!==null&&n.push(r.id)}catch{}return n}a(X,"detectInstalledMarketplaceEntries");async function Je(e,t="user"){if(C(e,t)!==null)return null;if(e!==E)throw new Error(`marketplace not registered: ${e}`);return await j({url:$,ref:A,scope:t}),e}a(Je,"ensureMarketplaceRegistered");function Ve(e){const t=M(),n=L(t);if(!n||typeof n!="object"||Array.isArray(n))throw new Error(`invalid pi settings: ${t}`);const r=n.packages;if(!Array.isArray(r))throw new Error(`invalid pi packages: ${t}`);const o=a(l=>{const s=typeof l=="string"?l:l&&typeof l=="object"?l.source:void 0;return typeof s=="string"&&z(s).includes(x("pi-crtr-extensions"))},"isCrtrExtensions"),u=r.findIndex(o),c=r.filter(l=>!o(l));c.splice(u<0?c.length:u,0,{source:le(_(t),e),extensions:B}),ke(t,{...n,packages:c})}a(Ve,"configureCrtrExtensions");const Q="git is not installed \u2014 install it (Debian/Ubuntu: apt-get install git), then run `crtr sys setup`";function Z(e){return e.sourceKind==="marketplace-source"||e.sourceKind==="marketplace-plugin"}a(Z,"isMarketplaceEntry");async function ee(e){if(e.sourceKind==="marketplace-source")return await j({url:e.installSource,ref:A,scope:"user"}),[e.name];if(e.sourceKind==="marketplace-plugin"){const[t,n]=e.installSource.split("/"),r=await Je(t);return await Re({marketplace:t,plugin:n},"user"),e.id==="capture-plugin"&&await W(),r===null?[e.name]:[r,e.name]}return await ze(e.installSource),e.id==="crtr-extensions"&&Ve(e.installSource),[e.name]}a(ee,"installSetupPackage");async function Rt(e,t=k){const n=D(),r=Y(L(M()),n);for(const s of X(n,"user"))r.add(s);const o=new Map(n.map(s=>[s.id,s])),u=process.stdin.isTTY&&process.stdout.isTTY?["crtr-extensions","official-marketplace","oauth-adapter","capture-plugin"]:["crtr-extensions","official-marketplace","capture-plugin"];let c,l=!1;for(const s of u){const d=o.get(s);if(!r.has(s)){if(Z(d)&&(c??=!t("git"),c)){l||e("marketplace packages",new Error(Q)),l=!0;continue}try{await ee(d)}catch(m){e(d.name,m)}}}try{J(void 0,()=>{})==="unavailable"&&e("termrender renderer",new Error("unavailable \u2014 install uv"))}catch(s){e("termrender renderer",s)}return we()}a(Rt,"reconcileFirstRun");async function Dt(e,t=k){const n=[],r=[],o=[],u=[],c=new We;let l,s=!1;for(const i of e.packages){if(e.installedPackageIds.has(i.id)){if(r.push(`${i.name} (already installed)`),i.id==="capture-plugin"&&!k("capture"))try{await c.run("Capture CLI",()=>W()),n.push("Capture CLI")}catch(p){r.push(`Capture CLI (${p instanceof Error?p.message:String(p)})`)}continue}if(Z(i)&&(l??=!t("git"),l)){s||r.push(`marketplace packages (${Q})`),s=!0;continue}try{n.push(...await c.run(i.name,()=>ee(i)))}catch(p){if(i.sourceKind!=="marketplace-source"&&i.sourceKind!=="marketplace-plugin")throw p;r.push(`${i.name} (${p instanceof Error?p.message:String(p)})`)}}for(const i of e.systemDeps){if(i.installed){u.push(`${i.tool} (already installed)`);continue}if(!i.autoInstall||!i.command){u.push(`${i.tool} (${i.hint})`);continue}const p=i.command,v=p===Ce;await c.run(i.tool,N=>{if(!v||N===null)return T(p);const te=Se();return T(p,ne=>{const O=te(ne);O!==null&&N.setFraction(O/100)})}),o.push(i.tool)}const d=[];let m=!1,f;try{f=J(()=>{m=!0,c.start("termrender renderer")},i=>d.push(i))}catch(i){throw m&&await c.fail("termrender renderer",i),i}switch(f){case"provisioned":m&&await c.succeed("termrender renderer"),n.push("termrender renderer");break;case"current":r.push("termrender renderer (current)");break;case"unavailable":{const i=new P("unavailable \u2014 install uv",d.join(""));m&&await c.fail("termrender renderer",i),r.push("termrender renderer (unavailable \u2014 install uv)");break}}if(e.terminalEdit!==void 0){const i=`Option as Alt (${e.terminalEdit.path})`,p=Le(e.terminalEdit);p.ok?n.push(`${i} \u2014 ${e.terminalEdit.reload}`):r.push(`${i} (${p.message})`)}return await He(),{installed:[...n,...o],skipped:[...r,...u]}}a(Dt,"executeSetupSubmission");export{E as OFFICIAL_MARKETPLACE_NAME,A as OFFICIAL_MARKETPLACE_REF,$ as OFFICIAL_MARKETPLACE_URL,It as SetupKeybindingsDraft,Ct as buildSetupInitialState,D as buildSetupManifest,Ue as buildSystemInstallPlan,k as detectCommandOnPath,Y as detectInstalledSetupPackageIds,Be as detectPackageManager,Dt as executeSetupSubmission,At as formatSetupExecutionSummary,y as normalizePackageIdentity,St as packagePlanAction,Rt as reconcileFirstRun,He as reconcileInboxFrontDoor,Et as renderSetupStaticInstructions,M as resolveSettingsPath,Pt as setupPluginEnvFields};
@@ -1 +1 @@
1
- var a=Object.defineProperty;var t=(e,n)=>a(e,"name",{value:n,configurable:!0});import{defineLeaf as s}from"../../core/command.js";const o="Valid CRTR_WARN_LIVE_BROKERS and CRTR_MAX_LIVE_BROKERS environment overrides take precedence over their corresponding configured limits.",c=s({name:"setup",description:"bootstrap a fresh machine \u2014 provider login, companion packages, system dependencies",whenToUse:"you need to re-run the first-launch installer \u2014 sign in to another provider, add companion packages or system dependencies, or repair package paths. A person never needs it to get started: the first bare `crtr` in a terminal opens this installer itself. Use sys settings to change configuration on an installed machine, and sys config set for scriptable edits.",help:{name:"sys setup",summary:"reopen the installer bare `crtr` runs on first launch: provider login, companion packages, system dependencies",inputNote:"No input parameters.",output:[],outputKind:"object",effects:["Opens a three-step pi-tui installer. Step one logs in to a model provider (pi's real OAuth/API-key flow, same as in-app /login) so a fresh install has credentials before running any node.","The remaining steps collect companion package installs and system dependency installs, then confirm them all at once.","On macOS, a final step detects the terminal and explains how to make Option act as Alt (crouter's menu is Alt+C). Where the setting is safely scriptable (Ghostty, stock VS Code) it can write the one line for you, but only if you tick it and after showing exactly what will be written.","Runs the bundled pi CLI to install the selected companion packages and prints a summary.","The companion-package list includes the official crtr marketplace and the plugins installed from it (currently `capture` and `exa-search`), all checked by default and registered or installed into the user scope when left checked. Nothing else registers a marketplace, so an install that never runs setup fetches no catalog. An unreachable marketplace is reported as skipped rather than failing setup. Vendor credentials belong to the plugin that needs them, never to setup.","In a terminal, records setup as done (the same record the first bare `crtr` writes), so the next bare `crtr` boots a conversation instead of reopening the installer, and offers the tutorial if no conversation has started since setup first ran.","On every invocation (best-effort, idempotent), refreshes crouter-owned tmux bindings and registers known nodes' interaction roots so resolved tickets can call back into the asking node. The inbox popup toggle is a crouter-owned keybinding, editable on the keybindings tab."]},run:t(async()=>{const e=await(await import("./setup-wizard.js")).runSetup();process.stdout.isTTY&&await(await import("../../core/runtime/setup-marker.js")).recordSetupCompleted(e)},"run"),render:t(()=>"","render")});export{o as BROKER_LIMIT_OVERRIDE_PRECEDENCE,c as sysSetupLeaf};
1
+ var s=Object.defineProperty;var t=(e,n)=>s(e,"name",{value:n,configurable:!0});import{defineLeaf as a}from"../../core/command.js";const o="Valid CRTR_WARN_LIVE_BROKERS and CRTR_MAX_LIVE_BROKERS environment overrides take precedence over their corresponding configured limits.",c=a({name:"setup",description:"bootstrap a fresh machine \u2014 provider login, companion packages, system dependencies",whenToUse:"you need to re-run the first-launch installer \u2014 sign in to another provider, add companion packages or system dependencies, or repair package paths. A person never needs it to get started: the first bare `crtr` in a terminal opens this installer itself. Use sys settings to change configuration on an installed machine, and sys config set for scriptable edits.",help:{name:"sys setup",summary:"reopen the installer bare `crtr` runs on first launch: provider login, companion packages, system dependencies",inputNote:"No input parameters.",output:[],outputKind:"object",effects:["Opens a three-step pi-tui installer. Step one logs in to a model provider (pi's real OAuth/API-key flow, same as in-app /login) so a fresh install has credentials before running any node.","The remaining steps collect companion package installs and system dependency installs, then confirm them all at once.","On macOS, a final step detects the terminal and explains how to make Option act as Alt (crouter's menu is Alt+C). Where the setting is safely scriptable (Ghostty, stock VS Code) it can write the one line for you, but only if you tick it and after showing exactly what will be written.","Runs the bundled pi CLI to install the selected companion packages and prints a summary.","The companion-package list includes the official crtr marketplace and the plugins installed from it (currently `capture`), all checked by default and registered or installed into the user scope when left checked. Nothing else registers a marketplace, so an install that never runs setup fetches no catalog. An unreachable marketplace is reported as skipped rather than failing setup. Vendor credentials belong to the plugin that needs them, never to setup.","In a terminal, records setup as done (the same record the first bare `crtr` writes), so the next bare `crtr` boots a conversation instead of reopening the installer, and offers the tutorial if no conversation has started since setup first ran.","On every invocation (best-effort, idempotent), refreshes crouter-owned tmux bindings and registers known nodes' interaction roots so resolved tickets can call back into the asking node. The inbox popup toggle is a crouter-owned keybinding, editable on the keybindings tab."]},run:t(async()=>{const e=await(await import("./setup-wizard.js")).runSetup();process.stdout.isTTY&&await(await import("../../core/runtime/setup-marker.js")).recordSetupCompleted(e)},"run"),render:t(()=>"","render")});export{o as BROKER_LIMIT_OVERRIDE_PRECEDENCE,c as sysSetupLeaf};
@@ -0,0 +1,4 @@
1
+ -- 032-model-cooldown-vendor-limit.sql — each cooldown keeps the vendor 429 observation that set it (NL-310): the reset the vendor named,
2
+ -- the window claim, safe rate-limit headers and the model, so a later refusal from a cooling pool still reports them. Added columns only.
3
+ ALTER TABLE model_accounts ADD COLUMN IF NOT EXISTS vendor_limit_json text;
4
+ ALTER TABLE model_account_cooldowns ADD COLUMN IF NOT EXISTS vendor_limit_json text;
@@ -1,7 +1,7 @@
1
1
  /** The canvas schema version this build supports: the number of the highest delta in `schema-pg/` (the baseline
2
2
  * `schema-pg.sql` is version 1). `scripts/install-runtime.mjs` reads this module from a candidate generation to refuse
3
3
  * one below the live database's `schema_min_reader`. */
4
- export declare const CANVAS_SCHEMA_VERSION = 31;
4
+ export declare const CANVAS_SCHEMA_VERSION = 32;
5
5
  /** The Postgres schema holding the canvas tables: `CRTR_DATABASE_SCHEMA` (`crtr` in the cloud deploy). Unset or empty
6
6
  * means the role's own search_path (`public` on a Mac and on a VM). A name that is not a plain identifier is an error:
7
7
  * it is put in a `search_path` connection option. */
@@ -1 +1 @@
1
- var m=Object.defineProperty;var r=(n,e)=>m(n,"name",{value:e,configurable:!0});const A=31;function _(n=process.env){const e=n.CRTR_DATABASE_SCHEMA?.trim();if(e){if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(e))throw new Error(`CRTR_DATABASE_SCHEMA must be a plain identifier (letters, digits, underscore); got ${JSON.stringify(e)}`);return e}}r(_,"canvasDatabaseSchema");function h(n=process.env){return n.CRTR_SCHEMA_DATABASE_URL?.trim()||void 0}r(h,"canvasSchemaDatabaseUrl");function E(n=process.env){const e=_(n);return e===void 0?void 0:`-c search_path=${e}`}r(E,"canvasSearchPathOptions");async function v(n,e){const t=e===void 0?"canvas_meta":`"${e.replace(/"/g,'""')}".canvas_meta`;if((await n.query(`SELECT to_regclass('${t.replace(/'/g,"''")}') IS NOT NULL AS found`)).rows[0].found!==!0)return;const u=(await n.query(`SELECT key, value FROM ${t} WHERE key IN ('schema_version', 'schema_min_reader')`)).rows,o=r(c=>{const i=u.find(f=>f.key===c);if(i===void 0)return;const d=Number(i.value);if(!Number.isSafeInteger(d))throw new Error(`canvas_meta.${c} is not an integer: ${String(i.value)}`);return d},"value"),s=o("schema_version");return s===void 0?void 0:{version:s,minReader:o("schema_min_reader")??s}}r(v,"readStoredVersions");async function l(n,e,t){const a=await v(n,t);if(a!==void 0&&a.minReader>e)throw new Error(`refusing to select runtime with canvas schema ${e}: the live database requires readers at version ${a.minReader} or above (it is at ${a.version}); install a descendant build instead`)}r(l,"assertCandidateMayOpen");export{A as CANVAS_SCHEMA_VERSION,l as assertCandidateMayOpen,_ as canvasDatabaseSchema,h as canvasSchemaDatabaseUrl,E as canvasSearchPathOptions,v as readStoredVersions};
1
+ var m=Object.defineProperty;var r=(n,e)=>m(n,"name",{value:e,configurable:!0});const A=32;function _(n=process.env){const e=n.CRTR_DATABASE_SCHEMA?.trim();if(e){if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(e))throw new Error(`CRTR_DATABASE_SCHEMA must be a plain identifier (letters, digits, underscore); got ${JSON.stringify(e)}`);return e}}r(_,"canvasDatabaseSchema");function h(n=process.env){return n.CRTR_SCHEMA_DATABASE_URL?.trim()||void 0}r(h,"canvasSchemaDatabaseUrl");function E(n=process.env){const e=_(n);return e===void 0?void 0:`-c search_path=${e}`}r(E,"canvasSearchPathOptions");async function v(n,e){const t=e===void 0?"canvas_meta":`"${e.replace(/"/g,'""')}".canvas_meta`;if((await n.query(`SELECT to_regclass('${t.replace(/'/g,"''")}') IS NOT NULL AS found`)).rows[0].found!==!0)return;const u=(await n.query(`SELECT key, value FROM ${t} WHERE key IN ('schema_version', 'schema_min_reader')`)).rows,o=r(c=>{const i=u.find(f=>f.key===c);if(i===void 0)return;const d=Number(i.value);if(!Number.isSafeInteger(d))throw new Error(`canvas_meta.${c} is not an integer: ${String(i.value)}`);return d},"value"),s=o("schema_version");return s===void 0?void 0:{version:s,minReader:o("schema_min_reader")??s}}r(v,"readStoredVersions");async function l(n,e,t){const a=await v(n,t);if(a!==void 0&&a.minReader>e)throw new Error(`refusing to select runtime with canvas schema ${e}: the live database requires readers at version ${a.minReader} or above (it is at ${a.version}); install a descendant build instead`)}r(l,"assertCandidateMayOpen");export{A as CANVAS_SCHEMA_VERSION,l as assertCandidateMayOpen,_ as canvasDatabaseSchema,h as canvasSchemaDatabaseUrl,E as canvasSearchPathOptions,v as readStoredVersions};
@@ -0,0 +1 @@
1
+ export declare const STARTER_SETUP_SCRIPT = "#!/usr/bin/env bash\n# Setup script for a crtr cloud environment.\n#\n# How it runs\n# - Once per image build, as root, in /work, on Alpine Linux (use apk, not apt). Every sandbox of the profile starts from the result.\n# - Your repositories are already checked out at /work/<repo name> before this runs.\n# - The sandbox user is \"crtr\" (home /home/crtr). Files you create for it must be chowned to it.\n# - Already done for you: git, gh, curl, ripgrep, Node 24, pnpm. For every repository with a pnpm-lock.yaml, its packages are already\n# downloaded into a shared pnpm store, so `pnpm install` in a sandbox links instead of downloading.\n# - Output goes to /work/.crtr/setup.log in the image. If this script exits non-zero, sandboxes refuse to start and point at that log.\n# - The image keeps /work, /home/crtr, /usr, /etc and /lib. Anything written to /root or /tmp is lost.\n#\n# Secrets (API keys, database URLs) do not belong here: anything written by this script is baked into the image. Store them on the profile\n# instead and every sandbox gets them as environment variables:\n# printf '%s' \"<value>\" | crtr profile env set <profile> --name OPENAI_API_KEY\n#\n# Apply this file with:\n# crtr profile environment set --profile <profile> --setup-script-file ./setup.sh\n# then watch the build with `crtr profile environment show --profile <profile>` (ready when image_revision equals recipe_revision).\n#\n# Uncomment the sections you need. Delete the rest.\n\nset -euo pipefail\n\n# \u2500\u2500 1. System packages \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n# Alpine package names: https://pkgs.alpinelinux.org/packages\n# apk add --no-cache build-base python3 # native npm modules (node-gyp)\n# apk add --no-cache jq sqlite # command-line tools your agents use\n# apk add --no-cache chromium # headless browser tests\n\n# \u2500\u2500 2. A local Postgres \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n# Creates a database cluster owned by crtr. Section 5 starts it on the agent's first shell command.\n# apk add --no-cache postgresql postgresql-contrib\n# mkdir -p /run/postgresql && chown crtr /run/postgresql\n# su crtr -c 'initdb -D /home/crtr/pg -U postgres --auth=trust'\n\n# \u2500\u2500 3. App dependencies \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n# pnpm repositories are already prepared (see above). For npm or yarn, or to install fully at build time:\n# (cd /work/<repo name> && npm ci)\n# (cd /work/<repo name> && pnpm install --frozen-lockfile)\n# Each full install can take 0.5-1.5 GB of the sandbox disk. Install only the repositories agents work in most.\n\n# \u2500\u2500 4. Global CLIs \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n# npm install -g typescript tsx\n# curl -fsSL https://example.com/install.sh | sh\n\n# \u2500\u2500 5. Start services on the agent's first command \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n# The agent's shell is non-interactive bash, which runs the file named by $BASH_ENV before each command. Write a start script here, then\n# set BASH_ENV on the profile: printf '%s' /home/crtr/.services-up.sh | crtr profile env set <profile> --name BASH_ENV\n# cat > /home/crtr/.services-up.sh <<'UP'\n# pg_ctl -D /home/crtr/pg status >/dev/null 2>&1 || pg_ctl -D /home/crtr/pg -o \"-k /tmp -h localhost\" -l /tmp/pg.log -w start >/dev/null 2>&1 || true\n# UP\n# chown crtr /home/crtr/.services-up.sh\n\n# \u2500\u2500 6. Seed files and config \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n# cp /work/<repo name>/.env.example /work/<repo name>/.env # placeholders only; real values come from `crtr profile env`\n# chown -R crtr /work/<repo name>\n";
@@ -0,0 +1,58 @@
1
+ const e=`#!/usr/bin/env bash
2
+ # Setup script for a crtr cloud environment.
3
+ #
4
+ # How it runs
5
+ # - Once per image build, as root, in /work, on Alpine Linux (use apk, not apt). Every sandbox of the profile starts from the result.
6
+ # - Your repositories are already checked out at /work/<repo name> before this runs.
7
+ # - The sandbox user is "crtr" (home /home/crtr). Files you create for it must be chowned to it.
8
+ # - Already done for you: git, gh, curl, ripgrep, Node 24, pnpm. For every repository with a pnpm-lock.yaml, its packages are already
9
+ # downloaded into a shared pnpm store, so \`pnpm install\` in a sandbox links instead of downloading.
10
+ # - Output goes to /work/.crtr/setup.log in the image. If this script exits non-zero, sandboxes refuse to start and point at that log.
11
+ # - The image keeps /work, /home/crtr, /usr, /etc and /lib. Anything written to /root or /tmp is lost.
12
+ #
13
+ # Secrets (API keys, database URLs) do not belong here: anything written by this script is baked into the image. Store them on the profile
14
+ # instead and every sandbox gets them as environment variables:
15
+ # printf '%s' "<value>" | crtr profile env set <profile> --name OPENAI_API_KEY
16
+ #
17
+ # Apply this file with:
18
+ # crtr profile environment set --profile <profile> --setup-script-file ./setup.sh
19
+ # then watch the build with \`crtr profile environment show --profile <profile>\` (ready when image_revision equals recipe_revision).
20
+ #
21
+ # Uncomment the sections you need. Delete the rest.
22
+
23
+ set -euo pipefail
24
+
25
+ # \u2500\u2500 1. System packages \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
26
+ # Alpine package names: https://pkgs.alpinelinux.org/packages
27
+ # apk add --no-cache build-base python3 # native npm modules (node-gyp)
28
+ # apk add --no-cache jq sqlite # command-line tools your agents use
29
+ # apk add --no-cache chromium # headless browser tests
30
+
31
+ # \u2500\u2500 2. A local Postgres \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
32
+ # Creates a database cluster owned by crtr. Section 5 starts it on the agent's first shell command.
33
+ # apk add --no-cache postgresql postgresql-contrib
34
+ # mkdir -p /run/postgresql && chown crtr /run/postgresql
35
+ # su crtr -c 'initdb -D /home/crtr/pg -U postgres --auth=trust'
36
+
37
+ # \u2500\u2500 3. App dependencies \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
38
+ # pnpm repositories are already prepared (see above). For npm or yarn, or to install fully at build time:
39
+ # (cd /work/<repo name> && npm ci)
40
+ # (cd /work/<repo name> && pnpm install --frozen-lockfile)
41
+ # Each full install can take 0.5-1.5 GB of the sandbox disk. Install only the repositories agents work in most.
42
+
43
+ # \u2500\u2500 4. Global CLIs \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
44
+ # npm install -g typescript tsx
45
+ # curl -fsSL https://example.com/install.sh | sh
46
+
47
+ # \u2500\u2500 5. Start services on the agent's first command \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
48
+ # The agent's shell is non-interactive bash, which runs the file named by $BASH_ENV before each command. Write a start script here, then
49
+ # set BASH_ENV on the profile: printf '%s' /home/crtr/.services-up.sh | crtr profile env set <profile> --name BASH_ENV
50
+ # cat > /home/crtr/.services-up.sh <<'UP'
51
+ # pg_ctl -D /home/crtr/pg status >/dev/null 2>&1 || pg_ctl -D /home/crtr/pg -o "-k /tmp -h localhost" -l /tmp/pg.log -w start >/dev/null 2>&1 || true
52
+ # UP
53
+ # chown crtr /home/crtr/.services-up.sh
54
+
55
+ # \u2500\u2500 6. Seed files and config \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
56
+ # cp /work/<repo name>/.env.example /work/<repo name>/.env # placeholders only; real values come from \`crtr profile env\`
57
+ # chown -R crtr /work/<repo name>
58
+ `;export{e as STARTER_SETUP_SCRIPT};