@north-light/cli 0.3.691 → 0.3.692

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 (45) hide show
  1. package/dist/api/client.d.ts +3 -1
  2. package/dist/api/client.js +2 -2
  3. package/dist/api/contract.d.ts +1 -1
  4. package/dist/api/contract.js +1 -1
  5. package/dist/api/dto/canvas.d.ts +6 -0
  6. package/dist/api/routes.d.ts +1 -0
  7. package/dist/api/routes.js +1 -1
  8. package/dist/clients/attach/chrome/canvas-panels.d.ts +2 -1
  9. package/dist/clients/attach/chrome/canvas-panels.js +1 -1
  10. package/dist/clients/attach/chrome/inbox-strip.d.ts +2 -1
  11. package/dist/clients/attach/chrome/inbox-strip.js +1 -1
  12. package/dist/clients/attach/chrome/roster.d.ts +2 -1
  13. package/dist/clients/attach/chrome/roster.js +5 -5
  14. package/dist/clients/attach/session/chrome-refresh.d.ts +2 -1
  15. package/dist/clients/attach/session/chrome-refresh.js +1 -1
  16. package/dist/clients/attach/viewer.js +546 -546
  17. package/dist/commands/api-client.d.ts +2 -1
  18. package/dist/commands/api-client.js +2 -2
  19. package/dist/core/canvas/canvas.d.ts +2 -2
  20. package/dist/core/canvas/canvas.js +2 -2
  21. package/dist/core/canvas/source.d.ts +4 -2
  22. package/dist/core/canvas/waits.d.ts +2 -2
  23. package/dist/core/canvas/waits.js +7 -7
  24. package/dist/daemon/api/handlers/canvas.js +16 -6
  25. package/dist/daemon/api/operations.js +1 -1
  26. package/dist/daemon/api/router.d.ts +2 -0
  27. package/dist/daemon/api/router.js +1 -1
  28. package/package.json +3 -3
  29. package/packages/crouter-api/dist/api/client.js +4 -0
  30. package/packages/crouter-api/dist/api/contract.js +1 -1
  31. package/packages/crouter-api/dist/api/routes.js +1 -0
  32. package/packages/crouter-api/dist/clients/attach/chrome/canvas-panels.js +2 -2
  33. package/packages/crouter-api/dist/clients/attach/chrome/inbox-strip.js +11 -9
  34. package/packages/crouter-api/dist/clients/attach/chrome/roster.js +2 -2
  35. package/packages/crouter-api/dist/clients/attach/session/chrome-refresh.js +22 -10
  36. package/packages/crouter-api/dist/clients/attach/viewer.js +3 -3
  37. package/packages/crouter-api/dist/commands/api-client.js +3 -0
  38. package/packages/crouter-api/dist/core/canvas/canvas.js +4 -4
  39. package/packages/crouter-api/dist/core/canvas/waits.js +4 -4
  40. package/packages/crouter-api/dist/daemon/api/operations.js +1 -0
  41. package/packages/crouter-api/dist/daemon/api/router.js +11 -0
  42. package/packages/crouter-api/package.json +1 -1
  43. package/packages/crouter-identity/package.json +1 -1
  44. package/packages/crouter-plugin/package.json +3 -3
  45. package/runtime.lock.json +14 -14
