@north-light/cli 0.3.707 → 0.3.708

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 (183) hide show
  1. package/dist/api/client.d.ts +1 -2
  2. package/dist/api/client.js +3 -3
  3. package/dist/api/contract.d.ts +1 -1
  4. package/dist/api/contract.js +1 -1
  5. package/dist/api/dto/human.d.ts +9 -6
  6. package/dist/api/dto/inbox.d.ts +2 -0
  7. package/dist/api/dto/review-comments.d.ts +12 -35
  8. package/dist/api/dto/reviews.d.ts +3 -10
  9. package/dist/api/routes.d.ts +0 -1
  10. package/dist/api/routes.js +1 -1
  11. package/dist/builtin-memory/05-kinds/review/companion/00-base.md +2 -2
  12. package/dist/builtin-memory/crouter-sdk/release-notes.md +6 -0
  13. package/dist/clients/attach/chrome/canvas-panels.d.ts +1 -1
  14. package/dist/clients/attach/chrome/canvas-panels.js +1 -1
  15. package/dist/clients/attach/chrome/roster.js +6 -6
  16. package/dist/clients/attach/chrome/status-line.js +1 -1
  17. package/dist/clients/attach/chrome/ticket-panel.js +1 -1
  18. package/dist/clients/attach/input/controller.d.ts +0 -1
  19. package/dist/clients/attach/input/controller.js +3 -3
  20. package/dist/clients/attach/input/overlay-owner.d.ts +0 -1
  21. package/dist/clients/attach/input/overlay-owner.js +1 -1
  22. package/dist/clients/attach/session/keys.d.ts +0 -2
  23. package/dist/clients/attach/session/keys.js +1 -1
  24. package/dist/clients/attach/session/surface-host.d.ts +0 -5
  25. package/dist/clients/attach/session/surface-host.js +1 -1
  26. package/dist/clients/attach/viewer.js +544 -559
  27. package/dist/clients/editor-roundtrip.js +3 -0
  28. package/dist/clients/inbox/controller.d.ts +1 -6
  29. package/dist/clients/inbox/controller.js +1 -1
  30. package/dist/clients/inbox/dto-adapt.js +1 -1
  31. package/dist/clients/inbox/tui/page-body.js +1 -1
  32. package/dist/clients/inbox/tui/render.js +2 -2
  33. package/dist/clients/open-browser.d.ts +2 -0
  34. package/dist/clients/open-browser.js +1 -0
  35. package/dist/clients/surfaces/host.d.ts +0 -6
  36. package/dist/commands/human/review.js +1 -1
  37. package/dist/commands/sys/context/admin/shell.js +1 -1
  38. package/dist/core/canvas/schema-pg/025-review-anchors.sql +19 -0
  39. package/dist/core/canvas/schema-version.d.ts +1 -1
  40. package/dist/core/canvas/schema-version.js +1 -1
  41. package/dist/core/human/page-markdown.js +10 -12
  42. package/dist/core/human/tickets.js +1 -1
  43. package/dist/core/human/types.d.ts +4 -6
  44. package/dist/core/keybindings/attach-control.d.ts +0 -3
  45. package/dist/core/keybindings/attach-control.js +1 -1
  46. package/dist/core/keybindings/catalog.d.ts +1 -1
  47. package/dist/core/keybindings/catalog.js +1 -1
  48. package/dist/core/review/anchors.d.ts +28 -0
  49. package/dist/core/review/anchors.js +6 -0
  50. package/dist/core/review/comments.d.ts +2 -2
  51. package/dist/core/review/comments.js +7 -8
  52. package/dist/core/review/companion.d.ts +2 -1
  53. package/dist/core/review/companion.js +1 -1
  54. package/dist/core/review/document.d.ts +4 -17
  55. package/dist/core/review/document.js +1 -2
  56. package/dist/core/review/fork.js +2 -4
  57. package/dist/core/review/project.d.ts +1 -1
  58. package/dist/core/review/project.js +2 -2
  59. package/dist/core/review/realize.js +1 -1
  60. package/dist/core/review/stage.d.ts +2 -9
  61. package/dist/core/review/stage.js +1 -1
  62. package/dist/core/review/types.d.ts +16 -12
  63. package/dist/core/review/types.js +1 -1
  64. package/dist/core/runtime/broker-cli.js +3 -3
  65. package/dist/core/runtime/broker-extension-render.js +1 -1
  66. package/dist/core/runtime/tmux-bindings.js +3 -3
  67. package/dist/daemon/api/canvas-host.js +1 -1
  68. package/dist/daemon/api/document-page.d.ts +12 -1
  69. package/dist/daemon/api/document-page.js +6 -6
  70. package/dist/daemon/api/handlers/inbox.js +1 -1
  71. package/dist/daemon/api/handlers/review-comments.js +1 -1
  72. package/dist/daemon/api/handlers/reviews.js +1 -1
  73. package/dist/daemon/api/map.js +2 -2
  74. package/dist/daemon/api/review-page.d.ts +3 -0
  75. package/dist/daemon/api/review-page.js +13 -0
  76. package/dist/daemon/broker-memory-cap.d.ts +9 -0
  77. package/dist/daemon/broker-memory-cap.js +2 -0
  78. package/dist/daemon/broker-signals/bus.d.ts +1 -1
  79. package/dist/daemon/broker-signals/bus.js +1 -1
  80. package/dist/daemon/crtrd.js +14 -14
  81. package/dist/daemon/machine-daemon.js +1 -1
  82. package/dist/daemon/review/comment-notify.js +2 -2
  83. package/dist/daemon/review/deliver.d.ts +2 -2
  84. package/dist/daemon/review/deliver.js +6 -2
  85. package/dist/daemon/review/finish.js +1 -1
  86. package/dist/doc-editor/Geist-Variable.woff2 +0 -0
  87. package/dist/doc-editor/GeistMono-Variable.woff2 +0 -0
  88. package/dist/doc-editor/editor.css +1 -1
  89. package/dist/doc-editor/review.css +2 -0
  90. package/dist/doc-editor/review.js +149 -0
  91. package/dist/pi-extensions/canvas-review-boundary.js +3 -3
  92. package/docs/sdk/release-notes.md +6 -0
  93. package/package.json +13 -4
  94. package/packages/crouter-api/dist/api/client.js +0 -3
  95. package/packages/crouter-api/dist/api/contract.js +1 -1
  96. package/packages/crouter-api/dist/api/routes.js +0 -1
  97. package/packages/crouter-api/dist/clients/attach/chrome/canvas-panels.js +3 -3
  98. package/packages/crouter-api/dist/clients/attach/chrome/roster.js +9 -20
  99. package/packages/crouter-api/dist/clients/attach/chrome/status-line.js +1 -6
  100. package/packages/crouter-api/dist/clients/attach/chrome/ticket-panel.js +1 -1
  101. package/packages/crouter-api/dist/clients/attach/input/controller.js +0 -3
  102. package/packages/crouter-api/dist/clients/attach/input/overlay-owner.js +0 -7
  103. package/packages/crouter-api/dist/clients/attach/session/keys.js +0 -1
  104. package/packages/crouter-api/dist/clients/attach/session/surface-host.js +0 -17
  105. package/packages/crouter-api/dist/clients/attach/viewer.js +0 -37
  106. package/packages/crouter-api/dist/clients/{inbox/review/roundtrip.js → editor-roundtrip.js} +1 -1
  107. package/packages/crouter-api/dist/clients/inbox/controller.js +12 -31
  108. package/packages/crouter-api/dist/clients/inbox/dto-adapt.js +1 -0
  109. package/packages/crouter-api/dist/clients/inbox/tui/page-body.js +0 -7
  110. package/packages/crouter-api/dist/clients/inbox/tui/render.js +0 -7
  111. package/packages/crouter-api/dist/clients/open-browser.js +6 -0
  112. package/packages/crouter-api/dist/commands/human/review.js +17 -18
  113. package/packages/crouter-api/dist/commands/sys/context/admin/shell.js +1 -1
  114. package/packages/crouter-api/dist/core/canvas/schema-version.js +1 -1
  115. package/packages/crouter-api/dist/core/human/page-markdown.js +2 -6
  116. package/packages/crouter-api/dist/core/human/tickets.js +2 -11
  117. package/packages/crouter-api/dist/core/keybindings/attach-control.js +0 -1
  118. package/packages/crouter-api/dist/core/keybindings/catalog.js +1 -3
  119. package/packages/crouter-api/dist/core/review/anchors.js +91 -0
  120. package/packages/crouter-api/dist/core/review/comments.js +27 -46
  121. package/packages/crouter-api/dist/core/review/companion.js +5 -9
  122. package/packages/crouter-api/dist/core/review/document.js +17 -89
  123. package/packages/crouter-api/dist/core/review/project.js +2 -1
  124. package/packages/crouter-api/dist/core/review/types.js +2 -2
  125. package/packages/crouter-api/dist/core/runtime/tmux-bindings.js +0 -5
  126. package/packages/crouter-api/dist/daemon/api/map.js +2 -6
  127. package/packages/crouter-api/dist/daemon/broker-signals/bus.js +1 -1
  128. package/packages/crouter-api/dist/daemon/review/deliver.js +4 -3
  129. package/packages/crouter-api/dist/daemon/review/finish.js +26 -47
  130. package/packages/crouter-api/package.json +1 -1
  131. package/packages/crouter-identity/package.json +1 -1
  132. package/packages/crouter-plugin/package.json +3 -3
  133. package/runtime.lock.json +1740 -505
  134. package/dist/clients/attach/overlays/file-review.d.ts +0 -10
  135. package/dist/clients/attach/overlays/file-review.js +0 -2
  136. package/dist/clients/inbox/review/anchors.d.ts +0 -41
  137. package/dist/clients/inbox/review/anchors.js +0 -1
  138. package/dist/clients/inbox/review/comments-client.d.ts +0 -74
  139. package/dist/clients/inbox/review/comments-client.js +0 -1
  140. package/dist/clients/inbox/review/companion-pane.d.ts +0 -47
  141. package/dist/clients/inbox/review/companion-pane.js +0 -1
  142. package/dist/clients/inbox/review/document-surface.d.ts +0 -212
  143. package/dist/clients/inbox/review/document-surface.js +0 -2
  144. package/dist/clients/inbox/review/frame.d.ts +0 -57
  145. package/dist/clients/inbox/review/frame.js +0 -1
  146. package/dist/clients/inbox/review/keys.d.ts +0 -69
  147. package/dist/clients/inbox/review/keys.js +0 -1
  148. package/dist/clients/inbox/review/launch.d.ts +0 -16
  149. package/dist/clients/inbox/review/launch.js +0 -1
  150. package/dist/clients/inbox/review/live-source.d.ts +0 -24
  151. package/dist/clients/inbox/review/live-source.js +0 -1
  152. package/dist/clients/inbox/review/nvim.d.ts +0 -15
  153. package/dist/clients/inbox/review/nvim.js +0 -1
  154. package/dist/clients/inbox/review/remap.d.ts +0 -51
  155. package/dist/clients/inbox/review/remap.js +0 -1
  156. package/dist/clients/inbox/review/review-client.d.ts +0 -43
  157. package/dist/clients/inbox/review/review-client.js +0 -1
  158. package/dist/clients/inbox/review/roundtrip.js +0 -3
  159. package/dist/clients/inbox/review/state.d.ts +0 -153
  160. package/dist/clients/inbox/review/state.js +0 -4
  161. package/dist/clients/inbox/review-adapter.d.ts +0 -17
  162. package/dist/clients/inbox/review-adapter.js +0 -1
  163. package/dist/core/review/remap.d.ts +0 -24
  164. package/dist/core/review/remap.js +0 -19
  165. package/dist/core/review/signal.d.ts +0 -5
  166. package/dist/core/review/signal.js +0 -1
  167. package/packages/crouter-api/dist/clients/attach/overlays/file-review.js +0 -146
  168. package/packages/crouter-api/dist/clients/inbox/review/anchors.js +0 -89
  169. package/packages/crouter-api/dist/clients/inbox/review/comments-client.js +0 -103
  170. package/packages/crouter-api/dist/clients/inbox/review/companion-pane.js +0 -109
  171. package/packages/crouter-api/dist/clients/inbox/review/document-surface.js +0 -1268
  172. package/packages/crouter-api/dist/clients/inbox/review/frame.js +0 -309
  173. package/packages/crouter-api/dist/clients/inbox/review/keys.js +0 -133
  174. package/packages/crouter-api/dist/clients/inbox/review/launch.js +0 -170
  175. package/packages/crouter-api/dist/clients/inbox/review/live-source.js +0 -160
  176. package/packages/crouter-api/dist/clients/inbox/review/nvim.js +0 -43
  177. package/packages/crouter-api/dist/clients/inbox/review/remap.js +0 -157
  178. package/packages/crouter-api/dist/clients/inbox/review/review-client.js +0 -125
  179. package/packages/crouter-api/dist/clients/inbox/review/state.js +0 -315
  180. package/packages/crouter-api/dist/clients/inbox/review-adapter.js +0 -43
  181. package/packages/crouter-api/dist/core/review/signal.js +0 -12
  182. package/packages/crouter-api/dist/core/termrender/code-doc.js +0 -92
  183. /package/dist/clients/{inbox/review/roundtrip.d.ts → editor-roundtrip.d.ts} +0 -0
