@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,113 @@
|
|
|
1
|
+
import type { IsoTime, NodeIdDTO } from './common.js';
|
|
2
|
+
import type { FeedbackResultDTO } from './human.js';
|
|
3
|
+
export type ReviewOriginKindDTO = 'ticket' | 'inline';
|
|
4
|
+
/** `binding` is intentionally never exposed over the API. */
|
|
5
|
+
export type ReviewStateDTO = 'open' | 'approved' | 'canceled';
|
|
6
|
+
/** Caller-supplied body for `POST /v1/human/reviews`. */
|
|
7
|
+
export interface CreateReviewRequest {
|
|
8
|
+
/** Caller-selected review origin. */
|
|
9
|
+
origin_kind: ReviewOriginKindDTO;
|
|
10
|
+
/** Caller-selected node whose persisted session is forked. */
|
|
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
|
+
/** Caller-minted invocation key; the daemon enforces its uniqueness. */
|
|
21
|
+
idempotency_key: string;
|
|
22
|
+
/** Caller-supplied ticket subtitle; required for ticket origins. */
|
|
23
|
+
subtitle?: string;
|
|
24
|
+
/** Caller-supplied ticket-only projection destination. */
|
|
25
|
+
output_path?: string;
|
|
26
|
+
}
|
|
27
|
+
/** Daemon-derived canonical review projection. */
|
|
28
|
+
export interface ReviewDTO {
|
|
29
|
+
/** Daemon-minted opaque review identity. */
|
|
30
|
+
review_id: string;
|
|
31
|
+
/** Daemon-recorded origin kind. */
|
|
32
|
+
origin_kind: ReviewOriginKindDTO;
|
|
33
|
+
/** Daemon-recorded originating node. */
|
|
34
|
+
origin_node_id: NodeIdDTO;
|
|
35
|
+
/** Daemon-owned directory containing the review branch and terminal result. */
|
|
36
|
+
review_dir: string;
|
|
37
|
+
/** Daemon-preallocated companion node. */
|
|
38
|
+
companion_node_id: NodeIdDTO;
|
|
39
|
+
/** Daemon-canonicalized reviewed file path (for a document review, its `document.md` snapshot). */
|
|
40
|
+
file: string;
|
|
41
|
+
/** The reviewed document's `<owner>/<name>`, for a document review. */
|
|
42
|
+
document?: string;
|
|
43
|
+
/** Daemon lifecycle state; never `binding`. */
|
|
44
|
+
state: ReviewStateDTO;
|
|
45
|
+
/** Daemon capture timestamp. */
|
|
46
|
+
created: IsoTime;
|
|
47
|
+
/** Daemon open timestamp, after the companion binds. */
|
|
48
|
+
opened_at?: IsoTime;
|
|
49
|
+
/** When the human submitted a review whose companion was still working. The
|
|
50
|
+
* review remains `open` until the companion goes quiet. */
|
|
51
|
+
submit_requested_at?: IsoTime;
|
|
52
|
+
/** Daemon source-read status at projection time. */
|
|
53
|
+
source_missing: boolean;
|
|
54
|
+
/** Daemon-owned current comment-coordinate source digest. */
|
|
55
|
+
anchor_base_sha256: string;
|
|
56
|
+
/** Daemon approval timestamp. */
|
|
57
|
+
approved_at?: IsoTime;
|
|
58
|
+
/** Daemon comparison of approval bytes to the invocation baseline. */
|
|
59
|
+
changed?: boolean;
|
|
60
|
+
/** Daemon snapshot count at approval. */
|
|
61
|
+
comments_total?: number;
|
|
62
|
+
/** Daemon unresolved-comment count at approval. */
|
|
63
|
+
comments_unresolved?: number;
|
|
64
|
+
/** Daemon cancellation timestamp. */
|
|
65
|
+
canceled_at?: IsoTime;
|
|
66
|
+
/** Daemon-recorded caller cancellation reason. */
|
|
67
|
+
cancel_reason?: string;
|
|
68
|
+
/** Daemon-recorded cancellation actor. */
|
|
69
|
+
cancel_actor?: string;
|
|
70
|
+
/** Daemon-owned immutable result projection path. */
|
|
71
|
+
result_path?: string;
|
|
72
|
+
/** Daemon-recorded approval delivery error, when delivery failed after commit. */
|
|
73
|
+
delivery_error?: string;
|
|
74
|
+
/** Daemon-recorded result projection error, when publication failed after commit. */
|
|
75
|
+
projection_error?: string;
|
|
76
|
+
}
|
|
77
|
+
/** Caller-supplied optional filters for `GET /v1/human/reviews`. */
|
|
78
|
+
export interface ListReviewsQuery {
|
|
79
|
+
state?: ReviewStateDTO;
|
|
80
|
+
origin_node_id?: NodeIdDTO;
|
|
81
|
+
file?: string;
|
|
82
|
+
}
|
|
83
|
+
/** Daemon-derived review list. */
|
|
84
|
+
export interface ReviewListDTO {
|
|
85
|
+
reviews: ReviewDTO[];
|
|
86
|
+
}
|
|
87
|
+
/** Daemon-derived result of review approval, which may still be waiting on the
|
|
88
|
+
* review's companion. */
|
|
89
|
+
export interface ReviewSubmitResultDTO {
|
|
90
|
+
review: ReviewDTO;
|
|
91
|
+
/** Immutable approval result; absent while the approval awaits the companion. */
|
|
92
|
+
result?: FeedbackResultDTO;
|
|
93
|
+
outcome: 'settled' | 'already_settled' | 'awaiting_companion';
|
|
94
|
+
}
|
|
95
|
+
/** Daemon-derived result of terminal review cancellation. */
|
|
96
|
+
export interface ReviewCancelResultDTO {
|
|
97
|
+
review: ReviewDTO;
|
|
98
|
+
outcome: 'settled' | 'already_settled';
|
|
99
|
+
}
|
|
100
|
+
/** Caller-supplied optional cancellation context. */
|
|
101
|
+
export interface CancelReviewRequest {
|
|
102
|
+
reason?: string;
|
|
103
|
+
actor?: string;
|
|
104
|
+
/** Recipient surfaces send `dismissed`; a requester withdrawal defaults to `canceled`. */
|
|
105
|
+
disposition?: 'canceled' | 'dismissed';
|
|
106
|
+
}
|
|
107
|
+
/** Daemon-derived coordinate base for the terminal review surface. */
|
|
108
|
+
export interface ReviewDocumentBaseDTO {
|
|
109
|
+
review_id: string;
|
|
110
|
+
anchor_base_sha256: string;
|
|
111
|
+
anchor_base_text: string;
|
|
112
|
+
file: string;
|
|
113
|
+
}
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import type { NodeStatusDTO } from './common.js';
|
|
2
|
+
import type { NodeOutcomeDTO } from './node-outcomes.js';
|
|
3
|
+
import type { DeclinedResultDTO } from './reports.js';
|
|
4
|
+
/** A run's cumulative token and cost totals (`run.get` `usage`). */
|
|
5
|
+
export interface RunUsageDTO {
|
|
6
|
+
input_tokens: number;
|
|
7
|
+
output_tokens: number;
|
|
8
|
+
cache_read_tokens: number;
|
|
9
|
+
cache_write_tokens: number;
|
|
10
|
+
cost_usd: number;
|
|
11
|
+
}
|
|
12
|
+
/** `run.get` status. */
|
|
13
|
+
export type RunStatusDTO = 'running' | 'waiting_on_user' | 'idle' | 'settled';
|
|
14
|
+
/** `run.get` `activity`: what the run's root node is doing now; null unless the run is `running`.
|
|
15
|
+
* Read on each `run.get`, not stored; `last_activity_at` is when any node of the run last emitted an event.
|
|
16
|
+
* - `starting`: the root's first turn has not begun (its agent is launching).
|
|
17
|
+
* - `thinking`: a root turn is open and the model is reasoning, or its call is in flight before any output.
|
|
18
|
+
* - `tool`: the model is writing a tool call, or the tool is executing. `tool.summary` is the command's
|
|
19
|
+
* first line or the path the call acts on, null while the call is still streaming or when it has neither.
|
|
20
|
+
* - `writing`: the model is streaming answer text.
|
|
21
|
+
* - `between_turns`: no root turn is open, yet the run is still running — a child node is working,
|
|
22
|
+
* mail waits to start the next turn, or the runtime is about to remind the root of its `output_schema`. */
|
|
23
|
+
export type RunActivityDTO = {
|
|
24
|
+
phase: 'starting' | 'thinking' | 'writing' | 'between_turns';
|
|
25
|
+
} | {
|
|
26
|
+
phase: 'tool';
|
|
27
|
+
tool: {
|
|
28
|
+
name: string;
|
|
29
|
+
summary: string | null;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
/** Why a turn ended in error: `content_refused` when the vendor refused the
|
|
33
|
+
* model call on safety grounds, `model_error` for any other failed call. */
|
|
34
|
+
export interface TurnErrorDTO {
|
|
35
|
+
code: 'content_refused' | 'model_error';
|
|
36
|
+
message: string;
|
|
37
|
+
}
|
|
38
|
+
/** The broker's stop reason for one assistant message, unchanged. */
|
|
39
|
+
export type AssistantStopReasonDTO = 'stop' | 'toolUse' | 'length' | 'error' | 'aborted';
|
|
40
|
+
type OutcomeBase = Omit<Extract<NodeOutcomeDTO, {
|
|
41
|
+
kind: 'result';
|
|
42
|
+
}>, 'kind' | 'reason' | 'declined'>;
|
|
43
|
+
/** A settled run's (or child's) outcome: the wire `NodeOutcomeDTO` with
|
|
44
|
+
* contract 4's settlement reasons. */
|
|
45
|
+
export type RunOutcomeDTO = (OutcomeBase & {
|
|
46
|
+
kind: 'result';
|
|
47
|
+
reason: 'finalized';
|
|
48
|
+
declined: null;
|
|
49
|
+
})
|
|
50
|
+
/** `details` is the decline's `reason`, `code`, `retryable` (D4-SET-18); null only on a row recorded before the decline block was. */
|
|
51
|
+
| (OutcomeBase & {
|
|
52
|
+
kind: 'failure';
|
|
53
|
+
reason: 'declined';
|
|
54
|
+
declined: DeclinedResultDTO | null;
|
|
55
|
+
details: DeclinedResultDTO | null;
|
|
56
|
+
}) | (OutcomeBase & {
|
|
57
|
+
kind: 'failure';
|
|
58
|
+
reason: 'canceled' | 'deadline_exceeded';
|
|
59
|
+
declined: null;
|
|
60
|
+
}) | (OutcomeBase & {
|
|
61
|
+
kind: 'failure';
|
|
62
|
+
reason: 'runtime_error';
|
|
63
|
+
declined: null;
|
|
64
|
+
details: {
|
|
65
|
+
crouter_reason: string;
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
/** One element of a question page (`waiting_on_user`). `id` is absent on a slot that takes no response. */
|
|
69
|
+
export interface RunQuestionSlotDTO {
|
|
70
|
+
id?: string;
|
|
71
|
+
kind: string;
|
|
72
|
+
/** Zero-based step the slot appears on. */
|
|
73
|
+
step: number;
|
|
74
|
+
config: Record<string, unknown>;
|
|
75
|
+
}
|
|
76
|
+
/** Fields every run event carries. The root's events have `node_id === run_id`; any other `node_id` is a descendant. */
|
|
77
|
+
export interface RunEventBaseDTO {
|
|
78
|
+
run_id: string;
|
|
79
|
+
node_id: string;
|
|
80
|
+
sequence_number: number;
|
|
81
|
+
ts: string;
|
|
82
|
+
/** The run's `metadata` from `run.start`. */
|
|
83
|
+
metadata: Record<string, unknown>;
|
|
84
|
+
}
|
|
85
|
+
/** Events whose stored content older retention passes may redact: the content field is then absent and `content_redacted` is true. */
|
|
86
|
+
interface Redactable {
|
|
87
|
+
content_redacted?: true;
|
|
88
|
+
}
|
|
89
|
+
export interface RunStartedEvent extends RunEventBaseDTO {
|
|
90
|
+
type: 'run.started';
|
|
91
|
+
/** Only on events stored before this field was dropped: it named the kind's
|
|
92
|
+
* default model, not one actually served. The served model is on `usage`. */
|
|
93
|
+
served_model?: string | null;
|
|
94
|
+
scopes: string[] | null;
|
|
95
|
+
payer: 'user';
|
|
96
|
+
usage: RunUsageDTO;
|
|
97
|
+
/** Present when a schedule's firing started the run. */
|
|
98
|
+
schedule_id?: string;
|
|
99
|
+
}
|
|
100
|
+
export interface NodeSystemPromptSetEvent extends RunEventBaseDTO, Redactable {
|
|
101
|
+
type: 'node.system_prompt.set';
|
|
102
|
+
text?: string;
|
|
103
|
+
entry_id: string;
|
|
104
|
+
}
|
|
105
|
+
export interface NodeMessageAcceptedEvent extends RunEventBaseDTO {
|
|
106
|
+
type: 'node.message.accepted';
|
|
107
|
+
message_id: string;
|
|
108
|
+
start_turn: boolean;
|
|
109
|
+
}
|
|
110
|
+
export interface NodeTurnStartedEvent extends RunEventBaseDTO {
|
|
111
|
+
type: 'node.turn.started';
|
|
112
|
+
/** `message_ids`: the accepted `run.message` messages this turn delivers (empty for the prompt, an answer, or a child's report). */
|
|
113
|
+
input: {
|
|
114
|
+
text: string;
|
|
115
|
+
message_ids: string[];
|
|
116
|
+
};
|
|
117
|
+
entry_id: string;
|
|
118
|
+
}
|
|
119
|
+
export interface NodeThinkingDeltaEvent extends RunEventBaseDTO {
|
|
120
|
+
type: 'node.thinking.delta';
|
|
121
|
+
delta: string;
|
|
122
|
+
}
|
|
123
|
+
export interface NodeThinkingDoneEvent extends RunEventBaseDTO, Redactable {
|
|
124
|
+
type: 'node.thinking.done';
|
|
125
|
+
text?: string;
|
|
126
|
+
entry_id: string;
|
|
127
|
+
}
|
|
128
|
+
export interface NodeOutputTextDeltaEvent extends RunEventBaseDTO {
|
|
129
|
+
type: 'node.output_text.delta';
|
|
130
|
+
delta: string;
|
|
131
|
+
}
|
|
132
|
+
/** Once per assistant message that ends, even an empty one (a refused or failed call writes no text). */
|
|
133
|
+
export interface NodeOutputTextDoneEvent extends RunEventBaseDTO {
|
|
134
|
+
type: 'node.output_text.done';
|
|
135
|
+
/** The message's whole text, possibly empty. */
|
|
136
|
+
text: string;
|
|
137
|
+
stop_reason: AssistantStopReasonDTO;
|
|
138
|
+
entry_id: string;
|
|
139
|
+
}
|
|
140
|
+
export interface NodeToolCallStartedEvent extends RunEventBaseDTO, Redactable {
|
|
141
|
+
type: 'node.tool_call.started';
|
|
142
|
+
tool_call_id: string;
|
|
143
|
+
name: string;
|
|
144
|
+
arguments?: unknown;
|
|
145
|
+
entry_id: string;
|
|
146
|
+
}
|
|
147
|
+
export interface NodeToolCallCompletedEvent extends RunEventBaseDTO, Redactable {
|
|
148
|
+
type: 'node.tool_call.completed';
|
|
149
|
+
tool_call_id: string;
|
|
150
|
+
name: string;
|
|
151
|
+
result?: unknown;
|
|
152
|
+
status: 'ok' | 'error' | 'denied';
|
|
153
|
+
entry_id: string;
|
|
154
|
+
}
|
|
155
|
+
export interface NodeTurnCompletedEvent extends RunEventBaseDTO {
|
|
156
|
+
type: 'node.turn.completed';
|
|
157
|
+
/** The same as the turn's `node.turn.started` `input.message_ids`. */
|
|
158
|
+
message_ids: string[];
|
|
159
|
+
/** The run's `run.get` status when the turn ended. */
|
|
160
|
+
run_status: Exclude<RunStatusDTO, 'settled'>;
|
|
161
|
+
/** The stop reason of the turn's last assistant message. */
|
|
162
|
+
stop_reason: string;
|
|
163
|
+
/** Present when the turn's last assistant message stopped with `error`. */
|
|
164
|
+
error?: TurnErrorDTO;
|
|
165
|
+
entry_id: string;
|
|
166
|
+
}
|
|
167
|
+
export interface RunUsageEvent extends RunEventBaseDTO, RunUsageDTO {
|
|
168
|
+
type: 'usage';
|
|
169
|
+
/** One model call's model; its tokens and cost are the event's own counts. */
|
|
170
|
+
served_model: string;
|
|
171
|
+
/** The run's cumulative usage after this call. */
|
|
172
|
+
usage: RunUsageDTO;
|
|
173
|
+
entry_id: string;
|
|
174
|
+
}
|
|
175
|
+
export interface NodeReportPushedEvent extends RunEventBaseDTO {
|
|
176
|
+
type: 'node.report.pushed';
|
|
177
|
+
body: string;
|
|
178
|
+
kind: 'final' | 'update';
|
|
179
|
+
}
|
|
180
|
+
export interface ChildStartedEvent extends RunEventBaseDTO {
|
|
181
|
+
type: 'child.started';
|
|
182
|
+
child_node_id: string;
|
|
183
|
+
kind: string;
|
|
184
|
+
}
|
|
185
|
+
export interface ChildSettledEvent extends RunEventBaseDTO {
|
|
186
|
+
type: 'child.settled';
|
|
187
|
+
child_node_id: string;
|
|
188
|
+
outcome: RunOutcomeDTO;
|
|
189
|
+
}
|
|
190
|
+
export interface WaitingOnUserEvent extends RunEventBaseDTO {
|
|
191
|
+
type: 'waiting_on_user';
|
|
192
|
+
question_id: string;
|
|
193
|
+
/** The app whose run asked. */
|
|
194
|
+
initiating_app: string;
|
|
195
|
+
/** Set on a provider's approval question. */
|
|
196
|
+
provider?: string;
|
|
197
|
+
tool?: string;
|
|
198
|
+
title: string;
|
|
199
|
+
subtitle?: string;
|
|
200
|
+
steps: number;
|
|
201
|
+
slots: RunQuestionSlotDTO[];
|
|
202
|
+
}
|
|
203
|
+
export interface QuestionAnsweredEvent extends RunEventBaseDTO {
|
|
204
|
+
type: 'question.answered';
|
|
205
|
+
question_id: string;
|
|
206
|
+
/** The accepted responses, keyed by slot id. */
|
|
207
|
+
answer: Record<string, unknown>;
|
|
208
|
+
}
|
|
209
|
+
export interface NodeStatusChangedEvent extends RunEventBaseDTO {
|
|
210
|
+
type: 'node.status.changed';
|
|
211
|
+
/** Crouter's node status; `dormant` means no broker is running. Not a run status. */
|
|
212
|
+
status: NodeStatusDTO | 'dormant';
|
|
213
|
+
reason: string | null;
|
|
214
|
+
}
|
|
215
|
+
/** The run settled (the root only; a child's settlement is `child.settled`). */
|
|
216
|
+
export interface NodeSettledEvent extends RunEventBaseDTO {
|
|
217
|
+
type: 'node.settled';
|
|
218
|
+
outcome: RunOutcomeDTO;
|
|
219
|
+
usage: RunUsageDTO;
|
|
220
|
+
result?: unknown;
|
|
221
|
+
}
|
|
222
|
+
/** Every run event. Its `type`s are exactly the Vocabulary table of contract 2. */
|
|
223
|
+
export type RunEvent = RunStartedEvent | NodeSystemPromptSetEvent | NodeMessageAcceptedEvent | NodeTurnStartedEvent | NodeThinkingDeltaEvent | NodeThinkingDoneEvent | NodeOutputTextDeltaEvent | NodeOutputTextDoneEvent | NodeToolCallStartedEvent | NodeToolCallCompletedEvent | NodeTurnCompletedEvent | RunUsageEvent | NodeReportPushedEvent | ChildStartedEvent | ChildSettledEvent | WaitingOnUserEvent | QuestionAnsweredEvent | NodeStatusChangedEvent | NodeSettledEvent;
|
|
224
|
+
export type RunEventType = RunEvent['type'];
|
|
225
|
+
/** The run event of one `type`. */
|
|
226
|
+
export type RunEventOf<T extends RunEventType> = Extract<RunEvent, {
|
|
227
|
+
type: T;
|
|
228
|
+
}>;
|
|
229
|
+
/** The fields a writer supplies for one event `type`; the base fields are the daemon's. */
|
|
230
|
+
export type RunEventFields<T extends RunEventType> = Omit<RunEventOf<T>, keyof RunEventBaseDTO | 'type'>;
|
|
231
|
+
/** One content part of a rendered trace message, discriminated on `type`. */
|
|
232
|
+
export type RunTraceContentDTO = {
|
|
233
|
+
type: 'text';
|
|
234
|
+
text: string;
|
|
235
|
+
} | {
|
|
236
|
+
type: 'thinking';
|
|
237
|
+
text: string;
|
|
238
|
+
} | {
|
|
239
|
+
type: 'tool_call';
|
|
240
|
+
tool_call_id: string;
|
|
241
|
+
name: string;
|
|
242
|
+
arguments: Record<string, unknown>;
|
|
243
|
+
} | {
|
|
244
|
+
type: 'image';
|
|
245
|
+
mime_type: string;
|
|
246
|
+
};
|
|
247
|
+
/** The nine rendered roles. */
|
|
248
|
+
export type RunTraceRoleDTO = 'system' | 'user' | 'assistant' | 'tool_result' | 'bash_execution' | 'custom' | 'compaction_summary' | 'branch_summary' | 'cycle_divider';
|
|
249
|
+
interface RunTraceMessageBase {
|
|
250
|
+
entry_id: string;
|
|
251
|
+
time: string;
|
|
252
|
+
content: RunTraceContentDTO[];
|
|
253
|
+
}
|
|
254
|
+
/** One rendered trace message; the role-specific fields narrow on `role`. */
|
|
255
|
+
export type RunTraceMessageDTO = (RunTraceMessageBase & {
|
|
256
|
+
role: 'assistant';
|
|
257
|
+
model: string;
|
|
258
|
+
provider: string;
|
|
259
|
+
stop_reason: AssistantStopReasonDTO;
|
|
260
|
+
error_message?: string;
|
|
261
|
+
usage?: RunUsageDTO;
|
|
262
|
+
}) | (RunTraceMessageBase & {
|
|
263
|
+
role: 'tool_result';
|
|
264
|
+
tool_call_id: string;
|
|
265
|
+
tool_name: string;
|
|
266
|
+
is_error: boolean;
|
|
267
|
+
}) | (RunTraceMessageBase & {
|
|
268
|
+
role: 'custom';
|
|
269
|
+
custom_type: string;
|
|
270
|
+
}) | (RunTraceMessageBase & {
|
|
271
|
+
role: Exclude<RunTraceRoleDTO, 'assistant' | 'tool_result' | 'custom'>;
|
|
272
|
+
});
|
|
273
|
+
/** One conversation (a pi session) of a traced node. */
|
|
274
|
+
export interface RunTraceConversationDTO {
|
|
275
|
+
conversation_id: string;
|
|
276
|
+
messages: RunTraceMessageDTO[];
|
|
277
|
+
}
|
|
278
|
+
/** `run.trace` response in its rendered form. */
|
|
279
|
+
export interface RunTraceDTO {
|
|
280
|
+
run_id: string;
|
|
281
|
+
latest_sequence: number;
|
|
282
|
+
nodes: Array<{
|
|
283
|
+
node_id: string;
|
|
284
|
+
parent_node_id: string | null;
|
|
285
|
+
conversations: RunTraceConversationDTO[];
|
|
286
|
+
/** The assistant message streaming now, or null. */
|
|
287
|
+
in_progress_message: null | {
|
|
288
|
+
thinking: string;
|
|
289
|
+
text: string;
|
|
290
|
+
};
|
|
291
|
+
}>;
|
|
292
|
+
}
|
|
293
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// The run event stream (`GET /v1/runs/{id}/events`): one declaration of every
|
|
2
|
+
// run event type and its fields. The daemon's `appendRunEvent` is typed against
|
|
3
|
+
// it and the SDK exports it, so a new event or field is added here once.
|
|
4
|
+
//
|
|
5
|
+
// PURITY (spec §3.1): imports only other `src/api/*` modules.
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IsoTime, NodeIdDTO } from './common.js';
|
|
2
|
+
/** `POST /v1/nodes/{id}/subscriptions` body — {id} subscribes to `target`. */
|
|
3
|
+
export interface SubscribeRequest {
|
|
4
|
+
target: NodeIdDTO;
|
|
5
|
+
/** active = wake the subscriber on emit; passive = accumulate, no wake. */
|
|
6
|
+
active?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/** A subscription as seen from one endpoint. */
|
|
9
|
+
export interface SubscriptionDTO {
|
|
10
|
+
/** The node id at the other end of the edge. */
|
|
11
|
+
node_id: NodeIdDTO;
|
|
12
|
+
active: boolean;
|
|
13
|
+
created: IsoTime;
|
|
14
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { NodeIdDTO } from './common.js';
|
|
2
|
+
/** `POST /v1/nodes/{id}/worktree/close` result. */
|
|
3
|
+
export interface CloseWorktreeResultDTO {
|
|
4
|
+
node_id: NodeIdDTO;
|
|
5
|
+
/** The worktree branch fast-forwarded into its recorded local base branch. */
|
|
6
|
+
branch: string;
|
|
7
|
+
worktree_path: string;
|
|
8
|
+
/** The commit SHA the recorded local base branch was fast-forwarded onto. */
|
|
9
|
+
landed_sha: string;
|
|
10
|
+
/** False while the caller's checkout remains registered for deferred cleanup.
|
|
11
|
+
* `worktree_remove_error` names that state and the safe follow-up. */
|
|
12
|
+
worktree_removed: boolean;
|
|
13
|
+
worktree_remove_error?: string;
|
|
14
|
+
/** False while the local branch remains checked out by the deferred cleanup. */
|
|
15
|
+
branch_deleted: boolean;
|
|
16
|
+
branch_delete_error?: string;
|
|
17
|
+
/** Present ONLY when landing had to stash local changes in the base checkout
|
|
18
|
+
* and re-applying them conflicted: names the preserved stash and how to
|
|
19
|
+
* re-apply it. Its absence means nothing local was left over. */
|
|
20
|
+
base_checkout_stash?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface AbandonWorktreeRequest {
|
|
23
|
+
by: string;
|
|
24
|
+
}
|
|
25
|
+
export interface AbandonWorktreeResultDTO {
|
|
26
|
+
node_id: NodeIdDTO;
|
|
27
|
+
branch: string;
|
|
28
|
+
tip_sha: string;
|
|
29
|
+
worktree_path: string;
|
|
30
|
+
branch_deleted: boolean;
|
|
31
|
+
}
|
|
32
|
+
/** A daemon-cleanup refusal retained for human intervention. */
|
|
33
|
+
export interface QuarantinedWorktreeDTO {
|
|
34
|
+
node_id: string;
|
|
35
|
+
path: string;
|
|
36
|
+
branch: string;
|
|
37
|
+
repo_root: string;
|
|
38
|
+
reason: string;
|
|
39
|
+
detail?: string;
|
|
40
|
+
attempts: number;
|
|
41
|
+
last_attempt: string;
|
|
42
|
+
/** Bytes occupied by the checkout, or null when it is gone or unmeasurable. */
|
|
43
|
+
size_bytes: number | null;
|
|
44
|
+
}
|
|
45
|
+
/** One space on the runtime: the person's (`user`) or an app's (`app:<id>`). */
|
|
46
|
+
export interface SpaceDTO {
|
|
47
|
+
space: string;
|
|
48
|
+
path: string;
|
|
49
|
+
/** Bytes the space occupies, or null when it cannot be measured. */
|
|
50
|
+
size_bytes: number | null;
|
|
51
|
+
}
|
|
52
|
+
/** `GET /v1/spaces`. */
|
|
53
|
+
export interface SpaceListDTO {
|
|
54
|
+
spaces: SpaceDTO[];
|
|
55
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Worktree DTOs (spec §6.2 — `node worktree close`). Landing + closing a
|
|
2
|
+
// node-managed git worktree is a canvas WRITE interleaved with a git land
|
|
3
|
+
// transaction, so it runs server-side (crtrd is the repo host — same principle
|
|
4
|
+
// as spawnChild's server-side creation git). This is the projected result of
|
|
5
|
+
// core's `CloseManagedWorktreeResult` — already snake_case, so a 1:1 mirror.
|
|
6
|
+
export {};
|