@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.
- package/README.md +67 -0
- package/dist/api/__tests__/error-codes.test.d.ts +1 -0
- package/dist/api/__tests__/error-codes.test.js +78 -0
- package/dist/api/__tests__/integration/client.test.d.ts +1 -0
- package/dist/api/__tests__/integration/client.test.js +179 -0
- package/dist/api/client.d.ts +467 -0
- package/dist/api/client.js +1179 -0
- package/dist/api/command-manifest/index.d.ts +3 -0
- package/dist/api/command-manifest/index.js +3 -0
- package/dist/api/command-manifest/manifest.d.ts +51 -0
- package/dist/api/command-manifest/manifest.js +332 -0
- package/dist/api/command-manifest/result.d.ts +25 -0
- package/dist/api/command-manifest/result.js +97 -0
- package/dist/api/command-manifest/schema.d.ts +28 -0
- package/dist/api/command-manifest/schema.js +856 -0
- package/dist/api/dto/analytics.d.ts +184 -0
- package/dist/api/dto/analytics.js +3 -0
- package/dist/api/dto/attach.d.ts +22 -0
- package/dist/api/dto/attach.js +13 -0
- package/dist/api/dto/bash-jobs.d.ts +24 -0
- package/dist/api/dto/bash-jobs.js +9 -0
- package/dist/api/dto/bash.d.ts +17 -0
- package/dist/api/dto/bash.js +1 -0
- package/dist/api/dto/broker-ops.d.ts +187 -0
- package/dist/api/dto/broker-ops.js +6 -0
- package/dist/api/dto/broker-signals.d.ts +25 -0
- package/dist/api/dto/broker-signals.js +1 -0
- package/dist/api/dto/broker.d.ts +86 -0
- package/dist/api/dto/broker.js +20 -0
- package/dist/api/dto/canvas.d.ts +359 -0
- package/dist/api/dto/canvas.js +2 -0
- package/dist/api/dto/chat-inventory.d.ts +56 -0
- package/dist/api/dto/chat-inventory.js +11 -0
- package/dist/api/dto/common.d.ts +29 -0
- package/dist/api/dto/common.js +15 -0
- package/dist/api/dto/config.d.ts +36 -0
- package/dist/api/dto/config.js +3 -0
- package/dist/api/dto/crons.d.ts +150 -0
- package/dist/api/dto/crons.js +10 -0
- package/dist/api/dto/custom-objects.d.ts +66 -0
- package/dist/api/dto/custom-objects.js +1 -0
- package/dist/api/dto/delivery.d.ts +71 -0
- package/dist/api/dto/delivery.js +7 -0
- package/dist/api/dto/docs.d.ts +135 -0
- package/dist/api/dto/docs.js +8 -0
- package/dist/api/dto/files.d.ts +21 -0
- package/dist/api/dto/files.js +1 -0
- package/dist/api/dto/focus.d.ts +24 -0
- package/dist/api/dto/focus.js +10 -0
- package/dist/api/dto/grants.d.ts +14 -0
- package/dist/api/dto/grants.js +1 -0
- package/dist/api/dto/health.d.ts +106 -0
- package/dist/api/dto/health.js +2 -0
- package/dist/api/dto/human-requests.d.ts +113 -0
- package/dist/api/dto/human-requests.js +4 -0
- package/dist/api/dto/human.d.ts +28 -0
- package/dist/api/dto/human.js +4 -0
- package/dist/api/dto/inbox.d.ts +273 -0
- package/dist/api/dto/inbox.js +4 -0
- package/dist/api/dto/lifecycle.d.ts +88 -0
- package/dist/api/dto/lifecycle.js +3 -0
- package/dist/api/dto/mail.d.ts +44 -0
- package/dist/api/dto/mail.js +1 -0
- package/dist/api/dto/messages.d.ts +88 -0
- package/dist/api/dto/messages.js +2 -0
- package/dist/api/dto/model-config.d.ts +25 -0
- package/dist/api/dto/model-config.js +1 -0
- package/dist/api/dto/modelauth.d.ts +132 -0
- package/dist/api/dto/modelauth.js +4 -0
- package/dist/api/dto/node-events.d.ts +65 -0
- package/dist/api/dto/node-events.js +4 -0
- package/dist/api/dto/node-outcomes.d.ts +88 -0
- package/dist/api/dto/node-outcomes.js +2 -0
- package/dist/api/dto/node-records.d.ts +35 -0
- package/dist/api/dto/node-records.js +5 -0
- package/dist/api/dto/nodes.d.ts +368 -0
- package/dist/api/dto/nodes.js +3 -0
- package/dist/api/dto/objects.d.ts +172 -0
- package/dist/api/dto/objects.js +5 -0
- package/dist/api/dto/profiles.d.ts +117 -0
- package/dist/api/dto/profiles.js +4 -0
- package/dist/api/dto/recovery.d.ts +104 -0
- package/dist/api/dto/recovery.js +1 -0
- package/dist/api/dto/reports.d.ts +93 -0
- package/dist/api/dto/reports.js +2 -0
- package/dist/api/dto/review-comments.d.ts +146 -0
- package/dist/api/dto/review-comments.js +5 -0
- package/dist/api/dto/reviews.d.ts +113 -0
- package/dist/api/dto/reviews.js +5 -0
- package/dist/api/dto/run-events.d.ts +293 -0
- package/dist/api/dto/run-events.js +6 -0
- package/dist/api/dto/subscriptions.d.ts +14 -0
- package/dist/api/dto/subscriptions.js +2 -0
- package/dist/api/dto/worktree.d.ts +55 -0
- package/dist/api/dto/worktree.js +6 -0
- package/dist/api/error-codes.d.ts +254 -0
- package/dist/api/error-codes.js +54 -0
- package/dist/api/errors.d.ts +47 -0
- package/dist/api/errors.js +66 -0
- package/dist/api/index.d.ts +42 -0
- package/dist/api/index.js +41 -0
- package/dist/api/node-transport.d.ts +18 -0
- package/dist/api/node-transport.js +105 -0
- package/dist/api/plugin-manifest-schema.d.ts +233 -0
- package/dist/api/plugin-manifest-schema.js +23 -0
- package/dist/api/routes.d.ts +160 -0
- package/dist/api/routes.js +193 -0
- package/dist/shared/generated-context.d.ts +79 -0
- package/dist/shared/generated-context.js +232 -0
- package/dist/shared/predicates.d.ts +2 -0
- package/dist/shared/predicates.js +4 -0
- package/package.json +49 -0
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import type { IsoTime } from './common.js';
|
|
2
|
+
/** Opaque, stable, URL-safe ticket id: lowercase SHA-256 hex. */
|
|
3
|
+
export type InboxTicketIdDTO = string;
|
|
4
|
+
export interface TicketSourceDTO {
|
|
5
|
+
sessionName?: string;
|
|
6
|
+
askedBy?: string;
|
|
7
|
+
blockedSince?: IsoTime;
|
|
8
|
+
emittedAt?: IsoTime;
|
|
9
|
+
profileName?: string;
|
|
10
|
+
nodeId?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ReviewTicketSummaryDTO {
|
|
13
|
+
/** Request identity for direct request/review routes. */
|
|
14
|
+
request_id: string;
|
|
15
|
+
/** Daemon-owned projection directory. */
|
|
16
|
+
request_dir: string;
|
|
17
|
+
ticket_id: InboxTicketIdDTO;
|
|
18
|
+
kind: 'review';
|
|
19
|
+
title: string;
|
|
20
|
+
subtitle: string;
|
|
21
|
+
blocked_since: IsoTime;
|
|
22
|
+
source: TicketSourceDTO;
|
|
23
|
+
}
|
|
24
|
+
/** One question's recommended option, flat on the wire like every other summary field. */
|
|
25
|
+
export interface RecommendedOptionDTO {
|
|
26
|
+
slot_id: string;
|
|
27
|
+
option_id: string;
|
|
28
|
+
label: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* What one keypress on an inbox row publishes. `responses` is a complete final response
|
|
32
|
+
* map this daemon already accepts for the ticket, so a client publishes it untouched
|
|
33
|
+
* rather than assembling one from the summary.
|
|
34
|
+
*/
|
|
35
|
+
export interface PageFastActionDTO {
|
|
36
|
+
kind: 'answer' | 'acknowledge';
|
|
37
|
+
responses: PageResponsesDTO;
|
|
38
|
+
}
|
|
39
|
+
export interface PageTicketSummaryDTO {
|
|
40
|
+
/** Request identity for direct request routes. */
|
|
41
|
+
request_id: string;
|
|
42
|
+
/** Daemon-owned projection directory. */
|
|
43
|
+
request_dir: string;
|
|
44
|
+
ticket_id: InboxTicketIdDTO;
|
|
45
|
+
kind: 'page';
|
|
46
|
+
title: string;
|
|
47
|
+
subtitle?: string;
|
|
48
|
+
placement: 'inline' | 'panel';
|
|
49
|
+
dialect: 'jsx' | 'html';
|
|
50
|
+
inbox: boolean;
|
|
51
|
+
steps: number;
|
|
52
|
+
emitted_at: IsoTime;
|
|
53
|
+
source: TicketSourceDTO;
|
|
54
|
+
slot_kinds: string[];
|
|
55
|
+
/** The ticket is waiting on the person: it asks something, or an agent bridge is parked on its reply. Not a writability gate — any pending, non-passive ticket accepts a response. */
|
|
56
|
+
awaits_response: boolean;
|
|
57
|
+
/** Omitted when no question recommends an option. */
|
|
58
|
+
recommended_options?: RecommendedOptionDTO[];
|
|
59
|
+
/** Present only on a pending ticket that a row can settle without opening it. */
|
|
60
|
+
fast_action?: PageFastActionDTO;
|
|
61
|
+
state: 'pending' | 'resolved' | 'canceled' | 'passive';
|
|
62
|
+
/** Present only on resolved history entries; the stored one-line answer digest. */
|
|
63
|
+
answer_digest?: string;
|
|
64
|
+
}
|
|
65
|
+
export type InboxTicketSummaryDTO = PageTicketSummaryDTO | ReviewTicketSummaryDTO;
|
|
66
|
+
export interface InboxListDTO {
|
|
67
|
+
tickets: InboxTicketSummaryDTO[];
|
|
68
|
+
}
|
|
69
|
+
export interface PageSlotDTO {
|
|
70
|
+
id?: string;
|
|
71
|
+
kind: string;
|
|
72
|
+
step: number;
|
|
73
|
+
config: Record<string, unknown>;
|
|
74
|
+
unvalidated?: true;
|
|
75
|
+
display?: true;
|
|
76
|
+
}
|
|
77
|
+
/** The nested protocol object is deliberately camelCase on the wire. */
|
|
78
|
+
export interface PageManifestDTO {
|
|
79
|
+
schema: 'crtr.page/v2';
|
|
80
|
+
dialect: 'jsx' | 'html';
|
|
81
|
+
title: string;
|
|
82
|
+
subtitle?: string;
|
|
83
|
+
delivery: {
|
|
84
|
+
placement: 'inline' | 'panel';
|
|
85
|
+
inbox: boolean;
|
|
86
|
+
reply: boolean;
|
|
87
|
+
};
|
|
88
|
+
document: 'page.tsx' | 'page.html';
|
|
89
|
+
steps: number;
|
|
90
|
+
slots: PageSlotDTO[];
|
|
91
|
+
source?: TicketSourceDTO;
|
|
92
|
+
}
|
|
93
|
+
/** Answer-annotation anchors: option on UserQuestion, row on UserTable.
|
|
94
|
+
* Feedback on other page content — including the question text — is a
|
|
95
|
+
* ticket-level feedback comment, never a response anchor. */
|
|
96
|
+
export interface PageCommentAnchorDTO {
|
|
97
|
+
kind: 'option' | 'row';
|
|
98
|
+
optionId?: string;
|
|
99
|
+
rowId?: string;
|
|
100
|
+
}
|
|
101
|
+
export interface PageCommentDTO {
|
|
102
|
+
id: string;
|
|
103
|
+
anchor: PageCommentAnchorDTO;
|
|
104
|
+
text: string;
|
|
105
|
+
}
|
|
106
|
+
export interface PageOptionsResponseDTO {
|
|
107
|
+
selectedOptionIds: string[];
|
|
108
|
+
comments: PageCommentDTO[];
|
|
109
|
+
freetext?: string;
|
|
110
|
+
}
|
|
111
|
+
export interface PageTextResponseDTO {
|
|
112
|
+
text: string;
|
|
113
|
+
edited: boolean;
|
|
114
|
+
}
|
|
115
|
+
export interface PageTableResponseDTO {
|
|
116
|
+
selectedRowIds: string[];
|
|
117
|
+
selectedColumnIds: string[];
|
|
118
|
+
comments: PageCommentDTO[];
|
|
119
|
+
}
|
|
120
|
+
export interface PageCardsResponseDTO {
|
|
121
|
+
selectedCardIds: string[];
|
|
122
|
+
}
|
|
123
|
+
export type SlotResponseDTO = PageOptionsResponseDTO | PageTextResponseDTO | PageTableResponseDTO | PageCardsResponseDTO | Record<string, unknown>;
|
|
124
|
+
export type PageResponsesDTO = Record<string, SlotResponseDTO>;
|
|
125
|
+
export interface InboxPageDTO {
|
|
126
|
+
ticket_id: InboxTicketIdDTO;
|
|
127
|
+
kind: 'page';
|
|
128
|
+
state: 'pending' | 'resolved' | 'canceled' | 'passive';
|
|
129
|
+
/** Opaque SQL-selected immutable presentation revision. */
|
|
130
|
+
revision: string;
|
|
131
|
+
page: PageManifestDTO;
|
|
132
|
+
/** JSX is compiled for the host; HTML is the authored document verbatim. */
|
|
133
|
+
document: string;
|
|
134
|
+
/** Authored JSX or HTML, distinct from the compiled JSX host document. */
|
|
135
|
+
source_document: string;
|
|
136
|
+
document_media_type: 'text/jsx' | 'text/html';
|
|
137
|
+
progress: {
|
|
138
|
+
responses: PageResponsesDTO;
|
|
139
|
+
} | null;
|
|
140
|
+
/** Canonical stored terminal result, or null while the ticket remains open. */
|
|
141
|
+
result: PageTicketResultDTO | CanceledTicketResultDTO | null;
|
|
142
|
+
/** Ticket-attached feedback comments and the companion conversation they
|
|
143
|
+
* deliver to. Comments are immutable once sent — open until the companion
|
|
144
|
+
* resolves them. */
|
|
145
|
+
feedback: PageFeedbackDTO;
|
|
146
|
+
}
|
|
147
|
+
export interface PageFeedbackCommentDTO {
|
|
148
|
+
id: string;
|
|
149
|
+
/** The highlighted text the note is about; for a chart, its title. */
|
|
150
|
+
quote: string;
|
|
151
|
+
/** Surrounding text that locates the quote on the page. */
|
|
152
|
+
context?: string;
|
|
153
|
+
note: string;
|
|
154
|
+
/** Open until the companion has dealt with it; resolution is terminal. */
|
|
155
|
+
status: 'open' | 'resolved';
|
|
156
|
+
created_at: IsoTime;
|
|
157
|
+
resolved_at?: IsoTime;
|
|
158
|
+
}
|
|
159
|
+
export interface PageFeedbackDTO {
|
|
160
|
+
/** The ticket-bound companion conversation comments deliver to; null until
|
|
161
|
+
* the first comment realizes it. */
|
|
162
|
+
companion_node_id: string | null;
|
|
163
|
+
/** How many comments remain open. Zero once feedback exists is the ticket's
|
|
164
|
+
* authoritative signal that the companion has dealt with all of it. */
|
|
165
|
+
open_count: number;
|
|
166
|
+
comments: PageFeedbackCommentDTO[];
|
|
167
|
+
}
|
|
168
|
+
/** `POST /v1/human/inbox/:ticket_id/feedback-comments` body. */
|
|
169
|
+
export interface CreatePageFeedbackCommentRequest {
|
|
170
|
+
quote: string;
|
|
171
|
+
context?: string;
|
|
172
|
+
note: string;
|
|
173
|
+
}
|
|
174
|
+
export interface PageFeedbackDeliveryDTO {
|
|
175
|
+
target_node_id: string;
|
|
176
|
+
status: 'delivered' | 'failed';
|
|
177
|
+
via?: 'engine' | 'inbox';
|
|
178
|
+
woke: boolean;
|
|
179
|
+
reason?: 'capacity_frozen';
|
|
180
|
+
error?: string;
|
|
181
|
+
}
|
|
182
|
+
/** Create result: the new comment, the ticket's full feedback state after it,
|
|
183
|
+
* and the delivery outcome in the companion conversation. */
|
|
184
|
+
export interface PageFeedbackMutationDTO {
|
|
185
|
+
comment: PageFeedbackCommentDTO;
|
|
186
|
+
feedback: PageFeedbackDTO;
|
|
187
|
+
delivery: PageFeedbackDeliveryDTO;
|
|
188
|
+
}
|
|
189
|
+
/** `POST .../feedback-comments/:comment_id/resolve` request. Resolution is
|
|
190
|
+
* companion-only: `node_id` names the calling node and must equal the
|
|
191
|
+
* ticket's bound companion. */
|
|
192
|
+
export interface ResolvePageFeedbackCommentRequest {
|
|
193
|
+
node_id: string;
|
|
194
|
+
}
|
|
195
|
+
/** `POST .../feedback-comments/:comment_id/resolve` result. Resolution appends
|
|
196
|
+
* no chat turn; the companion's own conversational report covers it. */
|
|
197
|
+
export interface PageFeedbackResolutionDTO {
|
|
198
|
+
comment: PageFeedbackCommentDTO;
|
|
199
|
+
feedback: PageFeedbackDTO;
|
|
200
|
+
}
|
|
201
|
+
export interface InboxPageHistoryDTO {
|
|
202
|
+
tickets: PageTicketSummaryDTO[];
|
|
203
|
+
}
|
|
204
|
+
export interface RespondInboxPageRequest {
|
|
205
|
+
responses: PageResponsesDTO;
|
|
206
|
+
}
|
|
207
|
+
export interface InboxPageProgressDTO {
|
|
208
|
+
responses: PageResponsesDTO;
|
|
209
|
+
}
|
|
210
|
+
export interface PageTicketResultDTO {
|
|
211
|
+
schema: 'crtr.page-response/v1';
|
|
212
|
+
kind: 'page';
|
|
213
|
+
responses: PageResponsesDTO;
|
|
214
|
+
summary: string;
|
|
215
|
+
completedAt: IsoTime;
|
|
216
|
+
}
|
|
217
|
+
export interface PageAnswerGroupDTO {
|
|
218
|
+
group: 'option' | 'card' | 'row' | 'column';
|
|
219
|
+
mode: 'single' | 'multi';
|
|
220
|
+
total: number;
|
|
221
|
+
picked: {
|
|
222
|
+
id: string;
|
|
223
|
+
label: string;
|
|
224
|
+
}[];
|
|
225
|
+
}
|
|
226
|
+
export interface PageAnswerCommentDTO {
|
|
227
|
+
/** Legacy stored responses may still carry the retired `whole` anchor. */
|
|
228
|
+
anchor: PageCommentAnchorDTO | {
|
|
229
|
+
kind: 'whole';
|
|
230
|
+
};
|
|
231
|
+
anchorLabel: string;
|
|
232
|
+
text: string;
|
|
233
|
+
}
|
|
234
|
+
export interface PageAnswerSlotDTO {
|
|
235
|
+
id: string;
|
|
236
|
+
kind: string;
|
|
237
|
+
label?: string;
|
|
238
|
+
state: 'answered' | 'unanswered';
|
|
239
|
+
blank: boolean;
|
|
240
|
+
groups: PageAnswerGroupDTO[];
|
|
241
|
+
freetext?: string;
|
|
242
|
+
text?: {
|
|
243
|
+
value: string;
|
|
244
|
+
edited: boolean;
|
|
245
|
+
singleLine?: boolean;
|
|
246
|
+
};
|
|
247
|
+
comments: PageAnswerCommentDTO[];
|
|
248
|
+
raw?: Record<string, unknown>;
|
|
249
|
+
}
|
|
250
|
+
/** The camelCase protocol object shipped only by GET .../response. */
|
|
251
|
+
export interface PageAnswerDTO {
|
|
252
|
+
title: string;
|
|
253
|
+
subtitle?: string;
|
|
254
|
+
completedAt: IsoTime;
|
|
255
|
+
kind: 'answer' | 'acknowledgement';
|
|
256
|
+
digest: string;
|
|
257
|
+
slots: PageAnswerSlotDTO[];
|
|
258
|
+
}
|
|
259
|
+
export interface InboxPageResponseDTO extends PageTicketResultDTO {
|
|
260
|
+
answer: PageAnswerDTO;
|
|
261
|
+
}
|
|
262
|
+
/** `POST /v1/human/inbox/:ticket_id/cancel` body. */
|
|
263
|
+
export interface CancelInboxTicketRequest {
|
|
264
|
+
reason?: string;
|
|
265
|
+
}
|
|
266
|
+
/** `POST /v1/human/inbox/:ticket_id/cancel` result. */
|
|
267
|
+
export interface CanceledTicketResultDTO {
|
|
268
|
+
schema: 'humanloop.cancel/v1';
|
|
269
|
+
kind: 'canceled';
|
|
270
|
+
canceledAt: IsoTime;
|
|
271
|
+
reason?: string;
|
|
272
|
+
actor?: string;
|
|
273
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { NodeIdDTO, NodeStatusDTO } from './common.js';
|
|
2
|
+
/** `POST /v1/nodes/{id}/revive` body. */
|
|
3
|
+
export interface ReviveRequest {
|
|
4
|
+
/** Resume the saved conversation (true) vs a fresh launch (false). */
|
|
5
|
+
resume?: boolean;
|
|
6
|
+
/** Clear the finalization latch before reviving (the `--reopen` gate). The
|
|
7
|
+
* revive doorway accepts it only for a finalized node (`not_finalized`
|
|
8
|
+
* otherwise); without it, a finalized node is rejected (`node_finalized`).
|
|
9
|
+
* Message delivery has its own wider reopen behavior. */
|
|
10
|
+
reopen?: boolean;
|
|
11
|
+
/** Wake provenance: the cron whose run drove this revive (`CRTR_CRON_ID`,
|
|
12
|
+
* set by the daemon in every cron run's environment and forwarded by the
|
|
13
|
+
* CLI). With `resume:false` and a still-live cron row, crtrd injects the
|
|
14
|
+
* `<crtr-wake>` block so the revived node learns a CLOCK woke it, not a
|
|
15
|
+
* message. Prose only — an unknown id is ignored, never an error. */
|
|
16
|
+
cron_id?: string;
|
|
17
|
+
}
|
|
18
|
+
/** Result of a revive. `revived` is false on the idempotent double-revive no-op. */
|
|
19
|
+
export interface ReviveResultDTO {
|
|
20
|
+
node_id: NodeIdDTO;
|
|
21
|
+
revived: boolean;
|
|
22
|
+
resumed: boolean;
|
|
23
|
+
status: NodeStatusDTO;
|
|
24
|
+
/** What the call did: `launched` started a broker, `already-live` found one
|
|
25
|
+
* already running, `frozen` found no free broker slot and left the row
|
|
26
|
+
* waiting for one. */
|
|
27
|
+
outcome: 'launched' | 'already-live' | 'frozen';
|
|
28
|
+
}
|
|
29
|
+
/** `POST /v1/nodes/{id}/relaunch-root` result. A null id means the target
|
|
30
|
+
* was not a relaunchable live root, or its replacement failed to launch. */
|
|
31
|
+
export interface RelaunchRootResultDTO {
|
|
32
|
+
newNodeId: NodeIdDTO | null;
|
|
33
|
+
}
|
|
34
|
+
/** `POST /v1/nodes/revive-all` result. Node ids relaunched, any that failed to
|
|
35
|
+
* revive with the reason, and any the broker cap turned away (the reader
|
|
36
|
+
* reports all three). */
|
|
37
|
+
export interface ReviveAllResultDTO {
|
|
38
|
+
revived: NodeIdDTO[];
|
|
39
|
+
failed: {
|
|
40
|
+
node_id: NodeIdDTO;
|
|
41
|
+
error: string;
|
|
42
|
+
}[];
|
|
43
|
+
/** Frozen for capacity, not failed: the daemon relaunches these as slots free. */
|
|
44
|
+
frozen: NodeIdDTO[];
|
|
45
|
+
}
|
|
46
|
+
/** `POST /v1/nodes/{id}/close` body. The cascade set is computed server-side
|
|
47
|
+
* from edges; the flag only opts out of cascading descendants. */
|
|
48
|
+
export interface CloseRequest {
|
|
49
|
+
cascade?: boolean;
|
|
50
|
+
/** PID of the shell that invoked this close. The daemon excludes this process
|
|
51
|
+
* and its descendants from broker teardown so a node can close itself. */
|
|
52
|
+
caller_pid?: number;
|
|
53
|
+
/** Root close disposition: `true` finalizes the root to `done` (the browse `x`
|
|
54
|
+
* "finish" semantics); default/`false` cancels it. The cascade set (computed
|
|
55
|
+
* server-side) is torn down either way. */
|
|
56
|
+
finish?: boolean;
|
|
57
|
+
}
|
|
58
|
+
/** Result of a close. */
|
|
59
|
+
export interface CloseResultDTO {
|
|
60
|
+
/** The closed node — the cascade root. */
|
|
61
|
+
root: NodeIdDTO;
|
|
62
|
+
/** Every node torn down (root + cascaded descendants), leaves-first. */
|
|
63
|
+
closed: NodeIdDTO[];
|
|
64
|
+
/** Descendants left alive because an out-of-subtree manager still subscribes. */
|
|
65
|
+
spared: NodeIdDTO[];
|
|
66
|
+
}
|
|
67
|
+
/** `POST /v1/nodes/{id}/promote` body. */
|
|
68
|
+
export interface PromoteRequest {
|
|
69
|
+
/** Specialize as this kind of orchestrator; defaults to the node's current kind. */
|
|
70
|
+
kind?: string;
|
|
71
|
+
/** Also flip lifecycle→resident (interactable). */
|
|
72
|
+
resident?: boolean;
|
|
73
|
+
/** Durably change the model tier (ultra|strong). */
|
|
74
|
+
model?: string;
|
|
75
|
+
}
|
|
76
|
+
/** `POST /v1/nodes/{id}/yield` body. */
|
|
77
|
+
export interface YieldRequest {
|
|
78
|
+
note?: string;
|
|
79
|
+
promote?: boolean;
|
|
80
|
+
/** Respecialize the kind as the node refreshes. */
|
|
81
|
+
kind?: string;
|
|
82
|
+
/** Durably raise the model tier (ultra|strong) for the fresh revive. */
|
|
83
|
+
model?: string;
|
|
84
|
+
}
|
|
85
|
+
/** `POST /v1/nodes/{id}/wait` body. */
|
|
86
|
+
export interface WaitRequest {
|
|
87
|
+
controller: NodeIdDTO;
|
|
88
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export interface MailEntryDTO {
|
|
2
|
+
entry_id: string;
|
|
3
|
+
seq?: number;
|
|
4
|
+
operation_id: string;
|
|
5
|
+
ts: string;
|
|
6
|
+
from: string | null;
|
|
7
|
+
from_name?: string;
|
|
8
|
+
tier: 'critical' | 'urgent' | 'normal' | 'deferred';
|
|
9
|
+
kind: 'update' | 'urgent' | 'final' | 'message' | 'completed';
|
|
10
|
+
ref?: string;
|
|
11
|
+
label: string;
|
|
12
|
+
data?: Record<string, unknown>;
|
|
13
|
+
disposition?: 'human-answer' | 'human-canceled';
|
|
14
|
+
}
|
|
15
|
+
export interface ClaimedMailDTO {
|
|
16
|
+
delivery_id: string;
|
|
17
|
+
attempts: number;
|
|
18
|
+
handoff: 'fresh' | 'inherited';
|
|
19
|
+
entry: MailEntryDTO;
|
|
20
|
+
}
|
|
21
|
+
export interface ClaimMailRequest {
|
|
22
|
+
execution_id: string;
|
|
23
|
+
channel: 'wake' | 'passive' | 'deferred_run';
|
|
24
|
+
}
|
|
25
|
+
export interface ClaimMailResultDTO {
|
|
26
|
+
action: 'claimed' | 'hold';
|
|
27
|
+
deliveries: ClaimedMailDTO[];
|
|
28
|
+
}
|
|
29
|
+
export interface MailReceiptDTO {
|
|
30
|
+
delivery_id: string;
|
|
31
|
+
attempts: number;
|
|
32
|
+
disposition: 'acknowledged' | 'released';
|
|
33
|
+
}
|
|
34
|
+
export interface AcknowledgeMailRequest {
|
|
35
|
+
execution_id: string;
|
|
36
|
+
deliveries: MailReceiptDTO[];
|
|
37
|
+
}
|
|
38
|
+
export interface AcknowledgeMailResultDTO {
|
|
39
|
+
action: 'acknowledged' | 'hold';
|
|
40
|
+
results: Array<{
|
|
41
|
+
delivery_id: string;
|
|
42
|
+
outcome: 'acknowledged' | 'released' | 'stale';
|
|
43
|
+
}>;
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { InboxTierDTO, IsoTime, NodeIdDTO } from './common.js';
|
|
2
|
+
/** One runtime card supplied by a caller: the runtime renders and escapes it
|
|
3
|
+
* exactly once, so a caller cannot emit a malformed card or smuggle markup
|
|
4
|
+
* into one. `kind` must be namespaced (contain `:`) — bare kinds are
|
|
5
|
+
* crouter's own closed vocabulary. */
|
|
6
|
+
export interface RuntimeCardRequest {
|
|
7
|
+
kind: string;
|
|
8
|
+
facts?: Record<string, string | number>;
|
|
9
|
+
/** Data, not markup. */
|
|
10
|
+
body?: string;
|
|
11
|
+
}
|
|
12
|
+
/** `POST /v1/nodes/{id}/messages` body. */
|
|
13
|
+
export interface SendMessageRequest {
|
|
14
|
+
body: string;
|
|
15
|
+
tier?: InboxTierDTO;
|
|
16
|
+
/** Sender node id for feed attribution (the CLI resolves `CRTR_NODE_ID`;
|
|
17
|
+
* the daemon has no ambient caller identity). Absent → an external/human
|
|
18
|
+
* caller (`from: null`). */
|
|
19
|
+
from?: NodeIdDTO | null;
|
|
20
|
+
/** Revive with no inbox entry (`--fresh` → `reviveNode({ resume: false })`). */
|
|
21
|
+
fresh?: boolean;
|
|
22
|
+
/** Before delivery, make the target resident and clear its finalization latch
|
|
23
|
+
* when present (`--reopen`). Accepted for both durable and interactive
|
|
24
|
+
* delivery; `--fresh` retains its separate finalized-only gate. */
|
|
25
|
+
reopen?: boolean;
|
|
26
|
+
/** Hidden ambient context upserted onto the target's sidecar as a
|
|
27
|
+
* `situational` card, never visible chat (`--situational-context`).
|
|
28
|
+
* Immediate only; valid alone (no body). Prose only — its body is NOT
|
|
29
|
+
* escaped; a caller with untrusted text uses `situational_card`. */
|
|
30
|
+
situational_context?: string;
|
|
31
|
+
/** A runtime card that REPLACES the target's situational sidecar, delivered
|
|
32
|
+
* ahead of the body in the same turn and re-stated by the session-start
|
|
33
|
+
* bearings after a context refresh. Mutually exclusive with
|
|
34
|
+
* `situational_context`; valid alone (no body) on the durable path. */
|
|
35
|
+
situational_card?: RuntimeCardRequest;
|
|
36
|
+
/** One-shot runtime cards for this turn only — never persisted. Delivered in
|
|
37
|
+
* array order, after `situational_card` and ahead of the body. */
|
|
38
|
+
context_cards?: RuntimeCardRequest[];
|
|
39
|
+
/** Raw JSON-schema string installing a one-off output schema before delivery
|
|
40
|
+
* (`--output-schema`); the target answers with `crtr push result`. Immediate only. */
|
|
41
|
+
output_schema?: string;
|
|
42
|
+
/** `'interactive'`: deliver via the target's LIVE broker engine (prompt/steer
|
|
43
|
+
* on its one serialized frame loop — the same ordering a tmux viewer gets)
|
|
44
|
+
* instead of the durable inbox; a dormant or mid-revive target falls back to
|
|
45
|
+
* the durable inbox + revive (watcher delivers post-boot). Plain immediate
|
|
46
|
+
* body only — rejected with fresh/situational_context/output_schema or tier
|
|
47
|
+
* 'deferred'. Runtime cards and reopen ARE accepted: a
|
|
48
|
+
* card-bearing send is an ordinary human send that happens to carry context,
|
|
49
|
+
* and the live deliver frame places the cards ahead of the body in one turn.
|
|
50
|
+
* Absent → durable inbox (unchanged). */
|
|
51
|
+
delivery?: 'interactive';
|
|
52
|
+
}
|
|
53
|
+
/** Result of an immediate message send. */
|
|
54
|
+
export interface MessageResultDTO {
|
|
55
|
+
node_id: NodeIdDTO;
|
|
56
|
+
/** Whether an inbox entry was appended now. */
|
|
57
|
+
delivered: boolean;
|
|
58
|
+
/** Whether this request synchronously launched the target. Ordinary durable
|
|
59
|
+
* delivery to an active or idle dormant target always reports false: the
|
|
60
|
+
* lifecycle reconciler launches it from the durable inbox entry later. */
|
|
61
|
+
revived: boolean;
|
|
62
|
+
/** Present only when this request attempted a synchronous wake and no broker
|
|
63
|
+
* slot was free. The target's row is frozen and the daemon relaunches it
|
|
64
|
+
* when one frees; the entry was durably appended either way. */
|
|
65
|
+
not_revived_reason?: 'capacity_frozen';
|
|
66
|
+
/** Present only when the entry was appended ABOVE the requested tier: a
|
|
67
|
+
* terminal target never takes the later cycle `normal`/`deferred` wait for,
|
|
68
|
+
* so its mail is raised to the steering tier. */
|
|
69
|
+
delivered_tier?: InboxTierDTO;
|
|
70
|
+
delivered_at?: IsoTime;
|
|
71
|
+
/** Which channel a `delivery:'interactive'` send actually used: `'engine'`
|
|
72
|
+
* (live broker frame loop, no inbox entry) or `'inbox'` (durable fallback).
|
|
73
|
+
* Absent for non-interactive sends. */
|
|
74
|
+
delivered_via?: 'engine' | 'inbox';
|
|
75
|
+
}
|
|
76
|
+
/** `POST /v1/nodes/{id}/interrupt` result — the human Esc, first-class. Cancels
|
|
77
|
+
* pending undelivered human-send inbox entries FIRST, then aborts a live
|
|
78
|
+
* in-flight turn; a dormant target is NEVER revived. */
|
|
79
|
+
export interface InterruptResultDTO {
|
|
80
|
+
node_id: NodeIdDTO;
|
|
81
|
+
/** Primary outcome: `aborted_turn` wins over `canceled_pending` over `idle`
|
|
82
|
+
* (abort + cancel can co-occur; the flags below carry the full picture). */
|
|
83
|
+
outcome: 'aborted_turn' | 'canceled_pending' | 'idle';
|
|
84
|
+
/** True when a live in-flight turn (or `!` bash run) was actually aborted. */
|
|
85
|
+
aborted_turn: boolean;
|
|
86
|
+
/** How many pending undelivered human-send inbox entries were canceled. */
|
|
87
|
+
canceled_pending: number;
|
|
88
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type ModelStrengthDTO = 'ultra' | 'strong' | 'medium' | 'light';
|
|
2
|
+
export interface ModelRouteConfigDTO {
|
|
3
|
+
family: string;
|
|
4
|
+
credentialSource: string;
|
|
5
|
+
providerId: string;
|
|
6
|
+
models: Record<ModelStrengthDTO, string>;
|
|
7
|
+
}
|
|
8
|
+
export interface ModelRoutingDTO {
|
|
9
|
+
credentialSourceOrder?: string[];
|
|
10
|
+
familyOrder?: string[];
|
|
11
|
+
strengthFallback?: ModelStrengthDTO[];
|
|
12
|
+
}
|
|
13
|
+
export interface PutModelConfigRequest {
|
|
14
|
+
config_version: string;
|
|
15
|
+
modelRoutes: Record<string, ModelRouteConfigDTO>;
|
|
16
|
+
modelRouting: ModelRoutingDTO;
|
|
17
|
+
kinds: Record<string, {
|
|
18
|
+
model: string;
|
|
19
|
+
orchestratorModel?: string;
|
|
20
|
+
}>;
|
|
21
|
+
}
|
|
22
|
+
export interface PutModelConfigResponse {
|
|
23
|
+
config_version: string;
|
|
24
|
+
delivered: true;
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/** `PUT /v1/model-auth/{provider}` body — a discriminated union over credential
|
|
2
|
+
* kind. Idempotent upsert/rotate keyed by provider (and `account_id` for a
|
|
3
|
+
* managed account). */
|
|
4
|
+
export type InstallCredentialRequest = {
|
|
5
|
+
kind: 'api_key';
|
|
6
|
+
api_key: string;
|
|
7
|
+
} | {
|
|
8
|
+
kind: 'oauth';
|
|
9
|
+
access_token: string;
|
|
10
|
+
/** Required — pi's `OAuthCredentials` always carries both; the handler is
|
|
11
|
+
* fail-loud (400) when either is absent, so the type matches (no lenient
|
|
12
|
+
* fallback). */
|
|
13
|
+
refresh_token: string;
|
|
14
|
+
expires_at: string;
|
|
15
|
+
account_id?: string;
|
|
16
|
+
/** Provider-specific credential keys beyond the canonical tokens (e.g.
|
|
17
|
+
* github-copilot's `enterpriseUrl`), retained for enterprise routing and
|
|
18
|
+
* token refresh. */
|
|
19
|
+
extra?: Record<string, unknown>;
|
|
20
|
+
} | {
|
|
21
|
+
kind: 'managed_account';
|
|
22
|
+
/** Optional requested label. A bare provider login automatically labels a newly seen
|
|
23
|
+
* account from its identity profile. */
|
|
24
|
+
label?: string;
|
|
25
|
+
auto_label?: boolean;
|
|
26
|
+
account_id?: string;
|
|
27
|
+
access_token: string;
|
|
28
|
+
/** Required — the managed login always returns both; the handler is
|
|
29
|
+
* fail-loud (400) when either is absent. */
|
|
30
|
+
refresh_token: string;
|
|
31
|
+
expires_at: string;
|
|
32
|
+
/** Causal-cooldown floor snapshotted before the interactive login flow. Epoch ms. */
|
|
33
|
+
last_rate_limited_at?: number;
|
|
34
|
+
};
|
|
35
|
+
/** Result of a credential install/rotate. */
|
|
36
|
+
export interface CredentialResultDTO {
|
|
37
|
+
provider: string;
|
|
38
|
+
installed: true;
|
|
39
|
+
managed: boolean;
|
|
40
|
+
account_id?: string;
|
|
41
|
+
}
|
|
42
|
+
/** One managed-pool account, projected without credential material. Timestamps are
|
|
43
|
+
* ISO strings so remote consumers do not need to understand pi's epoch-ms storage. */
|
|
44
|
+
export interface ManagedAccountStatusDTO {
|
|
45
|
+
label: string;
|
|
46
|
+
expires_at: string;
|
|
47
|
+
/** Account-wide cooldown: every model on the account is cooling until this instant. */
|
|
48
|
+
rate_limited_until: string;
|
|
49
|
+
/** Per-model-family cooldowns still in force (e.g. `opus` from an Opus weekly window); other families on the account stay usable. */
|
|
50
|
+
model_cooldowns?: Array<{
|
|
51
|
+
family: string;
|
|
52
|
+
rate_limited_until: string;
|
|
53
|
+
}>;
|
|
54
|
+
auth_failure?: 'invalid_grant';
|
|
55
|
+
account_id?: string;
|
|
56
|
+
}
|
|
57
|
+
/** A provider's sanitized credential state. Managed providers are always listed
|
|
58
|
+
* (even with no accounts); non-managed providers appear only when auth.json has
|
|
59
|
+
* an API-key or OAuth credential for them. */
|
|
60
|
+
export type ModelAuthProviderStatusDTO = {
|
|
61
|
+
provider: string;
|
|
62
|
+
managed: true;
|
|
63
|
+
configured: boolean;
|
|
64
|
+
accounts: ManagedAccountStatusDTO[];
|
|
65
|
+
} | {
|
|
66
|
+
provider: string;
|
|
67
|
+
managed: false;
|
|
68
|
+
configured: true;
|
|
69
|
+
kind: 'api_key' | 'oauth';
|
|
70
|
+
};
|
|
71
|
+
/** `GET /v1/model-auth` — credential-presence projection for every known provider. */
|
|
72
|
+
export interface ModelAuthListDTO {
|
|
73
|
+
providers: ModelAuthProviderStatusDTO[];
|
|
74
|
+
}
|
|
75
|
+
/** Inputs that select the exact provider a new root node would use. */
|
|
76
|
+
export interface ModelAuthReadinessQuery {
|
|
77
|
+
profile?: string;
|
|
78
|
+
cwd?: string;
|
|
79
|
+
kind?: string;
|
|
80
|
+
model?: string;
|
|
81
|
+
}
|
|
82
|
+
/** `GET /v1/model-auth/readiness` — credential state for the provider selected by a prospective root launch. */
|
|
83
|
+
export interface ModelAuthReadinessDTO {
|
|
84
|
+
provider: string;
|
|
85
|
+
model: string;
|
|
86
|
+
credential: 'ready' | 'missing' | 'unusable';
|
|
87
|
+
reason?: 'invalid_grant';
|
|
88
|
+
rate_limited_until?: string | null;
|
|
89
|
+
}
|
|
90
|
+
/** `DELETE /v1/model-auth/{provider}` — all user credentials removed for one provider. */
|
|
91
|
+
export interface CredentialRemovalResultDTO {
|
|
92
|
+
provider: string;
|
|
93
|
+
removed_accounts: number;
|
|
94
|
+
}
|
|
95
|
+
/** `POST /v1/model-auth/flows` (`model_auth.start`) — begin a daemon-run vendor
|
|
96
|
+
* sign-in. `openai` is accepted as `openai-codex`; `openai-chatgpt` starts Sign in
|
|
97
|
+
* with ChatGPT for the runtime provider `openai`. `redirect: "loopback"` makes
|
|
98
|
+
* the daemon listen on the vendor's registered localhost port (self-host only). */
|
|
99
|
+
export interface StartModelAuthFlowRequest {
|
|
100
|
+
provider: 'anthropic' | 'openai-codex' | 'openai' | 'openai-chatgpt';
|
|
101
|
+
redirect?: 'loopback';
|
|
102
|
+
/** Name for the signed-in account; omitted, a newly seen account is auto-labeled. */
|
|
103
|
+
label?: string;
|
|
104
|
+
}
|
|
105
|
+
/** The started flow: open `url`; for Anthropic's code page paste the code back
|
|
106
|
+
* through `complete`; for OpenAI's device flow enter `user_code` at `url`; for
|
|
107
|
+
* ChatGPT paste the final redirect URL through `complete`. `provider` is the
|
|
108
|
+
* runtime provider id (`openai` for ChatGPT). */
|
|
109
|
+
export interface ModelAuthFlowStartedDTO {
|
|
110
|
+
flow_id: string;
|
|
111
|
+
provider: 'anthropic' | 'openai-codex' | 'openai';
|
|
112
|
+
url: string;
|
|
113
|
+
instructions: string;
|
|
114
|
+
user_code?: string;
|
|
115
|
+
expires_at: string;
|
|
116
|
+
}
|
|
117
|
+
/** `POST /v1/model-auth/flows/{flow_id}/complete` (`model_auth.complete`). */
|
|
118
|
+
export interface CompleteModelAuthFlowRequest {
|
|
119
|
+
input: string;
|
|
120
|
+
}
|
|
121
|
+
export interface ModelAuthFlowCompletedDTO {
|
|
122
|
+
flow_id: string;
|
|
123
|
+
provider: 'anthropic' | 'openai-codex' | 'openai';
|
|
124
|
+
status: 'connected';
|
|
125
|
+
}
|
|
126
|
+
/** `GET /v1/model-auth/flows/{flow_id}` — a flow's state. */
|
|
127
|
+
export interface ModelAuthFlowDTO {
|
|
128
|
+
flow_id: string;
|
|
129
|
+
provider: 'anthropic' | 'openai-codex' | 'openai';
|
|
130
|
+
status: 'pending' | 'connected' | 'failed' | 'expired';
|
|
131
|
+
message?: string;
|
|
132
|
+
}
|