@crouter/api 0.3.377

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 (112) hide show
  1. package/README.md +67 -0
  2. package/dist/api/__tests__/error-codes.test.d.ts +1 -0
  3. package/dist/api/__tests__/error-codes.test.js +78 -0
  4. package/dist/api/__tests__/integration/client.test.d.ts +1 -0
  5. package/dist/api/__tests__/integration/client.test.js +179 -0
  6. package/dist/api/client.d.ts +467 -0
  7. package/dist/api/client.js +1179 -0
  8. package/dist/api/command-manifest/index.d.ts +3 -0
  9. package/dist/api/command-manifest/index.js +3 -0
  10. package/dist/api/command-manifest/manifest.d.ts +51 -0
  11. package/dist/api/command-manifest/manifest.js +332 -0
  12. package/dist/api/command-manifest/result.d.ts +25 -0
  13. package/dist/api/command-manifest/result.js +97 -0
  14. package/dist/api/command-manifest/schema.d.ts +28 -0
  15. package/dist/api/command-manifest/schema.js +856 -0
  16. package/dist/api/dto/analytics.d.ts +184 -0
  17. package/dist/api/dto/analytics.js +3 -0
  18. package/dist/api/dto/attach.d.ts +22 -0
  19. package/dist/api/dto/attach.js +13 -0
  20. package/dist/api/dto/bash-jobs.d.ts +24 -0
  21. package/dist/api/dto/bash-jobs.js +9 -0
  22. package/dist/api/dto/bash.d.ts +17 -0
  23. package/dist/api/dto/bash.js +1 -0
  24. package/dist/api/dto/broker-ops.d.ts +187 -0
  25. package/dist/api/dto/broker-ops.js +6 -0
  26. package/dist/api/dto/broker-signals.d.ts +25 -0
  27. package/dist/api/dto/broker-signals.js +1 -0
  28. package/dist/api/dto/broker.d.ts +86 -0
  29. package/dist/api/dto/broker.js +20 -0
  30. package/dist/api/dto/canvas.d.ts +359 -0
  31. package/dist/api/dto/canvas.js +2 -0
  32. package/dist/api/dto/chat-inventory.d.ts +56 -0
  33. package/dist/api/dto/chat-inventory.js +11 -0
  34. package/dist/api/dto/common.d.ts +29 -0
  35. package/dist/api/dto/common.js +15 -0
  36. package/dist/api/dto/config.d.ts +36 -0
  37. package/dist/api/dto/config.js +3 -0
  38. package/dist/api/dto/crons.d.ts +150 -0
  39. package/dist/api/dto/crons.js +10 -0
  40. package/dist/api/dto/custom-objects.d.ts +66 -0
  41. package/dist/api/dto/custom-objects.js +1 -0
  42. package/dist/api/dto/delivery.d.ts +71 -0
  43. package/dist/api/dto/delivery.js +7 -0
  44. package/dist/api/dto/docs.d.ts +135 -0
  45. package/dist/api/dto/docs.js +8 -0
  46. package/dist/api/dto/files.d.ts +21 -0
  47. package/dist/api/dto/files.js +1 -0
  48. package/dist/api/dto/focus.d.ts +24 -0
  49. package/dist/api/dto/focus.js +10 -0
  50. package/dist/api/dto/grants.d.ts +14 -0
  51. package/dist/api/dto/grants.js +1 -0
  52. package/dist/api/dto/health.d.ts +106 -0
  53. package/dist/api/dto/health.js +2 -0
  54. package/dist/api/dto/human-requests.d.ts +113 -0
  55. package/dist/api/dto/human-requests.js +4 -0
  56. package/dist/api/dto/human.d.ts +28 -0
  57. package/dist/api/dto/human.js +4 -0
  58. package/dist/api/dto/inbox.d.ts +273 -0
  59. package/dist/api/dto/inbox.js +4 -0
  60. package/dist/api/dto/lifecycle.d.ts +88 -0
  61. package/dist/api/dto/lifecycle.js +3 -0
  62. package/dist/api/dto/mail.d.ts +44 -0
  63. package/dist/api/dto/mail.js +1 -0
  64. package/dist/api/dto/messages.d.ts +88 -0
  65. package/dist/api/dto/messages.js +2 -0
  66. package/dist/api/dto/model-config.d.ts +25 -0
  67. package/dist/api/dto/model-config.js +1 -0
  68. package/dist/api/dto/modelauth.d.ts +132 -0
  69. package/dist/api/dto/modelauth.js +4 -0
  70. package/dist/api/dto/node-events.d.ts +65 -0
  71. package/dist/api/dto/node-events.js +4 -0
  72. package/dist/api/dto/node-outcomes.d.ts +88 -0
  73. package/dist/api/dto/node-outcomes.js +2 -0
  74. package/dist/api/dto/node-records.d.ts +35 -0
  75. package/dist/api/dto/node-records.js +5 -0
  76. package/dist/api/dto/nodes.d.ts +368 -0
  77. package/dist/api/dto/nodes.js +3 -0
  78. package/dist/api/dto/objects.d.ts +172 -0
  79. package/dist/api/dto/objects.js +5 -0
  80. package/dist/api/dto/profiles.d.ts +117 -0
  81. package/dist/api/dto/profiles.js +4 -0
  82. package/dist/api/dto/recovery.d.ts +104 -0
  83. package/dist/api/dto/recovery.js +1 -0
  84. package/dist/api/dto/reports.d.ts +93 -0
  85. package/dist/api/dto/reports.js +2 -0
  86. package/dist/api/dto/review-comments.d.ts +146 -0
  87. package/dist/api/dto/review-comments.js +5 -0
  88. package/dist/api/dto/reviews.d.ts +113 -0
  89. package/dist/api/dto/reviews.js +5 -0
  90. package/dist/api/dto/run-events.d.ts +293 -0
  91. package/dist/api/dto/run-events.js +6 -0
  92. package/dist/api/dto/subscriptions.d.ts +14 -0
  93. package/dist/api/dto/subscriptions.js +2 -0
  94. package/dist/api/dto/worktree.d.ts +55 -0
  95. package/dist/api/dto/worktree.js +6 -0
  96. package/dist/api/error-codes.d.ts +254 -0
  97. package/dist/api/error-codes.js +54 -0
  98. package/dist/api/errors.d.ts +47 -0
  99. package/dist/api/errors.js +66 -0
  100. package/dist/api/index.d.ts +42 -0
  101. package/dist/api/index.js +41 -0
  102. package/dist/api/node-transport.d.ts +18 -0
  103. package/dist/api/node-transport.js +105 -0
  104. package/dist/api/plugin-manifest-schema.d.ts +233 -0
  105. package/dist/api/plugin-manifest-schema.js +23 -0
  106. package/dist/api/routes.d.ts +160 -0
  107. package/dist/api/routes.js +193 -0
  108. package/dist/shared/generated-context.d.ts +79 -0
  109. package/dist/shared/generated-context.js +232 -0
  110. package/dist/shared/predicates.d.ts +2 -0
  111. package/dist/shared/predicates.js +4 -0
  112. package/package.json +49 -0
