@supernovae-st/nika 0.118.7 → 0.120.2
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 +649 -162
- package/dist/index.cjs +809 -144
- package/dist/index.d.cts +315 -19
- package/dist/index.d.ts +315 -19
- package/dist/index.js +808 -144
- package/docs/architecture.md +75 -12
- package/docs/http-api.md +81 -8
- package/docs/migrating-to-0.116.md +21 -6
- package/docs/testing.md +27 -2
- package/openapi.json +1797 -1
- package/package.json +9 -8
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
interface NikaSharedConfig {
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* How many of a run's most recent frames a session retains, and therefore
|
|
4
|
+
* the most a view opened after the fact can be given, and the largest
|
|
5
|
+
* `bufferSize` a view may ask for. Default: 4096 frames. For scale, one
|
|
6
|
+
* measured fixture (a clean native run of 90 independent mock/echo infer
|
|
7
|
+
* tasks) wrote 273 frames; other shapes write more, so count your own.
|
|
8
|
+
*
|
|
9
|
+
* It is a finite bound, never a promise about the run. A run longer than it
|
|
10
|
+
* still succeeds and `run.result()` still resolves; only a late view is
|
|
11
|
+
* refused, with `NikaEventBufferOverflowError` whose `reason` is
|
|
12
|
+
* `replay_truncated` and whose `observed` says what to set. An explicit
|
|
13
|
+
* value is kept exactly as given. Each frame is bounded by
|
|
14
|
+
* `machineBufferBytes`, so the retained history holds at most
|
|
15
|
+
* `eventBufferSize * machineBufferBytes` of frame text per run. That bounds
|
|
16
|
+
* the history only: frames already handed to a consumer, other views and
|
|
17
|
+
* other runs are not counted in it.
|
|
18
|
+
*/
|
|
3
19
|
eventBufferSize?: number;
|
|
4
20
|
/** Bound for buffered diagnostics and one machine frame. Default: 64 KiB. */
|
|
5
21
|
machineBufferBytes?: number;
|
|
@@ -130,11 +146,38 @@ interface NikaRunSealedEvent extends NikaEventFields {
|
|
|
130
146
|
kind: 'run_sealed';
|
|
131
147
|
receipt?: NikaReceipt;
|
|
132
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* A journal delivery loss the resident reported, exactly as its contract
|
|
151
|
+
* closes it: the run's journal mirror stopped recording. It is independent of
|
|
152
|
+
* the execution: a run can settle `succeeded` and still carry it. It is never
|
|
153
|
+
* a verdict and never changes a status; it says the trace may be incomplete
|
|
154
|
+
* before `traceVerify` is trusted. Its absence is only absence: it never
|
|
155
|
+
* claims that a journal exists.
|
|
156
|
+
*
|
|
157
|
+
* Engine main, ahead of the contract this package pins: no released engine
|
|
158
|
+
* writes it yet, and a resident that predates it simply never sends it.
|
|
159
|
+
*/
|
|
160
|
+
interface NikaJournalEvidence {
|
|
161
|
+
status: 'mirror_lost';
|
|
162
|
+
/** The mirror's first error, classified: never OS text, never a path. */
|
|
163
|
+
reason: 'write_failed' | 'record_refused';
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Fields only the resident's frames carry, both from engine main, ahead of the
|
|
167
|
+
* contract this package pins. Both are optional on the wire and absent on a
|
|
168
|
+
* resident that predates them.
|
|
169
|
+
*/
|
|
170
|
+
interface NikaResidentEventFields extends NikaEventFields {
|
|
171
|
+
/** When the resident admitted the event: RFC 3339, UTC. Outside the event's hash chain. */
|
|
172
|
+
at?: string;
|
|
173
|
+
/** A reported journal delivery loss, on the terminal frame. */
|
|
174
|
+
evidence?: NikaJournalEvidence;
|
|
175
|
+
}
|
|
133
176
|
/**
|
|
134
177
|
* The HTTP transport admitted the execution and it is running. This is the
|
|
135
178
|
* first lifecycle frame `nika serve --bind` streams for a durable job.
|
|
136
179
|
*/
|
|
137
|
-
interface NikaExecutionStartedEvent extends
|
|
180
|
+
interface NikaExecutionStartedEvent extends NikaResidentEventFields {
|
|
138
181
|
kind: 'execution.started';
|
|
139
182
|
}
|
|
140
183
|
/**
|
|
@@ -142,7 +185,7 @@ interface NikaExecutionStartedEvent extends NikaEventFields {
|
|
|
142
185
|
* `run_settled`: the one frame that carries the run's outputs, receipt, and
|
|
143
186
|
* final status together.
|
|
144
187
|
*/
|
|
145
|
-
interface NikaExecutionSettledEvent<Outputs extends Record<string, unknown> = Record<string, unknown>> extends
|
|
188
|
+
interface NikaExecutionSettledEvent<Outputs extends Record<string, unknown> = Record<string, unknown>> extends NikaResidentEventFields {
|
|
146
189
|
kind: 'execution.settled';
|
|
147
190
|
status?: NikaRunStatus;
|
|
148
191
|
outputs?: Outputs;
|
|
@@ -155,19 +198,19 @@ interface NikaExecutionSettledEvent<Outputs extends Record<string, unknown> = Re
|
|
|
155
198
|
* claimed, or a running one whose owner settled the request as a
|
|
156
199
|
* cancellation. It carries the settlement when the runtime built one.
|
|
157
200
|
*/
|
|
158
|
-
interface NikaExecutionCancelledEvent extends
|
|
201
|
+
interface NikaExecutionCancelledEvent extends NikaResidentEventFields {
|
|
159
202
|
kind: 'execution.cancelled';
|
|
160
203
|
settlement?: NikaSettlement;
|
|
161
204
|
}
|
|
162
205
|
/** The server refused the execution. */
|
|
163
|
-
interface NikaExecutionRefusedEvent extends
|
|
206
|
+
interface NikaExecutionRefusedEvent extends NikaResidentEventFields {
|
|
164
207
|
kind: 'execution.refused';
|
|
165
208
|
}
|
|
166
209
|
/**
|
|
167
210
|
* The execution was interrupted before settling. A resident that restarts
|
|
168
211
|
* marks an orphaned running job with either word, so both are one variant.
|
|
169
212
|
*/
|
|
170
|
-
interface NikaExecutionInterruptedEvent extends
|
|
213
|
+
interface NikaExecutionInterruptedEvent extends NikaResidentEventFields {
|
|
171
214
|
kind: 'execution.interrupted' | 'interrupted';
|
|
172
215
|
}
|
|
173
216
|
/**
|
|
@@ -187,6 +230,69 @@ interface NikaUnknownEvent extends NikaEventFields {
|
|
|
187
230
|
* shape, so untyped callers see no change.
|
|
188
231
|
*/
|
|
189
232
|
type NikaEvent<Outputs extends Record<string, unknown> = Record<string, unknown>> = NikaWorkflowStartedEvent | NikaTaskScheduledEvent | NikaTaskStartedEvent | NikaTaskCompletedEvent | NikaWorkflowCompletedEvent<Outputs> | NikaWorkflowFailedEvent | NikaWorkflowInterruptedEvent | NikaRunSettledEvent<Outputs> | NikaRunSealedEvent | NikaExecutionStartedEvent | NikaExecutionSettledEvent<Outputs> | NikaExecutionCancelledEvent | NikaExecutionRefusedEvent | NikaExecutionInterruptedEvent | NikaUnknownEvent;
|
|
233
|
+
/**
|
|
234
|
+
* The SDK's one lifecycle vocabulary, identical on both transports. Each word
|
|
235
|
+
* names a fact an engine wrote; the protocol word that carried it stays on
|
|
236
|
+
* `raw.kind`. Transports differ in cardinality, never in these names.
|
|
237
|
+
*
|
|
238
|
+
* A frame that speaks of the run's state earns its name only for a
|
|
239
|
+
* (kind, status) pair a producer defines. The engine's state word decides and
|
|
240
|
+
* is never defaulted: an absent, null, future, or still-running status, or
|
|
241
|
+
* one that contradicts its kind, stays an `engine.event`.
|
|
242
|
+
*
|
|
243
|
+
* - `run.started`: `workflow_started` · `execution.started`.
|
|
244
|
+
* - `task.scheduled` · `task.started` · `task.completed` · `task.failed`: the
|
|
245
|
+
* native `task_*` frames. `nika serve` streams no per-task frame, so an HTTP
|
|
246
|
+
* run yields none; the SDK never synthesizes one.
|
|
247
|
+
* - `run.waiting`: the settlement frame (`run_settled` · `execution.settled`)
|
|
248
|
+
* carrying `paused`. A human gate holds the run: it is not failed, not a
|
|
249
|
+
* completed execution, and stays resumable.
|
|
250
|
+
* - `run.settled`: exactly these pairs, and no other. The settlement frame
|
|
251
|
+
* (`run_settled` · `execution.settled`) carrying `succeeded`, `failed`, or
|
|
252
|
+
* `cancelled`; `execution.cancelled` carrying `cancelled`;
|
|
253
|
+
* `execution.refused` carrying `failed`. A dedicated end kind with another
|
|
254
|
+
* terminal word (a refusal that `succeeded`, a cancellation that `failed`)
|
|
255
|
+
* contradicts itself and stays an `engine.event`.
|
|
256
|
+
* - `run.interrupted`: `workflow_interrupted` · `execution.interrupted` ·
|
|
257
|
+
* `interrupted` carrying `interrupted`. The engine lost the execution and
|
|
258
|
+
* its settlement is unknown: an evidence state, never a settlement. This is
|
|
259
|
+
* an engine-reported frame, distinct from the thrown
|
|
260
|
+
* `NikaObservationInterrupted`, which means this client lost its
|
|
261
|
+
* observation of a run that may still be running.
|
|
262
|
+
* - `run.sealed`: `run_sealed`, native only.
|
|
263
|
+
* - `engine.event`: every other frame, including kinds this SDK version does
|
|
264
|
+
* not know yet. Nothing is dropped; read `raw`.
|
|
265
|
+
*
|
|
266
|
+
* The projection keeps no state between frames and deduplicates nothing. The
|
|
267
|
+
* set is additive: keep a `default` branch.
|
|
268
|
+
*/
|
|
269
|
+
type NikaRunEventKind = 'run.started' | 'task.scheduled' | 'task.started' | 'task.completed' | 'task.failed' | 'run.waiting' | 'run.settled' | 'run.interrupted' | 'run.sealed' | 'engine.event';
|
|
270
|
+
/**
|
|
271
|
+
* One run event in the SDK's lifecycle vocabulary, as `run.events()` yields
|
|
272
|
+
* it. It is a projection of exactly one protocol frame: `raw` is that frame,
|
|
273
|
+
* untouched, and every other field is present only when the frame stated it.
|
|
274
|
+
* An `engine.event` is given no lifecycle meaning: it carries no `status`,
|
|
275
|
+
* `task` or `error`, only its cursor and `raw`.
|
|
276
|
+
*/
|
|
277
|
+
interface NikaRunEvent<Outputs extends Record<string, unknown> = Record<string, unknown>> {
|
|
278
|
+
readonly kind: NikaRunEventKind;
|
|
279
|
+
/** The transport whose protocol `raw` speaks. */
|
|
280
|
+
readonly transport: NikaTransportKind;
|
|
281
|
+
/** The engine's own state word, never renamed: a waiting run reads `paused`. */
|
|
282
|
+
readonly status?: NikaRunStatus;
|
|
283
|
+
/**
|
|
284
|
+
* HTTP only: the SSE sequence of this frame, the cursor to persist for
|
|
285
|
+
* `attachRun(id, { lastEventId })`. A native process has no durable replay,
|
|
286
|
+
* so a native event never carries one.
|
|
287
|
+
*/
|
|
288
|
+
readonly sequence?: number;
|
|
289
|
+
/** The task a `task.*` frame named. */
|
|
290
|
+
readonly task?: string;
|
|
291
|
+
/** The failure the frame named: a failed task, or a failed settlement. */
|
|
292
|
+
readonly error?: NikaMachineError;
|
|
293
|
+
/** The exact protocol frame the engine wrote. */
|
|
294
|
+
readonly raw: NikaEvent<Outputs>;
|
|
295
|
+
}
|
|
190
296
|
/**
|
|
191
297
|
* Engine-issued proof material. The SDK transports it but never constructs,
|
|
192
298
|
* reads a workflow to enrich it, or verifies its claims itself.
|
|
@@ -250,7 +356,13 @@ interface NikaSettlement {
|
|
|
250
356
|
error?: NikaMachineError;
|
|
251
357
|
[key: string]: unknown;
|
|
252
358
|
}
|
|
253
|
-
/**
|
|
359
|
+
/**
|
|
360
|
+
* The engine's result of observing an admitted run, including a paused run.
|
|
361
|
+
* Admitted workflow failure resolves with `status: 'failed'`; configuration,
|
|
362
|
+
* transport, protocol, and compatibility errors reject instead. Use
|
|
363
|
+
* `isNikaRunSucceeded(result)` before treating an observation as success.
|
|
364
|
+
* Outputs are optional even on success, and status stays forward-compatible.
|
|
365
|
+
*/
|
|
254
366
|
interface NikaRunResult<Outputs extends Record<string, unknown> = Record<string, unknown>> {
|
|
255
367
|
id: NikaRunId;
|
|
256
368
|
status: NikaRunStatus;
|
|
@@ -263,11 +375,68 @@ interface NikaRunResult<Outputs extends Record<string, unknown> = Record<string,
|
|
|
263
375
|
execution_id?: NikaExecutionId;
|
|
264
376
|
/** The settlement's cause, tally and spend (engine 0.118+), when the terminal frame carried them. */
|
|
265
377
|
settlement?: NikaSettlement;
|
|
378
|
+
/**
|
|
379
|
+
* HTTP only: the journal delivery loss the resident reported on the terminal
|
|
380
|
+
* frame or the durable job that settled this run. Copied, never inferred:
|
|
381
|
+
* absent when the resident reported none, which claims nothing about a
|
|
382
|
+
* journal. It never changes `status`. A native process reports none.
|
|
383
|
+
*/
|
|
384
|
+
evidence?: NikaJournalEvidence;
|
|
266
385
|
[key: string]: unknown;
|
|
267
386
|
}
|
|
268
|
-
/**
|
|
387
|
+
/**
|
|
388
|
+
* An admitted run and its whole lifecycle. `run()` and `attachRun()` return
|
|
389
|
+
* one only after admission: a workflow the engine refuses rejects there and
|
|
390
|
+
* never yields a handle. Every member is bound to the run, so a method may be
|
|
391
|
+
* extracted (`const { events, result } = run`) and still works.
|
|
392
|
+
*
|
|
393
|
+
* The handle owns observation, settlement, status and cancellation, nothing
|
|
394
|
+
* else: checking, proof, catalogs and authoring stay on `Nika`. It is
|
|
395
|
+
* process-bound. To continue in another process, persist `id` and the last
|
|
396
|
+
* `event.sequence` you fully processed, then call
|
|
397
|
+
* `nika.attachRun(id, { lastEventId })`, the one recovery door.
|
|
398
|
+
*
|
|
399
|
+
* `id` is what differs by transport, and the type cannot show it:
|
|
400
|
+
* - HTTP: the resident's durable job id. This is the identity to store.
|
|
401
|
+
* - native: an ephemeral correlation id of this SDK process. It appears in no
|
|
402
|
+
* journal and cannot be recovered after the process ends; `attachRun`
|
|
403
|
+
* refuses it. Resume a native run through the engine's own trace.
|
|
404
|
+
*/
|
|
269
405
|
interface NikaRun<Outputs extends Record<string, unknown> = Record<string, unknown>> {
|
|
270
406
|
readonly id: NikaRunId;
|
|
407
|
+
/**
|
|
408
|
+
* A bounded view of the run's events in the SDK's lifecycle vocabulary;
|
|
409
|
+
* each event keeps its protocol frame on `raw`. Transports differ in how
|
|
410
|
+
* many facts they emit, never in their names. The iterator throws for a
|
|
411
|
+
* broken observation (`NikaObservationInterrupted` carries the cursor); an
|
|
412
|
+
* admitted workflow failure ends it normally and is read from `result()`.
|
|
413
|
+
*/
|
|
414
|
+
readonly events: (options?: NikaEventsOptions) => AsyncIterable<NikaRunEvent<Outputs>>;
|
|
415
|
+
/**
|
|
416
|
+
* The engine's result of observing this run, settled once. One failure law:
|
|
417
|
+
* - rejects: a transport, protocol, or compatibility fault, or a broken
|
|
418
|
+
* observation (`NikaObservationInterrupted`, which carries the cursor).
|
|
419
|
+
* None of them says the run failed; it may still be running.
|
|
420
|
+
* - resolves with `status: 'failed'`: an admitted failure is result data,
|
|
421
|
+
* with the engine's `error.code` when the engine named one. `cancelled`
|
|
422
|
+
* and the engine-reported `interrupted` resolve the same way.
|
|
423
|
+
* - resolves with `status: 'paused'`: a human gate holds the run. It is
|
|
424
|
+
* neither a failure nor a completed execution.
|
|
425
|
+
* Read `isNikaRunSucceeded(result)` before treating it as success.
|
|
426
|
+
*/
|
|
427
|
+
readonly result: () => Promise<NikaRunResult<Outputs>>;
|
|
428
|
+
/**
|
|
429
|
+
* The current durable status, without waiting for settlement. Only a
|
|
430
|
+
* resident owns one: a native run rejects with a typed
|
|
431
|
+
* `NikaCompatibilityError` instead of inventing a status.
|
|
432
|
+
*/
|
|
433
|
+
readonly status: () => Promise<NikaRunStatus>;
|
|
434
|
+
/**
|
|
435
|
+
* Ask the engine to cancel. Idempotent: every call returns the one request.
|
|
436
|
+
* Acceptance is not a result; read what the engine recorded from `result()`.
|
|
437
|
+
*/
|
|
438
|
+
readonly cancel: () => Promise<NikaCancelResult>;
|
|
439
|
+
/** Compatibility alias of `result()`: the same promise, kept while code migrates. */
|
|
271
440
|
readonly done: Promise<NikaRunResult<Outputs>>;
|
|
272
441
|
}
|
|
273
442
|
interface NikaCancelResult {
|
|
@@ -278,9 +447,9 @@ interface NikaCancelResult {
|
|
|
278
447
|
* `already_settled`: the run had already ended, nothing was cancelled.
|
|
279
448
|
* `cancellation_requested`: the request was accepted while the execution
|
|
280
449
|
* owner had not settled yet (a native SIGTERM, or the resident's 202); the
|
|
281
|
-
* run then settles on its own terminal, read from `run.
|
|
282
|
-
* `cancelled`, `succeeded`, `failed`, or `interrupted` once the
|
|
283
|
-
* grace expired. Open to the engine's future words.
|
|
450
|
+
* run then settles on its own terminal, read from `run.result()`, which may
|
|
451
|
+
* be `cancelled`, `succeeded`, `failed`, or `interrupted` once the
|
|
452
|
+
* resident's grace expired. Open to the engine's future words.
|
|
284
453
|
*/
|
|
285
454
|
status: 'cancelled' | 'already_settled' | 'cancellation_requested' | (string & {});
|
|
286
455
|
transport: NikaTransportKind;
|
|
@@ -315,10 +484,39 @@ interface NikaCheckOptions {
|
|
|
315
484
|
signal?: AbortSignal;
|
|
316
485
|
}
|
|
317
486
|
interface NikaRunOptions {
|
|
487
|
+
/**
|
|
488
|
+
* Literal values for the workflow's declared `inputs:`, by name, with the
|
|
489
|
+
* same meaning on both transports. Values are strict JSON and stay literal:
|
|
490
|
+
* a string is never read as `@env:NAME`, an expression or a number, and
|
|
491
|
+
* nothing is coerced to the declared type. The engine validates the map
|
|
492
|
+
* (unknown key, type mismatch, missing required input) and refuses before
|
|
493
|
+
* any run exists. A value JSON cannot carry (`undefined`, a function, a
|
|
494
|
+
* symbol, a bigint, a non-finite number, a cycle, a class instance, a
|
|
495
|
+
* custom prototype, an array hole, an accessor, a Proxy) rejects `run()`
|
|
496
|
+
* with `NikaConfigurationError` instead of being dropped, and the
|
|
497
|
+
* serialized map is bounded at 1 MiB. No caller code runs while it is
|
|
498
|
+
* judged: no getter is invoked, and a Proxy is refused before it is read.
|
|
499
|
+
*
|
|
500
|
+
* Needs an engine that advertises the literal channel: `inputsLiteral`
|
|
501
|
+
* natively (values ride stdin, never argv), `jobInputs` over HTTP by served
|
|
502
|
+
* name. An engine without it rejects with `NikaCompatibilityError`; the SDK
|
|
503
|
+
* never falls back to `--var`. An execution snapshot freezes its inputs, so
|
|
504
|
+
* an HTTP run of a local path refuses `inputs`. Never put a secret here.
|
|
505
|
+
*/
|
|
506
|
+
inputs?: Record<string, unknown>;
|
|
507
|
+
/**
|
|
508
|
+
* @deprecated Use `inputs`. `vars` is the native `--var KEY=VALUE` operator
|
|
509
|
+
* channel: the engine reads `@env:NAME` from its environment and coerces
|
|
510
|
+
* text to the declared type, so it cannot carry literal API values and has
|
|
511
|
+
* no HTTP form. Combining it with `inputs` rejects `run()`.
|
|
512
|
+
*/
|
|
318
513
|
vars?: Record<string, string | number | boolean>;
|
|
319
514
|
model?: string;
|
|
320
515
|
maxCostUsd?: number;
|
|
321
|
-
/**
|
|
516
|
+
/**
|
|
517
|
+
* Required for HTTP admission; reuse the same key and request after an
|
|
518
|
+
* uncertain response. Direct native runs reject this option.
|
|
519
|
+
*/
|
|
322
520
|
idempotencyKey?: string;
|
|
323
521
|
}
|
|
324
522
|
/** Resume observation of an already-admitted durable HTTP job. */
|
|
@@ -329,7 +527,12 @@ interface NikaAttachRunOptions {
|
|
|
329
527
|
interface NikaEventsOptions {
|
|
330
528
|
/** Stops this subscriber view. It never cancels the run. */
|
|
331
529
|
signal?: AbortSignal;
|
|
332
|
-
/**
|
|
530
|
+
/**
|
|
531
|
+
* Per-view queue bound, capped by the client eventBufferSize, which is also
|
|
532
|
+
* its default. A live view that falls further behind than this fails with
|
|
533
|
+
* `reason: 'live_backpressure'`; a view opened after more frames than this
|
|
534
|
+
* is refused with `reason: 'replay_truncated'`. Neither skips a frame.
|
|
535
|
+
*/
|
|
333
536
|
bufferSize?: number;
|
|
334
537
|
}
|
|
335
538
|
interface NikaTraceVerifyOptions {
|
|
@@ -344,8 +547,29 @@ interface NikaScheduleFinding {
|
|
|
344
547
|
detail: string;
|
|
345
548
|
[key: string]: unknown;
|
|
346
549
|
}
|
|
347
|
-
/**
|
|
348
|
-
|
|
550
|
+
/**
|
|
551
|
+
* One engine-owned check finding, exactly as the engine's check report
|
|
552
|
+
* carries it. `code` is absent when the engine's failure class names none (an
|
|
553
|
+
* unreadable workflow file); the SDK never supplies one. The vocabulary
|
|
554
|
+
* remains additive.
|
|
555
|
+
*/
|
|
556
|
+
interface NikaCheckFinding {
|
|
557
|
+
code?: string;
|
|
558
|
+
message?: string;
|
|
559
|
+
severity?: string;
|
|
560
|
+
gate?: string;
|
|
561
|
+
kind?: string;
|
|
562
|
+
/** The task the finding judges, when it judges one. */
|
|
563
|
+
task?: string;
|
|
564
|
+
docs_url?: string;
|
|
565
|
+
[key: string]: unknown;
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* Findings carried by the one operation-error taxonomy: a schedule refusal
|
|
569
|
+
* carries schedule findings (`detail`), a refused `run()` carries the check
|
|
570
|
+
* findings that refused it (`message`).
|
|
571
|
+
*/
|
|
572
|
+
type NikaOperationFinding = NikaScheduleFinding | NikaCheckFinding;
|
|
349
573
|
type NikaScheduleWhen = {
|
|
350
574
|
kind: 'once';
|
|
351
575
|
at: string;
|
|
@@ -497,6 +721,10 @@ declare class NikaProtocolError extends NikaTransportError {
|
|
|
497
721
|
/**
|
|
498
722
|
* Observation broke before terminal settlement and the final durable read
|
|
499
723
|
* stayed non-terminal. The cursor feeds attachRun(id, { lastEventId }).
|
|
724
|
+
*
|
|
725
|
+
* This is about the client's view, never about the run: the run may still be
|
|
726
|
+
* running on the resident. It is not the engine's own `interrupted` state,
|
|
727
|
+
* which arrives as a `run.interrupted` event and as `result.status`.
|
|
500
728
|
*/
|
|
501
729
|
declare class NikaObservationInterrupted extends NikaTransportError {
|
|
502
730
|
readonly runId: string;
|
|
@@ -520,10 +748,36 @@ declare class NikaOperationError extends NikaError {
|
|
|
520
748
|
machineCode?: string;
|
|
521
749
|
});
|
|
522
750
|
}
|
|
751
|
+
/**
|
|
752
|
+
* An event view would have had to skip frames, so it refused instead. The SDK
|
|
753
|
+
* never silently omits a frame. Two different bounds can be exceeded, and
|
|
754
|
+
* `reason` says which. Neither is about the run: it keeps running or stays
|
|
755
|
+
* settled, and `run.result()` is unaffected.
|
|
756
|
+
*
|
|
757
|
+
* - `live_backpressure`: a view that was observing live fell more than
|
|
758
|
+
* `limit` frames behind the stream. Read faster, or give it a larger
|
|
759
|
+
* `bufferSize`. Other views are unaffected.
|
|
760
|
+
* - `replay_truncated`: a view was opened after the run had already produced
|
|
761
|
+
* more frames than it can be given. `observed` is how many the session saw
|
|
762
|
+
* and `retained` how many it still holds. When `retained === observed`
|
|
763
|
+
* nothing is lost and a view with `bufferSize >= observed` replays them
|
|
764
|
+
* all; when `retained < observed` the earlier frames are gone from this
|
|
765
|
+
* process, so raise `eventBufferSize` to at least `observed` for the next
|
|
766
|
+
* run, or observe it live.
|
|
767
|
+
*/
|
|
523
768
|
declare class NikaEventBufferOverflowError extends NikaError {
|
|
524
769
|
readonly runId: string;
|
|
770
|
+
/** The bound that was exceeded: the view's `bufferSize`. */
|
|
525
771
|
readonly limit: number;
|
|
526
|
-
|
|
772
|
+
readonly reason: 'live_backpressure' | 'replay_truncated';
|
|
773
|
+
/** `replay_truncated` only: frames the session had observed when it refused. */
|
|
774
|
+
readonly observed?: number;
|
|
775
|
+
/** `replay_truncated` only: frames the session still held when it refused. */
|
|
776
|
+
readonly retained?: number;
|
|
777
|
+
constructor(runId: string, limit: number, replay?: {
|
|
778
|
+
observed: number;
|
|
779
|
+
retained: number;
|
|
780
|
+
});
|
|
527
781
|
}
|
|
528
782
|
declare class NikaRunOwnershipError extends NikaError {
|
|
529
783
|
constructor();
|
|
@@ -538,6 +792,16 @@ declare class NikaEngineUnavailable extends NikaError {
|
|
|
538
792
|
constructor(platform: string, arch: string, packageName?: string);
|
|
539
793
|
}
|
|
540
794
|
|
|
795
|
+
/**
|
|
796
|
+
* Narrows a result to the engine's successful settlement. Admitted failures
|
|
797
|
+
* resolve as result data; awaiting a run alone does not establish success.
|
|
798
|
+
* Paused, cancelled, interrupted, failed, and unknown statuses return false.
|
|
799
|
+
* Outputs remain optional: a successful workflow need not declare any.
|
|
800
|
+
*/
|
|
801
|
+
declare function isNikaRunSucceeded<Outputs extends Record<string, unknown> = Record<string, unknown>>(result: NikaRunResult<Outputs>): result is NikaRunResult<Outputs> & {
|
|
802
|
+
status: 'succeeded';
|
|
803
|
+
};
|
|
804
|
+
|
|
541
805
|
/**
|
|
542
806
|
* Narrows any run event to the terminal settlement frame, which carries the
|
|
543
807
|
* run's status, outputs, and receipt together. Both transports have one: the
|
|
@@ -570,24 +834,56 @@ declare class Nika {
|
|
|
570
834
|
constructor(config?: NikaConfig);
|
|
571
835
|
check(workflow: string, options?: NikaCheckOptions): Promise<NikaCheckResult>;
|
|
572
836
|
/**
|
|
837
|
+
* Resolves with the run's handle once the engine admitted it, and rejects
|
|
838
|
+
* without one when the engine refused it. The handle owns the lifecycle:
|
|
839
|
+
* `run.events()`, `run.result()`, `run.status()`, `run.cancel()`.
|
|
840
|
+
*
|
|
573
841
|
* `Outputs` is the caller's projection of the engine-emitted outputs map;
|
|
574
842
|
* the SDK transports outputs without validating their shape.
|
|
575
843
|
*/
|
|
576
844
|
run<Outputs extends Record<string, unknown> = Record<string, unknown>>(workflow: string, options?: NikaRunOptions): Promise<NikaRun<Outputs>>;
|
|
577
|
-
/**
|
|
845
|
+
/**
|
|
846
|
+
* The one recovery door: reattach this client process to an
|
|
847
|
+
* already-admitted durable HTTP job and get a full `NikaRun` back. Pass the
|
|
848
|
+
* last `event.sequence` you fully processed as `lastEventId`. A native
|
|
849
|
+
* process is process-bound and refuses with a typed compatibility error.
|
|
850
|
+
*/
|
|
578
851
|
attachRun<Outputs extends Record<string, unknown> = Record<string, unknown>>(id: string, options?: NikaAttachRunOptions): Promise<NikaRun<Outputs>>;
|
|
579
852
|
/** List contained workflow names from a resident HTTP authority. */
|
|
580
853
|
listWorkflows(): Promise<readonly string[]>;
|
|
581
854
|
/** Read path-free metadata for one contained workflow. */
|
|
582
855
|
workflow(name: string): Promise<NikaWorkflowMetadata>;
|
|
856
|
+
/**
|
|
857
|
+
* The run's events in the protocol vocabulary of its transport
|
|
858
|
+
* (`workflow_*` · `task_*` · `run_*` natively, `execution.*` over HTTP).
|
|
859
|
+
*
|
|
860
|
+
* @deprecated Use `run.events()`: one lifecycle vocabulary on both
|
|
861
|
+
* transports, with this same frame kept on `event.raw`. This wrapper is a
|
|
862
|
+
* compatibility door for one release train, counted from publication: it
|
|
863
|
+
* ships unchanged in the first published train that carries `run.events()`,
|
|
864
|
+
* and the earliest train that may remove it is the one after, as announced
|
|
865
|
+
* in that train's release notes. It accepts only a run this client created.
|
|
866
|
+
*/
|
|
583
867
|
events<Outputs extends Record<string, unknown> = Record<string, unknown>>(run: NikaRun<Outputs>, options?: NikaEventsOptions): AsyncIterable<NikaEvent<Outputs>>;
|
|
868
|
+
/**
|
|
869
|
+
* @deprecated Use `run.cancel()`; both return the one memoized request.
|
|
870
|
+
* Kept through the same compatibility window as `events(run)`. It accepts
|
|
871
|
+
* only a run this client created.
|
|
872
|
+
*/
|
|
584
873
|
cancel(run: NikaRun): Promise<NikaCancelResult>;
|
|
585
|
-
/**
|
|
874
|
+
/**
|
|
875
|
+
* Read the current durable status without waiting for terminal settlement.
|
|
876
|
+
*
|
|
877
|
+
* @deprecated Use `run.status()`. Kept through the same compatibility
|
|
878
|
+
* window as `events(run)`. It accepts only a run this client created.
|
|
879
|
+
*/
|
|
586
880
|
status(run: NikaRun): Promise<NikaRunStatus>;
|
|
587
881
|
schedule(workflow: string, options: NikaScheduleOptions): Promise<NikaScheduleApplyResult>;
|
|
588
882
|
scheduleStatus(id: string): Promise<NikaScheduleStatus>;
|
|
589
883
|
traceVerify(receipt: NikaReceipt, options?: NikaTraceVerifyOptions): Promise<NikaTraceVerifyResult>;
|
|
884
|
+
/** One session per admitted run, owned by this client and by no registry. */
|
|
885
|
+
private own;
|
|
590
886
|
private session;
|
|
591
887
|
}
|
|
592
888
|
|
|
593
|
-
export { Nika, type NikaAttachRunOptions, type NikaCancelResult, type NikaCheckOptions, type NikaCheckResult, NikaCompatibilityError, type NikaConfig, NikaConfigurationError, type NikaCostQualifier, NikaEngineUnavailable, NikaError, type NikaEvent, NikaEventBufferOverflowError, type NikaEventsOptions, type NikaExecutionCancelledEvent, type NikaExecutionId, type NikaExecutionInterruptedEvent, type NikaExecutionRefusedEvent, type NikaExecutionSettledEvent, type NikaExecutionStartedEvent, type NikaJobId, type NikaLocalConfig, type NikaMachineError, NikaObservationInterrupted, type NikaOperation, NikaOperationError, type NikaOperationFinding, NikaProtocolError, type NikaReceipt, type NikaRemoteConfig, type NikaRun, type NikaRunCause, type NikaRunId, type NikaRunOptions, NikaRunOwnershipError, type NikaRunResult, type NikaRunSealedEvent, type NikaRunSettledEvent, type NikaRunStatus, type NikaScheduleAfterSkip, type NikaScheduleApplyResult, type NikaScheduleClaim, type NikaScheduleDefinition, type NikaScheduleDue, type NikaScheduleFinding, type NikaScheduleLastDecision, type NikaScheduleMissed, type NikaScheduleOptions, type NikaScheduleOverlap, type NikaSchedulePause, type NikaScheduleSlot, type NikaScheduleStatus, type NikaScheduleWhen, type NikaSettlement, type NikaSpend, type NikaTaskCompletedEvent, type NikaTaskScheduledEvent, type NikaTaskStartedEvent, type NikaTaskTally, type NikaTraceVerifyOptions, type NikaTraceVerifyResult, NikaTransportError, type NikaTransportKind, type NikaUnknownEvent, type NikaWorkflowCompletedEvent, type NikaWorkflowFailedEvent, type NikaWorkflowInterruptedEvent, type NikaWorkflowMetadata, type NikaWorkflowStartedEvent, isNikaRunSealedEvent, isNikaRunSettledEvent, isNikaTerminalEvent };
|
|
889
|
+
export { Nika, type NikaAttachRunOptions, type NikaCancelResult, type NikaCheckFinding, type NikaCheckOptions, type NikaCheckResult, NikaCompatibilityError, type NikaConfig, NikaConfigurationError, type NikaCostQualifier, NikaEngineUnavailable, NikaError, type NikaEvent, NikaEventBufferOverflowError, type NikaEventsOptions, type NikaExecutionCancelledEvent, type NikaExecutionId, type NikaExecutionInterruptedEvent, type NikaExecutionRefusedEvent, type NikaExecutionSettledEvent, type NikaExecutionStartedEvent, type NikaJobId, type NikaJournalEvidence, type NikaLocalConfig, type NikaMachineError, NikaObservationInterrupted, type NikaOperation, NikaOperationError, type NikaOperationFinding, NikaProtocolError, type NikaReceipt, type NikaRemoteConfig, type NikaRun, type NikaRunCause, type NikaRunEvent, type NikaRunEventKind, type NikaRunId, type NikaRunOptions, NikaRunOwnershipError, type NikaRunResult, type NikaRunSealedEvent, type NikaRunSettledEvent, type NikaRunStatus, type NikaScheduleAfterSkip, type NikaScheduleApplyResult, type NikaScheduleClaim, type NikaScheduleDefinition, type NikaScheduleDue, type NikaScheduleFinding, type NikaScheduleLastDecision, type NikaScheduleMissed, type NikaScheduleOptions, type NikaScheduleOverlap, type NikaSchedulePause, type NikaScheduleSlot, type NikaScheduleStatus, type NikaScheduleWhen, type NikaSettlement, type NikaSpend, type NikaTaskCompletedEvent, type NikaTaskScheduledEvent, type NikaTaskStartedEvent, type NikaTaskTally, type NikaTraceVerifyOptions, type NikaTraceVerifyResult, NikaTransportError, type NikaTransportKind, type NikaUnknownEvent, type NikaWorkflowCompletedEvent, type NikaWorkflowFailedEvent, type NikaWorkflowInterruptedEvent, type NikaWorkflowMetadata, type NikaWorkflowStartedEvent, isNikaRunSealedEvent, isNikaRunSettledEvent, isNikaRunSucceeded, isNikaTerminalEvent };
|