@celestia-island/plana-types 0.1.4 → 0.1.5
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/bindings/gateway.ts +54 -2
- package/bindings/ops.ts +149 -0
- package/bindings/protocol-core-httpTypes.ts +8 -7
- package/index.ts +3 -0
- package/package.json +1 -1
package/bindings/gateway.ts
CHANGED
|
@@ -135,7 +135,28 @@ export type QuotaState = { remaining: bigint, limit: bigint, allowed: boolean, }
|
|
|
135
135
|
* `rescue.diagnose` params. The diagnostics bundle is opaque to the
|
|
136
136
|
* protocol (the model defines its shape).
|
|
137
137
|
*/
|
|
138
|
-
export type RescueDiagnoseParams = { bundle: JsonValue,
|
|
138
|
+
export type RescueDiagnoseParams = { bundle: JsonValue,
|
|
139
|
+
/**
|
|
140
|
+
* Ask for deferred mode (default false = the blocking behaviour that
|
|
141
|
+
* every current deployment serves).
|
|
142
|
+
*
|
|
143
|
+
* The diagnostic LLM call has a budget of minutes, which far exceeds
|
|
144
|
+
* the service profile's dispatch stall limit (a liveness guard measured
|
|
145
|
+
* in seconds — see `plana-rpc-server`'s crate docs). A server that
|
|
146
|
+
* implements deferred mode answers `deferred: true` immediately with
|
|
147
|
+
* [`RescueDiagnoseStarted`] instead of holding the dispatch, and the
|
|
148
|
+
* caller collects the [`RescueDiagnoseResult`] through the built-in
|
|
149
|
+
* deferred-op methods (`ops.result {op_id}` / the advisory
|
|
150
|
+
* `ops.settled` notification).
|
|
151
|
+
*
|
|
152
|
+
* **Adoption is a follow-up**: the reference gateway still drops this
|
|
153
|
+
* flag and blocks until the model returns, so a client must not send
|
|
154
|
+
* `deferred: true` until its target deployment has adopted it (it will
|
|
155
|
+
* otherwise block, and answer the stall error past the limit). The flag
|
|
156
|
+
* is defined here so the adoption is mechanical, and it is additive: a
|
|
157
|
+
* server that ignores it keeps behaving exactly as before.
|
|
158
|
+
*/
|
|
159
|
+
deferred?: boolean, };
|
|
139
160
|
|
|
140
161
|
/**
|
|
141
162
|
* `rescue.diagnose.progress` notification params.
|
|
@@ -147,7 +168,16 @@ export type RescueDiagnoseProgressParams = {
|
|
|
147
168
|
step: number, };
|
|
148
169
|
|
|
149
170
|
/**
|
|
150
|
-
* `rescue.diagnose` result.
|
|
171
|
+
* `rescue.diagnose` result. Exactly one of the two shapes is returned,
|
|
172
|
+
* selected by [`RescueDiagnoseParams::deferred`]:
|
|
173
|
+
*
|
|
174
|
+
* - `deferred: false` (default) → a completed diagnosis.
|
|
175
|
+
* - `deferred: true` → [`RescueDiagnoseStarted`]: the op reference and its
|
|
176
|
+
* validity window.
|
|
177
|
+
*
|
|
178
|
+
* A client tells them apart by the presence of `op_id` (the deferred start)
|
|
179
|
+
* versus `diagnosis` (the completed result); the two shapes share no field
|
|
180
|
+
* name, so the discrimination is unambiguous.
|
|
151
181
|
*/
|
|
152
182
|
export type RescueDiagnoseResult = {
|
|
153
183
|
/**
|
|
@@ -163,6 +193,28 @@ model: string,
|
|
|
163
193
|
*/
|
|
164
194
|
generated_at: string, };
|
|
165
195
|
|
|
196
|
+
/**
|
|
197
|
+
* `rescue.diagnose` result when [`RescueDiagnoseParams::deferred`] is set:
|
|
198
|
+
* the work was handed off, this is what to collect it with.
|
|
199
|
+
*
|
|
200
|
+
* The shape is the generic deferred-op answer
|
|
201
|
+
* (`plana::jsonrpc::deferred::DeferredOpCreated`) — declared here as well so
|
|
202
|
+
* the gateway's published TypeScript bindings carry it without depending on
|
|
203
|
+
* a generated file outside this package. [`DeferredOpCreated`] remains the
|
|
204
|
+
* canonical definition; a parity test pins the two to the same wire shape.
|
|
205
|
+
*/
|
|
206
|
+
export type RescueDiagnoseStarted = {
|
|
207
|
+
/**
|
|
208
|
+
* Opaque, unguessable deferred-operation reference.
|
|
209
|
+
*/
|
|
210
|
+
op_id: string,
|
|
211
|
+
/**
|
|
212
|
+
* Remaining validity of `op_id` in seconds, measured from creation
|
|
213
|
+
* (the 10–30 minute band; the collect call still works after a
|
|
214
|
+
* reconnect inside the window).
|
|
215
|
+
*/
|
|
216
|
+
expires_in: bigint, };
|
|
217
|
+
|
|
166
218
|
/**
|
|
167
219
|
* `rescue.open_session` params. The ticket is the one-shot opaque
|
|
168
220
|
* credential issued by the OAuth callback redirect; it is consumed
|
package/bindings/ops.ts
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
// Vendored snapshot of packages/plana/bindings/ops.ts (ts-rs generated) so the
|
|
2
|
+
// published npm tarball carries the deferred-operation wire shapes: npm `files`
|
|
3
|
+
// cannot reach a sibling package's directory, exactly as with
|
|
4
|
+
// `protocol-core-httpTypes.ts` above. Re-sync after `cargo test -p plana`
|
|
5
|
+
// whenever the deferred types in packages/plana/src/jsonrpc/deferred.rs or the
|
|
6
|
+
// JSON-RPC error object change.
|
|
7
|
+
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
|
8
|
+
import type { JsonValue } from "./serde_json/JsonValue";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Immediate answer of a handler that switched to deferred mode.
|
|
12
|
+
*
|
|
13
|
+
* `expires_in` is the **remaining** validity in seconds measured from
|
|
14
|
+
* creation, not from the moment of serialization — a client that reconnects
|
|
15
|
+
* half-way through the window sees the shrunk remainder.
|
|
16
|
+
*/
|
|
17
|
+
export type DeferredOpCreated = {
|
|
18
|
+
/**
|
|
19
|
+
* The opaque client-facing reference.
|
|
20
|
+
*/
|
|
21
|
+
op_id: DeferredOpRef,
|
|
22
|
+
/**
|
|
23
|
+
* Remaining validity of `op_id`, in seconds.
|
|
24
|
+
*/
|
|
25
|
+
expires_in: bigint, };
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Current state of a deferred operation, as answered by `ops.result`.
|
|
29
|
+
*
|
|
30
|
+
* Exactly one of `result` / `error` is present once the status is terminal;
|
|
31
|
+
* both are absent while the status is `pending`.
|
|
32
|
+
*/
|
|
33
|
+
export type DeferredOpOutcome = {
|
|
34
|
+
/**
|
|
35
|
+
* The collected reference (echoed so a multiplexed client can route).
|
|
36
|
+
*/
|
|
37
|
+
op_id: DeferredOpRef,
|
|
38
|
+
/**
|
|
39
|
+
* Current lifecycle status.
|
|
40
|
+
*/
|
|
41
|
+
status: DeferredOpStatus,
|
|
42
|
+
/**
|
|
43
|
+
* The method whose handler deferred the work — audit and debugging
|
|
44
|
+
* surface; the outcome is meaningless without knowing what it is a
|
|
45
|
+
* result of.
|
|
46
|
+
*/
|
|
47
|
+
method: string,
|
|
48
|
+
/**
|
|
49
|
+
* Remaining validity of this entry, in seconds. Once it reaches zero the
|
|
50
|
+
* entry is gone and the id answers `-32053`.
|
|
51
|
+
*/
|
|
52
|
+
expires_in: bigint,
|
|
53
|
+
/**
|
|
54
|
+
* Whether a cancellation was requested through `ops.cancel` while the
|
|
55
|
+
* operation was still pending (advisory — the worker may not honour it).
|
|
56
|
+
*/
|
|
57
|
+
cancel_requested: boolean,
|
|
58
|
+
/**
|
|
59
|
+
* Present iff `status == completed`.
|
|
60
|
+
*/
|
|
61
|
+
result?: JsonValue,
|
|
62
|
+
/**
|
|
63
|
+
* Present iff `status == failed`.
|
|
64
|
+
*/
|
|
65
|
+
error?: JsonRpcError, };
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Client-facing reference to a deferred operation.
|
|
69
|
+
*
|
|
70
|
+
* Opaque, unguessable and stable for the whole validity window: the id is
|
|
71
|
+
* the same string before and after a reconnect, so a client (or a different
|
|
72
|
+
* client, e.g. a browser tab resuming a rescue session) can collect with it
|
|
73
|
+
* while the entry is retained — the registry's retention cap can evict a
|
|
74
|
+
* settled outcome early, the id string itself never changes. Treat it as a
|
|
75
|
+
* bearer value — whoever holds it can read the outcome.
|
|
76
|
+
*/
|
|
77
|
+
export type DeferredOpRef = string;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* `ops.settled` notification params.
|
|
81
|
+
*
|
|
82
|
+
* Advisory only: it says *that* an operation settled, never *what* it
|
|
83
|
+
* produced — the client still calls `ops.result` to collect the payload.
|
|
84
|
+
* That keeps a single authoritative collection path.
|
|
85
|
+
*/
|
|
86
|
+
export type DeferredOpSettledParams = {
|
|
87
|
+
/**
|
|
88
|
+
* The reference that settled.
|
|
89
|
+
*/
|
|
90
|
+
op_id: DeferredOpRef,
|
|
91
|
+
/**
|
|
92
|
+
* Its new status.
|
|
93
|
+
*/
|
|
94
|
+
status: DeferredOpStatus, };
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Lifecycle of a deferred operation.
|
|
98
|
+
*
|
|
99
|
+
* A cancellation request does **not** add a state: `ops.cancel` only sets a
|
|
100
|
+
* flag the worker may observe, and a cancelled operation settles as
|
|
101
|
+
* [`DeferredOpStatus::Failed`] with `-32055` (`error_codes::OPS_CANCELLED`)
|
|
102
|
+
* when the worker honours it. That keeps the state machine to the three
|
|
103
|
+
* states a client actually has to handle.
|
|
104
|
+
*/
|
|
105
|
+
export type DeferredOpStatus = "pending" | "completed" | "failed";
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The JSON-RPC 2.0 error object. Also generated into the TypeScript
|
|
109
|
+
* bindings, because it is the payload a client must parse out of a
|
|
110
|
+
* deferred outcome (`plana::jsonrpc::deferred`).
|
|
111
|
+
*/
|
|
112
|
+
export type JsonRpcError = { code: bigint, message: string, data?: JsonValue, };
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* `ops.cancel` params.
|
|
116
|
+
*/
|
|
117
|
+
export type OpsCancelParams = {
|
|
118
|
+
/**
|
|
119
|
+
* The reference to ask cancellation for.
|
|
120
|
+
*/
|
|
121
|
+
op_id: DeferredOpRef, };
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* `ops.cancel` result.
|
|
125
|
+
*/
|
|
126
|
+
export type OpsCancelResult = {
|
|
127
|
+
/**
|
|
128
|
+
* The reference the request was recorded for.
|
|
129
|
+
*/
|
|
130
|
+
op_id: DeferredOpRef,
|
|
131
|
+
/**
|
|
132
|
+
* The status observed at request time.
|
|
133
|
+
*/
|
|
134
|
+
status: DeferredOpStatus,
|
|
135
|
+
/**
|
|
136
|
+
* True when the request was recorded for a still-pending operation (so
|
|
137
|
+
* the worker can observe it); false when the operation had already
|
|
138
|
+
* settled and there was nothing to cancel.
|
|
139
|
+
*/
|
|
140
|
+
cancel_requested: boolean, };
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* `ops.result` params.
|
|
144
|
+
*/
|
|
145
|
+
export type OpsResultParams = {
|
|
146
|
+
/**
|
|
147
|
+
* The reference to collect.
|
|
148
|
+
*/
|
|
149
|
+
op_id: DeferredOpRef, };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
// Vendored snapshot of
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
// crate's own ts-rs-generated
|
|
7
|
-
//
|
|
1
|
+
// Vendored snapshot of the plana foundation's generated bindings
|
|
2
|
+
// (packages/plana/bindings/httpTypes.ts — the former
|
|
3
|
+
// packages/protocol-core/bindings/httpTypes.ts, which the protocol-core
|
|
4
|
+
// re-export shim no longer owns) so the published npm tarball is
|
|
5
|
+
// self-contained: npm `files` cannot reach a sibling package's directory.
|
|
6
|
+
// Distinct filename to avoid colliding with this crate's own ts-rs-generated
|
|
7
|
+
// bindings/httpTypes.ts. Re-sync when the foundation's HttpTypes bindings
|
|
8
|
+
// change (`cargo test -p plana` then re-copy).
|
|
8
9
|
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
|
9
10
|
|
|
10
11
|
/**
|
package/index.ts
CHANGED
|
@@ -39,6 +39,9 @@ export * from "./bindings/gateway";
|
|
|
39
39
|
export * from "./bindings/httpTypes";
|
|
40
40
|
export * from "./bindings/mdd";
|
|
41
41
|
export * from "./bindings/model";
|
|
42
|
+
// Deferred-operation wire shapes (vendored snapshot of plana's generated
|
|
43
|
+
// bindings): no name on this file's surface collides with the exports above.
|
|
44
|
+
export * from "./bindings/ops";
|
|
42
45
|
export * from "./bindings/ws/agentLifecycle";
|
|
43
46
|
export * from "./bindings/ws/auth";
|
|
44
47
|
export * from "./bindings/ws/bridgeNetwork";
|