@rulvar/core 1.0.0 → 1.2.0
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/dist/index.d.ts +486 -531
- package/dist/index.js +316 -326
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
* L0 JSON value domain.
|
|
4
4
|
*
|
|
5
5
|
* Everything that enters the journal (entry values, error data, artifacts)
|
|
6
|
-
* MUST be JSON-serializable
|
|
7
|
-
* entries, dispatch, and the budget ledger"); `Json` is the type-level face
|
|
8
|
-
* of that rule.
|
|
6
|
+
* MUST be JSON-serializable; `Json` is the type-level face of that rule.
|
|
9
7
|
*/
|
|
10
8
|
type Json = null | boolean | number | string | Json[] | {
|
|
11
9
|
[key: string]: Json;
|
|
@@ -26,16 +24,16 @@ type WireError = {
|
|
|
26
24
|
data?: Json;
|
|
27
25
|
};
|
|
28
26
|
/**
|
|
29
|
-
* The closed error-code registry
|
|
27
|
+
* The closed error-code registry.
|
|
30
28
|
* 'agent' is carried by the AgentError value projection, not by a
|
|
31
29
|
* RulvarError subclass.
|
|
32
30
|
*/
|
|
33
31
|
type ErrorCode = "agent" | "config" | "non_serializable_value" | "script_rejected" | "journal_compat" | "invalid_resolution" | "journal_order_violation" | "plan_invariant" | "replay_plan_hash_mismatch" | "orchestrator_cap_config" | "journal_miss" | "budget_exhausted" | "admission_rejected" | "sandbox_limit" | "lease_held" | "knowledge_cas";
|
|
34
|
-
/**
|
|
32
|
+
/** An alias for the registry type; both names are public. */
|
|
35
33
|
type RulvarErrorCode = ErrorCode;
|
|
36
34
|
/**
|
|
37
35
|
* Base class for all engine-raised errors. "Retryable" means the engine's
|
|
38
|
-
* own retry machinery (RetryPolicy under the journal
|
|
36
|
+
* own retry machinery (RetryPolicy under the journal) MAY retry;
|
|
39
37
|
* it never means a provider SDK autoretry, which is disabled.
|
|
40
38
|
*/
|
|
41
39
|
declare abstract class RulvarError extends Error {
|
|
@@ -84,12 +82,12 @@ declare class ScriptRejected extends RulvarError {
|
|
|
84
82
|
cause?: unknown;
|
|
85
83
|
});
|
|
86
84
|
}
|
|
87
|
-
/** Sub-code detail of JournalCompatibilityError
|
|
85
|
+
/** Sub-code detail of JournalCompatibilityError. */
|
|
88
86
|
type JournalCompatSubCode = "HASH_VERSION_TOO_OLD" | "HASH_VERSION_TOO_NEW";
|
|
89
87
|
/**
|
|
90
88
|
* Refusal to open a journal whose hashVersion falls outside the engine's
|
|
91
|
-
* support window (
|
|
92
|
-
* The registry code is 'journal_compat'; the
|
|
89
|
+
* support window (producers ship in M2).
|
|
90
|
+
* The registry code is 'journal_compat'; the sub-codes live on
|
|
93
91
|
* `subCode` and in `data`.
|
|
94
92
|
*/
|
|
95
93
|
declare class JournalCompatibilityError extends RulvarError {
|
|
@@ -119,8 +117,7 @@ declare class JournalCompatibilityError extends RulvarError {
|
|
|
119
117
|
}
|
|
120
118
|
/**
|
|
121
119
|
* A resolution attempt against an already-closed suspension, rejected under
|
|
122
|
-
* the first-closing-wins fold; appends no entry (
|
|
123
|
-
* "Suspension and resolutions"; producers ship in M2).
|
|
120
|
+
* the first-closing-wins fold; appends no entry (producers ship in M2).
|
|
124
121
|
*/
|
|
125
122
|
declare class InvalidResolutionError extends RulvarError {
|
|
126
123
|
readonly code = "invalid_resolution";
|
|
@@ -131,7 +128,7 @@ declare class InvalidResolutionError extends RulvarError {
|
|
|
131
128
|
}
|
|
132
129
|
/**
|
|
133
130
|
* A breach of the total per-run append order: an unfenced concurrent writer
|
|
134
|
-
* or a store violating contract A2 (docs/
|
|
131
|
+
* or a store violating contract A2 (https://docs.rulvar.com/guide/stores).
|
|
135
132
|
*/
|
|
136
133
|
declare class JournalOrderViolation extends RulvarError {
|
|
137
134
|
readonly code = "journal_order_violation";
|
|
@@ -140,7 +137,7 @@ declare class JournalOrderViolation extends RulvarError {
|
|
|
140
137
|
cause?: unknown;
|
|
141
138
|
});
|
|
142
139
|
}
|
|
143
|
-
/** PlanRunner plan-invariant rejection (
|
|
140
|
+
/** PlanRunner plan-invariant rejection (producers ship in M7). */
|
|
144
141
|
declare class PlanInvariantError extends RulvarError {
|
|
145
142
|
readonly code = "plan_invariant";
|
|
146
143
|
constructor(message: string, opts?: {
|
|
@@ -150,7 +147,7 @@ declare class PlanInvariantError extends RulvarError {
|
|
|
150
147
|
}
|
|
151
148
|
/**
|
|
152
149
|
* Raised at resume when the refolded plan state disagrees with the
|
|
153
|
-
* journaled planHash chain (
|
|
150
|
+
* journaled planHash chain (producers ship in M7).
|
|
154
151
|
*/
|
|
155
152
|
declare class ReplayPlanHashMismatch extends RulvarError {
|
|
156
153
|
readonly code = "replay_plan_hash_mismatch";
|
|
@@ -161,8 +158,7 @@ declare class ReplayPlanHashMismatch extends RulvarError {
|
|
|
161
158
|
}
|
|
162
159
|
/**
|
|
163
160
|
* Invalid orchestrator cap and finalize-reserve configuration, thrown
|
|
164
|
-
* before the first LLM call (
|
|
165
|
-
* producers ship in M6/M7).
|
|
161
|
+
* before the first LLM call (DEF-7; producers ship in M6/M7).
|
|
166
162
|
*/
|
|
167
163
|
declare class OrchestratorCapConfigError extends RulvarError {
|
|
168
164
|
readonly code = "orchestrator_cap_config";
|
|
@@ -185,8 +181,7 @@ declare class JournalMissError extends RulvarError {
|
|
|
185
181
|
/**
|
|
186
182
|
* The run budget ceiling blocked further work. The budget guard denial is
|
|
187
183
|
* a decision entry; ctx primitives throw this as AgentError kind 'budget';
|
|
188
|
-
* the run reports outcome 'exhausted', overriding 'error'
|
|
189
|
-
* "Three-layer budget").
|
|
184
|
+
* the run reports outcome 'exhausted', overriding 'error'.
|
|
190
185
|
*/
|
|
191
186
|
declare class BudgetExhaustedError extends RulvarError {
|
|
192
187
|
readonly code = "budget_exhausted";
|
|
@@ -197,13 +192,12 @@ declare class BudgetExhaustedError extends RulvarError {
|
|
|
197
192
|
}
|
|
198
193
|
/**
|
|
199
194
|
* A structural admission rejection (maxDepth, maxChildrenPerNode,
|
|
200
|
-
* maxTotalSpawns) from the AdmissionController (
|
|
201
|
-
* "AdmissionController"; M6-T06). The rejection verdict is embedded in
|
|
195
|
+
* maxTotalSpawns) from the AdmissionController (M6-T06). The rejection verdict is embedded in
|
|
202
196
|
* the carrying spawn-admission decision entry and replays identically;
|
|
203
197
|
* the error surfaces the embedded AdmitRejectReason in `data` to the
|
|
204
198
|
* caller (a typed tool error for orchestrators) and MUST NOT tear down
|
|
205
199
|
* the run. Budget-code rejections throw BudgetExhaustedError instead,
|
|
206
|
-
* keeping the
|
|
200
|
+
* keeping the budget exhaustion semantics (https://docs.rulvar.com/guide/budgets).
|
|
207
201
|
*/
|
|
208
202
|
declare class AdmissionRejectedError extends RulvarError {
|
|
209
203
|
readonly code = "admission_rejected";
|
|
@@ -213,8 +207,8 @@ declare class AdmissionRejectedError extends RulvarError {
|
|
|
213
207
|
});
|
|
214
208
|
}
|
|
215
209
|
/**
|
|
216
|
-
* A WorkerSandboxRunner resource-limit breach (
|
|
217
|
-
*
|
|
210
|
+
* A WorkerSandboxRunner resource-limit breach (M6-T02): crossing
|
|
211
|
+
* timeoutMs or memoryMb terminates the worker and the
|
|
218
212
|
* run completes with outcome 'error' carrying this error's WireError
|
|
219
213
|
* projection; `data` records { reason: 'timeout' | 'memory', limit }.
|
|
220
214
|
* The class itself is never journaled as an entry of its own.
|
|
@@ -228,8 +222,7 @@ declare class SandboxError extends RulvarError {
|
|
|
228
222
|
}
|
|
229
223
|
/**
|
|
230
224
|
* acquire() on a currently held lease. Retryable by contract: retry after
|
|
231
|
-
* the lease ttl elapses or the holder releases
|
|
232
|
-
* "Storage SPI").
|
|
225
|
+
* the lease ttl elapses or the holder releases.
|
|
233
226
|
*/
|
|
234
227
|
declare class LeaseHeldError extends RulvarError {
|
|
235
228
|
readonly code = "lease_held";
|
|
@@ -241,8 +234,7 @@ declare class LeaseHeldError extends RulvarError {
|
|
|
241
234
|
/**
|
|
242
235
|
* commit() on a ModelKnowledgeStore against a snapshot version that is
|
|
243
236
|
* no longer current. Retryable by contract: re-read current(), rebase
|
|
244
|
-
* the ops, commit again, mirroring the lease fencing discipline
|
|
245
|
-
* (docs/05, section "Commit discipline").
|
|
237
|
+
* the ops, commit again, mirroring the lease fencing discipline.
|
|
246
238
|
*/
|
|
247
239
|
declare class KnowledgeCasError extends RulvarError {
|
|
248
240
|
readonly code = "knowledge_cas";
|
|
@@ -252,8 +244,8 @@ declare class KnowledgeCasError extends RulvarError {
|
|
|
252
244
|
});
|
|
253
245
|
}
|
|
254
246
|
/**
|
|
255
|
-
* The vendored Standard Schema issue shape
|
|
256
|
-
*
|
|
247
|
+
* The vendored Standard Schema issue shape: validation issues carried
|
|
248
|
+
* on AgentError and surfaced to the
|
|
257
249
|
* model during bounded schema re-prompts.
|
|
258
250
|
*/
|
|
259
251
|
type Issue$1 = {
|
|
@@ -264,8 +256,7 @@ type Issue$1 = {
|
|
|
264
256
|
};
|
|
265
257
|
/**
|
|
266
258
|
* The structured error value carried on AgentResult.error and journaled
|
|
267
|
-
* inside the agent terminal entry. Deliberately NOT a RulvarError subclass
|
|
268
|
-
* (docs/02, section "Error taxonomy").
|
|
259
|
+
* inside the agent terminal entry. Deliberately NOT a RulvarError subclass.
|
|
269
260
|
*/
|
|
270
261
|
type AgentError = {
|
|
271
262
|
kind: "transport" | "rate-limit" | "schema-mismatch" | "tool" | "budget" | "terminal";
|
|
@@ -275,8 +266,8 @@ type AgentError = {
|
|
|
275
266
|
};
|
|
276
267
|
/**
|
|
277
268
|
* Projects an AgentError to its WireError form: code 'agent', with kind,
|
|
278
|
-
* retryAfterMs, and issues carried in data
|
|
279
|
-
*
|
|
269
|
+
* retryAfterMs, and issues carried in data. Issue paths are flattened to
|
|
270
|
+
* JSON-safe segments.
|
|
280
271
|
*/
|
|
281
272
|
declare function agentErrorToWire(error: AgentError, message: string): WireError;
|
|
282
273
|
/**
|
|
@@ -290,14 +281,12 @@ type Role = "system" | "user" | "assistant" | "tool";
|
|
|
290
281
|
/**
|
|
291
282
|
* Engine-minted ULID identifying a tool call across providers. The library,
|
|
292
283
|
* not the provider, mints tool-call ids; each adapter keeps a bijective map
|
|
293
|
-
* between canonical ids and wire ids (toolu_* / call_*) in both directions
|
|
294
|
-
* (docs/04, section "Canonical tool-call ids").
|
|
284
|
+
* between canonical ids and wire ids (toolu_* / call_*) in both directions.
|
|
295
285
|
*/
|
|
296
286
|
type CanonicalId = string;
|
|
297
287
|
/**
|
|
298
288
|
* Returns a per-engine minter of CanonicalId values. Monotonic within the
|
|
299
|
-
* factory instance; never a module-level singleton (
|
|
300
|
-
* "Dependency rules": no module state).
|
|
289
|
+
* factory instance; never a module-level singleton (no module state).
|
|
301
290
|
*/
|
|
302
291
|
declare function createCanonicalIdMinter(options?: {
|
|
303
292
|
now?: () => number;
|
|
@@ -312,8 +301,7 @@ interface Msg {
|
|
|
312
301
|
* The canonical part union. provider-raw parts carry opaque provider blocks
|
|
313
302
|
* that must survive round trips (thinking blocks with signatures, reasoning
|
|
314
303
|
* items including encrypted_content). Retention is unconditional; dropping
|
|
315
|
-
* happens only in projection, never in retention
|
|
316
|
-
* "Messages and parts").
|
|
304
|
+
* happens only in projection, never in retention.
|
|
317
305
|
*/
|
|
318
306
|
type Part = {
|
|
319
307
|
type: "text";
|
|
@@ -340,16 +328,14 @@ type Part = {
|
|
|
340
328
|
};
|
|
341
329
|
/**
|
|
342
330
|
* A JSON Schema document (draft 2020-12) as plain JSON data. Canonical
|
|
343
|
-
* serialization and hashing rules live with the KeyDeriver
|
|
344
|
-
* section "schemaHash and toolsetHash derivation").
|
|
331
|
+
* serialization and hashing rules live with the KeyDeriver.
|
|
345
332
|
*/
|
|
346
333
|
type JsonSchema = {
|
|
347
334
|
[key: string]: unknown;
|
|
348
335
|
};
|
|
349
336
|
/**
|
|
350
337
|
* The identity-bearing tool contract: exactly what the model sees and
|
|
351
|
-
* exactly what toolsetHash hashes. Never contains execute or any closure
|
|
352
|
-
* (docs/08, section "Tool definition and toolsetHash").
|
|
338
|
+
* exactly what toolsetHash hashes. Never contains execute or any closure.
|
|
353
339
|
*/
|
|
354
340
|
interface ToolContract {
|
|
355
341
|
name: string;
|
|
@@ -364,7 +350,7 @@ type ToolChoice = "auto" | "none" | "required" | {
|
|
|
364
350
|
};
|
|
365
351
|
/**
|
|
366
352
|
* Canonical effort: exactly five levels, a string-literal union, never a TS
|
|
367
|
-
* enum
|
|
353
|
+
* enum. OpenAI 'none' has no
|
|
368
354
|
* canonical equivalent and is reachable only via providerOptions.
|
|
369
355
|
*/
|
|
370
356
|
type Effort = "low" | "medium" | "high" | "xhigh" | "max";
|
|
@@ -372,7 +358,7 @@ type CacheTtl = "5m" | "1h";
|
|
|
372
358
|
/**
|
|
373
359
|
* Provider-neutral declaration of intended prompt-cache boundaries.
|
|
374
360
|
* Transport-level cost optimization only: MUST NOT enter IdentityInput and
|
|
375
|
-
* MUST NOT change response semantics
|
|
361
|
+
* MUST NOT change response semantics.
|
|
376
362
|
*/
|
|
377
363
|
interface CacheHint {
|
|
378
364
|
/** Desired cache boundaries, ordered from shallowest to deepest prefix. */
|
|
@@ -388,8 +374,7 @@ interface CacheHint {
|
|
|
388
374
|
* top_p, top_k) are deliberately absent from the first-class surface: both
|
|
389
375
|
* first-class providers reject them on current reasoning models; where a
|
|
390
376
|
* target legitimately supports them they travel through the adapter's
|
|
391
|
-
* providerOptions namespace, subject to caps scrubbing
|
|
392
|
-
* "ChatRequest").
|
|
377
|
+
* providerOptions namespace, subject to caps scrubbing.
|
|
393
378
|
*/
|
|
394
379
|
interface ChatRequest {
|
|
395
380
|
/** Wire model id: the segment after 'adapterId:' in ModelRef. */
|
|
@@ -410,8 +395,7 @@ interface ChatRequest {
|
|
|
410
395
|
* adapter MUST read only its own namespace and MUST ignore unknown
|
|
411
396
|
* namespaces without error. Canonical fields always win where both
|
|
412
397
|
* express the same thing; a namespaced option silently contradicting a
|
|
413
|
-
* canonical field is a typed ConfigError
|
|
414
|
-
* "providerOptions and providerMetadata namespacing").
|
|
398
|
+
* canonical field is a typed ConfigError.
|
|
415
399
|
*/
|
|
416
400
|
providerOptions?: Record<string, Record<string, unknown>>;
|
|
417
401
|
}
|
|
@@ -419,7 +403,7 @@ interface ChatRequest {
|
|
|
419
403
|
* Usage under the Usage invariant: inputTokens is the FULL prompt size
|
|
420
404
|
* including cache reads and cache writes. Adapters MUST normalize
|
|
421
405
|
* provider-reported usage to satisfy this invariant, and the core verifies
|
|
422
|
-
* it at the adapter boundary
|
|
406
|
+
* it at the adapter boundary.
|
|
423
407
|
*/
|
|
424
408
|
type Usage = {
|
|
425
409
|
inputTokens: number;
|
|
@@ -441,7 +425,7 @@ interface RefusalInfo {
|
|
|
441
425
|
/**
|
|
442
426
|
* Typed finish outcomes. A refusal MUST surface as a typed finish outcome
|
|
443
427
|
* carrying the provider stop details; it MUST NOT be projected to a null
|
|
444
|
-
* output silently
|
|
428
|
+
* output silently.
|
|
445
429
|
*/
|
|
446
430
|
type FinishInfo = {
|
|
447
431
|
reason: "stop";
|
|
@@ -458,7 +442,7 @@ type FinishInfo = {
|
|
|
458
442
|
/**
|
|
459
443
|
* The single canonical stream-event vocabulary yielded by
|
|
460
444
|
* ProviderAdapter.stream. Adapters MUST emit exactly one terminal event per
|
|
461
|
-
* stream (finish or error)
|
|
445
|
+
* stream (finish or error).
|
|
462
446
|
*/
|
|
463
447
|
type ChatEvent = {
|
|
464
448
|
type: "text-delta";
|
|
@@ -490,13 +474,12 @@ type ChatEvent = {
|
|
|
490
474
|
type: "error";
|
|
491
475
|
error: WireError;
|
|
492
476
|
};
|
|
493
|
-
/** Strictly 'adapterId:model', no query parameters
|
|
477
|
+
/** Strictly 'adapterId:model', no query parameters. */
|
|
494
478
|
type ModelRef = `${string}:${string}`;
|
|
495
479
|
type InvocationRole = "orchestrate" | "plan" | "loop" | "finalize" | "extract" | "summarize";
|
|
496
480
|
/**
|
|
497
481
|
* What authors write wherever a model is configurable: a call override, an
|
|
498
|
-
* agent profile, a workflow default, or an engine default
|
|
499
|
-
* "Router and resolution chain").
|
|
482
|
+
* agent profile, a workflow default, or an engine default.
|
|
500
483
|
*/
|
|
501
484
|
type ModelSpec = ModelRef | ModelChoice | {
|
|
502
485
|
ladder: LadderSpec;
|
|
@@ -505,19 +488,18 @@ interface ModelChoice {
|
|
|
505
488
|
model: ModelRef;
|
|
506
489
|
/** Absent: resolved by the chain, including role effort defaults. */
|
|
507
490
|
effort?: Effort;
|
|
508
|
-
/** Namespaced by adapter id
|
|
491
|
+
/** Namespaced by adapter id. */
|
|
509
492
|
providerOptions?: Record<string, Record<string, unknown>>;
|
|
510
|
-
/** Transport-failure failover list; never enters identity
|
|
493
|
+
/** Transport-failure failover list; never enters identity. */
|
|
511
494
|
fallbacks?: ModelRef[];
|
|
512
495
|
}
|
|
513
496
|
/**
|
|
514
497
|
* Identity-facing canonical form of a RESOLVED model request; the value
|
|
515
|
-
* that enters AgentIdentityInput.modelSpec
|
|
516
|
-
*
|
|
498
|
+
* that enters AgentIdentityInput.modelSpec.
|
|
499
|
+
* providerOptions and fallbacks NEVER enter this form: they are
|
|
517
500
|
* delivery options, excluded from identity exactly like label, phase,
|
|
518
501
|
* onError, retry, and replay. `effort` is absent exactly when no layer of
|
|
519
|
-
* the chain and no role effort default resolves one
|
|
520
|
-
* "Router and resolution chain").
|
|
502
|
+
* the chain and no role effort default resolves one.
|
|
521
503
|
*/
|
|
522
504
|
type CanonicalModelSpec = {
|
|
523
505
|
kind: "model";
|
|
@@ -530,7 +512,7 @@ type CanonicalModelSpec = {
|
|
|
530
512
|
type TriggerClass = "error" | "limit" | "schema-exhausted" | "verify-failed" | "no-progress";
|
|
531
513
|
/**
|
|
532
514
|
* Ladder acceptance gates. Spot-check sibling selection is strictly via
|
|
533
|
-
* ctx.random, never Math.random
|
|
515
|
+
* ctx.random, never Math.random.
|
|
534
516
|
*/
|
|
535
517
|
type Gate = {
|
|
536
518
|
kind: "mechanical";
|
|
@@ -544,7 +526,7 @@ type Gate = {
|
|
|
544
526
|
};
|
|
545
527
|
/**
|
|
546
528
|
* The author-facing ladder declaration. This is the SINGLE declaration of
|
|
547
|
-
* the ladder family:
|
|
529
|
+
* the ladder family: other layers reference it and never redeclare (runtime
|
|
548
530
|
* semantics land in M7).
|
|
549
531
|
*/
|
|
550
532
|
interface LadderSpec {
|
|
@@ -570,7 +552,7 @@ interface CanonicalLadderSpec {
|
|
|
570
552
|
maxCostUsd?: number;
|
|
571
553
|
memoizeOutcome?: boolean;
|
|
572
554
|
}>;
|
|
573
|
-
/** After clamping of any orchestrator model_hint
|
|
555
|
+
/** After clamping of any orchestrator model_hint. */
|
|
574
556
|
startTier: number;
|
|
575
557
|
escalateOn: TriggerClass[];
|
|
576
558
|
acceptance?: Gate[];
|
|
@@ -581,29 +563,27 @@ interface CanonicalLadderSpec {
|
|
|
581
563
|
* Versions the ENTIRE identity and replay pipeline as one unit: canonical
|
|
582
564
|
* JSON algorithm, identity field sets, hash function, schema/toolset hash
|
|
583
565
|
* derivation, scope grammar and ordinal rules, replay predicate, fold
|
|
584
|
-
* defaults, and the kind/status vocabularies
|
|
585
|
-
* "hashVersion").
|
|
566
|
+
* defaults, and the kind/status vocabularies.
|
|
586
567
|
*/
|
|
587
568
|
type HashVersion = number;
|
|
588
569
|
/** 1 = round 1; 2 = current. */
|
|
589
570
|
declare const CURRENT_HASH_VERSION: HashVersion;
|
|
590
571
|
/**
|
|
591
|
-
* The single kinds registry v2
|
|
572
|
+
* The single kinds registry v2.
|
|
592
573
|
* Readers MUST tolerate unknown kinds; stores pass them through
|
|
593
574
|
* byte-for-byte (obligation A4).
|
|
594
575
|
*/
|
|
595
576
|
type EntryKind = "agent" | "step" | "child" | "external" | "approval" | "rand" | "decision" | "plan.revision" | "plan.decision" | "ledger.op" | "resolution" | "abandon" | "node.link" | "termination.init" | "termination.denied";
|
|
596
577
|
/**
|
|
597
578
|
* The stored status vocabulary, exactly. 'skipped' is DELIBERATELY absent:
|
|
598
|
-
* it is a derived fold status, never persisted
|
|
599
|
-
* status vocabulary").
|
|
579
|
+
* it is a derived fold status, never persisted.
|
|
600
580
|
*/
|
|
601
581
|
type EntryStatus = "running" | "ok" | "error" | "limit" | "suspended" | "cancelled" | "escalated";
|
|
602
|
-
/** The canonical EntryRef between entries is seq
|
|
582
|
+
/** The canonical EntryRef between entries is seq. */
|
|
603
583
|
type EntryRef = number;
|
|
604
|
-
/** The journaled by-source of a resolution
|
|
584
|
+
/** The journaled by-source of a resolution. */
|
|
605
585
|
type ResolutionBy = "external" | "timeout" | "class_decision" | "operator" | "quiescence" | "engine_fallback";
|
|
606
|
-
/** Payload of resolution ref-entries (
|
|
586
|
+
/** Payload of resolution ref-entries (DEF-4). */
|
|
607
587
|
type ResolutionPayload = {
|
|
608
588
|
/** Duplicates ref for self-description. */target: number;
|
|
609
589
|
by: ResolutionBy; /** awaitExternal resolution / EscalationDecision / WakeDigest. */
|
|
@@ -612,7 +592,7 @@ type ResolutionPayload = {
|
|
|
612
592
|
logicalTaskId?: string; /** Only on escalation resolutions (DEF-3, M7). */
|
|
613
593
|
countsAgainstLimit?: boolean;
|
|
614
594
|
};
|
|
615
|
-
/** Payload of abandon ref-entries (
|
|
595
|
+
/** Payload of abandon ref-entries (DEF-4/DEF-5). */
|
|
616
596
|
type AbandonPayload = {
|
|
617
597
|
/** Seq of the abandoned branch's spawn entry. */target: number; /** Seq of the plan.revision or decision entry sanctioning it. */
|
|
618
598
|
authorizedBy: number;
|
|
@@ -623,7 +603,7 @@ type AbandonPayload = {
|
|
|
623
603
|
retainWorktree?: boolean;
|
|
624
604
|
};
|
|
625
605
|
/**
|
|
626
|
-
* Final entry form (hashVersion 2
|
|
606
|
+
* Final entry form (hashVersion 2).
|
|
627
607
|
* All journaled values MUST be JSON-serializable; a violation raises a
|
|
628
608
|
* typed NonSerializableValueError at the call site. append is serialized
|
|
629
609
|
* by a per-run queue.
|
|
@@ -652,21 +632,20 @@ type JournalEntry = {
|
|
|
652
632
|
/**
|
|
653
633
|
* Terminal agent entries: the Artifact list (worktree patch refs and
|
|
654
634
|
* inline values); rides the terminal payload so replay reconstructs
|
|
655
|
-
* AgentResult.artifacts without live calls
|
|
635
|
+
* AgentResult.artifacts without live calls.
|
|
656
636
|
*/
|
|
657
637
|
artifacts?: Json;
|
|
658
638
|
/**
|
|
659
639
|
* Terminal escalated entries ONLY: the schema-validated
|
|
660
640
|
* EscalationReport with runtime-filled costToDate and salvage; replay
|
|
661
|
-
* synthesizes the byte-identical report from here (
|
|
662
|
-
* 5.4; DEF-1).
|
|
641
|
+
* synthesizes the byte-identical report from here (DEF-1).
|
|
663
642
|
*/
|
|
664
643
|
escalation?: Json; /** Only when kind === 'resolution'. */
|
|
665
644
|
resolution?: ResolutionPayload; /** Only when kind === 'abandon'. */
|
|
666
645
|
abandon?: AbandonPayload;
|
|
667
646
|
/**
|
|
668
|
-
* Policy field on agent entries, fixed in the payload at dispatch
|
|
669
|
-
*
|
|
647
|
+
* Policy field on agent entries, fixed in the payload at dispatch
|
|
648
|
+
* time: the M2 predicate reads
|
|
670
649
|
* the flag from the ENTRY, never from current code. Excluded from
|
|
671
650
|
* identity like every policy field.
|
|
672
651
|
*/
|
|
@@ -676,7 +655,7 @@ type JournalEntry = {
|
|
|
676
655
|
startedAt: string;
|
|
677
656
|
endedAt?: string;
|
|
678
657
|
};
|
|
679
|
-
/** Rand-entry payload
|
|
658
|
+
/** Rand-entry payload. */
|
|
680
659
|
type RandPayload = {
|
|
681
660
|
subtype: "now";
|
|
682
661
|
value: number;
|
|
@@ -691,8 +670,7 @@ type RandPayload = {
|
|
|
691
670
|
/**
|
|
692
671
|
* Round-1 normalization: hashVersion is taken from `hashVersion`, else
|
|
693
672
|
* from the legacy `v` field, else 1. Stores are never rewritten;
|
|
694
|
-
* normalization happens at read
|
|
695
|
-
* mechanism").
|
|
673
|
+
* normalization happens at read.
|
|
696
674
|
*/
|
|
697
675
|
declare function normalizeEntry(raw: unknown): JournalEntry;
|
|
698
676
|
//#endregion
|
|
@@ -706,8 +684,7 @@ type Lease = {
|
|
|
706
684
|
/**
|
|
707
685
|
* Run-level metadata written by the ENGINE via putMeta as a separate
|
|
708
686
|
* record, so listRuns never parses payloads. The hashVersion range fields
|
|
709
|
-
* are advisory only; the journal is authoritative
|
|
710
|
-
* "RunMeta").
|
|
687
|
+
* are advisory only; the journal is authoritative.
|
|
711
688
|
*/
|
|
712
689
|
type RunMeta = {
|
|
713
690
|
runId: string;
|
|
@@ -736,8 +713,7 @@ interface JournalStore {
|
|
|
736
713
|
/**
|
|
737
714
|
* Lease capability: acquire on a held lease MUST reject with a typed
|
|
738
715
|
* LeaseHeldError; renew MUST run at an interval of at most ttl/3; an
|
|
739
|
-
* append carrying a stale epoch MUST be rejected and never appear in load
|
|
740
|
-
* (docs/03, section "LeasableStore").
|
|
716
|
+
* append carrying a stale epoch MUST be rejected and never appear in load.
|
|
741
717
|
*/
|
|
742
718
|
interface LeasableStore extends JournalStore {
|
|
743
719
|
acquire(runId: string, owner: string): Promise<Lease>;
|
|
@@ -928,13 +904,12 @@ type SchemaPair<T = unknown> = {
|
|
|
928
904
|
/**
|
|
929
905
|
* The L0 schema contract with exactly three accepted forms: a Standard
|
|
930
906
|
* Schema (Zod, ArkType, Valibot, ...), a { jsonSchema, validate } pair, or
|
|
931
|
-
* a bare JSON Schema literal
|
|
907
|
+
* a bare JSON Schema literal.
|
|
932
908
|
*/
|
|
933
909
|
type SchemaSpec<T = unknown> = StandardSchemaV1<unknown, T> | SchemaPair<T> | JsonSchema;
|
|
934
910
|
/**
|
|
935
911
|
* Inferred output type per form: the Standard Schema output type; the
|
|
936
|
-
* type-guard target of validate(); unknown for a bare JSON Schema
|
|
937
|
-
* (docs/08, section "Out<S> inference").
|
|
912
|
+
* type-guard target of validate(); unknown for a bare JSON Schema.
|
|
938
913
|
*/
|
|
939
914
|
type Out<S> = S extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<S> : S extends {
|
|
940
915
|
validate: (value: unknown) => value is infer T;
|
|
@@ -948,8 +923,7 @@ declare function isStandardSchemaSpec(spec: SchemaSpec): spec is StandardSchemaV
|
|
|
948
923
|
/** Form-2 guard: an explicit { jsonSchema, validate } pair. */
|
|
949
924
|
declare function isSchemaPairSpec(spec: SchemaSpec): spec is SchemaPair;
|
|
950
925
|
/**
|
|
951
|
-
* Derives the JSON Schema of a SchemaSpec
|
|
952
|
-
* derivation and acceptance rules"). Form 1 projects via the
|
|
926
|
+
* Derives the JSON Schema of a SchemaSpec. Form 1 projects via the
|
|
953
927
|
* StandardJSONSchemaV1 input() converter, target draft 2020-12 with
|
|
954
928
|
* draft-07 fallback; a library without the projection is a typed
|
|
955
929
|
* ConfigError at definition time, never at first call. Transforming
|
|
@@ -958,8 +932,7 @@ declare function isSchemaPairSpec(spec: SchemaSpec): spec is SchemaPair;
|
|
|
958
932
|
*/
|
|
959
933
|
declare function projectToJsonSchema(spec: SchemaSpec): JsonSchema;
|
|
960
934
|
/**
|
|
961
|
-
* Canonical schema derivation
|
|
962
|
-
* toolsetHash derivation"): local fragment-only $ref inlined (recursion is
|
|
935
|
+
* Canonical schema derivation: local fragment-only $ref inlined (recursion is
|
|
963
936
|
* a ConfigError), remote and dynamic references forbidden, annotation
|
|
964
937
|
* keywords stripped (format retained), reference infrastructure ($defs,
|
|
965
938
|
* definitions, $anchor) removed once inlined. The result feeds JCS
|
|
@@ -968,8 +941,7 @@ declare function projectToJsonSchema(spec: SchemaSpec): JsonSchema;
|
|
|
968
941
|
declare function canonicalizeSchema(schema: JsonSchema): JsonSchema;
|
|
969
942
|
/**
|
|
970
943
|
* The schemaHash used when no structured-output schema is declared: the
|
|
971
|
-
* hash of the canonical `true` schema
|
|
972
|
-
* toolsetHash derivation").
|
|
944
|
+
* hash of the canonical `true` schema.
|
|
973
945
|
*/
|
|
974
946
|
declare const EMPTY_SCHEMA_HASH: string;
|
|
975
947
|
/** The toolsetHash of an empty toolset: the hash of the canonical empty contract array. */
|
|
@@ -986,8 +958,7 @@ declare function schemaHashOfSpec(spec: SchemaSpec | undefined): string;
|
|
|
986
958
|
* contract tuples (name, description, canonical parameters, version)
|
|
987
959
|
* sorted by name. Tool description IS part of the contract; schema
|
|
988
960
|
* annotations inside parameters are not. An absent version participates as
|
|
989
|
-
* absent
|
|
990
|
-
* docs/08, section "toolsetHash contract").
|
|
961
|
+
* absent.
|
|
991
962
|
*/
|
|
992
963
|
declare function toolsetHash(contracts: ToolContract[]): string;
|
|
993
964
|
/** Result of validating a value against a SchemaSpec. */
|
|
@@ -999,7 +970,7 @@ type SchemaValidationResult<T = unknown> = {
|
|
|
999
970
|
issues: Issue$1[];
|
|
1000
971
|
};
|
|
1001
972
|
/**
|
|
1002
|
-
* Runtime validation per form
|
|
973
|
+
* Runtime validation per form:
|
|
1003
974
|
* form 1 via the Standard Schema's own validate, form 2 via the pair's
|
|
1004
975
|
* type guard, form 3 via the vendored draft 2020-12 validator. The same
|
|
1005
976
|
* machinery backs the structured-output tiers of the Agent Runtime.
|
|
@@ -1008,8 +979,8 @@ declare function validateSchemaSpec<S extends SchemaSpec>(spec: S, value: unknow
|
|
|
1008
979
|
//#endregion
|
|
1009
980
|
//#region src/l0/spi/provider.d.ts
|
|
1010
981
|
/**
|
|
1011
|
-
* Per-model pricing in USD per million tokens
|
|
1012
|
-
*
|
|
982
|
+
* Per-model pricing in USD per million tokens. The registry's
|
|
983
|
+
* versioned price table wins over adapter-
|
|
1013
984
|
* reported caps.pricing, which is a fallback only.
|
|
1014
985
|
*/
|
|
1015
986
|
interface Pricing {
|
|
@@ -1035,8 +1006,8 @@ interface ProviderAdapter {
|
|
|
1035
1006
|
/** Stable adapter id; the left segment of ModelRef. */
|
|
1036
1007
|
id: string;
|
|
1037
1008
|
/**
|
|
1038
|
-
* Provider family for provider-raw matching and retention (
|
|
1039
|
-
*
|
|
1009
|
+
* Provider family for provider-raw matching and retention (committed
|
|
1010
|
+
* during M4-T02). Two adapters of the same
|
|
1040
1011
|
* family share retained blocks and projections; default = id.
|
|
1041
1012
|
*/
|
|
1042
1013
|
provider?: string;
|
|
@@ -1050,7 +1021,7 @@ interface ProviderAdapter {
|
|
|
1050
1021
|
//#region src/l0/spi/isolation.d.ts
|
|
1051
1022
|
/**
|
|
1052
1023
|
* The canonical identity encoding of spawn isolation: this exact value
|
|
1053
|
-
* domain enters spawn identity
|
|
1024
|
+
* domain enters spawn identity.
|
|
1054
1025
|
* 'readonly' is a determinism and blast-radius declaration, not
|
|
1055
1026
|
* containment.
|
|
1056
1027
|
*/
|
|
@@ -1076,19 +1047,18 @@ interface IsolationProvider {
|
|
|
1076
1047
|
//#region src/l0/spi/toolsource.d.ts
|
|
1077
1048
|
/**
|
|
1078
1049
|
* Declarative risk metadata on the tool contract. Policy input, not
|
|
1079
|
-
* identity: it does NOT enter toolsetHash
|
|
1080
|
-
* metadata and permission presets").
|
|
1050
|
+
* identity: it does NOT enter toolsetHash.
|
|
1081
1051
|
*/
|
|
1082
1052
|
type ToolRisk = "read" | "write" | "network" | "execute" | "destructive";
|
|
1083
1053
|
/**
|
|
1084
1054
|
* The context handed to execute (and to permission hooks and canUseTool).
|
|
1085
1055
|
* Deliberately exposes NO spawn primitives: tools are leaves of the
|
|
1086
1056
|
* call-and-return tree (invariant I3); all spawning flows through Ctx
|
|
1087
|
-
* primitives
|
|
1057
|
+
* primitives.
|
|
1088
1058
|
*/
|
|
1089
1059
|
interface ToolContext {
|
|
1090
1060
|
runId: string;
|
|
1091
|
-
/** Tool span in the run > phase > agent > tool hierarchy
|
|
1061
|
+
/** Tool span in the run > phase > agent > tool hierarchy. */
|
|
1092
1062
|
spanId: string;
|
|
1093
1063
|
agent: {
|
|
1094
1064
|
agentType: string;
|
|
@@ -1106,23 +1076,21 @@ interface ToolContext {
|
|
|
1106
1076
|
/**
|
|
1107
1077
|
* Where execute runs. A declared capability consumed by dispatch and
|
|
1108
1078
|
* policy; only 'inprocess' is enforced in v1, subprocess/container remain
|
|
1109
|
-
* declared capability
|
|
1110
|
-
* "Executors"; OQ in docs/14).
|
|
1079
|
+
* declared capability while the executor design stays an open question.
|
|
1111
1080
|
*/
|
|
1112
1081
|
type ToolExecutor = "inprocess" | "subprocess" | "container";
|
|
1113
1082
|
/**
|
|
1114
1083
|
* A defined tool. The identity projection is the ToolContract
|
|
1115
1084
|
* { name, description, parameters, version }: exactly what the model sees
|
|
1116
1085
|
* and exactly what toolsetHash hashes; execute and every other
|
|
1117
|
-
* non-contract field are excluded by construction
|
|
1118
|
-
* "tool() definition and ToolDef").
|
|
1086
|
+
* non-contract field are excluded by construction.
|
|
1119
1087
|
*/
|
|
1120
1088
|
interface ToolDef<S extends SchemaSpec = SchemaSpec> {
|
|
1121
1089
|
readonly kind: "tool";
|
|
1122
1090
|
readonly name: string;
|
|
1123
1091
|
readonly description: string;
|
|
1124
1092
|
readonly parameters: S;
|
|
1125
|
-
/** Opaque contract version; part of toolsetHash
|
|
1093
|
+
/** Opaque contract version; part of toolsetHash. */
|
|
1126
1094
|
readonly version?: string;
|
|
1127
1095
|
/** Default 'inprocess'. */
|
|
1128
1096
|
readonly executor: ToolExecutor;
|
|
@@ -1139,7 +1107,7 @@ interface ToolSourceSession {
|
|
|
1139
1107
|
* The ToolSource seam: tools() yields the source's current ToolDefs. The
|
|
1140
1108
|
* toolset snapshot for a given agent spawn is captured at spawn time and
|
|
1141
1109
|
* hashed into the spawn's identity via toolsetHash; a mid-run change MUST
|
|
1142
|
-
* NOT mutate an in-flight agent's toolset
|
|
1110
|
+
* NOT mutate an in-flight agent's toolset.
|
|
1143
1111
|
*/
|
|
1144
1112
|
interface ToolSource {
|
|
1145
1113
|
id: string;
|
|
@@ -1149,7 +1117,7 @@ interface ToolSource {
|
|
|
1149
1117
|
//#region src/l0/spi/knowledge.d.ts
|
|
1150
1118
|
/**
|
|
1151
1119
|
* Task-class vocabulary aligned with the role quality floors vocabulary
|
|
1152
|
-
* (docs/
|
|
1120
|
+
* (https://docs.rulvar.com/guide/model-routing). Scopeless global statements
|
|
1153
1121
|
* are inexpressible: every claim binds a taskClass.
|
|
1154
1122
|
*/
|
|
1155
1123
|
type TaskClass = "code-edit" | "investigation" | "synthesis" | "extraction" | "planning" | "judging" | (string & {});
|
|
@@ -1196,7 +1164,7 @@ interface ModelClaim {
|
|
|
1196
1164
|
confidence: "high" | "medium" | "low";
|
|
1197
1165
|
/** ISO date. */
|
|
1198
1166
|
observedAt: string;
|
|
1199
|
-
/** TTL by class and polarity (
|
|
1167
|
+
/** TTL by class and polarity (the grounding and decay rules). */
|
|
1200
1168
|
expiresAt: string;
|
|
1201
1169
|
/** Honestly best-effort drift signal. */
|
|
1202
1170
|
modelEpoch?: {
|
|
@@ -1269,7 +1237,7 @@ type ClaimOp = {
|
|
|
1269
1237
|
reason: "canary-drift";
|
|
1270
1238
|
};
|
|
1271
1239
|
/**
|
|
1272
|
-
* The SPI seam
|
|
1240
|
+
* The SPI seam. commit performs CAS on
|
|
1273
1241
|
* the monotonic snapshot version, mirroring the fencing-epoch
|
|
1274
1242
|
* discipline of LeasableStore; concurrent maintenance commits serialize
|
|
1275
1243
|
* through CAS rejection and rebase. commit is UNREACHABLE from the
|
|
@@ -1282,13 +1250,13 @@ interface ModelKnowledgeStore {
|
|
|
1282
1250
|
/**
|
|
1283
1251
|
* The runtime handle: with propose() deleted from the design and
|
|
1284
1252
|
* commit absent from this shape, a run has no write path into the
|
|
1285
|
-
* cross-run medium at all
|
|
1253
|
+
* cross-run medium at all.
|
|
1286
1254
|
*/
|
|
1287
1255
|
type ModelKnowledgeHandle = Pick<ModelKnowledgeStore, "current">;
|
|
1288
1256
|
//#endregion
|
|
1289
1257
|
//#region src/knowledge/decay.d.ts
|
|
1290
1258
|
/**
|
|
1291
|
-
* The asymmetric TTL table
|
|
1259
|
+
* The asymmetric TTL table:
|
|
1292
1260
|
* a false negative is costlier through lock-in, so weaknesses expire
|
|
1293
1261
|
* sooner than strengths.
|
|
1294
1262
|
*/
|
|
@@ -1304,37 +1272,37 @@ declare const CLAIM_TTL_DAYS: {
|
|
|
1304
1272
|
};
|
|
1305
1273
|
/** Inbox proposals expire after 14 days (reserved for M12 phase 3). */
|
|
1306
1274
|
declare const INBOX_PROPOSAL_TTL_DAYS = 14;
|
|
1307
|
-
/** The
|
|
1275
|
+
/** The asymmetric TTL applied to an observedAt ISO date. */
|
|
1308
1276
|
declare function claimExpiry(claimClass: ModelClaim["class"], polarity: ModelClaim["polarity"], observedAt: string): string;
|
|
1309
|
-
/** True when the claim steers nothing at `at` (
|
|
1277
|
+
/** True when the claim steers nothing at `at` (the read-path filter). */
|
|
1310
1278
|
declare function claimExpired(claim: Pick<ModelClaim, "expiresAt">, at: string): boolean;
|
|
1311
1279
|
/** The TTL state a maintenance view renders per claim. */
|
|
1312
1280
|
type TtlState = "holds" | "expired";
|
|
1313
1281
|
declare function ttlState(claim: Pick<ModelClaim, "expiresAt">, at: string): TtlState;
|
|
1314
1282
|
/**
|
|
1315
|
-
* The re-measurement queue
|
|
1283
|
+
* The re-measurement queue:
|
|
1316
1284
|
* expired eval-measured claims that are still ACTIVE. Just a status
|
|
1317
1285
|
* filter: the next sweep re-measures these subjects; nothing archives
|
|
1318
1286
|
* them (archiving would empty the queue and hide the decay).
|
|
1319
1287
|
*/
|
|
1320
1288
|
declare function remeasureQueue(claims: readonly ModelClaim[], at: string): ModelClaim[];
|
|
1321
1289
|
/**
|
|
1322
|
-
* Deprecation maintenance (
|
|
1323
|
-
*
|
|
1324
|
-
*
|
|
1290
|
+
* Deprecation maintenance (deprecations archive claims, never delete
|
|
1291
|
+
* them, so historical runs keep their audit trail): archive ops for
|
|
1292
|
+
* every non-terminal claim of the deprecated
|
|
1325
1293
|
* models. The caller commits them under its own gate-free archive ops.
|
|
1326
1294
|
*/
|
|
1327
1295
|
declare function archiveDeprecatedModelOps(claims: readonly ModelClaim[], deprecated: readonly ModelRef[]): ClaimOp[];
|
|
1328
1296
|
//#endregion
|
|
1329
1297
|
//#region src/knowledge/claims.d.ts
|
|
1330
|
-
/**
|
|
1298
|
+
/** Appendix A: KB active-claims cap, default 8 per (model, taskClass). */
|
|
1331
1299
|
declare const KB_ACTIVE_CLAIMS_CAP = 8;
|
|
1332
|
-
/**
|
|
1300
|
+
/** The committed data model bound: statement <= 200 chars. */
|
|
1333
1301
|
declare const CLAIM_STATEMENT_MAX_CHARS = 200;
|
|
1334
1302
|
interface ClaimValidationOptions {
|
|
1335
1303
|
/**
|
|
1336
|
-
* True on the eval-committer path (the eval-committer gate
|
|
1337
|
-
*
|
|
1304
|
+
* True on the eval-committer path (the eval-committer gate).
|
|
1305
|
+
* Editorial validation leaves it false and both eval-measured
|
|
1338
1306
|
* claims and metrics reject. At the op level the GATE decides this
|
|
1339
1307
|
* flag; the option exists for direct claim-level validation.
|
|
1340
1308
|
*/
|
|
@@ -1349,7 +1317,7 @@ declare function claimIssues(claim: ModelClaim, path: string, options?: ClaimVal
|
|
|
1349
1317
|
*/
|
|
1350
1318
|
declare function claimOpIssues(op: ClaimOp, index: number): string[];
|
|
1351
1319
|
/**
|
|
1352
|
-
* The commit-time cap (
|
|
1320
|
+
* The commit-time cap (Appendix A): active claims per
|
|
1353
1321
|
* (model, taskClass) after the batch applies. Supersede chains keep
|
|
1354
1322
|
* only the head active by construction (applyClaimOps flips the prior
|
|
1355
1323
|
* to 'superseded'), so a supersede never grows the count.
|
|
@@ -1393,9 +1361,9 @@ declare function knowledgeHash(claims: readonly ModelClaim[]): string;
|
|
|
1393
1361
|
*/
|
|
1394
1362
|
declare function applyClaimOps(claims: readonly ModelClaim[], ops: readonly ClaimOp[]): ModelClaim[];
|
|
1395
1363
|
interface FileModelKnowledgeStoreOptions {
|
|
1396
|
-
/** Default './rulvar.models.json'
|
|
1364
|
+
/** Default './rulvar.models.json'. */
|
|
1397
1365
|
path?: string;
|
|
1398
|
-
/**
|
|
1366
|
+
/** Active claims per (model, taskClass); default 8. */
|
|
1399
1367
|
activeClaimsCap?: number;
|
|
1400
1368
|
}
|
|
1401
1369
|
declare class FileModelKnowledgeStore implements ModelKnowledgeStore {
|
|
@@ -1414,9 +1382,9 @@ declare class FileModelKnowledgeStore implements ModelKnowledgeStore {
|
|
|
1414
1382
|
type LogicalTaskId = string;
|
|
1415
1383
|
/** The closed relation vocabulary of the minting and inheritance table. */
|
|
1416
1384
|
type LineageRelation = "first" | "respawn" | "rung-retry" | "decompose-child" | "unpark-restart";
|
|
1417
|
-
/** approachSig/approachSigCoarse derivation version
|
|
1385
|
+
/** approachSig/approachSigCoarse derivation version. */
|
|
1418
1386
|
declare const LINEAGE_SIG_VERSION: 1;
|
|
1419
|
-
/** Deterministic LTIDs canonized onto legacy journals
|
|
1387
|
+
/** Deterministic LTIDs canonized onto legacy journals. */
|
|
1420
1388
|
declare const LEGACY_LTID_PREFIX = "legacy:";
|
|
1421
1389
|
/** The computed lineage record of one spawn-authorizing decision entry. */
|
|
1422
1390
|
interface LineageRef {
|
|
@@ -1434,14 +1402,14 @@ interface LineageRef {
|
|
|
1434
1402
|
}
|
|
1435
1403
|
/**
|
|
1436
1404
|
* The value-part lineage block embedded in decision entries: the computed
|
|
1437
|
-
* LineageRef plus the normalized tag (
|
|
1405
|
+
* LineageRef plus the normalized tag (the request part
|
|
1438
1406
|
* holds the RAW proposal; the value part holds what was COMPUTED and is
|
|
1439
1407
|
* reused byte-exact on replay).
|
|
1440
1408
|
*/
|
|
1441
1409
|
interface SpawnLineage extends LineageRef {
|
|
1442
1410
|
approachTag: string;
|
|
1443
1411
|
}
|
|
1444
|
-
/** Attempt outcome classes entering LineageStats
|
|
1412
|
+
/** Attempt outcome classes entering LineageStats. */
|
|
1445
1413
|
type AttemptOutcomeClass = "ok" | "escalated" | "task-error" | "transient-error" | "no-progress" | "verify-failed" | "limit" | "abandoned";
|
|
1446
1414
|
/**
|
|
1447
1415
|
* The pure lineage fold rendered in plan_view and WakeDigest, always
|
|
@@ -1484,13 +1452,13 @@ declare const DEFAULT_ESCALATION_LIMITS: EscalationLimits;
|
|
|
1484
1452
|
*/
|
|
1485
1453
|
declare function validateEscalationLimits(raw?: Partial<EscalationLimits> | Record<string, unknown>): EscalationLimits;
|
|
1486
1454
|
/**
|
|
1487
|
-
* Approach-tag normalization
|
|
1455
|
+
* Approach-tag normalization: NFC, lowercase, runs of
|
|
1488
1456
|
* non-alphanumerics collapse into a hyphen, truncate to 32 characters; an
|
|
1489
1457
|
* empty value canonicalizes to 'default'. Prompt prose never enters any
|
|
1490
1458
|
* signature: rephrasings collide by construction, not by heuristic.
|
|
1491
1459
|
*/
|
|
1492
1460
|
declare function normalizeApproachTag(raw?: string): string;
|
|
1493
|
-
/** The isolation string entering approachSigCoarse
|
|
1461
|
+
/** The isolation string entering approachSigCoarse. */
|
|
1494
1462
|
declare function canonicalIsolationTag(spec: IsolationSpec | undefined): string;
|
|
1495
1463
|
/** The identity inputs of the coarse signature (prompt prose excluded). */
|
|
1496
1464
|
interface ApproachSignatureInputs {
|
|
@@ -1502,7 +1470,7 @@ interface ApproachSignatureInputs {
|
|
|
1502
1470
|
/**
|
|
1503
1471
|
* approachSigCoarse = sha256(JCS({ sigVersion, agentType, toolsetHash,
|
|
1504
1472
|
* schemaHash, isolation })). Feeds the stall detector and the oscillation
|
|
1505
|
-
* guard, which keys ACROSS LTID boundaries
|
|
1473
|
+
* guard, which keys ACROSS LTID boundaries.
|
|
1506
1474
|
*/
|
|
1507
1475
|
declare function approachSigCoarse(inputs: ApproachSignatureInputs): string;
|
|
1508
1476
|
/** approachSig = sha256(JCS({ sigVersion, coarse, approachTag })); keys lessons. */
|
|
@@ -1511,7 +1479,7 @@ declare function approachSigOf(coarse: string, tag?: string): string;
|
|
|
1511
1479
|
* The deterministic signature inputs assigned to legacy spawns (journals
|
|
1512
1480
|
* written before lineage existed) and to attempts whose producers did not
|
|
1513
1481
|
* record signature inputs: stable constants, never wall-clock, so replay
|
|
1514
|
-
* canonizes identically on every engine
|
|
1482
|
+
* canonizes identically on every engine.
|
|
1515
1483
|
*/
|
|
1516
1484
|
declare const LEGACY_SIGNATURE_INPUTS: ApproachSignatureInputs;
|
|
1517
1485
|
/** Classifies one settled root terminal into its attempt outcome class. */
|
|
@@ -1520,8 +1488,7 @@ declare function classifyAttemptOutcome(terminal: JournalEntry): AttemptOutcomeC
|
|
|
1520
1488
|
* The incremental lineage fold: attempts, escalation debits, stall
|
|
1521
1489
|
* streaks, single-live-attempt, and legacy canonization, computed from
|
|
1522
1490
|
* journal entries only. `absorb` is idempotent by seq cursor; every read
|
|
1523
|
-
* accepts an optional `uptoSeq` pin so renders stay snapshot-stable
|
|
1524
|
-
* (docs/03, 10.4; docs/07, 8.3).
|
|
1491
|
+
* accepts an optional `uptoSeq` pin so renders stay snapshot-stable.
|
|
1525
1492
|
*/
|
|
1526
1493
|
declare class LineageIndex {
|
|
1527
1494
|
private readonly attemptsByLtid;
|
|
@@ -1551,7 +1518,7 @@ declare class LineageIndex {
|
|
|
1551
1518
|
* attempt whose bound key matches (an at-least-once redispatch of the
|
|
1552
1519
|
* same slot after cancelled/error/limit); else a legacy attempt is
|
|
1553
1520
|
* canonized with the deterministic 'legacy:' + contentHash LTID
|
|
1554
|
-
* (
|
|
1521
|
+
* (random ULIDs on replay are forbidden).
|
|
1555
1522
|
*/
|
|
1556
1523
|
private bindRoot;
|
|
1557
1524
|
private recordEscalation;
|
|
@@ -1562,12 +1529,12 @@ declare class LineageIndex {
|
|
|
1562
1529
|
* True while the LTID has an unsettled attempt (admitted, dispatched, or
|
|
1563
1530
|
* redispatched without a terminal), including admits whose decision
|
|
1564
1531
|
* entries have not landed yet. Backs the single-live-attempt invariant:
|
|
1565
|
-
* a competing admit gets `lineage_busy
|
|
1532
|
+
* a competing admit gets `lineage_busy`.
|
|
1566
1533
|
*/
|
|
1567
1534
|
hasLiveAttempt(logicalTaskId: LogicalTaskId): boolean;
|
|
1568
|
-
/** The stall streak
|
|
1535
|
+
/** The stall streak (pinnable to a snapshot seq). */
|
|
1569
1536
|
stallStreak(logicalTaskId: LogicalTaskId, uptoSeq?: number): number;
|
|
1570
|
-
/** The pinned LineageStats render
|
|
1537
|
+
/** The pinned LineageStats render. */
|
|
1571
1538
|
statsOf(logicalTaskId: LogicalTaskId, uptoSeq?: number): LineageStats;
|
|
1572
1539
|
/** Every LTID the fold has seen (diagnostics and renders). */
|
|
1573
1540
|
knownLogicalTaskIds(): LogicalTaskId[];
|
|
@@ -1581,14 +1548,14 @@ interface AgentIdentityInput {
|
|
|
1581
1548
|
/**
|
|
1582
1549
|
* The REQUESTED model spec, including canonical effort where resolved;
|
|
1583
1550
|
* for laddered spawns it embeds the declared ladder together with
|
|
1584
|
-
* startTier
|
|
1551
|
+
* startTier.
|
|
1585
1552
|
*/
|
|
1586
1553
|
modelSpec: CanonicalModelSpec;
|
|
1587
1554
|
/** Replaced verbatim by opts.key when opts.key is set. */
|
|
1588
1555
|
prompt: string;
|
|
1589
1556
|
schemaHash: string;
|
|
1590
1557
|
toolsetHash: string;
|
|
1591
|
-
/**
|
|
1558
|
+
/** The canonical IsolationSpec encoding (see https://docs.rulvar.com/guide/tools). */
|
|
1592
1559
|
isolation: IsolationSpec;
|
|
1593
1560
|
}
|
|
1594
1561
|
/** Nested workflow spawns: ctx.workflow (kind 'child'). */
|
|
@@ -1630,8 +1597,8 @@ type IdentityInput = AgentIdentityInput | ChildIdentityInput | StepIdentityInput
|
|
|
1630
1597
|
/**
|
|
1631
1598
|
* The identity projection of a CanonicalModelSpec. For the plain-model
|
|
1632
1599
|
* kind the projection is `{ model, effort? }` WITHOUT the kind
|
|
1633
|
-
* discriminant, exactly as
|
|
1634
|
-
*
|
|
1600
|
+
* discriminant, exactly as frozen by the hashVersion 2 profile;
|
|
1601
|
+
* `effort` is omitted when unresolved. The ladder embedding lands
|
|
1635
1602
|
* with ladder execution (M7).
|
|
1636
1603
|
*/
|
|
1637
1604
|
declare function modelSpecIdentity(spec: CanonicalModelSpec): {
|
|
@@ -1651,7 +1618,7 @@ declare function projectIdentity(input: IdentityInput): Record<string, unknown>;
|
|
|
1651
1618
|
/** The JCS form of an IdentityInput under the hashVersion 2 profile. */
|
|
1652
1619
|
declare function identityJcs(input: IdentityInput): string;
|
|
1653
1620
|
/**
|
|
1654
|
-
* key = sha256(JCS(IdentityInput))
|
|
1621
|
+
* key = sha256(JCS(IdentityInput)).
|
|
1655
1622
|
*/
|
|
1656
1623
|
declare function deriveContentKey(input: IdentityInput): string;
|
|
1657
1624
|
//#endregion
|
|
@@ -1664,8 +1631,8 @@ interface JournalOperation {
|
|
|
1664
1631
|
/**
|
|
1665
1632
|
* Versioned key derivation for matching: the live call is compared
|
|
1666
1633
|
* against every unconsumed entry with the key computed UNDER THAT ENTRY'S
|
|
1667
|
-
* VERSION; 'incomparable' is a guaranteed non-match
|
|
1668
|
-
*
|
|
1634
|
+
* VERSION; 'incomparable' is a guaranteed non-match.
|
|
1635
|
+
* M2-T05 supplies the real registry; the default ring knows only
|
|
1669
1636
|
* the current version.
|
|
1670
1637
|
*/
|
|
1671
1638
|
/** A derived key, or the guaranteed non-match marker. */
|
|
@@ -1717,7 +1684,7 @@ declare class JournalMatcher {
|
|
|
1717
1684
|
private readonly keyRing;
|
|
1718
1685
|
private disposition;
|
|
1719
1686
|
private aliasDisposition?;
|
|
1720
|
-
/** Scope-prefix aliases (DEF-5
|
|
1687
|
+
/** Scope-prefix aliases (DEF-5): donor prefix -> target prefix. */
|
|
1721
1688
|
private readonly aliases;
|
|
1722
1689
|
private readonly keyCache;
|
|
1723
1690
|
private hitsInternal;
|
|
@@ -1731,8 +1698,8 @@ declare class JournalMatcher {
|
|
|
1731
1698
|
/** M2-T06 swaps in the full DEF-1 predicate after folds are built. */
|
|
1732
1699
|
setDisposition(disposition: (op: JournalOperation) => OperationDisposition): void;
|
|
1733
1700
|
/**
|
|
1734
|
-
* The disposition applied to alias-sourced candidates (DEF-5
|
|
1735
|
-
*
|
|
1701
|
+
* The disposition applied to alias-sourced candidates (DEF-5): the
|
|
1702
|
+
* skipped overlay from abandon is bypassed ONLY through the
|
|
1736
1703
|
* alias, so entries regain their pre-abandon terminal status for
|
|
1737
1704
|
* matching in the NEW scope; the standalone old scope stays skipped.
|
|
1738
1705
|
*/
|
|
@@ -1751,7 +1718,7 @@ declare class JournalMatcher {
|
|
|
1751
1718
|
* Forward-matches one live call. A miss does not advance any cursor and
|
|
1752
1719
|
* does not extinguish future hits: the scan always starts at the scope
|
|
1753
1720
|
* head and skips consumed operations, so insertion stability holds by
|
|
1754
|
-
* construction
|
|
1721
|
+
* construction.
|
|
1755
1722
|
*/
|
|
1756
1723
|
match(scope: string, identity: IdentityInput, mode: "scoped" | "cache" | "never"): MatchResult;
|
|
1757
1724
|
/** Marks an operation consumed without matching (fold-driven paths). */
|
|
@@ -1764,8 +1731,8 @@ declare class JournalMatcher {
|
|
|
1764
1731
|
type CanonicalIdentity = Record<string, unknown>;
|
|
1765
1732
|
/**
|
|
1766
1733
|
* Per-effective-status disposition rules; DATA on the profile, consumed
|
|
1767
|
-
* only by the single canonical replayDisposition function (
|
|
1768
|
-
*
|
|
1734
|
+
* only by the single canonical replayDisposition function (there is NO
|
|
1735
|
+
* replayAction method).
|
|
1769
1736
|
*/
|
|
1770
1737
|
type DispositionRule = "replay" | "rerun" | "memoize-limit" | "memoize-task-error";
|
|
1771
1738
|
type DispositionTable = Readonly<Partial<Record<"ok" | "escalated" | "limit" | "error" | "cancelled" | "running", DispositionRule>>>;
|
|
@@ -1794,20 +1761,19 @@ declare const deriverV1: KeyDeriver;
|
|
|
1794
1761
|
type DeriverRegistry = ReadonlyMap<HashVersion, KeyDeriver>;
|
|
1795
1762
|
/**
|
|
1796
1763
|
* Builds the per-engine deriver registry: the shipped v1/v2 profiles plus
|
|
1797
|
-
* EngineOptions.extraDerivers, the ONLY window extender
|
|
1798
|
-
*
|
|
1764
|
+
* EngineOptions.extraDerivers, the ONLY window extender. A malformed
|
|
1765
|
+
* extra deriver is a ConfigError before any run effect.
|
|
1799
1766
|
*/
|
|
1800
1767
|
declare function buildDeriverRegistry(extraDerivers?: readonly unknown[]): DeriverRegistry;
|
|
1801
1768
|
/**
|
|
1802
1769
|
* The one compatibility scan: immediately after load, strictly BEFORE any
|
|
1803
1770
|
* live call, any append, and any admission reserve; repeated at lease
|
|
1804
|
-
* acquire in queue mode
|
|
1771
|
+
* acquire in queue mode. Side-effect free.
|
|
1805
1772
|
*/
|
|
1806
1773
|
declare function scanJournalCompatibility(runId: string, entries: readonly JournalEntry[], registry: DeriverRegistry): void;
|
|
1807
1774
|
/**
|
|
1808
1775
|
* KeyRing over the registry: the live call is projected DOWN into the
|
|
1809
|
-
* profile of the stored entry; there is no upward canonization
|
|
1810
|
-
* section 4.7).
|
|
1776
|
+
* profile of the stored entry; there is no upward canonization.
|
|
1811
1777
|
*/
|
|
1812
1778
|
declare function registryKeyRing(registry: DeriverRegistry): KeyRing;
|
|
1813
1779
|
//#endregion
|
|
@@ -1820,12 +1786,12 @@ interface AbandonFold {
|
|
|
1820
1786
|
type ErrorClass = "transport" | "task";
|
|
1821
1787
|
/**
|
|
1822
1788
|
* task-class: schema-mismatch, terminal, non-retryable tool. transport,
|
|
1823
|
-
* rate-limit, and budget are never memoized
|
|
1789
|
+
* rate-limit, and budget are never memoized.
|
|
1824
1790
|
*/
|
|
1825
1791
|
declare function classifyAgentError(e: AgentError): ErrorClass;
|
|
1826
1792
|
/**
|
|
1827
1793
|
* The child scope-prefix an abandon over `target` covers transitively.
|
|
1828
|
-
* Agent spawns nest under agent:<seq
|
|
1794
|
+
* Agent spawns nest under agent:<seq>; a child
|
|
1829
1795
|
* workflow's subtree runs under the wf:<name>:<ordinal> scope recorded in
|
|
1830
1796
|
* its dispatch payload (M6-T06). A child entry without the payload
|
|
1831
1797
|
* (foreign journals) degrades to the agent:<seq> convention, which covers
|
|
@@ -1836,7 +1802,7 @@ declare function childCoveragePrefix(target: JournalEntry): string;
|
|
|
1836
1802
|
* Builds the AbandonFold in ONE pass at load, in append order, pinned for
|
|
1837
1803
|
* the entire resume (DEF-1 ordering rule 4). Coverage is the target seq
|
|
1838
1804
|
* itself plus, transitively, every entry under the target's child
|
|
1839
|
-
* scope-prefix
|
|
1805
|
+
* scope-prefix. Repeated abandons over an
|
|
1840
1806
|
* already-covered target fold to noop.
|
|
1841
1807
|
*/
|
|
1842
1808
|
declare function buildAbandonFold(entries: readonly JournalEntry[]): AbandonFold;
|
|
@@ -1894,7 +1860,7 @@ type SuspensionState = {
|
|
|
1894
1860
|
state: "abandoned";
|
|
1895
1861
|
by: number;
|
|
1896
1862
|
};
|
|
1897
|
-
/** Fold classification of one ref-entry; NEVER persisted
|
|
1863
|
+
/** Fold classification of one ref-entry; NEVER persisted. */
|
|
1898
1864
|
type RefEntryClassification = {
|
|
1899
1865
|
classification: "applied";
|
|
1900
1866
|
} | {
|
|
@@ -1913,7 +1879,7 @@ type RefEntryClassification = {
|
|
|
1913
1879
|
* schema-invalid offline resolution classifies invalid and does NOT close
|
|
1914
1880
|
* the target. Abandon coverage is the target seq plus the transitive
|
|
1915
1881
|
* child scope-prefix; the AbandonFold consumed by the replay predicate is
|
|
1916
|
-
* a projection of THIS fold (
|
|
1882
|
+
* a projection of THIS fold (not a separate pass).
|
|
1917
1883
|
*/
|
|
1918
1884
|
declare class ResolutionFold {
|
|
1919
1885
|
private readonly targets;
|
|
@@ -1955,8 +1921,8 @@ interface RefEntryAppender {
|
|
|
1955
1921
|
}): Promise<JournalEntry>;
|
|
1956
1922
|
}
|
|
1957
1923
|
/**
|
|
1958
|
-
* Per-run, per-target FIFO serializer of resolution/abandon attempts
|
|
1959
|
-
*
|
|
1924
|
+
* Per-run, per-target FIFO serializer of resolution/abandon attempts:
|
|
1925
|
+
* classification against the in-memory fold ->
|
|
1960
1926
|
* durable append -> settle exactly once; losing attempts are ALSO
|
|
1961
1927
|
* appended and become journaled noops by fold classification. Winner
|
|
1962
1928
|
* effects run strictly after the critical section (the caller's job).
|
|
@@ -1974,7 +1940,7 @@ declare class ResolutionArbiter {
|
|
|
1974
1940
|
//#endregion
|
|
1975
1941
|
//#region src/journal/replayer.d.ts
|
|
1976
1942
|
type ReplayMode = "scoped" | "cache" | "never";
|
|
1977
|
-
/**
|
|
1943
|
+
/** Large-value soft warn threshold (committed for M2). */
|
|
1978
1944
|
declare const LARGE_VALUE_WARN_BYTES = 262144;
|
|
1979
1945
|
interface Ledger {
|
|
1980
1946
|
usage: Usage;
|
|
@@ -2009,7 +1975,7 @@ interface TerminalPatch {
|
|
|
2009
1975
|
servedBy?: ModelRef;
|
|
2010
1976
|
transcriptRef?: string;
|
|
2011
1977
|
checkpointRef?: string;
|
|
2012
|
-
/** Terminal agent entries: Artifact list
|
|
1978
|
+
/** Terminal agent entries: Artifact list. */
|
|
2013
1979
|
artifacts?: unknown;
|
|
2014
1980
|
/** Terminal escalated entries: the validated EscalationReport. */
|
|
2015
1981
|
escalation?: unknown;
|
|
@@ -2017,14 +1983,14 @@ interface TerminalPatch {
|
|
|
2017
1983
|
* Engine-decided terminal abort classes (the no-progress abort) stamp
|
|
2018
1984
|
* memoizeOutcome on the TERMINAL entry so the frozen memoize rules
|
|
2019
1985
|
* replay them on every resume; the running entry keeps the user's
|
|
2020
|
-
* policy verbatim (
|
|
1986
|
+
* policy verbatim (M3 amendment).
|
|
2021
1987
|
*/
|
|
2022
1988
|
memoizeOutcome?: boolean;
|
|
2023
1989
|
site?: string;
|
|
2024
1990
|
}
|
|
2025
1991
|
/**
|
|
2026
1992
|
* Per-run journal kernel front end. Everything is per instance: no module
|
|
2027
|
-
* state anywhere
|
|
1993
|
+
* state anywhere.
|
|
2028
1994
|
*/
|
|
2029
1995
|
declare class Replayer {
|
|
2030
1996
|
private readonly runId;
|
|
@@ -2047,44 +2013,44 @@ declare class Replayer {
|
|
|
2047
2013
|
runId: string;
|
|
2048
2014
|
store: JournalStore;
|
|
2049
2015
|
now?: () => number;
|
|
2050
|
-
priceUsd?: (servedBy: ModelRef | undefined, usage: Usage) => number | undefined; /** Receives large-value soft warnings (
|
|
2016
|
+
priceUsd?: (servedBy: ModelRef | undefined, usage: Usage) => number | undefined; /** Receives large-value soft warnings (never an error). */
|
|
2051
2017
|
onWarn?: (msg: string) => void;
|
|
2052
|
-
largeValueWarnBytes?: number; /** The loaded, normalized prior journal (resume
|
|
2018
|
+
largeValueWarnBytes?: number; /** The loaded, normalized prior journal (resume). */
|
|
2053
2019
|
priorEntries?: readonly JournalEntry[];
|
|
2054
2020
|
keyRing?: KeyRing;
|
|
2055
2021
|
disposition?: (op: JournalOperation) => OperationDisposition; /** Replay-strict: any live-class match throws JournalMissError. */
|
|
2056
2022
|
strict?: boolean;
|
|
2057
2023
|
/**
|
|
2058
2024
|
* Queue mode: every append carries this lease so a stale holder's
|
|
2059
|
-
* writes are rejected by the fencing epoch (
|
|
2060
|
-
*
|
|
2025
|
+
* writes are rejected by the fencing epoch (M8 entry amendment).
|
|
2026
|
+
* Absent means the single-writer precondition
|
|
2061
2027
|
* is asserted instead of fenced (the embedded default).
|
|
2062
2028
|
*/
|
|
2063
2029
|
lease?: Lease;
|
|
2064
2030
|
});
|
|
2065
2031
|
/**
|
|
2066
|
-
* Forward-matches one live call against the prior journal
|
|
2067
|
-
*
|
|
2032
|
+
* Forward-matches one live call against the prior journal. Fresh
|
|
2033
|
+
* runs always miss; the M2-T06 predicate is injected
|
|
2068
2034
|
* through setDisposition once folds are built.
|
|
2069
2035
|
*/
|
|
2070
2036
|
match(scope: string, identity: IdentityInput, mode: ReplayMode): MatchResult;
|
|
2071
2037
|
setDisposition(disposition: (op: JournalOperation) => OperationDisposition): void;
|
|
2072
2038
|
/**
|
|
2073
|
-
* The disposition for alias-sourced candidates (DEF-5
|
|
2039
|
+
* The disposition for alias-sourced candidates (DEF-5):
|
|
2074
2040
|
* bypasses the abandon overlay so donor entries regain their
|
|
2075
2041
|
* pre-abandon terminal status when matched through the alias.
|
|
2076
2042
|
*/
|
|
2077
2043
|
setAliasDisposition(disposition: (op: JournalOperation) => OperationDisposition): void;
|
|
2078
2044
|
/**
|
|
2079
|
-
* Registers a node.link scope-prefix rewrite (DEF-5
|
|
2045
|
+
* Registers a node.link scope-prefix rewrite (DEF-5):
|
|
2080
2046
|
* donorPrefix forward-matches into targetPrefix at every nested level.
|
|
2081
2047
|
* Idempotent; the alias map is rebuilt by fold on resume.
|
|
2082
2048
|
*/
|
|
2083
2049
|
registerAlias(donorPrefix: string, targetPrefix: string): void;
|
|
2084
2050
|
/**
|
|
2085
|
-
* invalidate/retry
|
|
2051
|
+
* invalidate/retry: explicit unpinning of a
|
|
2086
2052
|
* memoized failure; the invalidated entry reruns on this resume. The
|
|
2087
|
-
* safety boundary is an open question
|
|
2053
|
+
* safety boundary is an open question.
|
|
2088
2054
|
*/
|
|
2089
2055
|
invalidate(seq: number): void;
|
|
2090
2056
|
get invalidatedSeqs(): ReadonlySet<number>;
|
|
@@ -2101,15 +2067,15 @@ declare class Replayer {
|
|
|
2101
2067
|
abandon?: AbandonPayload;
|
|
2102
2068
|
}): Promise<JournalEntry>;
|
|
2103
2069
|
/**
|
|
2104
|
-
* Submits a resolution attempt through the per-target FIFO arbiter
|
|
2105
|
-
*
|
|
2070
|
+
* Submits a resolution attempt through the per-target FIFO arbiter.
|
|
2071
|
+
* Losing attempts are journaled noops.
|
|
2106
2072
|
*/
|
|
2107
2073
|
resolveSuspended(target: number, attempt: ResolutionAttempt): Promise<ResolutionOutcome>;
|
|
2108
2074
|
abandonBranch(attempt: AbandonAttempt): Promise<ResolutionOutcome>;
|
|
2109
|
-
/** Pure fold view, snapshot-pinned
|
|
2075
|
+
/** Pure fold view, snapshot-pinned. */
|
|
2110
2076
|
suspensionState(target: number): SuspensionState;
|
|
2111
2077
|
/**
|
|
2112
|
-
* Value size policy
|
|
2078
|
+
* Value size policy:
|
|
2113
2079
|
* there is NO automatic offload in v1; oversized values warn and
|
|
2114
2080
|
* proceed. Large artifacts belong in TranscriptStore by reference.
|
|
2115
2081
|
*/
|
|
@@ -2120,7 +2086,7 @@ declare class Replayer {
|
|
|
2120
2086
|
* Two-phase dispatch: the running entry (kinds agent, step, child).
|
|
2121
2087
|
* `value` is legal on child dispatches only: the child payload
|
|
2122
2088
|
* `{ workflow, childScope }` lets the abandon fold compute the child's
|
|
2123
|
-
* transitive scope coverage (
|
|
2089
|
+
* transitive scope coverage (M6-T06). Values
|
|
2124
2090
|
* never enter identity.
|
|
2125
2091
|
*/
|
|
2126
2092
|
appendRunning(input: BaseAppend & {
|
|
@@ -2137,8 +2103,7 @@ declare class Replayer {
|
|
|
2137
2103
|
/** Suspended kinds (external, approval): appended once, closed by ref-entries (M2). */
|
|
2138
2104
|
appendSuspended(input: SuspendedAppend): Promise<JournalEntry>;
|
|
2139
2105
|
/**
|
|
2140
|
-
* The budget ledger fold
|
|
2141
|
-
* resume"): usage sums over terminal entries exactly once; agentsSpawned
|
|
2106
|
+
* The budget ledger fold: usage sums over terminal entries exactly once; agentsSpawned
|
|
2142
2107
|
* counts agent dispatches.
|
|
2143
2108
|
*/
|
|
2144
2109
|
ledger(): Ledger;
|
|
@@ -2174,9 +2139,8 @@ declare const DEFAULT_RETRY_POLICY: RetryPolicy;
|
|
|
2174
2139
|
/**
|
|
2175
2140
|
* Classifies a WireError for the retry engine. Task-class failures are
|
|
2176
2141
|
* never retryable by construction: adapters mark them retryable: false
|
|
2177
|
-
* and this returns undefined. The kind travels in WireError.data.kind
|
|
2178
|
-
*
|
|
2179
|
-
* transport.
|
|
2142
|
+
* and this returns undefined. The kind travels in WireError.data.kind;
|
|
2143
|
+
* anything retryable without a specific kind is transport.
|
|
2180
2144
|
*/
|
|
2181
2145
|
declare function retryClassOf(error: WireError): RetryClass | undefined;
|
|
2182
2146
|
/**
|
|
@@ -2191,13 +2155,13 @@ declare function retryDelayMs(policy: RetryPolicy, retryIndex: number, retryAfte
|
|
|
2191
2155
|
//#region src/model/failover.d.ts
|
|
2192
2156
|
/** Transport-level failover triggers; budget is explicitly excluded. */
|
|
2193
2157
|
type FailoverTrigger = "transport" | "rate-limit";
|
|
2194
|
-
/** One resolved failover target (
|
|
2158
|
+
/** One resolved failover target (rich form). */
|
|
2195
2159
|
interface FailoverTarget {
|
|
2196
2160
|
model: ModelRef;
|
|
2197
2161
|
/** Triggers this target serves; absent = both. */
|
|
2198
2162
|
on?: FailoverTrigger[];
|
|
2199
2163
|
}
|
|
2200
|
-
/** Normalizes the author-facing ModelChoice.fallbacks list
|
|
2164
|
+
/** Normalizes the author-facing ModelChoice.fallbacks list. */
|
|
2201
2165
|
declare function normalizeFallbacks(refs: ModelRef[] | undefined): FailoverTarget[];
|
|
2202
2166
|
/**
|
|
2203
2167
|
* Maps a retry class to its failover trigger once retries exhaust.
|
|
@@ -2211,7 +2175,7 @@ declare function failoverTriggerOf(retryClass: RetryClass | undefined): Failover
|
|
|
2211
2175
|
* moves backwards (sticky failover).
|
|
2212
2176
|
*/
|
|
2213
2177
|
declare function nextFailover(targets: Array<Pick<FailoverTarget, "on">>, trigger: FailoverTrigger, from: number): number | undefined;
|
|
2214
|
-
/** The degenerate fallback triggers
|
|
2178
|
+
/** The degenerate fallback triggers. */
|
|
2215
2179
|
type FallbackTrigger = "error" | "limit" | "schema-exhausted";
|
|
2216
2180
|
/** The degenerate fallback field: one agent-level second attempt. */
|
|
2217
2181
|
interface FallbackField {
|
|
@@ -2219,8 +2183,8 @@ interface FallbackField {
|
|
|
2219
2183
|
on: FallbackTrigger[];
|
|
2220
2184
|
}
|
|
2221
2185
|
/**
|
|
2222
|
-
* Classifies a terminal agent outcome for the degenerate fallback
|
|
2223
|
-
*
|
|
2186
|
+
* Classifies a terminal agent outcome for the degenerate fallback:
|
|
2187
|
+
* schema-mismatch errors are
|
|
2224
2188
|
* 'schema-exhausted'; any other error is 'error'; limit terminals (the
|
|
2225
2189
|
* no-progress abort included) are 'limit'; cancelled, escalated, and
|
|
2226
2190
|
* skipped never trigger.
|
|
@@ -2325,8 +2289,7 @@ declare function decodeCheckpoint(blob: Uint8Array): CheckpointState | undefined
|
|
|
2325
2289
|
//#region src/model/router.d.ts
|
|
2326
2290
|
/**
|
|
2327
2291
|
* Per-engine adapter registry: strictly per engine, no global mutable
|
|
2328
|
-
* registry exists. A duplicate adapterId is a typed ConfigError
|
|
2329
|
-
* (docs/04, section "Registry and ModelRef").
|
|
2292
|
+
* registry exists. A duplicate adapterId is a typed ConfigError.
|
|
2330
2293
|
*/
|
|
2331
2294
|
declare function buildAdapterRegistry(adapters: ProviderAdapter[]): ReadonlyMap<string, ProviderAdapter>;
|
|
2332
2295
|
/**
|
|
@@ -2339,12 +2302,10 @@ declare function parseModelRef(ref: ModelRef): {
|
|
|
2339
2302
|
model: string;
|
|
2340
2303
|
};
|
|
2341
2304
|
/**
|
|
2342
|
-
* Role effort defaults
|
|
2343
|
-
* protocol"): orchestrate and plan default to high; summarize and extract
|
|
2305
|
+
* Role effort defaults: orchestrate and plan default to high; summarize and extract
|
|
2344
2306
|
* default to low. loop and finalize have NO role default: when the chain
|
|
2345
2307
|
* resolves nothing, the wire omits effort and identity records the spec
|
|
2346
|
-
* with the effort member absent
|
|
2347
|
-
* chain", as amended).
|
|
2308
|
+
* with the effort member absent.
|
|
2348
2309
|
*/
|
|
2349
2310
|
declare const ROLE_EFFORT_DEFAULTS: Partial<Record<InvocationRole, Effort>>;
|
|
2350
2311
|
/** One layer's contribution to the resolution merge. */
|
|
@@ -2374,7 +2335,7 @@ interface ResolvedInvocation {
|
|
|
2374
2335
|
requestedEffort?: Effort;
|
|
2375
2336
|
providerOptions?: Record<string, Record<string, unknown>>;
|
|
2376
2337
|
fallbacks?: ModelRef[];
|
|
2377
|
-
/** Identity-facing canonical form
|
|
2338
|
+
/** Identity-facing canonical form. */
|
|
2378
2339
|
canonical: CanonicalModelSpec;
|
|
2379
2340
|
scrubs: ScrubNote[];
|
|
2380
2341
|
}
|
|
@@ -2382,7 +2343,7 @@ interface ResolvedInvocation {
|
|
|
2382
2343
|
* Resolution runs on every model invocation, not once per agent: a layered
|
|
2383
2344
|
* merge of { model, effort, providerOptions, fallbacks } in the order call
|
|
2384
2345
|
* override > agent profile > workflow defaults > engine defaults, with the
|
|
2385
|
-
* invocation role attached as a tag
|
|
2346
|
+
* invocation role attached as a tag.
|
|
2386
2347
|
* After resolution the router reads ModelCaps and scrubs illegal
|
|
2387
2348
|
* parameters visibly: unsupported effort is removed from the wire but
|
|
2388
2349
|
* kept in identity; sampling params rejected by the model are removed
|
|
@@ -2399,7 +2360,7 @@ declare function resolveModelInvocation(options: {
|
|
|
2399
2360
|
taskClass?: string;
|
|
2400
2361
|
}): ResolvedInvocation;
|
|
2401
2362
|
/**
|
|
2402
|
-
* Canonicalizes a declared LadderSpec
|
|
2363
|
+
* Canonicalizes a declared LadderSpec: validates the
|
|
2403
2364
|
* shape once (FR-119 judge declaration included) and resolves every rung's
|
|
2404
2365
|
* effort to an explicit value. `chainEffort` is the effort the resolution
|
|
2405
2366
|
* chain would contribute at the declaring layer; a rung that resolves no
|
|
@@ -2412,16 +2373,16 @@ declare function canonicalizeLadder(spec: LadderSpec, options?: {
|
|
|
2412
2373
|
/**
|
|
2413
2374
|
* The concrete ModelChoice of one rung attempt: each attempt is an
|
|
2414
2375
|
* ordinary agent scope whose CanonicalModelSpec is that rung's
|
|
2415
|
-
* `{ kind: 'model' }` form
|
|
2376
|
+
* `{ kind: 'model' }` form.
|
|
2416
2377
|
*/
|
|
2417
2378
|
declare function ladderRungChoice(ladder: CanonicalLadderSpec, index: number): ModelChoice;
|
|
2418
2379
|
//#endregion
|
|
2419
2380
|
//#region src/runtime/escalation.d.ts
|
|
2420
|
-
/** Closed in v1
|
|
2381
|
+
/** Closed in v1. */
|
|
2421
2382
|
type EscalationKind = "scope_bigger" | "scope_different" | "blocked_with_evidence";
|
|
2422
2383
|
/**
|
|
2423
2384
|
* Minimal TaskSpec stand-in: the full typed TaskSpec is owned by the
|
|
2424
|
-
* PlanRunner surface
|
|
2385
|
+
* PlanRunner surface and ships with M7; script
|
|
2425
2386
|
* modes carry proposals opaquely until then.
|
|
2426
2387
|
*/
|
|
2427
2388
|
type TaskSpec = Json;
|
|
@@ -2483,15 +2444,15 @@ interface EscalationRequest {
|
|
|
2483
2444
|
}
|
|
2484
2445
|
declare const ESCALATE_TOOL_NAME = "escalate";
|
|
2485
2446
|
/**
|
|
2486
|
-
* The
|
|
2447
|
+
* The escalate tool's exact request schema. costToDate and salvage
|
|
2487
2448
|
* MUST NOT appear here: additionalProperties false rejects model-authored
|
|
2488
2449
|
* values for them at argument validation.
|
|
2489
2450
|
*/
|
|
2490
2451
|
declare const ESCALATION_REQUEST_SCHEMA: JsonSchema;
|
|
2491
|
-
/** The full-report schema applied BEFORE append
|
|
2452
|
+
/** The full-report schema applied BEFORE append. */
|
|
2492
2453
|
declare const ESCALATION_REPORT_SCHEMA: JsonSchema;
|
|
2493
2454
|
/**
|
|
2494
|
-
* The engine opt-in tool
|
|
2455
|
+
* The engine opt-in tool: registered through the
|
|
2495
2456
|
* same path as any tool under escalation opt-in of EITHER flavor (the
|
|
2496
2457
|
* worker's only authoring channel for a report), never available without
|
|
2497
2458
|
* opt-in, and dispatched through the same permission chain. The loop
|
|
@@ -2501,7 +2462,7 @@ declare function escalateTool(): ToolDef;
|
|
|
2501
2462
|
/** Validates the runtime-completed report BEFORE append; returns issues. */
|
|
2502
2463
|
declare function validateEscalationReport(report: EscalationReport): Promise<Issue$1[]>;
|
|
2503
2464
|
/**
|
|
2504
|
-
* countsAgainstLimit derivation (
|
|
2465
|
+
* countsAgainstLimit derivation (XF-06): true iff
|
|
2505
2466
|
* scope_bigger; scope_different and blocked_with_evidence are exempt and
|
|
2506
2467
|
* never debit the escalation counter.
|
|
2507
2468
|
*/
|
|
@@ -2513,11 +2474,11 @@ declare function countsAgainstLimit(kind: EscalationKind): boolean;
|
|
|
2513
2474
|
* journaled as a first-class terminal abort distinct from user
|
|
2514
2475
|
* cancellation (a cancelled entry always reruns; a no-progress abort
|
|
2515
2476
|
* must replay, or every resume would re-pay the stuck turns). The
|
|
2516
|
-
* interim heuristic is committed
|
|
2477
|
+
* interim heuristic is committed: N consecutive
|
|
2517
2478
|
* turns without tool calls or artifact deltas, N = 3; the broader
|
|
2518
|
-
* heuristic stays OQ-15
|
|
2479
|
+
* heuristic stays OQ-15, revisited on dogfood traces.
|
|
2519
2480
|
*
|
|
2520
|
-
* Encoding
|
|
2481
|
+
* Encoding: the abort is the agent's
|
|
2521
2482
|
* terminal entry with status 'limit', an error payload carrying
|
|
2522
2483
|
* abortClass 'no-progress', and memoizeOutcome stamped by the ENGINE on
|
|
2523
2484
|
* the terminal entry, so the frozen memoize-limit rule replays it on
|
|
@@ -2525,7 +2486,7 @@ declare function countsAgainstLimit(kind: EscalationKind): boolean;
|
|
|
2525
2486
|
* per-turn artifact channel, so the tool-call test subsumes artifact
|
|
2526
2487
|
* deltas; per-turn artifact producers arrive with M4 compaction.
|
|
2527
2488
|
*/
|
|
2528
|
-
/**
|
|
2489
|
+
/** The committed no-progress detector N. */
|
|
2529
2490
|
declare const DEFAULT_NO_PROGRESS_TURNS = 3;
|
|
2530
2491
|
/** The consumer-visible dedicated class marker (FR-424). */
|
|
2531
2492
|
type AbortClass = "no-progress";
|
|
@@ -2553,8 +2514,7 @@ declare class NoProgressDetector {
|
|
|
2553
2514
|
/**
|
|
2554
2515
|
* UsageLimits (M1-T06): normative limit vocabulary and the per-spawn merge.
|
|
2555
2516
|
*
|
|
2556
|
-
*
|
|
2557
|
-
* (normative)"; defaults from Appendix A. Expiry of maxTurns, maxToolCalls,
|
|
2517
|
+
* Full contract: https://docs.rulvar.com/guide/agents. Expiry of maxTurns, maxToolCalls,
|
|
2558
2518
|
* or timeoutMs produces the terminal status 'limit' (paid partial work);
|
|
2559
2519
|
* streamIdleTimeoutMs expiry is a retryable transport-class AgentError,
|
|
2560
2520
|
* never 'limit'. The run-level deadline is RunOptions.deadlineAt, not a
|
|
@@ -2572,7 +2532,7 @@ interface UsageLimits {
|
|
|
2572
2532
|
/** Gap between stream events; default 120000. */
|
|
2573
2533
|
streamIdleTimeoutMs?: number;
|
|
2574
2534
|
/**
|
|
2575
|
-
* The no-progress detector N (
|
|
2535
|
+
* The no-progress detector N (committed at 3):
|
|
2576
2536
|
* consecutive turns without tool calls or artifact deltas before the
|
|
2577
2537
|
* engine aborts with the dedicated class (M3-T08).
|
|
2578
2538
|
*/
|
|
@@ -2586,18 +2546,18 @@ interface EffectiveUsageLimits {
|
|
|
2586
2546
|
maxOutputTokensPerTurn?: number;
|
|
2587
2547
|
timeoutMs?: number;
|
|
2588
2548
|
streamIdleTimeoutMs: number;
|
|
2589
|
-
/** Default DEFAULT_NO_PROGRESS_TURNS
|
|
2549
|
+
/** Default DEFAULT_NO_PROGRESS_TURNS. */
|
|
2590
2550
|
noProgressTurns?: number;
|
|
2591
2551
|
}
|
|
2592
2552
|
/**
|
|
2593
2553
|
* Limits merge per spawn: AgentOpts.limits over profile limits over engine
|
|
2594
|
-
* defaults.limits
|
|
2554
|
+
* defaults.limits.
|
|
2595
2555
|
*/
|
|
2596
2556
|
declare function mergeUsageLimits(call?: UsageLimits, profile?: UsageLimits, engine?: UsageLimits): EffectiveUsageLimits;
|
|
2597
2557
|
//#endregion
|
|
2598
2558
|
//#region src/runtime/agent-loop.d.ts
|
|
2599
2559
|
type AgentStatus = "ok" | "error" | "limit" | "cancelled" | "skipped" | "escalated";
|
|
2600
|
-
/** Artifact: the normative shape of AgentResult.artifacts entries
|
|
2560
|
+
/** Artifact: the normative shape of AgentResult.artifacts entries. */
|
|
2601
2561
|
interface Artifact {
|
|
2602
2562
|
/** Stable within the result. */
|
|
2603
2563
|
id: string;
|
|
@@ -2612,15 +2572,15 @@ interface Artifact {
|
|
|
2612
2572
|
/** Inline JSON content for small values. */
|
|
2613
2573
|
data?: Json;
|
|
2614
2574
|
}
|
|
2615
|
-
/** The verdict of one mechanical acceptance gate evaluation
|
|
2575
|
+
/** The verdict of one mechanical acceptance gate evaluation. */
|
|
2616
2576
|
interface MechanicalGateVerdict {
|
|
2617
2577
|
pass: boolean;
|
|
2618
2578
|
detail?: string;
|
|
2619
2579
|
}
|
|
2620
2580
|
/**
|
|
2621
2581
|
* A mechanical acceptance gate: an engine-registered NAMED pure function
|
|
2622
|
-
* over AgentResult.artifacts
|
|
2623
|
-
* The registry is per engine like every other registry
|
|
2582
|
+
* over AgentResult.artifacts.
|
|
2583
|
+
* The registry is per engine like every other registry; the
|
|
2624
2584
|
* ladder driver journals each evaluation as a decision entry, so the
|
|
2625
2585
|
* ladder fold consumes only journaled verdicts, never live re-evaluation.
|
|
2626
2586
|
*/
|
|
@@ -2641,8 +2601,8 @@ interface AgentResult<T> {
|
|
|
2641
2601
|
error?: AgentError;
|
|
2642
2602
|
/**
|
|
2643
2603
|
* Human-readable detail behind `error` (provider message, first schema
|
|
2644
|
-
* issue): feeds the journaled WireError message.
|
|
2645
|
-
*
|
|
2604
|
+
* issue): feeds the journaled WireError message. An additive
|
|
2605
|
+
* field; never part of identity.
|
|
2646
2606
|
*/
|
|
2647
2607
|
errorMessage?: string;
|
|
2648
2608
|
/** Present if and only if status === 'escalated'. */
|
|
@@ -2671,7 +2631,7 @@ interface RuntimeEventSink {
|
|
|
2671
2631
|
type: string;
|
|
2672
2632
|
} & Record<string, unknown>): void;
|
|
2673
2633
|
}
|
|
2674
|
-
/** Budget hooks bound by the three-layer budget
|
|
2634
|
+
/** Budget hooks bound by the three-layer budget. */
|
|
2675
2635
|
interface BudgetHooks {
|
|
2676
2636
|
/** Layer 2: before every turn; throws BudgetExhaustedError to block dispatch. */
|
|
2677
2637
|
beforeTurn(): void;
|
|
@@ -2714,7 +2674,7 @@ type PermissionGate = ({
|
|
|
2714
2674
|
reason?: string;
|
|
2715
2675
|
}>;
|
|
2716
2676
|
}) & {
|
|
2717
|
-
/** Chain audit payload ridden into tool:end telemetry
|
|
2677
|
+
/** Chain audit payload ridden into tool:end telemetry. */audit?: GateAudit;
|
|
2718
2678
|
};
|
|
2719
2679
|
/**
|
|
2720
2680
|
* The spawn's frozen toolset plus the per-call context factory, prepared
|
|
@@ -2743,14 +2703,14 @@ interface RunAgentOptions<S extends SchemaSpec = JsonSchema> {
|
|
|
2743
2703
|
adapter: ProviderAdapter;
|
|
2744
2704
|
resolved: ResolvedInvocation;
|
|
2745
2705
|
/**
|
|
2746
|
-
* Transport failover chain for the loop phase (M4-T04
|
|
2747
|
-
*
|
|
2706
|
+
* Transport failover chain for the loop phase (M4-T04):
|
|
2707
|
+
* resolved fallback targets tried in order on
|
|
2748
2708
|
* transport or rate-limit failures after retries exhaust. Failover is
|
|
2749
2709
|
* sticky and changes only servedBy, never the content key.
|
|
2750
2710
|
*/
|
|
2751
2711
|
fallbacks?: PhaseTarget[];
|
|
2752
2712
|
/**
|
|
2753
|
-
* Transport RetryPolicy (M4-T05
|
|
2713
|
+
* Transport RetryPolicy (M4-T05): lives UNDER
|
|
2754
2714
|
* the journal, wired around every adapter.stream dispatch. sleep and
|
|
2755
2715
|
* random are injectable for tests; the core owns wall-clock.
|
|
2756
2716
|
*/
|
|
@@ -2764,14 +2724,14 @@ interface RunAgentOptions<S extends SchemaSpec = JsonSchema> {
|
|
|
2764
2724
|
* under the serving adapter's key; absent = unlimited (Appendix A).
|
|
2765
2725
|
*/
|
|
2766
2726
|
providerSlot?: <T>(key: string, fn: () => Promise<T>) => Promise<T>;
|
|
2767
|
-
/** The resolved toolset; absent = no tools declared
|
|
2727
|
+
/** The resolved toolset; absent = no tools declared. */
|
|
2768
2728
|
tools?: ToolRuntime;
|
|
2769
2729
|
/**
|
|
2770
2730
|
* Separate final extract invocation, present only when the role trigger
|
|
2771
2731
|
* protocol demands one: schema set AND (routing directs extract to a
|
|
2772
2732
|
* different model OR the loop model's caps cannot serve the required
|
|
2773
2733
|
* tier OR finalize is routed). Otherwise the schema rides the last loop
|
|
2774
|
-
* turn (
|
|
2734
|
+
* turn (the necessity rule is
|
|
2775
2735
|
* decided by the ctx layer via model/roles.ts).
|
|
2776
2736
|
*/
|
|
2777
2737
|
extract?: PhaseTarget & {
|
|
@@ -2792,7 +2752,7 @@ interface RunAgentOptions<S extends SchemaSpec = JsonSchema> {
|
|
|
2792
2752
|
/**
|
|
2793
2753
|
* Summarize invocation target for compaction (M4-T03): resolved
|
|
2794
2754
|
* through the chain with role 'summarize', falling back to the loop
|
|
2795
|
-
* model when routing resolves nothing
|
|
2755
|
+
* model when routing resolves nothing. Compaction
|
|
2796
2756
|
* is ON by default; absence of this option disables it (direct
|
|
2797
2757
|
* runAgent callers).
|
|
2798
2758
|
*/
|
|
@@ -2804,7 +2764,7 @@ interface RunAgentOptions<S extends SchemaSpec = JsonSchema> {
|
|
|
2804
2764
|
threshold?: number;
|
|
2805
2765
|
};
|
|
2806
2766
|
/**
|
|
2807
|
-
* Turn-boundary checkpointing (M3-T02
|
|
2767
|
+
* Turn-boundary checkpointing (M3-T02).
|
|
2808
2768
|
* load() restores the last boundary on a dangling-dispatch resume;
|
|
2809
2769
|
* save() persists each boundary where the loop continues. The separate
|
|
2810
2770
|
* extract invocation is not checkpointed in v1: an extract-phase crash
|
|
@@ -2826,7 +2786,7 @@ interface RunAgentOptions<S extends SchemaSpec = JsonSchema> {
|
|
|
2826
2786
|
put(ref: string, blob: Uint8Array): Promise<void>;
|
|
2827
2787
|
};
|
|
2828
2788
|
priceUsd?: (servedBy: ModelRef, usage: Usage) => number | undefined;
|
|
2829
|
-
/** Bounded schema re-prompt attempts; default 2 (
|
|
2789
|
+
/** Bounded schema re-prompt attempts; default 2 (Appendix A). */
|
|
2830
2790
|
schemaRetryAttempts?: number;
|
|
2831
2791
|
/** Bounded ModelRetry conversions per tool call chain; default 2 (Appendix A). */
|
|
2832
2792
|
modelRetryAttempts?: number;
|
|
@@ -2834,7 +2794,7 @@ interface RunAgentOptions<S extends SchemaSpec = JsonSchema> {
|
|
|
2834
2794
|
* Escalation opt-in (M3-T07): the loop intercepts accepted calls to
|
|
2835
2795
|
* the escalate tool and terminates with status 'escalated'; the
|
|
2836
2796
|
* in-run minSpend gate rejects early scope_bigger escalations with a
|
|
2837
|
-
* "keep working" error tool result (M3-T09
|
|
2797
|
+
* "keep working" error tool result (M3-T09).
|
|
2838
2798
|
*/
|
|
2839
2799
|
escalation?: {
|
|
2840
2800
|
minSpendUsd: number;
|
|
@@ -2842,8 +2802,8 @@ interface RunAgentOptions<S extends SchemaSpec = JsonSchema> {
|
|
|
2842
2802
|
/**
|
|
2843
2803
|
* Terminal-tool interception (M6-T07): an accepted call to the named
|
|
2844
2804
|
* tool ends the loop with status ok; the call's validated `result`
|
|
2845
|
-
* argument becomes the agent output (the orchestrator finish
|
|
2846
|
-
*
|
|
2805
|
+
* argument becomes the agent output (the orchestrator finish
|
|
2806
|
+
* tool). The tool's execute never runs, mirroring escalate.
|
|
2847
2807
|
*/
|
|
2848
2808
|
terminalTool?: {
|
|
2849
2809
|
name: string;
|
|
@@ -2868,9 +2828,9 @@ type PermissionHook = (toolName: string, input: unknown, ctx: ToolContext) => Ho
|
|
|
2868
2828
|
/**
|
|
2869
2829
|
* Declarative rule tables (no closures). `'undeclared'` in risk
|
|
2870
2830
|
* position matches every tool WITHOUT declared risk: presets treat the
|
|
2871
|
-
* undeclared state conservatively
|
|
2872
|
-
* match through the real shell matcher
|
|
2873
|
-
* ADVISORY outside the first-party fetch tool
|
|
2831
|
+
* undeclared state conservatively. Argv rules
|
|
2832
|
+
* match through the real shell matcher; domain rules are
|
|
2833
|
+
* ADVISORY outside the first-party fetch tool: they never
|
|
2874
2834
|
* change a verdict in M5, and matches surface in audit events.
|
|
2875
2835
|
*/
|
|
2876
2836
|
type RiskRuleValue = ToolRisk | "undeclared";
|
|
@@ -2898,7 +2858,7 @@ interface PermissionConfig {
|
|
|
2898
2858
|
canUseTool?: CanUseTool;
|
|
2899
2859
|
}
|
|
2900
2860
|
/**
|
|
2901
|
-
* Profile-level permissions
|
|
2861
|
+
* Profile-level permissions.
|
|
2902
2862
|
* inheritPermissions governs SUBAGENT inheritance (mode c orchestrators,
|
|
2903
2863
|
* M6+): children get their own config only unless explicitly opted in.
|
|
2904
2864
|
* It is carried as data here and consumed by the spawning layers.
|
|
@@ -2931,7 +2891,7 @@ type PermissionVerdict = ({
|
|
|
2931
2891
|
input: unknown;
|
|
2932
2892
|
}) & {
|
|
2933
2893
|
/**
|
|
2934
|
-
* Advisory domain-rule matches
|
|
2894
|
+
* Advisory domain-rule matches: reported in audit
|
|
2935
2895
|
* events, never enforced outside the first-party fetch tool.
|
|
2936
2896
|
*/
|
|
2937
2897
|
advisory?: PermissionRule[];
|
|
@@ -2939,7 +2899,7 @@ type PermissionVerdict = ({
|
|
|
2939
2899
|
/**
|
|
2940
2900
|
* Merges the engine-wide config and the profile config into one chain.
|
|
2941
2901
|
* Layers concatenate engine-first; since rules only deny or ask, ordering
|
|
2942
|
-
* within a layer cannot change the verdict
|
|
2902
|
+
* within a layer cannot change the verdict. The
|
|
2943
2903
|
* profile's canUseTool wins over the engine's (a single slot by
|
|
2944
2904
|
* construction). A declared preset compiles INTO the same layers, after
|
|
2945
2905
|
* the host-authored rules, never as a fifth layer (M5-T05).
|
|
@@ -2947,19 +2907,19 @@ type PermissionVerdict = ({
|
|
|
2947
2907
|
declare function compilePermissionChain(engine?: PermissionConfig, profile?: AgentProfilePermissions): CompiledPermissionChain;
|
|
2948
2908
|
/**
|
|
2949
2909
|
* Evaluates the chain for one dispatch, or OFFLINE against a
|
|
2950
|
-
* hypothetical call by tool name (the dry-run API
|
|
2951
|
-
*
|
|
2910
|
+
* hypothetical call by tool name (the dry-run API: nothing executes;
|
|
2911
|
+
* shells and tests read the verdict, the
|
|
2952
2912
|
* deciding layer, and the matched rule). Hooks run in deterministic
|
|
2953
2913
|
* registration order; { modifiedInput } substitutes the input and
|
|
2954
2914
|
* continues; the first decisive verdict wins. The returned input is what
|
|
2955
|
-
* execute receives and what the approval identity hashes (
|
|
2956
|
-
*
|
|
2957
|
-
* ride every verdict for the audit payload
|
|
2915
|
+
* execute receives and what the approval identity hashes (post hook
|
|
2916
|
+
* modification). Advisory domain-rule matches
|
|
2917
|
+
* ride every verdict for the audit payload.
|
|
2958
2918
|
*/
|
|
2959
2919
|
declare function evaluatePermission(chain: CompiledPermissionChain, tool: string | Pick<ToolDef, "name" | "needsApproval" | "risk">, input: unknown, ctx?: ToolContext): Promise<PermissionVerdict>;
|
|
2960
2920
|
//#endregion
|
|
2961
2921
|
//#region src/tools/toolset-hash.d.ts
|
|
2962
|
-
/** The per-spawn tools option value domain
|
|
2922
|
+
/** The per-spawn tools option value domain. */
|
|
2963
2923
|
type ToolsOption = ReadonlyArray<ToolDef | ToolSource | string>;
|
|
2964
2924
|
/** The spawn's frozen toolset snapshot plus its identity hash. */
|
|
2965
2925
|
interface ResolvedToolset {
|
|
@@ -2971,13 +2931,13 @@ interface ResolvedToolset {
|
|
|
2971
2931
|
declare function emptyToolset(): ResolvedToolset;
|
|
2972
2932
|
/**
|
|
2973
2933
|
* Expands sources, validates every tool name and duplicate names across
|
|
2974
|
-
* the whole toolset (ConfigError at spawn time
|
|
2975
|
-
*
|
|
2934
|
+
* the whole toolset (ConfigError at spawn time), and computes the
|
|
2935
|
+
* toolsetHash over contracts sorted by name.
|
|
2976
2936
|
*/
|
|
2977
2937
|
declare function resolveToolset(specs: ToolsOption | undefined, session: ToolSourceSession): Promise<ResolvedToolset>;
|
|
2978
2938
|
//#endregion
|
|
2979
2939
|
//#region src/journal/termination.d.ts
|
|
2980
|
-
/** The frozen limits vector written into termination.init
|
|
2940
|
+
/** The frozen limits vector written into termination.init. */
|
|
2981
2941
|
interface TerminationLimits {
|
|
2982
2942
|
/** V0, default 32; absolute and non-replenishable. */
|
|
2983
2943
|
maxRevisionsPerRun: number;
|
|
@@ -2999,7 +2959,7 @@ interface TerminationLimits {
|
|
|
2999
2959
|
/** Appendix A committed defaults for the countable resources. */
|
|
3000
2960
|
declare const DEFAULT_MAX_REVISIONS_PER_RUN = 32;
|
|
3001
2961
|
declare const DEFAULT_MAX_TOTAL_SPAWNS = 128;
|
|
3002
|
-
/** The countable resource vocabulary
|
|
2962
|
+
/** The countable resource vocabulary. */
|
|
3003
2963
|
type TerminationResource = "revisionUnits" | "spawnUnits" | "escalationUnits" | "rungs" | "depth";
|
|
3004
2964
|
interface LineageCounters {
|
|
3005
2965
|
escalationUnitsRemaining: number;
|
|
@@ -3009,7 +2969,7 @@ interface TerminationAccountSnapshot {
|
|
|
3009
2969
|
revisionUnitsRemaining: number;
|
|
3010
2970
|
spawnUnitsRemaining: number;
|
|
3011
2971
|
perLineage: Record<LogicalTaskId, LineageCounters>;
|
|
3012
|
-
/** The variant function, a pure fold over the journal
|
|
2972
|
+
/** The variant function, a pure fold over the journal. */
|
|
3013
2973
|
phi: number;
|
|
3014
2974
|
}
|
|
3015
2975
|
type DebitResult = {
|
|
@@ -3020,13 +2980,13 @@ type DebitResult = {
|
|
|
3020
2980
|
deniedEntryRef: EntryRef;
|
|
3021
2981
|
resource: TerminationResource;
|
|
3022
2982
|
};
|
|
3023
|
-
/** The value payload of a termination.init entry
|
|
2983
|
+
/** The value payload of a termination.init entry. */
|
|
3024
2984
|
interface TerminationInitValue {
|
|
3025
2985
|
limits: TerminationLimits;
|
|
3026
2986
|
profileRegistrySnapshotHash: string;
|
|
3027
2987
|
phiInitial: number;
|
|
3028
2988
|
}
|
|
3029
|
-
/** The value payload of a termination.denied entry
|
|
2989
|
+
/** The value payload of a termination.denied entry. */
|
|
3030
2990
|
interface TerminationDeniedValue {
|
|
3031
2991
|
resource: TerminationResource;
|
|
3032
2992
|
logicalTaskId?: LogicalTaskId;
|
|
@@ -3038,7 +2998,7 @@ interface TerminationDeniedValue {
|
|
|
3038
2998
|
/**
|
|
3039
2999
|
* Reads the declared ladder length of one agent profile. Ladders are
|
|
3040
3000
|
* declared through the profile's ModelSpec (`model: { ladder }`, or the
|
|
3041
|
-
* loop-role routing entry
|
|
3001
|
+
* loop-role routing entry). The reader is defensive
|
|
3042
3002
|
* so the snapshot is total over every registry shape (an undeclared
|
|
3043
3003
|
* ladder has length 1: the single implicit rung).
|
|
3044
3004
|
*/
|
|
@@ -3048,7 +3008,7 @@ declare function kMaxOf(profiles: Record<string, unknown> | undefined): number;
|
|
|
3048
3008
|
/**
|
|
3049
3009
|
* The deterministic profile-registry snapshot hash frozen inside
|
|
3050
3010
|
* termination.init: profile names mapped to their declared ladder
|
|
3051
|
-
* lengths, canonical JSON, sha256
|
|
3011
|
+
* lengths, canonical JSON, sha256.
|
|
3052
3012
|
*/
|
|
3053
3013
|
declare function profileRegistrySnapshotHash(profiles: Record<string, unknown> | undefined): string;
|
|
3054
3014
|
/**
|
|
@@ -3059,14 +3019,14 @@ declare function profileRegistrySnapshotHash(profiles: Record<string, unknown> |
|
|
|
3059
3019
|
declare function validateTerminationLimits(raw: Partial<TerminationLimits> | Record<string, unknown>): TerminationLimits;
|
|
3060
3020
|
/** C = E0 + kMax: the per-spawn weight of the variant function. */
|
|
3061
3021
|
declare function lineageWeightOf(limits: TerminationLimits): number;
|
|
3062
|
-
/** Phi0 = V0 + C * S0, finite and fixed in termination.init
|
|
3022
|
+
/** Phi0 = V0 + C * S0, finite and fixed in termination.init. */
|
|
3063
3023
|
declare function phiInitialOf(limits: TerminationLimits): number;
|
|
3064
|
-
/** Builds the termination.init value payload
|
|
3024
|
+
/** Builds the termination.init value payload. */
|
|
3065
3025
|
declare function buildTerminationInitValue(limits: TerminationLimits, registrySnapshotHash: string): TerminationInitValue;
|
|
3066
3026
|
/** Reads a termination.init entry's payload; undefined when malformed. */
|
|
3067
3027
|
declare function readTerminationInit(entry: JournalEntry): TerminationInitValue | undefined;
|
|
3068
3028
|
/**
|
|
3069
|
-
* Config-drift detection at resume
|
|
3029
|
+
* Config-drift detection at resume: the journaled vector
|
|
3070
3030
|
* always wins; every differing field is reported for the
|
|
3071
3031
|
* `termination:config-drift` event. Dynamic budget top-up via restart is
|
|
3072
3032
|
* excluded by construction.
|
|
@@ -3079,9 +3039,9 @@ declare function terminationConfigDrift(frozen: TerminationLimits, live: Partial
|
|
|
3079
3039
|
/** Injected appender for termination.denied entries (engine-owned I/O). */
|
|
3080
3040
|
type TerminationDeniedWriter = (denied: TerminationDeniedValue) => Promise<EntryRef>;
|
|
3081
3041
|
/**
|
|
3082
|
-
* The single per-run TerminationAccount
|
|
3042
|
+
* The single per-run TerminationAccount: debit ONLY. No
|
|
3083
3043
|
* credit operation exists by construction; reclaim never replenishes
|
|
3084
|
-
* anything (DEF-5 interaction
|
|
3044
|
+
* anything (DEF-5 interaction). Live: the engine debits the
|
|
3085
3045
|
* in-memory account, writes the carrying entry with the balance-after,
|
|
3086
3046
|
* then applies effects. Resume state is rebuilt by TerminationFold from
|
|
3087
3047
|
* the journal, never from live config.
|
|
@@ -3103,7 +3063,7 @@ declare class TerminationAccount {
|
|
|
3103
3063
|
*/
|
|
3104
3064
|
bindDeniedWriter(writer: TerminationDeniedWriter): void;
|
|
3105
3065
|
snapshot(): TerminationAccountSnapshot;
|
|
3106
|
-
/** Phi = V + C * S + sum over live lineages (E + R)
|
|
3066
|
+
/** Phi = V + C * S + sum over live lineages (E + R). */
|
|
3107
3067
|
phi(): number;
|
|
3108
3068
|
/** The current rung index of a lineage (0 before any raise). */
|
|
3109
3069
|
rungIndexOf(logicalTaskId: LogicalTaskId): number;
|
|
@@ -3111,7 +3071,7 @@ declare class TerminationAccount {
|
|
|
3111
3071
|
get spawnUnitsExhausted(): boolean;
|
|
3112
3072
|
get revisionUnitsRemaining(): number;
|
|
3113
3073
|
/**
|
|
3114
|
-
* The spawn-admission debit
|
|
3074
|
+
* The spawn-admission debit: minus one spawnUnit for
|
|
3115
3075
|
* an admitted spawn of ANY origin; a NEW lineage receives E0 escalation
|
|
3116
3076
|
* units and (K_l - 1) rung transitions in the same atomic step, so the
|
|
3117
3077
|
* lemma's per-spawn decrease is C - (E0 + K_l - 1) = kMax - K_l + 1,
|
|
@@ -3130,7 +3090,7 @@ declare class TerminationAccount {
|
|
|
3130
3090
|
resource: "spawnUnits";
|
|
3131
3091
|
};
|
|
3132
3092
|
/**
|
|
3133
|
-
* The plan_revise debit
|
|
3093
|
+
* The plan_revise debit: minus one
|
|
3134
3094
|
* revisionUnit on EVERY journaled plan.revision, regardless of the op
|
|
3135
3095
|
* count, guard verdicts, or the auto-rebase outcome; conflict spam is
|
|
3136
3096
|
* never a free retry.
|
|
@@ -3143,7 +3103,7 @@ declare class TerminationAccount {
|
|
|
3143
3103
|
resource: "revisionUnits";
|
|
3144
3104
|
};
|
|
3145
3105
|
/**
|
|
3146
|
-
* The escalation debit
|
|
3106
|
+
* The escalation debit: minus one escalationUnit of
|
|
3147
3107
|
* the affected lineage, including EACH lineage of a class-level
|
|
3148
3108
|
* decision and timeout defaultDecisions. Conditioned on the
|
|
3149
3109
|
* countsAgainstLimit flag embedded in the decision entry by the caller.
|
|
@@ -3156,7 +3116,7 @@ declare class TerminationAccount {
|
|
|
3156
3116
|
resource: "escalationUnits";
|
|
3157
3117
|
};
|
|
3158
3118
|
/**
|
|
3159
|
-
* The ladder-raise debit
|
|
3119
|
+
* The ladder-raise debit: minus one rung of the
|
|
3160
3120
|
* lineage; rungIndex is strictly monotone, there are no demotions and
|
|
3161
3121
|
* no runtime startTier promotion in v1.
|
|
3162
3122
|
*/
|
|
@@ -3169,7 +3129,7 @@ declare class TerminationAccount {
|
|
|
3169
3129
|
resource: "rungs";
|
|
3170
3130
|
};
|
|
3171
3131
|
/**
|
|
3172
|
-
* The
|
|
3132
|
+
* The unified debit surface: attempts the named resource and, on
|
|
3173
3133
|
* underflow, writes `termination.denied` strictly BEFORE resolving with
|
|
3174
3134
|
* the typed failure (the caller surfaces the error only after this
|
|
3175
3135
|
* settles). Requires a deniedWriter; pure-fold contexts use the
|
|
@@ -3195,10 +3155,10 @@ declare class TerminationAccount {
|
|
|
3195
3155
|
private requireLineage;
|
|
3196
3156
|
private requireLineageId;
|
|
3197
3157
|
}
|
|
3198
|
-
/** The typed error code surfaced after a denied debit
|
|
3158
|
+
/** The typed error code surfaced after a denied debit. */
|
|
3199
3159
|
declare function exhaustionCodeOf(resource: TerminationResource): string;
|
|
3200
3160
|
/**
|
|
3201
|
-
* The replay fold
|
|
3161
|
+
* The replay fold: rebuilds the account from
|
|
3202
3162
|
* termination.init and the debiting decision entries, asserting every
|
|
3203
3163
|
* embedded balance-after against the recomputation. A divergence raises
|
|
3204
3164
|
* the typed journal-integrity error at exactly the diverging entry;
|
|
@@ -3220,13 +3180,12 @@ type Spend = {
|
|
|
3220
3180
|
usage: Usage;
|
|
3221
3181
|
agentsSpawned: number;
|
|
3222
3182
|
};
|
|
3223
|
-
/** Last resort of the admission reserve formula
|
|
3183
|
+
/** Last resort of the admission reserve formula. */
|
|
3224
3184
|
declare const DEFAULT_FLAT_RESERVE_USD = .5;
|
|
3225
|
-
/** The run-root account scope
|
|
3185
|
+
/** The run-root account scope. */
|
|
3226
3186
|
declare const ROOT_ACCOUNT = "run";
|
|
3227
3187
|
/**
|
|
3228
|
-
* The admission reserve for a spawn
|
|
3229
|
-
* before spawn"): opts.estCost, else profile.estCost, else
|
|
3188
|
+
* The admission reserve for a spawn: opts.estCost, else profile.estCost, else
|
|
3230
3189
|
* price(countTokens(input) + caps.maxOutputTokens), else the engine flat
|
|
3231
3190
|
* default.
|
|
3232
3191
|
*/
|
|
@@ -3237,7 +3196,7 @@ declare function admissionReserveUsd(options: {
|
|
|
3237
3196
|
caps?: ModelCaps;
|
|
3238
3197
|
flatReserveUsd?: number;
|
|
3239
3198
|
}): number;
|
|
3240
|
-
/** Read-only projection of one account
|
|
3199
|
+
/** Read-only projection of one account. */
|
|
3241
3200
|
interface BudgetAccountView {
|
|
3242
3201
|
scope: string;
|
|
3243
3202
|
ceilingUsd?: number;
|
|
@@ -3268,7 +3227,7 @@ declare class RunBudget {
|
|
|
3268
3227
|
events?: RuntimeEventSink;
|
|
3269
3228
|
priceUsd?: (servedBy: ModelRef, usage: Usage) => number | undefined;
|
|
3270
3229
|
/**
|
|
3271
|
-
* The resume ledger fold
|
|
3230
|
+
* The resume ledger fold: spend is never
|
|
3272
3231
|
* reset and never double-counted; replayed entries are already inside
|
|
3273
3232
|
* this seed and add no increments.
|
|
3274
3233
|
*/
|
|
@@ -3282,7 +3241,7 @@ declare class RunBudget {
|
|
|
3282
3241
|
/** The account chain from `scope` up to and including the root. */
|
|
3283
3242
|
private chainOf;
|
|
3284
3243
|
/**
|
|
3285
|
-
* Opens a child sub-account under `parentScope
|
|
3244
|
+
* Opens a child sub-account under `parentScope`.
|
|
3286
3245
|
* Re-opening an existing scope is the resume roll-forward path: the
|
|
3287
3246
|
* recorded ceiling wins once and the accumulated state is kept.
|
|
3288
3247
|
*/
|
|
@@ -3306,7 +3265,7 @@ declare class RunBudget {
|
|
|
3306
3265
|
/**
|
|
3307
3266
|
* Marks the run exhausted without a ceiling event: the orchestrator
|
|
3308
3267
|
* finalize fallback maps to outcome 'exhausted' with the synthesized
|
|
3309
|
-
* partial value (DEF-7
|
|
3268
|
+
* partial value (DEF-7; exhaustion is never null).
|
|
3310
3269
|
*/
|
|
3311
3270
|
markExhausted(): void;
|
|
3312
3271
|
get committedReserveUsd(): number;
|
|
@@ -3316,17 +3275,17 @@ declare class RunBudget {
|
|
|
3316
3275
|
* Layer 1: admission before spawn. Blocks when spent + committedReserve
|
|
3317
3276
|
* has reached the ceiling on ANY account in the ancestor chain of
|
|
3318
3277
|
* `accountScope`, otherwise commits the reserve along the whole chain.
|
|
3319
|
-
* Also enforces the engine lifetime spawn cap
|
|
3278
|
+
* Also enforces the engine lifetime spawn cap.
|
|
3320
3279
|
*/
|
|
3321
3280
|
admitSpawn(reserveUsd: number, accountScope?: string): void;
|
|
3322
3281
|
/**
|
|
3323
3282
|
* Resume roll-forward: commits a reserve recovered from a journaled
|
|
3324
3283
|
* spawn-admission decision entry without re-evaluating admission
|
|
3325
|
-
* (
|
|
3284
|
+
* (reserves are recovered, never re-estimated).
|
|
3326
3285
|
*/
|
|
3327
3286
|
admitRecovered(reserveUsd: number, accountScope?: string): void;
|
|
3328
3287
|
/**
|
|
3329
|
-
* Registers the orchestrator finalize reserve (DEF-7
|
|
3288
|
+
* Registers the orchestrator finalize reserve (DEF-7):
|
|
3330
3289
|
* absolute dollars set on the named account AND the run root, so
|
|
3331
3290
|
* admission never lets any spawn eat the finalization money even
|
|
3332
3291
|
* against whole-run exhaustion. Kept SEPARATE from committedReserveUsd
|
|
@@ -3355,17 +3314,17 @@ declare class RunBudget {
|
|
|
3355
3314
|
*/
|
|
3356
3315
|
onUsage(usage: Usage, servedBy: ModelRef, accountScope?: string): void;
|
|
3357
3316
|
spent(): Spend;
|
|
3358
|
-
/** Null when the run has no USD ceiling
|
|
3317
|
+
/** Null when the run has no USD ceiling. */
|
|
3359
3318
|
remaining(): Spend | null;
|
|
3360
3319
|
private emitUpdate;
|
|
3361
3320
|
}
|
|
3362
3321
|
//#endregion
|
|
3363
3322
|
//#region src/journal/reuse.d.ts
|
|
3364
|
-
/** Kernel contentHash of a spawn root entry
|
|
3323
|
+
/** Kernel contentHash of a spawn root entry. */
|
|
3365
3324
|
type SpawnKey = string;
|
|
3366
|
-
/** Plan-node identity
|
|
3325
|
+
/** Plan-node identity. */
|
|
3367
3326
|
type NodeId$1 = string;
|
|
3368
|
-
/** The rich donor descriptor embedded in reuse verdicts
|
|
3327
|
+
/** The rich donor descriptor embedded in reuse verdicts. */
|
|
3369
3328
|
interface DonorRef {
|
|
3370
3329
|
/** Head of the link chain. */
|
|
3371
3330
|
nodeId: NodeId$1;
|
|
@@ -3374,12 +3333,12 @@ interface DonorRef {
|
|
|
3374
3333
|
/** Transitive chain, oldest first. */
|
|
3375
3334
|
chain: NodeId$1[];
|
|
3376
3335
|
spawnKey: SpawnKey;
|
|
3377
|
-
/** Lineage continues through the link (
|
|
3336
|
+
/** Lineage continues through the link (DEF-3). */
|
|
3378
3337
|
logicalTaskId: LogicalTaskId;
|
|
3379
3338
|
/** Paid under the chain at the verdict snapshot. */
|
|
3380
3339
|
paidUsd: number;
|
|
3381
3340
|
}
|
|
3382
|
-
/** Graft bootstrap payload
|
|
3341
|
+
/** Graft bootstrap payload. */
|
|
3383
3342
|
interface GraftBoot {
|
|
3384
3343
|
/** Retained by the abandon entry, when it was. */
|
|
3385
3344
|
checkpointRef?: string;
|
|
@@ -3387,13 +3346,13 @@ interface GraftBoot {
|
|
|
3387
3346
|
eligiblePaidUsd: number;
|
|
3388
3347
|
worktreePinned: boolean;
|
|
3389
3348
|
}
|
|
3390
|
-
/** Telemetry for a SpawnKey match admitted fresh
|
|
3349
|
+
/** Telemetry for a SpawnKey match admitted fresh. */
|
|
3391
3350
|
interface DedupNote {
|
|
3392
3351
|
spawnKey: SpawnKey;
|
|
3393
3352
|
donorNodeId: NodeId$1;
|
|
3394
3353
|
reason: "donor_failed" | "no_paid_entries" | "graft_unsafe" | "donor_active";
|
|
3395
3354
|
}
|
|
3396
|
-
/** The reuse block of AdmissionConfig
|
|
3355
|
+
/** The reuse block of AdmissionConfig. */
|
|
3397
3356
|
interface ReuseConfig {
|
|
3398
3357
|
/** Default true. */
|
|
3399
3358
|
enabled?: boolean;
|
|
@@ -3401,11 +3360,11 @@ interface ReuseConfig {
|
|
|
3401
3360
|
allowGraft?: boolean;
|
|
3402
3361
|
/** Default 2 (Appendix A). */
|
|
3403
3362
|
maxOscillationsPerKey?: number;
|
|
3404
|
-
/** Optional RevisionGuards trigger on netLostUsd
|
|
3363
|
+
/** Optional RevisionGuards trigger on netLostUsd. */
|
|
3405
3364
|
maxAbandonedNetUsdFraction?: number;
|
|
3406
3365
|
}
|
|
3407
3366
|
declare const DEFAULT_MAX_OSCILLATIONS_PER_KEY = 2;
|
|
3408
|
-
/** The consumer-facing reuse mark on results
|
|
3367
|
+
/** The consumer-facing reuse mark on results. */
|
|
3409
3368
|
interface AgentResultMeta {
|
|
3410
3369
|
reusedFrom?: {
|
|
3411
3370
|
nodeId: NodeId$1;
|
|
@@ -3414,7 +3373,7 @@ interface AgentResultMeta {
|
|
|
3414
3373
|
reclaimedUsd: number;
|
|
3415
3374
|
};
|
|
3416
3375
|
}
|
|
3417
|
-
/** The node.link entry value
|
|
3376
|
+
/** The node.link entry value: an ordinary content-keyed effect entry. */
|
|
3418
3377
|
interface NodeLinkValue {
|
|
3419
3378
|
targetNodeId: NodeId$1;
|
|
3420
3379
|
/** plan/NewNodeId. */
|
|
@@ -3426,19 +3385,19 @@ interface NodeLinkValue {
|
|
|
3426
3385
|
spawnKey: SpawnKey;
|
|
3427
3386
|
logicalTaskId: LogicalTaskId;
|
|
3428
3387
|
mode: "full" | "graft";
|
|
3429
|
-
/** full is shareable, graft is exclusive
|
|
3388
|
+
/** full is shareable, graft is exclusive. */
|
|
3430
3389
|
claim: "shared" | "exclusive";
|
|
3431
3390
|
checkpointRef?: string;
|
|
3432
3391
|
reclaimedUsdAtLink: number;
|
|
3433
3392
|
donorRootRef: EntryRef;
|
|
3434
3393
|
}
|
|
3435
3394
|
/**
|
|
3436
|
-
* node.link identity
|
|
3395
|
+
* node.link identity: sha256 of {kind, spawnKey,
|
|
3437
3396
|
* donorScope, targetNodeId}; targetNodeId is deterministic on replay
|
|
3438
3397
|
* because NodeIds are assigned inside plan.revision.
|
|
3439
3398
|
*/
|
|
3440
3399
|
declare function nodeLinkKey(spawnKey: SpawnKey, donorScope: string, targetNodeId: NodeId$1): string;
|
|
3441
|
-
/** The abandoned-spend ledger fold
|
|
3400
|
+
/** The abandoned-spend ledger fold. */
|
|
3442
3401
|
interface AbandonedSpendView {
|
|
3443
3402
|
abandonedUsd: number;
|
|
3444
3403
|
reclaimedUsd: number;
|
|
@@ -3449,7 +3408,7 @@ interface AbandonedSpendView {
|
|
|
3449
3408
|
reclaimedUsd: number;
|
|
3450
3409
|
}>;
|
|
3451
3410
|
}
|
|
3452
|
-
/** One donor candidate surfaced by the DedupIndex fold
|
|
3411
|
+
/** One donor candidate surfaced by the DedupIndex fold. */
|
|
3453
3412
|
interface DonorCandidate {
|
|
3454
3413
|
rootEntryRef: EntryRef;
|
|
3455
3414
|
rootScope: string;
|
|
@@ -3471,7 +3430,7 @@ interface DonorCandidate {
|
|
|
3471
3430
|
retainedCheckpoint: boolean;
|
|
3472
3431
|
/** Seq of the exclusive node.link that captured this donor, if any. */
|
|
3473
3432
|
claimedBy?: EntryRef;
|
|
3474
|
-
/** Scope chain for transitive drainage, oldest first
|
|
3433
|
+
/** Scope chain for transitive drainage, oldest first. */
|
|
3475
3434
|
chain: string[];
|
|
3476
3435
|
}
|
|
3477
3436
|
/**
|
|
@@ -3493,13 +3452,13 @@ declare class DedupIndex {
|
|
|
3493
3452
|
donorsOf(spawnKey: SpawnKey): DonorCandidate[];
|
|
3494
3453
|
/** Every donor for a key including claimed ones (diagnostics). */
|
|
3495
3454
|
allDonorsOf(spawnKey: SpawnKey): DonorCandidate[];
|
|
3496
|
-
/** Link count per key: the oscillation counter
|
|
3455
|
+
/** Link count per key: the oscillation counter. */
|
|
3497
3456
|
oscillationCountOf(spawnKey: SpawnKey): number;
|
|
3498
3457
|
abandonedSpend(): AbandonedSpendView;
|
|
3499
3458
|
}
|
|
3500
3459
|
/**
|
|
3501
|
-
* The four-outcome verdict evaluation on a SpawnKey match
|
|
3502
|
-
*
|
|
3460
|
+
* The four-outcome verdict evaluation on a SpawnKey match, computed
|
|
3461
|
+
* once live at the fold head and embedded into the
|
|
3503
3462
|
* deciding entry; replay never re-evaluates.
|
|
3504
3463
|
*/
|
|
3505
3464
|
declare function evaluateReuse(index: DedupIndex, spawnKey: SpawnKey, config?: ReuseConfig): {
|
|
@@ -3519,7 +3478,7 @@ declare function evaluateReuse(index: DedupIndex, spawnKey: SpawnKey, config?: R
|
|
|
3519
3478
|
};
|
|
3520
3479
|
//#endregion
|
|
3521
3480
|
//#region src/orchestrator/admission.d.ts
|
|
3522
|
-
/** Plan-node identity; engine-minted ULID
|
|
3481
|
+
/** Plan-node identity; engine-minted ULID. */
|
|
3523
3482
|
type NodeId = string;
|
|
3524
3483
|
/** Layer-1 reservation embedded in the carrying decision entry. */
|
|
3525
3484
|
interface BudgetReserve {
|
|
@@ -3534,7 +3493,7 @@ interface AdmitLineage {
|
|
|
3534
3493
|
depth: number;
|
|
3535
3494
|
}
|
|
3536
3495
|
/**
|
|
3537
|
-
* The unified admission verdict (
|
|
3496
|
+
* The unified admission verdict (XF-11). One union,
|
|
3538
3497
|
* closed now; every debit is atomic with its carrying decision entry and
|
|
3539
3498
|
* embeds the balance-after (DEF-2).
|
|
3540
3499
|
*/
|
|
@@ -3562,7 +3521,7 @@ type AdmitVerdict = {
|
|
|
3562
3521
|
kind: "reject";
|
|
3563
3522
|
reason: AdmitRejectReason;
|
|
3564
3523
|
};
|
|
3565
|
-
/** The merged reject-code set
|
|
3524
|
+
/** The merged reject-code set. */
|
|
3566
3525
|
type AdmitRejectReason = {
|
|
3567
3526
|
code: "depth" | "quota" | "budget" | "lifetime" | "termination_exhausted" | "ladder_exceeds_frozen" | "lineage_exhausted" | "lineage_busy";
|
|
3568
3527
|
} | {
|
|
@@ -3570,7 +3529,7 @@ type AdmitRejectReason = {
|
|
|
3570
3529
|
spawnKey: SpawnKey;
|
|
3571
3530
|
oscillationCount: number;
|
|
3572
3531
|
};
|
|
3573
|
-
/** Every spawn origin routed through the single admission point
|
|
3532
|
+
/** Every spawn origin routed through the single admission point. */
|
|
3574
3533
|
type SpawnOrigin = "ctx.workflow" | "ctx.orchestrate" | "spawn_agent" | "parallel_agents" | "escalation-decomposition" | "rung-respawn" | "reuse-link";
|
|
3575
3534
|
/** What the admission point needs to know about one spawn. */
|
|
3576
3535
|
interface AdmitSpec {
|
|
@@ -3581,24 +3540,24 @@ interface AdmitSpec {
|
|
|
3581
3540
|
childScope: string;
|
|
3582
3541
|
/** The nearest enclosing budget account of the spawner. */
|
|
3583
3542
|
parentAccountScope: string;
|
|
3584
|
-
/** Explicit child budget; clamped by childBudgetFraction
|
|
3543
|
+
/** Explicit child budget; clamped by childBudgetFraction. */
|
|
3585
3544
|
budgetUsd?: number;
|
|
3586
|
-
/** Reserve hint; falls back to the flat engine default
|
|
3545
|
+
/** Reserve hint; falls back to the flat engine default. */
|
|
3587
3546
|
estCostUsd?: number;
|
|
3588
3547
|
/**
|
|
3589
3548
|
* Lineage continuation (DEF-3); absence mints a fresh lineage root. A
|
|
3590
3549
|
* continuation demands a causeRef: the seq of the entry that caused the
|
|
3591
|
-
* rebirth
|
|
3550
|
+
* rebirth.
|
|
3592
3551
|
*/
|
|
3593
3552
|
lineage?: SpawnLineageOpt;
|
|
3594
|
-
/** Raw approach tag; normalized by the engine
|
|
3553
|
+
/** Raw approach tag; normalized by the engine. */
|
|
3595
3554
|
approach?: string;
|
|
3596
3555
|
/** Decomposition parent-LTID chain (relation 'decompose-child' only). */
|
|
3597
3556
|
ancestry?: LogicalTaskId[];
|
|
3598
3557
|
/**
|
|
3599
3558
|
* Coarse-signature identity inputs; unspecified fields canonize onto
|
|
3600
3559
|
* the deterministic legacy constants so signatures stay byte-stable
|
|
3601
|
-
* (
|
|
3560
|
+
* (the toolset/schema registries land in M7-T05).
|
|
3602
3561
|
*/
|
|
3603
3562
|
signature?: Partial<ApproachSignatureInputs>;
|
|
3604
3563
|
/**
|
|
@@ -3611,7 +3570,7 @@ interface AdmitSpec {
|
|
|
3611
3570
|
/**
|
|
3612
3571
|
* The children-quota key (maxChildrenPerNode); defaults to
|
|
3613
3572
|
* parentAccountScope. Orchestrators pass their own scope so each node
|
|
3614
|
-
* counts its own children
|
|
3573
|
+
* counts its own children.
|
|
3615
3574
|
*/
|
|
3616
3575
|
nodeKey?: string;
|
|
3617
3576
|
}
|
|
@@ -3627,11 +3586,11 @@ interface AdmissionStatsBefore {
|
|
|
3627
3586
|
interface AdmissionDecision {
|
|
3628
3587
|
verdict: AdmitVerdict;
|
|
3629
3588
|
statsBefore: AdmissionStatsBefore;
|
|
3630
|
-
/** Node identity minted inside the decision
|
|
3589
|
+
/** Node identity minted inside the decision; absent on reject. */
|
|
3631
3590
|
nodeId?: NodeId;
|
|
3632
3591
|
/**
|
|
3633
3592
|
* The computed value-part lineage block (DEF-3): reused byte-exact on
|
|
3634
|
-
* replay, never recomputed
|
|
3593
|
+
* replay, never recomputed. Absent on reject.
|
|
3635
3594
|
*/
|
|
3636
3595
|
lineage?: SpawnLineage;
|
|
3637
3596
|
/**
|
|
@@ -3667,7 +3626,7 @@ declare class AdmissionController {
|
|
|
3667
3626
|
maxDepth?: number;
|
|
3668
3627
|
maxChildrenPerNode?: number;
|
|
3669
3628
|
childBudgetFraction?: number;
|
|
3670
|
-
flatReserveUsd?: number; /** Per-orchestrate spawn cap (
|
|
3629
|
+
flatReserveUsd?: number; /** Per-orchestrate spawn cap (maxSpawns); engine lifetime cap applies regardless. */
|
|
3671
3630
|
maxTotalSpawns?: number;
|
|
3672
3631
|
mintId?: () => string;
|
|
3673
3632
|
/**
|
|
@@ -3685,8 +3644,8 @@ declare class AdmissionController {
|
|
|
3685
3644
|
/** The validated lineage limits this controller enforces (DEF-3). */
|
|
3686
3645
|
get escalationLimits(): EscalationLimits;
|
|
3687
3646
|
/**
|
|
3688
|
-
* Binds the run's TerminationAccount (DEF-2; PlanRunner runs only
|
|
3689
|
-
*
|
|
3647
|
+
* Binds the run's TerminationAccount (DEF-2; PlanRunner runs only):
|
|
3648
|
+
* from bind time on, every admitted spawn of any
|
|
3690
3649
|
* origin debits one spawnUnit atomically with its decision entry, and
|
|
3691
3650
|
* a declared ladder longer than the frozen kMax rejects with
|
|
3692
3651
|
* ladder_exceeds_frozen. Non-PlanRunner runs never bind an account and
|
|
@@ -3696,7 +3655,7 @@ declare class AdmissionController {
|
|
|
3696
3655
|
/** The bound account, when this is a PlanRunner run (DEF-2). */
|
|
3697
3656
|
get termination(): TerminationAccount | undefined;
|
|
3698
3657
|
/**
|
|
3699
|
-
* The lineage half of admission (DEF-3
|
|
3658
|
+
* The lineage half of admission (DEF-3): folds are
|
|
3700
3659
|
* computed live STRICTLY BEFORE the carrying decision entry is appended;
|
|
3701
3660
|
* the caller embeds the returned block in the entry and replay reads it
|
|
3702
3661
|
* back byte-exact. Enforces the single-live-attempt invariant
|
|
@@ -3750,21 +3709,21 @@ declare class AdmissionController {
|
|
|
3750
3709
|
* Resume roll-forward for a child that already SETTLED before the
|
|
3751
3710
|
* resume: re-registers the counters (maxChildrenPerNode, the lifetime
|
|
3752
3711
|
* cap, statsBefore fidelity) without committing any reserve; the spend
|
|
3753
|
-
* itself sits in the root ledger seed
|
|
3712
|
+
* itself sits in the root ledger seed.
|
|
3754
3713
|
*/
|
|
3755
3714
|
recoverSettled(parentAccountScope: string): void;
|
|
3756
3715
|
/**
|
|
3757
3716
|
* Resume roll-forward for an admission whose decision entry exists but
|
|
3758
3717
|
* whose child has NOT settled: re-applies the recorded reserve and
|
|
3759
|
-
* counters without re-evaluating any limit (
|
|
3760
|
-
* re-evaluates admission;
|
|
3718
|
+
* counters without re-evaluating any limit (replay never
|
|
3719
|
+
* re-evaluates admission; reserves are recovered, never
|
|
3761
3720
|
* re-estimated).
|
|
3762
3721
|
*/
|
|
3763
3722
|
recoverInFlight(parentAccountScope: string, verdict: AdmitVerdict): void;
|
|
3764
3723
|
}
|
|
3765
3724
|
//#endregion
|
|
3766
3725
|
//#region src/l0/events.d.ts
|
|
3767
|
-
/**
|
|
3726
|
+
/** Run lifecycle and core telemetry (M1 subset). */
|
|
3768
3727
|
type CoreEvents = {
|
|
3769
3728
|
type: "run:start";
|
|
3770
3729
|
workflow: string;
|
|
@@ -3807,7 +3766,7 @@ type CoreEvents = {
|
|
|
3807
3766
|
scope: string;
|
|
3808
3767
|
status: string;
|
|
3809
3768
|
};
|
|
3810
|
-
/**
|
|
3769
|
+
/** Agent lifecycle. */
|
|
3811
3770
|
type AgentEvents = {
|
|
3812
3771
|
type: "agent:queued";
|
|
3813
3772
|
agentType: string;
|
|
@@ -3841,7 +3800,7 @@ type AgentEvents = {
|
|
|
3841
3800
|
type: "agent:stream";
|
|
3842
3801
|
delta: string;
|
|
3843
3802
|
};
|
|
3844
|
-
/**
|
|
3803
|
+
/** Tool lifecycle (emitters arrive with the tool system, M3). */
|
|
3845
3804
|
type ToolEvents = {
|
|
3846
3805
|
type: "tool:start";
|
|
3847
3806
|
toolName: string;
|
|
@@ -3852,7 +3811,7 @@ type ToolEvents = {
|
|
|
3852
3811
|
outcome: "ok" | "error" | "denied";
|
|
3853
3812
|
durationMs: number;
|
|
3854
3813
|
/**
|
|
3855
|
-
* Audit fields (
|
|
3814
|
+
* Audit fields (M5-T05): the chain verdict,
|
|
3856
3815
|
* the deciding layer, the matched rule, and advisory domain-rule
|
|
3857
3816
|
* matches. Telemetry, never identity; ask verdicts additionally
|
|
3858
3817
|
* journal as suspended approvals.
|
|
@@ -3863,9 +3822,10 @@ type ToolEvents = {
|
|
|
3863
3822
|
advisory?: Json;
|
|
3864
3823
|
};
|
|
3865
3824
|
/**
|
|
3866
|
-
*
|
|
3825
|
+
* Adaptive orchestration, resolutions, and
|
|
3867
3826
|
* accounting: emitted only by runs where the corresponding machinery is
|
|
3868
|
-
* active (applicability per mode:
|
|
3827
|
+
* active (applicability per mode:
|
|
3828
|
+
* https://docs.rulvar.com/guide/adaptive-orchestration). The types land as
|
|
3869
3829
|
* one closed catalog with M7-T03; emitters arrive with their tasks.
|
|
3870
3830
|
*/
|
|
3871
3831
|
type AdaptiveEvents = {
|
|
@@ -3916,7 +3876,7 @@ type AdaptiveEvents = {
|
|
|
3916
3876
|
countsAgainstLimit: boolean;
|
|
3917
3877
|
} | {
|
|
3918
3878
|
type: "spawn:admitted";
|
|
3919
|
-
entryRef: number; /** The admitting arms of the unified AdmitVerdict union
|
|
3879
|
+
entryRef: number; /** The admitting arms of the unified AdmitVerdict union. */
|
|
3920
3880
|
verdict: "admit" | "reuse_full" | "admit_graft";
|
|
3921
3881
|
agentType: string;
|
|
3922
3882
|
logicalTaskId: string;
|
|
@@ -3981,12 +3941,12 @@ type AdaptiveEvents = {
|
|
|
3981
3941
|
};
|
|
3982
3942
|
type WorkflowEventBody = CoreEvents | AgentEvents | ToolEvents | AdaptiveEvents;
|
|
3983
3943
|
/**
|
|
3984
|
-
* The envelope
|
|
3944
|
+
* The envelope: seq is an independent per-run
|
|
3985
3945
|
* telemetry counter, strictly increasing in emission order and DISTINCT
|
|
3986
3946
|
* from JournalEntry.seq (never compare or join the two; entryRef fields
|
|
3987
3947
|
* carry journal seqs explicitly). ts is wall clock, telemetry only.
|
|
3988
|
-
* replayed is true only on re-emitted journal-backed lifecycle events
|
|
3989
|
-
*
|
|
3948
|
+
* replayed is true only on re-emitted journal-backed lifecycle events;
|
|
3949
|
+
* stream deltas are never re-emitted.
|
|
3990
3950
|
*/
|
|
3991
3951
|
type WorkflowEvent = {
|
|
3992
3952
|
runId: string;
|
|
@@ -4017,7 +3977,7 @@ interface PendingExternal {
|
|
|
4017
3977
|
/** Approvals and Flavor B escalations only. */
|
|
4018
3978
|
deadlineAt?: string;
|
|
4019
3979
|
}
|
|
4020
|
-
/**
|
|
3980
|
+
/** Full contract: https://docs.rulvar.com/guide/observability. */
|
|
4021
3981
|
interface CostReport {
|
|
4022
3982
|
totalUsd: number;
|
|
4023
3983
|
/** Keyed by canonical ModelRef 'adapterId:model'. */
|
|
@@ -4049,7 +4009,7 @@ type RunOutcome<R> = {
|
|
|
4049
4009
|
usage: Usage;
|
|
4050
4010
|
cost: CostReport;
|
|
4051
4011
|
};
|
|
4052
|
-
/** Adds 'running' for in-flight inspection
|
|
4012
|
+
/** Adds 'running' for in-flight inspection. */
|
|
4053
4013
|
type RunStatus = RunOutcome<unknown>["status"] | "running";
|
|
4054
4014
|
interface RunHandle<R> {
|
|
4055
4015
|
runId: string;
|
|
@@ -4084,7 +4044,7 @@ interface CompiledWorkflow {
|
|
|
4084
4044
|
interface ScriptRunner {
|
|
4085
4045
|
execute<A, R>(wf: Workflow<A, R> | CompiledWorkflow, ctx: Ctx<never>, args: A): Promise<R>;
|
|
4086
4046
|
}
|
|
4087
|
-
/** Escalation hook
|
|
4047
|
+
/** Escalation hook: decides for value-form calls. */
|
|
4088
4048
|
type OnEscalation = (result: EscalatedResult<unknown>) => EscalationDecision | Promise<EscalationDecision>;
|
|
4089
4049
|
/**
|
|
4090
4050
|
* The mode (a) runner for human-authored closures. Determinism is enforced
|
|
@@ -4118,17 +4078,17 @@ interface PriceTable {
|
|
|
4118
4078
|
*/
|
|
4119
4079
|
declare function resolvePricing(ref: ModelRef, table: PriceTable | undefined, capsPricing: Pricing | undefined): Pricing | undefined;
|
|
4120
4080
|
/**
|
|
4121
|
-
* Dollars from normalized usage against one pricing row (
|
|
4122
|
-
*
|
|
4081
|
+
* Dollars from normalized usage against one pricing row (the adapter
|
|
4082
|
+
* normalized the usage; inputTokens is the
|
|
4123
4083
|
* full prompt). Cache writes price at the 5m premium rate; the 1h rate
|
|
4124
4084
|
* applies where a provider distinguishes it in usage, which the
|
|
4125
|
-
* canonical Usage does not yet carry
|
|
4085
|
+
* canonical Usage does not yet carry.
|
|
4126
4086
|
*/
|
|
4127
4087
|
declare function priceUsdOf(pricing: Pricing, usage: Usage): number;
|
|
4128
4088
|
//#endregion
|
|
4129
4089
|
//#region src/engine/engine.d.ts
|
|
4130
4090
|
/**
|
|
4131
|
-
* The per-engine workflow registry (
|
|
4091
|
+
* The per-engine workflow registry (M5-T01): an
|
|
4132
4092
|
* explicit, first-class value; no module-level registry exists. Shells
|
|
4133
4093
|
* resolve by-name runs against it; ctx.workflow's string form (M6) and
|
|
4134
4094
|
* the queue worker (M8) resolve against it too. CompiledWorkflow values
|
|
@@ -4140,24 +4100,23 @@ interface EngineDefaults {
|
|
|
4140
4100
|
profiles?: Record<string, AgentProfile>;
|
|
4141
4101
|
/** The workflow registry for shells and by-name resolution (10.4). */
|
|
4142
4102
|
workflows?: WorkflowRegistry;
|
|
4143
|
-
/** Registered SchemaSpec names for outputSchemaRef (
|
|
4103
|
+
/** Registered SchemaSpec names for outputSchemaRef (M7-T05). */
|
|
4144
4104
|
schemas?: Record<string, SchemaSpec>;
|
|
4145
|
-
/** Registered tool profile names for toolsetRef (
|
|
4105
|
+
/** Registered tool profile names for toolsetRef (M7-T05). */
|
|
4146
4106
|
toolsets?: Record<string, ToolsOption>;
|
|
4147
4107
|
/**
|
|
4148
4108
|
* Registered mechanical gate profiles: named pure functions over
|
|
4149
|
-
* AgentResult.artifacts for ladder acceptance gates (
|
|
4150
|
-
* "Registries"; docs/07, section 10; M7-T10).
|
|
4109
|
+
* AgentResult.artifacts for ladder acceptance gates (M7-T10).
|
|
4151
4110
|
*/
|
|
4152
4111
|
gates?: Record<string, MechanicalGateProfile>;
|
|
4153
4112
|
limits?: UsageLimits;
|
|
4154
|
-
/** Engine-wide permission chain layers
|
|
4113
|
+
/** Engine-wide permission chain layers. */
|
|
4155
4114
|
permissions?: PermissionConfig;
|
|
4156
|
-
/** The worktree lifecycle provider
|
|
4115
|
+
/** The worktree lifecycle provider. */
|
|
4157
4116
|
isolation?: IsolationProvider;
|
|
4158
|
-
/** Engine-wide transport RetryPolicy (
|
|
4117
|
+
/** Engine-wide transport RetryPolicy (M4-T05). */
|
|
4159
4118
|
retry?: RetryPolicy;
|
|
4160
|
-
/** Hard per-role model constraints (
|
|
4119
|
+
/** Hard per-role model constraints (M4-T09). */
|
|
4161
4120
|
roleFloors?: QualityFloors;
|
|
4162
4121
|
}
|
|
4163
4122
|
interface BudgetDefaults {
|
|
@@ -4167,13 +4126,13 @@ interface BudgetDefaults {
|
|
|
4167
4126
|
lifetimeSpawnCap?: number;
|
|
4168
4127
|
/**
|
|
4169
4128
|
* Fraction of the parent remainder (minus the parent finalize reserve)
|
|
4170
|
-
* a child sub-account may take; default 0.3 (
|
|
4129
|
+
* a child sub-account may take; default 0.3 (M6-T06).
|
|
4171
4130
|
*/
|
|
4172
4131
|
childBudgetFraction?: number;
|
|
4173
|
-
/** AdmissionController nesting depth; default 1, hard ceiling 4
|
|
4132
|
+
/** AdmissionController nesting depth; default 1, hard ceiling 4. */
|
|
4174
4133
|
maxDepth?: number;
|
|
4175
4134
|
/**
|
|
4176
|
-
* Lineage limits (DEF-3
|
|
4135
|
+
* Lineage limits (DEF-3): maxEscalationsPerLogicalTask
|
|
4177
4136
|
* (default 2) and maxAttemptsPerLogicalTask (default 8), monotonically
|
|
4178
4137
|
* consumed. The validator rejects the pre-rename knob name
|
|
4179
4138
|
* maxEscalationsPerNode with a migration hint (XF-10).
|
|
@@ -4186,7 +4145,7 @@ interface CreateEngineOptions {
|
|
|
4186
4145
|
/** Default InMemoryStore (resume disabled, loud warning). */journal?: JournalStore;
|
|
4187
4146
|
transcripts?: TranscriptStore;
|
|
4188
4147
|
/**
|
|
4189
|
-
* The ModelKnowledge claim store (
|
|
4148
|
+
* The ModelKnowledge claim store (M10-T03). Optional and
|
|
4190
4149
|
* OFF by default: an engine without it writes no kb entries at
|
|
4191
4150
|
* all. The runtime only ever receives the current()-only handle.
|
|
4192
4151
|
*/
|
|
@@ -4198,11 +4157,11 @@ interface CreateEngineOptions {
|
|
|
4198
4157
|
perRun?: number; /** Per-adapter-id caps; unlimited unless configured (Appendix A; M4-T07). */
|
|
4199
4158
|
perProvider?: Record<string, number>;
|
|
4200
4159
|
};
|
|
4201
|
-
/** Versioned price table; wins over caps.pricing (
|
|
4160
|
+
/** Versioned price table; wins over caps.pricing (M4-T06). */
|
|
4202
4161
|
pricing?: PriceTable;
|
|
4203
4162
|
/**
|
|
4204
|
-
* Runner registrations beyond the built-in InProcessRunner (
|
|
4205
|
-
*
|
|
4163
|
+
* Runner registrations beyond the built-in InProcessRunner (M6-T02).
|
|
4164
|
+
* `sandbox` executes CompiledWorkflow
|
|
4206
4165
|
* values (WorkerSandboxRunner ships in @rulvar/planner); running or
|
|
4207
4166
|
* resuming a compiled workflow without one is a typed ConfigError.
|
|
4208
4167
|
*/
|
|
@@ -4210,28 +4169,28 @@ interface CreateEngineOptions {
|
|
|
4210
4169
|
sandbox?: ScriptRunner;
|
|
4211
4170
|
};
|
|
4212
4171
|
/**
|
|
4213
|
-
* The InProcessRunner escalation hook
|
|
4172
|
+
* The InProcessRunner escalation hook:
|
|
4214
4173
|
* receives escalated results when the call form cannot carry them; the
|
|
4215
4174
|
* returned decision is journaled as the authoritative
|
|
4216
4175
|
* escalation-decision entry.
|
|
4217
4176
|
*/
|
|
4218
4177
|
onEscalation?: (result: EscalatedResult<unknown>) => EscalationDecision | Promise<EscalationDecision>;
|
|
4219
4178
|
/**
|
|
4220
|
-
* KeyDeriver registry extension (
|
|
4179
|
+
* KeyDeriver registry extension (see
|
|
4180
|
+
* https://docs.rulvar.com/guide/journal-compatibility).
|
|
4221
4181
|
* Plumbed now, consumed by the matching kernel from M2.
|
|
4222
4182
|
*/
|
|
4223
4183
|
extraDerivers?: readonly unknown[];
|
|
4224
4184
|
/**
|
|
4225
4185
|
* Redact/encrypt at the append/put boundaries, symmetric on load/get
|
|
4226
|
-
* (
|
|
4186
|
+
* (M8-T04, OQ-22 executed).
|
|
4227
4187
|
* Applied by wrapping the configured stores; Engine.stores exposes
|
|
4228
4188
|
* the wrapped instances, so every reader passes one policy point.
|
|
4229
4189
|
*/
|
|
4230
4190
|
serialization?: SerializationHook;
|
|
4231
4191
|
/**
|
|
4232
|
-
* The default key-masking policy at the telemetry boundary
|
|
4233
|
-
*
|
|
4234
|
-
* "event secret masking"). Default ON: key-shaped strings in every
|
|
4192
|
+
* The default key-masking policy at the telemetry boundary. Default
|
|
4193
|
+
* ON: key-shaped strings in every
|
|
4235
4194
|
* emitted WorkflowEvent are masked; never touches the journal.
|
|
4236
4195
|
*/
|
|
4237
4196
|
redaction?: {
|
|
@@ -4252,7 +4211,7 @@ interface RunOptions {
|
|
|
4252
4211
|
/** Host-initiated cancellation. */
|
|
4253
4212
|
signal?: AbortSignal;
|
|
4254
4213
|
}
|
|
4255
|
-
/** Resume-time hit/miss/orphan accounting
|
|
4214
|
+
/** Resume-time hit/miss/orphan accounting. */
|
|
4256
4215
|
interface ResumePreview extends ResumeReport {
|
|
4257
4216
|
invalidResolutions: Array<{
|
|
4258
4217
|
seq: number;
|
|
@@ -4262,23 +4221,23 @@ interface ResumePreview extends ResumeReport {
|
|
|
4262
4221
|
interface ResumeOptions {
|
|
4263
4222
|
/**
|
|
4264
4223
|
* The run's original arguments: not journaled for in-process workflows
|
|
4265
|
-
* in v1, so the host supplies them (resume binding residuals
|
|
4224
|
+
* in v1, so the host supplies them (resume binding residuals).
|
|
4266
4225
|
*/
|
|
4267
4226
|
args?: unknown;
|
|
4268
4227
|
/**
|
|
4269
4228
|
* Dry-run: replay-strict matching; the first would-be-live call throws
|
|
4270
4229
|
* JournalMissError and the run settles with that typed error, zero live
|
|
4271
|
-
* calls performed
|
|
4230
|
+
* calls performed.
|
|
4272
4231
|
*/
|
|
4273
4232
|
dryRun?: boolean;
|
|
4274
|
-
/** invalidate/retry: entries to unpin before matching
|
|
4233
|
+
/** invalidate/retry: entries to unpin before matching. */
|
|
4275
4234
|
invalidate?: number[];
|
|
4276
4235
|
/**
|
|
4277
4236
|
* Queue mode: the worker's lease. The engine carries it on EVERY
|
|
4278
4237
|
* journal append of this resume (the kernel's single append site), so
|
|
4279
4238
|
* a stale worker's writes are rejected by the fencing epoch and never
|
|
4280
|
-
* become visible (
|
|
4281
|
-
*
|
|
4239
|
+
* become visible (M8 entry amendment; DEF-6; FR-703). putMeta and
|
|
4240
|
+
* transcript blobs stay advisory and
|
|
4282
4241
|
* unfenced.
|
|
4283
4242
|
*/
|
|
4284
4243
|
lease?: Lease;
|
|
@@ -4290,44 +4249,43 @@ interface ResumeHandle<R> extends RunHandle<R> {
|
|
|
4290
4249
|
interface Engine {
|
|
4291
4250
|
run<A, R>(wf: Workflow<A, R> | CompiledWorkflow, args: A, opts?: RunOptions): RunHandle<R>;
|
|
4292
4251
|
/**
|
|
4293
|
-
* Rebinds a journal to a workflow definition and resumes
|
|
4294
|
-
*
|
|
4252
|
+
* Rebinds a journal to a workflow definition and resumes. Requires wf
|
|
4253
|
+
* for in-process workflows;
|
|
4295
4254
|
* a name mismatch is a typed ConfigError; a body-hash mismatch warns
|
|
4296
4255
|
* loudly and proceeds (the journal decides replay per content keys).
|
|
4297
4256
|
* A compiled run resumes WITHOUT wf: the engine rehydrates the
|
|
4298
4257
|
* persisted source pinned by workflowHash; supplying a compiled wf
|
|
4299
4258
|
* whose source hash differs from the recorded one is a typed
|
|
4300
|
-
* ConfigError (
|
|
4259
|
+
* ConfigError (M6-T02).
|
|
4301
4260
|
*/
|
|
4302
4261
|
resume<A, R>(runId: string, wf?: Workflow<A, R> | CompiledWorkflow, options?: ResumeOptions): ResumeHandle<R>;
|
|
4303
4262
|
/**
|
|
4304
4263
|
* Renders the registered agent profiles into the shared vocabulary
|
|
4305
|
-
* card
|
|
4306
|
-
*
|
|
4307
|
-
* amendment). Unknown names are ignored.
|
|
4264
|
+
* card, optionally filtered to `names`; the registry itself stays
|
|
4265
|
+
* private to the engine (M6-T05 amendment). Unknown names are ignored.
|
|
4308
4266
|
*/
|
|
4309
4267
|
profileCard(names?: readonly string[]): string;
|
|
4310
4268
|
/**
|
|
4311
4269
|
* The engine's configured stores, exposed for shells and hosts
|
|
4312
|
-
* (
|
|
4313
|
-
*
|
|
4270
|
+
* (M8 entry amendment: the journal store comes from the engine).
|
|
4271
|
+
* Exactly the
|
|
4314
4272
|
* instances createEngine received, or the defaults it built; no store
|
|
4315
4273
|
* contract widens through this accessor. With a serialization hook
|
|
4316
4274
|
* configured these are the HOOKED wrappers, so every reader passes
|
|
4317
|
-
* the one policy point (
|
|
4275
|
+
* the one policy point (M8-T04).
|
|
4318
4276
|
*/
|
|
4319
4277
|
readonly stores: {
|
|
4320
4278
|
journal: JournalStore;
|
|
4321
4279
|
transcripts: TranscriptStore;
|
|
4322
4280
|
};
|
|
4323
4281
|
/**
|
|
4324
|
-
* Retention (
|
|
4282
|
+
* Retention (OQ-20 executed at M8-T04): deletes every
|
|
4325
4283
|
* blob transcripts.list(runId) returns, then the journal; no orphan
|
|
4326
4284
|
* blobs survive. The caller owns the decision that the run is done.
|
|
4327
4285
|
*/
|
|
4328
4286
|
deleteRun(runId: string): Promise<void>;
|
|
4329
4287
|
/**
|
|
4330
|
-
* Checkpoint pruning (
|
|
4288
|
+
* Checkpoint pruning (OQ-20 executed at M8-T04):
|
|
4331
4289
|
* deletes checkpoint blobs of ok-terminal attempts that no other
|
|
4332
4290
|
* entry references; returns the count. Parked, cancelled, escalated,
|
|
4333
4291
|
* and hanging attempts keep theirs (park/unpark, DEF-5 retention, and
|
|
@@ -4335,16 +4293,16 @@ interface Engine {
|
|
|
4335
4293
|
*/
|
|
4336
4294
|
pruneRun(runId: string): Promise<number>;
|
|
4337
4295
|
}
|
|
4338
|
-
/** Content hash of an in-process workflow body (run-to-definition binding
|
|
4296
|
+
/** Content hash of an in-process workflow body (run-to-definition binding). */
|
|
4339
4297
|
declare function hashWorkflowBody(wf: Workflow<never, never> | Workflow<unknown, unknown>): string;
|
|
4340
|
-
/** Content hash of a compiled workflow source (run-to-definition binding
|
|
4298
|
+
/** Content hash of a compiled workflow source (run-to-definition binding). */
|
|
4341
4299
|
declare function hashWorkflowSource(source: string): string;
|
|
4342
4300
|
/** TranscriptStore ref of the persisted CompiledWorkflow source blob. */
|
|
4343
4301
|
declare function workflowSourceRef(runId: string): string;
|
|
4344
4302
|
declare function createEngine(options: CreateEngineOptions): Engine;
|
|
4345
4303
|
//#endregion
|
|
4346
4304
|
//#region src/orchestrator/handles.d.ts
|
|
4347
|
-
/**
|
|
4305
|
+
/** The per-child digest handed to the orchestrator. */
|
|
4348
4306
|
interface TaskDigest {
|
|
4349
4307
|
nodeId: string;
|
|
4350
4308
|
logicalTaskId: string;
|
|
@@ -4363,7 +4321,7 @@ interface SpawnRecord {
|
|
|
4363
4321
|
result: Promise<AgentResult<unknown>>;
|
|
4364
4322
|
settled?: AgentResult<unknown>;
|
|
4365
4323
|
abort: () => void;
|
|
4366
|
-
/** The spawn's escalation flavor, captured at dispatch
|
|
4324
|
+
/** The spawn's escalation flavor, captured at dispatch. */
|
|
4367
4325
|
escalationFlavor?: "A" | "B";
|
|
4368
4326
|
}
|
|
4369
4327
|
/** The engine seam the spawn tools close over (never on ToolContext). */
|
|
@@ -4393,11 +4351,11 @@ interface OrchestratorRuntime {
|
|
|
4393
4351
|
cancelled: boolean;
|
|
4394
4352
|
handle: number;
|
|
4395
4353
|
}>;
|
|
4396
|
-
/**
|
|
4354
|
+
/** Sleep until a coalesced WakeDigest (M6-T09). */
|
|
4397
4355
|
waitForEvents(triggers: unknown): Promise<unknown>;
|
|
4398
4356
|
}
|
|
4399
4357
|
/**
|
|
4400
|
-
* The committed WakeDigest render budget (
|
|
4358
|
+
* The committed WakeDigest render budget (Appendix A: 400
|
|
4401
4359
|
* chars per outputSummary row, the character measure; committed at M10
|
|
4402
4360
|
* entry by adopting the implemented distillation cap unchanged, the
|
|
4403
4361
|
* value frozen into every cassette since M6). One value serves both
|
|
@@ -4407,8 +4365,8 @@ interface OrchestratorRuntime {
|
|
|
4407
4365
|
declare const WAKE_SUMMARY_RENDER_BUDGET_CHARS = 400;
|
|
4408
4366
|
/**
|
|
4409
4367
|
* The M6 outputSummary: a deterministic truncation of the child's
|
|
4410
|
-
* output (or error message), identical live and on replay (
|
|
4411
|
-
*
|
|
4368
|
+
* output (or error message), identical live and on replay (distillation
|
|
4369
|
+
* lives with the child, ordered by
|
|
4412
4370
|
* spawn ordinal; the LLM distillation upgrade is M7 territory).
|
|
4413
4371
|
*/
|
|
4414
4372
|
declare function summarizeOutput(result: AgentResult<unknown>): string;
|
|
@@ -4428,10 +4386,10 @@ interface SpawnAdmissionValue {
|
|
|
4428
4386
|
}
|
|
4429
4387
|
//#endregion
|
|
4430
4388
|
//#region src/orchestrator/wake.d.ts
|
|
4431
|
-
/**
|
|
4389
|
+
/** The wait_for_events parameter schema (normative). */
|
|
4432
4390
|
declare const WAIT_FOR_EVENTS_SCHEMA: SchemaSpec;
|
|
4433
4391
|
declare const WAIT_FOR_EVENTS_TOOL_NAME = "wait_for_events";
|
|
4434
|
-
/** The closed v1 trigger vocabulary
|
|
4392
|
+
/** The closed v1 trigger vocabulary. */
|
|
4435
4393
|
type WakeTrigger = {
|
|
4436
4394
|
kind: "quiescence";
|
|
4437
4395
|
} | {
|
|
@@ -4443,7 +4401,7 @@ type WakeTrigger = {
|
|
|
4443
4401
|
kind: "budget_threshold";
|
|
4444
4402
|
percent: 50 | 80;
|
|
4445
4403
|
};
|
|
4446
|
-
/**
|
|
4404
|
+
/** The escalation block of a digest. */
|
|
4447
4405
|
interface EscalationDigest {
|
|
4448
4406
|
nodeId: string;
|
|
4449
4407
|
logicalTaskId: string;
|
|
@@ -4454,7 +4412,7 @@ interface EscalationDigest {
|
|
|
4454
4412
|
/** Flavor B only. */
|
|
4455
4413
|
deadlineAt?: string;
|
|
4456
4414
|
}
|
|
4457
|
-
/** Passive budget visibility in every digest (DEF-7
|
|
4415
|
+
/** Passive budget visibility in every digest (DEF-7). */
|
|
4458
4416
|
interface WakeBudgetBlock {
|
|
4459
4417
|
runSpentUsd: number;
|
|
4460
4418
|
runCeilingUsd: number;
|
|
@@ -4467,7 +4425,7 @@ interface WakeBudgetBlock {
|
|
|
4467
4425
|
softWarning: boolean;
|
|
4468
4426
|
}
|
|
4469
4427
|
/**
|
|
4470
|
-
* The FINAL normative WakeDigest
|
|
4428
|
+
* The FINAL normative WakeDigest: one coordinated
|
|
4471
4429
|
* schema change inside the hashVersion-2 profile (XF-12). The digest
|
|
4472
4430
|
* render enters the content key of orchestrator turns. In runs without
|
|
4473
4431
|
* the PlanRunner extension the termination, budget, and reuse blocks are
|
|
@@ -4512,7 +4470,7 @@ declare function emptyDigestBlocks(): Pick<WakeDigest, "planHash" | "termination
|
|
|
4512
4470
|
/** One append into an extension-owned sequential scope. */
|
|
4513
4471
|
interface ExtensionAppendInput {
|
|
4514
4472
|
scope: string;
|
|
4515
|
-
/** The content key; extension kinds derive their own
|
|
4473
|
+
/** The content key; extension kinds derive their own. */
|
|
4516
4474
|
key: string;
|
|
4517
4475
|
kind: EntryKind;
|
|
4518
4476
|
value: Json;
|
|
@@ -4521,9 +4479,9 @@ interface ExtensionAppendInput {
|
|
|
4521
4479
|
interface ExtensionDispatchSpec {
|
|
4522
4480
|
agentType: string;
|
|
4523
4481
|
prompt: string;
|
|
4524
|
-
/** Resolved against defaults.schemas
|
|
4482
|
+
/** Resolved against defaults.schemas; unknown names are typed errors. */
|
|
4525
4483
|
outputSchemaRef?: string;
|
|
4526
|
-
/** Resolved against defaults.toolsets
|
|
4484
|
+
/** Resolved against defaults.toolsets; unknown names are typed errors. */
|
|
4527
4485
|
toolsetRef?: string;
|
|
4528
4486
|
isolation?: IsolationSpec;
|
|
4529
4487
|
budgetUsd?: number;
|
|
@@ -4533,15 +4491,15 @@ interface ExtensionDispatchSpec {
|
|
|
4533
4491
|
taskClass?: string;
|
|
4534
4492
|
/**
|
|
4535
4493
|
* A retained transcript checkpoint the dispatch boots from (park and
|
|
4536
|
-
* unpark continuation, the DEF-5 graft boot
|
|
4537
|
-
*
|
|
4494
|
+
* unpark continuation, the DEF-5 graft boot). Dangling redispatch
|
|
4495
|
+
* checkpoints take precedence.
|
|
4538
4496
|
*/
|
|
4539
4497
|
bootCheckpointRef?: string;
|
|
4540
4498
|
/**
|
|
4541
4499
|
* The CONCRETE model of this attempt: the ladder driver resolves each
|
|
4542
4500
|
* rung to its `{ model, effort }` form and dispatches with it, so the
|
|
4543
|
-
* attempt's identity hash includes the concrete ModelRef
|
|
4544
|
-
*
|
|
4501
|
+
* attempt's identity hash includes the concrete ModelRef. The
|
|
4502
|
+
* orchestrator itself never names models; only the
|
|
4545
4503
|
* engine-side driver populates this from the declared ladder.
|
|
4546
4504
|
*/
|
|
4547
4505
|
model?: {
|
|
@@ -4549,7 +4507,7 @@ interface ExtensionDispatchSpec {
|
|
|
4549
4507
|
effort?: Effort;
|
|
4550
4508
|
};
|
|
4551
4509
|
/**
|
|
4552
|
-
* Rung/fallback opt-in
|
|
4510
|
+
* Rung/fallback opt-in: a memoized terminal
|
|
4553
4511
|
* outcome replays by match instead of re-running live; the global
|
|
4554
4512
|
* default errors-re-run-live is preserved (DEF-1).
|
|
4555
4513
|
*/
|
|
@@ -4557,7 +4515,7 @@ interface ExtensionDispatchSpec {
|
|
|
4557
4515
|
/**
|
|
4558
4516
|
* An INLINE SchemaSpec for engine-synthesized children (the ladder
|
|
4559
4517
|
* judge verdict); user-authored plan specs use `outputSchemaRef`
|
|
4560
|
-
* against the registry instead
|
|
4518
|
+
* against the registry instead.
|
|
4561
4519
|
*/
|
|
4562
4520
|
schema?: unknown;
|
|
4563
4521
|
}
|
|
@@ -4571,7 +4529,7 @@ interface OrchestratorExtensionIO {
|
|
|
4571
4529
|
/** Registered agent profiles advertised to this orchestrate call. */
|
|
4572
4530
|
readonly profiles: Record<string, unknown>;
|
|
4573
4531
|
/**
|
|
4574
|
-
* The per-engine mechanical gate registry
|
|
4532
|
+
* The per-engine mechanical gate registry:
|
|
4575
4533
|
* named pure functions over AgentResult.artifacts. Typed loose at the
|
|
4576
4534
|
* seam exactly like `profiles`.
|
|
4577
4535
|
*/
|
|
@@ -4583,7 +4541,7 @@ interface OrchestratorExtensionIO {
|
|
|
4583
4541
|
/**
|
|
4584
4542
|
* A journaled random draw in [0, 1) under the orchestrate scope: the
|
|
4585
4543
|
* ctx.random primitive, computed once live and replayed by match. The
|
|
4586
|
-
* spot-check gate draws HERE, never Math.random
|
|
4544
|
+
* spot-check gate draws HERE, never Math.random.
|
|
4587
4545
|
*/
|
|
4588
4546
|
random(key?: string): Promise<number>;
|
|
4589
4547
|
/** Total-order append; the extension owns its scopes' content keys. */
|
|
@@ -4592,7 +4550,7 @@ interface OrchestratorExtensionIO {
|
|
|
4592
4550
|
snapshot(): readonly JournalEntry[];
|
|
4593
4551
|
/** Flushes the serialized append queue before reading back. */
|
|
4594
4552
|
flush(): Promise<void>;
|
|
4595
|
-
/** The single admission point for all spawns
|
|
4553
|
+
/** The single admission point for all spawns. */
|
|
4596
4554
|
readonly admission: AdmissionController;
|
|
4597
4555
|
/**
|
|
4598
4556
|
* Dispatches one child agent under the EXPLICIT child scope through
|
|
@@ -4614,7 +4572,7 @@ interface OrchestratorExtensionIO {
|
|
|
4614
4572
|
}>;
|
|
4615
4573
|
/**
|
|
4616
4574
|
* Appends the severing abandon ref-entry over a branch through the
|
|
4617
|
-
* ResolutionArbiter (DEF-4/DEF-5
|
|
4575
|
+
* ResolutionArbiter (DEF-4/DEF-5).
|
|
4618
4576
|
*/
|
|
4619
4577
|
abandonBranch(attempt: {
|
|
4620
4578
|
target: number;
|
|
@@ -4630,10 +4588,10 @@ interface OrchestratorExtensionIO {
|
|
|
4630
4588
|
}>;
|
|
4631
4589
|
/**
|
|
4632
4590
|
* Registers a node.link scope-prefix alias for forward matching
|
|
4633
|
-
* (DEF-5
|
|
4591
|
+
* (DEF-5). Idempotent; rebuilt by fold on resume.
|
|
4634
4592
|
*/
|
|
4635
4593
|
registerAlias(donorScope: string, targetScope: string): void;
|
|
4636
|
-
/** The engine price fold (journal facts in, USD out
|
|
4594
|
+
/** The engine price fold (journal facts in, USD out). */
|
|
4637
4595
|
priceUsd(servedBy: string | undefined, usage: Usage): number | undefined;
|
|
4638
4596
|
/** Telemetry emission into the run event stream. */
|
|
4639
4597
|
emit(event: {
|
|
@@ -4648,12 +4606,12 @@ interface OrchestratorExtensionIO {
|
|
|
4648
4606
|
interface OrchestratorExtension {
|
|
4649
4607
|
readonly name: string;
|
|
4650
4608
|
/**
|
|
4651
|
-
* Runs strictly BEFORE the orchestrator agent's first entry
|
|
4652
|
-
*
|
|
4609
|
+
* Runs strictly BEFORE the orchestrator agent's first entry
|
|
4610
|
+
* (termination.init precedes the first scheduling entry and the
|
|
4653
4611
|
* budget reserve). On resume it rebuilds state from the journal.
|
|
4654
4612
|
*/
|
|
4655
4613
|
boot?(io: OrchestratorExtensionIO): Promise<void> | void;
|
|
4656
|
-
/** Extension tools appended to the mode (c) toolset
|
|
4614
|
+
/** Extension tools appended to the mode (c) toolset. */
|
|
4657
4615
|
tools(io: OrchestratorExtensionIO): ToolDef[];
|
|
4658
4616
|
/** Extra orchestrator prompt lines describing the extension's protocol. */
|
|
4659
4617
|
promptLines?(): string[];
|
|
@@ -4664,7 +4622,7 @@ interface OrchestratorExtension {
|
|
|
4664
4622
|
*/
|
|
4665
4623
|
onActivity?(io: OrchestratorExtensionIO): Promise<void> | void;
|
|
4666
4624
|
/**
|
|
4667
|
-
* Quiescence participation
|
|
4625
|
+
* Quiescence participation: the mandatory trigger fires
|
|
4668
4626
|
* only when every dispatched child settled AND the extension reports
|
|
4669
4627
|
* nothing running and nothing ready.
|
|
4670
4628
|
*/
|
|
@@ -4679,7 +4637,10 @@ interface OrchestratorExtension {
|
|
|
4679
4637
|
}
|
|
4680
4638
|
//#endregion
|
|
4681
4639
|
//#region src/orchestrator/orchestrate.d.ts
|
|
4682
|
-
/**
|
|
4640
|
+
/**
|
|
4641
|
+
* Budget contract: https://docs.rulvar.com/guide/budgets; the cap
|
|
4642
|
+
* machinery (reserves, freeze) completes in M7 (DEF-7).
|
|
4643
|
+
*/
|
|
4683
4644
|
interface OrchestratorBudgetSpec {
|
|
4684
4645
|
capUsd?: number;
|
|
4685
4646
|
/** default 0.2; effectiveCap = min of the given bounds */
|
|
@@ -4688,7 +4649,7 @@ interface OrchestratorBudgetSpec {
|
|
|
4688
4649
|
finalizeTurns?: number;
|
|
4689
4650
|
atCap?: "finish-with-partial" | "fail-run";
|
|
4690
4651
|
}
|
|
4691
|
-
/**
|
|
4652
|
+
/** Options for orchestrate(engine, goal, o?). */
|
|
4692
4653
|
interface OrchestrateOptions {
|
|
4693
4654
|
model?: ModelSpec;
|
|
4694
4655
|
/** Registered profile names to advertise; default: every profile. */
|
|
@@ -4698,17 +4659,17 @@ interface OrchestrateOptions {
|
|
|
4698
4659
|
/** The orchestrator's own budget sub-account (cap enforcement layers only in M6). */
|
|
4699
4660
|
budget?: OrchestratorBudgetSpec;
|
|
4700
4661
|
/**
|
|
4701
|
-
* Deterministic digest render bound
|
|
4662
|
+
* Deterministic digest render bound: each
|
|
4702
4663
|
* TaskDigest outputSummary is clamped to this many CHARACTERS (the
|
|
4703
4664
|
* model-independent measure; OQ-04 closed at M10 entry). Default
|
|
4704
|
-
* WAKE_SUMMARY_RENDER_BUDGET_CHARS
|
|
4665
|
+
* WAKE_SUMMARY_RENDER_BUDGET_CHARS.
|
|
4705
4666
|
*/
|
|
4706
4667
|
renderBudgetChars?: number;
|
|
4707
4668
|
/** UsageLimits of the orchestrator agent itself (maxTurns etc.). */
|
|
4708
4669
|
limits?: UsageLimits;
|
|
4709
4670
|
/**
|
|
4710
4671
|
* The opt-in mode (c) extension seam (M7-T05): PlanRunner from
|
|
4711
|
-
* @rulvar/plan attaches here
|
|
4672
|
+
* @rulvar/plan attaches here. The extension boots
|
|
4712
4673
|
* strictly before the orchestrator's first agent entry, contributes
|
|
4713
4674
|
* tools, schedules ready plan nodes on every settlement, and
|
|
4714
4675
|
* participates in the mandatory quiescence trigger.
|
|
@@ -4723,7 +4684,7 @@ declare const ORCHESTRATE_WORKFLOW_NAME = "rulvar-orchestrate";
|
|
|
4723
4684
|
* orchestrator agent with the finish terminal tool.
|
|
4724
4685
|
*/
|
|
4725
4686
|
declare function makeOrchestratorWorkflow(goal: string, opts?: OrchestrateOptions): Workflow<undefined, unknown>;
|
|
4726
|
-
/** Top-level surface: creates a run
|
|
4687
|
+
/** Top-level surface: creates a run. */
|
|
4727
4688
|
declare function orchestrate(engine: Engine, goal: string, opts?: OrchestrateOptions): RunHandle<unknown>;
|
|
4728
4689
|
//#endregion
|
|
4729
4690
|
//#region src/engine/scheduler.d.ts
|
|
@@ -4731,10 +4692,10 @@ declare function orchestrate(engine: Engine, goal: string, opts?: OrchestrateOpt
|
|
|
4731
4692
|
* Scheduler and concurrency (M1-T08): the per-run semaphore with a FIFO
|
|
4732
4693
|
* queue (default 12 concurrent model calls). The engine lifetime spawn cap
|
|
4733
4694
|
* is enforced by the budget layer at admission; parallel/pipeline
|
|
4734
|
-
* composition semantics live with ctx
|
|
4695
|
+
* composition semantics live with ctx.
|
|
4735
4696
|
* Per-provider concurrency keys land with M4.
|
|
4736
4697
|
*/
|
|
4737
|
-
/** FIFO semaphore; default per-run width is 12
|
|
4698
|
+
/** FIFO semaphore; default per-run width is 12. */
|
|
4738
4699
|
declare const DEFAULT_PER_RUN_CONCURRENCY = 12;
|
|
4739
4700
|
declare class Semaphore {
|
|
4740
4701
|
private readonly limit;
|
|
@@ -4766,7 +4727,7 @@ declare function toApprovalDecision(value: Json): ApprovalDecision;
|
|
|
4766
4727
|
* Per-run registry of open external suspensions plus the run's activity
|
|
4767
4728
|
* counter: when every in-flight branch is blocked on suspensions
|
|
4768
4729
|
* (activity zero, waiters open), the run quiesces into outcome
|
|
4769
|
-
* 'suspended'
|
|
4730
|
+
* 'suspended'.
|
|
4770
4731
|
*/
|
|
4771
4732
|
declare class ExternalRegistry {
|
|
4772
4733
|
private readonly replayer;
|
|
@@ -4798,7 +4759,7 @@ declare class ExternalRegistry {
|
|
|
4798
4759
|
prompt?: string;
|
|
4799
4760
|
}): Promise<Json>;
|
|
4800
4761
|
/**
|
|
4801
|
-
* Tool-approval suspension (M3-T03
|
|
4762
|
+
* Tool-approval suspension (M3-T03): journals (or
|
|
4802
4763
|
* re-matches) the suspended approval entry keyed by (toolName, input)
|
|
4803
4764
|
* in the agent's child scope and parks until a resolution closes it.
|
|
4804
4765
|
* The ask verdict is journaled together with the turn checkpoint; on
|
|
@@ -4814,7 +4775,7 @@ declare class ExternalRegistry {
|
|
|
4814
4775
|
onPending?: (entry: JournalEntry, replayed: boolean) => void;
|
|
4815
4776
|
}): Promise<ApprovalDecision>;
|
|
4816
4777
|
/**
|
|
4817
|
-
* Flavor B escalation suspension (M3-T07
|
|
4778
|
+
* Flavor B escalation suspension (M3-T07): the
|
|
4818
4779
|
* escalate tool suspends the agent on the SAME machinery as approvals
|
|
4819
4780
|
* (kind 'approval', toolName 'escalate') with a journaled deadlineAt so
|
|
4820
4781
|
* deadlines survive resume; the resolution VALUE is the raw
|
|
@@ -4843,7 +4804,7 @@ declare class ExternalRegistry {
|
|
|
4843
4804
|
/**
|
|
4844
4805
|
* RunHandle.resolveExternal: the live path validates BEFORE append and
|
|
4845
4806
|
* throws InvalidResolutionError without journaling; a winning attempt
|
|
4846
|
-
* settles the waiting promise in place
|
|
4807
|
+
* settles the waiting promise in place.
|
|
4847
4808
|
*/
|
|
4848
4809
|
resolveExternal(key: string, value: Json): Promise<ResolutionOutcome>;
|
|
4849
4810
|
}
|
|
@@ -4851,9 +4812,9 @@ declare class ExternalRegistry {
|
|
|
4851
4812
|
//#region src/engine/ctx.d.ts
|
|
4852
4813
|
type ErrorPolicy = "strict" | "lenient";
|
|
4853
4814
|
/**
|
|
4854
|
-
* The canonical, complete AgentProfile shape
|
|
4855
|
-
*
|
|
4856
|
-
*
|
|
4815
|
+
* The canonical, complete AgentProfile shape; M1 honors description,
|
|
4816
|
+
* model, routing, effort, limits, and estCost. A profile never carries
|
|
4817
|
+
* a prompt or a schema.
|
|
4857
4818
|
*/
|
|
4858
4819
|
interface AgentProfile {
|
|
4859
4820
|
description?: string;
|
|
@@ -4862,11 +4823,11 @@ interface AgentProfile {
|
|
|
4862
4823
|
effort?: Effort;
|
|
4863
4824
|
/** Toolset default; the resolved snapshot enters identity via toolsetHash. */
|
|
4864
4825
|
tools?: ToolsOption;
|
|
4865
|
-
/** Chain layers merged over engine defaults
|
|
4826
|
+
/** Chain layers merged over engine defaults. */
|
|
4866
4827
|
permissions?: AgentProfilePermissions;
|
|
4867
|
-
/** Isolation default; the RESOLVED value enters identity
|
|
4828
|
+
/** Isolation default; the RESOLVED value enters identity. */
|
|
4868
4829
|
isolation?: IsolationSpec;
|
|
4869
|
-
/** Flavor B opt-in lives here or on the call
|
|
4830
|
+
/** Flavor B opt-in lives here or on the call. */
|
|
4870
4831
|
escalation?: EscalationOptions;
|
|
4871
4832
|
limits?: UsageLimits;
|
|
4872
4833
|
/** Transport RetryPolicy layer: call over profile over engine (M4-T05). */
|
|
@@ -4875,7 +4836,7 @@ interface AgentProfile {
|
|
|
4875
4836
|
taskClass?: string;
|
|
4876
4837
|
/**
|
|
4877
4838
|
* Per-profile compaction threshold; default 0.8 of the loop model's
|
|
4878
|
-
* contextWindow (
|
|
4839
|
+
* contextWindow (M4-T03). Compaction is ON by
|
|
4879
4840
|
* default; history-processor plumbing stays engine-internal.
|
|
4880
4841
|
*/
|
|
4881
4842
|
compaction?: {
|
|
@@ -4885,7 +4846,7 @@ interface AgentProfile {
|
|
|
4885
4846
|
estCost?: number;
|
|
4886
4847
|
}
|
|
4887
4848
|
/**
|
|
4888
|
-
* Per-spawn options
|
|
4849
|
+
* Per-spawn options. The
|
|
4889
4850
|
* identity split is normative: agentType, model/routing/effort (the
|
|
4890
4851
|
* requested modelSpec), schema (schemaHash), and key enter the content
|
|
4891
4852
|
* key; everything else is policy or telemetry and never re-keys entries.
|
|
@@ -4899,8 +4860,7 @@ interface AgentOpts<S extends SchemaSpec = SchemaSpec> {
|
|
|
4899
4860
|
* 'loop'. The plan and orchestrate entry points set it so the
|
|
4900
4861
|
* resolution chain, role effort defaults, quality floors, and cost
|
|
4901
4862
|
* buckets see the right role; extract/finalize/summarize stay
|
|
4902
|
-
* trigger-derived and are never settable here (
|
|
4903
|
-
* M6-T05 amendment).
|
|
4863
|
+
* trigger-derived and are never settable here (M6-T05 amendment).
|
|
4904
4864
|
*/
|
|
4905
4865
|
role?: "loop" | "plan" | "orchestrate";
|
|
4906
4866
|
/** Overrides all roles at once. */
|
|
@@ -4911,29 +4871,29 @@ interface AgentOpts<S extends SchemaSpec = SchemaSpec> {
|
|
|
4911
4871
|
effort?: Effort;
|
|
4912
4872
|
/** schemaHash enters identity. */
|
|
4913
4873
|
schema?: S;
|
|
4914
|
-
/** toolsetHash enters identity; wins over profile.tools
|
|
4874
|
+
/** toolsetHash enters identity; wins over profile.tools. */
|
|
4915
4875
|
tools?: ToolsOption;
|
|
4916
|
-
/**
|
|
4876
|
+
/** The RESOLVED value enters identity; worktree needs defaults.isolation. */
|
|
4917
4877
|
isolation?: IsolationSpec;
|
|
4918
4878
|
/** Explicit discriminator; replaces the prompt in the content key. */
|
|
4919
4879
|
key?: string;
|
|
4920
4880
|
onError?: "throw" | "null";
|
|
4921
|
-
/** Transport RetryPolicy under the journal (
|
|
4881
|
+
/** Transport RetryPolicy under the journal (M4-T05). */
|
|
4922
4882
|
retry?: RetryPolicy;
|
|
4923
4883
|
/**
|
|
4924
|
-
* The degenerate fallback (
|
|
4884
|
+
* The degenerate fallback (M4-T04): an agent-level
|
|
4925
4885
|
* second attempt on `model` when the terminal matches `on`; one
|
|
4926
4886
|
* journaled decision entry; the fallback attempt is a NEW content key.
|
|
4927
4887
|
*/
|
|
4928
4888
|
fallback?: FallbackField;
|
|
4929
|
-
/** Per-call replay mode; default scoped forward-matching
|
|
4889
|
+
/** Per-call replay mode; default scoped forward-matching. */
|
|
4930
4890
|
replay?: "cache" | "never";
|
|
4931
4891
|
/** Journaled as a policy field from day one; consumed by the M2 predicate. */
|
|
4932
4892
|
memoizeOutcome?: boolean;
|
|
4933
|
-
/** Opt-in; without it 'escalated' is physically unproducible
|
|
4893
|
+
/** Opt-in; without it 'escalated' is physically unproducible. */
|
|
4934
4894
|
escalation?: EscalationOptions;
|
|
4935
4895
|
/**
|
|
4936
|
-
* Lineage continuation (DEF-3
|
|
4896
|
+
* Lineage continuation (DEF-3): declares this
|
|
4937
4897
|
* spawn a rebirth of an existing logical task; absence means a new
|
|
4938
4898
|
* lineage root. Never enters the content key. Declaring lineage or
|
|
4939
4899
|
* approach journals a spawn-admission decision entry BEFORE dispatch,
|
|
@@ -4944,7 +4904,7 @@ interface AgentOpts<S extends SchemaSpec = SchemaSpec> {
|
|
|
4944
4904
|
approach?: string;
|
|
4945
4905
|
/** Admission reserve hint (USD). */
|
|
4946
4906
|
estCost?: number;
|
|
4947
|
-
/** Merged over profile and engine limits
|
|
4907
|
+
/** Merged over profile and engine limits. */
|
|
4948
4908
|
limits?: UsageLimits;
|
|
4949
4909
|
result?: "value" | "full";
|
|
4950
4910
|
/** Telemetry only. */
|
|
@@ -4952,7 +4912,7 @@ interface AgentOpts<S extends SchemaSpec = SchemaSpec> {
|
|
|
4952
4912
|
/** Enables agent:stream delta events. */
|
|
4953
4913
|
stream?: boolean;
|
|
4954
4914
|
}
|
|
4955
|
-
/**
|
|
4915
|
+
/** One dropped result: its source, scope, entry ref, and wire error. */
|
|
4956
4916
|
interface DroppedItem {
|
|
4957
4917
|
source: "pipeline" | "agent-onerror-null" | "parallel-settled";
|
|
4958
4918
|
/** Scope path of the failed call. */
|
|
@@ -4964,8 +4924,7 @@ interface DroppedItem {
|
|
|
4964
4924
|
}
|
|
4965
4925
|
/**
|
|
4966
4926
|
* The discriminated union over AgentStatus carrying the underlying
|
|
4967
|
-
* AgentResult where one exists
|
|
4968
|
-
* Settled").
|
|
4927
|
+
* AgentResult where one exists.
|
|
4969
4928
|
*/
|
|
4970
4929
|
type Settled<T> = {
|
|
4971
4930
|
status: "ok";
|
|
@@ -4991,10 +4950,9 @@ type Settled<T> = {
|
|
|
4991
4950
|
type Stage<I, O> = (item: I) => Promise<O>;
|
|
4992
4951
|
/**
|
|
4993
4952
|
* The rejection carrier of ctx.agent value-form calls: a real Error that
|
|
4994
|
-
* structurally satisfies the typed AgentError
|
|
4995
|
-
*
|
|
4996
|
-
*
|
|
4997
|
-
* registry (docs/02, section "Error taxonomy").
|
|
4953
|
+
* structurally satisfies the typed AgentError and carries the full
|
|
4954
|
+
* AgentResult for Settled mapping. Deliberately not a RulvarError:
|
|
4955
|
+
* AgentError is not in the closed code registry.
|
|
4998
4956
|
*/
|
|
4999
4957
|
declare class AgentCallError extends Error implements AgentError {
|
|
5000
4958
|
readonly kind: AgentError["kind"];
|
|
@@ -5011,7 +4969,7 @@ interface PipelineCollected<T> {
|
|
|
5011
4969
|
results: T[];
|
|
5012
4970
|
dropped: DroppedItem[];
|
|
5013
4971
|
}
|
|
5014
|
-
/** The canonical Ctx interface, M1 members
|
|
4972
|
+
/** The canonical Ctx interface, M1 members. */
|
|
5015
4973
|
interface Ctx<P extends ErrorPolicy = "strict"> {
|
|
5016
4974
|
agent(prompt: string): Promise<P extends "lenient" ? string | null : string>;
|
|
5017
4975
|
agent<S extends SchemaSpec>(prompt: string, o: AgentOpts<S> & {
|
|
@@ -5045,33 +5003,33 @@ interface Ctx<P extends ErrorPolicy = "strict"> {
|
|
|
5045
5003
|
key?: string;
|
|
5046
5004
|
}): Promise<T>;
|
|
5047
5005
|
/**
|
|
5048
|
-
* Runs a child workflow under the AdmissionController (
|
|
5049
|
-
*
|
|
5006
|
+
* Runs a child workflow under the AdmissionController (M6-T06). The
|
|
5007
|
+
* child gets a nested journal scope (registered name
|
|
5050
5008
|
* plus ordinal) and a hierarchical budget sub-account whose spend
|
|
5051
5009
|
* propagates to every ancestor. Structural limit violations throw the
|
|
5052
5010
|
* typed AdmissionRejectedError and never tear the run down; budget
|
|
5053
5011
|
* rejections throw BudgetExhaustedError. The string form resolves
|
|
5054
|
-
* against the per-engine workflow registry
|
|
5012
|
+
* against the per-engine workflow registry and is the
|
|
5055
5013
|
* only form available inside the worker sandbox.
|
|
5056
5014
|
*/
|
|
5057
5015
|
workflow<A, R>(wf: Workflow<A, R>, args: A, o?: WorkflowCallOpts): Promise<R>;
|
|
5058
5016
|
workflow(name: string, args?: Json, o?: WorkflowCallOpts): Promise<unknown>;
|
|
5059
5017
|
/**
|
|
5060
|
-
* Nests a dynamic orchestrator under the AdmissionController (
|
|
5061
|
-
*
|
|
5018
|
+
* Nests a dynamic orchestrator under the AdmissionController (M6-T07):
|
|
5019
|
+
* one implementation with the top-level
|
|
5062
5020
|
* orchestrate(engine, goal, opts) surface, clamped by maxDepth and the
|
|
5063
5021
|
* parent budget account through the ordinary ctx.workflow admission.
|
|
5064
5022
|
*/
|
|
5065
5023
|
orchestrate(goal: string, opts?: OrchestrateOptions): Promise<unknown>;
|
|
5066
5024
|
/**
|
|
5067
5025
|
* A journaled summarize invocation for handing an inheritable brief to
|
|
5068
|
-
* a child (
|
|
5026
|
+
* a child (M6-T10): one agent-kind entry under
|
|
5069
5027
|
* role 'summarize', therefore free on replay.
|
|
5070
5028
|
*/
|
|
5071
5029
|
brief(o: BriefOpts): Promise<string>;
|
|
5072
5030
|
/**
|
|
5073
5031
|
* Suspends this position on a journaled entry until an external
|
|
5074
|
-
* resolution arrives
|
|
5032
|
+
* resolution arrives. NO deadline in v1.
|
|
5075
5033
|
*/
|
|
5076
5034
|
awaitExternal<T = Json>(key: string, o?: {
|
|
5077
5035
|
schema?: SchemaSpec;
|
|
@@ -5093,7 +5051,7 @@ interface PipelineOpts {
|
|
|
5093
5051
|
interface CollectOpts {
|
|
5094
5052
|
onItemError: "collect";
|
|
5095
5053
|
}
|
|
5096
|
-
/** Options of ctx.workflow; `key` replaces args in the child identity
|
|
5054
|
+
/** Options of ctx.workflow; `key` replaces args in the child identity. */
|
|
5097
5055
|
interface WorkflowCallOpts {
|
|
5098
5056
|
key?: string;
|
|
5099
5057
|
/** Lineage continuation (DEF-3); embedded in the admission decision entry. */
|
|
@@ -5102,8 +5060,8 @@ interface WorkflowCallOpts {
|
|
|
5102
5060
|
approach?: string;
|
|
5103
5061
|
}
|
|
5104
5062
|
/**
|
|
5105
|
-
* Options of ctx.brief (
|
|
5106
|
-
*
|
|
5063
|
+
* Options of ctx.brief (concrete shape fixed in M6-T10): the content to
|
|
5064
|
+
* distill plus an optional instruction;
|
|
5107
5065
|
* the invocation resolves role 'summarize', so it needs
|
|
5108
5066
|
* defaults.routing.summarize, a profile, or the explicit model.
|
|
5109
5067
|
*/
|
|
@@ -5113,7 +5071,7 @@ interface BriefOpts {
|
|
|
5113
5071
|
model?: ModelSpec;
|
|
5114
5072
|
agentType?: string;
|
|
5115
5073
|
}
|
|
5116
|
-
/** Closure-form workflow value; in-process only
|
|
5074
|
+
/** Closure-form workflow value; in-process only. */
|
|
5117
5075
|
interface Workflow<A = unknown, R = unknown> {
|
|
5118
5076
|
readonly kind: "workflow";
|
|
5119
5077
|
readonly name: string;
|
|
@@ -5163,7 +5121,7 @@ interface RunInternals {
|
|
|
5163
5121
|
runId: string;
|
|
5164
5122
|
replayer: Replayer;
|
|
5165
5123
|
budget: RunBudget;
|
|
5166
|
-
/** The single admission point for all spawns (
|
|
5124
|
+
/** The single admission point for all spawns (M6-T06). */
|
|
5167
5125
|
admission?: AdmissionController;
|
|
5168
5126
|
semaphore: Semaphore;
|
|
5169
5127
|
events: RunEventSink;
|
|
@@ -5175,38 +5133,38 @@ interface RunInternals {
|
|
|
5175
5133
|
defaults: {
|
|
5176
5134
|
routing?: Partial<Record<InvocationRole, ModelSpec>>;
|
|
5177
5135
|
profiles?: Record<string, AgentProfile>;
|
|
5178
|
-
limits?: UsageLimits; /** Engine-wide permission chain layers
|
|
5179
|
-
permissions?: PermissionConfig; /** Engine-wide transport RetryPolicy (
|
|
5180
|
-
retry?: RetryPolicy; /** The per-engine workflow registry (
|
|
5181
|
-
workflows?: Record<string, unknown>; /** Registered SchemaSpec names for outputSchemaRef (
|
|
5182
|
-
schemas?: Record<string, SchemaSpec>; /** Registered tool profile names for toolsetRef (
|
|
5183
|
-
toolsets?: Record<string, ToolsOption>; /** Registered mechanical gate profiles (
|
|
5136
|
+
limits?: UsageLimits; /** Engine-wide permission chain layers. */
|
|
5137
|
+
permissions?: PermissionConfig; /** Engine-wide transport RetryPolicy (M4-T05). */
|
|
5138
|
+
retry?: RetryPolicy; /** The per-engine workflow registry (consumers: M6 ctx.workflow, M8 worker). */
|
|
5139
|
+
workflows?: Record<string, unknown>; /** Registered SchemaSpec names for outputSchemaRef (M7-T05). */
|
|
5140
|
+
schemas?: Record<string, SchemaSpec>; /** Registered tool profile names for toolsetRef (M7-T05). */
|
|
5141
|
+
toolsets?: Record<string, ToolsOption>; /** Registered mechanical gate profiles (M7-T10). */
|
|
5184
5142
|
gates?: Record<string, MechanicalGateProfile>;
|
|
5185
5143
|
};
|
|
5186
|
-
/** Engine-scoped per-provider keyed limiter (
|
|
5144
|
+
/** Engine-scoped per-provider keyed limiter (M4-T07). */
|
|
5187
5145
|
providerLimiter?: KeyedLimiter;
|
|
5188
5146
|
/** The configured price table's version; pinned in decision entries (M4-T06). */
|
|
5189
5147
|
pricingVersion?: string;
|
|
5190
|
-
/** budgetDefaults.flatReserveUsd; last resort of the reserve formula
|
|
5148
|
+
/** budgetDefaults.flatReserveUsd; last resort of the reserve formula. */
|
|
5191
5149
|
flatReserveUsd?: number;
|
|
5192
|
-
/** Hard router constraints from engine config (
|
|
5150
|
+
/** Hard router constraints from engine config (M4-T09). */
|
|
5193
5151
|
floors?: QualityFloors;
|
|
5194
5152
|
errorPolicy: ErrorPolicy;
|
|
5195
5153
|
dropped: DroppedItem[];
|
|
5196
5154
|
cost: CostAttribution;
|
|
5197
5155
|
priceUsd: (servedBy: ModelRef, usage: Usage) => number | undefined;
|
|
5198
5156
|
runSignal?: AbortSignal;
|
|
5199
|
-
/** The worktree lifecycle provider
|
|
5157
|
+
/** The worktree lifecycle provider. */
|
|
5200
5158
|
isolation?: IsolationProvider;
|
|
5201
5159
|
/**
|
|
5202
|
-
* The ModelKnowledge runtime handle (
|
|
5160
|
+
* The ModelKnowledge runtime handle (M10-T03): current()
|
|
5203
5161
|
* only, commit physically absent. Present only when the engine was
|
|
5204
5162
|
* given stores.modelKnowledge; absent means the feature is off and
|
|
5205
5163
|
* no kb entries are ever written.
|
|
5206
5164
|
*/
|
|
5207
5165
|
knowledge?: ModelKnowledgeHandle;
|
|
5208
5166
|
/**
|
|
5209
|
-
* The InProcessRunner escalation hook
|
|
5167
|
+
* The InProcessRunner escalation hook: receives
|
|
5210
5168
|
* escalated results when the call form cannot carry them; its decision
|
|
5211
5169
|
* is journaled as the authoritative escalation-decision entry.
|
|
5212
5170
|
*/
|
|
@@ -5237,7 +5195,7 @@ declare function createCtx(internals: RunInternals): Ctx<ErrorPolicy>;
|
|
|
5237
5195
|
declare function executeWorkflow<A, R>(internals: RunInternals, wf: Workflow<A, R>, args: A): Promise<R>;
|
|
5238
5196
|
//#endregion
|
|
5239
5197
|
//#region src/knowledge/card.d.ts
|
|
5240
|
-
/**
|
|
5198
|
+
/** The KB card render budget (characters). */
|
|
5241
5199
|
declare const KB_CARD_RENDER_BUDGET_CHARS = 4096;
|
|
5242
5200
|
/** One declared ladder of the run, named by its agentType. */
|
|
5243
5201
|
interface DeclaredLadder {
|
|
@@ -5250,12 +5208,12 @@ interface DeclaredLadder {
|
|
|
5250
5208
|
}
|
|
5251
5209
|
/**
|
|
5252
5210
|
* The ladders a run declares: every advertised profile whose model
|
|
5253
|
-
* spec is a ladder
|
|
5211
|
+
* spec is a ladder. The card is tier-relative to
|
|
5254
5212
|
* exactly these.
|
|
5255
5213
|
*/
|
|
5256
5214
|
declare function collectDeclaredLadders(profiles: Record<string, AgentProfile> | undefined): DeclaredLadder[];
|
|
5257
5215
|
/**
|
|
5258
|
-
* The admission filter
|
|
5216
|
+
* The admission filter: status active, unexpired at
|
|
5259
5217
|
* `now`, and the subject reachable through the run's declared ladders
|
|
5260
5218
|
* after the role-floor filter.
|
|
5261
5219
|
*/
|
|
@@ -5273,8 +5231,7 @@ interface VerifiedRecommendation {
|
|
|
5273
5231
|
votes: number;
|
|
5274
5232
|
}
|
|
5275
5233
|
/**
|
|
5276
|
-
* The verified-layer compiler (M11-T06
|
|
5277
|
-
* and "Composition with the model layer"): start-tier recommendations
|
|
5234
|
+
* The verified-layer compiler (M11-T06): start-tier recommendations
|
|
5278
5235
|
* per (ladder, taskClass) compiled EXCLUSIVELY from eval-measured
|
|
5279
5236
|
* claims. A strength on a rung below the default votes down (start
|
|
5280
5237
|
* cheaper); a weakness on the default rung or below votes up. The net
|
|
@@ -5287,13 +5244,14 @@ interface VerifiedRecommendation {
|
|
|
5287
5244
|
*/
|
|
5288
5245
|
declare function compileVerifiedLayer(claims: readonly ModelClaim[], ladders: readonly DeclaredLadder[]): VerifiedRecommendation[];
|
|
5289
5246
|
/**
|
|
5290
|
-
* The deterministic card render
|
|
5247
|
+
* The deterministic card render. Pure: same filtered
|
|
5291
5248
|
* claims and ladders give byte-identical text. The render budget is
|
|
5292
|
-
*
|
|
5249
|
+
* 4096 chars; over it, the OLDEST-observed notes
|
|
5293
5250
|
* withhold first behind an explicit marker.
|
|
5294
5251
|
*/
|
|
5295
5252
|
declare function modelKnowledgeCard(claims: readonly ModelClaim[], ladders: readonly DeclaredLadder[], options?: {
|
|
5296
5253
|
budgetChars?: number;
|
|
5254
|
+
profiles?: Record<string, AgentProfile>;
|
|
5297
5255
|
}): string;
|
|
5298
5256
|
//#endregion
|
|
5299
5257
|
//#region src/tools/presets.d.ts
|
|
@@ -5305,7 +5263,7 @@ declare function compilePermissionPreset(preset: PermissionPreset): {
|
|
|
5305
5263
|
//#endregion
|
|
5306
5264
|
//#region src/tools/shell-matcher.d.ts
|
|
5307
5265
|
/**
|
|
5308
|
-
* Argv-parsing shell matcher (M5-T06
|
|
5266
|
+
* Argv-parsing shell matcher (M5-T06): shell
|
|
5309
5267
|
* allow/ask/deny is matched through a real argv parser, never a string
|
|
5310
5268
|
* prefix. The composition rule is the entire point: for a compound
|
|
5311
5269
|
* command the verdict is the strictest across segments, and any
|
|
@@ -5332,7 +5290,7 @@ interface ShellSegment {
|
|
|
5332
5290
|
unmatchable: boolean;
|
|
5333
5291
|
}
|
|
5334
5292
|
/**
|
|
5335
|
-
* Lexes a command into segments per the
|
|
5293
|
+
* Lexes a command into segments per the matching algorithm above. Quotes
|
|
5336
5294
|
* and escapes are honored; nothing is expanded; `$(`, backticks, `<(`,
|
|
5337
5295
|
* `>(`, and `<<` (outside single quotes) poison their segment.
|
|
5338
5296
|
*/
|
|
@@ -5358,19 +5316,19 @@ interface ShellPatternRules {
|
|
|
5358
5316
|
declare function matchShellCommand(command: string, rules: ShellPatternRules): ShellVerdict;
|
|
5359
5317
|
//#endregion
|
|
5360
5318
|
//#region src/tools/tool.d.ts
|
|
5361
|
-
/** First-party provider tool-name constraint intersection
|
|
5319
|
+
/** First-party provider tool-name constraint intersection. */
|
|
5362
5320
|
declare const TOOL_NAME_PATTERN: RegExp;
|
|
5363
5321
|
interface ToolInit<S extends SchemaSpec> {
|
|
5364
5322
|
name: string;
|
|
5365
5323
|
description: string;
|
|
5366
5324
|
parameters: S;
|
|
5367
|
-
/** Contract version, part of toolsetHash
|
|
5325
|
+
/** Contract version, part of toolsetHash. */
|
|
5368
5326
|
version?: string;
|
|
5369
|
-
/** Default 'inprocess'
|
|
5327
|
+
/** Default 'inprocess'. */
|
|
5370
5328
|
executor?: ToolExecutor;
|
|
5371
|
-
/** Default false
|
|
5329
|
+
/** Default false. */
|
|
5372
5330
|
needsApproval?: boolean;
|
|
5373
|
-
/** Policy metadata; never identity
|
|
5331
|
+
/** Policy metadata; never identity. */
|
|
5374
5332
|
risk?: ToolRisk;
|
|
5375
5333
|
execute: (input: Out<S>, ctx: ToolContext) => Promise<unknown>;
|
|
5376
5334
|
}
|
|
@@ -5378,13 +5336,12 @@ interface ToolInit<S extends SchemaSpec> {
|
|
|
5378
5336
|
* Defines a tool. Definition-time failures are typed ConfigErrors, never
|
|
5379
5337
|
* first-call surprises: an illegal name, a Standard Schema without the
|
|
5380
5338
|
* JSON Schema projection, a recursive local $ref, or a remote/dynamic
|
|
5381
|
-
* reference all fail here
|
|
5339
|
+
* reference all fail here.
|
|
5382
5340
|
*/
|
|
5383
5341
|
declare function tool<S extends SchemaSpec>(init: ToolInit<S>): ToolDef<S>;
|
|
5384
5342
|
/**
|
|
5385
5343
|
* The identity projection: the contract tuple that enters toolsetHash.
|
|
5386
|
-
* parameters is the canonicalized derived JSON Schema
|
|
5387
|
-
* "schemaHash and toolsetHash derivation").
|
|
5344
|
+
* parameters is the canonicalized derived JSON Schema.
|
|
5388
5345
|
*/
|
|
5389
5346
|
declare function toolContract(def: ToolDef): ToolContract;
|
|
5390
5347
|
//#endregion
|
|
@@ -5419,11 +5376,11 @@ interface McpConfig {
|
|
|
5419
5376
|
allow?: string[];
|
|
5420
5377
|
/** Deny wins over allow (pre-prefix names). */
|
|
5421
5378
|
deny?: string[];
|
|
5422
|
-
/** Namespaces imported names as `${prefix}_${name}
|
|
5379
|
+
/** Namespaces imported names as `${prefix}_${name}`. */
|
|
5423
5380
|
prefix?: string;
|
|
5424
5381
|
/** true = every imported tool needsApproval; record form is per name. */
|
|
5425
5382
|
approval?: boolean | Record<string, boolean>;
|
|
5426
|
-
/** Host-supplied risk labels for imported tools
|
|
5383
|
+
/** Host-supplied risk labels for imported tools. */
|
|
5427
5384
|
risk?: Record<string, ToolRisk>;
|
|
5428
5385
|
}
|
|
5429
5386
|
/**
|
|
@@ -5431,19 +5388,19 @@ interface McpConfig {
|
|
|
5431
5388
|
* first tools() call; tools/list is fetched with cursor pagination until
|
|
5432
5389
|
* exhaustion and cached per session; a listChanged notification
|
|
5433
5390
|
* invalidates the cache, affecting subsequently spawned agents only (a
|
|
5434
|
-
* spawn's toolset snapshot is immutable by construction
|
|
5391
|
+
* spawn's toolset snapshot is immutable by construction).
|
|
5435
5392
|
*/
|
|
5436
5393
|
declare function mcp(cfg: McpConfig): ToolSource;
|
|
5437
5394
|
//#endregion
|
|
5438
5395
|
//#region src/tools/isolation.d.ts
|
|
5439
|
-
/**
|
|
5396
|
+
/** Appendix A: the shared pin cap (park/unpark and retainWorktree). */
|
|
5440
5397
|
declare const DEFAULT_MAX_PINNED_WORKTREES = 4;
|
|
5441
5398
|
interface GitWorktreeProviderOptions {
|
|
5442
5399
|
/** Host repository root; default process.cwd(). */
|
|
5443
5400
|
repoRoot?: string;
|
|
5444
5401
|
/**
|
|
5445
5402
|
* Retain the tree of a FAILED agent for inspection when the engine
|
|
5446
|
-
* requests keep on dispose
|
|
5403
|
+
* requests keep on dispose. Default false.
|
|
5447
5404
|
*/
|
|
5448
5405
|
keepOnError?: boolean;
|
|
5449
5406
|
/** Pin cap shared by park/unpark and retainWorktree (default 4). */
|
|
@@ -5453,7 +5410,7 @@ interface GitWorktreeProviderOptions {
|
|
|
5453
5410
|
}
|
|
5454
5411
|
/**
|
|
5455
5412
|
* The shipped git worktree lifecycle. A non-git host is a typed
|
|
5456
|
-
* ConfigError at acquire
|
|
5413
|
+
* ConfigError at acquire.
|
|
5457
5414
|
*/
|
|
5458
5415
|
declare class GitWorktreeProvider implements IsolationProvider {
|
|
5459
5416
|
private readonly repoRoot;
|
|
@@ -5484,7 +5441,7 @@ declare class GitWorktreeProvider implements IsolationProvider {
|
|
|
5484
5441
|
* of wall-clock (invariant I3: structure comes from call-and-return only).
|
|
5485
5442
|
* The grammar is part of the hashVersion 2 profile.
|
|
5486
5443
|
*
|
|
5487
|
-
*
|
|
5444
|
+
* Full contract: https://docs.rulvar.com/guide/journal.
|
|
5488
5445
|
*
|
|
5489
5446
|
* Segment rules: a sequential body is ONE scope (sequential calls add no
|
|
5490
5447
|
* segment; they are distinguished by key and ordinal only). ctx.phase is
|
|
@@ -5505,7 +5462,7 @@ declare function workflowScope(parent: string, name: string, ordinal: number): s
|
|
|
5505
5462
|
declare function agentScope(parent: string, seq: number): string;
|
|
5506
5463
|
/** PlanRunner node scopes: `plan/<NodeId>` (NodeIds are engine-minted ULIDs). */
|
|
5507
5464
|
declare function planNodeScope(nodeId: string): string;
|
|
5508
|
-
/** A parsed scope-path segment
|
|
5465
|
+
/** A parsed scope-path segment. */
|
|
5509
5466
|
type ScopeSegment = {
|
|
5510
5467
|
kind: "parallel";
|
|
5511
5468
|
site: number;
|
|
@@ -5611,7 +5568,7 @@ declare class JsonlFileStore implements JournalStore {
|
|
|
5611
5568
|
/**
|
|
5612
5569
|
* File-backed TranscriptStore (M6-T02): blobs (transcripts, checkpoints,
|
|
5613
5570
|
* persisted CompiledWorkflow sources) as one file per ref under `dir`,
|
|
5614
|
-
* so compiled runs resume across processes
|
|
5571
|
+
* so compiled runs resume across processes. Refs follow
|
|
5615
5572
|
* the `<runId>/<name>` convention; each path segment is checked
|
|
5616
5573
|
* filesystem-safe and nested segments become directories.
|
|
5617
5574
|
*/
|
|
@@ -5643,8 +5600,8 @@ interface RunProfile {
|
|
|
5643
5600
|
maxDepth?: number;
|
|
5644
5601
|
}
|
|
5645
5602
|
/**
|
|
5646
|
-
* The shipped presets (
|
|
5647
|
-
*
|
|
5603
|
+
* The shipped presets (fast / standard / deep / ultra "and similar").
|
|
5604
|
+
* Data only; a review-time assertion checks the
|
|
5648
5605
|
* engine has zero behavioral branches keyed on these names.
|
|
5649
5606
|
*/
|
|
5650
5607
|
declare const RUN_PROFILES: Record<string, RunProfile>;
|
|
@@ -5656,15 +5613,15 @@ type StructuredOutputTier = "native" | "forced-tool" | "prompt";
|
|
|
5656
5613
|
/**
|
|
5657
5614
|
* Strict-schema compatibility as both first-class providers define it:
|
|
5658
5615
|
* every object node declares `additionalProperties: false` and lists every
|
|
5659
|
-
* property in `required
|
|
5616
|
+
* property in `required`. Boolean schemas and
|
|
5660
5617
|
* non-object shapes are trivially compatible.
|
|
5661
5618
|
*/
|
|
5662
5619
|
declare function isStrictCompatibleSchema(schema: JsonSchema | boolean): boolean;
|
|
5663
5620
|
/**
|
|
5664
|
-
* Tier selection
|
|
5621
|
+
* Tier selection: the model's declared ceiling
|
|
5665
5622
|
* bounds the tier; the native tier additionally requires a
|
|
5666
|
-
* strict-compatible canonical schema (
|
|
5667
|
-
*
|
|
5623
|
+
* strict-compatible canonical schema (relying on silent server-side
|
|
5624
|
+
* fallback is forbidden), degrading to forced-tool.
|
|
5668
5625
|
* Prefill is not a tier.
|
|
5669
5626
|
*/
|
|
5670
5627
|
declare function selectStructuredOutputTier(caps: ModelCaps, canonicalSchema: JsonSchema): StructuredOutputTier;
|
|
@@ -5692,7 +5649,7 @@ declare function providerOf(adapter: Pick<ProviderAdapter, "id" | "provider">):
|
|
|
5692
5649
|
declare function projectHistory(messages: Msg[], targetProvider: string): Msg[];
|
|
5693
5650
|
/**
|
|
5694
5651
|
* Lifts the adapter-shipped retention payload of one finished turn into
|
|
5695
|
-
* provider-raw parts (
|
|
5652
|
+
* provider-raw parts (the retention transport). Reads
|
|
5696
5653
|
* providerMetadata[<adapter id>].retainedParts and tags each block with
|
|
5697
5654
|
* the adapter's provider family. Returns [] when the adapter shipped
|
|
5698
5655
|
* nothing.
|
|
@@ -5700,17 +5657,17 @@ declare function projectHistory(messages: Msg[], targetProvider: string): Msg[];
|
|
|
5700
5657
|
declare function liftRetainedParts(providerMetadata: Record<string, unknown> | undefined, adapter: Pick<ProviderAdapter, "id" | "provider">): Part[];
|
|
5701
5658
|
//#endregion
|
|
5702
5659
|
//#region src/runtime/compaction.d.ts
|
|
5703
|
-
/**
|
|
5660
|
+
/** Compaction threshold default, 0.8 of contextWindow. */
|
|
5704
5661
|
declare const DEFAULT_COMPACTION_THRESHOLD = .8;
|
|
5705
5662
|
/** Deterministic marker opening every compaction summary message. */
|
|
5706
5663
|
declare const COMPACTION_SUMMARY_PREFIX = "Summary of the conversation so far:";
|
|
5707
|
-
/** Per-profile compaction config (
|
|
5664
|
+
/** Per-profile compaction config (AgentProfile). */
|
|
5708
5665
|
interface CompactionConfig {
|
|
5709
5666
|
/** Fraction of the loop model's contextWindow; default 0.8. */
|
|
5710
5667
|
threshold?: number;
|
|
5711
5668
|
}
|
|
5712
5669
|
/**
|
|
5713
|
-
* The threshold check (
|
|
5670
|
+
* The threshold check (M4-T03 committed semantics): the context
|
|
5714
5671
|
* estimate is the last loop turn's inputTokens + outputTokens; the Usage
|
|
5715
5672
|
* invariant makes inputTokens the full prompt, and the turn's output
|
|
5716
5673
|
* joins the next prompt.
|
|
@@ -5746,7 +5703,7 @@ declare function compactMessages(messages: Msg[], summaryText: string): Msg[];
|
|
|
5746
5703
|
* agent with no tools every tier rides (the M1 behavior, unchanged).
|
|
5747
5704
|
*/
|
|
5748
5705
|
declare function canRideLoopTurn(tier: StructuredOutputTier, toolsAvailable: boolean): boolean;
|
|
5749
|
-
/** The inputs of the extract-necessity rule
|
|
5706
|
+
/** The inputs of the extract-necessity rule. */
|
|
5750
5707
|
interface ExtractNecessityInput {
|
|
5751
5708
|
/** A schema is set on the call; without one extract never fires. */
|
|
5752
5709
|
schemaSet: boolean;
|
|
@@ -5754,7 +5711,7 @@ interface ExtractNecessityInput {
|
|
|
5754
5711
|
loopRef: ModelRef;
|
|
5755
5712
|
/** The extract-resolved model (same chain, role 'extract'). */
|
|
5756
5713
|
extractRef: ModelRef;
|
|
5757
|
-
/** The required tier for the schema on the LOOP model
|
|
5714
|
+
/** The required tier for the schema on the LOOP model. */
|
|
5758
5715
|
loopTier: StructuredOutputTier;
|
|
5759
5716
|
/** The agent's toolset is non-empty (escalate opt-in counts). */
|
|
5760
5717
|
toolsAvailable: boolean;
|
|
@@ -5767,7 +5724,7 @@ interface ExtractNecessityInput {
|
|
|
5767
5724
|
* to a different model OR the loop model's caps cannot serve the required
|
|
5768
5725
|
* tier OR finalize is routed, in which case the schema never rides a loop
|
|
5769
5726
|
* or synthesis turn). Otherwise the schema rides the last loop turn with
|
|
5770
|
-
* no extra call (
|
|
5727
|
+
* no extra call (as amended in M4-T01).
|
|
5771
5728
|
*/
|
|
5772
5729
|
declare function needsSeparateExtract(input: ExtractNecessityInput): boolean;
|
|
5773
5730
|
/**
|
|
@@ -5775,14 +5732,14 @@ declare function needsSeparateExtract(input: ExtractNecessityInput): boolean;
|
|
|
5775
5732
|
* map. This is the finalize TRIGGER: firing is decided by the presence of
|
|
5776
5733
|
* a routing entry at any layer; the model it fires ON still resolves
|
|
5777
5734
|
* through the full chain (a higher layer's all-roles `model` may override
|
|
5778
|
-
* the routed choice
|
|
5735
|
+
* the routed choice).
|
|
5779
5736
|
*/
|
|
5780
5737
|
declare function roleConfiguredInRouting(role: InvocationRole, layers: Array<ResolutionLayer | undefined>): boolean;
|
|
5781
5738
|
/**
|
|
5782
5739
|
* The finalize firing rule: only if configured in routing, and only after
|
|
5783
5740
|
* tools stop, which presupposes a non-empty toolset. A no-tools agent's
|
|
5784
|
-
* single loop turn is already its synthesis (
|
|
5785
|
-
*
|
|
5741
|
+
* single loop turn is already its synthesis (as amended in M4-T01). The
|
|
5742
|
+
* caller additionally gates on the loop having
|
|
5786
5743
|
* ended without an abort: a limit/error/cancelled/escalated loop never
|
|
5787
5744
|
* reaches synthesis.
|
|
5788
5745
|
*/
|
|
@@ -5792,7 +5749,7 @@ declare function finalizeFires(options: {
|
|
|
5792
5749
|
}): boolean;
|
|
5793
5750
|
/**
|
|
5794
5751
|
* The summarize trigger: the compaction threshold on the context window
|
|
5795
|
-
* (
|
|
5752
|
+
* (default 0.8). Pure predicate; the compaction
|
|
5796
5753
|
* pipeline that acts on it is M4-T03.
|
|
5797
5754
|
*/
|
|
5798
5755
|
declare function atCompactionThreshold(usedTokens: number, contextWindow: number, threshold: number): boolean;
|
|
@@ -5804,7 +5761,7 @@ declare class ModelRetry extends Error {
|
|
|
5804
5761
|
data?: Json;
|
|
5805
5762
|
});
|
|
5806
5763
|
}
|
|
5807
|
-
/** Bounded semantic retries per tool call chain
|
|
5764
|
+
/** Bounded semantic retries per tool call chain. */
|
|
5808
5765
|
declare const DEFAULT_MODEL_RETRY_ATTEMPTS = 2;
|
|
5809
5766
|
//#endregion
|
|
5810
5767
|
//#region src/runtime/structured-output.d.ts
|
|
@@ -5838,18 +5795,18 @@ declare function extractCandidate(turn: CollectedTurn, tier: StructuredOutputTie
|
|
|
5838
5795
|
declare function formatRePrompt(issues: Issue$1[], attempt: number, maxAttempts: number): Msg;
|
|
5839
5796
|
//#endregion
|
|
5840
5797
|
//#region src/orchestrator/spawn-tools.d.ts
|
|
5841
|
-
/**
|
|
5798
|
+
/** The spawn_agent parameter schema (normative). */
|
|
5842
5799
|
declare const SPAWN_AGENT_SCHEMA: SchemaSpec;
|
|
5843
|
-
/**
|
|
5800
|
+
/** parallel_agents wraps the spawn_agent params. */
|
|
5844
5801
|
declare const PARALLEL_AGENTS_SCHEMA: SchemaSpec;
|
|
5845
|
-
/**
|
|
5802
|
+
/** await_any and await_all share one parameter shape. */
|
|
5846
5803
|
declare const AWAIT_SCHEMA: SchemaSpec;
|
|
5847
|
-
/**
|
|
5804
|
+
/** The cancel_agent parameter schema. */
|
|
5848
5805
|
declare const CANCEL_AGENT_SCHEMA: SchemaSpec;
|
|
5849
|
-
/**
|
|
5806
|
+
/** finish; result validates against the declared output schema. */
|
|
5850
5807
|
declare const FINISH_SCHEMA: SchemaSpec;
|
|
5851
5808
|
declare const FINISH_TOOL_NAME = "finish";
|
|
5852
|
-
/** The spawn parameters as validated JSON (
|
|
5809
|
+
/** The spawn parameters as validated JSON (a TaskSpec subset). */
|
|
5853
5810
|
interface SpawnAgentParams {
|
|
5854
5811
|
agentType: string;
|
|
5855
5812
|
prompt: string;
|
|
@@ -5870,15 +5827,14 @@ interface SpawnAgentParams {
|
|
|
5870
5827
|
/**
|
|
5871
5828
|
* Builds the mode (c) toolset over the per-call runtime. profileCardText
|
|
5872
5829
|
* rides the spawn tools' descriptions so both modes speak one agent
|
|
5873
|
-
* vocabulary (
|
|
5830
|
+
* vocabulary (M6-T04).
|
|
5874
5831
|
*/
|
|
5875
5832
|
declare function buildOrchestratorTools(runtime: OrchestratorRuntime, profileCardText: string): ToolDef[];
|
|
5876
5833
|
//#endregion
|
|
5877
5834
|
//#region src/engine/events.d.ts
|
|
5878
5835
|
/**
|
|
5879
5836
|
* Spans form a tree per run; spanId values are engine-minted opaque
|
|
5880
|
-
* strings, unique per run, pure telemetry, never identity
|
|
5881
|
-
* section "Span hierarchy").
|
|
5837
|
+
* strings, unique per run, pure telemetry, never identity.
|
|
5882
5838
|
*/
|
|
5883
5839
|
declare class SpanRegistry {
|
|
5884
5840
|
private readonly parents;
|
|
@@ -5905,8 +5861,7 @@ declare class EventBus {
|
|
|
5905
5861
|
spans: SpanRegistry;
|
|
5906
5862
|
now?: () => number;
|
|
5907
5863
|
/**
|
|
5908
|
-
* Default true (M8-T04
|
|
5909
|
-
* data"): key-shaped strings in every emitted body are masked.
|
|
5864
|
+
* Default true (M8-T04): key-shaped strings in every emitted body are masked.
|
|
5910
5865
|
* Telemetry only, never the journal: events are excluded from
|
|
5911
5866
|
* identity by construction, so masking cannot perturb replay.
|
|
5912
5867
|
*/
|
|
@@ -5922,7 +5877,7 @@ declare class EventBus {
|
|
|
5922
5877
|
}
|
|
5923
5878
|
//#endregion
|
|
5924
5879
|
//#region src/runner/sandbox-bridge.d.ts
|
|
5925
|
-
/** Methods a sandbox script may proxy to the host ctx
|
|
5880
|
+
/** Methods a sandbox script may proxy to the host ctx. */
|
|
5926
5881
|
type SandboxMethod = "agent" | "step" | "workflow" | "awaitExternal" | "parallel" | "pipeline" | "phase" | "budget.spent" | "budget.remaining";
|
|
5927
5882
|
/** Worker-to-host protocol messages (JSON only). */
|
|
5928
5883
|
type SandboxWorkerToHost = {
|