@ai-matrx/agents 0.10.7 → 0.11.1
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/CHANGELOG.md +20 -0
- package/dist/content-transfer/index.cjs +1424 -0
- package/dist/content-transfer/index.cjs.map +1 -0
- package/dist/content-transfer/index.d.cts +84 -0
- package/dist/content-transfer/index.d.ts +84 -0
- package/dist/content-transfer/index.js +1406 -0
- package/dist/content-transfer/index.js.map +1 -0
- package/dist/content-transfer/react/index.cjs +1566 -0
- package/dist/content-transfer/react/index.cjs.map +1 -0
- package/dist/content-transfer/react/index.d.cts +63 -0
- package/dist/content-transfer/react/index.d.ts +63 -0
- package/dist/content-transfer/react/index.js +1541 -0
- package/dist/content-transfer/react/index.js.map +1 -0
- package/dist/index.cjs +23 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -1
- package/dist/mandates/index.cjs +9 -2
- package/dist/mandates/index.cjs.map +1 -1
- package/dist/mandates/index.d.cts +12 -5
- package/dist/mandates/index.d.ts +12 -5
- package/dist/mandates/index.js +9 -2
- package/dist/mandates/index.js.map +1 -1
- package/dist/matrx/index.cjs +23 -0
- package/dist/matrx/index.cjs.map +1 -1
- package/dist/matrx/index.d.cts +13 -646
- package/dist/matrx/index.d.ts +13 -646
- package/dist/matrx/index.js +23 -0
- package/dist/matrx/index.js.map +1 -1
- package/dist/operations--f5ko9Su.d.cts +659 -0
- package/dist/operations-BT5kKMHl.d.cts +203 -0
- package/dist/operations-BT5kKMHl.d.ts +203 -0
- package/dist/operations-Dp4ut-ac.d.ts +659 -0
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +44 -244
- package/dist/react/index.d.ts +44 -244
- package/dist/react/index.js.map +1 -1
- package/mandates/snapshots/keys.0.11.0.json +475 -0
- package/mandates/snapshots/keys.0.11.1.json +477 -0
- package/package.json +25 -4
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@ai-matrx/agents/matrx` — the Matrx transport port.
|
|
3
|
+
*
|
|
4
|
+
* The ONE seam between this package's wire semantics and a host's connection
|
|
5
|
+
* policy. This package owns WHAT is said to the AI Matrx server — paths,
|
|
6
|
+
* methods, JSON bodies, streaming Accept headers, the `Last-Event-ID` cursor
|
|
7
|
+
* header — and the host owns HOW the connection is made:
|
|
8
|
+
*
|
|
9
|
+
* - base-URL / backend-channel resolution (global, sandbox override, local
|
|
10
|
+
* engine, EC2-dedicated — whatever ladder the host runs);
|
|
11
|
+
* - credentials (Supabase JWT `Authorization: Bearer`, guest
|
|
12
|
+
* `X-Fingerprint-ID`, or the API-key lane) — NEVER implemented here;
|
|
13
|
+
* - the `X-Organization-Id` context header;
|
|
14
|
+
* - retry policy, network-level timeouts, and diagnostics capture.
|
|
15
|
+
*
|
|
16
|
+
* A host implements the port in a few lines:
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* const transport: MatrxTransport = {
|
|
20
|
+
* fetch: (path, init) =>
|
|
21
|
+
* fetch(`${baseUrl}${path}`, {
|
|
22
|
+
* ...init,
|
|
23
|
+
* headers: { ...init.headers, ...authHeaders() },
|
|
24
|
+
* }),
|
|
25
|
+
* };
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* The port is deliberately structural and `fetch`-shaped so `@ai-matrx/data`'s
|
|
29
|
+
* `/api` transport can implement it without importing this package.
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* The request this package hands the port. A strict subset of `RequestInit`,
|
|
33
|
+
* so a host can spread it straight into `fetch`.
|
|
34
|
+
*/
|
|
35
|
+
interface MatrxTransportRequest {
|
|
36
|
+
method: "GET" | "POST";
|
|
37
|
+
/**
|
|
38
|
+
* Wire-semantic headers the CALL requires (`Content-Type`, `Accept`,
|
|
39
|
+
* `Last-Event-ID`). The host merges its policy headers (auth, org) on top;
|
|
40
|
+
* it must not drop these.
|
|
41
|
+
*/
|
|
42
|
+
headers: Record<string, string>;
|
|
43
|
+
/** Pre-serialized JSON body, present on POST calls that carry one. */
|
|
44
|
+
body?: string;
|
|
45
|
+
/** Caller cancellation. The host must wire it to the underlying fetch. */
|
|
46
|
+
signal?: AbortSignal;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The transport port. `path` is server-relative and always starts with `/`
|
|
50
|
+
* (`/ai/...`, `/runtime/...`); the host prepends its resolved base URL.
|
|
51
|
+
*/
|
|
52
|
+
interface MatrxTransport {
|
|
53
|
+
fetch(path: string, init: MatrxTransportRequest): Promise<Response>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The conversation-start contract — client-minted `conversation_id`, `is_new`,
|
|
58
|
+
* `store` — typed exactly per the cross-repo System of Record
|
|
59
|
+
* (`common-docs/systems/agents/conversation-start-contract/FEATURE.md`;
|
|
60
|
+
* server truth `aidream/services/conversation_context/scope.py::
|
|
61
|
+
* ConversationStartRequest`).
|
|
62
|
+
*
|
|
63
|
+
* Every request that STARTS a conversation sends all three fields, no
|
|
64
|
+
* defaults:
|
|
65
|
+
*
|
|
66
|
+
* | `is_new` | `store` | Result |
|
|
67
|
+
* |----------|---------|----------------------------------------------------------|
|
|
68
|
+
* | true | true | Create the row with the caller's id — 409 if it exists |
|
|
69
|
+
* | true | false | No row. The id is correlation only (ephemeral run) |
|
|
70
|
+
* | false | true | Continue it — 404 if the caller doesn't own it |
|
|
71
|
+
* | false | false | Ephemeral run on a known id; nothing read, nothing written |
|
|
72
|
+
*
|
|
73
|
+
* `store` is the ONLY ephemeral signal; `is_new` is the caller's assertion
|
|
74
|
+
* about the id, never a persistence switch. `prior_messages` (the client-owned
|
|
75
|
+
* transcript of an ephemeral multi-turn run) is only valid with
|
|
76
|
+
* `store: false` — the union below makes the invalid combination
|
|
77
|
+
* unrepresentable, mirroring the server's 422.
|
|
78
|
+
*
|
|
79
|
+
* Continue routes (`POST /ai/conversations/{id}`) take the id from the path
|
|
80
|
+
* and do not carry this triple.
|
|
81
|
+
*/
|
|
82
|
+
/** Recursive JSON value — the package's honest type for free-form wire bags. */
|
|
83
|
+
type MatrxJsonValue = string | number | boolean | null | MatrxJsonValue[] | {
|
|
84
|
+
[key: string]: MatrxJsonValue;
|
|
85
|
+
};
|
|
86
|
+
/** A JSON object on the wire. */
|
|
87
|
+
type MatrxJsonObject = {
|
|
88
|
+
[key: string]: MatrxJsonValue;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* One LLM message on the request wire — `prior_messages` entries for
|
|
92
|
+
* stateless multi-turn runs. Mirrors aidream's `ChatMessageInput`
|
|
93
|
+
* (`aidream/schemas/messages.py`, `extra="allow"` — additional provider
|
|
94
|
+
* fields round-trip untouched).
|
|
95
|
+
*/
|
|
96
|
+
interface MatrxChatMessage {
|
|
97
|
+
role: string;
|
|
98
|
+
content?: string | MatrxJsonValue[] | null;
|
|
99
|
+
name?: string | null;
|
|
100
|
+
tool_call_id?: string | null;
|
|
101
|
+
tool_calls?: MatrxJsonObject[] | null;
|
|
102
|
+
[extra: string]: MatrxJsonValue | undefined;
|
|
103
|
+
}
|
|
104
|
+
/** `is_new: true, store: true` — create the row with the caller's id. */
|
|
105
|
+
interface MatrxStoredConversationCreate {
|
|
106
|
+
conversation_id: string;
|
|
107
|
+
is_new: true;
|
|
108
|
+
store: true;
|
|
109
|
+
}
|
|
110
|
+
/** `is_new: false, store: true` — continue an owned stored conversation via a start route. */
|
|
111
|
+
interface MatrxStoredConversationContinue {
|
|
112
|
+
conversation_id: string;
|
|
113
|
+
is_new: false;
|
|
114
|
+
store: true;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* `store: false` — ephemeral: nothing read, nothing written; the id is the
|
|
118
|
+
* caller's correlation handle. This is the ONLY member that may carry
|
|
119
|
+
* `prior_messages` (the server 422s a client transcript on a stored run).
|
|
120
|
+
*/
|
|
121
|
+
interface MatrxEphemeralConversation {
|
|
122
|
+
conversation_id: string;
|
|
123
|
+
is_new: boolean;
|
|
124
|
+
store: false;
|
|
125
|
+
prior_messages?: MatrxChatMessage[];
|
|
126
|
+
}
|
|
127
|
+
/** The full conversation-start triple, one member per contract cell. */
|
|
128
|
+
type MatrxConversationStart = MatrxStoredConversationCreate | MatrxStoredConversationContinue | MatrxEphemeralConversation;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Canonical AI Matrx NDJSON wire kernel.
|
|
132
|
+
*
|
|
133
|
+
* This module is deliberately independent of React, Redux, Next.js, Supabase,
|
|
134
|
+
* and generated application types. Every Matrx client uses it to turn the
|
|
135
|
+
* backend's byte stream into the same normalized `{ event, data }` envelopes.
|
|
136
|
+
* Host runtimes remain responsible for HTTP/auth errors and for deciding what
|
|
137
|
+
* each event means in their state model.
|
|
138
|
+
*/
|
|
139
|
+
interface MatrxStreamEnvelope<TData = unknown> {
|
|
140
|
+
event: string;
|
|
141
|
+
/** Immutable emitter segment; transport sequence is scoped to this id. */
|
|
142
|
+
stream_id?: string;
|
|
143
|
+
data: TData;
|
|
144
|
+
/** Monotonic transport sequence from full envelopes, when supplied. */
|
|
145
|
+
stream_seq?: number;
|
|
146
|
+
}
|
|
147
|
+
interface MatrxNdjsonIssue {
|
|
148
|
+
line: string;
|
|
149
|
+
error: unknown;
|
|
150
|
+
/** One-based physical NDJSON line number. */
|
|
151
|
+
lineNumber: number;
|
|
152
|
+
/** True when an unterminated trailing fragment was parsed by `finish()`. */
|
|
153
|
+
atCompletion: boolean;
|
|
154
|
+
}
|
|
155
|
+
interface MatrxStreamEnvelopeObservation {
|
|
156
|
+
/** Exact parsed JSON value before compact/full normalization. */
|
|
157
|
+
raw: unknown;
|
|
158
|
+
envelope: MatrxStreamEnvelope;
|
|
159
|
+
line: string;
|
|
160
|
+
lineNumber: number;
|
|
161
|
+
atCompletion: boolean;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Runtime operations — the canonical reconnect & resume read surface of the
|
|
166
|
+
* execution spine, over the `MatrxTransport` port.
|
|
167
|
+
*
|
|
168
|
+
* Server truth (verified against aidream source,
|
|
169
|
+
* `aidream/api/routers/runtime_operations.py` + `aidream/services/runtime/
|
|
170
|
+
* reconnect.py`; mounted at bare `/runtime`):
|
|
171
|
+
* - `GET /runtime/operations/{request_id}` — identify by `X-Request-ID`
|
|
172
|
+
* - `GET /runtime/operations/by-link/{kind}/{id}` — identify by feature record
|
|
173
|
+
* - `GET /runtime/executions/{id}/events` — durable seq-cursored page
|
|
174
|
+
* - `GET /runtime/executions/{id}/events/stream` — SSE replay-then-follow,
|
|
175
|
+
* `id:` = per-tree seq, reconnect with `Last-Event-ID`
|
|
176
|
+
* - `POST /runtime/operations/{request_id}/rejoin` — replay + follow the
|
|
177
|
+
* ORIGINAL NDJSON response while its detached task is alive (409 when live
|
|
178
|
+
* delivery is unavailable — fall back to the durable lifecycle stream)
|
|
179
|
+
*
|
|
180
|
+
* The contract: identify → recover durable progress → follow live → re-query
|
|
181
|
+
* the final result from the feature's own record. Token text is deliberately
|
|
182
|
+
* never replayed on the lifecycle stream — that is what `/rejoin` is for.
|
|
183
|
+
*
|
|
184
|
+
* The SSE wire rides the package's own `stream/sse` kernel. This module owns
|
|
185
|
+
* ONE connection's semantics (frames → typed events, cursor advancement,
|
|
186
|
+
* terminal `end`); stall timers, retry budgets, and reconnect loops stay host
|
|
187
|
+
* policy — every yielded item carries the cursor the next attempt resumes from.
|
|
188
|
+
*/
|
|
189
|
+
|
|
190
|
+
/** `matrx_runtime.models.ExecutionStatus` — the only progress column. */
|
|
191
|
+
type MatrxRuntimeExecutionStatus = "pending" | "running" | "paused" | "waiting_input" | "completed" | "failed" | "cancelled";
|
|
192
|
+
/** One durable spine event on the wire (`OperationEvent`) — `seq` is the reconnect cursor. */
|
|
193
|
+
interface MatrxRuntimeOperationEvent {
|
|
194
|
+
seq: number | null;
|
|
195
|
+
/** Lifecycle vocabulary: created | started | paused | resumed | waiting_input | completed | failed | cancelled | checkpoint_saved | note. */
|
|
196
|
+
kind: string;
|
|
197
|
+
execution_id: string;
|
|
198
|
+
root_execution_id: string | null;
|
|
199
|
+
detail: MatrxJsonObject | null;
|
|
200
|
+
created_at: string | null;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export type { MatrxTransport as M, MatrxStreamEnvelope as a, MatrxRuntimeOperationEvent as b, MatrxRuntimeExecutionStatus as c, MatrxNdjsonIssue as d, MatrxStreamEnvelopeObservation as e, MatrxConversationStart as f, MatrxJsonValue as g, MatrxJsonObject as h };
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@ai-matrx/agents/matrx` — the Matrx transport port.
|
|
3
|
+
*
|
|
4
|
+
* The ONE seam between this package's wire semantics and a host's connection
|
|
5
|
+
* policy. This package owns WHAT is said to the AI Matrx server — paths,
|
|
6
|
+
* methods, JSON bodies, streaming Accept headers, the `Last-Event-ID` cursor
|
|
7
|
+
* header — and the host owns HOW the connection is made:
|
|
8
|
+
*
|
|
9
|
+
* - base-URL / backend-channel resolution (global, sandbox override, local
|
|
10
|
+
* engine, EC2-dedicated — whatever ladder the host runs);
|
|
11
|
+
* - credentials (Supabase JWT `Authorization: Bearer`, guest
|
|
12
|
+
* `X-Fingerprint-ID`, or the API-key lane) — NEVER implemented here;
|
|
13
|
+
* - the `X-Organization-Id` context header;
|
|
14
|
+
* - retry policy, network-level timeouts, and diagnostics capture.
|
|
15
|
+
*
|
|
16
|
+
* A host implements the port in a few lines:
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* const transport: MatrxTransport = {
|
|
20
|
+
* fetch: (path, init) =>
|
|
21
|
+
* fetch(`${baseUrl}${path}`, {
|
|
22
|
+
* ...init,
|
|
23
|
+
* headers: { ...init.headers, ...authHeaders() },
|
|
24
|
+
* }),
|
|
25
|
+
* };
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* The port is deliberately structural and `fetch`-shaped so `@ai-matrx/data`'s
|
|
29
|
+
* `/api` transport can implement it without importing this package.
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* The request this package hands the port. A strict subset of `RequestInit`,
|
|
33
|
+
* so a host can spread it straight into `fetch`.
|
|
34
|
+
*/
|
|
35
|
+
interface MatrxTransportRequest {
|
|
36
|
+
method: "GET" | "POST";
|
|
37
|
+
/**
|
|
38
|
+
* Wire-semantic headers the CALL requires (`Content-Type`, `Accept`,
|
|
39
|
+
* `Last-Event-ID`). The host merges its policy headers (auth, org) on top;
|
|
40
|
+
* it must not drop these.
|
|
41
|
+
*/
|
|
42
|
+
headers: Record<string, string>;
|
|
43
|
+
/** Pre-serialized JSON body, present on POST calls that carry one. */
|
|
44
|
+
body?: string;
|
|
45
|
+
/** Caller cancellation. The host must wire it to the underlying fetch. */
|
|
46
|
+
signal?: AbortSignal;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The transport port. `path` is server-relative and always starts with `/`
|
|
50
|
+
* (`/ai/...`, `/runtime/...`); the host prepends its resolved base URL.
|
|
51
|
+
*/
|
|
52
|
+
interface MatrxTransport {
|
|
53
|
+
fetch(path: string, init: MatrxTransportRequest): Promise<Response>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The conversation-start contract — client-minted `conversation_id`, `is_new`,
|
|
58
|
+
* `store` — typed exactly per the cross-repo System of Record
|
|
59
|
+
* (`common-docs/systems/agents/conversation-start-contract/FEATURE.md`;
|
|
60
|
+
* server truth `aidream/services/conversation_context/scope.py::
|
|
61
|
+
* ConversationStartRequest`).
|
|
62
|
+
*
|
|
63
|
+
* Every request that STARTS a conversation sends all three fields, no
|
|
64
|
+
* defaults:
|
|
65
|
+
*
|
|
66
|
+
* | `is_new` | `store` | Result |
|
|
67
|
+
* |----------|---------|----------------------------------------------------------|
|
|
68
|
+
* | true | true | Create the row with the caller's id — 409 if it exists |
|
|
69
|
+
* | true | false | No row. The id is correlation only (ephemeral run) |
|
|
70
|
+
* | false | true | Continue it — 404 if the caller doesn't own it |
|
|
71
|
+
* | false | false | Ephemeral run on a known id; nothing read, nothing written |
|
|
72
|
+
*
|
|
73
|
+
* `store` is the ONLY ephemeral signal; `is_new` is the caller's assertion
|
|
74
|
+
* about the id, never a persistence switch. `prior_messages` (the client-owned
|
|
75
|
+
* transcript of an ephemeral multi-turn run) is only valid with
|
|
76
|
+
* `store: false` — the union below makes the invalid combination
|
|
77
|
+
* unrepresentable, mirroring the server's 422.
|
|
78
|
+
*
|
|
79
|
+
* Continue routes (`POST /ai/conversations/{id}`) take the id from the path
|
|
80
|
+
* and do not carry this triple.
|
|
81
|
+
*/
|
|
82
|
+
/** Recursive JSON value — the package's honest type for free-form wire bags. */
|
|
83
|
+
type MatrxJsonValue = string | number | boolean | null | MatrxJsonValue[] | {
|
|
84
|
+
[key: string]: MatrxJsonValue;
|
|
85
|
+
};
|
|
86
|
+
/** A JSON object on the wire. */
|
|
87
|
+
type MatrxJsonObject = {
|
|
88
|
+
[key: string]: MatrxJsonValue;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* One LLM message on the request wire — `prior_messages` entries for
|
|
92
|
+
* stateless multi-turn runs. Mirrors aidream's `ChatMessageInput`
|
|
93
|
+
* (`aidream/schemas/messages.py`, `extra="allow"` — additional provider
|
|
94
|
+
* fields round-trip untouched).
|
|
95
|
+
*/
|
|
96
|
+
interface MatrxChatMessage {
|
|
97
|
+
role: string;
|
|
98
|
+
content?: string | MatrxJsonValue[] | null;
|
|
99
|
+
name?: string | null;
|
|
100
|
+
tool_call_id?: string | null;
|
|
101
|
+
tool_calls?: MatrxJsonObject[] | null;
|
|
102
|
+
[extra: string]: MatrxJsonValue | undefined;
|
|
103
|
+
}
|
|
104
|
+
/** `is_new: true, store: true` — create the row with the caller's id. */
|
|
105
|
+
interface MatrxStoredConversationCreate {
|
|
106
|
+
conversation_id: string;
|
|
107
|
+
is_new: true;
|
|
108
|
+
store: true;
|
|
109
|
+
}
|
|
110
|
+
/** `is_new: false, store: true` — continue an owned stored conversation via a start route. */
|
|
111
|
+
interface MatrxStoredConversationContinue {
|
|
112
|
+
conversation_id: string;
|
|
113
|
+
is_new: false;
|
|
114
|
+
store: true;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* `store: false` — ephemeral: nothing read, nothing written; the id is the
|
|
118
|
+
* caller's correlation handle. This is the ONLY member that may carry
|
|
119
|
+
* `prior_messages` (the server 422s a client transcript on a stored run).
|
|
120
|
+
*/
|
|
121
|
+
interface MatrxEphemeralConversation {
|
|
122
|
+
conversation_id: string;
|
|
123
|
+
is_new: boolean;
|
|
124
|
+
store: false;
|
|
125
|
+
prior_messages?: MatrxChatMessage[];
|
|
126
|
+
}
|
|
127
|
+
/** The full conversation-start triple, one member per contract cell. */
|
|
128
|
+
type MatrxConversationStart = MatrxStoredConversationCreate | MatrxStoredConversationContinue | MatrxEphemeralConversation;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Canonical AI Matrx NDJSON wire kernel.
|
|
132
|
+
*
|
|
133
|
+
* This module is deliberately independent of React, Redux, Next.js, Supabase,
|
|
134
|
+
* and generated application types. Every Matrx client uses it to turn the
|
|
135
|
+
* backend's byte stream into the same normalized `{ event, data }` envelopes.
|
|
136
|
+
* Host runtimes remain responsible for HTTP/auth errors and for deciding what
|
|
137
|
+
* each event means in their state model.
|
|
138
|
+
*/
|
|
139
|
+
interface MatrxStreamEnvelope<TData = unknown> {
|
|
140
|
+
event: string;
|
|
141
|
+
/** Immutable emitter segment; transport sequence is scoped to this id. */
|
|
142
|
+
stream_id?: string;
|
|
143
|
+
data: TData;
|
|
144
|
+
/** Monotonic transport sequence from full envelopes, when supplied. */
|
|
145
|
+
stream_seq?: number;
|
|
146
|
+
}
|
|
147
|
+
interface MatrxNdjsonIssue {
|
|
148
|
+
line: string;
|
|
149
|
+
error: unknown;
|
|
150
|
+
/** One-based physical NDJSON line number. */
|
|
151
|
+
lineNumber: number;
|
|
152
|
+
/** True when an unterminated trailing fragment was parsed by `finish()`. */
|
|
153
|
+
atCompletion: boolean;
|
|
154
|
+
}
|
|
155
|
+
interface MatrxStreamEnvelopeObservation {
|
|
156
|
+
/** Exact parsed JSON value before compact/full normalization. */
|
|
157
|
+
raw: unknown;
|
|
158
|
+
envelope: MatrxStreamEnvelope;
|
|
159
|
+
line: string;
|
|
160
|
+
lineNumber: number;
|
|
161
|
+
atCompletion: boolean;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Runtime operations — the canonical reconnect & resume read surface of the
|
|
166
|
+
* execution spine, over the `MatrxTransport` port.
|
|
167
|
+
*
|
|
168
|
+
* Server truth (verified against aidream source,
|
|
169
|
+
* `aidream/api/routers/runtime_operations.py` + `aidream/services/runtime/
|
|
170
|
+
* reconnect.py`; mounted at bare `/runtime`):
|
|
171
|
+
* - `GET /runtime/operations/{request_id}` — identify by `X-Request-ID`
|
|
172
|
+
* - `GET /runtime/operations/by-link/{kind}/{id}` — identify by feature record
|
|
173
|
+
* - `GET /runtime/executions/{id}/events` — durable seq-cursored page
|
|
174
|
+
* - `GET /runtime/executions/{id}/events/stream` — SSE replay-then-follow,
|
|
175
|
+
* `id:` = per-tree seq, reconnect with `Last-Event-ID`
|
|
176
|
+
* - `POST /runtime/operations/{request_id}/rejoin` — replay + follow the
|
|
177
|
+
* ORIGINAL NDJSON response while its detached task is alive (409 when live
|
|
178
|
+
* delivery is unavailable — fall back to the durable lifecycle stream)
|
|
179
|
+
*
|
|
180
|
+
* The contract: identify → recover durable progress → follow live → re-query
|
|
181
|
+
* the final result from the feature's own record. Token text is deliberately
|
|
182
|
+
* never replayed on the lifecycle stream — that is what `/rejoin` is for.
|
|
183
|
+
*
|
|
184
|
+
* The SSE wire rides the package's own `stream/sse` kernel. This module owns
|
|
185
|
+
* ONE connection's semantics (frames → typed events, cursor advancement,
|
|
186
|
+
* terminal `end`); stall timers, retry budgets, and reconnect loops stay host
|
|
187
|
+
* policy — every yielded item carries the cursor the next attempt resumes from.
|
|
188
|
+
*/
|
|
189
|
+
|
|
190
|
+
/** `matrx_runtime.models.ExecutionStatus` — the only progress column. */
|
|
191
|
+
type MatrxRuntimeExecutionStatus = "pending" | "running" | "paused" | "waiting_input" | "completed" | "failed" | "cancelled";
|
|
192
|
+
/** One durable spine event on the wire (`OperationEvent`) — `seq` is the reconnect cursor. */
|
|
193
|
+
interface MatrxRuntimeOperationEvent {
|
|
194
|
+
seq: number | null;
|
|
195
|
+
/** Lifecycle vocabulary: created | started | paused | resumed | waiting_input | completed | failed | cancelled | checkpoint_saved | note. */
|
|
196
|
+
kind: string;
|
|
197
|
+
execution_id: string;
|
|
198
|
+
root_execution_id: string | null;
|
|
199
|
+
detail: MatrxJsonObject | null;
|
|
200
|
+
created_at: string | null;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export type { MatrxTransport as M, MatrxStreamEnvelope as a, MatrxRuntimeOperationEvent as b, MatrxRuntimeExecutionStatus as c, MatrxNdjsonIssue as d, MatrxStreamEnvelopeObservation as e, MatrxConversationStart as f, MatrxJsonValue as g, MatrxJsonObject as h };
|