@@ -0,0 +1,467 @@
1
+ import type { DaemonAdmitDTO, DaemonRestartDTO, HealthDTO, MigrateStateDTO, MigrateStateRequest, StatusDTO } from './dto/health.js';
2
+ import type { BashJobStatusDTO, BashJobStopResultDTO } from './dto/bash-jobs.js';
3
+ import type { ContextListDTO, CreateNodeRequest, ListNodesQuery, NodeDetailDTO, NodeMessagesPageDTO, NodeMessagesQuery, NodeSessionDTO, NodeSnapshotDTO, NodeSubjectDTO, NodeSummaryDTO, TranscriptDTO, TranscriptQuery } from './dto/nodes.js';
4
+ import type { NodeOutcomeResponseDTO, OutcomeDeliveryDTO, RegisterOutcomeDeliveryRequest } from './dto/node-outcomes.js';
5
+ import type { AnalyticsDTO, AnalyticsQuery, MemoryReadsRequestDTO } from './dto/analytics.js';
6
+ import type { NodeEventsQuery } from './dto/node-events.js';
7
+ import type { BrokerSignalLineDTO } from './dto/broker-signals.js';
8
+ import type { NodeLogAppendRequest, NodeLogAppendResultDTO, NodeTelemetryRecordRequest, NodeRecapRecordRequest, NodeMessageBodyDTO, NodePushedFinalRequest, NodePushedFinalResultDTO } from './dto/node-records.js';
9
+ import type { InterruptResultDTO, MessageResultDTO, SendMessageRequest } from './dto/messages.js';
10
+ import type { PushReportRequest, PushReportResultDTO, ReportDTO, ReportsQuery, SubmitResultDTO, SubmitResultRequest } from './dto/reports.js';
11
+ import type { CloseRequest, CloseResultDTO, PromoteRequest, RelaunchRootResultDTO, ReviveRequest, ReviveResultDTO, WaitRequest, YieldRequest } from './dto/lifecycle.js';
12
+ import type { SubscribeRequest, SubscriptionDTO } from './dto/subscriptions.js';
13
+ import type { FocusDTO, RegisterFocusRequest, SetFocusPaneRequest } from './dto/focus.js';
14
+ import { type ArmCronRequest, type CancelCronQuery, type CronDTO, type CronRunDTO, type CronScopeQuery, type CronShowDTO, type ListCronsQuery, type PokeCronsResult } from './dto/crons.js';
15
+ import type { KindListDTO, NodeConfigPatch } from './dto/config.js';
16
+ import type { AttachEnsureRequest, AttachEnsureResultDTO } from './dto/attach.js';
17
+ import type { CreateProfileRequest, DeleteProfileRequest, DeleteProfileResultDTO, EnsureProfileRequest, ProfileDTO, ProfileEnvChangeDTO, ProfileEnvNamesDTO, ProfilePauseResultDTO, UpdateProfileMetadataRequest, UpdateProfileRequest } from './dto/profiles.js';
18
+ import type { FileEncoding, FileListDTO, FilePeekDTO, FileWriteDTO } from './dto/files.js';
19
+ import type { BashRunDTO, BashRunParams } from './dto/bash.js';
20
+ import type { EdgesDTO, EdgesQuery, ObjectListDTO, ObjectListRequest, ObjectReadDTO, ObjectReadQuery, ObjectSearchDTO, ObjectSearchRequest, UnwatchQuery, UnwatchResultDTO, WatchRequest, WatchResultDTO } from './dto/objects.js';
21
+ import type { DocDeletedDTO, DocEditRequest, DocEditedDTO, DocHistoryDTO, DocHistoryQuery, DocLintDTO, DocLintRequest, DocMoveRequest, DocMovedDTO, DocWriteRequest, DocWrittenDTO, ReconcilePackagesDTO } from './dto/docs.js';
22
+ import type { BackgroundedJobDTO, BackgroundedJobRequest, DeliveryDryRunRequest, DeliveryRequest, DeliveryResponse } from './dto/delivery.js';
23
+ import type { ChatInventoryDTO, ProspectiveChatInventoryDTO, ProspectiveChatInventoryQuery } from './dto/chat-inventory.js';
24
+ import type { CredentialRemovalResultDTO, CredentialResultDTO, InstallCredentialRequest, CompleteModelAuthFlowRequest, ModelAuthFlowCompletedDTO, ModelAuthFlowDTO, ModelAuthFlowStartedDTO, ModelAuthListDTO, ModelAuthReadinessDTO, ModelAuthReadinessQuery, StartModelAuthFlowRequest } from './dto/modelauth.js';
25
+ import type { CancelReviewRequest, CreateReviewRequest, ListReviewsQuery, ReviewCancelResultDTO, ReviewDocumentBaseDTO, ReviewDTO, ReviewListDTO, ReviewSubmitResultDTO } from './dto/reviews.js';
26
+ import type { CreateReviewCommentRequest, EditReviewCommentRequest, ListReviewCommentsQuery, ReadReviewCommentEventsQuery, ReviewCommentActionRequest, ReviewCommentDetailDTO, ReviewCommentEventsDTO, ReviewCommentForkDTO, ReviewCommentListDTO, ReviewCommentMutationDTO, ReviewCommentRangeBatchRequest, ReviewCommentRangeBatchResultDTO } from './dto/review-comments.js';
27
+ import type { CancelInboxTicketRequest, CanceledTicketResultDTO, InboxListDTO, InboxPageDTO, InboxPageHistoryDTO, InboxPageResponseDTO, InboxTicketIdDTO, PageFeedbackResolutionDTO, PageResponsesDTO, PageTicketResultDTO, RespondInboxPageRequest } from './dto/inbox.js';
28
+ import type { CreateHumanRequestDTO, CreateHumanRequestRequest, HumanRequestDTO, HumanRequestIdDTO, ReplaceHumanRequestRequest, RespondHumanRequestRequest, SettleHumanRequestRequest, PageComponentListDTO } from './dto/human-requests.js';
29
+ import type { AttentionCountsDTO, AttentionDTO, DashboardDTO, DashboardQuery, HistoryGrepQuery, HistoryGrepResultDTO, HistoryReadQuery, HistoryStatsQuery, HistoryStatsResultDTO, HistoryReadResultDTO, HistorySearchQuery, HistorySearchResultDTO, GraphDTO, PruneRequest, PruneResultDTO, RosterDTO, SnapshotDTO } from './dto/canvas.js';
30
+ import type { AbandonWorktreeRequest, AbandonWorktreeResultDTO, CloseWorktreeResultDTO, QuarantinedWorktreeDTO, SpaceListDTO } from './dto/worktree.js';
31
+ import type { BrokerExtensionStateDTO, BrokerExecutionRequest, BrokerGeneratedNameRequest, BrokerGeneratedNameResultDTO, BrokerModelCommitRequest, BrokerModelCommitResultDTO, BrokerParkActivityResultDTO, BrokerParkCompleteRequest, BrokerPersonaAckRequest, BrokerPersonaAckResultDTO, BrokerSessionBoundRequest, BrokerSessionBoundResultDTO, BrokerSettleDirective, BrokerSettleRequest, BrokerTelemetryRequest } from './dto/broker-ops.js';
32
+ import type { AcknowledgeMailRequest, AcknowledgeMailResultDTO, ClaimMailRequest, ClaimMailResultDTO } from './dto/mail.js';
33
+ import type { BrokerFaultInputDTO, BrokerFaultRequest, BrokerFaultResultDTO, BrokerProviderRetryRequest, BrokerProviderRetryResultDTO, BrokerTurnRequest, BrokerTurnResultDTO, NodeFaultClearResultDTO, RecoveryStateDTO } from './dto/recovery.js';
34
+ export interface CrtrClientOptions {
35
+ /** `http(s)://host:port` for a TCP/remote transport. */
36
+ baseUrl: string;
37
+ /** Fetch implementation. The global Web fetch is used unless a caller supplies one. */
38
+ fetch?: typeof fetch;
39
+ /** Extra headers, e.g. `{ authorization: 'Bearer <token>' }` when the target
40
+ * crtrd's TCP listener has `CRTRD_TOKEN` set (unix-socket transport is
41
+ * never checked, and a TCP daemon with no token set ignores this too). */
42
+ headers?: Record<string, string>;
43
+ /** Retry a cold local connection through this hook once when enabled. */
44
+ autostart?: boolean;
45
+ /** Maximum retries for transient GET, HEAD, and DELETE requests. Defaults to 2. */
46
+ maxRetries?: number;
47
+ /** Per-request timeout in ms (default 30_000). */
48
+ timeoutMs?: number;
49
+ /** Injected daemon-start hook (spec §7.1). Called once on a cold socket when
50
+ * autostart is on; after it resolves, the client polls `/healthz` and retries
51
+ * the original request once. Absent → a cold socket throws `daemon_unavailable`. */
52
+ onColdSocket?: () => Promise<void>;
53
+ /** Injected cold-start diagnostic. Called ONLY when the bounded
54
+ * `/healthz` poll times out after `onColdSocket`, so the caller can attach
55
+ * operator-useful context (e.g. a bounded tail of `crtrd.log`) to the
56
+ * `daemon_unavailable` error instead of it staying a bare message. Must
57
+ * return synchronously and cheaply — it runs on the failure path, not the
58
+ * happy path. A thrown/undefined result is treated as "no diagnostic". */
59
+ coldStartDiagnostic?: () => string | undefined;
60
+ /** Strict wall-clock window (ms) for local API availability after a cold
61
+ * socket or interrupted response. Each probe is capped to the remaining
62
+ * budget. Defaults to `HEALTHZ_POLL_WINDOW_MS`. */
63
+ coldStartPollWindowMs?: number;
64
+ }
65
+ /** One strict wall-clock availability window shared by local API clients and
66
+ * daemon management. Each probe gets only the budget remaining at its start. */
67
+ export declare function waitForDaemonAvailability({ windowMs, probe, initialError, pollIntervalMs, retry, now, sleep, }: {
68
+ windowMs: number;
69
+ probe: (timeoutMs: number) => Promise<void>;
70
+ initialError?: unknown;
71
+ pollIntervalMs?: number;
72
+ retry?: (error: unknown) => boolean;
73
+ now?: () => number;
74
+ sleep?: (ms: number) => Promise<void> | void;
75
+ }): Promise<void>;
76
+ export interface CrtrRequestOptions {
77
+ headers?: Record<string, string>;
78
+ signal?: AbortSignal;
79
+ timeout?: number;
80
+ maxRetries?: number;
81
+ }
82
+ export declare class CrtrClient {
83
+ private readonly baseUrl;
84
+ private readonly fetch;
85
+ private readonly headers;
86
+ private readonly autostart;
87
+ private readonly timeoutMs;
88
+ private readonly maxRetries;
89
+ private readonly localSocketTransport;
90
+ private readonly onColdSocket?;
91
+ private readonly coldStartDiagnostic?;
92
+ private readonly coldStartPollWindowMs;
93
+ /** Guards against invoking the daemon-start hook more than once per client. */
94
+ private coldStartAttempted;
95
+ constructor(opts: CrtrClientOptions);
96
+ healthz(): Promise<HealthDTO>;
97
+ /** One `/healthz` observation without cold-socket recovery. Availability
98
+ * waiters own retry policy and pass their remaining wall-clock budget here. */
99
+ probeHealthz(timeoutMs: number): Promise<HealthDTO>;
100
+ status(): Promise<StatusDTO>;
101
+ /** Ask the daemon to replace itself with a successor running the currently
102
+ * selected runtime generation. Answers before the handover starts, so a
103
+ * caller living inside a node the handover will tear down still gets a
104
+ * settled result. */
105
+ restartDaemon(): Promise<DaemonRestartDTO>;
106
+ admitDaemon(): Promise<DaemonAdmitDTO>;
107
+ migrateState(req: MigrateStateRequest): Promise<MigrateStateDTO>;
108
+ appendNodeLog(id: string, req: NodeLogAppendRequest): Promise<NodeLogAppendResultDTO>;
109
+ putNodeTelemetry(id: string, req: NodeTelemetryRecordRequest): Promise<void>;
110
+ putNodeRecap(id: string, req: NodeRecapRecordRequest): Promise<void>;
111
+ readNodeInboxReport(id: string, ref: string, executionId: string): Promise<NodeMessageBodyDTO>;
112
+ readNodePassiveMessage(id: string, ref: string): Promise<NodeMessageBodyDTO>;
113
+ nodePushedFinal(id: string, req: NodePushedFinalRequest): Promise<NodePushedFinalResultDTO>;
114
+ createNode(req: CreateNodeRequest): Promise<NodeDetailDTO>;
115
+ /** List canvas nodes with composable row filters. `include: 'activity'` adds
116
+ * latest/canonical reports and pending-human counts in the same response. */
117
+ listNodes(q?: ListNodesQuery): Promise<NodeSummaryDTO[]>;
118
+ getNode(id: string): Promise<NodeDetailDTO>;
119
+ /** Read a node outcome, optionally awaiting it for at most 25 seconds. This
120
+ * is a GET so the client can safely replay it across daemon handover. */
121
+ getNodeOutcome(id: string, { waitSeconds }?: {
122
+ waitSeconds?: number;
123
+ }): Promise<NodeOutcomeResponseDTO>;
124
+ /** Open the raw server-sent event response for a node. The caller owns SSE
125
+ * parsing and must consume or cancel the response body. Streams deliberately
126
+ * have no client wall-clock timeout. */
127
+ getNodeEvents(id: string, query?: NodeEventsQuery, options?: Omit<CrtrRequestOptions, 'timeout'>): Promise<Response>;
128
+ /** Parsed NDJSON hints, consumed eagerly and line by line. The caller must
129
+ * cancel with `signal` when done; no wall-clock timeout applies to the stream. */
130
+ getBrokerSignals(id: string, executionId: string, options?: Omit<CrtrRequestOptions, 'timeout'>): AsyncIterable<BrokerSignalLineDTO>;
131
+ /** Register or replace an armed target for terminal-outcome delivery. */
132
+ registerOutcomeDelivery(id: string, req: RegisterOutcomeDeliveryRequest): Promise<OutcomeDeliveryDTO>;
133
+ getOutcomeDelivery(id: string): Promise<OutcomeDeliveryDTO>;
134
+ /** Disarm an unsettled outcome-delivery registration. */
135
+ disarmOutcomeDelivery(id: string): Promise<void>;
136
+ listBashJobs(id: string): Promise<BashJobStatusDTO[]>;
137
+ stopBashJob(id: string, jobId: string): Promise<BashJobStopResultDTO>;
138
+ sendMessage(id: string, req: SendMessageRequest): Promise<MessageResultDTO>;
139
+ /** First-class interrupt (the human Esc): cancels pending undelivered
140
+ * human-send inbox entries, then aborts a live in-flight turn. NEVER
141
+ * revives a dormant target. */
142
+ interruptNode(id: string): Promise<InterruptResultDTO>;
143
+ pushReport(id: string, req: PushReportRequest): Promise<PushReportResultDTO>;
144
+ submitResult(id: string, req: SubmitResultRequest): Promise<SubmitResultDTO>;
145
+ forkNode(id: string): Promise<NodeDetailDTO>;
146
+ reviveNode(id: string, req?: ReviveRequest): Promise<ReviveResultDTO>;
147
+ relaunchRoot(id: string): Promise<RelaunchRootResultDTO>;
148
+ bindBrokerSession(id: string, req: BrokerSessionBoundRequest): Promise<BrokerSessionBoundResultDTO>;
149
+ settleBroker(id: string, req: BrokerSettleRequest): Promise<BrokerSettleDirective>;
150
+ completeBrokerPark(id: string, req: BrokerParkCompleteRequest): Promise<BrokerSettleDirective>;
151
+ recordBrokerParkActivity(id: string, req: BrokerExecutionRequest): Promise<BrokerParkActivityResultDTO>;
152
+ recordBrokerTelemetry(id: string, req: BrokerTelemetryRequest): Promise<void>;
153
+ claimNodeMail(id: string, req: ClaimMailRequest): Promise<ClaimMailResultDTO>;
154
+ acknowledgeNodeMail(id: string, req: AcknowledgeMailRequest): Promise<AcknowledgeMailResultDTO>;
155
+ recordBrokerTurn(id: string, req: BrokerTurnRequest): Promise<BrokerTurnResultDTO>;
156
+ mutateBrokerProviderRetry(id: string, req: BrokerProviderRetryRequest): Promise<BrokerProviderRetryResultDTO>;
157
+ mutateBrokerFault(id: string, req: BrokerFaultRequest): Promise<BrokerFaultResultDTO>;
158
+ getBrokerRecovery(id: string, expectedExecutionId: string): Promise<RecoveryStateDTO>;
159
+ recordNodeFault(id: string, req: BrokerFaultInputDTO): Promise<BrokerFaultResultDTO>;
160
+ clearNodeFault(id: string, opts?: {
161
+ link?: BrokerFaultInputDTO['link'];
162
+ preserve_episode?: boolean;
163
+ }): Promise<NodeFaultClearResultDTO>;
164
+ commitBrokerModel(id: string, req: BrokerModelCommitRequest): Promise<BrokerModelCommitResultDTO>;
165
+ brokerExtensionState(id: string): Promise<BrokerExtensionStateDTO>;
166
+ commitBrokerGeneratedName(id: string, req: BrokerGeneratedNameRequest): Promise<BrokerGeneratedNameResultDTO>;
167
+ commitBrokerPersonaAck(id: string, req: BrokerPersonaAckRequest): Promise<BrokerPersonaAckResultDTO>;
168
+ closeNode(id: string, req?: CloseRequest): Promise<CloseResultDTO>;
169
+ recycleNode(id: string): Promise<NodeDetailDTO>;
170
+ demoteNode(id: string): Promise<NodeDetailDTO>;
171
+ promoteNode(id: string, req: PromoteRequest): Promise<NodeDetailDTO>;
172
+ yieldNode(id: string, req: YieldRequest): Promise<NodeDetailDTO>;
173
+ waitNode(id: string, req: WaitRequest): Promise<NodeDetailDTO>;
174
+ listKinds(): Promise<KindListDTO>;
175
+ /** A model change may first wait up to 30 s for a starting broker's view
176
+ * socket and then 15 s for its ack, so it gets that budget on top. */
177
+ patchConfig(id: string, patch: NodeConfigPatch): Promise<NodeDetailDTO>;
178
+ /** Land + close the node's managed git worktree (spec §6.2). Server-side
179
+ * because it interleaves a canvas WRITE with a git land transaction and
180
+ * crtrd is the repo host (same principle as spawnChild's creation git). */
181
+ closeWorktree(id: string): Promise<CloseWorktreeResultDTO>;
182
+ abandonWorktree(id: string, req: AbandonWorktreeRequest): Promise<AbandonWorktreeResultDTO>;
183
+ listQuarantinedWorktrees(): Promise<QuarantinedWorktreeDTO[]>;
184
+ /** Every space on the runtime with its size. */
185
+ listSpaces(): Promise<SpaceListDTO>;
186
+ subscribe(id: string, req: SubscribeRequest): Promise<SubscriptionDTO>;
187
+ listFocuses(): Promise<FocusDTO[]>;
188
+ focusOf(nodeId: string): Promise<FocusDTO | null>;
189
+ focusByPane(pane: string): Promise<FocusDTO | null>;
190
+ registerFocus(req: RegisterFocusRequest): Promise<FocusDTO | null>;
191
+ setFocusPane(focusId: string, req: SetFocusPaneRequest): Promise<void>;
192
+ closeFocus(focusId: string): Promise<void>;
193
+ unsubscribe(id: string, target: string): Promise<void>;
194
+ /** Arm one cron (`POST /v1/crons`) — the server mints the cron_id. */
195
+ armCron(req: ArmCronRequest): Promise<CronDTO>;
196
+ /** Crons visible to the caller (`GET /v1/crons`). With `q.profile` that is
197
+ * that profile's crons plus every global one; omit it only for a
198
+ * canvas-home-wide provenance read ("which crons did node X arm"). */
199
+ listCrons(q?: ListCronsQuery): Promise<CronDTO[]>;
200
+ /** One cron with its run-log ring (`GET /v1/crons/:cronId`). */
201
+ showCron(cronId: string, q?: CronScopeQuery): Promise<CronShowDTO>;
202
+ /** Pause one cron (`POST /v1/crons/:cronId/pause`) — stops firing, keeps config+history. */
203
+ pauseCron(cronId: string, q?: CronScopeQuery): Promise<CronDTO>;
204
+ /** Resume one paused cron (`POST /v1/crons/:cronId/resume`). */
205
+ resumeCron(cronId: string, q?: CronScopeQuery): Promise<CronDTO>;
206
+ /** Run one cron NOW, out of band (`POST /v1/crons/:cronId/run`) — synchronous:
207
+ * resolves with the settled run record after the subprocess closes. Does not
208
+ * advance the schedule or consume a one-shot; never escalates. */
209
+ runCron(cronId: string, q?: CronScopeQuery): Promise<CronRunDTO>;
210
+ /** Cancel one cron (`DELETE /v1/crons/:cronId`, idempotent). */
211
+ cancelCron(cronId: string, q?: CancelCronQuery): Promise<void>;
212
+ /** Bare eligibility poke (`POST /v1/crons/poke`): re-dues every held active
213
+ * cron now — "something changed; re-check now". Canvas-wide, label-free,
214
+ * idempotent, and free when nothing is held. */
215
+ pokeCrons(): Promise<PokeCronsResult>;
216
+ ensureAttach(id: string, req?: AttachEnsureRequest): Promise<AttachEnsureResultDTO>;
217
+ getReports(id: string, q?: ReportsQuery): Promise<ReportDTO[]>;
218
+ getTranscript(id: string, q?: TranscriptQuery): Promise<TranscriptDTO>;
219
+ getSnapshot(id: string): Promise<NodeSnapshotDTO>;
220
+ /** The node-config subject substrate gates evaluate against. */
221
+ nodeSubject(id: string): Promise<NodeSubjectDTO>;
222
+ getNodeMessages(id: string, q?: NodeMessagesQuery): Promise<NodeMessagesPageDTO>;
223
+ /** The node's conversation exactly as it ran — raw `.jsonl` bytes plus the
224
+ * assembled system prompt. For exports; `getSnapshot` is for renderers. */
225
+ getSession(id: string): Promise<NodeSessionDTO>;
226
+ /** What a non-terminal chat surface may offer for this node: the chat-capable
227
+ * slash commands its live engine registered, and the memory documents an
228
+ * inline `/name` token resolves to. Never revives — a node whose broker is
229
+ * not live answers `broker_live: false` with empty arrays. */
230
+ getChatInventory(id: string): Promise<ChatInventoryDTO>;
231
+ getProspectiveChatInventory(q?: ProspectiveChatInventoryQuery): Promise<ProspectiveChatInventoryDTO>;
232
+ getContext(id: string): Promise<ContextListDTO>;
233
+ /** Read an absolute host path (capped, `truncated` when clipped). */
234
+ peekFile(path: string, encoding?: FileEncoding, options?: CrtrRequestOptions): Promise<FilePeekDTO>;
235
+ writeFile(path: string, content: string, encoding?: FileEncoding, options?: CrtrRequestOptions): Promise<FileWriteDTO>;
236
+ listFiles(path: string, limit?: number, options?: CrtrRequestOptions): Promise<FileListDTO>;
237
+ runBash(params: BashRunParams, options?: CrtrRequestOptions): Promise<BashRunDTO>;
238
+ /** `crtr canvas` shared verbs. A ref is a name (with or without `[[ ]]`) or a raw object id. */
239
+ readonly objects: {
240
+ read: (ref: string, query?: ObjectReadQuery) => Promise<ObjectReadDTO>;
241
+ list: (query?: ObjectListRequest) => Promise<ObjectListDTO>;
242
+ search: (request: ObjectSearchRequest) => Promise<ObjectSearchDTO>;
243
+ watch: (ref: string, request?: WatchRequest) => Promise<WatchResultDTO>;
244
+ unwatch: (ref: string, query?: UnwatchQuery) => Promise<UnwatchResultDTO>;
245
+ edges: (ref: string, query?: EdgesQuery) => Promise<EdgesDTO>;
246
+ };
247
+ /** `crtr doc` write verbs. */
248
+ readonly docs: {
249
+ write: (request: DocWriteRequest) => Promise<DocWrittenDTO>;
250
+ edit: (ref: string, request: DocEditRequest) => Promise<DocEditedDTO>;
251
+ move: (ref: string, request: DocMoveRequest) => Promise<DocMovedDTO>;
252
+ delete: (ref: string) => Promise<DocDeletedDTO>;
253
+ history: (ref: string, query?: DocHistoryQuery) => Promise<DocHistoryDTO>;
254
+ lint: (request?: DocLintRequest) => Promise<DocLintDTO>;
255
+ };
256
+ /** Package (builtin and plugin) documents. */
257
+ readonly documents: {
258
+ reconcilePackages: () => Promise<ReconcilePackagesDTO>;
259
+ };
260
+ /** The broker's delivery of one node activity. */
261
+ nodeDelivery(id: string, request: DeliveryRequest): Promise<DeliveryResponse>;
262
+ /** A person's dry run of one delivery activity, for a live or hypothetical node. Writes nothing. */
263
+ deliveryDryRun(request: DeliveryDryRunRequest): Promise<DeliveryResponse>;
264
+ /** Record a backgrounded bash command as a job object. */
265
+ recordBackgroundedJob(id: string, jobId: string, request: BackgroundedJobRequest): Promise<BackgroundedJobDTO>;
266
+ /** Create-or-return by name. Supplied `projects` are shape-checked even when
267
+ * the profile already exists; their directories are only required to exist
268
+ * when this call creates the profile. */
269
+ ensureProfile(name: string, req?: EnsureProfileRequest): Promise<ProfileDTO>;
270
+ /** Create a profile of the caller's app; a name it already holds is refused. */
271
+ createProfile(req: CreateProfileRequest): Promise<ProfileDTO>;
272
+ listProfiles(): Promise<ProfileDTO[]>;
273
+ /** Rename, set the default kind, or add or remove one project. */
274
+ updateProfile(name: string, req: UpdateProfileRequest): Promise<ProfileDTO>;
275
+ listAppEnv(): Promise<{
276
+ names: string[];
277
+ }>;
278
+ setAppEnv(variable: string, value: string): Promise<{
279
+ changed: boolean;
280
+ }>;
281
+ removeAppEnv(variable: string): Promise<{
282
+ changed: boolean;
283
+ }>;
284
+ listProfileEnv(name: string): Promise<ProfileEnvNamesDTO>;
285
+ setProfileEnv(name: string, variable: string, value: string): Promise<ProfileEnvChangeDTO>;
286
+ removeProfileEnv(name: string, variable: string): Promise<ProfileEnvChangeDTO>;
287
+ getProfile(name: string): Promise<ProfileDTO>;
288
+ pauseProfile(name: string): Promise<ProfilePauseResultDTO>;
289
+ resumeProfile(name: string): Promise<ProfilePauseResultDTO>;
290
+ /** Merge and remove entries in a profile's metadata map. */
291
+ updateProfileMetadata(name: string, req: UpdateProfileMetadataRequest): Promise<ProfileDTO>;
292
+ /** Force-delete or detach one profile by exact id or unique name. */
293
+ deleteProfile(name: string, req: DeleteProfileRequest): Promise<DeleteProfileResultDTO>;
294
+ listModelAuth(): Promise<ModelAuthListDTO>;
295
+ getModelAuthReadiness(query?: ModelAuthReadinessQuery): Promise<ModelAuthReadinessDTO>;
296
+ installCredential(provider: string, req: InstallCredentialRequest): Promise<CredentialResultDTO>;
297
+ removeCredential(provider: string): Promise<CredentialRemovalResultDTO>;
298
+ /** `model_auth.start` — the daemon runs the vendor OAuth; the caller only shows `url`. */
299
+ startModelAuth(req: StartModelAuthFlowRequest): Promise<ModelAuthFlowStartedDTO>;
300
+ /** `model_auth.complete` — hand the daemon the code the vendor showed. */
301
+ completeModelAuth(flowId: string, req: CompleteModelAuthFlowRequest): Promise<ModelAuthFlowCompletedDTO>;
302
+ /** `model_auth.cancel` — end an in-flight flow the person gave up on; it writes nothing. */
303
+ cancelModelAuth(flowId: string): Promise<ModelAuthFlowDTO>;
304
+ /** A flow's state; `waitSeconds` (1-25) long-polls until it leaves `pending`. */
305
+ getModelAuthFlow(flowId: string, waitSeconds?: number): Promise<ModelAuthFlowDTO>;
306
+ createReview(req: CreateReviewRequest): Promise<ReviewDTO>;
307
+ listReviews(query?: ListReviewsQuery): Promise<ReviewListDTO>;
308
+ getReview(reviewId: string): Promise<ReviewDTO>;
309
+ submitReview(reviewId: string): Promise<ReviewSubmitResultDTO>;
310
+ cancelReview(reviewId: string, req?: CancelReviewRequest): Promise<ReviewCancelResultDTO>;
311
+ getReviewDocumentBase(reviewId: string): Promise<ReviewDocumentBaseDTO>;
312
+ createReviewComment(reviewId: string | undefined, req: CreateReviewCommentRequest): Promise<ReviewCommentMutationDTO>;
313
+ listReviewComments(reviewId?: string, query?: ListReviewCommentsQuery): Promise<ReviewCommentListDTO>;
314
+ readReviewCommentEvents(reviewId: string, query?: ReadReviewCommentEventsQuery): Promise<ReviewCommentEventsDTO>;
315
+ updateReviewCommentRanges(reviewId: string, req: ReviewCommentRangeBatchRequest): Promise<ReviewCommentRangeBatchResultDTO>;
316
+ getReviewComment(commentId: string): Promise<ReviewCommentDetailDTO>;
317
+ editReviewComment(commentId: string, req: EditReviewCommentRequest): Promise<ReviewCommentMutationDTO>;
318
+ resolveReviewComment(commentId: string, req?: ReviewCommentActionRequest): Promise<ReviewCommentMutationDTO>;
319
+ reopenReviewComment(commentId: string, req?: ReviewCommentActionRequest): Promise<ReviewCommentMutationDTO>;
320
+ deleteReviewComment(commentId: string, req?: ReviewCommentActionRequest): Promise<ReviewCommentMutationDTO>;
321
+ forkReviewComment(commentId: string): Promise<ReviewCommentForkDTO>;
322
+ /** Pending page/review tickets across every available crouter-owned
323
+ * humanloop root. */
324
+ listHumanInbox(): Promise<InboxListDTO>;
325
+ /** Read one page ticket by its opaque ticket id (pending, resolved, or canceled). */
326
+ getHumanInboxPage(ticketId: InboxTicketIdDTO): Promise<InboxPageDTO>;
327
+ /** All page tickets, oldest first (pending, resolved, or canceled) —
328
+ * home-wide, or narrowed to one raising node when `nodeId` is given. */
329
+ getInboxHistory(nodeId?: string): Promise<InboxPageHistoryDTO>;
330
+ /** Submit responses for a page ticket. Single-assignment server-side: a competing
331
+ * resolution races to `ticket_already_resolved`. */
332
+ respondHumanInboxPage(ticketId: InboxTicketIdDTO, request: RespondInboxPageRequest): Promise<PageTicketResultDTO>;
333
+ /** Autosave partial page work. Omitted slots are permitted in progress updates. */
334
+ postInboxProgress(ticketId: InboxTicketIdDTO, responses: PageResponsesDTO): Promise<void>;
335
+ /** Get the published response for a resolved page ticket. 404 if pending or canceled. */
336
+ getInboxResponse(ticketId: InboxTicketIdDTO): Promise<InboxPageResponseDTO>;
337
+ /** Cancel a ticket (terminal response, never deletion). */
338
+ cancelHumanInboxTicket(ticketId: InboxTicketIdDTO, request?: CancelInboxTicketRequest): Promise<CanceledTicketResultDTO>;
339
+ /** Create one durable human request. The minted `request_id` identifies the
340
+ * request; inbox presentation has its own ticket id. An unresolvable
341
+ * `action.name` is rejected before the page is published, leaving no inbox
342
+ * row behind. */
343
+ createHumanRequest(request: CreateHumanRequestRequest): Promise<CreateHumanRequestDTO>;
344
+ /** Product page components registered on the runtime (config + enabled plugins). */
345
+ listPageComponents(): Promise<PageComponentListDTO>;
346
+ /** Read one request: its current state, its answer when answered, and the
347
+ * delivery state of its completion action when it bound one. */
348
+ getHumanRequest(requestId: HumanRequestIdDTO): Promise<HumanRequestDTO>;
349
+ /** Revise a pending request's page in place. Identity, provenance, and the
350
+ * frozen action binding are preserved; a settled request refuses. */
351
+ replaceHumanRequest(requestId: HumanRequestIdDTO, request: ReplaceHumanRequestRequest): Promise<HumanRequestDTO>;
352
+ /** Settle a request `answered` programmatically. Races a human answer to the
353
+ * same first-writer-wins result. */
354
+ respondHumanRequest(requestId: HumanRequestIdDTO, request: RespondHumanRequestRequest): Promise<HumanRequestDTO>;
355
+ /** The recipient surface closing a request without answering. */
356
+ dismissHumanRequest(requestId: HumanRequestIdDTO, request?: SettleHumanRequestRequest): Promise<HumanRequestDTO>;
357
+ /** The requester withdrawing its own request. */
358
+ cancelHumanRequest(requestId: HumanRequestIdDTO, request?: SettleHumanRequestRequest): Promise<HumanRequestDTO>;
359
+ /** Resolve one page feedback comment — the bound companion's report that it
360
+ * has been dealt with. `nodeId` names the caller; the daemon refuses any
361
+ * node but the ticket's companion. Terminal for the comment; appends no
362
+ * chat turn. */
363
+ resolvePageFeedbackComment(ticketId: InboxTicketIdDTO, commentId: string, nodeId: string): Promise<PageFeedbackResolutionDTO>;
364
+ /** Composed client-side from `GET /v1/nodes` + `GET /v1/status` (spec §6.3 —
365
+ * the dashboard is absorbed into those two reads; there is no single route).
366
+ * `generated_at` is the client-side capture instant of the composition. */
367
+ dashboard(q?: DashboardQuery): Promise<DashboardDTO>;
368
+ attention(): Promise<AttentionDTO>;
369
+ /** Per-node pending-ticket counts for a bounded viewer slice. */
370
+ attentionCounts(node_ids: string[]): Promise<AttentionCountsDTO>;
371
+ /** Ranked/filtered content search over the per-cwd episodic corpus
372
+ * (`crtr canvas history search`). Optional query: ranked when present,
373
+ * recency browse when omitted. POST-bodied — the query carries arrays and
374
+ * free text; the whole search executes server-side (spec §6.3). */
375
+ historySearch(q: HistorySearchQuery): Promise<HistorySearchResultDTO>;
376
+ /** Required-pattern line-hit search over the per-cwd episodic corpus
377
+ * (`crtr canvas history grep`). Distinct stable schema from `historySearch`
378
+ * — POST-bodied for the same reasons. */
379
+ historyGrep(q: HistoryGrepQuery): Promise<HistoryGrepResultDTO>;
380
+ /** Resolve one `<node-id>:<relpath>` history ref to its full body
381
+ * (`crtr canvas history read`). */
382
+ historyRead(q: HistoryReadQuery): Promise<HistoryReadResultDTO>;
383
+ /** Grouped-count projection over the per-cwd episodic corpus
384
+ * (`crtr canvas history stats`). Same filters as search/grep, aggregate
385
+ * result instead of a hit page — POST-bodied for the same reasons. */
386
+ historyStats(q: HistoryStatsQuery): Promise<HistoryStatsResultDTO>;
387
+ /** The machine-readable browser canvas roster (`crtr canvas snapshot`) —
388
+ * distinct from the per-node `getSnapshot`. */
389
+ canvasSnapshot(): Promise<SnapshotDTO>;
390
+ /** The Analytics page model (`GET /v1/canvas/analytics`). The
391
+ * daemon scans transcripts for the window: a cold 7d scan of ~2 GB of
392
+ * transcripts measured 10 s, and with scan workers capped at 4 a queued
393
+ * request waits about one scan more. 60 s is 3x that worst case; past it the
394
+ * page shows the error instead of computing forever. */
395
+ analytics(q: AnalyticsQuery): Promise<AnalyticsDTO>;
396
+ /** Record memory reads/loads for one node (`POST /v1/nodes/:id/memory-reads`). */
397
+ recordMemoryReads(nodeId: string, body: MemoryReadsRequestDTO): Promise<void>;
398
+ /** The lean, set-based topology roster (`GET /v1/canvas/roster`) — exactly
399
+ * two indexed queries server-side, no per-row enrichment. The recurring
400
+ * poll target for attach/browser topology; use `canvasSnapshot` for the
401
+ * enriched on-demand view. */
402
+ canvasRoster(): Promise<RosterDTO>;
403
+ /** Explicitly compressed browse snapshot; the Node-only canvas source
404
+ * decompresses it because socketFetch does not interpret content-encoding. */
405
+ canvasBrowseCompressed(): Promise<Uint8Array>;
406
+ /** The lean attach-graph projection: display rows, topology, and focus state
407
+ * in one daemon-owned read rather than the full node-summary list. */
408
+ canvasGraph(): Promise<GraphDTO>;
409
+ prune(req: PruneRequest): Promise<PruneResultDTO>;
410
+ /** Raw request for routes not yet method-wrapped. Applies the same
411
+ * autostart + retry + error-mapping semantics. */
412
+ request<T>(method: string, path: string, body?: unknown, opts?: CrtrRequestOptions): Promise<T>;
413
+ /** Open a live response with the normal cold-socket and retry policy, without consuming its body. */
414
+ rawResponse(method: string, path: string, opts?: CrtrRequestOptions): Promise<Response>;
415
+ /** The unparsed request: cold-socket and interrupted-response recovery, plus
416
+ * the §7 retry policy (connection errors and 429/5xx on GET/HEAD/DELETE
417
+ * only — POST/PATCH are never replayed once a request has actually been
418
+ * sent). No JSON parse; every wrapper goes through here. */
419
+ private send;
420
+ private nodePath;
421
+ /** Validate a background job id before route construction. Job ids arrive
422
+ * from the daemon's file-backed roster and must remain one path segment. */
423
+ private jobPath;
424
+ /** Validate a cron id before route construction — `routes.ts` interpolates
425
+ * it raw, so a value carrying `/`, whitespace or `?` would corrupt the
426
+ * request line rather than 404 cleanly. Mirrors `nodePath`. */
427
+ private cronPath;
428
+ /** Validate a request id before route construction. Requests use the daemon's
429
+ * node-id-shaped identifiers, while inbox presentation uses a separate ticket
430
+ * id. A malformed request id is a server-rejectable request. */
431
+ private requestPath;
432
+ /** Validate an opaque inbox ticket id before route construction. A local
433
+ * shape violation is a caller bug, not a server-rejectable request — throws
434
+ * `TypeError` (matching the existing safe-segment discipline of a local
435
+ * precondition, distinct from `nodePath`'s `ApiError` because that one IS a
436
+ * request the server could plausibly receive and reject itself). */
437
+ private ticketId;
438
+ /** Validate a review id before route construction (D-A6). Reviews are minted
439
+ * and addressed like node ids, but arrive from agent argv, so a malformed
440
+ * one is a plausible request the server would also reject — `ApiError`,
441
+ * not `TypeError`, matching `nodePath`. */
442
+ private reviewPath;
443
+ /** Validate a comment id before route construction (D-A6). Comment ids are
444
+ * daemon-minted 32-char lowercase hex, but — like `reviewPath` — arrive from
445
+ * agent argv, so a bad one is a plausible request the server would also
446
+ * reject, not a caller-bug `TypeError` like `ticketId`. */
447
+ private commentPath;
448
+ /** The one fetch path (§1). Resolves as soon as headers arrive — the body
449
+ * stays an unread `ReadableStream` on the returned `Response`, so a caller
450
+ * that wants to stream (SSE, later) never waits on a buffered body. */
451
+ private transport;
452
+ private retainRequestLifetime;
453
+ private isColdSocketError;
454
+ /** A connection torn down MID-request (Node's "socket hang up" / a broken
455
+ * pipe). It establishes only that the response was interrupted, not why. */
456
+ private isInterruptedSocketError;
457
+ /** Wait for the local API after an interrupted response. GET/HEAD can retry
458
+ * because they are idempotent. A mutation may already have been applied, so
459
+ * it never replays. */
460
+ private rideOutInterruptedRequest;
461
+ private awaitAvailability;
462
+ /** Optionally start the daemon, then observe availability before retrying the
463
+ * request. Waiting is independent from permission to spawn: externally
464
+ * managed daemons still get the same bounded readiness window. */
465
+ private handleColdSocket;
466
+ }
467
+ export declare function safeColdStartDiagnostic(hook: (() => string | undefined) | undefined): string | undefined;