@@ -35,7 +35,7 @@ import type { CancelReviewRequest, CreateReviewRequest, ListReviewsQuery, Review
35
35
  import type { CreateReviewCommentRequest, EditReviewCommentRequest, ListReviewCommentsQuery, ReadReviewCommentEventsQuery, ReviewCommentActionRequest, ReviewCommentDetailDTO, ReviewCommentEventsDTO, ReviewCommentForkDTO, ReviewCommentListDTO, ReviewCommentMutationDTO, ReviewCommentRangeBatchRequest, ReviewCommentRangeBatchResultDTO } from './dto/review-comments.js';
36
36
  import type { CancelInboxTicketRequest, CanceledTicketResultDTO, InboxListDTO, InboxPageDTO, InboxPageHistoryDTO, PageTicketSummaryDTO, InboxPageResponseDTO, InboxTicketIdDTO, PageFeedbackResolutionDTO, PageResponsesDTO, PageTicketResultDTO, RespondInboxPageRequest } from './dto/inbox.js';
37
37
  import type { CreateHumanRequestDTO, CreateHumanRequestRequest, HumanRequestDTO, HumanRequestIdDTO, ReplaceHumanRequestRequest, RespondHumanRequestRequest, SettleHumanRequestRequest, PageComponentListDTO } from './dto/human-requests.js';
38
- import type { AttentionCountsDTO, AttentionDTO, DashboardDTO, DashboardQuery, HistoryGrepQuery, HistoryGrepResultDTO, HistoryReadQuery, HistoryStatsQuery, HistoryStatsResultDTO, HistoryReadResultDTO, HistorySearchQuery, HistorySearchResultDTO, GraphDTO, PruneRequest, PruneResultDTO, LiveRootsDTO, RosterDTO, SnapshotDTO } from './dto/canvas.js';
38
+ import type { AttentionCountsDTO, AttentionDTO, DashboardDTO, DashboardQuery, HistoryGrepQuery, HistoryGrepResultDTO, HistoryReadQuery, HistoryStatsQuery, HistoryStatsResultDTO, HistoryReadResultDTO, HistorySearchQuery, HistorySearchResultDTO, GraphDTO, PruneRequest, PruneResultDTO, LiveRootsDTO, PanelViewDTO, RosterDTO, SnapshotDTO } from './dto/canvas.js';
39
39
  import type { AbandonWorktreeRequest, AbandonWorktreeResultDTO, CloseWorktreeResultDTO, QuarantinedWorktreeDTO, SpaceListDTO } from './dto/worktree.js';
40
40
  import type { BrokerExtensionStateDTO, BrokerExecutionRequest, BrokerGeneratedNameRequest, BrokerGoalRequest, BrokerGoalResultDTO, BrokerStructuredRequestDTO, BrokerGeneratedNameResultDTO, BrokerModelCommitRequest, BrokerModelCommitResultDTO, BrokerParkActivityResultDTO, BrokerParkCompleteRequest, BrokerPersonaAckRequest, BrokerPersonaAckResultDTO, BrokerCycleStartRequest, BrokerCycleStartResultDTO, BrokerSessionBoundRequest, BrokerSessionBoundResultDTO, BrokerCycleRequest, BrokerCycleResultDTO, BrokerSettleDirective, BrokerSettleRequest, BrokerTelemetryRequest } from './dto/broker-ops.js';
41
41
  import type { AcknowledgeMailRequest, AcknowledgeMailResultDTO, ClaimMailRequest, ClaimMailResultDTO } from './dto/mail.js';
@@ -516,6 +516,8 @@ export declare class CrtrClient {
516
516
  liveRoots(q?: {
517
517
  profile?: string;
518
518
  }): Promise<LiveRootsDTO>;
519
+ /** The tree containing `nodeId`, with its ticket counts (`GET /v1/canvas/view/:id`) — the attach viewer's one poll read. */
520
+ canvasView(nodeId: string): Promise<PanelViewDTO>;
519
521
  canvasRoster(): Promise<RosterDTO>;
520
522
  /** Explicitly compressed browse snapshot; the Node-only canvas source
521
523
  * decompresses it because socketFetch does not interpret content-encoding. */
@@ -1,3 +1,3 @@
1
1
  var N=Object.defineProperty;var a=(i,e)=>N(i,"name",{value:e,configurable:!0});import{ApiError as f,isErrorBody as x}from"./errors.js";import{routes as r}from"./routes.js";import{reportServerTiming as B}from"./server-timing.js";import{isSafeNodeId as b}from"./dto/common.js";import{isSafeBashJobId as L}from"./dto/bash-jobs.js";import{isSafeCronId as I}from"./dto/crons.js";const F=3e4,$=3e4,H=Symbol.for("@north-light/api/local-socket-fetch"),U=1e4,j=200;async function J({windowMs:i,probe:e,initialError:t,pollIntervalMs:n=j,retry:s=a(()=>!0,"retry"),now:o=Date.now,sleep:u=D}){const c=o()+i;let l=t;for(;;){const m=c-o();if(m<=0)throw l??new Error("crtrd availability window expired without a probe failure");try{await e(m);return}catch(P){if(l=P,!s(P))throw P}const h=c-o();if(h<=0)throw l;await u(Math.min(n,h))}}a(J,"waitForDaemonAvailability");const v=2147483647;function S(i,e="elapsed",t){const n=e==="retry_after"?`the server asked to retry after ${t}s, which is later than the call's deadline (${new Date(i).toISOString()}); not waiting`:`the call's deadline (${new Date(i).toISOString()}) passed`;return new f(504,"deadline_exceeded",n,{deadline_at:i,reason:e,...t===void 0?{}:{retry_after_s:t}})}a(S,"deadlineExceeded");const p=a(i=>S(i??Date.now()),"budgetExhausted");class oe{static{a(this,"CrtrClient")}baseUrl;fetch;headers;autostart;timeoutMs;maxRetries;localSocketTransport;onColdSocket;coldStartDiagnostic;coldStartFailure;availabilityFailure;coldStartPollWindowMs;startupFailureReported=!1;coldStartAttempted=!1;constructor(e){if(e.baseUrl==="")throw new TypeError("CrtrClient requires baseUrl");this.baseUrl=new URL(e.baseUrl),this.fetch=e.fetch??globalThis.fetch,this.headers={...e.headers},this.autostart=e.autostart??!1,this.timeoutMs=e.timeoutMs??F,this.maxRetries=e.maxRetries??2,this.localSocketTransport=this.fetch[H]===!0,e.onColdSocket!==void 0&&(this.onColdSocket=e.onColdSocket),e.coldStartDiagnostic!==void 0&&(this.coldStartDiagnostic=e.coldStartDiagnostic),e.coldStartFailure!==void 0&&(this.coldStartFailure=e.coldStartFailure),e.availabilityFailure!==void 0&&(this.availabilityFailure=e.availabilityFailure),this.coldStartPollWindowMs=e.coldStartPollWindowMs??U}healthz(){return this.request("GET",r.healthz())}async probeHealthz(e){const t=await this.transport("GET",r.healthz(),void 0,{timeout:e});if(t.status===503)try{const n=await t.clone().json();if(typeof n.startup_blocked=="string")return n}catch{}return q(t)}async ready(){const e=await this.transport("GET",r.ready(),void 0,{});if(e.status===503)try{const t=await e.clone().json();if(t.ready===!1)return t}catch{}return q(e)}status(){return this.request("GET",r.status())}due(){return this.request("GET",r.due())}restartDaemon(){return this.request("POST",r.daemonRestart())}drainDaemon(e={}){const t=e.settle_limit_ms??0;return this.request("POST",r.daemonDrain(),e,{timeout:t+this.timeoutMs})}endDaemonDrain(){return this.request("DELETE",r.daemonDrain())}admitDaemon(){return this.request("POST",r.daemonAdmit())}migrateState(e){return this.request("POST",r.daemonMigrate(),e)}appendNodeLog(e,t){return this.request("POST",r.nodeLog(this.nodePath(e)),t)}async putNodeTelemetry(e,t){await this.request("PUT",r.nodeTelemetry(this.nodePath(e)),t)}async putNodeSummaries(e,t){await this.request("PUT",r.nodeSummaries(this.nodePath(e)),t)}async putNodeRecap(e,t){await this.request("PUT",r.nodeRecap(this.nodePath(e)),t)}readNodeInboxReport(e,t,n){return this.request("GET",d(r.nodeInboxReport(this.nodePath(e)),{ref:t,execution_id:n}))}listNodeAttachments(e){return this.request("GET",r.nodeAttachments(this.nodePath(e)))}async readNodeAttachment(e,t){const n=await this.send("GET",r.nodeAttachment(this.nodePath(e),t));return n.ok||await q(n),new Uint8Array(await n.arrayBuffer())}createNodeFile(e,t){return this.request("POST",r.nodeFiles(this.nodePath(e)),t)}createNodeUpload(e,t){return this.request("POST",r.nodeUploads(this.nodePath(e)),t)}nodeUploadLink(e,t){return this.request("POST",r.nodeUploadLink(this.nodePath(e),t))}completeNodeFile(e,t){return this.request("POST",r.nodeFileComplete(this.nodePath(e),t))}readNodePassiveMessage(e,t){return this.request("GET",d(r.nodePassiveMessage(this.nodePath(e)),{ref:t}))}nodePushedFinal(e,t){return this.request("POST",r.nodePushedFinal(this.nodePath(e)),t)}createNode(e){return this.request("POST",r.nodes(),e,{timeout:12e4+this.timeoutMs})}listNodes(e){return this.request("GET",d(r.nodes(),e))}getNode(e){return this.request("GET",r.node(this.nodePath(e)))}getNodeOutcome(e,{waitSeconds:t}={}){if(t!==void 0&&(!Number.isInteger(t)||t<0||t>25))throw new RangeError("waitSeconds must be an integer between 0 and 25");return this.request("GET",d(r.nodeOutcome(this.nodePath(e)),{wait:t}),void 0,{timeout:(t??0)*1e3+this.timeoutMs})}getNodeEvents(e,t={},n={}){if(t.after!==void 0&&(!Number.isSafeInteger(t.after)||t.after<0))throw new RangeError("after must be a non-negative safe integer");return this.transport("GET",d(r.nodeEvents(this.nodePath(e)),t),void 0,{...n,headers:{accept:"text/event-stream",...n.headers??{}},timeout:0})}async*getBrokerSignals(e,t,n={}){const s=await this.send("GET",d(r.nodeBrokerSignals(this.nodePath(e)),{execution_id:t}),void 0,{...n,headers:{accept:"application/x-ndjson",...n.headers??{}},timeout:0});if(!s.ok){await q(s);return}if(s.body===null)throw new f(s.status,"invalid_response","broker signal stream has no body");const o=s.body.getReader(),u=new TextDecoder;let c="";try{for(;;){const{done:l,value:m}=await o.read();if(l)break;c+=u.decode(m,{stream:!0});let h;for(;(h=c.indexOf(`
2
- `))!==-1;){const P=c.slice(0,h);c=c.slice(h+1),P!==""&&(yield JSON.parse(P))}}if(c+=u.decode(),c.trim()!=="")throw new f(502,"invalid_response","broker signal stream ended mid-line")}finally{await o.cancel().catch(()=>{})}}createStructuredRequest(e,t){return e.mode==="sync"?this.sendOnce("POST","/v1/structured-requests",e,t):this.request("POST","/v1/structured-requests",e,t)}getStructuredRequest(e,{wait:t=0,budgetMs:n}={}){if(!Number.isInteger(t)||t<0||t>25)throw new RangeError("wait must be an integer between 0 and 25");return this.request("GET",d(`/v1/structured-requests/${this.requestPath(e)}`,{wait:t}),void 0,{budgetMs:n})}cancelStructuredRequest(e,t){return this.request("POST",`/v1/structured-requests/${this.requestPath(e)}/cancel`,{},t)}registerOutcomeDelivery(e,t){return this.request("PUT",r.nodeOutcomeDelivery(this.nodePath(e)),t)}getOutcomeDelivery(e){return this.request("GET",r.nodeOutcomeDelivery(this.nodePath(e)))}async disarmOutcomeDelivery(e){await this.request("DELETE",r.nodeOutcomeDelivery(this.nodePath(e)))}listBashJobs(e){return this.request("GET",r.nodeJobs(this.nodePath(e)))}readBashJobOutput(e,t,n={}){const s=new URLSearchParams;n.tail_lines!==void 0&&s.set("tail_lines",String(n.tail_lines)),n.max_bytes!==void 0&&s.set("max_bytes",String(n.max_bytes));const o=s.size===0?"":`?${s.toString()}`;return this.request("GET",`${r.nodeJobOutput(this.nodePath(e),this.jobPath(t))}${o}`)}stopBashJob(e,t){return this.request("DELETE",r.nodeJob(this.nodePath(e),this.jobPath(t)))}async patchBashJob(e,t,n){await this.request("PATCH",r.nodeJob(this.nodePath(e),this.jobPath(t)),n)}async reportBashJob(e,t,n){await this.request("POST",r.nodeJobReport(this.nodePath(e),this.jobPath(t)),n)}sendMessage(e,t){return this.request("POST",r.nodeMessages(this.nodePath(e)),t)}interruptNode(e){return this.request("POST",r.nodeInterrupt(this.nodePath(e)),{})}pushReport(e,t){return this.request("POST",r.nodeReports(this.nodePath(e)),t)}submitResult(e,t){return this.request("POST",r.nodeResult(this.nodePath(e)),t)}forkNode(e){return this.request("POST",r.nodeFork(this.nodePath(e)),{})}reviveNode(e,t){return this.request("POST",r.nodeRevive(this.nodePath(e)),t??{})}relaunchRoot(e){return this.request("POST",r.nodeRelaunchRoot(this.nodePath(e)),{})}bindBrokerSession(e,t){return this.request("POST",r.nodeBrokerSessionBound(this.nodePath(e)),t)}cycleStartBroker(e,t,n){return this.request("POST",r.nodeBrokerCycleStart(this.nodePath(e)),t,n)}settleBroker(e,t){return this.request("POST",r.nodeBrokerSettle(this.nodePath(e)),t)}startBrokerCycle(e,t){return this.request("POST",r.nodeBrokerCycle(this.nodePath(e)),t)}async postBrokerIdle(e,t){await this.request("POST",r.nodeBrokerIdle(this.nodePath(e)),t)}completeBrokerPark(e,t){return this.request("POST",r.nodeBrokerParkComplete(this.nodePath(e)),t)}recordBrokerParkActivity(e,t){return this.request("POST",r.nodeBrokerParkActivity(this.nodePath(e)),t)}async recordBrokerTelemetry(e,t){await this.request("POST",r.nodeBrokerTelemetry(this.nodePath(e)),t)}claimNodeMail(e,t){return this.request("POST",r.nodeMailClaim(this.nodePath(e)),t)}acknowledgeNodeMail(e,t){return this.request("POST",r.nodeMailAcknowledge(this.nodePath(e)),t)}recordBrokerTurn(e,t){return this.request("POST",r.brokerTurn(this.nodePath(e)),t)}mutateBrokerProviderRetry(e,t){return this.request("POST",r.brokerProviderRetry(this.nodePath(e)),t)}mutateBrokerFault(e,t){return this.request("POST",r.brokerFault(this.nodePath(e)),t)}getBrokerRecovery(e,t){return this.request("GET",`${r.brokerRecovery(this.nodePath(e))}?expected_execution_id=${encodeURIComponent(t)}`)}recordNodeFault(e,t){return this.request("POST",r.nodeFault(this.nodePath(e)),t)}clearNodeFault(e,t={}){const n=new URLSearchParams;t.link!==void 0&&n.set("link",t.link),t.preserve_episode!==void 0&&n.set("preserve_episode",String(t.preserve_episode));const s=n.size===0?"":`?${n.toString()}`;return this.request("DELETE",`${r.nodeFault(this.nodePath(e))}${s}`)}commitBrokerModel(e,t){return this.request("POST",r.nodeBrokerModel(this.nodePath(e)),t)}executionStart(e){return this.request("GET",r.executionStart(e))}executionImportUnpacked(e){return this.request("POST",r.executionImportUnpacked(e),{})}gitCredential(e,t){return this.request("POST",r.environmentGitCredential(e),t)}brokerExtensionState(e){return this.request("GET",r.nodeBrokerExtensionState(this.nodePath(e)))}brokerStructuredRequest(e){return this.request("GET",r.nodeBrokerStructuredRequest(this.nodePath(e)))}captureBrokerGoal(e,t){return this.request("POST",r.nodeBrokerGoal(this.nodePath(e)),t)}commitBrokerGeneratedName(e,t){return this.request("POST",r.nodeBrokerGeneratedName(this.nodePath(e)),t)}commitBrokerPersonaAck(e,t){return this.request("POST",r.nodeBrokerPersonaAck(this.nodePath(e)),t)}closeNode(e,t){return this.request("POST",r.nodeClose(this.nodePath(e)),t??{})}async markNodeRead(e){await this.request("POST",r.nodeRead(this.nodePath(e)),{})}recycleNode(e){return this.request("POST",r.nodeRecycle(this.nodePath(e)),{})}demoteNode(e){return this.request("POST",r.nodeDemote(this.nodePath(e)),{})}promoteNode(e,t){return this.request("POST",r.nodePromote(this.nodePath(e)),t)}yieldNode(e,t){return this.request("POST",r.nodeYield(this.nodePath(e)),t)}waitNode(e,t){return this.request("POST",r.nodeWait(this.nodePath(e)),t)}listKinds(){return this.request("GET",r.kinds())}patchConfig(e,t){return this.request("PATCH",r.nodeConfig(this.nodePath(e)),t,t.model!==void 0?{timeout:45e3+this.timeoutMs}:void 0)}closeWorktree(e){return this.request("POST",r.nodeWorktreeClose(this.nodePath(e)),{})}abandonWorktree(e,t){return this.request("POST",r.nodeWorktreeAbandon(this.nodePath(e)),t)}retryDelivery(e){return this.request("POST",r.deliveryRetry(e),{})}listQuarantinedWorktrees(){return this.request("GET",r.quarantinedWorktrees())}showLimits(){return this.request("GET",r.limits())}setAppLimits(e,t){return this.request("PUT",r.limitsApp(e),t)}removeAppLimits(e,t){return this.request("DELETE",d(r.limitsApp(e),{fields:t.join(",")}))}listCharges(e={}){return this.request("GET",d(r.charges(),e))}listSpendLimits(){return this.request("GET",r.spendLimits())}setSpendLimit(e,t){return this.request("PUT",r.spendLimit(e),t)}removeSpendLimit(e){return this.request("DELETE",r.spendLimit(e))}listSpaces(){return this.request("GET",r.spaces())}subscribe(e,t){return this.request("POST",r.nodeSubscriptions(this.nodePath(e)),t)}listFocuses(){return this.request("GET",r.focuses())}focusOf(e){return this.request("GET",d(r.focusByNode(),{node_id:e}))}focusByPane(e){return this.request("GET",d(r.focusByPane(),{pane:e}))}registerFocus(e){return this.request("POST",r.focuses(),e)}async setFocusPane(e,t){await this.request("PATCH",r.focus(e),t)}async closeFocus(e){await this.request("DELETE",r.focus(e))}async unsubscribe(e,t){await this.request("DELETE",r.nodeSubscription(this.nodePath(e),this.nodePath(t)))}armCron(e){return this.request("POST",r.crons(),e)}listCrons(e){return this.request("GET",d(r.crons(),e))}showCron(e,t){return this.request("GET",d(r.cron(this.cronPath(e)),t))}pauseCron(e,t){return this.request("POST",d(r.cronPause(this.cronPath(e)),t),{})}resumeCron(e,t){return this.request("POST",d(r.cronResume(this.cronPath(e)),t),{})}runCron(e,t){return this.request("POST",d(r.cronRun(this.cronPath(e)),t),{})}async cancelCron(e,t){await this.request("DELETE",d(r.cron(this.cronPath(e)),t))}pokeCrons(){return this.request("POST",r.cronsPoke(),{})}ensureAttach(e,t){return this.request("POST",r.nodeAttach(this.nodePath(e)),t??{},{timeout:$+this.timeoutMs})}getReports(e,t){return this.request("GET",d(r.nodeReports(this.nodePath(e)),t))}getTranscript(e,t){return this.request("GET",d(r.nodeTranscript(this.nodePath(e)),t))}getSnapshot(e){return this.request("GET",r.nodeSnapshot(this.nodePath(e)))}nodeSubject(e){return this.request("GET",r.nodeSubject(this.nodePath(e)))}getNodeMessages(e,t){return this.request("GET",d(r.nodeMessages(this.nodePath(e)),t))}getSession(e){return this.request("GET",r.nodeSession(this.nodePath(e)))}getChatInventory(e){return this.request("GET",r.nodeChatInventory(this.nodePath(e)))}getProspectiveChatInventory(e){return this.request("GET",d(r.prospectiveChatInventory(),e))}getContext(e){return this.request("GET",r.nodeContext(this.nodePath(e)))}peekFile(e,t,n){return this.request("GET",d(r.filePeek(),{path:e,encoding:t}),void 0,n)}writeFile(e,t,n,s){return this.request("POST",r.fileWrite(),{path:e,content:t,encoding:n},s)}listFiles(e,t,n){return this.request("GET",d(r.fileList(),{path:e,limit:t}),void 0,n)}runBash(e,t){return this.request("POST",r.bash(),e,t)}objects={read:a((e,t)=>this.request("GET",d(r.object(e),t)),"read"),list:a(e=>this.request("GET",d(r.objects(),e)),"list"),search:a(e=>this.request("POST",r.objectsSearch(),e),"search"),watch:a((e,t={})=>this.request("POST",r.objectWatch(e),t),"watch"),unwatch:a((e,t)=>this.request("DELETE",d(r.objectWatch(e),t)),"unwatch"),edges:a((e,t)=>this.request("GET",d(r.objectEdges(e),t)),"edges")};docs={write:a(e=>this.request("POST",r.docs(),e),"write"),edit:a((e,t)=>this.request("PATCH",r.doc(e),t),"edit"),move:a((e,t)=>this.request("POST",r.docMove(e),t),"move"),delete:a(e=>this.request("DELETE",r.doc(e)),"delete"),history:a((e,t)=>this.request("GET",d(r.docHistory(e),t)),"history"),lint:a((e={})=>this.request("POST",r.docsLint(),e),"lint")};documents={browserAccess:a(()=>this.request("GET",r.documentsBrowserAccess()),"browserAccess"),reconcilePackages:a(e=>this.request("POST",r.documentsReconcilePackages(),e),"reconcilePackages")};plugins={appToken:a(e=>this.request("GET",r.pluginAppToken(e)),"appToken"),callHeaders:a((e,t)=>this.request("POST",r.pluginCallHeaders(e),t),"callHeaders")};nodeDelivery(e,t){return this.request("POST",r.nodeDelivery(this.nodePath(e)),t)}deliveryDryRun(e){return this.request("POST",r.deliveryDryRun(),e)}recordBackgroundedJob(e,t,n){return this.request("POST",r.nodeJobBackground(this.nodePath(e),this.jobPath(t)),n)}ensureProfile(e,t){return this.request("PUT",r.profile(e),t??{})}createProfile(e){return this.request("POST",r.profiles(),e)}listProfiles(){return this.request("GET",r.profiles())}updateProfile(e,t){return this.request("PATCH",r.profile(e),t)}listAppEnv(){return this.request("GET",r.appEnv())}setAppEnv(e,t){return this.request("PUT",r.appEnvVar(e),{value:t})}removeAppEnv(e){return this.request("DELETE",r.appEnvVar(e))}listProfileEnv(e){return this.request("GET",r.profileEnv(e))}setProfileEnv(e,t,n){return this.request("PUT",r.profileEnvVar(e,t),{value:n})}removeProfileEnv(e,t){return this.request("DELETE",r.profileEnvVar(e,t))}getProfileEnvironment(e){return this.request("GET",r.profileEnvironment(e))}setProfileEnvironment(e,t){return this.request("PUT",r.profileEnvironment(e),t)}getProfile(e){return this.request("GET",r.profile(e))}pauseProfile(e){return this.request("POST",r.profilePause(e),{})}resumeProfile(e){return this.request("POST",r.profileResume(e),{})}updateProfileMetadata(e,t){return this.request("PATCH",r.profileMetadata(e),t)}deleteProfile(e,t){return this.request("DELETE",r.profile(e),t)}getSettings(){return this.request("GET",r.settings())}putSettings(e){return this.request("PUT",r.settings(),e)}listModelAuth(){return this.request("GET",r.modelAuths())}getModelAuthReadiness(e){return this.request("GET",d(r.modelAuthReadiness(),e))}installCredential(e,t){return this.request("PUT",r.modelAuth(e),t)}removeCredential(e){return this.request("DELETE",r.modelAuth(e))}patchModelAuthAccount(e,t,n){return this.request("PATCH",r.modelAuthAccount(e,t),n)}removeModelAuthAccount(e,t){return this.request("DELETE",r.modelAuthAccount(e,t))}startModelAuth(e){return this.request("POST",r.modelAuthFlows(),e,{timeout:3e4+this.timeoutMs})}completeModelAuth(e,t){return this.request("POST",r.modelAuthFlowComplete(e),t,{timeout:35e3+this.timeoutMs})}cancelModelAuth(e){return this.request("POST",r.modelAuthFlowCancel(e),{})}getModelAuthFlow(e,t){return this.request("GET",d(r.modelAuthFlow(e),{wait:t}),void 0,{timeout:(t??0)*1e3+this.timeoutMs})}createReview(e){return this.request("POST",r.humanReviews(),e)}listReviews(e){return this.request("GET",d(r.humanReviews(),e))}getReview(e){return this.request("GET",r.humanReview(this.reviewPath(e)))}submitReview(e){return this.request("POST",r.humanReviewSubmit(this.reviewPath(e)),{})}cancelReview(e,t={}){return this.request("POST",r.humanReviewCancel(this.reviewPath(e)),t)}getReviewDocumentBase(e){return this.request("GET",r.humanReviewDocument(this.reviewPath(e)))}createReviewComment(e,t){const n=e===void 0?"self":this.reviewPath(e);return this.request("POST",r.humanReviewComments(n),t)}listReviewComments(e,t){const n=e===void 0?"self":this.reviewPath(e);return this.request("GET",d(r.humanReviewComments(n),t))}readReviewCommentEvents(e,t){return this.request("GET",d(r.humanReviewCommentEvents(this.reviewPath(e)),t))}updateReviewCommentRanges(e,t){return this.request("POST",r.humanReviewCommentRanges(this.reviewPath(e)),t)}getReviewComment(e){return this.request("GET",r.humanComment(this.commentPath(e)))}editReviewComment(e,t){return this.request("POST",r.humanCommentEdit(this.commentPath(e)),t)}resolveReviewComment(e,t={}){return this.request("POST",r.humanCommentResolve(this.commentPath(e)),t)}reopenReviewComment(e,t={}){return this.request("POST",r.humanCommentReopen(this.commentPath(e)),t)}deleteReviewComment(e,t={}){return this.request("POST",r.humanCommentDelete(this.commentPath(e)),t)}forkReviewComment(e){return this.request("POST",r.humanCommentFork(this.commentPath(e)),{})}listHumanInbox(){return this.request("GET",r.humanInbox())}getHumanInboxPage(e){return this.request("GET",r.humanInboxTicket(this.ticketId(e)))}getInboxHistory(e,t={}){if(e!==void 0&&(typeof e!="string"||e===""))throw new TypeError(`invalid node id: ${JSON.stringify(e)}`);return this.request("GET",d(r.humanInbox()+"/history",{node_id:e,state:t.state}))}respondHumanInboxPage(e,t){return this.request("POST",r.humanInboxRespond(this.ticketId(e)),t)}postInboxProgress(e,t){return this.request("POST",r.humanInboxProgress(this.ticketId(e)),{responses:t})}getInboxResponse(e){return this.request("GET",r.humanInboxResponse(this.ticketId(e)))}cancelHumanInboxTicket(e,t){return this.request("POST",r.humanInboxCancel(this.ticketId(e)),t??{})}createHumanRequest(e){return this.request("POST",r.humanRequests(),e)}listPageComponents(){return this.request("GET",r.humanComponents())}getHumanRequest(e){return this.request("GET",r.humanRequest(this.requestPath(e)))}replaceHumanRequest(e,t){return this.request("POST",r.humanRequestReplace(this.requestPath(e)),t)}respondHumanRequest(e,t){return this.request("POST",r.humanRequestRespond(this.requestPath(e)),t)}dismissHumanRequest(e,t={}){return this.request("POST",r.humanRequestDismiss(this.requestPath(e)),t)}cancelHumanRequest(e,t={}){return this.request("POST",r.humanRequestCancel(this.requestPath(e)),t)}resolvePageFeedbackComment(e,t,n){if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(t))throw new TypeError(`invalid feedback comment id: ${JSON.stringify(t)}`);return this.request("POST",r.humanInboxFeedbackResolve(this.ticketId(e),t),{node_id:n})}async dashboard(e){const t=e?.under!==void 0?{under:e.under}:void 0,[n,s]=await Promise.all([this.listNodes(t),this.status()]);return{nodes:n,counts:s.node_counts,generated_at:new Date().toISOString()}}attention(){return this.request("GET",r.canvasAttention())}attentionCounts(e){const t={node_ids:e};return this.request("POST",r.canvasAttentionCounts(),t)}historySearch(e){return this.request("POST",r.canvasHistorySearch(),e)}historyGrep(e){return this.request("POST",r.canvasHistoryGrep(),e)}historyRead(e){return this.request("GET",d(r.canvasHistoryRead(),e))}historyStats(e){return this.request("POST",r.canvasHistoryStats(),e)}canvasSnapshot(){return this.request("GET",r.canvasSnapshot())}analytics(e){return this.request("GET",d(r.canvasAnalytics(),e),void 0,{timeout:6e4})}async recordMemoryReads(e,t){await this.request("POST",r.nodeMemoryReads(this.nodePath(e)),t)}liveRoots(e={}){return this.request("GET",d(r.canvasLiveRoots(),e))}canvasRoster(){return this.request("GET",r.canvasRoster())}async canvasBrowseCompressed(){const e=await this.send("GET",r.canvasBrowse());return e.ok||await q(e),new Uint8Array(await e.arrayBuffer())}canvasGraph(){return this.request("GET",r.canvasGraph())}prune(e){return this.request("POST",r.canvasPrune(),e)}async request(e,t,n,s){try{const o=s===void 0?void 0:this.resolveBudget(s),u=await this.send(e,t,n,o);return await q(u,o?.deadlineAt)}catch(o){throw Q(e,w(o,s?.signal))}}async rawResponse(e,t,n){try{return await this.send(e,t,void 0,n)}catch(s){throw w(s,n?.signal)}}async send(e,t,n,s={}){const o=this.resolveBudget(s),u=e==="GET"||e==="HEAD"||e==="DELETE",c=o.maxRetries??this.maxRetries,l=Math.min(o.deadlineAt??1/0,Date.now()+W);for(let m=0;;m++){let h;try{h=await this.transport(e,t,n,o)}catch(P){if(this.isColdSocketError(P)||this.isInterruptedSocketError(P)){const T=this.availabilityFailure?.();if(T!==void 0)throw T}if(this.isColdSocketError(P))try{await this.handleColdSocket(P,o.deadlineAt),h=await this.transport(e,t,n,o)}catch(T){throw o.deadlineAt!==void 0&&Date.now()>=o.deadlineAt&&!A(T,o.signal)?S(o.deadlineAt):w(T,o.signal)}else{if(this.isInterruptedSocketError(P)&&this.localSocketTransport&&(!u||m<c))return await this.rideOutInterruptedRequest(e,t,n,o);if(u&&m<c&&!A(P,o.signal)&&(!this.localSocketTransport||!this.isInterruptedSocketError(P))){await R(G(m+1),o);continue}else throw w(P,o.signal)}}if(z(e)&&c>0&&h.status===503&&await V(h,o.deadlineAt)){const P=Math.max(250,(M(h)??0)*1e3)+Math.random()*250;if(Date.now()+P>=l)return h;await g(h,o.deadlineAt),await R(P,{signal:o.signal});continue}if(u&&m<c&&K(h.status)){await g(h,o.deadlineAt),await R(G(m+1),o,M(h));continue}return h}}resolveBudget(e){const{budgetMs:t,deadlineAt:n,...s}=e;if(t===void 0&&n===void 0)return s;if(t!==void 0&&(!Number.isFinite(t)||t<=0||t>v))throw new RangeError(`budgetMs must be a positive finite number of at most ${v}`);if(n!==void 0&&(!Number.isFinite(n)||n-Date.now()>v))throw new RangeError(`deadlineAt must be a finite epoch-millisecond instant at most ${v} ms from now`);return{...s,deadlineAt:Math.min(n??1/0,t===void 0?1/0:Date.now()+t)}}async awaitWithinBudget(e,t){if(t===void 0)return e;const n=t-Date.now();if(n<=0)throw p(t);let s;try{return await Promise.race([e,new Promise((o,u)=>{s=setTimeout(()=>u(p(t)),n)})])}finally{s!==void 0&&clearTimeout(s)}}async sendOnce(e,t,n,s={}){const o=this.resolveBudget(s);try{return await q(await this.transport(e,t,n,o))}catch(u){throw w(u,o.signal)}}nodePath(e){if(!b(e))throw new f(400,"invalid_node_id",`invalid node id: ${JSON.stringify(e)}`);return e}jobPath(e){if(!L(e))throw new f(400,"invalid_job_id",`invalid background job id: ${JSON.stringify(e)}`);return e}cronPath(e){if(!I(e))throw new f(400,"invalid_cron_id",`invalid cron id: ${JSON.stringify(e)}`);return e}requestPath(e){if(!b(e))throw new f(400,"invalid_request_id",`invalid request id: ${JSON.stringify(e)}`);return e}ticketId(e){if(!/^[a-f0-9]{64}$/.test(e))throw new TypeError(`invalid inbox ticket id: ${JSON.stringify(e)}`);return e}reviewPath(e){if(!b(e))throw new f(400,"invalid_review_id",`invalid review id: ${JSON.stringify(e)}`);return e}commentPath(e){if(!/^[a-f0-9]{32}$/.test(e))throw new f(400,"invalid_comment_id",`invalid comment id: ${JSON.stringify(e)}`);return e}transport(e,t,n,s={}){const o=s.deadlineAt===void 0?void 0:s.deadlineAt-Date.now();if(o!==void 0&&o<=0)return Promise.reject(p(s.deadlineAt));const u=n===void 0?void 0:JSON.stringify(n),c={accept:"application/json",...this.headers,...s.headers};u!==void 0&&(c["content-type"]="application/json");const l=s.timeout??this.timeoutMs,m=o===void 0?l:l>0?Math.min(l,o):o,h=new AbortController,P=o!==void 0&&(l<=0||o<=l),T=m>0?setTimeout(()=>h.abort(P?p(s.deadlineAt):new DOMException("request timed out","TimeoutError")),m):void 0,E=s.signal,k=a(()=>h.abort(E?.reason),"onExternalAbort");E!==void 0&&(E.aborted?h.abort(E.reason):E.addEventListener("abort",k,{once:!0}));const C=a(()=>{T!==void 0&&clearTimeout(T),E?.removeEventListener("abort",k)},"finish");return Z(this.fetch(new URL(t,this.baseUrl),{method:e,headers:c,body:u,signal:h.signal}),h.signal).then(y=>(B(y.headers.get("server-timing")),this.retainRequestLifetime(y,C,()=>h.signal.aborted?h.signal.reason:void 0)),y=>{throw C(),y})}retainRequestLifetime(e,t,n){if(e.body===null)return t(),e;const s=e.body.getReader();let o=!1;const u=a(()=>{o||(o=!0,t())},"close"),c=new ReadableStream({async pull(l){try{const{done:m,value:h}=await s.read();m?(u(),l.close()):l.enqueue(h)}catch(m){u(),l.error(n()??m)}},async cancel(l){u(),await s.cancel(l)}});return new Response(c,{status:e.status,statusText:e.statusText,headers:e.headers})}isColdSocketError(e){const t=O(e);return t==="ECONNREFUSED"||t==="ENOENT"||t==="ENOTSOCK"}isInterruptedSocketError(e){const t=O(e);return t==="ECONNRESET"||t==="EPIPE"}async rideOutInterruptedRequest(e,t,n,s={}){try{await this.awaitAvailability(void 0,s.deadlineAt)}catch(o){throw w(o,s.signal)}if(e!=="GET"&&e!=="HEAD")throw new f(503,"daemon_request_interrupted",`crtrd connection ended before this ${e} response; the request may or may not have been applied.`);try{return await this.transport(e,t,n,s)}catch(o){throw w(o,s.signal)}}async awaitAvailability(e,t){const n=t===void 0?void 0:t-Date.now();if(n!==void 0&&n<=0)throw p(t);let s,o;try{await J({windowMs:Math.min(this.coldStartPollWindowMs,n??this.coldStartPollWindowMs),initialError:e,retry:a(u=>u!==s&&u!==o,"retry"),probe:a(async u=>{const c=this.availabilityFailure?.();if(c!==void 0)throw o=c,c;const l=this.coldStartFailure?.();if(l!==void 0)throw s=new f(503,"daemon_unavailable",`crtrd failed to start: ${l}`),s;const m=await this.transport("GET",r.healthz(),void 0,{timeout:u});if(m.status>=200&&m.status<300){await g(m);return}const h=await m.text();try{if(typeof JSON.parse(h).startup_blocked=="string")return}catch{}throw new f(m.status,"daemon_health_unavailable",`crtrd health check returned HTTP ${m.status}: ${h.slice(0,500)}`)},"probe")})}catch(u){throw u===s&&(this.startupFailureReported=!0),u}}async handleColdSocket(e,t){const n=this.autostart&&this.onColdSocket!==void 0&&!this.coldStartAttempted;n&&(this.coldStartAttempted=!0,await this.awaitWithinBudget(this.onColdSocket(),t));try{await this.awaitAvailability(e,t)}catch(s){if(n&&!this.startupFailureReported){const o=X(this.coldStartDiagnostic);if(o!==void 0){const u=w(s);throw new f(u.status,u.code,`${u.message}
3
- ${o}`)}}throw s}}}function d(i,e){if(e===void 0)return i;const t=new URLSearchParams;for(const[s,o]of Object.entries(e))o!=null&&t.set(s,String(o));const n=t.toString();return n===""?i:`${i}?${n}`}a(d,"withQuery");async function q(i,e){const t=i.status>=200&&i.status<300,n=(await _(i,e)).trim();let s;if(n!=="")try{s=JSON.parse(n)}catch{if(t)return;throw new f(i.status,"invalid_response",n.slice(0,500),void 0,i.headers)}if(t)return s;throw x(s)?new f(i.status,s.error.code,s.error.message,s.error.details,i.headers,s.error):new f(i.status,"internal",`request failed with status ${i.status}`,void 0,i.headers)}a(q,"parse");const W=6e4;function z(i){return i==="GET"||i==="HEAD"}a(z,"isRead");async function V(i,e){try{if(Number(i.headers.get("content-length")??0)>8192)return!1;const t=await _(i.clone(),Math.min(e??1/0,Date.now()+5e3)),n=JSON.parse(t).error;return n?.origin==="router"&&n.details?.forwarded===!1&&(n.details.runtime_state==="creating"||n.details.runtime_state==="recovering")}catch{return!1}}a(V,"isRefusedBeforeForwarding");function K(i){return i===429||i>=500}a(K,"isRetryableStatus");async function g(i,e){const t=(async()=>{try{await i.body?.cancel()}catch{}})();if(e===void 0)return t;let n;try{await Promise.race([t,new Promise(s=>{n=setTimeout(s,Math.max(0,e-Date.now()))})])}finally{n!==void 0&&clearTimeout(n)}}a(g,"drainResponseBody");async function _(i,e){if(e===void 0)return i.text();const t=e-Date.now(),n=i.text();if(n.catch(()=>{}),t<=0)throw i.body?.cancel().catch(()=>{}),S(e);let s;try{return await Promise.race([n,new Promise((o,u)=>{s=setTimeout(()=>{i.body?.cancel().catch(()=>{}),u(S(e))},t)})])}finally{s!==void 0&&clearTimeout(s)}}a(_,"readTextWithin");function G(i){return Math.min(2e3,250*2**(i-1))}a(G,"retryDelayMs");function O(i){if(typeof i!="object"||i===null)return;const e=i.code;if(typeof e=="string")return e;const t=i.cause;if(typeof t=="object"&&t!==null){const n=t.code;if(typeof n=="string")return n}}a(O,"transportErrorCode");function A(i,e){return e?.aborted?!0:i instanceof DOMException&&(i.name==="AbortError"||i.name==="TimeoutError")}a(A,"isAbortError");function w(i,e){if(e?.aborted)return new f(0,"request_aborted","request aborted by caller signal");if(i instanceof f)return i;if(i instanceof DOMException&&i.name==="TimeoutError")return new f(504,"request_timeout",`crtrd request timed out: ${i.message}`);if(i instanceof DOMException&&i.name==="AbortError")return new f(0,"request_aborted","request aborted by caller signal");const t=O(i),n=i instanceof Error?i.message:String(i);return t==="ECONNREFUSED"||t==="ENOENT"||t==="ENOTSOCK"?new f(503,"daemon_unavailable",`crtrd is not reachable: ${n}`):t==="ETIMEDOUT"?new f(504,"request_timeout",`crtrd request timed out: ${n}`):new f(503,"transport_error",n)}a(w,"toTransportApiError");function Q(i,e){return i==="GET"||i==="HEAD"||e.status!==504||e.code!=="request_timeout"?e:new f(e.status,e.code,`${e.message}; the ${i} request was sent, so it may or may not have been applied`,{outcome:"unknown"},e.headers)}a(Q,"withUnknownOutcome");function M(i){const e=Number(i.headers.get("retry-after"));return Number.isFinite(e)&&e>0?e:void 0}a(M,"retryAfterHeaderS");async function R(i,e,t,n){const{deadlineAt:s,signal:o}=e;if(o?.aborted)throw new f(0,"request_aborted","request aborted by caller signal");const u=s!==void 0&&t!==void 0?t*1e3:void 0,c=Math.max(i,u??0);if(s!==void 0&&Date.now()+c>=s){const l=S(s,u!==void 0&&u>=i?"retry_after":"elapsed",u===void 0?void 0:t);throw n!==void 0&&Object.defineProperty(l,"cause",{value:n,configurable:!0,writable:!0}),l}if(o===void 0)return D(c);await new Promise((l,m)=>{const h=a(()=>{clearTimeout(P),o.removeEventListener("abort",h),m(new f(0,"request_aborted","request aborted by caller signal"))},"onAbort"),P=setTimeout(()=>{o.removeEventListener("abort",h),l()},c);o.addEventListener("abort",h,{once:!0})})}a(R,"sleepWithin");function Z(i,e){return new Promise((t,n)=>{const s=a(()=>n(e.reason),"onAbort");e.aborted?s():e.addEventListener("abort",s,{once:!0}),i.then(o=>{e.removeEventListener("abort",s),e.aborted?o.body?.cancel().catch(()=>{}):t(o)},o=>{e.removeEventListener("abort",s),n(o)})})}a(Z,"abortable");function D(i){return new Promise(e=>setTimeout(e,i))}a(D,"sleepMs");function X(i){if(i!==void 0)try{return i()}catch{return}}a(X,"safeColdStartDiagnostic");export{oe as CrtrClient,v as MAX_TIMER_MS,S as deadlineExceeded,X as safeColdStartDiagnostic,R as sleepWithin,J as waitForDaemonAvailability};
2
+ `))!==-1;){const P=c.slice(0,h);c=c.slice(h+1),P!==""&&(yield JSON.parse(P))}}if(c+=u.decode(),c.trim()!=="")throw new f(502,"invalid_response","broker signal stream ended mid-line")}finally{await o.cancel().catch(()=>{})}}createStructuredRequest(e,t){return e.mode==="sync"?this.sendOnce("POST","/v1/structured-requests",e,t):this.request("POST","/v1/structured-requests",e,t)}getStructuredRequest(e,{wait:t=0,budgetMs:n}={}){if(!Number.isInteger(t)||t<0||t>25)throw new RangeError("wait must be an integer between 0 and 25");return this.request("GET",d(`/v1/structured-requests/${this.requestPath(e)}`,{wait:t}),void 0,{budgetMs:n})}cancelStructuredRequest(e,t){return this.request("POST",`/v1/structured-requests/${this.requestPath(e)}/cancel`,{},t)}registerOutcomeDelivery(e,t){return this.request("PUT",r.nodeOutcomeDelivery(this.nodePath(e)),t)}getOutcomeDelivery(e){return this.request("GET",r.nodeOutcomeDelivery(this.nodePath(e)))}async disarmOutcomeDelivery(e){await this.request("DELETE",r.nodeOutcomeDelivery(this.nodePath(e)))}listBashJobs(e){return this.request("GET",r.nodeJobs(this.nodePath(e)))}readBashJobOutput(e,t,n={}){const s=new URLSearchParams;n.tail_lines!==void 0&&s.set("tail_lines",String(n.tail_lines)),n.max_bytes!==void 0&&s.set("max_bytes",String(n.max_bytes));const o=s.size===0?"":`?${s.toString()}`;return this.request("GET",`${r.nodeJobOutput(this.nodePath(e),this.jobPath(t))}${o}`)}stopBashJob(e,t){return this.request("DELETE",r.nodeJob(this.nodePath(e),this.jobPath(t)))}async patchBashJob(e,t,n){await this.request("PATCH",r.nodeJob(this.nodePath(e),this.jobPath(t)),n)}async reportBashJob(e,t,n){await this.request("POST",r.nodeJobReport(this.nodePath(e),this.jobPath(t)),n)}sendMessage(e,t){return this.request("POST",r.nodeMessages(this.nodePath(e)),t)}interruptNode(e){return this.request("POST",r.nodeInterrupt(this.nodePath(e)),{})}pushReport(e,t){return this.request("POST",r.nodeReports(this.nodePath(e)),t)}submitResult(e,t){return this.request("POST",r.nodeResult(this.nodePath(e)),t)}forkNode(e){return this.request("POST",r.nodeFork(this.nodePath(e)),{})}reviveNode(e,t){return this.request("POST",r.nodeRevive(this.nodePath(e)),t??{})}relaunchRoot(e){return this.request("POST",r.nodeRelaunchRoot(this.nodePath(e)),{})}bindBrokerSession(e,t){return this.request("POST",r.nodeBrokerSessionBound(this.nodePath(e)),t)}cycleStartBroker(e,t,n){return this.request("POST",r.nodeBrokerCycleStart(this.nodePath(e)),t,n)}settleBroker(e,t){return this.request("POST",r.nodeBrokerSettle(this.nodePath(e)),t)}startBrokerCycle(e,t){return this.request("POST",r.nodeBrokerCycle(this.nodePath(e)),t)}async postBrokerIdle(e,t){await this.request("POST",r.nodeBrokerIdle(this.nodePath(e)),t)}completeBrokerPark(e,t){return this.request("POST",r.nodeBrokerParkComplete(this.nodePath(e)),t)}recordBrokerParkActivity(e,t){return this.request("POST",r.nodeBrokerParkActivity(this.nodePath(e)),t)}async recordBrokerTelemetry(e,t){await this.request("POST",r.nodeBrokerTelemetry(this.nodePath(e)),t)}claimNodeMail(e,t){return this.request("POST",r.nodeMailClaim(this.nodePath(e)),t)}acknowledgeNodeMail(e,t){return this.request("POST",r.nodeMailAcknowledge(this.nodePath(e)),t)}recordBrokerTurn(e,t){return this.request("POST",r.brokerTurn(this.nodePath(e)),t)}mutateBrokerProviderRetry(e,t){return this.request("POST",r.brokerProviderRetry(this.nodePath(e)),t)}mutateBrokerFault(e,t){return this.request("POST",r.brokerFault(this.nodePath(e)),t)}getBrokerRecovery(e,t){return this.request("GET",`${r.brokerRecovery(this.nodePath(e))}?expected_execution_id=${encodeURIComponent(t)}`)}recordNodeFault(e,t){return this.request("POST",r.nodeFault(this.nodePath(e)),t)}clearNodeFault(e,t={}){const n=new URLSearchParams;t.link!==void 0&&n.set("link",t.link),t.preserve_episode!==void 0&&n.set("preserve_episode",String(t.preserve_episode));const s=n.size===0?"":`?${n.toString()}`;return this.request("DELETE",`${r.nodeFault(this.nodePath(e))}${s}`)}commitBrokerModel(e,t){return this.request("POST",r.nodeBrokerModel(this.nodePath(e)),t)}executionStart(e){return this.request("GET",r.executionStart(e))}executionImportUnpacked(e){return this.request("POST",r.executionImportUnpacked(e),{})}gitCredential(e,t){return this.request("POST",r.environmentGitCredential(e),t)}brokerExtensionState(e){return this.request("GET",r.nodeBrokerExtensionState(this.nodePath(e)))}brokerStructuredRequest(e){return this.request("GET",r.nodeBrokerStructuredRequest(this.nodePath(e)))}captureBrokerGoal(e,t){return this.request("POST",r.nodeBrokerGoal(this.nodePath(e)),t)}commitBrokerGeneratedName(e,t){return this.request("POST",r.nodeBrokerGeneratedName(this.nodePath(e)),t)}commitBrokerPersonaAck(e,t){return this.request("POST",r.nodeBrokerPersonaAck(this.nodePath(e)),t)}closeNode(e,t){return this.request("POST",r.nodeClose(this.nodePath(e)),t??{})}async markNodeRead(e){await this.request("POST",r.nodeRead(this.nodePath(e)),{})}recycleNode(e){return this.request("POST",r.nodeRecycle(this.nodePath(e)),{})}demoteNode(e){return this.request("POST",r.nodeDemote(this.nodePath(e)),{})}promoteNode(e,t){return this.request("POST",r.nodePromote(this.nodePath(e)),t)}yieldNode(e,t){return this.request("POST",r.nodeYield(this.nodePath(e)),t)}waitNode(e,t){return this.request("POST",r.nodeWait(this.nodePath(e)),t)}listKinds(){return this.request("GET",r.kinds())}patchConfig(e,t){return this.request("PATCH",r.nodeConfig(this.nodePath(e)),t,t.model!==void 0?{timeout:45e3+this.timeoutMs}:void 0)}closeWorktree(e){return this.request("POST",r.nodeWorktreeClose(this.nodePath(e)),{})}abandonWorktree(e,t){return this.request("POST",r.nodeWorktreeAbandon(this.nodePath(e)),t)}retryDelivery(e){return this.request("POST",r.deliveryRetry(e),{})}listQuarantinedWorktrees(){return this.request("GET",r.quarantinedWorktrees())}showLimits(){return this.request("GET",r.limits())}setAppLimits(e,t){return this.request("PUT",r.limitsApp(e),t)}removeAppLimits(e,t){return this.request("DELETE",d(r.limitsApp(e),{fields:t.join(",")}))}listCharges(e={}){return this.request("GET",d(r.charges(),e))}listSpendLimits(){return this.request("GET",r.spendLimits())}setSpendLimit(e,t){return this.request("PUT",r.spendLimit(e),t)}removeSpendLimit(e){return this.request("DELETE",r.spendLimit(e))}listSpaces(){return this.request("GET",r.spaces())}subscribe(e,t){return this.request("POST",r.nodeSubscriptions(this.nodePath(e)),t)}listFocuses(){return this.request("GET",r.focuses())}focusOf(e){return this.request("GET",d(r.focusByNode(),{node_id:e}))}focusByPane(e){return this.request("GET",d(r.focusByPane(),{pane:e}))}registerFocus(e){return this.request("POST",r.focuses(),e)}async setFocusPane(e,t){await this.request("PATCH",r.focus(e),t)}async closeFocus(e){await this.request("DELETE",r.focus(e))}async unsubscribe(e,t){await this.request("DELETE",r.nodeSubscription(this.nodePath(e),this.nodePath(t)))}armCron(e){return this.request("POST",r.crons(),e)}listCrons(e){return this.request("GET",d(r.crons(),e))}showCron(e,t){return this.request("GET",d(r.cron(this.cronPath(e)),t))}pauseCron(e,t){return this.request("POST",d(r.cronPause(this.cronPath(e)),t),{})}resumeCron(e,t){return this.request("POST",d(r.cronResume(this.cronPath(e)),t),{})}runCron(e,t){return this.request("POST",d(r.cronRun(this.cronPath(e)),t),{})}async cancelCron(e,t){await this.request("DELETE",d(r.cron(this.cronPath(e)),t))}pokeCrons(){return this.request("POST",r.cronsPoke(),{})}ensureAttach(e,t){return this.request("POST",r.nodeAttach(this.nodePath(e)),t??{},{timeout:$+this.timeoutMs})}getReports(e,t){return this.request("GET",d(r.nodeReports(this.nodePath(e)),t))}getTranscript(e,t){return this.request("GET",d(r.nodeTranscript(this.nodePath(e)),t))}getSnapshot(e){return this.request("GET",r.nodeSnapshot(this.nodePath(e)))}nodeSubject(e){return this.request("GET",r.nodeSubject(this.nodePath(e)))}getNodeMessages(e,t){return this.request("GET",d(r.nodeMessages(this.nodePath(e)),t))}getSession(e){return this.request("GET",r.nodeSession(this.nodePath(e)))}getChatInventory(e){return this.request("GET",r.nodeChatInventory(this.nodePath(e)))}getProspectiveChatInventory(e){return this.request("GET",d(r.prospectiveChatInventory(),e))}getContext(e){return this.request("GET",r.nodeContext(this.nodePath(e)))}peekFile(e,t,n){return this.request("GET",d(r.filePeek(),{path:e,encoding:t}),void 0,n)}writeFile(e,t,n,s){return this.request("POST",r.fileWrite(),{path:e,content:t,encoding:n},s)}listFiles(e,t,n){return this.request("GET",d(r.fileList(),{path:e,limit:t}),void 0,n)}runBash(e,t){return this.request("POST",r.bash(),e,t)}objects={read:a((e,t)=>this.request("GET",d(r.object(e),t)),"read"),list:a(e=>this.request("GET",d(r.objects(),e)),"list"),search:a(e=>this.request("POST",r.objectsSearch(),e),"search"),watch:a((e,t={})=>this.request("POST",r.objectWatch(e),t),"watch"),unwatch:a((e,t)=>this.request("DELETE",d(r.objectWatch(e),t)),"unwatch"),edges:a((e,t)=>this.request("GET",d(r.objectEdges(e),t)),"edges")};docs={write:a(e=>this.request("POST",r.docs(),e),"write"),edit:a((e,t)=>this.request("PATCH",r.doc(e),t),"edit"),move:a((e,t)=>this.request("POST",r.docMove(e),t),"move"),delete:a(e=>this.request("DELETE",r.doc(e)),"delete"),history:a((e,t)=>this.request("GET",d(r.docHistory(e),t)),"history"),lint:a((e={})=>this.request("POST",r.docsLint(),e),"lint")};documents={browserAccess:a(()=>this.request("GET",r.documentsBrowserAccess()),"browserAccess"),reconcilePackages:a(e=>this.request("POST",r.documentsReconcilePackages(),e),"reconcilePackages")};plugins={appToken:a(e=>this.request("GET",r.pluginAppToken(e)),"appToken"),callHeaders:a((e,t)=>this.request("POST",r.pluginCallHeaders(e),t),"callHeaders")};nodeDelivery(e,t){return this.request("POST",r.nodeDelivery(this.nodePath(e)),t)}deliveryDryRun(e){return this.request("POST",r.deliveryDryRun(),e)}recordBackgroundedJob(e,t,n){return this.request("POST",r.nodeJobBackground(this.nodePath(e),this.jobPath(t)),n)}ensureProfile(e,t){return this.request("PUT",r.profile(e),t??{})}createProfile(e){return this.request("POST",r.profiles(),e)}listProfiles(){return this.request("GET",r.profiles())}updateProfile(e,t){return this.request("PATCH",r.profile(e),t)}listAppEnv(){return this.request("GET",r.appEnv())}setAppEnv(e,t){return this.request("PUT",r.appEnvVar(e),{value:t})}removeAppEnv(e){return this.request("DELETE",r.appEnvVar(e))}listProfileEnv(e){return this.request("GET",r.profileEnv(e))}setProfileEnv(e,t,n){return this.request("PUT",r.profileEnvVar(e,t),{value:n})}removeProfileEnv(e,t){return this.request("DELETE",r.profileEnvVar(e,t))}getProfileEnvironment(e){return this.request("GET",r.profileEnvironment(e))}setProfileEnvironment(e,t){return this.request("PUT",r.profileEnvironment(e),t)}getProfile(e){return this.request("GET",r.profile(e))}pauseProfile(e){return this.request("POST",r.profilePause(e),{})}resumeProfile(e){return this.request("POST",r.profileResume(e),{})}updateProfileMetadata(e,t){return this.request("PATCH",r.profileMetadata(e),t)}deleteProfile(e,t){return this.request("DELETE",r.profile(e),t)}getSettings(){return this.request("GET",r.settings())}putSettings(e){return this.request("PUT",r.settings(),e)}listModelAuth(){return this.request("GET",r.modelAuths())}getModelAuthReadiness(e){return this.request("GET",d(r.modelAuthReadiness(),e))}installCredential(e,t){return this.request("PUT",r.modelAuth(e),t)}removeCredential(e){return this.request("DELETE",r.modelAuth(e))}patchModelAuthAccount(e,t,n){return this.request("PATCH",r.modelAuthAccount(e,t),n)}removeModelAuthAccount(e,t){return this.request("DELETE",r.modelAuthAccount(e,t))}startModelAuth(e){return this.request("POST",r.modelAuthFlows(),e,{timeout:3e4+this.timeoutMs})}completeModelAuth(e,t){return this.request("POST",r.modelAuthFlowComplete(e),t,{timeout:35e3+this.timeoutMs})}cancelModelAuth(e){return this.request("POST",r.modelAuthFlowCancel(e),{})}getModelAuthFlow(e,t){return this.request("GET",d(r.modelAuthFlow(e),{wait:t}),void 0,{timeout:(t??0)*1e3+this.timeoutMs})}createReview(e){return this.request("POST",r.humanReviews(),e)}listReviews(e){return this.request("GET",d(r.humanReviews(),e))}getReview(e){return this.request("GET",r.humanReview(this.reviewPath(e)))}submitReview(e){return this.request("POST",r.humanReviewSubmit(this.reviewPath(e)),{})}cancelReview(e,t={}){return this.request("POST",r.humanReviewCancel(this.reviewPath(e)),t)}getReviewDocumentBase(e){return this.request("GET",r.humanReviewDocument(this.reviewPath(e)))}createReviewComment(e,t){const n=e===void 0?"self":this.reviewPath(e);return this.request("POST",r.humanReviewComments(n),t)}listReviewComments(e,t){const n=e===void 0?"self":this.reviewPath(e);return this.request("GET",d(r.humanReviewComments(n),t))}readReviewCommentEvents(e,t){return this.request("GET",d(r.humanReviewCommentEvents(this.reviewPath(e)),t))}updateReviewCommentRanges(e,t){return this.request("POST",r.humanReviewCommentRanges(this.reviewPath(e)),t)}getReviewComment(e){return this.request("GET",r.humanComment(this.commentPath(e)))}editReviewComment(e,t){return this.request("POST",r.humanCommentEdit(this.commentPath(e)),t)}resolveReviewComment(e,t={}){return this.request("POST",r.humanCommentResolve(this.commentPath(e)),t)}reopenReviewComment(e,t={}){return this.request("POST",r.humanCommentReopen(this.commentPath(e)),t)}deleteReviewComment(e,t={}){return this.request("POST",r.humanCommentDelete(this.commentPath(e)),t)}forkReviewComment(e){return this.request("POST",r.humanCommentFork(this.commentPath(e)),{})}listHumanInbox(){return this.request("GET",r.humanInbox())}getHumanInboxPage(e){return this.request("GET",r.humanInboxTicket(this.ticketId(e)))}getInboxHistory(e,t={}){if(e!==void 0&&(typeof e!="string"||e===""))throw new TypeError(`invalid node id: ${JSON.stringify(e)}`);return this.request("GET",d(r.humanInbox()+"/history",{node_id:e,state:t.state}))}respondHumanInboxPage(e,t){return this.request("POST",r.humanInboxRespond(this.ticketId(e)),t)}postInboxProgress(e,t){return this.request("POST",r.humanInboxProgress(this.ticketId(e)),{responses:t})}getInboxResponse(e){return this.request("GET",r.humanInboxResponse(this.ticketId(e)))}cancelHumanInboxTicket(e,t){return this.request("POST",r.humanInboxCancel(this.ticketId(e)),t??{})}createHumanRequest(e){return this.request("POST",r.humanRequests(),e)}listPageComponents(){return this.request("GET",r.humanComponents())}getHumanRequest(e){return this.request("GET",r.humanRequest(this.requestPath(e)))}replaceHumanRequest(e,t){return this.request("POST",r.humanRequestReplace(this.requestPath(e)),t)}respondHumanRequest(e,t){return this.request("POST",r.humanRequestRespond(this.requestPath(e)),t)}dismissHumanRequest(e,t={}){return this.request("POST",r.humanRequestDismiss(this.requestPath(e)),t)}cancelHumanRequest(e,t={}){return this.request("POST",r.humanRequestCancel(this.requestPath(e)),t)}resolvePageFeedbackComment(e,t,n){if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(t))throw new TypeError(`invalid feedback comment id: ${JSON.stringify(t)}`);return this.request("POST",r.humanInboxFeedbackResolve(this.ticketId(e),t),{node_id:n})}async dashboard(e){const t=e?.under!==void 0?{under:e.under}:void 0,[n,s]=await Promise.all([this.listNodes(t),this.status()]);return{nodes:n,counts:s.node_counts,generated_at:new Date().toISOString()}}attention(){return this.request("GET",r.canvasAttention())}attentionCounts(e){const t={node_ids:e};return this.request("POST",r.canvasAttentionCounts(),t)}historySearch(e){return this.request("POST",r.canvasHistorySearch(),e)}historyGrep(e){return this.request("POST",r.canvasHistoryGrep(),e)}historyRead(e){return this.request("GET",d(r.canvasHistoryRead(),e))}historyStats(e){return this.request("POST",r.canvasHistoryStats(),e)}canvasSnapshot(){return this.request("GET",r.canvasSnapshot())}analytics(e){return this.request("GET",d(r.canvasAnalytics(),e),void 0,{timeout:6e4})}async recordMemoryReads(e,t){await this.request("POST",r.nodeMemoryReads(this.nodePath(e)),t)}liveRoots(e={}){return this.request("GET",d(r.canvasLiveRoots(),e))}canvasView(e){return this.request("GET",r.canvasView(e))}canvasRoster(){return this.request("GET",r.canvasRoster())}async canvasBrowseCompressed(){const e=await this.send("GET",r.canvasBrowse());return e.ok||await q(e),new Uint8Array(await e.arrayBuffer())}canvasGraph(){return this.request("GET",r.canvasGraph())}prune(e){return this.request("POST",r.canvasPrune(),e)}async request(e,t,n,s){try{const o=s===void 0?void 0:this.resolveBudget(s),u=await this.send(e,t,n,o);return await q(u,o?.deadlineAt)}catch(o){throw Q(e,w(o,s?.signal))}}async rawResponse(e,t,n){try{return await this.send(e,t,void 0,n)}catch(s){throw w(s,n?.signal)}}async send(e,t,n,s={}){const o=this.resolveBudget(s),u=e==="GET"||e==="HEAD"||e==="DELETE",c=o.maxRetries??this.maxRetries,l=Math.min(o.deadlineAt??1/0,Date.now()+W);for(let m=0;;m++){let h;try{h=await this.transport(e,t,n,o)}catch(P){if(this.isColdSocketError(P)||this.isInterruptedSocketError(P)){const T=this.availabilityFailure?.();if(T!==void 0)throw T}if(this.isColdSocketError(P))try{await this.handleColdSocket(P,o.deadlineAt),h=await this.transport(e,t,n,o)}catch(T){throw o.deadlineAt!==void 0&&Date.now()>=o.deadlineAt&&!A(T,o.signal)?S(o.deadlineAt):w(T,o.signal)}else{if(this.isInterruptedSocketError(P)&&this.localSocketTransport&&(!u||m<c))return await this.rideOutInterruptedRequest(e,t,n,o);if(u&&m<c&&!A(P,o.signal)&&(!this.localSocketTransport||!this.isInterruptedSocketError(P))){await R(G(m+1),o);continue}else throw w(P,o.signal)}}if(V(e)&&c>0&&h.status===503&&await z(h,o.deadlineAt)){const P=Math.max(250,(M(h)??0)*1e3)+Math.random()*250;if(Date.now()+P>=l)return h;await g(h,o.deadlineAt),await R(P,{signal:o.signal});continue}if(u&&m<c&&K(h.status)){await g(h,o.deadlineAt),await R(G(m+1),o,M(h));continue}return h}}resolveBudget(e){const{budgetMs:t,deadlineAt:n,...s}=e;if(t===void 0&&n===void 0)return s;if(t!==void 0&&(!Number.isFinite(t)||t<=0||t>v))throw new RangeError(`budgetMs must be a positive finite number of at most ${v}`);if(n!==void 0&&(!Number.isFinite(n)||n-Date.now()>v))throw new RangeError(`deadlineAt must be a finite epoch-millisecond instant at most ${v} ms from now`);return{...s,deadlineAt:Math.min(n??1/0,t===void 0?1/0:Date.now()+t)}}async awaitWithinBudget(e,t){if(t===void 0)return e;const n=t-Date.now();if(n<=0)throw p(t);let s;try{return await Promise.race([e,new Promise((o,u)=>{s=setTimeout(()=>u(p(t)),n)})])}finally{s!==void 0&&clearTimeout(s)}}async sendOnce(e,t,n,s={}){const o=this.resolveBudget(s);try{return await q(await this.transport(e,t,n,o))}catch(u){throw w(u,o.signal)}}nodePath(e){if(!b(e))throw new f(400,"invalid_node_id",`invalid node id: ${JSON.stringify(e)}`);return e}jobPath(e){if(!L(e))throw new f(400,"invalid_job_id",`invalid background job id: ${JSON.stringify(e)}`);return e}cronPath(e){if(!I(e))throw new f(400,"invalid_cron_id",`invalid cron id: ${JSON.stringify(e)}`);return e}requestPath(e){if(!b(e))throw new f(400,"invalid_request_id",`invalid request id: ${JSON.stringify(e)}`);return e}ticketId(e){if(!/^[a-f0-9]{64}$/.test(e))throw new TypeError(`invalid inbox ticket id: ${JSON.stringify(e)}`);return e}reviewPath(e){if(!b(e))throw new f(400,"invalid_review_id",`invalid review id: ${JSON.stringify(e)}`);return e}commentPath(e){if(!/^[a-f0-9]{32}$/.test(e))throw new f(400,"invalid_comment_id",`invalid comment id: ${JSON.stringify(e)}`);return e}transport(e,t,n,s={}){const o=s.deadlineAt===void 0?void 0:s.deadlineAt-Date.now();if(o!==void 0&&o<=0)return Promise.reject(p(s.deadlineAt));const u=n===void 0?void 0:JSON.stringify(n),c={accept:"application/json",...this.headers,...s.headers};u!==void 0&&(c["content-type"]="application/json");const l=s.timeout??this.timeoutMs,m=o===void 0?l:l>0?Math.min(l,o):o,h=new AbortController,P=o!==void 0&&(l<=0||o<=l),T=m>0?setTimeout(()=>h.abort(P?p(s.deadlineAt):new DOMException("request timed out","TimeoutError")),m):void 0,E=s.signal,k=a(()=>h.abort(E?.reason),"onExternalAbort");E!==void 0&&(E.aborted?h.abort(E.reason):E.addEventListener("abort",k,{once:!0}));const C=a(()=>{T!==void 0&&clearTimeout(T),E?.removeEventListener("abort",k)},"finish");return Z(this.fetch(new URL(t,this.baseUrl),{method:e,headers:c,body:u,signal:h.signal}),h.signal).then(y=>(B(y.headers.get("server-timing")),this.retainRequestLifetime(y,C,()=>h.signal.aborted?h.signal.reason:void 0)),y=>{throw C(),y})}retainRequestLifetime(e,t,n){if(e.body===null)return t(),e;const s=e.body.getReader();let o=!1;const u=a(()=>{o||(o=!0,t())},"close"),c=new ReadableStream({async pull(l){try{const{done:m,value:h}=await s.read();m?(u(),l.close()):l.enqueue(h)}catch(m){u(),l.error(n()??m)}},async cancel(l){u(),await s.cancel(l)}});return new Response(c,{status:e.status,statusText:e.statusText,headers:e.headers})}isColdSocketError(e){const t=O(e);return t==="ECONNREFUSED"||t==="ENOENT"||t==="ENOTSOCK"}isInterruptedSocketError(e){const t=O(e);return t==="ECONNRESET"||t==="EPIPE"}async rideOutInterruptedRequest(e,t,n,s={}){try{await this.awaitAvailability(void 0,s.deadlineAt)}catch(o){throw w(o,s.signal)}if(e!=="GET"&&e!=="HEAD")throw new f(503,"daemon_request_interrupted",`crtrd connection ended before this ${e} response; the request may or may not have been applied.`);try{return await this.transport(e,t,n,s)}catch(o){throw w(o,s.signal)}}async awaitAvailability(e,t){const n=t===void 0?void 0:t-Date.now();if(n!==void 0&&n<=0)throw p(t);let s,o;try{await J({windowMs:Math.min(this.coldStartPollWindowMs,n??this.coldStartPollWindowMs),initialError:e,retry:a(u=>u!==s&&u!==o,"retry"),probe:a(async u=>{const c=this.availabilityFailure?.();if(c!==void 0)throw o=c,c;const l=this.coldStartFailure?.();if(l!==void 0)throw s=new f(503,"daemon_unavailable",`crtrd failed to start: ${l}`),s;const m=await this.transport("GET",r.healthz(),void 0,{timeout:u});if(m.status>=200&&m.status<300){await g(m);return}const h=await m.text();try{if(typeof JSON.parse(h).startup_blocked=="string")return}catch{}throw new f(m.status,"daemon_health_unavailable",`crtrd health check returned HTTP ${m.status}: ${h.slice(0,500)}`)},"probe")})}catch(u){throw u===s&&(this.startupFailureReported=!0),u}}async handleColdSocket(e,t){const n=this.autostart&&this.onColdSocket!==void 0&&!this.coldStartAttempted;n&&(this.coldStartAttempted=!0,await this.awaitWithinBudget(this.onColdSocket(),t));try{await this.awaitAvailability(e,t)}catch(s){if(n&&!this.startupFailureReported){const o=X(this.coldStartDiagnostic);if(o!==void 0){const u=w(s);throw new f(u.status,u.code,`${u.message}
3
+ ${o}`)}}throw s}}}function d(i,e){if(e===void 0)return i;const t=new URLSearchParams;for(const[s,o]of Object.entries(e))o!=null&&t.set(s,String(o));const n=t.toString();return n===""?i:`${i}?${n}`}a(d,"withQuery");async function q(i,e){const t=i.status>=200&&i.status<300,n=(await _(i,e)).trim();let s;if(n!=="")try{s=JSON.parse(n)}catch{if(t)return;throw new f(i.status,"invalid_response",n.slice(0,500),void 0,i.headers)}if(t)return s;throw x(s)?new f(i.status,s.error.code,s.error.message,s.error.details,i.headers,s.error):new f(i.status,"internal",`request failed with status ${i.status}`,void 0,i.headers)}a(q,"parse");const W=6e4;function V(i){return i==="GET"||i==="HEAD"}a(V,"isRead");async function z(i,e){try{if(Number(i.headers.get("content-length")??0)>8192)return!1;const t=await _(i.clone(),Math.min(e??1/0,Date.now()+5e3)),n=JSON.parse(t).error;return n?.origin==="router"&&n.details?.forwarded===!1&&(n.details.runtime_state==="creating"||n.details.runtime_state==="recovering")}catch{return!1}}a(z,"isRefusedBeforeForwarding");function K(i){return i===429||i>=500}a(K,"isRetryableStatus");async function g(i,e){const t=(async()=>{try{await i.body?.cancel()}catch{}})();if(e===void 0)return t;let n;try{await Promise.race([t,new Promise(s=>{n=setTimeout(s,Math.max(0,e-Date.now()))})])}finally{n!==void 0&&clearTimeout(n)}}a(g,"drainResponseBody");async function _(i,e){if(e===void 0)return i.text();const t=e-Date.now(),n=i.text();if(n.catch(()=>{}),t<=0)throw i.body?.cancel().catch(()=>{}),S(e);let s;try{return await Promise.race([n,new Promise((o,u)=>{s=setTimeout(()=>{i.body?.cancel().catch(()=>{}),u(S(e))},t)})])}finally{s!==void 0&&clearTimeout(s)}}a(_,"readTextWithin");function G(i){return Math.min(2e3,250*2**(i-1))}a(G,"retryDelayMs");function O(i){if(typeof i!="object"||i===null)return;const e=i.code;if(typeof e=="string")return e;const t=i.cause;if(typeof t=="object"&&t!==null){const n=t.code;if(typeof n=="string")return n}}a(O,"transportErrorCode");function A(i,e){return e?.aborted?!0:i instanceof DOMException&&(i.name==="AbortError"||i.name==="TimeoutError")}a(A,"isAbortError");function w(i,e){if(e?.aborted)return new f(0,"request_aborted","request aborted by caller signal");if(i instanceof f)return i;if(i instanceof DOMException&&i.name==="TimeoutError")return new f(504,"request_timeout",`crtrd request timed out: ${i.message}`);if(i instanceof DOMException&&i.name==="AbortError")return new f(0,"request_aborted","request aborted by caller signal");const t=O(i),n=i instanceof Error?i.message:String(i);return t==="ECONNREFUSED"||t==="ENOENT"||t==="ENOTSOCK"?new f(503,"daemon_unavailable",`crtrd is not reachable: ${n}`):t==="ETIMEDOUT"?new f(504,"request_timeout",`crtrd request timed out: ${n}`):new f(503,"transport_error",n)}a(w,"toTransportApiError");function Q(i,e){return i==="GET"||i==="HEAD"||e.status!==504||e.code!=="request_timeout"?e:new f(e.status,e.code,`${e.message}; the ${i} request was sent, so it may or may not have been applied`,{outcome:"unknown"},e.headers)}a(Q,"withUnknownOutcome");function M(i){const e=Number(i.headers.get("retry-after"));return Number.isFinite(e)&&e>0?e:void 0}a(M,"retryAfterHeaderS");async function R(i,e,t,n){const{deadlineAt:s,signal:o}=e;if(o?.aborted)throw new f(0,"request_aborted","request aborted by caller signal");const u=s!==void 0&&t!==void 0?t*1e3:void 0,c=Math.max(i,u??0);if(s!==void 0&&Date.now()+c>=s){const l=S(s,u!==void 0&&u>=i?"retry_after":"elapsed",u===void 0?void 0:t);throw n!==void 0&&Object.defineProperty(l,"cause",{value:n,configurable:!0,writable:!0}),l}if(o===void 0)return D(c);await new Promise((l,m)=>{const h=a(()=>{clearTimeout(P),o.removeEventListener("abort",h),m(new f(0,"request_aborted","request aborted by caller signal"))},"onAbort"),P=setTimeout(()=>{o.removeEventListener("abort",h),l()},c);o.addEventListener("abort",h,{once:!0})})}a(R,"sleepWithin");function Z(i,e){return new Promise((t,n)=>{const s=a(()=>n(e.reason),"onAbort");e.aborted?s():e.addEventListener("abort",s,{once:!0}),i.then(o=>{e.removeEventListener("abort",s),e.aborted?o.body?.cancel().catch(()=>{}):t(o)},o=>{e.removeEventListener("abort",s),n(o)})})}a(Z,"abortable");function D(i){return new Promise(e=>setTimeout(e,i))}a(D,"sleepMs");function X(i){if(i!==void 0)try{return i()}catch{return}}a(X,"safeColdStartDiagnostic");export{oe as CrtrClient,v as MAX_TIMER_MS,S as deadlineExceeded,X as safeColdStartDiagnostic,R as sleepWithin,J as waitForDaemonAvailability};
@@ -1,5 +1,5 @@
1
1
  /** The contract level this build serves and requires. Written by `scripts/contract.mjs release`; never edit by hand. */
2
- export declare const CONTRACT_LEVEL = "1.63";
2
+ export declare const CONTRACT_LEVEL = "1.64";
3
3
  /** Request header naming the one contract level the caller needs, e.g. `1.3`. Optional: absent means no check. */
4
4
  export declare const REQUIRED_CONTRACT_HEADER = "Crouter-Required-Contract";
5
5
  /** Response header listing the contract levels the server serves, comma-separated, one per major, e.g. `1.3`. */
@@ -1 +1 @@
1
- var c=Object.defineProperty;var e=(r,t)=>c(r,"name",{value:t,configurable:!0});const f="1.63",i="Crouter-Required-Contract",p="Crouter-Contract";function l(r){const t=/^(\d+)\.(\d+)$/.exec(r.trim());return t===null?null:{major:Number(t[1]),minor:Number(t[2])}}e(l,"parseContractLevel");function a(r){return r==null?[]:r.split(",").map(t=>l(t)).filter(t=>t!==null)}e(a,"parseServedContracts");function s(r,t){const n=l(r);return n===null?!1:(typeof t=="string"||t===null||t===void 0?a(t):t).some(u=>u.major===n.major&&u.minor>=n.minor)}e(s,"contractSatisfies");function C(r,t,n={}){if(r===void 0)return null;if(l(r)===null)return{status:400,code:"invalid_request",param:i,message:`${i} must be a contract level like 1.0.`};if(s(r,t))return null;const o=r.trim();return{status:426,code:"runtime_version_unsupported",message:t===null||a(t).length===0?`The runtime did not name its contract level; the caller requires contract ${o} or later. Roll the runtime forward.`:`The runtime serves contract ${t}; the caller requires contract ${o} or later within the same major. Roll the runtime forward, or pin an SDK whose crouterContract the runtime serves.`,details:{sdk_version:(n.legacyMinimum??"").trim(),runtime_version:n.runtimeVersion??null,required_contract:o,runtime_contract:t}}}e(C,"contractRefusal");export{p as CONTRACT_HEADER,f as CONTRACT_LEVEL,i as REQUIRED_CONTRACT_HEADER,C as contractRefusal,s as contractSatisfies,l as parseContractLevel,a as parseServedContracts};
1
+ var c=Object.defineProperty;var e=(r,t)=>c(r,"name",{value:t,configurable:!0});const f="1.64",i="Crouter-Required-Contract",p="Crouter-Contract";function l(r){const t=/^(\d+)\.(\d+)$/.exec(r.trim());return t===null?null:{major:Number(t[1]),minor:Number(t[2])}}e(l,"parseContractLevel");function a(r){return r==null?[]:r.split(",").map(t=>l(t)).filter(t=>t!==null)}e(a,"parseServedContracts");function s(r,t){const n=l(r);return n===null?!1:(typeof t=="string"||t===null||t===void 0?a(t):t).some(u=>u.major===n.major&&u.minor>=n.minor)}e(s,"contractSatisfies");function C(r,t,n={}){if(r===void 0)return null;if(l(r)===null)return{status:400,code:"invalid_request",param:i,message:`${i} must be a contract level like 1.0.`};if(s(r,t))return null;const o=r.trim();return{status:426,code:"runtime_version_unsupported",message:t===null||a(t).length===0?`The runtime did not name its contract level; the caller requires contract ${o} or later. Roll the runtime forward.`:`The runtime serves contract ${t}; the caller requires contract ${o} or later within the same major. Roll the runtime forward, or pin an SDK whose crouterContract the runtime serves.`,details:{sdk_version:(n.legacyMinimum??"").trim(),runtime_version:n.runtimeVersion??null,required_contract:o,runtime_contract:t}}}e(C,"contractRefusal");export{p as CONTRACT_HEADER,f as CONTRACT_LEVEL,i as REQUIRED_CONTRACT_HEADER,C as contractRefusal,s as contractSatisfies,l as parseContractLevel,a as parseServedContracts};
@@ -291,6 +291,12 @@ export interface RosterObjectWaitDTO {
291
291
  object_name: string;
292
292
  created: IsoTime;
293
293
  }
294
+ /** `GET /v1/canvas/view/:id` result — what one attach viewer draws from: the tree that contains node `:id` (its top manager,
295
+ * everything below it, their edges and object waits) and the pending-ticket count of each of those nodes. Only nodes the
296
+ * caller may read appear. */
297
+ export interface PanelViewDTO extends RosterDTO {
298
+ counts: Record<NodeIdDTO, number>;
299
+ }
294
300
  /** Browse's initial frame needs the dashboard fields and topology, not the full
295
301
  * node detail/list projection. Transported as gzip JSON (application/gzip) over
296
302
  * the local socket; other /v1/nodes consumers keep their original response. */
@@ -117,6 +117,7 @@ export declare const routes: {
117
117
  readonly canvasSnapshot: () => string;
118
118
  readonly canvasLiveRoots: () => string;
119
119
  readonly canvasRoster: () => string;
120
+ readonly canvasView: (id: string) => string;
120
121
  readonly canvasBrowse: () => string;
121
122
  readonly canvasAnalytics: () => string;
122
123
  readonly canvasGraph: () => string;
@@ -1 +1 @@
1
- var s=Object.defineProperty;var o=(e,n)=>s(e,"name",{value:n,configurable:!0});const $="v1",r="/v1",a={healthz:o(()=>"/healthz","healthz"),ready:o(()=>"/v1/ready","ready"),status:o(()=>"/v1/status","status"),due:o(()=>"/v1/due","due"),daemonRestart:o(()=>"/v1/daemon/restart","daemonRestart"),daemonMigrate:o(()=>"/v1/daemon/migrate","daemonMigrate"),daemonDrain:o(()=>"/v1/daemon/drain","daemonDrain"),daemonAdmit:o(()=>"/v1/daemon/admit","daemonAdmit"),nodes:o(()=>"/v1/nodes","nodes"),reviveAll:o(()=>"/v1/nodes/revive-all","reviveAll"),node:o(e=>`/v1/nodes/${e}`,"node"),nodeMemoryReads:o(e=>`/v1/nodes/${e}/memory-reads`,"nodeMemoryReads"),executionStart:o(e=>`/v1/executions/${e}/start`,"executionStart"),executionImportUnpacked:o(e=>`/v1/executions/${e}/import-unpacked`,"executionImportUnpacked"),environmentGitCredential:o(e=>`/v1/environments/${e}/git-credential`,"environmentGitCredential"),nodeOutcome:o(e=>`/v1/nodes/${e}/outcome`,"nodeOutcome"),nodeOutcomeDelivery:o(e=>`/v1/nodes/${e}/outcome-delivery`,"nodeOutcomeDelivery"),nodeEvents:o(e=>`/v1/nodes/${e}/events`,"nodeEvents"),nodeSnapshot:o(e=>`/v1/nodes/${e}/snapshot`,"nodeSnapshot"),nodeSubject:o(e=>`/v1/nodes/${e}/subject`,"nodeSubject"),nodeSession:o(e=>`/v1/nodes/${e}/session`,"nodeSession"),nodeChatInventory:o(e=>`/v1/nodes/${e}/chat-inventory`,"nodeChatInventory"),prospectiveChatInventory:o(()=>"/v1/prospective-chat-inventory","prospectiveChatInventory"),nodeTranscript:o(e=>`/v1/nodes/${e}/transcript`,"nodeTranscript"),nodeContext:o(e=>`/v1/nodes/${e}/context`,"nodeContext"),nodeReports:o(e=>`/v1/nodes/${e}/reports`,"nodeReports"),nodeResult:o(e=>`/v1/nodes/${e}/result`,"nodeResult"),nodeFiles:o(e=>`/v1/nodes/${e}/files`,"nodeFiles"),nodeFileComplete:o((e,n)=>`/v1/nodes/${e}/files/${encodeURIComponent(n)}/complete`,"nodeFileComplete"),nodeUploads:o(e=>`/v1/nodes/${e}/uploads`,"nodeUploads"),nodeUploadLink:o((e,n)=>`/v1/nodes/${e}/uploads/${encodeURIComponent(n)}/link`,"nodeUploadLink"),nodeJobs:o(e=>`/v1/nodes/${e}/jobs`,"nodeJobs"),nodeJob:o((e,n)=>`/v1/nodes/${e}/jobs/${n}`,"nodeJob"),nodeJobReport:o((e,n)=>`/v1/nodes/${e}/jobs/${n}/report`,"nodeJobReport"),nodeJobOutput:o((e,n)=>`/v1/nodes/${e}/jobs/${n}/output`,"nodeJobOutput"),nodeJobBackground:o((e,n)=>`/v1/nodes/${e}/jobs/${n}/background`,"nodeJobBackground"),nodeDelivery:o(e=>`/v1/nodes/${e}/delivery`,"nodeDelivery"),deliveryDryRun:o(()=>"/v1/delivery/dry-run","deliveryDryRun"),deliveryRetry:o(e=>`/v1/deliveries/${encodeURIComponent(e)}/retry`,"deliveryRetry"),nodeMessages:o(e=>`/v1/nodes/${e}/messages`,"nodeMessages"),nodeInterrupt:o(e=>`/v1/nodes/${e}/interrupt`,"nodeInterrupt"),nodeFork:o(e=>`/v1/nodes/${e}/fork`,"nodeFork"),nodeRevive:o(e=>`/v1/nodes/${e}/revive`,"nodeRevive"),nodeRelaunchRoot:o(e=>`/v1/nodes/${e}/relaunch-root`,"nodeRelaunchRoot"),nodeBrokerSessionBound:o(e=>`/v1/nodes/${e}/broker/session-bound`,"nodeBrokerSessionBound"),nodeBrokerCycleStart:o(e=>`/v1/nodes/${e}/broker/cycle-start`,"nodeBrokerCycleStart"),nodeBrokerSettle:o(e=>`/v1/nodes/${e}/broker/settle`,"nodeBrokerSettle"),nodeBrokerCycle:o(e=>`/v1/nodes/${e}/broker/cycle`,"nodeBrokerCycle"),nodeBrokerIdle:o(e=>`/v1/nodes/${e}/broker/idle`,"nodeBrokerIdle"),nodeBrokerParkComplete:o(e=>`/v1/nodes/${e}/broker/park-complete`,"nodeBrokerParkComplete"),nodeBrokerParkActivity:o(e=>`/v1/nodes/${e}/broker/park-activity`,"nodeBrokerParkActivity"),nodeBrokerTelemetry:o(e=>`/v1/nodes/${e}/broker/telemetry`,"nodeBrokerTelemetry"),nodeLog:o(e=>`/v1/nodes/${e}/records/log`,"nodeLog"),nodeSummaries:o(e=>`/v1/nodes/${e}/records/summaries`,"nodeSummaries"),nodeAttachments:o(e=>`/v1/nodes/${e}/attachments`,"nodeAttachments"),nodeAttachment:o((e,n)=>`/v1/nodes/${e}/attachments/${n}`,"nodeAttachment"),nodeTelemetry:o(e=>`/v1/nodes/${e}/records/telemetry`,"nodeTelemetry"),nodeRecap:o(e=>`/v1/nodes/${e}/records/recap`,"nodeRecap"),nodeInboxReport:o(e=>`/v1/nodes/${e}/records/inbox`,"nodeInboxReport"),nodePassiveMessage:o(e=>`/v1/nodes/${e}/records/passive`,"nodePassiveMessage"),nodePushedFinal:o(e=>`/v1/nodes/${e}/records/pushed-final`,"nodePushedFinal"),nodeMailClaim:o(e=>`/v1/nodes/${e}/mail/claim`,"nodeMailClaim"),nodeMailAcknowledge:o(e=>`/v1/nodes/${e}/mail/acknowledge`,"nodeMailAcknowledge"),nodeBrokerModel:o(e=>`/v1/nodes/${e}/broker/model`,"nodeBrokerModel"),nodeBrokerExtensionState:o(e=>`/v1/nodes/${e}/broker/extension-state`,"nodeBrokerExtensionState"),nodeBrokerSignals:o(e=>`/v1/nodes/${e}/broker/signals`,"nodeBrokerSignals"),nodeBrokerStructuredRequest:o(e=>`/v1/nodes/${e}/broker/structured-request`,"nodeBrokerStructuredRequest"),nodeBrokerGoal:o(e=>`/v1/nodes/${e}/broker/goal`,"nodeBrokerGoal"),nodeBrokerGeneratedName:o(e=>`/v1/nodes/${e}/broker/generated-name`,"nodeBrokerGeneratedName"),nodeBrokerPersonaAck:o(e=>`/v1/nodes/${e}/broker/persona-ack`,"nodeBrokerPersonaAck"),brokerTurn:o(e=>`/v1/broker/${e}/turn`,"brokerTurn"),brokerProviderRetry:o(e=>`/v1/broker/${e}/provider-retry`,"brokerProviderRetry"),brokerFault:o(e=>`/v1/broker/${e}/fault`,"brokerFault"),brokerRecovery:o(e=>`/v1/broker/${e}/recovery`,"brokerRecovery"),nodeFault:o(e=>`/v1/nodes/${e}/fault`,"nodeFault"),nodeClose:o(e=>`/v1/nodes/${e}/close`,"nodeClose"),nodeRead:o(e=>`/v1/nodes/${e}/read`,"nodeRead"),nodeRecycle:o(e=>`/v1/nodes/${e}/recycle`,"nodeRecycle"),nodeDemote:o(e=>`/v1/nodes/${e}/demote`,"nodeDemote"),nodePromote:o(e=>`/v1/nodes/${e}/promote`,"nodePromote"),nodeYield:o(e=>`/v1/nodes/${e}/yield`,"nodeYield"),nodeWait:o(e=>`/v1/nodes/${e}/wait`,"nodeWait"),nodeConfig:o(e=>`/v1/nodes/${e}/config`,"nodeConfig"),kinds:o(()=>"/v1/kinds","kinds"),nodeWorktreeClose:o(e=>`/v1/nodes/${e}/worktree/close`,"nodeWorktreeClose"),nodeWorktreeAbandon:o(e=>`/v1/nodes/${e}/worktree/abandon`,"nodeWorktreeAbandon"),quarantinedWorktrees:o(()=>"/v1/worktrees/quarantined","quarantinedWorktrees"),spaces:o(()=>"/v1/spaces","spaces"),limits:o(()=>"/v1/limits","limits"),limitsApp:o(e=>`/v1/limits/apps/${encodeURIComponent(e)}`,"limitsApp"),charges:o(()=>"/v1/charges","charges"),spendLimits:o(()=>"/v1/spend-limits","spendLimits"),spendLimit:o(e=>`/v1/spend-limits/${encodeURIComponent(e)}`,"spendLimit"),nodeAttach:o(e=>`/v1/nodes/${e}/attach`,"nodeAttach"),focuses:o(()=>"/v1/focuses","focuses"),focusByNode:o(()=>"/v1/focuses/by-node","focusByNode"),focusByPane:o(()=>"/v1/focuses/by-pane","focusByPane"),focus:o(e=>`/v1/focuses/${e}`,"focus"),nodeSubscriptions:o(e=>`/v1/nodes/${e}/subscriptions`,"nodeSubscriptions"),nodeSubscription:o((e,n)=>`/v1/nodes/${e}/subscriptions/${n}`,"nodeSubscription"),crons:o(()=>"/v1/crons","crons"),cron:o(e=>`/v1/crons/${e}`,"cron"),cronPause:o(e=>`/v1/crons/${e}/pause`,"cronPause"),cronResume:o(e=>`/v1/crons/${e}/resume`,"cronResume"),cronRun:o(e=>`/v1/crons/${e}/run`,"cronRun"),cronsPoke:o(()=>"/v1/crons/poke","cronsPoke"),canvasAttention:o(()=>"/v1/canvas/attention","canvasAttention"),canvasAttentionCounts:o(()=>"/v1/canvas/attention/counts","canvasAttentionCounts"),canvasHistorySearch:o(()=>"/v1/canvas/history/search","canvasHistorySearch"),canvasHistoryGrep:o(()=>"/v1/canvas/history/grep","canvasHistoryGrep"),canvasHistoryRead:o(()=>"/v1/canvas/history/read","canvasHistoryRead"),canvasHistoryStats:o(()=>"/v1/canvas/history/stats","canvasHistoryStats"),canvasSnapshot:o(()=>"/v1/canvas/snapshot","canvasSnapshot"),canvasLiveRoots:o(()=>"/v1/canvas/live-roots","canvasLiveRoots"),canvasRoster:o(()=>"/v1/canvas/roster","canvasRoster"),canvasBrowse:o(()=>"/v1/canvas/browse","canvasBrowse"),canvasAnalytics:o(()=>"/v1/canvas/analytics","canvasAnalytics"),canvasGraph:o(()=>"/v1/canvas/graph","canvasGraph"),canvasPrune:o(()=>"/v1/canvas/prune","canvasPrune"),humanReviews:o(()=>"/v1/human/reviews","humanReviews"),humanReview:o(e=>`/v1/human/reviews/${e}`,"humanReview"),humanReviewSubmit:o(e=>`/v1/human/reviews/${e}/submit`,"humanReviewSubmit"),humanReviewCancel:o(e=>`/v1/human/reviews/${e}/cancel`,"humanReviewCancel"),humanReviewDocument:o(e=>`/v1/human/reviews/${e}/document`,"humanReviewDocument"),humanReviewComments:o(e=>`/v1/human/reviews/${e}/comments`,"humanReviewComments"),humanReviewCommentEvents:o(e=>`/v1/human/reviews/${e}/comment-events`,"humanReviewCommentEvents"),humanReviewCommentRanges:o(e=>`/v1/human/reviews/${e}/comment-ranges`,"humanReviewCommentRanges"),humanComment:o(e=>`/v1/human/comments/${e}`,"humanComment"),humanCommentEdit:o(e=>`/v1/human/comments/${e}/edit`,"humanCommentEdit"),humanCommentResolve:o(e=>`/v1/human/comments/${e}/resolve`,"humanCommentResolve"),humanCommentReopen:o(e=>`/v1/human/comments/${e}/reopen`,"humanCommentReopen"),humanCommentDelete:o(e=>`/v1/human/comments/${e}/delete`,"humanCommentDelete"),humanCommentFork:o(e=>`/v1/human/comments/${e}/fork`,"humanCommentFork"),humanInbox:o(()=>"/v1/human/inbox","humanInbox"),humanInboxTicket:o(e=>`/v1/human/inbox/${e}`,"humanInboxTicket"),humanInboxRespond:o(e=>`/v1/human/inbox/${e}/respond`,"humanInboxRespond"),humanInboxProgress:o(e=>`/v1/human/inbox/${e}/progress`,"humanInboxProgress"),humanInboxResponse:o(e=>`/v1/human/inbox/${e}/response`,"humanInboxResponse"),humanInboxCancel:o(e=>`/v1/human/inbox/${e}/cancel`,"humanInboxCancel"),humanInboxFeedbackResolve:o((e,n)=>`/v1/human/inbox/${e}/feedback-comments/${n}/resolve`,"humanInboxFeedbackResolve"),humanRequests:o(()=>"/v1/human/requests","humanRequests"),humanComponents:o(()=>"/v1/human/components","humanComponents"),humanRequest:o(e=>`/v1/human/requests/${e}`,"humanRequest"),humanRequestReplace:o(e=>`/v1/human/requests/${e}/replace`,"humanRequestReplace"),humanRequestRespond:o(e=>`/v1/human/requests/${e}/respond`,"humanRequestRespond"),humanRequestDismiss:o(e=>`/v1/human/requests/${e}/dismiss`,"humanRequestDismiss"),humanRequestCancel:o(e=>`/v1/human/requests/${e}/cancel`,"humanRequestCancel"),profiles:o(()=>"/v1/profiles","profiles"),profile:o(e=>`/v1/profiles/${e}`,"profile"),profilePause:o(e=>`/v1/profiles/${e}/pause`,"profilePause"),profileResume:o(e=>`/v1/profiles/${e}/resume`,"profileResume"),profileMetadata:o(e=>`/v1/profiles/${e}/metadata`,"profileMetadata"),appEnv:o(()=>"/v1/apps/self/env","appEnv"),appEnvVar:o(e=>`/v1/apps/self/env/${encodeURIComponent(e)}`,"appEnvVar"),profileEnv:o(e=>`/v1/profiles/${e}/env`,"profileEnv"),profileEnvVar:o((e,n)=>`/v1/profiles/${e}/env/${n}`,"profileEnvVar"),profileEnvironment:o(e=>`/v1/profiles/${e}/environment`,"profileEnvironment"),settings:o(()=>"/v1/settings","settings"),modelAuths:o(()=>"/v1/model-auth","modelAuths"),modelAuthReadiness:o(()=>"/v1/model-auth/readiness","modelAuthReadiness"),modelAuth:o(e=>`/v1/model-auth/${e}`,"modelAuth"),modelAuthAccount:o((e,n)=>`/v1/model-auth/${e}/accounts/${encodeURIComponent(n)}`,"modelAuthAccount"),modelAuthFlows:o(()=>"/v1/model-auth/flows","modelAuthFlows"),modelAuthFlow:o(e=>`/v1/model-auth/flows/${encodeURIComponent(e)}`,"modelAuthFlow"),modelAuthFlowComplete:o(e=>`/v1/model-auth/flows/${encodeURIComponent(e)}/complete`,"modelAuthFlowComplete"),modelAuthFlowCancel:o(e=>`/v1/model-auth/flows/${encodeURIComponent(e)}/cancel`,"modelAuthFlowCancel"),filePeek:o(()=>"/v1/files/peek","filePeek"),fileWrite:o(()=>"/v1/files/write","fileWrite"),fileList:o(()=>"/v1/files/list","fileList"),bash:o(()=>"/v1/bash","bash"),exec:o(()=>"/v1/exec","exec"),objects:o(()=>"/v1/objects","objects"),object:o(e=>`/v1/objects/${encodeURIComponent(e)}`,"object"),objectsSearch:o(()=>"/v1/objects/search","objectsSearch"),objectWatch:o(e=>`/v1/objects/${encodeURIComponent(e)}/watch`,"objectWatch"),customObjects:o(()=>"/v1/custom-objects","customObjects"),customObject:o(e=>`/v1/custom-objects/${encodeURIComponent(e)}`,"customObject"),customObjectEvents:o(e=>`/v1/custom-objects/${encodeURIComponent(e)}/events`,"customObjectEvents"),customObjectDeliveries:o(e=>`/v1/custom-objects/${encodeURIComponent(e)}/deliveries`,"customObjectDeliveries"),customObjectAck:o(e=>`/v1/custom-objects/${encodeURIComponent(e)}/deliveries/ack`,"customObjectAck"),objectShares:o(e=>`/v1/objects/${encodeURIComponent(e)}/shares`,"objectShares"),objectEdges:o(e=>`/v1/objects/${encodeURIComponent(e)}/edges`,"objectEdges"),docs:o(()=>"/v1/docs","docs"),doc:o(e=>`/v1/docs/${encodeURIComponent(e)}`,"doc"),docMove:o(e=>`/v1/docs/${encodeURIComponent(e)}/move`,"docMove"),docHistory:o(e=>`/v1/docs/${encodeURIComponent(e)}/history`,"docHistory"),docsLint:o(()=>"/v1/docs/lint","docsLint"),schemas:o(()=>"/v1/schemas","schemas"),relations:o(()=>"/v1/relations","relations"),check:o(()=>"/v1/check","check"),pluginAppToken:o(e=>`/v1/plugins/${encodeURIComponent(e)}/app-token`,"pluginAppToken"),pluginCallHeaders:o(e=>`/v1/plugins/${encodeURIComponent(e)}/call-headers`,"pluginCallHeaders"),documentsBrowserAccess:o(()=>"/v1/documents/browser-access","documentsBrowserAccess"),documentsReconcilePackages:o(()=>"/v1/documents/reconcile-packages","documentsReconcilePackages")};export{$ as API_VERSION,a as routes};
1
+ var s=Object.defineProperty;var o=(e,n)=>s(e,"name",{value:n,configurable:!0});const $="v1",r="/v1",a={healthz:o(()=>"/healthz","healthz"),ready:o(()=>"/v1/ready","ready"),status:o(()=>"/v1/status","status"),due:o(()=>"/v1/due","due"),daemonRestart:o(()=>"/v1/daemon/restart","daemonRestart"),daemonMigrate:o(()=>"/v1/daemon/migrate","daemonMigrate"),daemonDrain:o(()=>"/v1/daemon/drain","daemonDrain"),daemonAdmit:o(()=>"/v1/daemon/admit","daemonAdmit"),nodes:o(()=>"/v1/nodes","nodes"),reviveAll:o(()=>"/v1/nodes/revive-all","reviveAll"),node:o(e=>`/v1/nodes/${e}`,"node"),nodeMemoryReads:o(e=>`/v1/nodes/${e}/memory-reads`,"nodeMemoryReads"),executionStart:o(e=>`/v1/executions/${e}/start`,"executionStart"),executionImportUnpacked:o(e=>`/v1/executions/${e}/import-unpacked`,"executionImportUnpacked"),environmentGitCredential:o(e=>`/v1/environments/${e}/git-credential`,"environmentGitCredential"),nodeOutcome:o(e=>`/v1/nodes/${e}/outcome`,"nodeOutcome"),nodeOutcomeDelivery:o(e=>`/v1/nodes/${e}/outcome-delivery`,"nodeOutcomeDelivery"),nodeEvents:o(e=>`/v1/nodes/${e}/events`,"nodeEvents"),nodeSnapshot:o(e=>`/v1/nodes/${e}/snapshot`,"nodeSnapshot"),nodeSubject:o(e=>`/v1/nodes/${e}/subject`,"nodeSubject"),nodeSession:o(e=>`/v1/nodes/${e}/session`,"nodeSession"),nodeChatInventory:o(e=>`/v1/nodes/${e}/chat-inventory`,"nodeChatInventory"),prospectiveChatInventory:o(()=>"/v1/prospective-chat-inventory","prospectiveChatInventory"),nodeTranscript:o(e=>`/v1/nodes/${e}/transcript`,"nodeTranscript"),nodeContext:o(e=>`/v1/nodes/${e}/context`,"nodeContext"),nodeReports:o(e=>`/v1/nodes/${e}/reports`,"nodeReports"),nodeResult:o(e=>`/v1/nodes/${e}/result`,"nodeResult"),nodeFiles:o(e=>`/v1/nodes/${e}/files`,"nodeFiles"),nodeFileComplete:o((e,n)=>`/v1/nodes/${e}/files/${encodeURIComponent(n)}/complete`,"nodeFileComplete"),nodeUploads:o(e=>`/v1/nodes/${e}/uploads`,"nodeUploads"),nodeUploadLink:o((e,n)=>`/v1/nodes/${e}/uploads/${encodeURIComponent(n)}/link`,"nodeUploadLink"),nodeJobs:o(e=>`/v1/nodes/${e}/jobs`,"nodeJobs"),nodeJob:o((e,n)=>`/v1/nodes/${e}/jobs/${n}`,"nodeJob"),nodeJobReport:o((e,n)=>`/v1/nodes/${e}/jobs/${n}/report`,"nodeJobReport"),nodeJobOutput:o((e,n)=>`/v1/nodes/${e}/jobs/${n}/output`,"nodeJobOutput"),nodeJobBackground:o((e,n)=>`/v1/nodes/${e}/jobs/${n}/background`,"nodeJobBackground"),nodeDelivery:o(e=>`/v1/nodes/${e}/delivery`,"nodeDelivery"),deliveryDryRun:o(()=>"/v1/delivery/dry-run","deliveryDryRun"),deliveryRetry:o(e=>`/v1/deliveries/${encodeURIComponent(e)}/retry`,"deliveryRetry"),nodeMessages:o(e=>`/v1/nodes/${e}/messages`,"nodeMessages"),nodeInterrupt:o(e=>`/v1/nodes/${e}/interrupt`,"nodeInterrupt"),nodeFork:o(e=>`/v1/nodes/${e}/fork`,"nodeFork"),nodeRevive:o(e=>`/v1/nodes/${e}/revive`,"nodeRevive"),nodeRelaunchRoot:o(e=>`/v1/nodes/${e}/relaunch-root`,"nodeRelaunchRoot"),nodeBrokerSessionBound:o(e=>`/v1/nodes/${e}/broker/session-bound`,"nodeBrokerSessionBound"),nodeBrokerCycleStart:o(e=>`/v1/nodes/${e}/broker/cycle-start`,"nodeBrokerCycleStart"),nodeBrokerSettle:o(e=>`/v1/nodes/${e}/broker/settle`,"nodeBrokerSettle"),nodeBrokerCycle:o(e=>`/v1/nodes/${e}/broker/cycle`,"nodeBrokerCycle"),nodeBrokerIdle:o(e=>`/v1/nodes/${e}/broker/idle`,"nodeBrokerIdle"),nodeBrokerParkComplete:o(e=>`/v1/nodes/${e}/broker/park-complete`,"nodeBrokerParkComplete"),nodeBrokerParkActivity:o(e=>`/v1/nodes/${e}/broker/park-activity`,"nodeBrokerParkActivity"),nodeBrokerTelemetry:o(e=>`/v1/nodes/${e}/broker/telemetry`,"nodeBrokerTelemetry"),nodeLog:o(e=>`/v1/nodes/${e}/records/log`,"nodeLog"),nodeSummaries:o(e=>`/v1/nodes/${e}/records/summaries`,"nodeSummaries"),nodeAttachments:o(e=>`/v1/nodes/${e}/attachments`,"nodeAttachments"),nodeAttachment:o((e,n)=>`/v1/nodes/${e}/attachments/${n}`,"nodeAttachment"),nodeTelemetry:o(e=>`/v1/nodes/${e}/records/telemetry`,"nodeTelemetry"),nodeRecap:o(e=>`/v1/nodes/${e}/records/recap`,"nodeRecap"),nodeInboxReport:o(e=>`/v1/nodes/${e}/records/inbox`,"nodeInboxReport"),nodePassiveMessage:o(e=>`/v1/nodes/${e}/records/passive`,"nodePassiveMessage"),nodePushedFinal:o(e=>`/v1/nodes/${e}/records/pushed-final`,"nodePushedFinal"),nodeMailClaim:o(e=>`/v1/nodes/${e}/mail/claim`,"nodeMailClaim"),nodeMailAcknowledge:o(e=>`/v1/nodes/${e}/mail/acknowledge`,"nodeMailAcknowledge"),nodeBrokerModel:o(e=>`/v1/nodes/${e}/broker/model`,"nodeBrokerModel"),nodeBrokerExtensionState:o(e=>`/v1/nodes/${e}/broker/extension-state`,"nodeBrokerExtensionState"),nodeBrokerSignals:o(e=>`/v1/nodes/${e}/broker/signals`,"nodeBrokerSignals"),nodeBrokerStructuredRequest:o(e=>`/v1/nodes/${e}/broker/structured-request`,"nodeBrokerStructuredRequest"),nodeBrokerGoal:o(e=>`/v1/nodes/${e}/broker/goal`,"nodeBrokerGoal"),nodeBrokerGeneratedName:o(e=>`/v1/nodes/${e}/broker/generated-name`,"nodeBrokerGeneratedName"),nodeBrokerPersonaAck:o(e=>`/v1/nodes/${e}/broker/persona-ack`,"nodeBrokerPersonaAck"),brokerTurn:o(e=>`/v1/broker/${e}/turn`,"brokerTurn"),brokerProviderRetry:o(e=>`/v1/broker/${e}/provider-retry`,"brokerProviderRetry"),brokerFault:o(e=>`/v1/broker/${e}/fault`,"brokerFault"),brokerRecovery:o(e=>`/v1/broker/${e}/recovery`,"brokerRecovery"),nodeFault:o(e=>`/v1/nodes/${e}/fault`,"nodeFault"),nodeClose:o(e=>`/v1/nodes/${e}/close`,"nodeClose"),nodeRead:o(e=>`/v1/nodes/${e}/read`,"nodeRead"),nodeRecycle:o(e=>`/v1/nodes/${e}/recycle`,"nodeRecycle"),nodeDemote:o(e=>`/v1/nodes/${e}/demote`,"nodeDemote"),nodePromote:o(e=>`/v1/nodes/${e}/promote`,"nodePromote"),nodeYield:o(e=>`/v1/nodes/${e}/yield`,"nodeYield"),nodeWait:o(e=>`/v1/nodes/${e}/wait`,"nodeWait"),nodeConfig:o(e=>`/v1/nodes/${e}/config`,"nodeConfig"),kinds:o(()=>"/v1/kinds","kinds"),nodeWorktreeClose:o(e=>`/v1/nodes/${e}/worktree/close`,"nodeWorktreeClose"),nodeWorktreeAbandon:o(e=>`/v1/nodes/${e}/worktree/abandon`,"nodeWorktreeAbandon"),quarantinedWorktrees:o(()=>"/v1/worktrees/quarantined","quarantinedWorktrees"),spaces:o(()=>"/v1/spaces","spaces"),limits:o(()=>"/v1/limits","limits"),limitsApp:o(e=>`/v1/limits/apps/${encodeURIComponent(e)}`,"limitsApp"),charges:o(()=>"/v1/charges","charges"),spendLimits:o(()=>"/v1/spend-limits","spendLimits"),spendLimit:o(e=>`/v1/spend-limits/${encodeURIComponent(e)}`,"spendLimit"),nodeAttach:o(e=>`/v1/nodes/${e}/attach`,"nodeAttach"),focuses:o(()=>"/v1/focuses","focuses"),focusByNode:o(()=>"/v1/focuses/by-node","focusByNode"),focusByPane:o(()=>"/v1/focuses/by-pane","focusByPane"),focus:o(e=>`/v1/focuses/${e}`,"focus"),nodeSubscriptions:o(e=>`/v1/nodes/${e}/subscriptions`,"nodeSubscriptions"),nodeSubscription:o((e,n)=>`/v1/nodes/${e}/subscriptions/${n}`,"nodeSubscription"),crons:o(()=>"/v1/crons","crons"),cron:o(e=>`/v1/crons/${e}`,"cron"),cronPause:o(e=>`/v1/crons/${e}/pause`,"cronPause"),cronResume:o(e=>`/v1/crons/${e}/resume`,"cronResume"),cronRun:o(e=>`/v1/crons/${e}/run`,"cronRun"),cronsPoke:o(()=>"/v1/crons/poke","cronsPoke"),canvasAttention:o(()=>"/v1/canvas/attention","canvasAttention"),canvasAttentionCounts:o(()=>"/v1/canvas/attention/counts","canvasAttentionCounts"),canvasHistorySearch:o(()=>"/v1/canvas/history/search","canvasHistorySearch"),canvasHistoryGrep:o(()=>"/v1/canvas/history/grep","canvasHistoryGrep"),canvasHistoryRead:o(()=>"/v1/canvas/history/read","canvasHistoryRead"),canvasHistoryStats:o(()=>"/v1/canvas/history/stats","canvasHistoryStats"),canvasSnapshot:o(()=>"/v1/canvas/snapshot","canvasSnapshot"),canvasLiveRoots:o(()=>"/v1/canvas/live-roots","canvasLiveRoots"),canvasRoster:o(()=>"/v1/canvas/roster","canvasRoster"),canvasView:o(e=>`/v1/canvas/view/${encodeURIComponent(e)}`,"canvasView"),canvasBrowse:o(()=>"/v1/canvas/browse","canvasBrowse"),canvasAnalytics:o(()=>"/v1/canvas/analytics","canvasAnalytics"),canvasGraph:o(()=>"/v1/canvas/graph","canvasGraph"),canvasPrune:o(()=>"/v1/canvas/prune","canvasPrune"),humanReviews:o(()=>"/v1/human/reviews","humanReviews"),humanReview:o(e=>`/v1/human/reviews/${e}`,"humanReview"),humanReviewSubmit:o(e=>`/v1/human/reviews/${e}/submit`,"humanReviewSubmit"),humanReviewCancel:o(e=>`/v1/human/reviews/${e}/cancel`,"humanReviewCancel"),humanReviewDocument:o(e=>`/v1/human/reviews/${e}/document`,"humanReviewDocument"),humanReviewComments:o(e=>`/v1/human/reviews/${e}/comments`,"humanReviewComments"),humanReviewCommentEvents:o(e=>`/v1/human/reviews/${e}/comment-events`,"humanReviewCommentEvents"),humanReviewCommentRanges:o(e=>`/v1/human/reviews/${e}/comment-ranges`,"humanReviewCommentRanges"),humanComment:o(e=>`/v1/human/comments/${e}`,"humanComment"),humanCommentEdit:o(e=>`/v1/human/comments/${e}/edit`,"humanCommentEdit"),humanCommentResolve:o(e=>`/v1/human/comments/${e}/resolve`,"humanCommentResolve"),humanCommentReopen:o(e=>`/v1/human/comments/${e}/reopen`,"humanCommentReopen"),humanCommentDelete:o(e=>`/v1/human/comments/${e}/delete`,"humanCommentDelete"),humanCommentFork:o(e=>`/v1/human/comments/${e}/fork`,"humanCommentFork"),humanInbox:o(()=>"/v1/human/inbox","humanInbox"),humanInboxTicket:o(e=>`/v1/human/inbox/${e}`,"humanInboxTicket"),humanInboxRespond:o(e=>`/v1/human/inbox/${e}/respond`,"humanInboxRespond"),humanInboxProgress:o(e=>`/v1/human/inbox/${e}/progress`,"humanInboxProgress"),humanInboxResponse:o(e=>`/v1/human/inbox/${e}/response`,"humanInboxResponse"),humanInboxCancel:o(e=>`/v1/human/inbox/${e}/cancel`,"humanInboxCancel"),humanInboxFeedbackResolve:o((e,n)=>`/v1/human/inbox/${e}/feedback-comments/${n}/resolve`,"humanInboxFeedbackResolve"),humanRequests:o(()=>"/v1/human/requests","humanRequests"),humanComponents:o(()=>"/v1/human/components","humanComponents"),humanRequest:o(e=>`/v1/human/requests/${e}`,"humanRequest"),humanRequestReplace:o(e=>`/v1/human/requests/${e}/replace`,"humanRequestReplace"),humanRequestRespond:o(e=>`/v1/human/requests/${e}/respond`,"humanRequestRespond"),humanRequestDismiss:o(e=>`/v1/human/requests/${e}/dismiss`,"humanRequestDismiss"),humanRequestCancel:o(e=>`/v1/human/requests/${e}/cancel`,"humanRequestCancel"),profiles:o(()=>"/v1/profiles","profiles"),profile:o(e=>`/v1/profiles/${e}`,"profile"),profilePause:o(e=>`/v1/profiles/${e}/pause`,"profilePause"),profileResume:o(e=>`/v1/profiles/${e}/resume`,"profileResume"),profileMetadata:o(e=>`/v1/profiles/${e}/metadata`,"profileMetadata"),appEnv:o(()=>"/v1/apps/self/env","appEnv"),appEnvVar:o(e=>`/v1/apps/self/env/${encodeURIComponent(e)}`,"appEnvVar"),profileEnv:o(e=>`/v1/profiles/${e}/env`,"profileEnv"),profileEnvVar:o((e,n)=>`/v1/profiles/${e}/env/${n}`,"profileEnvVar"),profileEnvironment:o(e=>`/v1/profiles/${e}/environment`,"profileEnvironment"),settings:o(()=>"/v1/settings","settings"),modelAuths:o(()=>"/v1/model-auth","modelAuths"),modelAuthReadiness:o(()=>"/v1/model-auth/readiness","modelAuthReadiness"),modelAuth:o(e=>`/v1/model-auth/${e}`,"modelAuth"),modelAuthAccount:o((e,n)=>`/v1/model-auth/${e}/accounts/${encodeURIComponent(n)}`,"modelAuthAccount"),modelAuthFlows:o(()=>"/v1/model-auth/flows","modelAuthFlows"),modelAuthFlow:o(e=>`/v1/model-auth/flows/${encodeURIComponent(e)}`,"modelAuthFlow"),modelAuthFlowComplete:o(e=>`/v1/model-auth/flows/${encodeURIComponent(e)}/complete`,"modelAuthFlowComplete"),modelAuthFlowCancel:o(e=>`/v1/model-auth/flows/${encodeURIComponent(e)}/cancel`,"modelAuthFlowCancel"),filePeek:o(()=>"/v1/files/peek","filePeek"),fileWrite:o(()=>"/v1/files/write","fileWrite"),fileList:o(()=>"/v1/files/list","fileList"),bash:o(()=>"/v1/bash","bash"),exec:o(()=>"/v1/exec","exec"),objects:o(()=>"/v1/objects","objects"),object:o(e=>`/v1/objects/${encodeURIComponent(e)}`,"object"),objectsSearch:o(()=>"/v1/objects/search","objectsSearch"),objectWatch:o(e=>`/v1/objects/${encodeURIComponent(e)}/watch`,"objectWatch"),customObjects:o(()=>"/v1/custom-objects","customObjects"),customObject:o(e=>`/v1/custom-objects/${encodeURIComponent(e)}`,"customObject"),customObjectEvents:o(e=>`/v1/custom-objects/${encodeURIComponent(e)}/events`,"customObjectEvents"),customObjectDeliveries:o(e=>`/v1/custom-objects/${encodeURIComponent(e)}/deliveries`,"customObjectDeliveries"),customObjectAck:o(e=>`/v1/custom-objects/${encodeURIComponent(e)}/deliveries/ack`,"customObjectAck"),objectShares:o(e=>`/v1/objects/${encodeURIComponent(e)}/shares`,"objectShares"),objectEdges:o(e=>`/v1/objects/${encodeURIComponent(e)}/edges`,"objectEdges"),docs:o(()=>"/v1/docs","docs"),doc:o(e=>`/v1/docs/${encodeURIComponent(e)}`,"doc"),docMove:o(e=>`/v1/docs/${encodeURIComponent(e)}/move`,"docMove"),docHistory:o(e=>`/v1/docs/${encodeURIComponent(e)}/history`,"docHistory"),docsLint:o(()=>"/v1/docs/lint","docsLint"),schemas:o(()=>"/v1/schemas","schemas"),relations:o(()=>"/v1/relations","relations"),check:o(()=>"/v1/check","check"),pluginAppToken:o(e=>`/v1/plugins/${encodeURIComponent(e)}/app-token`,"pluginAppToken"),pluginCallHeaders:o(e=>`/v1/plugins/${encodeURIComponent(e)}/call-headers`,"pluginCallHeaders"),documentsBrowserAccess:o(()=>"/v1/documents/browser-access","documentsBrowserAccess"),documentsReconcilePackages:o(()=>"/v1/documents/reconcile-packages","documentsReconcilePackages")};export{$ as API_VERSION,a as routes};
@@ -1,3 +1,4 @@
1
+ import type { RosterDTO } from '../../../api/dto/canvas.js';
1
2
  import type { CanvasSource } from '../../../core/canvas/source.js';
2
3
  import type { CronDTO } from '../../../api/dto/crons.js';
3
4
  import type { ReviewDTO } from '../../../api/dto/reviews.js';
@@ -48,4 +49,4 @@ export interface OtherNodeWaits {
48
49
  * `{}` to omit the ⚑ badges. `crons` are this node's armed schedules.
49
50
  * `palette`
50
51
  * drives the headers + dim cells; omit it and the panels render uncolored. */
51
- export declare function buildCanvasPanelLines(nodeId: string, asks: Record<string, number>, palette: AttachPalette | undefined, source: CanvasSource, crons?: readonly CronDTO[], jobs?: readonly BashJobStatus[], reviews?: readonly ReviewDTO[], others?: OtherNodeWaits): Promise<CanvasPanelLines>;
52
+ export declare function buildCanvasPanelLines(nodeId: string, asks: Record<string, number>, palette: AttachPalette | undefined, source: CanvasSource, crons?: readonly CronDTO[], jobs?: readonly BashJobStatus[], reviews?: readonly ReviewDTO[], others?: OtherNodeWaits, view?: RosterDTO): Promise<CanvasPanelLines>;
@@ -1 +1 @@
1
- var dn=Object.defineProperty;var i=(s,a)=>dn(s,"name",{value:a,configurable:!0});import{navLabel as K,nodeGlyph as un,truncate as ln,tokensCell as fn,cycleBadge as mn,askBadge as hn,fillWidth as W,RESET as m,DIM as C,GREEN as pn}from"../../../core/canvas/nav-render.js";const wn=34,$n=30,gn=40;import{RemoteCanvasSource as _n}from"../../../core/canvas/remote-canvas-source.js";import{cronWaitSummary as L}from"./cron-wait.js";import{bashJobsWaitSummary as V}from"./bash-jobs.js";import{reviewWaitSummary as yn}from"./review-wait.js";import{objectWaitSummary as q}from"./object-wait.js";import{formatBashElapsed as bn}from"../../../core/bash-jobs.js";const z=i((s,a)=>{const c=s==null?Number.NaN:Date.parse(s);return Number.isNaN(c)?void 0:bn(a-c)},"since"),vn=12,kn=6,Q=22;function U(s,a){return s.length>a?`${s.slice(0,a-1)}\u2026`:s+" ".repeat(a-s.length)}i(U,"nameCell");function Mn(s,a){return s.length>=a?s.slice(0,a):" ".repeat(a-s.length)+s}i(Mn,"padStartVisible");async function Bn(s,a,c,h,X=[],E=[],Y=[],y){const S=h instanceof _n,p=await h.panelRoster?.(),b=p===void 0?null:new Map(p.nodes.map(n=>[n.node_id,n])),M=new Map,N=new Map;if(p!==void 0)for(const n of p.edges){const t=M.get(n.from_id)??[];t.push(n.to_id),M.set(n.from_id,t),N.has(n.to_id)||N.set(n.to_id,n.from_id)}const B=new Map,I=new Map,x=new Map,v=i(n=>{const t=B.get(n);if(t!==void 0)return t;const e=b===null?h.getNode(n).catch(()=>null):Promise.resolve(b.get(n)??null);return B.set(n,e),e},"node"),Z=i(n=>h.getNode(n).catch(()=>null),"detail"),O=i(n=>{const t=I.get(n);if(t!==void 0)return t;const e=(async()=>{const o=b===null?(await h.subscriptionsOf(n).catch(()=>[])).map(r=>r.node_id):M.get(n)??[],d=[];for(const r of o)(await v(r))?.kind!=="human"&&d.push(r);return d})();return I.set(n,e),e},"convoChildIds"),A=i(n=>{const t=x.get(n);if(t!==void 0)return t;const e=b===null?h.subscribersOf(n).then(o=>o[0]?.node_id).catch(()=>{}):Promise.resolve(N.get(n));return x.set(n,e),e},"managerOf"),D=i(async n=>{const t=[];for(const e of await O(n)){const o=(await v(e))?.status;(o==="active"||o==="idle")&&t.push(e)}return t},"liveReports"),nn=i(async n=>{let t=n;const e=new Set([t]);for(;;){const o=await A(t);if(o===void 0||e.has(o))break;e.add(o),t=o}return t},"climbRoot"),H=new Map,tn=i(async n=>{const t=new Set,e=i(async o=>{const d=(await v(o))?.status==="active";if(t.has(o))return d?1:0;t.add(o);let r=0;for(const w of await O(o))r+=await e(w);return H.set(o,r),r+(d?1:0)},"visit");await e(n)},"computeActivity"),en=i(async n=>{if(n===null||n.mode!=="orchestrator")return"";const t=(await O(n.node_id)).length;return t>0?` ${C}\u2933${t}${m}`:""},"childBadgeFor"),on=i(n=>{if(n===null||n.status==="active")return"";const t=H.get(n.node_id)??0;return t>0?` ${pn}\u21E3${t}${m}`:""},"liveBelowBadgeFor"),$=c?.muted??(n=>n),sn=c?.faint??(n=>n);await tn(await nn(s));const l=await A(s),j=await D(s),k=[...l!==void 0?[l]:[],...j],P=await Promise.all(k.map(async n=>await Z(n)??await v(n))),an=k.length>0?Math.min(Q,Math.max(...k.map((n,t)=>K(P[t]??null,n).length))):Q,cn=i(async(n,t)=>{if(S||t===null||t.status!=="active"&&t.status!=="idle")return"";const e=Date.now();if(t.streaming===!0){const g=[(t.telemetry_last_activity??"").trim(),z(t.telemetry_updated_at,e)].filter(_=>_!==void 0&&_!=="");return g.length===0?"":` ${C}\xB7 ${g.join(" \xB7 ")}${m}`}const o=[],d=(await D(n)).length;if(d>0&&o.push(d===1?"1 child":`${d} children`),(a[n]??0)>0&&o.push("you"),y!==void 0){y.reviews.some(R=>R.origin_node_id===n)&&o.push("review");const u=await y.jobsOf(n).catch(()=>null),g=u===null?"bash jobs (could not read)":V(u,e,20);g!==void 0&&o.push(g.replace(/ · /g," "));const _=L(y.crons.filter(R=>R.created_by===n),e);_!==void 0&&o.push(_.replace(/ · /g," "))}for(const u of p?.object_waits??[])u.node_id===n&&o.push(q(u,e,20).replace(/ · /g," "));const r=z(t.last_settled_at,e),w=[r===void 0?void 0:`turn ended ${r} ago`,o.length===0?void 0:`waiting on ${o.join(", ")}`].filter(u=>u!==void 0);return w.length===0?"":` ${C}\xB7 ${w.join(" \xB7 ")}${m}`},"stateCell"),T=i(async(n,t)=>{const e=P[k.indexOf(n)]??null,o=U(K(e,n),an),d=sn(U(e?.kind??"",vn)),r=$(Mn(fn(e,S),kn)),w=`${mn(e)}${await en(e)}${on(e)}${hn(n,a)}${await cn(n,e)}`,u=` ${t} ${un(e)} ${o} ${d} ${r}${w}`;return ln(u)},"row"),rn=[...l!==void 0?[l]:[],...j],f=[];l!==void 0&&f.push({key:`node:${l}`,kind:"node",nodeId:l,line:await T(l,"\u2191")});for(const n of j)f.push({key:`node:${n}`,kind:"node",nodeId:n,line:await T(n,"\u2193")});for(const n of Y){const t=c?c.info("\u270E"):"\u270E",e=yn(n,Math.max(8,W()-gn));f.push({key:`review:${n.review_id}`,kind:"review",companionNodeId:n.companion_node_id,line:` ${t} ${$(`${e} \xB7 \u21B5 companion`)}${m}`})}const F=E.length===1?" \xB7 x stop":"",G=V(E,Date.now(),W()-(wn+F.length));if(G!==void 0){const n=c?c.info("\u2699"):"\u2699";f.push({key:"bash",kind:"bash",line:` ${n} ${$(`${G} \xB7 \u21B5 details${F}`)}${m}`})}const J=L(X);if(J!==void 0){const n=c?c.info("\u25F7"):"\u25F7";f.push({key:"crons",kind:"crons",line:` ${n} ${$(`${J} \xB7 \u21B5 details`)}${m}`})}for(const n of p?.object_waits??[]){if(n.node_id!==s)continue;const t=c?c.info("\u25C7"):"\u25C7",e=q(n,Date.now(),Math.max(8,W()-$n));f.push({key:`object:${n.object_id}`,kind:"object-wait",objectId:n.object_id,line:` ${t} ${$(`${e} \xB7 \u21B5 details`)}${m}`})}return{reports:f.map(n=>n.line),reportIds:rn,items:f}}i(Bn,"buildCanvasPanelLines");export{Bn as buildCanvasPanelLines};
1
+ var un=Object.defineProperty;var i=(s,a)=>un(s,"name",{value:a,configurable:!0});import{navLabel as K,nodeGlyph as ln,truncate as fn,tokensCell as mn,cycleBadge as hn,askBadge as pn,fillWidth as C,RESET as m,DIM as E,GREEN as wn}from"../../../core/canvas/nav-render.js";const $n=34,gn=30,_n=40;import{RemoteCanvasSource as yn}from"../../../core/canvas/remote-canvas-source.js";import{cronWaitSummary as L}from"./cron-wait.js";import{bashJobsWaitSummary as V}from"./bash-jobs.js";import{reviewWaitSummary as bn}from"./review-wait.js";import{objectWaitSummary as q}from"./object-wait.js";import{formatBashElapsed as vn}from"../../../core/bash-jobs.js";const z=i((s,a)=>{const c=s==null?Number.NaN:Date.parse(s);return Number.isNaN(c)?void 0:vn(a-c)},"since"),kn=12,Mn=6,Q=22;function U(s,a){return s.length>a?`${s.slice(0,a-1)}\u2026`:s+" ".repeat(a-s.length)}i(U,"nameCell");function Nn(s,a){return s.length>=a?s.slice(0,a):" ".repeat(a-s.length)+s}i(Nn,"padStartVisible");async function In(s,a,c,w,X=[],R=[],Y=[],y,Z){const S=w instanceof yn,h=Z,b=h===void 0?null:new Map(h.nodes.map(n=>[n.node_id,n])),M=new Map,N=new Map;if(h!==void 0)for(const n of h.edges){const t=M.get(n.from_id)??[];t.push(n.to_id),M.set(n.from_id,t),N.has(n.to_id)||N.set(n.to_id,n.from_id)}const B=new Map,I=new Map,x=new Map,v=i(n=>{const t=B.get(n);if(t!==void 0)return t;const e=b===null?w.getNode(n).catch(()=>null):Promise.resolve(b.get(n)??null);return B.set(n,e),e},"node"),nn=i(n=>w.getNode(n).catch(()=>null),"detail"),O=i(n=>{const t=I.get(n);if(t!==void 0)return t;const e=(async()=>{const o=b===null?(await w.subscriptionsOf(n).catch(()=>[])).map(r=>r.node_id):M.get(n)??[],d=[];for(const r of o)(await v(r))?.kind!=="human"&&d.push(r);return d})();return I.set(n,e),e},"convoChildIds"),A=i(n=>{const t=x.get(n);if(t!==void 0)return t;const e=b===null?w.subscribersOf(n).then(o=>o[0]?.node_id).catch(()=>{}):Promise.resolve(N.get(n));return x.set(n,e),e},"managerOf"),D=i(async n=>{const t=[];for(const e of await O(n)){const o=(await v(e))?.status;(o==="active"||o==="idle")&&t.push(e)}return t},"liveReports"),tn=i(async n=>{let t=n;const e=new Set([t]);for(;;){const o=await A(t);if(o===void 0||e.has(o))break;e.add(o),t=o}return t},"climbRoot"),H=new Map,en=i(async n=>{const t=new Set,e=i(async o=>{const d=(await v(o))?.status==="active";if(t.has(o))return d?1:0;t.add(o);let r=0;for(const p of await O(o))r+=await e(p);return H.set(o,r),r+(d?1:0)},"visit");await e(n)},"computeActivity"),on=i(async n=>{if(n===null||n.mode!=="orchestrator")return"";const t=(await O(n.node_id)).length;return t>0?` ${E}\u2933${t}${m}`:""},"childBadgeFor"),sn=i(n=>{if(n===null||n.status==="active")return"";const t=H.get(n.node_id)??0;return t>0?` ${wn}\u21E3${t}${m}`:""},"liveBelowBadgeFor"),$=c?.muted??(n=>n),an=c?.faint??(n=>n);await en(await tn(s));const l=await A(s),j=await D(s),k=[...l!==void 0?[l]:[],...j],P=await Promise.all(k.map(async n=>await nn(n)??await v(n))),cn=k.length>0?Math.min(Q,Math.max(...k.map((n,t)=>K(P[t]??null,n).length))):Q,rn=i(async(n,t)=>{if(S||t===null||t.status!=="active"&&t.status!=="idle")return"";const e=Date.now();if(t.streaming===!0){const g=[(t.telemetry_last_activity??"").trim(),z(t.telemetry_updated_at,e)].filter(_=>_!==void 0&&_!=="");return g.length===0?"":` ${E}\xB7 ${g.join(" \xB7 ")}${m}`}const o=[],d=(await D(n)).length;if(d>0&&o.push(d===1?"1 child":`${d} children`),(a[n]??0)>0&&o.push("you"),y!==void 0){y.reviews.some(W=>W.origin_node_id===n)&&o.push("review");const u=await y.jobsOf(n).catch(()=>null),g=u===null?"bash jobs (could not read)":V(u,e,20);g!==void 0&&o.push(g.replace(/ · /g," "));const _=L(y.crons.filter(W=>W.created_by===n),e);_!==void 0&&o.push(_.replace(/ · /g," "))}for(const u of h?.object_waits??[])u.node_id===n&&o.push(q(u,e,20).replace(/ · /g," "));const r=z(t.last_settled_at,e),p=[r===void 0?void 0:`turn ended ${r} ago`,o.length===0?void 0:`waiting on ${o.join(", ")}`].filter(u=>u!==void 0);return p.length===0?"":` ${E}\xB7 ${p.join(" \xB7 ")}${m}`},"stateCell"),T=i(async(n,t)=>{const e=P[k.indexOf(n)]??null,o=U(K(e,n),cn),d=an(U(e?.kind??"",kn)),r=$(Nn(mn(e,S),Mn)),p=`${hn(e)}${await on(e)}${sn(e)}${pn(n,a)}${await rn(n,e)}`,u=` ${t} ${ln(e)} ${o} ${d} ${r}${p}`;return fn(u)},"row"),dn=[...l!==void 0?[l]:[],...j],f=[];l!==void 0&&f.push({key:`node:${l}`,kind:"node",nodeId:l,line:await T(l,"\u2191")});for(const n of j)f.push({key:`node:${n}`,kind:"node",nodeId:n,line:await T(n,"\u2193")});for(const n of Y){const t=c?c.info("\u270E"):"\u270E",e=bn(n,Math.max(8,C()-_n));f.push({key:`review:${n.review_id}`,kind:"review",companionNodeId:n.companion_node_id,line:` ${t} ${$(`${e} \xB7 \u21B5 companion`)}${m}`})}const F=R.length===1?" \xB7 x stop":"",G=V(R,Date.now(),C()-($n+F.length));if(G!==void 0){const n=c?c.info("\u2699"):"\u2699";f.push({key:"bash",kind:"bash",line:` ${n} ${$(`${G} \xB7 \u21B5 details${F}`)}${m}`})}const J=L(X);if(J!==void 0){const n=c?c.info("\u25F7"):"\u25F7";f.push({key:"crons",kind:"crons",line:` ${n} ${$(`${J} \xB7 \u21B5 details`)}${m}`})}for(const n of h?.object_waits??[]){if(n.node_id!==s)continue;const t=c?c.info("\u25C7"):"\u25C7",e=q(n,Date.now(),Math.max(8,C()-gn));f.push({key:`object:${n.object_id}`,kind:"object-wait",objectId:n.object_id,line:` ${t} ${$(`${e} \xB7 \u21B5 details`)}${m}`})}return{reports:f.map(n=>n.line),reportIds:dn,items:f}}i(In,"buildCanvasPanelLines");export{In as buildCanvasPanelLines};
@@ -1,5 +1,6 @@
1
1
  import { Container } from '@earendil-works/pi-tui';
2
2
  import { type InboxRow } from '../../inbox/dto-adapt.js';
3
+ import type { RosterDTO } from '../../../api/dto/canvas.js';
3
4
  import type { AttachSession } from '../session/context.js';
4
5
  export type StripSession = Pick<AttachSession, 'nodeId' | 'remote' | 'canvasSource' | 'tui' | 'pal'>;
5
6
  export interface InboxStripHooks {
@@ -23,7 +24,7 @@ export interface InboxStrip {
23
24
  /** Rescan the subtree's pending tickets and repaint. Never rejects: most
24
25
  * callers fire it from inbox activity with nobody awaiting it, so a daemon
25
26
  * failure goes to `onRefreshFailure` and the last rows stay on screen. */
26
- refresh(): Promise<void>;
27
+ refresh(view?: RosterDTO): Promise<void>;
27
28
  /** Strip key routing, called BEFORE the editor sees the key. */
28
29
  handleKey(data: string): boolean;
29
30
  /** The dedicated binding: enter the strip, or leave it when already held. */
@@ -1 +1 @@
1
- var L=Object.defineProperty;var o=(f,c)=>L(f,"name",{value:c,configurable:!0});import{Container as F,Text as $,decodeKittyPrintable as K,matchesKey as x}from"@earendil-works/pi-tui";import{DynamicBorder as O}from"@earendil-works/pi-coding-agent";import{byNewestFirst as W,inboxRowFromDTO as R}from"../../inbox/dto-adapt.js";import{cliClient as q}from"../../../commands/api-client.js";import{fillBar as A,fillWidth as B,navLabel as H,stripSgr as P,truncate as j,REVERSE as V,YELLOW as X,RESET as Y}from"../../../core/canvas/nav-render.js";const y=3;function z(f){return f.kind==="page"?f.emittedAt:f.blockedSince}o(z,"ticketTime");function G(f){const c=Date.now()-Date.parse(f);if(!Number.isFinite(c)||c<0)return"now";const u=Math.floor(c/6e4);if(u<1)return"now";if(u<60)return`${u}m`;const p=Math.floor(u/60);return p<24?`${p}h`:`${Math.floor(p/24)}d`}o(G,"ageLabel");function ie(f,c){const{nodeId:u,remote:p,canvasSource:M,tui:k,pal:I}=f,h=new F;let i=[],b=new Map,r,l=0;const S=o(e=>{const t=e.source.nodeId,d=t!==void 0&&t!==u?` \xB7 ${H(b.get(t)??null,t)}`:"";return j(` ${X}\u2691${Y} ${e.title}${I.faint(` \xB7 ${G(z(e))}${d}`)}`)},"rowLine"),w=o(()=>{if(c.syncCursor(),h.clear(),i.length>0&&!c.suppressed()){const e=r===void 0?-1:i.findIndex(d=>d.dir===r);e>=0&&(l=Math.min(Math.max(l,e-y+1),e)),l=Math.max(0,Math.min(l,Math.max(0,i.length-y)));for(const d of i.slice(l,l+y)){const a=S(d);h.addChild(new $(d.dir===r?A(P(a),B(),V):a,1,0))}const t=i.length-Math.min(y,i.length-l);t>0&&h.addChild(new $(I.faint(` +${t} more`),1,0)),h.addChild(new O(I.border))}k.requestRender()},"paint"),C=o(async()=>{const e=await M.panelRoster?.(),t=e===void 0?await M.listNodes():e.nodes.map(n=>({node_id:n.node_id,name:n.name,kind:n.kind,status:n.status,...n.description?{description:n.description}:{}})),d=new Map(t.map(n=>[n.node_id,n])),a=new Map,m=o(async n=>{if(a.has(n))return;const s=d.get(n)??null;if(n!==u&&s?.kind==="human")return;a.set(n,s);const v=await M.subscriptionsOf(n).catch(()=>[]);for(const D of v)await m(D.node_id)},"visit");return await m(u),a},"subtreeNodes"),E=o(async()=>{try{await N()}catch(e){c.onRefreshFailure(e)}},"refresh"),N=o(async()=>{if(p)return;const e=await C(),t=q(),[d,a]=await Promise.all([t.listHumanInbox(),t.getInboxHistory(void 0,{state:"pending"})]);b=e;const m=new Map;for(const n of d.tickets){const s=R(n);m.set(s.dir,s)}for(const n of a.tickets){const s=R(n);s.kind==="page"&&(s.source.nodeId===void 0||!b.has(s.source.nodeId)||s.state!=="pending"||!s.awaitsResponse||s.inbox||m.has(s.dir)||m.set(s.dir,s))}i=[...m.values()].filter(n=>n.source.nodeId!==void 0&&b.has(n.source.nodeId)).sort(W),r!==void 0&&!i.some(n=>n.dir===r)&&(r=void 0),w()},"rescan"),g=o(()=>{r!==void 0&&(r=void 0,w())},"exit"),T=o(()=>{if(!p){if(r!==void 0){g();return}if(i.length===0){c.setNotice("No pending human requests in this subtree");return}c.exitRoster(),r=i[0].dir,l=0,w()}},"toggle"),_=o(()=>{const e=i.find(t=>t.dir===r);e!==void 0&&(g(),c.openTicket(e))},"openSelected");return{component:h,refresh:E,handleKey:o(e=>{if(r===void 0)return!1;const t=i.findIndex(a=>a.dir===r),d=K(e)??(e.length===1?e:void 0);return x(e,"up")||d==="k"?(t>0&&(r=i[t-1].dir,w()),!0):x(e,"down")||d==="j"?(t>=0&&t<i.length-1?(r=i[t+1].dir,w()):g(),!0):x(e,"enter")?(_(),!0):x(e,"escape")?(g(),!0):(g(),!1)},"handleKey"),toggle:T,active:o(()=>r!==void 0,"active"),pendingTickets:o(()=>[...i],"pendingTickets")}}o(ie,"createInboxStrip");export{ie as createInboxStrip};
1
+ var F=Object.defineProperty;var o=(a,c)=>F(a,"name",{value:c,configurable:!0});import{Container as K,Text as R,decodeKittyPrintable as O,matchesKey as M}from"@earendil-works/pi-tui";import{DynamicBorder as W}from"@earendil-works/pi-coding-agent";import{byNewestFirst as q,inboxRowFromDTO as S}from"../../inbox/dto-adapt.js";import{cliClient as A}from"../../../commands/api-client.js";import{fillBar as B,fillWidth as H,navLabel as P,stripSgr as V,truncate as j,REVERSE as X,YELLOW as Y,RESET as z}from"../../../core/canvas/nav-render.js";const I=3;function G(a){return a.kind==="page"?a.emittedAt:a.blockedSince}o(G,"ticketTime");function J(a){const c=Date.now()-Date.parse(a);if(!Number.isFinite(c)||c<0)return"now";const f=Math.floor(c/6e4);if(f<1)return"now";if(f<60)return`${f}m`;const h=Math.floor(f/60);return h<24?`${h}h`:`${Math.floor(h/24)}d`}o(J,"ageLabel");function re(a,c){const{nodeId:f,remote:h,canvasSource:$,tui:_,pal:k}=a,w=new K;let i=[],y=new Map,r,u=0;const C=o(n=>{const t=n.source.nodeId,d=t!==void 0&&t!==f?` \xB7 ${P(y.get(t)??null,t)}`:"";return j(` ${Y}\u2691${z} ${n.title}${k.faint(` \xB7 ${J(G(n))}${d}`)}`)},"rowLine"),g=o(()=>{if(c.syncCursor(),w.clear(),i.length>0&&!c.suppressed()){const n=r===void 0?-1:i.findIndex(d=>d.dir===r);n>=0&&(u=Math.min(Math.max(u,n-I+1),n)),u=Math.max(0,Math.min(u,Math.max(0,i.length-I)));for(const d of i.slice(u,u+I)){const l=C(d);w.addChild(new R(d.dir===r?B(V(l),H(),X):l,1,0))}const t=i.length-Math.min(I,i.length-u);t>0&&w.addChild(new R(k.faint(` +${t} more`),1,0)),w.addChild(new W(k.border))}_.requestRender()},"paint"),E=o(async n=>{const t=n??await $.panelView?.(f),d=t===void 0?await $.listNodes():t.nodes.map(e=>({node_id:e.node_id,name:e.name,kind:e.kind,status:e.status,...e.description?{description:e.description}:{}})),l=new Map(d.map(e=>[e.node_id,e])),x=new Map,m=o(async e=>{if(x.has(e))return;const s=l.get(e)??null;if(e!==f&&s?.kind==="human")return;x.set(e,s);const L=t===void 0?(await $.subscriptionsOf(e).catch(()=>[])).map(p=>p.node_id):t.edges.filter(p=>p.from_id===e).map(p=>p.to_id);for(const p of L)await m(p)},"visit");return await m(f),x},"subtreeNodes"),N=o(async n=>{try{await T(n)}catch(t){c.onRefreshFailure(t)}},"refresh"),T=o(async n=>{if(h)return;const t=await E(n),d=A(),[l,x]=await Promise.all([d.listHumanInbox(),d.getInboxHistory(void 0,{state:"pending"})]);y=t;const m=new Map;for(const e of l.tickets){const s=S(e);m.set(s.dir,s)}for(const e of x.tickets){const s=S(e);s.kind==="page"&&(s.source.nodeId===void 0||!y.has(s.source.nodeId)||s.state!=="pending"||!s.awaitsResponse||s.inbox||m.has(s.dir)||m.set(s.dir,s))}i=[...m.values()].filter(e=>e.source.nodeId!==void 0&&y.has(e.source.nodeId)).sort(q),r!==void 0&&!i.some(e=>e.dir===r)&&(r=void 0),g()},"rescan"),b=o(()=>{r!==void 0&&(r=void 0,g())},"exit"),v=o(()=>{if(!h){if(r!==void 0){b();return}if(i.length===0){c.setNotice("No pending human requests in this subtree");return}c.exitRoster(),r=i[0].dir,u=0,g()}},"toggle"),D=o(()=>{const n=i.find(t=>t.dir===r);n!==void 0&&(b(),c.openTicket(n))},"openSelected");return{component:w,refresh:N,handleKey:o(n=>{if(r===void 0)return!1;const t=i.findIndex(l=>l.dir===r),d=O(n)??(n.length===1?n:void 0);return M(n,"up")||d==="k"?(t>0&&(r=i[t-1].dir,g()),!0):M(n,"down")||d==="j"?(t>=0&&t<i.length-1?(r=i[t+1].dir,g()):b(),!0):M(n,"enter")?(D(),!0):M(n,"escape")?(b(),!0):(b(),!1)},"handleKey"),toggle:v,active:o(()=>r!==void 0,"active"),pendingTickets:o(()=>[...i],"pendingTickets")}}o(re,"createInboxStrip");export{re as createInboxStrip};
@@ -1,3 +1,4 @@
1
+ import type { RosterDTO } from '../../../api/dto/canvas.js';
1
2
  import type { AttachSession } from '../session/context.js';
2
3
  /** The slice of the session the roster reads. */
3
4
  export type RosterSession = Pick<AttachSession, 'nodeId' | 'remote' | 'role' | 'meta' | 'canvasSource' | 'tui' | 'pal' | 'editor' | 'containers'>;
@@ -27,7 +28,7 @@ export interface RosterHooks {
27
28
  }
28
29
  export interface AttachRoster {
29
30
  /** Rebuild the rows from the canvas source, reconcile the selection, repaint. */
30
- refresh(): Promise<void>;
31
+ refresh(view?: RosterDTO): Promise<void>;
31
32
  /** Roster key routing, called BEFORE the editor sees the key. Returns true
32
33
  * when the roster consumed it (the editor must not see it). */
33
34
  handleKey(data: string): boolean;
@@ -1,6 +1,6 @@
1
- var U=Object.defineProperty;var r=(v,n)=>U(v,"name",{value:n,configurable:!0});import{execFile as $}from"node:child_process";import{Text as k,decodeKittyPrintable as X,matchesKey as N}from"@earendil-works/pi-tui";import{cliClient as g}from"../../../commands/api-client.js";import{focusNode as D}from"../../../core/runtime/focus-viewer.js";import{daemonErrorMessage as j}from"../../inbox/resolve.js";import{toBashJobStatus as x}from"./bash-jobs.js";import{fillBar as F,fillWidth as L,stripSgr as V,REVERSE as W}from"../../../core/canvas/nav-render.js";import{buildCanvasPanelLines as z}from"./canvas-panels.js";const G=15e3;function ce(v,n){const{editor:E,tui:K,pal:A,nodeId:m,remote:f,role:R,canvasSource:B}=v,I=v.containers.reports;let s=[],o,w=process.env.CRTR_ATTACH_ROSTER;w!==void 0&&delete process.env.CRTR_ATTACH_ROSTER;let u,h;const b=r(()=>{n.syncCursor(),I.clear();for(const e of s){const i=e.key===o;I.addChild(new k(i?F(V(e.line),L(),W):e.line,1,0))}K.requestRender()},"paint"),C=r(async()=>(await g().listBashJobs(m)).map(x),"listJobs"),M=r(async()=>{const e=f?[]:await g().listCrons(),i=e.filter(d=>d.created_by===m),c=f?[]:await C(),t=f?[]:(await g().listReviews({state:"open"})).reviews,a=t.filter(d=>d.origin_node_id===m),p=f?void 0:{crons:e,reviews:t,jobsOf:r(async d=>(await g().listBashJobs(d)).map(x),"jobsOf")};if(s=(await z(m,n.asks(),A,B,i,c,a,p)).items,w!==void 0){const d=w;w=void 0;const S=s.find(_=>_.kind==="node"&&_.nodeId===d);S!==void 0&&(o=S.key)}o!==void 0&&!s.some(d=>d.key===o)&&(o=void 0),u!==void 0&&!c.some(d=>d.jobId===u?.jobId)&&y(!0),b()},"refresh"),y=r(e=>{h!==void 0&&(clearTimeout(h),h=void 0),u!==void 0&&(u=void 0,e&&n.setNotice(""))},"disarmKill"),l=r(()=>{y(!0),o!==void 0&&(o=void 0,b())},"exit"),T=r(e=>X(e)??(e.length===1?e:void 0),"typed"),P=r((e,i=40)=>{const c=(e.split(`
2
- `)[0]??"").replace(/\s+/g," ").trim();return c.length>i?`${c.slice(0,i-1)}\u2026`:c},"commandHead"),J=r(async()=>{if(R!=="controller"){n.setNotice("Read-only observer attach \u2014 cannot stop background jobs");return}const e=await C();if(e.length===0){n.setNotice("Background job already finished"),n.requestChromeRefresh();return}if(e.length>1){n.setNotice(`${e.length} background jobs \u2014 press \u21B5 to pick one in the Inspector`);return}const i=e[0];u={jobId:i.jobId,label:P(i.command)},n.setNotice(`Stop \u201C${u.label}\u201D? Press y to confirm.`,{sticky:!0}),h=setTimeout(()=>y(!0),G)},"armKill"),O=r(()=>{const e=u;e!==void 0&&(y(!1),n.setNotice(`Stopping \u201C${e.label}\u201D\u2026`),$("crtr",["node","bash","kill",e.jobId,"--node",m],i=>{n.setNotice(i===null?`Stopped \u201C${e.label}\u201D.`:`Could not stop the job: ${i.message.split(`
3
- `)[0]}`),n.requestChromeRefresh()}))},"confirmKill");E.onCursorDownAtBottom=f?void 0:()=>{o!==void 0||s.length===0||(o=s[0].key,b())};const q=r(()=>{const e=s.find(t=>t.key===o);if(e===void 0||f)return;if(e.kind==="crons"){l(),n.openInspector("schedule");return}if(e.kind==="review"){if(R!=="controller"){n.setNotice("Read-only observer attach \u2014 cannot open the review companion");return}l();const t=process.env.TMUX_PANE;if(t===void 0||t===""){n.setNotice("Could not open the companion: no tmux pane");return}(async()=>{const a=g(),p=await a.getNode(e.companionNodeId);(await D(a,p,{pane:t})).focused||n.setNotice("Could not open the companion")})().catch(a=>n.setNotice(`Could not open the companion: ${j(a).split(`
1
+ var U=Object.defineProperty;var r=(g,n)=>U(g,"name",{value:n,configurable:!0});import{execFile as E}from"node:child_process";import{Text as k,decodeKittyPrintable as V,matchesKey as N}from"@earendil-works/pi-tui";import{cliClient as w}from"../../../commands/api-client.js";import{focusNode as X}from"../../../core/runtime/focus-viewer.js";import{daemonErrorMessage as j}from"../../inbox/resolve.js";import{toBashJobStatus as K}from"./bash-jobs.js";import{fillBar as D,fillWidth as F,stripSgr as L,REVERSE as W}from"../../../core/canvas/nav-render.js";import{buildCanvasPanelLines as z}from"./canvas-panels.js";const G=15e3;function de(g,n){const{editor:A,tui:B,pal:M,nodeId:f,remote:p,role:R,canvasSource:I}=g,T=g.containers.reports;let s=[],o,v=process.env.CRTR_ATTACH_ROSTER;v!==void 0&&delete process.env.CRTR_ATTACH_ROSTER;let a,h;const b=r(()=>{n.syncCursor(),T.clear();for(const e of s){const i=e.key===o;T.addChild(new k(i?D(L(e.line),F(),W):e.line,1,0))}B.requestRender()},"paint"),C=r(async()=>(await w().listBashJobs(f)).map(K),"listJobs"),P=r(async e=>{const i=p?[]:await w().listCrons(),c=i.filter(d=>d.created_by===f),t=p?[]:await C(),u=p?[]:(await w().listReviews({state:"open"})).reviews,m=u.filter(d=>d.origin_node_id===f),_=p?void 0:{crons:i,reviews:u,jobsOf:r(async d=>(await w().listBashJobs(d)).map(K),"jobsOf")};if(s=(await z(f,n.asks(),M,I,c,t,m,_,e??await I.panelView?.(f))).items,v!==void 0){const d=v;v=void 0;const $=s.find(x=>x.kind==="node"&&x.nodeId===d);$!==void 0&&(o=$.key)}o!==void 0&&!s.some(d=>d.key===o)&&(o=void 0),a!==void 0&&!t.some(d=>d.jobId===a?.jobId)&&y(!0),b()},"refresh"),y=r(e=>{h!==void 0&&(clearTimeout(h),h=void 0),a!==void 0&&(a=void 0,e&&n.setNotice(""))},"disarmKill"),l=r(()=>{y(!0),o!==void 0&&(o=void 0,b())},"exit"),S=r(e=>V(e)??(e.length===1?e:void 0),"typed"),J=r((e,i=40)=>{const c=(e.split(`
2
+ `)[0]??"").replace(/\s+/g," ").trim();return c.length>i?`${c.slice(0,i-1)}\u2026`:c},"commandHead"),O=r(async()=>{if(R!=="controller"){n.setNotice("Read-only observer attach \u2014 cannot stop background jobs");return}const e=await C();if(e.length===0){n.setNotice("Background job already finished"),n.requestChromeRefresh();return}if(e.length>1){n.setNotice(`${e.length} background jobs \u2014 press \u21B5 to pick one in the Inspector`);return}const i=e[0];a={jobId:i.jobId,label:J(i.command)},n.setNotice(`Stop \u201C${a.label}\u201D? Press y to confirm.`,{sticky:!0}),h=setTimeout(()=>y(!0),G)},"armKill"),q=r(()=>{const e=a;e!==void 0&&(y(!1),n.setNotice(`Stopping \u201C${e.label}\u201D\u2026`),E("crtr",["node","bash","kill",e.jobId,"--node",f],i=>{n.setNotice(i===null?`Stopped \u201C${e.label}\u201D.`:`Could not stop the job: ${i.message.split(`
3
+ `)[0]}`),n.requestChromeRefresh()}))},"confirmKill");A.onCursorDownAtBottom=p?void 0:()=>{o!==void 0||s.length===0||(o=s[0].key,b())};const H=r(()=>{const e=s.find(t=>t.key===o);if(e===void 0||p)return;if(e.kind==="crons"){l(),n.openInspector("schedule");return}if(e.kind==="review"){if(R!=="controller"){n.setNotice("Read-only observer attach \u2014 cannot open the review companion");return}l();const t=process.env.TMUX_PANE;if(t===void 0||t===""){n.setNotice("Could not open the companion: no tmux pane");return}(async()=>{const u=w(),m=await u.getNode(e.companionNodeId);(await X(u,m,{pane:t})).focused||n.setNotice("Could not open the companion")})().catch(u=>n.setNotice(`Could not open the companion: ${j(u).split(`
4
4
  `)[0]}`));return}if(e.kind==="bash"){C().then(t=>{if(t.length===0){n.setNotice("Background job already finished"),n.requestChromeRefresh();return}l(),n.openInspector("jobs")},t=>n.setNotice(`Could not list background jobs: ${j(t).split(`
5
- `)[0]}`));return}if(e.kind==="object-wait"){l(),n.openObject(e.objectId);return}const i=e.nodeId;if(i===m){l();return}if(R!=="controller"){n.setNotice("Read-only observer attach \u2014 cannot focus nodes");return}const c=process.env.TMUX_PANE;if(c===void 0||c===""){n.setNotice("cannot swap \u2014 no tmux pane");return}$("tmux",["run-shell","-b",`crtr surface node focus ${i} --pane ${c} --in-place >/dev/null 2>&1`],()=>{})},"openSelected");return{refresh:M,handleKey:r(e=>{if(f)return!1;const i=N(e,"down"),c=N(e,"up");if(o===void 0)return!1;const t=s.findIndex(p=>p.key===o),a=s[t];if(u!==void 0){if(T(e)==="y")return O(),!0;y(!0)}return a?.kind==="bash"&&T(e)==="x"?(J().catch(p=>n.setNotice(`Could not list background jobs: ${j(p).split(`
6
- `)[0]}`)),!0):c?(t<=0?l():(o=s[t-1].key,b()),!0):i?(t>=0&&t<s.length-1&&(o=s[t+1].key,b()),!0):N(e,"enter")?(q(),!0):N(e,"escape")?(l(),!0):(l(),!1)},"handleKey"),active:r(()=>o!==void 0,"active"),exit:l}}r(ce,"createRoster");export{ce as createRoster};
5
+ `)[0]}`));return}if(e.kind==="object-wait"){l(),n.openObject(e.objectId);return}const i=e.nodeId;if(i===f){l();return}if(R!=="controller"){n.setNotice("Read-only observer attach \u2014 cannot focus nodes");return}const c=process.env.TMUX_PANE;if(c===void 0||c===""){n.setNotice("cannot swap \u2014 no tmux pane");return}E("tmux",["run-shell","-b",`crtr surface node focus ${i} --pane ${c} --in-place >/dev/null 2>&1`],()=>{})},"openSelected");return{refresh:P,handleKey:r(e=>{if(p)return!1;const i=N(e,"down"),c=N(e,"up");if(o===void 0)return!1;const t=s.findIndex(m=>m.key===o),u=s[t];if(a!==void 0){if(S(e)==="y")return q(),!0;y(!0)}return u?.kind==="bash"&&S(e)==="x"?(O().catch(m=>n.setNotice(`Could not list background jobs: ${j(m).split(`
6
+ `)[0]}`)),!0):c?(t<=0?l():(o=s[t-1].key,b()),!0):i?(t>=0&&t<s.length-1&&(o=s[t+1].key,b()),!0):N(e,"enter")?(H(),!0):N(e,"escape")?(l(),!0):(l(),!1)},"handleKey"),active:r(()=>o!==void 0,"active"),exit:l}}r(de,"createRoster");export{de as createRoster};
@@ -1,3 +1,4 @@
1
+ import type { PanelViewDTO } from '../../../api/dto/canvas.js';
1
2
  import type { AttachSession } from './context.js';
2
3
  /** The sticky status-line text while crtrd is not answering chrome reads. */
3
4
  export declare const DAEMON_STALLED_NOTICE = "crtrd not responding \u2014 retrying";
@@ -12,7 +13,7 @@ export interface ChromeRefreshHooks {
12
13
  sticky?: boolean;
13
14
  }) => void;
14
15
  /** Repaint the relationship roster (chrome/roster.ts refresh). */
15
- refreshRoster: () => Promise<void>;
16
+ refreshRoster: (view?: PanelViewDTO) => Promise<void>;
16
17
  /** Repaint the graph overlay if open. */
17
18
  refreshGraph: () => void;
18
19
  /** Re-read the node's persona/lifecycle/icon from canvas — a runtime
@@ -1 +1 @@
1
- var M=Object.defineProperty;var r=(s,e)=>M(s,"name",{value:e,configurable:!0});import{APIError as N,isDaemonTransportApiError as O}from"../../../api/errors.js";const u=5e3,v=6e4,I="crtrd not responding \u2014 retrying";function L(s){return O(s)||s instanceof N&&s.status>=500}r(L,"isTransientDaemonFailure");function C(s,e){const{nodeId:w,canvasSource:g}=s;let m={},a,p=!1,i=0,h=0;const _=r(()=>{i===0&&e.setNotice(I,{sticky:!0}),i=Math.min(i+1,16)},"markStalled"),D=r(()=>{i!==0&&(i=0,e.setNotice("crtrd responding again"),E(u))},"markHealthy"),c=r((t,n)=>{if(h++,L(n)){_();return}const o=(n instanceof Error?n.message:n===void 0?"":String(n)).replace(/\s+/g," ").trim().slice(0,120);e.setNotice(o===""?`${t} delayed`:`${t} delayed \u2014 ${o}`)},"reportFailure");let y=!1,f=!1;const l=r(()=>{f=!0,!y&&(y=!0,(async()=>{try{for(;f&&!e.isTornDown();){f=!1;const t=h;try{await e.refreshRoster(),h===t&&D()}catch(n){c("canvas panel refresh",n)}e.refreshGraph()}}finally{y=!1,f&&!e.isTornDown()&&l()}})().catch(t=>c("canvas chrome refresh",t)))},"refresh"),F=r(async t=>{let n=t;const o=new Set([n]);for(;;){const d=(await g.subscribersOf(n).catch(()=>[]))[0]?.node_id;if(d===void 0||o.has(d))break;o.add(d),n=d}return n},"climbRootFromSource"),T=r(()=>{l(),e.refreshIdentity(),e.renderExtensionWidgets(),e.pollGit(),e.refreshInFlightTools(),e.renderFooter(),(async()=>{const t=await F(w),n=await g.ticketCountsForView(t);JSON.stringify(n)!==JSON.stringify(m)&&(m=n,l(),e.renderFooter())})().catch(t=>c("canvas attention refresh",t))},"pollChrome"),A=r(()=>i===0?u:Math.min(u*2**i,v),"nextDelay");function E(t){p||a===void 0||(clearTimeout(a),S(t))}r(E,"rearm");function S(t){a=setTimeout(()=>{p||e.isTornDown()||(T(),S(A()))},t),typeof a.unref=="function"&&a.unref()}return r(S,"schedule"),{refresh:l,asks:r(()=>m,"asks"),reportFailure:c,daemonStalled:r(()=>i>0,"daemonStalled"),start:r(()=>{T(),S(u)},"start"),stop:r(()=>{p=!0,a!==void 0&&clearTimeout(a)},"stop")}}r(C,"createChromeRefresh");export{I as DAEMON_STALLED_NOTICE,C as createChromeRefresh,L as isTransientDaemonFailure};
1
+ var v=Object.defineProperty;var n=(s,r)=>v(s,"name",{value:r,configurable:!0});import{APIError as E,isDaemonTransportApiError as M}from"../../../api/errors.js";const p=5e3,I=6e4,L="crtrd not responding \u2014 retrying";function x(s){return M(s)||s instanceof E&&s.status>=500}n(x,"isTransientDaemonFailure");function J(s,r){const{nodeId:w,canvasSource:f}=s;let o={},a,y=!1,i=0,S=0;const _=n(()=>{i===0&&r.setNotice(L,{sticky:!0}),i=Math.min(i+1,16)},"markStalled"),F=n(()=>{i!==0&&(i=0,r.setNotice("crtrd responding again"),D(p))},"markHealthy"),l=n((e,t)=>{if(S++,x(t)){_();return}const c=(t instanceof Error?t.message:t===void 0?"":String(t)).replace(/\s+/g," ").trim().slice(0,120);r.setNotice(c===""?`${e} delayed`:`${e} delayed \u2014 ${c}`)},"reportFailure"),N=n(e=>{JSON.stringify(e)!==JSON.stringify(o)&&(o=e,r.renderFooter())},"setAsks");let g=!1,d=!1;const u=n(()=>{d=!0,!g&&(g=!0,(async()=>{try{for(;d&&!r.isTornDown();){d=!1;const e=S;try{const t=await f.panelView?.(w);t!==void 0&&N(t.counts),await r.refreshRoster(t),S===e&&F()}catch(t){l("canvas panel refresh",t)}r.refreshGraph()}}finally{g=!1,d&&!r.isTornDown()&&u()}})().catch(e=>l("canvas chrome refresh",e)))},"refresh"),O=n(async e=>{let t=e;const c=new Set([t]);for(;;){const m=(await f.subscribersOf(t).catch(()=>[]))[0]?.node_id;if(m===void 0||c.has(m))break;c.add(m),t=m}return t},"climbRootFromSource"),T=n(()=>{u(),r.refreshIdentity(),r.renderExtensionWidgets(),r.pollGit(),r.refreshInFlightTools(),r.renderFooter(),f.panelView===void 0&&(async()=>{const e=await O(w),t=await f.ticketCountsForView(e);JSON.stringify(t)!==JSON.stringify(o)&&(o=t,u(),r.renderFooter())})().catch(e=>l("canvas attention refresh",e))},"pollChrome"),A=n(()=>i===0?p:Math.min(p*2**i,I),"nextDelay");function D(e){y||a===void 0||(clearTimeout(a),h(e))}n(D,"rearm");function h(e){a=setTimeout(()=>{y||r.isTornDown()||(T(),h(A()))},e),typeof a.unref=="function"&&a.unref()}return n(h,"schedule"),{refresh:u,asks:n(()=>o,"asks"),reportFailure:l,daemonStalled:n(()=>i>0,"daemonStalled"),start:n(()=>{T(),h(p)},"start"),stop:n(()=>{y=!0,a!==void 0&&clearTimeout(a)},"stop")}}n(J,"createChromeRefresh");export{L as DAEMON_STALLED_NOTICE,J as createChromeRefresh,x as isTransientDaemonFailure};