@@ -32,7 +32,7 @@ import type { ChatInventoryDTO, ProspectiveChatInventoryDTO, ProspectiveChatInve
32
32
  import type { PersonSettingsDTO, PutPersonSettingsRequest } from './dto/settings.js';
33
33
  import type { CredentialRemovalResultDTO, CredentialResultDTO, InstallCredentialRequest, CompleteModelAuthFlowRequest, ModelAuthFlowCompletedDTO, ModelAuthFlowDTO, ModelAuthFlowStartedDTO, ModelAuthListDTO, ModelAuthProviderStatusDTO, PatchManagedAccountRequest, ModelAuthReadinessDTO, ModelAuthReadinessQuery, StartModelAuthFlowRequest } from './dto/modelauth.js';
34
34
  import type { CancelReviewRequest, CreateReviewRequest, ListReviewsQuery, ReviewCancelResultDTO, ReviewDocumentBaseDTO, ReviewDTO, ReviewListDTO, ReviewSubmitResultDTO } from './dto/reviews.js';
35
- import type { CreateReviewCommentRequest, EditReviewCommentRequest, ListReviewCommentsQuery, ReadReviewCommentEventsQuery, ReviewCommentActionRequest, ReviewCommentDetailDTO, ReviewCommentEventsDTO, ReviewCommentForkDTO, ReviewCommentListDTO, ReviewCommentMutationDTO, ReviewCommentRangeBatchRequest, ReviewCommentRangeBatchResultDTO } from './dto/review-comments.js';
35
+ import type { CreateReviewCommentRequest, EditReviewCommentRequest, ListReviewCommentsQuery, ReadReviewCommentEventsQuery, ReviewCommentActionRequest, ReviewCommentDetailDTO, ReviewCommentEventsDTO, ReviewCommentForkDTO, ReviewCommentListDTO, ReviewCommentMutationDTO } 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
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';
@@ -427,7 +427,6 @@ export declare class CrtrClient {
427
427
  createReviewComment(reviewId: string | undefined, req: CreateReviewCommentRequest): Promise<ReviewCommentMutationDTO>;
428
428
  listReviewComments(reviewId?: string, query?: ListReviewCommentsQuery): Promise<ReviewCommentListDTO>;
429
429
  readReviewCommentEvents(reviewId: string, query?: ReadReviewCommentEventsQuery): Promise<ReviewCommentEventsDTO>;
430
- updateReviewCommentRanges(reviewId: string, req: ReviewCommentRangeBatchRequest): Promise<ReviewCommentRangeBatchResultDTO>;
431
430
  getReviewComment(commentId: string): Promise<ReviewCommentDetailDTO>;
432
431
  editReviewComment(commentId: string, req: EditReviewCommentRequest): Promise<ReviewCommentMutationDTO>;
433
432
  resolveReviewComment(commentId: string, req?: ReviewCommentActionRequest): Promise<ReviewCommentMutationDTO>;
@@ -1,3 +1,3 @@
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)),{})}kickNode(e){return this.request("POST",r.nodeKick(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
+ 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 w(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 w(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 w(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 w(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)),{})}kickNode(e){return this.request("POST",r.nodeKick(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))}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 w(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 w(u,o?.deadlineAt)}catch(o){throw Q(e,q(o,s?.signal))}}async rawResponse(e,t,n){try{return await this.send(e,t,void 0,n)}catch(s){throw q(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):q(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 q(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 w(await this.transport(e,t,n,o))}catch(u){throw q(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 _=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,_,()=>h.signal.aborted?h.signal.reason:void 0)),y=>{throw _(),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 q(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 q(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=q(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 w(i,e){const t=i.status>=200&&i.status<300,n=(await C(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(w,"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 C(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 C(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(C,"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 q(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(q,"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.66";
2
+ export declare const CONTRACT_LEVEL = "1.67";
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.66",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.67",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,17 +1,20 @@
1
1
  /** One anchored review comment, mirroring crouter's canonical review result. */
2
2
  export interface FeedbackCommentDTO {
3
3
  id: string;
4
- line: number;
5
- endLine: number;
6
- quote?: string;
7
- colStart?: number;
8
- colEnd?: number;
9
- lineText: string;
4
+ quote: string;
10
5
  comment: string;
11
6
  createdAt: string;
7
+ resolved: boolean;
8
+ detached?: boolean;
12
9
  }
13
10
  /** Immutable daemon-projected review approval result. */
14
11
  export interface FeedbackResultDTO {
12
+ document: {
13
+ id: string;
14
+ name: string;
15
+ base_revision: string | null;
16
+ approved_revision: string | null;
17
+ } | null;
15
18
  file: string;
16
19
  submitted: true;
17
20
  approved: true;
@@ -20,6 +20,8 @@ export interface ReviewTicketSummaryDTO {
20
20
  subtitle: string;
21
21
  blocked_since: IsoTime;
22
22
  source: TicketSourceDTO;
23
+ /** The review page on the canvas host (`<CRTR_CANVAS_URL>/review/<id>`); absent when the daemon has no canvas host. */
24
+ url?: string;
23
25
  }
24
26
  /** One question's recommended option, flat on the wire like every other summary field. */
25
27
  export interface RecommendedOptionDTO {
@@ -1,14 +1,12 @@
1
1
  import type { IsoTime, NodeIdDTO } from './common.js';
2
2
  export type ReviewCommentStatusDTO = 'open' | 'resolved' | 'deleted';
3
3
  export type ReviewCommentDeliverDTO = 'wake' | 'quiet';
4
- export type ReviewCommentAnchorStateDTO = 'live' | 'detached';
5
- /** Caller-supplied source location for a comment or range remap. */
4
+ /** Selected text in the rendered document: the quote, up to 32 characters of context either side, and its offset when created. */
6
5
  export interface ReviewCommentAnchorDTO {
7
- line: number;
8
- end_line: number;
9
- col_start?: number;
10
- col_end?: number;
11
- quote?: string;
6
+ quote: string;
7
+ prefix?: string;
8
+ suffix?: string;
9
+ offset?: number;
12
10
  }
13
11
  /** Daemon-derived current comment projection. */
14
12
  export interface ReviewCommentDTO {
@@ -18,9 +16,11 @@ export interface ReviewCommentDTO {
18
16
  revision: number;
19
17
  text: string;
20
18
  anchor: ReviewCommentAnchorDTO;
21
- anchor_state: ReviewCommentAnchorStateDTO;
22
- anchor_line_text: string;
23
- anchor_doc_hash: string;
19
+ /** Rendered-text offsets of the quote in the current document; null when the text is gone. Set only where the daemon read the document. */
20
+ location?: {
21
+ start: number;
22
+ end: number;
23
+ } | null;
24
24
  author: {
25
25
  kind: 'human' | 'node';
26
26
  node_id?: NodeIdDTO;
@@ -35,11 +35,10 @@ export interface ReviewCommentDTO {
35
35
  deleted_at?: IsoTime;
36
36
  created_seq: number;
37
37
  }
38
- /** Caller-supplied body for comment creation. `doc_hash` is supplied by a rendered terminal surface; agent CLI creation omits it and the daemon verifies its current coordinate base instead. */
38
+ /** Caller-supplied body for comment creation. The quote must occur in the document's current rendered text. */
39
39
  export interface CreateReviewCommentRequest {
40
40
  text: string;
41
41
  anchor: ReviewCommentAnchorDTO;
42
- doc_hash?: string;
43
42
  actor_node_id?: NodeIdDTO | null;
44
43
  deliver?: ReviewCommentDeliverDTO;
45
44
  }
@@ -103,7 +102,7 @@ export interface ReviewCommentEventDTO {
103
102
  seq: number;
104
103
  review_id: string;
105
104
  comment_id: string;
106
- kind: 'created' | 'edited' | 'resolved' | 'reopened' | 'deleted' | 'reanchored' | 'notified' | 'notify_failed';
105
+ kind: 'created' | 'edited' | 'resolved' | 'reopened' | 'deleted' | 'notified' | 'notify_failed';
107
106
  state_change: boolean;
108
107
  revision_after: number | null;
109
108
  actor: {
@@ -114,28 +113,6 @@ export interface ReviewCommentEventDTO {
114
113
  operation_id: string;
115
114
  payload?: unknown;
116
115
  }
117
- /** Caller-supplied replacement location for one nondeleted comment. */
118
- export type ReviewCommentRangeEntryDTO = {
119
- comment_id: string;
120
- anchor: ReviewCommentAnchorDTO;
121
- } | {
122
- comment_id: string;
123
- detached: true;
124
- };
125
- /** Caller-supplied atomic full-set range remap body. */
126
- export interface ReviewCommentRangeBatchRequest {
127
- from_doc_hash: string;
128
- to_doc_hash: string;
129
- entries: ReviewCommentRangeEntryDTO[];
130
- }
131
- /** Daemon-derived result of an atomic full-set range remap. */
132
- export interface ReviewCommentRangeBatchResultDTO {
133
- review_id: string;
134
- anchor_base_sha256: string;
135
- updated: number;
136
- detached: number;
137
- unchanged: number;
138
- }
139
116
  /** Daemon-derived result of forking the review companion onto one comment. */
140
117
  export interface ReviewCommentForkDTO {
141
118
  comment_id: string;
@@ -9,16 +9,9 @@ export interface CreateReviewRequest {
9
9
  origin_kind: ReviewOriginKindDTO;
10
10
  /** Caller-selected node whose persisted session is forked. */
11
11
  origin_node_id: NodeIdDTO;
12
- /** The document to review, as a canvas ref (`[[ ]]` optional) — required for ticket reviews,
13
- * and the alternative to `file` for inline ones. The daemon reads it as the caller, snapshots
14
- * its head to `<review_dir>/document.md`, and on submit saves the reviewed text as a new
15
- * revision (refused as `stale_revision` if it moved). */
16
- document?: string;
17
- /** Inline reviews of a file: an absolute path; the daemon canonicalizes and validates it.
18
- * An inline review takes exactly one of `file` or `document`. */
19
- file?: string;
20
- /** Inline reviews on a control plane that cannot read the caller's disk: the id of an upload the caller's CLI made of the file. Exclusive with `file` and `document`. */
21
- file_upload_id?: string;
12
+ /** The document to review, as a canvas ref (`[[ ]]` optional). The daemon reads it as the caller
13
+ * and snapshots its head as the review's base text. */
14
+ document: string;
22
15
  /** Caller-minted invocation key; the daemon enforces its uniqueness. */
23
16
  idempotency_key: string;
24
17
  /** Caller-supplied ticket subtitle; required for ticket origins. */
@@ -130,7 +130,6 @@ export declare const routes: {
130
130
  readonly humanReviewDocument: (reviewId: string) => string;
131
131
  readonly humanReviewComments: (reviewId: string) => string;
132
132
  readonly humanReviewCommentEvents: (reviewId: string) => string;
133
- readonly humanReviewCommentRanges: (reviewId: string) => string;
134
133
  readonly humanComment: (commentId: string) => string;
135
134
  readonly humanCommentEdit: (commentId: string) => string;
136
135
  readonly humanCommentResolve: (commentId: string) => 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"),nodeKick:o(e=>`/v1/nodes/${e}/kick`,"nodeKick"),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
+ 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"),nodeKick:o(e=>`/v1/nodes/${e}/kick`,"nodeKick"),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"),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};
@@ -12,9 +12,9 @@ surfaces:
12
12
  ## When reviewing with a person
13
13
  When a person opens this review, think with them live about this one document and answer from the context you already carry, so the review can move without reconstructing the origin's work.
14
14
 
15
- When deciding what to change, edit only the reviewed document and keep the inherited task with its origin, so the review remains a focused collaboration rather than a resumed task.
15
+ When deciding what to change, edit only the reviewed document — a canvas document, revised with `crtr doc edit` (read it with `crtr canvas read` first; the person sees each edit on their page at once) — and keep the inherited task with its origin, so the review remains a focused collaboration rather than a resumed task.
16
16
 
17
- When the person leaves a comment, treat it as feedback to act on: address it by editing the reviewed document, then resolve it, and reply in this conversation when something needs discussion. Never create, edit, or delete comments of your own — comments are the person's channel for feedback on the document; your channels are the document itself and this chat. Read `crtr human review comment … -h` for exact syntax.
17
+ When the person leaves a comment, treat it as feedback to act on: address it by editing the reviewed document with `crtr doc edit`, then resolve it — the comment stays anchored to its quoted text through your edit, and detaches only if you delete that text — and reply in this conversation when something needs discussion. Never create, edit, or delete comments of your own — comments are the person's channel for feedback on the document; your channels are the document itself and this chat. Read `crtr human review comment … -h` for exact syntax.
18
18
 
19
19
  When a question needs real research, delegate it to a child node and keep talking with the person while it runs, so the review remains responsive without guessing.
20
20
 
@@ -9,6 +9,12 @@ when-and-why-to-read: When you need Release notes, this knowledge should be read
9
9
 
10
10
  Changes to `@north-light/sdk` that can change what an existing app sees. Newest first.
11
11
 
12
+ ## 0.3.708
13
+
14
+ ### Review comments anchor to quoted text (breaking)
15
+
16
+ Review comments carry `anchor: { quote, prefix?, suffix?, offset? }` instead of line numbers, and the `comment-ranges` route is removed. Reviews opened under the old shape are canceled at cutover. Reviews are read and approved in the browser at `/review/<id>` on the canvas host.
17
+
12
18
  ## 0.3.694
13
19
 
14
20
  ### The owner's daemon routes are no longer wrapped (breaking for code that calls them)
@@ -12,7 +12,7 @@ export type CanvasPanelItem = {
12
12
  } | {
13
13
  key: string;
14
14
  kind: 'review';
15
- companionNodeId: string;
15
+ reviewId: string;
16
16
  line: string;
17
17
  } | {
18
18
  key: 'bash';
@@ -1 +1 @@
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
+ 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 wn,fillWidth as C,RESET as m,DIM as E,GREEN as pn}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 On(s,a){return s.length>=a?s.slice(0,a):" ".repeat(a-s.length)+s}i(On,"padStartVisible");async function In(s,a,c,p,X=[],R=[],Y=[],y,Z){const S=p instanceof yn,h=Z,b=h===void 0?null:new Map(h.nodes.map(n=>[n.node_id,n])),M=new Map,O=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),O.has(n.to_id)||O.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?p.getNode(n).catch(()=>null):Promise.resolve(b.get(n)??null);return B.set(n,e),e},"node"),nn=i(n=>p.getNode(n).catch(()=>null),"detail"),j=i(n=>{const t=I.get(n);if(t!==void 0)return t;const e=(async()=>{const o=b===null?(await p.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?p.subscribersOf(n).then(o=>o[0]?.node_id).catch(()=>{}):Promise.resolve(O.get(n));return x.set(n,e),e},"managerOf"),D=i(async n=>{const t=[];for(const e of await j(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 w of await j(o))r+=await e(w);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 j(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?` ${pn}\u21E3${t}${m}`:""},"liveBelowBadgeFor"),$=c?.muted??(n=>n),an=c?.faint??(n=>n);await en(await tn(s));const l=await A(s),N=await D(s),k=[...l!==void 0?[l]:[],...N],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),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?"":` ${E}\xB7 ${w.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=$(On(mn(e,S),Mn)),w=`${hn(e)}${await on(e)}${sn(e)}${wn(n,a)}${await rn(n,e)}`,u=` ${t} ${ln(e)} ${o} ${d} ${r}${w}`;return fn(u)},"row"),dn=[...l!==void 0?[l]:[],...N],f=[];l!==void 0&&f.push({key:`node:${l}`,kind:"node",nodeId:l,line:await T(l,"\u2191")});for(const n of N)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",reviewId:n.review_id,line:` ${t} ${$(`${e} \xB7 \u21B5 open`)}${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,6 +1,6 @@
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
- `)[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===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
+ var P=Object.defineProperty;var o=(v,n)=>P(v,"name",{value:n,configurable:!0});import{execFile as x}from"node:child_process";import{Text as U,decodeKittyPrintable as V,matchesKey as R}from"@earendil-works/pi-tui";import{cliClient as y}from"../../../commands/api-client.js";import{daemonErrorMessage as C}from"../../inbox/resolve.js";import{openBrowser as D}from"../../open-browser.js";import{toBashJobStatus as K}from"./bash-jobs.js";import{fillBar as F,fillWidth as L,stripSgr as W,REVERSE as X}from"../../../core/canvas/nav-render.js";import{buildCanvasPanelLines as z}from"./canvas-panels.js";const G=15e3;function ce(v,n){const{editor:k,tui:B,pal:E,nodeId:a,remote:f,role:I,canvasSource:N}=v,T=v.containers.reports;let s=[],r,h=process.env.CRTR_ATTACH_ROSTER;h!==void 0&&delete process.env.CRTR_ATTACH_ROSTER;let u,g;const m=o(()=>{n.syncCursor(),T.clear();for(const e of s){const i=e.key===r;T.addChild(new U(i?F(W(e.line),L(),X):e.line,1,0))}B.requestRender()},"paint"),j=o(async()=>(await y().listBashJobs(a)).map(K),"listJobs"),A=o(async e=>{const i=f?[]:await y().listCrons(),d=i.filter(c=>c.created_by===a),t=f?[]:await j(),p=f?[]:(await y().listReviews({state:"open"})).reviews,w=p.filter(c=>c.origin_node_id===a),H=f?void 0:{crons:i,reviews:p,jobsOf:o(async c=>(await y().listBashJobs(c)).map(K),"jobsOf")};if(s=(await z(a,n.asks(),E,N,d,t,w,H,e??await N.panelView?.(a))).items,h!==void 0){const c=h;h=void 0;const _=s.find($=>$.kind==="node"&&$.nodeId===c);_!==void 0&&(r=_.key)}r!==void 0&&!s.some(c=>c.key===r)&&(r=void 0),u!==void 0&&!t.some(c=>c.jobId===u?.jobId)&&b(!0),m()},"refresh"),b=o(e=>{g!==void 0&&(clearTimeout(g),g=void 0),u!==void 0&&(u=void 0,e&&n.setNotice(""))},"disarmKill"),l=o(()=>{b(!0),r!==void 0&&(r=void 0,m())},"exit"),S=o(e=>V(e)??(e.length===1?e:void 0),"typed"),q=o((e,i=40)=>{const d=(e.split(`
2
+ `)[0]??"").replace(/\s+/g," ").trim();return d.length>i?`${d.slice(0,i-1)}\u2026`:d},"commandHead"),J=o(async()=>{if(I!=="controller"){n.setNotice("Read-only observer attach \u2014 cannot stop background jobs");return}const e=await j();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:q(i.command)},n.setNotice(`Stop \u201C${u.label}\u201D? Press y to confirm.`,{sticky:!0}),g=setTimeout(()=>b(!0),G)},"armKill"),M=o(()=>{const e=u;e!==void 0&&(b(!1),n.setNotice(`Stopping \u201C${e.label}\u201D\u2026`),x("crtr",["node","bash","kill",e.jobId,"--node",a],i=>{n.setNotice(i===null?`Stopped \u201C${e.label}\u201D.`:`Could not stop the job: ${i.message.split(`
3
+ `)[0]}`),n.requestChromeRefresh()}))},"confirmKill");k.onCursorDownAtBottom=f?void 0:()=>{r!==void 0||s.length===0||(r=s[0].key,m())};const O=o(()=>{const e=s.find(t=>t.key===r);if(e===void 0||f)return;if(e.kind==="crons"){l(),n.openInspector("schedule");return}if(e.kind==="review"){l(),(async()=>{const t=(await y().listHumanInbox()).tickets.find(p=>p.kind==="review"&&p.request_id===e.reviewId);if(t?.kind!=="review"||t.url===void 0){n.setNotice("Reviews open on canvas.northlight.ai; this runtime has no canvas host");return}D(t.url)})().catch(t=>n.setNotice(`Could not open the review: ${C(t).split(`
4
+ `)[0]}`));return}if(e.kind==="bash"){j().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: ${C(t).split(`
5
+ `)[0]}`));return}if(e.kind==="object-wait"){l(),n.openObject(e.objectId);return}const i=e.nodeId;if(i===a){l();return}if(I!=="controller"){n.setNotice("Read-only observer attach \u2014 cannot focus nodes");return}const d=process.env.TMUX_PANE;if(d===void 0||d===""){n.setNotice("cannot swap \u2014 no tmux pane");return}x("tmux",["run-shell","-b",`crtr surface node focus ${i} --pane ${d} --in-place >/dev/null 2>&1`],()=>{})},"openSelected");return{refresh:A,handleKey:o(e=>{if(f)return!1;const i=R(e,"down"),d=R(e,"up");if(r===void 0)return!1;const t=s.findIndex(w=>w.key===r),p=s[t];if(u!==void 0){if(S(e)==="y")return M(),!0;b(!0)}return p?.kind==="bash"&&S(e)==="x"?(J().catch(w=>n.setNotice(`Could not list background jobs: ${C(w).split(`
6
+ `)[0]}`)),!0):d?(t<=0?l():(r=s[t-1].key,m()),!0):i?(t>=0&&t<s.length-1&&(r=s[t+1].key,m()),!0):R(e,"enter")?(O(),!0):R(e,"escape")?(l(),!0):(l(),!1)},"handleKey"),active:o(()=>r!==void 0,"active"),exit:l}}o(ce,"createRoster");export{ce as createRoster};
@@ -1 +1 @@
1
- var L=Object.defineProperty;var r=(n,i)=>L(n,"name",{value:i,configurable:!0});import{Text as N,truncateToWidth as O}from"@earendil-works/pi-tui";import{visibleWidth as g}from"../../../core/canvas/nav-render.js";import{inTmux as S}from"../../../core/runtime/placement-tmux.js";import{formatBinding as W,inboxOpenHint as _}from"../../../core/keybindings/index.js";import{viewerKeyHint as j}from"./key-hint.js";const q=3e3,F=r(n=>n>=1e3?`${(n/1e3).toFixed(n>=1e4?0:1)}k`:`${n}`,"formatTokens");function G(n,i){const{pal:e,tui:w,nodeId:H,remote:I}=n,x=n.containers.footer;let u="",d;const m=r(()=>{const o=i.state(),a=i.bashMode(),f=i.bindings(),t=[];o.role!=="controller"&&t.push(e.muted("\u25CB read-only")),a===2?t.unshift(e.bashModeAlt("\u25CF bash \u2014 output hidden from agent")):a===1&&t.unshift(e.bashMode("\u25CF bash \u2014 output added to context"));const s=o.engine;s?.model&&t.push(e.info(s.model.id)),s?.isStreaming&&t.push(e.active("\u27F3")),o.contextTokens!==void 0&&t.push(e.muted(`${F(o.contextTokens)} ctx`)),s&&s.pendingMessageCount>0&&t.push(e.muted(`queued ${s.pendingMessageCount}`));let T=!1;if(i.inboxAffordance){const v=Object.values(i.asks()).reduce((y,E)=>y+E,0);v>0&&(T=!0,t.push(e.muted(`\u2691 ${v} \xB7 ${_(f)}`)))}i.mouseEnabled()||t.push(e.muted("mouse off")),S()&&f.gestures("crtr.attach.file-review").length>0&&t.push(e.muted(`${W(f,"crtr.attach.file-review")} review file`)),i.inboxAffordance&&t.push(e.muted(j(f,{inbox:!T})));const l=t.join(e.muted(" \xB7 ")),c=u?e.warning(`\u26A0 ${u}`):"",p=Math.max(1,(process.stdout.columns??80)-2),M=g(c),$=c?Math.max(0,p-M-1):p,h=g(l)>$?O(l,$,"\u2026"):l,C=Math.max(c?1:0,p-g(h)-M),A=c?h+" ".repeat(C)+c:h;x.clear(),x.addChild(new N(A,1,0)),w.requestRender()},"render"),b=r(()=>{d!==void 0&&(clearTimeout(d),d=void 0)},"clearTimer");return{render:m,setNotice:r((o,a)=>{u=o,b(),o&&!a?.sticky&&(d=setTimeout(()=>{d=void 0,u="",m()},q)),m()},"setNotice"),dispose:b}}r(G,"createStatusLine");export{G as createStatusLine};
1
+ var L=Object.defineProperty;var d=(n,o)=>L(n,"name",{value:o,configurable:!0});import{Text as N,truncateToWidth as O}from"@earendil-works/pi-tui";import{visibleWidth as h}from"../../../core/canvas/nav-render.js";import{inboxOpenHint as S}from"../../../core/keybindings/index.js";import{viewerKeyHint as W}from"./key-hint.js";const _=3e3,j=d(n=>n>=1e3?`${(n/1e3).toFixed(n>=1e4?0:1)}k`:`${n}`,"formatTokens");function z(n,o){const{pal:e,tui:v,nodeId:q,remote:F}=n,b=n.containers.footer;let r="",c;const f=d(()=>{const i=o.state(),a=o.bashMode(),g=o.bindings(),t=[];i.role!=="controller"&&t.push(e.muted("\u25CB read-only")),a===2?t.unshift(e.bashModeAlt("\u25CF bash \u2014 output hidden from agent")):a===1&&t.unshift(e.bashMode("\u25CF bash \u2014 output added to context"));const s=i.engine;s?.model&&t.push(e.info(s.model.id)),s?.isStreaming&&t.push(e.active("\u27F3")),i.contextTokens!==void 0&&t.push(e.muted(`${j(i.contextTokens)} ctx`)),s&&s.pendingMessageCount>0&&t.push(e.muted(`queued ${s.pendingMessageCount}`));let M=!1;if(o.inboxAffordance){const C=Object.values(o.asks()).reduce((y,E)=>y+E,0);C>0&&(M=!0,t.push(e.muted(`\u2691 ${C} \xB7 ${S(g)}`)))}o.mouseEnabled()||t.push(e.muted("mouse off")),o.inboxAffordance&&t.push(e.muted(W(g,{inbox:!M})));const m=t.join(e.muted(" \xB7 ")),u=r?e.warning(`\u26A0 ${r}`):"",l=Math.max(1,(process.stdout.columns??80)-2),T=h(u),$=u?Math.max(0,l-T-1):l,p=h(m)>$?O(m,$,"\u2026"):m,A=Math.max(u?1:0,l-h(p)-T),w=u?p+" ".repeat(A)+u:p;b.clear(),b.addChild(new N(w,1,0)),v.requestRender()},"render"),x=d(()=>{c!==void 0&&(clearTimeout(c),c=void 0)},"clearTimer");return{render:f,setNotice:d((i,a)=>{r=i,x(),i&&!a?.sticky&&(c=setTimeout(()=>{c=void 0,r="",f()},_)),f()},"setNotice"),dispose:x}}d(z,"createStatusLine");export{z as createStatusLine};