car-runtime 0.31.0 → 0.32.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +763 -9
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -184,18 +184,23 @@ export class CarRuntime {
|
|
|
184
184
|
|
|
185
185
|
// --- State ---
|
|
186
186
|
|
|
187
|
-
/** Set a state key (value must be a JSON string).
|
|
188
|
-
|
|
187
|
+
/** Set a state key (value must be a JSON string). `tenant` (optional)
|
|
188
|
+
* scopes the write to one tenant's keyspace (E3). */
|
|
189
|
+
stateSet(key: string, valueJson: string, tenant?: string): void;
|
|
189
190
|
|
|
190
|
-
/** Get a state key. Returns the value as a JSON string, or `"null"`.
|
|
191
|
-
|
|
191
|
+
/** Get a state key. Returns the value as a JSON string, or `"null"`.
|
|
192
|
+
* `tenant` (optional) scopes the read to one tenant's keyspace (E3). */
|
|
193
|
+
stateGet(key: string, tenant?: string): string;
|
|
192
194
|
|
|
193
|
-
|
|
195
|
+
/** `tenant` (optional) scopes the check to one tenant's keyspace (E3). */
|
|
196
|
+
stateExists(key: string, tenant?: string): boolean;
|
|
194
197
|
|
|
195
|
-
/** Snapshot of all state as a JSON string.
|
|
196
|
-
|
|
198
|
+
/** Snapshot of all state as a JSON string. `tenant` (optional) scopes
|
|
199
|
+
* the snapshot to one tenant's keyspace (E3). */
|
|
200
|
+
stateSnapshot(tenant?: string): string;
|
|
197
201
|
|
|
198
|
-
|
|
202
|
+
/** `tenant` (optional) scopes the key list to one tenant's keyspace (E3). */
|
|
203
|
+
stateKeys(tenant?: string): string[];
|
|
199
204
|
|
|
200
205
|
// --- Memory / Facts (graph-backed) ---
|
|
201
206
|
|
|
@@ -243,8 +248,129 @@ export class CarRuntime {
|
|
|
243
248
|
/** Run memory consolidation ("dream") pass. Returns a JSON report. */
|
|
244
249
|
consolidate(): string;
|
|
245
250
|
|
|
251
|
+
/**
|
|
252
|
+
* Get the live engine's utility-aware retrieval blend (U-Mem).
|
|
253
|
+
* Returns JSON `{ utility_weight, utility_exploration }`.
|
|
254
|
+
*/
|
|
255
|
+
utilityRetrieval(): string;
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Set the live engine's utility-aware retrieval blend (U-Mem).
|
|
259
|
+
* `utilityWeight` 0 = pure relevance (ordering unchanged);
|
|
260
|
+
* `utilityExploration` scales the UCB uncertainty term (only consulted
|
|
261
|
+
* when weight > 0). Omitting `utilityExploration` keeps the engine's
|
|
262
|
+
* current value (read-modify-write), it does NOT reset it to 0. Takes
|
|
263
|
+
* effect on the next context build. Returns the applied JSON
|
|
264
|
+
* `{ utility_weight, utility_exploration }`.
|
|
265
|
+
*/
|
|
266
|
+
setUtilityRetrieval(utilityWeight: number, utilityExploration?: number | null): Promise<string>;
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Run the U-Mem cost-aware knowledge cascade (Slice 5 live evolve loop) on
|
|
270
|
+
* the daemon. `requestJson` is `{ current_confidence, policy, observed,
|
|
271
|
+
* claim? }`; the daemon runs each tier's mechanic (self_reflect → reflect(),
|
|
272
|
+
* human_expert → ApprovalLedger HITL) + the budget/target walk, escalating
|
|
273
|
+
* cheapest-first on the caller-supplied observed confidence. Returns JSON
|
|
274
|
+
* `{ run, pending_approval? }`.
|
|
275
|
+
*/
|
|
276
|
+
cascadeRun(requestJson: string): Promise<string>;
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Plan an evolution cycle over the daemon's **live** engine signals — the
|
|
280
|
+
* self-evolution governor's host surface (arXiv 2507.21046). `requestJson` is
|
|
281
|
+
* `{ policy?: { pressure_threshold?, budget? } }`; the daemon folds the session
|
|
282
|
+
* memgine's real per-component pressure/evidence and runs the governor. Returns
|
|
283
|
+
* the `EvolutionPlan` JSON `{ decisions, spent, evolve_now }` — the live
|
|
284
|
+
* counterpart to the stateless `planEvolution` helper. Plans only; the caller
|
|
285
|
+
* dispatches the chosen components.
|
|
286
|
+
*/
|
|
287
|
+
planEvolutionLive(requestJson: string): Promise<string>;
|
|
288
|
+
/** `sync.status` — roster, journal frontier, stable frontier, state hash (B6). */
|
|
289
|
+
syncStatus(requestJson: string): Promise<string>;
|
|
290
|
+
/** `sync.append` — record an op on any surface: `{ surface, payload, scope? }` (B6). */
|
|
291
|
+
syncAppend(requestJson: string): Promise<string>;
|
|
292
|
+
/** `sync.record_turn` — route a conversation turn through the oplog so `syncResume` is real (B6). */
|
|
293
|
+
syncRecordTurn(requestJson: string): Promise<string>;
|
|
294
|
+
/** `sync.record_intent` — write the leased-execution intent ledger; feeds the fence oracle (B6). */
|
|
295
|
+
syncRecordIntent(requestJson: string): Promise<string>;
|
|
296
|
+
/** `sync.pump` — one push/pull/ack reconciliation round against the relay (B6). */
|
|
297
|
+
syncPump(requestJson: string): Promise<string>;
|
|
298
|
+
/** `sync.checkpoint` — publish a device-side checkpoint at the stable frontier (B6). */
|
|
299
|
+
syncCheckpoint(requestJson: string): Promise<string>;
|
|
300
|
+
/** `sync.rebase` — cold bootstrap / straggler re-entry onto the latest checkpoint (B6). */
|
|
301
|
+
syncRebase(requestJson: string): Promise<string>;
|
|
302
|
+
/** `sync.transcript` — the ordered role-threaded `Turn[]` projection (B6). */
|
|
303
|
+
syncTranscript(requestJson: string): Promise<string>;
|
|
304
|
+
/** `sync.resume` — the repaired, provider-valid `Message[]` for replay (B6). */
|
|
305
|
+
syncResume(requestJson: string): Promise<string>;
|
|
306
|
+
/** `sync.fence_check` — the dispatch fence at the point of effect; only `may_dispatch` authorizes (B6). */
|
|
307
|
+
syncFenceCheck(requestJson: string): Promise<string>;
|
|
308
|
+
/** `lease.acquire` — CAS-acquire the per-agent execution lease; epoch bumps on grant (B6). */
|
|
309
|
+
leaseAcquire(requestJson: string): Promise<string>;
|
|
310
|
+
/** `lease.renew` — heartbeat the lease (no epoch bump), iff still the holder (B6). */
|
|
311
|
+
leaseRenew(requestJson: string): Promise<string>;
|
|
312
|
+
/** `lease.release` — clean handoff (next acquire skips the TTL wait) (B6). */
|
|
313
|
+
leaseRelease(requestJson: string): Promise<string>;
|
|
314
|
+
/** `lease.status` — the linearizable read of the current lease, or `null` (B6). */
|
|
315
|
+
leaseStatus(requestJson: string): Promise<string>;
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Run one evolution cycle over the daemon's **live** signals — the
|
|
319
|
+
* self-evolution governor's real executor (arXiv 2507.21046). `requestJson`
|
|
320
|
+
* is `{ policy?, dry_run?, harness_baseline_metrics?,
|
|
321
|
+
* harness_candidate_metrics? }`; the daemon plans over all five live
|
|
322
|
+
* components (Memory/Skills/Context from the engine, Harness from the event
|
|
323
|
+
* log, Tools from connector health) and dispatches each `EvolveNow`
|
|
324
|
+
* component: Memory → consolidate (sized by decide_maintenance), Skills →
|
|
325
|
+
* evolve_skills over event-log failure traces, Harness → the HITL-gated
|
|
326
|
+
* harness_evolution loop (pending approvals resolve via
|
|
327
|
+
* `permission.approve`/`reject` by fingerprint); Context/Tools record
|
|
328
|
+
* `not_executable`. Returns the cycle record JSON
|
|
329
|
+
* `{ plan, steps, evolved, pending_approvals? }`.
|
|
330
|
+
*/
|
|
331
|
+
runEvolutionCycleLive(requestJson: string): Promise<string>;
|
|
332
|
+
|
|
246
333
|
// --- Skills ---
|
|
247
334
|
|
|
335
|
+
/**
|
|
336
|
+
* Gate a skill's deployment capability against its provenance on the daemon,
|
|
337
|
+
* folding the named skill's **live** track record into the decision
|
|
338
|
+
* (arXiv 2602.12430 "Agent Skills"). `requestJson` is `{ skill_name,
|
|
339
|
+
* provenance, requested_tier }` where `requested_tier` is
|
|
340
|
+
* `"read_only" | "sandbox_edit" | "full_access"`. The daemon overrides the
|
|
341
|
+
* provenance's lifecycle counts with the skill's real success/fail record, so
|
|
342
|
+
* a skill failing in the field is denied despite an official signature.
|
|
343
|
+
* Returns the `SkillDeploymentDecision` JSON. Live counterpart to the
|
|
344
|
+
* stateless `gateSkillDeployment` helper.
|
|
345
|
+
*/
|
|
346
|
+
gateSkillDeploymentLive(requestJson: string): Promise<string>;
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Enforce a skill's deployment at load time against the session's durable
|
|
350
|
+
* approval ledger (arXiv 2602.12430 "Agent Skills" Slice 4 — the HITL bridge).
|
|
351
|
+
* `requestJson` is `{ skill_name, provenance, requested_tier }`; the daemon
|
|
352
|
+
* gates the skill (folding its live track record), then resolves the verdict
|
|
353
|
+
* against standing operator decisions: `Allow`/`Downgrade` deploy
|
|
354
|
+
* autonomously, a `Deny` is overridden/blocked/pending. Returns
|
|
355
|
+
* `{ decision, enforcement, pending_approval? }`; a pending approval is
|
|
356
|
+
* resolved via `permission.approve`/`permission.reject` by the returned
|
|
357
|
+
* `fingerprint`.
|
|
358
|
+
*/
|
|
359
|
+
enforceSkillDeploymentLive(requestJson: string): Promise<string>;
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Ingest a skill through the deployment gate on the daemon (arXiv 2602.12430
|
|
363
|
+
* "Agent Skills" — the loader integration). `requestJson` carries the skill
|
|
364
|
+
* fields (`name`, `code`, `platform`, `persona?`, `url_pattern?`,
|
|
365
|
+
* `description?`, `supersedes?`, `task_keywords?`) plus `provenance?` and
|
|
366
|
+
* `requested_tier`. The daemon gates + enforces against the session ledger and
|
|
367
|
+
* **only ingests when deployment is permitted**, stamping the granted ceiling
|
|
368
|
+
* onto the skill. Returns `{ ingested, node?, decision, enforcement,
|
|
369
|
+
* pending_approval? }`; a pending deny is resolved via
|
|
370
|
+
* `permission.approve`/`permission.reject` by the returned `fingerprint`.
|
|
371
|
+
*/
|
|
372
|
+
ingestSkillGoverned(requestJson: string): Promise<string>;
|
|
373
|
+
|
|
248
374
|
/**
|
|
249
375
|
* Save a learned skill with trigger context. Returns the node
|
|
250
376
|
* index.
|
|
@@ -754,6 +880,15 @@ export class CarRuntime {
|
|
|
754
880
|
* `limit` caps results (clamped to [1, 50]; null = default 5).
|
|
755
881
|
*/
|
|
756
882
|
discoveryResolve(need: string, limit?: number | undefined | null): Promise<string>;
|
|
883
|
+
/**
|
|
884
|
+
* Record a discovery-routed run's outcome (`"success"` | `"failure"`) into
|
|
885
|
+
* the routing learning store, keyed by the service's `agentdns://`
|
|
886
|
+
* identifier — for EVERY provider kind (connector, registry, external, a2a,
|
|
887
|
+
* declarative). This is the feedback loop `discoveryResolve`'s success
|
|
888
|
+
* prior learns from. Returns `{ identifier, outcome, successes, failures }`
|
|
889
|
+
* JSON.
|
|
890
|
+
*/
|
|
891
|
+
discoveryReport(identifier: string, outcome: "success" | "failure" | string): Promise<string>;
|
|
757
892
|
/**
|
|
758
893
|
* Compose a decompose/retrieve/plan route over all discoverable services.
|
|
759
894
|
* Returns `{ plan, decomposition, candidates, metadata }` JSON. Planning only;
|
|
@@ -820,6 +955,58 @@ export class CarRuntime {
|
|
|
820
955
|
/** Count of events in this runtime's execution log. */
|
|
821
956
|
eventCount(): Promise<number>;
|
|
822
957
|
|
|
958
|
+
/** Drain buffered chunks + current status for a detached
|
|
959
|
+
* (streaming/long-running) tool invocation (C2). `handle` is the
|
|
960
|
+
* `tool_handle` a detached ToolCall action (`invocation_mode: "streaming"
|
|
961
|
+
* | "long_running"`) returned as its output. Returns the ToolPollResult
|
|
962
|
+
* JSON string `{handle, tool, action_id, status, chunks, result?,
|
|
963
|
+
* error?}`, or `null` for an unknown / already fully-consumed handle. */
|
|
964
|
+
toolPoll(handle: string): Promise<string | null>;
|
|
965
|
+
|
|
966
|
+
/** Request cooperative cancellation of a detached (streaming/long-running)
|
|
967
|
+
* tool invocation (C2). Resolves `true` when the handle was known (the
|
|
968
|
+
* invocation is sealed `cancelled` unless already terminal), `false` for
|
|
969
|
+
* an unknown handle. */
|
|
970
|
+
toolCancel(handle: string): Promise<boolean>;
|
|
971
|
+
|
|
972
|
+
/** Structured audit query over the event log (G2). `queryJson` is an
|
|
973
|
+
* EventQuery object (kinds/actionId/proposalId/since/until/dataMatches/limit);
|
|
974
|
+
* returns `{count, events}` as a JSON string, most-recent-first. */
|
|
975
|
+
eventQuery(queryJson: string): Promise<string>;
|
|
976
|
+
|
|
977
|
+
/** Get/set the event-log retention policy (G2). Pass a
|
|
978
|
+
* `{maxEvents, maxAgeSecs}` JSON string to install it, or omit to read the
|
|
979
|
+
* current policy. Returns a JSON string. */
|
|
980
|
+
eventRetention(policyJson?: string): Promise<string>;
|
|
981
|
+
|
|
982
|
+
/** Per-agent token/cost report (G3), folded from metered inference events.
|
|
983
|
+
* Returns a JSON array of `{agent, calls, tokensIn, tokensOut, costUsd}`. */
|
|
984
|
+
eventCostByAgent(): Promise<string>;
|
|
985
|
+
|
|
986
|
+
/** Turn on tamper-evident hash chaining for the session event log (A9).
|
|
987
|
+
* Every event appended from now on links to its predecessor by a content
|
|
988
|
+
* hash. Idempotent. */
|
|
989
|
+
enableEventLogHashChaining(): Promise<void>;
|
|
990
|
+
|
|
991
|
+
/** Verify the session event log's tamper-evidence chain (A9). Returns
|
|
992
|
+
* `{"verified": n}` (chained events verified) or `{"tampered_at": i}`
|
|
993
|
+
* (index of the first interior edit/deletion/reorder) as a JSON string.
|
|
994
|
+
* Head/tail truncation is not detectable (no anchored head hash). */
|
|
995
|
+
verifyEventLogChain(): Promise<string>;
|
|
996
|
+
|
|
997
|
+
/** Live operational metrics rollup (G1) — success/error rate, cost, latency,
|
|
998
|
+
* approvals, gate rejections, per-agent cost. `cost_usd` is the fold over the
|
|
999
|
+
* retained window; `cumulative_cost_usd` is the monotonic lifetime spend
|
|
1000
|
+
* (survives retention trims). Returns JSON. */
|
|
1001
|
+
metricsSummary(): Promise<string>;
|
|
1002
|
+
|
|
1003
|
+
/** Evaluate live metrics against thresholds (G1). `thresholdsJson` is an
|
|
1004
|
+
* AlertThresholds object (omit for defaults); returns `{summary, alerts}` as
|
|
1005
|
+
* JSON. The `max_cost_usd` budget is checked against the monotonic
|
|
1006
|
+
* `cumulative_cost_usd` counter, so a retention trim never un-fires the
|
|
1007
|
+
* `cost_overage` alert. */
|
|
1008
|
+
metricsAlerts(thresholdsJson?: string): Promise<string>;
|
|
1009
|
+
|
|
823
1010
|
/** Execution log counts and approximate retained native bytes. Returns JSON. */
|
|
824
1011
|
eventLogStats(): Promise<string>;
|
|
825
1012
|
|
|
@@ -1586,8 +1773,34 @@ export function removeEnrollment(rt: CarRuntime, label: string): string;
|
|
|
1586
1773
|
* Run a multi-stage workflow definition. Reuses the agent runner
|
|
1587
1774
|
* registered via `registerAgentRunner` for any agent stages in the
|
|
1588
1775
|
* workflow.
|
|
1776
|
+
*
|
|
1777
|
+
* `initialStateJson`, when given, is a JSON object seeded into workflow state
|
|
1778
|
+
* before the run starts — the inter-workflow chaining hook (hand a prior
|
|
1779
|
+
* result's `final_state` to the next workflow). Omitted = prior behavior.
|
|
1780
|
+
* The reserved `goal` drift anchor cannot be injected this way.
|
|
1589
1781
|
*/
|
|
1590
|
-
export function runWorkflow(
|
|
1782
|
+
export function runWorkflow(
|
|
1783
|
+
workflowJson: string,
|
|
1784
|
+
initialStateJson?: string | undefined | null,
|
|
1785
|
+
): Promise<string>;
|
|
1786
|
+
|
|
1787
|
+
/**
|
|
1788
|
+
* Run a JSON array of workflow definitions sequentially as a chain: each next
|
|
1789
|
+
* workflow's initial state is the previous result's `final_state`, merged
|
|
1790
|
+
* over `initialStateJson` (the previous result wins). Every workflow is
|
|
1791
|
+
* statically pre-validated before any executes — structural garbage rejects
|
|
1792
|
+
* the chain up front. Stops at the first non-`completed` result. Returns
|
|
1793
|
+
* `{ results: [WorkflowResult, ...], status, paused_at_index?, error?,
|
|
1794
|
+
* failed_at_index? }` JSON; a paused intermediate carries its `paused`
|
|
1795
|
+
* checkpoint inside its result (checkpoint persistence stays caller-owned,
|
|
1796
|
+
* like `runWorkflow`), and a mid-chain runtime engine error preserves the
|
|
1797
|
+
* results so far (with top-level `error` + `failed_at_index`) instead of
|
|
1798
|
+
* throwing. Reuses the agent runner registered via `registerAgentRunner`.
|
|
1799
|
+
*/
|
|
1800
|
+
export function workflowChain(
|
|
1801
|
+
workflowsJson: string,
|
|
1802
|
+
initialStateJson?: string | undefined | null,
|
|
1803
|
+
): Promise<string>;
|
|
1591
1804
|
|
|
1592
1805
|
/**
|
|
1593
1806
|
* Resume a workflow that paused at a human-in-the-loop approval gate.
|
|
@@ -1598,6 +1811,23 @@ export function runWorkflow(workflowJson: string): Promise<string>;
|
|
|
1598
1811
|
*/
|
|
1599
1812
|
export function resumeWorkflow(pausedJson: string, inputJson: string): Promise<string>;
|
|
1600
1813
|
|
|
1814
|
+
/** List resumable workflow checkpoints under `runsDir` (H1). Returns a JSON
|
|
1815
|
+
* array of `{run_id, paused_stage_id, prompt, created_at}` — rediscover
|
|
1816
|
+
* resumable runs after a restart. */
|
|
1817
|
+
export function listPausedWorkflows(runsDir: string): string;
|
|
1818
|
+
|
|
1819
|
+
/** NLP (F4): identify the dominant language of `text`. Returns
|
|
1820
|
+
* `{language, backend}` JSON (Apple NaturalLanguage on macOS, pure-Rust
|
|
1821
|
+
* fallback elsewhere). */
|
|
1822
|
+
export function nlpIdentifyLanguage(text: string): string;
|
|
1823
|
+
|
|
1824
|
+
/** NLP (F4): word-tokenize `text`. Returns `{tokens, backend}` JSON. */
|
|
1825
|
+
export function nlpTokenize(text: string): string;
|
|
1826
|
+
|
|
1827
|
+
/** NLP (F4): extract named entities from `text`. Returns `{entities, backend}`
|
|
1828
|
+
* JSON; entities are `{text, kind, byte_range}`. */
|
|
1829
|
+
export function nlpExtractEntities(text: string): string;
|
|
1830
|
+
|
|
1601
1831
|
/** Static analysis on a workflow definition. Returns verification report JSON. */
|
|
1602
1832
|
export function verifyWorkflow(workflowJson: string): string;
|
|
1603
1833
|
|
|
@@ -1840,6 +2070,468 @@ export function transactionCheck(
|
|
|
1840
2070
|
stateJson?: string | null,
|
|
1841
2071
|
): string;
|
|
1842
2072
|
|
|
2073
|
+
/**
|
|
2074
|
+
* Like `transactionCheck`, but unions each action's write set with the keys a
|
|
2075
|
+
* verified Code World Model predicts it writes (Code World Models Slice 3b —
|
|
2076
|
+
* pre-flight conflict detection; `docs/proposals/code-world-models.md`).
|
|
2077
|
+
* `transactionCheck` reasons over *declared* effects; a tool that writes a key
|
|
2078
|
+
* it didn't declare produces a hazard that only surfaces at runtime. Once a
|
|
2079
|
+
* model is verified you can predict those writes and fold them in here.
|
|
2080
|
+
*
|
|
2081
|
+
* `predictionsJson` is a JSON object mapping `actionId` → array of predicted
|
|
2082
|
+
* write keys (the caller produced them by running the generated model). Returns
|
|
2083
|
+
* the same `TransactionReport` JSON as `transactionCheck` `{ consistent,
|
|
2084
|
+
* conflicts }`.
|
|
2085
|
+
*/
|
|
2086
|
+
export function transactionCheckWithPredictions(
|
|
2087
|
+
proposalJson: string,
|
|
2088
|
+
versionsJson: string | null | undefined,
|
|
2089
|
+
stateJson: string | null | undefined,
|
|
2090
|
+
predictionsJson: string,
|
|
2091
|
+
): string;
|
|
2092
|
+
|
|
2093
|
+
/**
|
|
2094
|
+
* Score a Code World Model against recorded trajectories (Slice 1 of
|
|
2095
|
+
* `docs/proposals/code-world-models.md`, applying arXiv 2510.04542 "Code
|
|
2096
|
+
* World Models for General Game Playing"). The paper validates an
|
|
2097
|
+
* LLM-generated world model by unit-testing its `apply(state, action)`
|
|
2098
|
+
* against recorded transitions; this is that transition-accuracy metric.
|
|
2099
|
+
*
|
|
2100
|
+
* `transitionsJson` is a JSON array of `{ stateBefore, action, stateAfter }`
|
|
2101
|
+
* records (e.g. from `cwmTransitionsFromEvents`). `predictionsJson` is an
|
|
2102
|
+
* index-aligned JSON array; each element is the model's predicted post-state
|
|
2103
|
+
* object, or `{ "error": "<stack trace>" }` when running the generated code
|
|
2104
|
+
* threw. Code execution is the caller's responsibility (e.g. a sandbox), so
|
|
2105
|
+
* this stays a pure scoring function.
|
|
2106
|
+
*
|
|
2107
|
+
* Returns the `ScoreReport` JSON `{ total, correct, errored, accuracy,
|
|
2108
|
+
* failures: [{ index, action, expected, predicted?, error? }] }`. A
|
|
2109
|
+
* length mismatch between transitions and predictions is an error, not a
|
|
2110
|
+
* silent truncation.
|
|
2111
|
+
*/
|
|
2112
|
+
export function cwmScore(
|
|
2113
|
+
transitionsJson: string,
|
|
2114
|
+
predictionsJson: string,
|
|
2115
|
+
): string;
|
|
2116
|
+
|
|
2117
|
+
/**
|
|
2118
|
+
* Gate a skill's deployment capability against its provenance
|
|
2119
|
+
* (`docs/proposals/skill-trust-governance.md`, applying arXiv 2602.12430 "Agent
|
|
2120
|
+
* Skills"). Maps a skill's provenance to a trust tier and caps the
|
|
2121
|
+
* `PermissionTier` capability that tier permits — the supply-chain governance
|
|
2122
|
+
* lens motivated by the paper's finding that 26.1% of community skills are
|
|
2123
|
+
* vulnerable.
|
|
2124
|
+
*
|
|
2125
|
+
* `provenanceJson` is a `SkillProvenance` `{ signed?, signer_trusted?, scanned?,
|
|
2126
|
+
* vulnerabilities?, source?: "official" | "first_party" | "community" |
|
|
2127
|
+
* "unknown", success_count?, fail_count? }`; `requestedTier` is `"read_only" |
|
|
2128
|
+
* "sandbox_edit" | "full_access"`. Returns the `SkillDeploymentDecision` JSON
|
|
2129
|
+
* `{ trust: "untrusted" | "community" | "verified" | "official", ceiling,
|
|
2130
|
+
* granted, outcome: "allow" | "downgrade" | "deny", reason }`. A vulnerable,
|
|
2131
|
+
* unsigned, or degraded skill is denied regardless of the requested tier.
|
|
2132
|
+
*/
|
|
2133
|
+
export function gateSkillDeployment(
|
|
2134
|
+
provenanceJson: string,
|
|
2135
|
+
requestedTier: string,
|
|
2136
|
+
): string;
|
|
2137
|
+
|
|
2138
|
+
/**
|
|
2139
|
+
* Static information-flow + tool-sequence safety check over a plan
|
|
2140
|
+
* (`docs/proposals/verifiable-tool-safety.md`, applying arXiv 2601.08012
|
|
2141
|
+
* "Towards Verifiably Safe Tool Use for LLM Agents"). Catches hazards no
|
|
2142
|
+
* per-action check covers: sensitive data reaching an exfiltration/untrusted
|
|
2143
|
+
* sink, and forbidden tool orderings — statically, before execution.
|
|
2144
|
+
*
|
|
2145
|
+
* `labelsJson` is a JSON object mapping `toolName` → capability-enhanced-MCP
|
|
2146
|
+
* labels `{ capability?: string, confidentiality?: "public" | "internal" |
|
|
2147
|
+
* "secret", trust?: "trusted" | "untrusted", sink?: boolean, declassifier?:
|
|
2148
|
+
* boolean }` (all fields default to public/trusted/non-sink). `policyJson`
|
|
2149
|
+
* (optional) is `{ minConfidential?: "public" | "internal" | "secret",
|
|
2150
|
+
* forbiddenSequences?: [string, string][] }` — the minimum confidentiality
|
|
2151
|
+
* guarded at sinks and forbidden ordered `(before, after)` capability pairs.
|
|
2152
|
+
*
|
|
2153
|
+
* Returns the `FlowReport` JSON `{ safe: boolean, violations: [{ kind:
|
|
2154
|
+
* "sensitive_to_sink" | "forbidden_sequence", actions: string[], key?: string,
|
|
2155
|
+
* explanation: string, mitigation: string }] }`. Tools absent from `labelsJson`
|
|
2156
|
+
* are unconstrained, so an empty map is trivially safe. Reasons over declared
|
|
2157
|
+
* `state_dependencies`/`expected_effects` (the edges the executor sequences on);
|
|
2158
|
+
* flows through undeclared channels are out of scope.
|
|
2159
|
+
*/
|
|
2160
|
+
export function checkInformationFlow(
|
|
2161
|
+
proposalJson: string,
|
|
2162
|
+
labelsJson: string,
|
|
2163
|
+
policyJson?: string | null,
|
|
2164
|
+
): string;
|
|
2165
|
+
|
|
2166
|
+
/**
|
|
2167
|
+
* Map an information-flow `FlowReport` (from `checkInformationFlow`) to an
|
|
2168
|
+
* enforcement decision (Slice 2 of `docs/proposals/verifiable-tool-safety.md`).
|
|
2169
|
+
* Turns the advisory check into a gate: clear data exfiltration is blocked,
|
|
2170
|
+
* ambiguous forbidden orderings are escalated to a human, the rest proceed.
|
|
2171
|
+
*
|
|
2172
|
+
* `gatePolicyJson` (optional) is `{ onSensitiveToSink?: "allow" |
|
|
2173
|
+
* "require_approval" | "block", onForbiddenSequence?: "allow" |
|
|
2174
|
+
* "require_approval" | "block" }` (defaults: block exfiltration, escalate
|
|
2175
|
+
* orderings). Returns the `FlowGateDecision` JSON `{ action: "allow" |
|
|
2176
|
+
* "require_approval" | "block", blocked: FlowViolation[], needs_approval:
|
|
2177
|
+
* FlowViolation[], reason: string }`, where `action` is the most severe across
|
|
2178
|
+
* violations. Wiring `require_approval` to the permission-tier HITL ledger is
|
|
2179
|
+
* the engine step.
|
|
2180
|
+
*/
|
|
2181
|
+
export function gateInformationFlow(
|
|
2182
|
+
reportJson: string,
|
|
2183
|
+
gatePolicyJson?: string | null,
|
|
2184
|
+
): string;
|
|
2185
|
+
|
|
2186
|
+
/**
|
|
2187
|
+
* Enforce a `FlowGateDecision` (from `gateInformationFlow`) against the durable
|
|
2188
|
+
* human-in-the-loop approval ledger (Slice 3 of
|
|
2189
|
+
* `docs/proposals/verifiable-tool-safety.md`). A `require_approval` hazard a
|
|
2190
|
+
* human previously **approved** (by its stable flow fingerprint) is allowed
|
|
2191
|
+
* through, one **rejected** is blocked, and an unseen one becomes pending — so
|
|
2192
|
+
* the runtime confirms only the hazardous flows, and only once.
|
|
2193
|
+
*
|
|
2194
|
+
* `approvalsJson` (optional) is a JSON array of prior `ApprovalRecord`s
|
|
2195
|
+
* (`{ fingerprint, required_tier, decision: "approved" | "rejected", reviewer,
|
|
2196
|
+
* reason, evidence?, decided_at }`). Returns the `FlowEnforcement` JSON `{ allow:
|
|
2197
|
+
* boolean, blocked: FlowViolation[], pending: [{ fingerprint, violation }],
|
|
2198
|
+
* reason }`. Stateless — the ledger is rebuilt from `approvalsJson` each call.
|
|
2199
|
+
*/
|
|
2200
|
+
export function enforceInformationFlow(
|
|
2201
|
+
decisionJson: string,
|
|
2202
|
+
approvalsJson?: string | null,
|
|
2203
|
+
): string;
|
|
2204
|
+
|
|
2205
|
+
/**
|
|
2206
|
+
* Analyze a schedule of multi-agent read-generate-write operations for the four
|
|
2207
|
+
* concurrency anomalies of *Verified Detection and Prevention of Concurrency
|
|
2208
|
+
* Anomalies in Multi-Agent LLM Systems* (`docs/proposals/concurrency-anomalies.md`,
|
|
2209
|
+
* applying arXiv 2606.17182) and classify the achieved consistency level. The
|
|
2210
|
+
* time-extended, inter-agent complement to `transactionCheck`.
|
|
2211
|
+
*
|
|
2212
|
+
* `opsJson` is a JSON array of `AgentOp` (serde snake_case keys): `{ id, agent?,
|
|
2213
|
+
* read_set?, write_set?, tools_read?, tools_written?, depends_on?, read_at?,
|
|
2214
|
+
* commit_at? }` (omitted fields default). Returns the `ConcurrencyReport` JSON:
|
|
2215
|
+
* `{ level: "l0" | "l1" | "l2" | "l3" | "l4", serializable, anomalies: [{
|
|
2216
|
+
* anomaly: "stale_generation" | "phantom_tool" | "causal_cascade" |
|
|
2217
|
+
* "tool_effect_reorder", key, ops, explanation }] }` — `level` is set by the
|
|
2218
|
+
* most severe anomaly present (causal-cascade → l0 … none → l4 serializable).
|
|
2219
|
+
*/
|
|
2220
|
+
export function analyzeConcurrency(opsJson: string): string;
|
|
2221
|
+
|
|
2222
|
+
/**
|
|
2223
|
+
* Gate a concurrency report (from `analyzeConcurrency`) into remediations under a
|
|
2224
|
+
* policy (`docs/proposals/concurrency-anomalies.md`, arXiv 2606.17182 Slice 2 —
|
|
2225
|
+
* the analogue of `gateInformationFlow` for concurrency). Maps each anomaly to a
|
|
2226
|
+
* structural fix and a dispatch disposition by severity.
|
|
2227
|
+
*
|
|
2228
|
+
* `reportJson` is the `ConcurrencyReport`; `policyJson` (optional) is a
|
|
2229
|
+
* `ConcurrencyGatePolicy` `{ abort_at_or_below, require_approval_at_or_below }`
|
|
2230
|
+
* (levels `"l0".."l4"`; defaults abort on `l0`, approval on `l1`). Returns the
|
|
2231
|
+
* `ConcurrencyGate` JSON: `{ safe, level, abort, remediations: [{ anomaly,
|
|
2232
|
+
* remediation: { kind: "reread_and_regenerate" | "pin_tool_registry" |
|
|
2233
|
+
* "enforce_causal_order" | "serialize_writers", ... }, disposition:
|
|
2234
|
+
* "auto_remediate" | "require_approval" | "abort" }] }`.
|
|
2235
|
+
*/
|
|
2236
|
+
export function gateConcurrency(
|
|
2237
|
+
reportJson: string,
|
|
2238
|
+
policyJson?: string | null,
|
|
2239
|
+
): string;
|
|
2240
|
+
|
|
2241
|
+
/**
|
|
2242
|
+
* Statically verify a workflow graph for structural defects
|
|
2243
|
+
* (`docs/proposals/workflow-graph-verification.md`, applying arXiv 2603.20356
|
|
2244
|
+
* "Agentproof"). Catches topology-level defects a schema check misses — a
|
|
2245
|
+
* dead-end stage, an unreachable exit, a trap loop — before execution, each with
|
|
2246
|
+
* a witness path (the counter-example for a repair loop).
|
|
2247
|
+
*
|
|
2248
|
+
* `graphJson` is a `WorkflowGraph` `{ entry: string, terminals: string[],
|
|
2249
|
+
* stages: string[], edges: [{ from, to, condition? }] }`. Returns the
|
|
2250
|
+
* `WorkflowVerifyReport` JSON `{ sound: boolean, defects: [{ kind:
|
|
2251
|
+
* "missing_entry" | "dangling_edge" | "unreachable_stage" | "dead_end" |
|
|
2252
|
+
* "no_exit_reachable" | "unreachable_terminal", subject, witness: string[],
|
|
2253
|
+
* explanation }] }`.
|
|
2254
|
+
*/
|
|
2255
|
+
export function verifyWorkflowGraph(graphJson: string): string;
|
|
2256
|
+
|
|
2257
|
+
/**
|
|
2258
|
+
* Check temporal safety policies over a workflow graph
|
|
2259
|
+
* (`docs/proposals/workflow-graph-verification.md`, arXiv 2603.20356 "Agentproof"
|
|
2260
|
+
* Slice 2 — the static half of the policy layer). The headline policy is the
|
|
2261
|
+
* human-gate: a guard stage must precede a sensitive stage on *every* path.
|
|
2262
|
+
*
|
|
2263
|
+
* `graphJson` is a `WorkflowGraph`; `policiesJson` is a JSON array of
|
|
2264
|
+
* `TemporalPolicy` (`{ kind: "precedes", earlier: string, later: string, name?:
|
|
2265
|
+
* string }`). Returns the `PolicyReport` JSON `{ compliant: boolean, violations:
|
|
2266
|
+
* [{ policy, stage, witness: string[], explanation }] }` — each violation's
|
|
2267
|
+
* witness is a path that reaches the guarded stage without the required
|
|
2268
|
+
* predecessor.
|
|
2269
|
+
*/
|
|
2270
|
+
export function checkWorkflowPolicies(
|
|
2271
|
+
graphJson: string,
|
|
2272
|
+
policiesJson: string,
|
|
2273
|
+
): string;
|
|
2274
|
+
|
|
2275
|
+
/**
|
|
2276
|
+
* Verify a plan's sequential feasibility by symbolic forward simulation
|
|
2277
|
+
* (`docs/proposals/plan-precondition-verification.md`, applying arXiv 2603.14730
|
|
2278
|
+
* "GNNVerifier" — the deterministic, training-free counterpart). Catches a step
|
|
2279
|
+
* whose preconditions the earlier steps never establish, and an unreached goal,
|
|
2280
|
+
* before anything runs (the STRIPS applicability check).
|
|
2281
|
+
*
|
|
2282
|
+
* `requestJson` is a `PlanCheckRequest` `{ initial: string[], steps: [{ id:
|
|
2283
|
+
* string, preconditions?: string[], add_effects?: string[], del_effects?:
|
|
2284
|
+
* string[] }], goal: string[] }`. Returns the `PlanCheckReport` JSON `{ valid:
|
|
2285
|
+
* boolean, defects: [{ kind: "unmet_precondition" | "goal_not_achieved", step?,
|
|
2286
|
+
* fact, explanation }], final_state: string[] }`. Effects apply even when a
|
|
2287
|
+
* precondition fails, so one pass surfaces every defect.
|
|
2288
|
+
*/
|
|
2289
|
+
export function checkPlan(requestJson: string): string;
|
|
2290
|
+
|
|
2291
|
+
/**
|
|
2292
|
+
* Intent-grounded verify-before-commit (arXiv 2601.05755 "VIGIL" — defending
|
|
2293
|
+
* against tool stream injection). Flags actions that drift outside the user's
|
|
2294
|
+
* declared intent, blocking commit when the drifting action is influenced by an
|
|
2295
|
+
* untrusted tool result (the injection signature). `requestJson` is `{ intent: {
|
|
2296
|
+
* allowed_tools?: string[], allowed_resources?: string[], forbidden_capabilities?:
|
|
2297
|
+
* string[] }, actions: [{ id: string, tool?: string, targets?: string[],
|
|
2298
|
+
* capabilities?: string[], depends_on?: string[], untrusted?: boolean }] }`.
|
|
2299
|
+
* Returns the `IntentReport` JSON `{ safe: boolean, commit_blocked: string[],
|
|
2300
|
+
* violations: [{ action, kind: "tool_out_of_intent" | "target_out_of_intent" |
|
|
2301
|
+
* "forbidden_capability", detail, tool_influenced: boolean, explanation }] }`.
|
|
2302
|
+
* Pure, zero-inference.
|
|
2303
|
+
*/
|
|
2304
|
+
export function checkIntent(requestJson: string): string;
|
|
2305
|
+
|
|
2306
|
+
/**
|
|
2307
|
+
* Intent-grounded verify-before-commit straight from a plan's IR actions (VIGIL
|
|
2308
|
+
* Slice 4 — the IR populater + check in one call). `requestJson` is `{ intent,
|
|
2309
|
+
* actions: Action[], untrusted_tools?: string[], untrusted_ids?: string[] }`. The
|
|
2310
|
+
* runtime derives the `IntentAction`s from its own IR (tool, `expected_effects` →
|
|
2311
|
+
* targets, dependency edges → `depends_on`, `metadata.capabilities` →
|
|
2312
|
+
* capabilities, `untrusted` from the supplied provenance) then runs the intent
|
|
2313
|
+
* check. Returns the same `IntentReport` JSON.
|
|
2314
|
+
*/
|
|
2315
|
+
export function checkIntentPlan(requestJson: string): string;
|
|
2316
|
+
|
|
2317
|
+
/**
|
|
2318
|
+
* Map an intent report to an enforcement disposition (VIGIL Slice 2 — the gate).
|
|
2319
|
+
* `reportJson` is a `checkIntent` report; `gatePolicyJson` is an optional
|
|
2320
|
+
* `IntentGatePolicy` `{ on_untainted_drift: "allow" | "require_approval" | "block"
|
|
2321
|
+
* }` (default `require_approval`). Injections (tool-stream-influenced drift) and
|
|
2322
|
+
* forbidden capabilities always block regardless of policy. Returns the
|
|
2323
|
+
* `IntentGateDecision` JSON `{ action, blocked, needs_approval, reason }`.
|
|
2324
|
+
*/
|
|
2325
|
+
export function gateIntent(reportJson: string, gatePolicyJson?: string): string;
|
|
2326
|
+
|
|
2327
|
+
/**
|
|
2328
|
+
* Enforce an `IntentGateDecision` against the durable approval ledger (VIGIL
|
|
2329
|
+
* Slice 3 — the HITL bridge). `decisionJson` is a `gateIntent` decision;
|
|
2330
|
+
* `approvalsJson` is an optional `ApprovalRecord[]` seeding the ledger. An
|
|
2331
|
+
* out-of-intent action a human approved commits; one they rejected is blocked; a
|
|
2332
|
+
* novel one is pending. Hard blocks (injections / forbidden capabilities) are
|
|
2333
|
+
* never committable. Returns the `IntentEnforcement` JSON `{ commit, blocked,
|
|
2334
|
+
* pending: [{ fingerprint, violation }], reason }`.
|
|
2335
|
+
*/
|
|
2336
|
+
export function enforceIntent(decisionJson: string, approvalsJson?: string): string;
|
|
2337
|
+
|
|
2338
|
+
/**
|
|
2339
|
+
* Plan a deterministic, budget-bounded context eviction over typed trajectory
|
|
2340
|
+
* episodes (`docs/proposals/context-eviction.md`, applying arXiv 2606.11213
|
|
2341
|
+
* "CWL" + the Governance-Decay guard, arXiv 2606.22528). The cheaper-than-
|
|
2342
|
+
* summarization first move when the context window fills: shed action results
|
|
2343
|
+
* whose effects are already persisted, preserve user turns and the active
|
|
2344
|
+
* reasoning frontier, and never evict a pinned constraint.
|
|
2345
|
+
*
|
|
2346
|
+
* `episodesJson` is a JSON array of `ContextEpisode` `{ id, kind: "constraint" |
|
|
2347
|
+
* "user_turn" | "agent_reasoning" | "action_result" | "observation", tokens?,
|
|
2348
|
+
* persisted?, pinned?, recency? }`; `budget` is the token ceiling. Returns the
|
|
2349
|
+
* `EvictionPlan` JSON `{ evicted: string[], retained_tokens, pinned_tokens,
|
|
2350
|
+
* within_budget }`. `within_budget = false` means even the pinned/retained floor
|
|
2351
|
+
* exceeds budget — the caller must fall back to summarizing compaction.
|
|
2352
|
+
*/
|
|
2353
|
+
export function planContextEviction(
|
|
2354
|
+
episodesJson: string,
|
|
2355
|
+
budget: number,
|
|
2356
|
+
): string;
|
|
2357
|
+
|
|
2358
|
+
/**
|
|
2359
|
+
* Merge divergent replicas of a CRDT shared state into the single state they
|
|
2360
|
+
* all converge to, with strong eventual consistency
|
|
2361
|
+
* (`docs/proposals/convergent-shared-state.md`, applying arXiv 2510.18893
|
|
2362
|
+
* "CodeCRDT"). Supplies the deterministic *resolution* that complements
|
|
2363
|
+
* `transactionCheck`'s conflict *detection*, and the merge layer the
|
|
2364
|
+
* multi-device-sync design defers to.
|
|
2365
|
+
*
|
|
2366
|
+
* `replicasJson` is a JSON array of last-writer-wins maps, each `{ "<key>": {
|
|
2367
|
+
* value: any, version: number, replica: string } }` (per-key version, e.g. from
|
|
2368
|
+
* the versioned state store, plus the writing replica/agent id). Per shared key
|
|
2369
|
+
* the dominating `(version, replica)` wins. Returns `{ registers, state }`: the
|
|
2370
|
+
* merged LWW map (tags retained, so it can be merged again) and a materialized
|
|
2371
|
+
* `key → value` state for feeding `verify`/`simulate`. Order-independent and
|
|
2372
|
+
* idempotent (zero merge failures by construction).
|
|
2373
|
+
*/
|
|
2374
|
+
export function crdtMerge(replicasJson: string): string;
|
|
2375
|
+
|
|
2376
|
+
/**
|
|
2377
|
+
* Export a device/agent's state as a CRDT LWW map for replication — the *export*
|
|
2378
|
+
* half of multi-device sync (`docs/proposals/convergent-shared-state.md`).
|
|
2379
|
+
* `snapshotJson` is the plain state `{ key: value }` (e.g. from the state
|
|
2380
|
+
* store's snapshot); `versionsJson` is `{ key: version }` (per-key versions);
|
|
2381
|
+
* `replica` is this device/agent id. Returns the LWW map JSON `{ "<key>": {
|
|
2382
|
+
* value, version, replica } }`, ready to exchange between replicas and feed to
|
|
2383
|
+
* `crdtMerge`. Keys absent from `versionsJson` default to version 0.
|
|
2384
|
+
*/
|
|
2385
|
+
export function crdtExport(
|
|
2386
|
+
snapshotJson: string,
|
|
2387
|
+
versionsJson: string,
|
|
2388
|
+
replica: string,
|
|
2389
|
+
): string;
|
|
2390
|
+
|
|
2391
|
+
/**
|
|
2392
|
+
* Merge replicas of a first-claim-wins claim registry for observation-driven
|
|
2393
|
+
* multi-agent task coordination (Slice 3 of
|
|
2394
|
+
* `docs/proposals/convergent-shared-state.md`). `registriesJson` is a JSON array
|
|
2395
|
+
* of registries `{ "<task>": { claimant, version, replica } }`; per shared task
|
|
2396
|
+
* the earliest `(version, replica)` claim wins. Returns `{ registry, owners: {
|
|
2397
|
+
* [task]: claimant } }` — the merged CRDT plus the resolved one-owner-per-task
|
|
2398
|
+
* view agents read to self-partition work without a coordinator. Order-independent
|
|
2399
|
+
* and idempotent.
|
|
2400
|
+
*/
|
|
2401
|
+
export function crdtMergeClaims(registriesJson: string): string;
|
|
2402
|
+
|
|
2403
|
+
/**
|
|
2404
|
+
* Rank memory-retrieval candidates by utility-aware UCB — the deterministic
|
|
2405
|
+
* variant of U-Mem's Semantic-Aware Thompson Sampling
|
|
2406
|
+
* (`docs/proposals/autonomous-memory-agents.md`, applying arXiv 2602.22406).
|
|
2407
|
+
* Blends each candidate's semantic `relevance` with a learned utility posterior
|
|
2408
|
+
* (`Beta(success+1, fail+1)`): proven-useful memories rise, untried ones get an
|
|
2409
|
+
* exploration bonus from their uncertainty, and it's reproducible (no RNG).
|
|
2410
|
+
*
|
|
2411
|
+
* `candidatesJson` is a JSON array of `{ id: string, relevance: number,
|
|
2412
|
+
* success?: number, fail?: number }`. `exploration` weights the cold-start
|
|
2413
|
+
* uncertainty bonus; `utilityWeight` (0..1) blends utility vs. raw relevance
|
|
2414
|
+
* (`0` = pure relevance, so enabling this never changes ranking unless opted
|
|
2415
|
+
* in). Returns the ranked JSON array `[{ id, score, relevance, utility }]`,
|
|
2416
|
+
* highest score first.
|
|
2417
|
+
*/
|
|
2418
|
+
export function utilityRank(
|
|
2419
|
+
candidatesJson: string,
|
|
2420
|
+
exploration: number,
|
|
2421
|
+
utilityWeight: number,
|
|
2422
|
+
): string;
|
|
2423
|
+
|
|
2424
|
+
/**
|
|
2425
|
+
* Decide U-Mem's cost-aware knowledge cascade — the *Evolve* escalation
|
|
2426
|
+
* (`docs/proposals/autonomous-memory-agents.md`, applying arXiv 2602.22406).
|
|
2427
|
+
* Given the current confidence in a piece of knowledge and an escalation policy,
|
|
2428
|
+
* returns the cheapest tier (self-reflect → tool-verify → human-expert) that
|
|
2429
|
+
* reaches the confidence target within a cost budget — or that the answer is
|
|
2430
|
+
* already confident enough, or that the budget is exhausted.
|
|
2431
|
+
*
|
|
2432
|
+
* `policyJson` is `{ confidence_target: number, budget: number, tiers: [{ tier:
|
|
2433
|
+
* "self_reflect" | "tool_verify" | "human_expert", cost: number,
|
|
2434
|
+
* expected_confidence: number }] }` (tiers cheapest-first). Returns the outcome
|
|
2435
|
+
* JSON — one of `{ decision: "already_confident", confidence }`, `{ decision:
|
|
2436
|
+
* "accept", tier, confidence, cost_spent }`, or `{ decision: "exhausted",
|
|
2437
|
+
* best_tier, confidence, cost_spent }`. Pure decision core; the caller runs the
|
|
2438
|
+
* chosen tier (`reflect()`, tools, or the HITL approval ledger).
|
|
2439
|
+
*/
|
|
2440
|
+
export function cascadeDecide(
|
|
2441
|
+
currentConfidence: number,
|
|
2442
|
+
policyJson: string,
|
|
2443
|
+
): string;
|
|
2444
|
+
|
|
2445
|
+
/**
|
|
2446
|
+
* Diagnose a memory system along the four system-level dimensions of *Are We
|
|
2447
|
+
* Ready For An Agent-Native Memory System?*
|
|
2448
|
+
* (`docs/proposals/agent-native-memory-diagnostic.md`, applying arXiv
|
|
2449
|
+
* 2606.24775): representation fidelity, retrieval precision, update correctness,
|
|
2450
|
+
* long-horizon stability. Scores the memory store as a data system rather than
|
|
2451
|
+
* by end-to-end task success, and names the bottleneck module to invest in next.
|
|
2452
|
+
*
|
|
2453
|
+
* `statsJson` is aggregate counters (parsed by serde — keys are snake_case):
|
|
2454
|
+
* `{ total_facts, structured_facts, total_edges, total_retrievals,
|
|
2455
|
+
* helpful_retrievals, conflicts_resolved, outstanding_outdated, facts_created,
|
|
2456
|
+
* facts_superseded }` (omitted fields default to 0). Returns the report JSON:
|
|
2457
|
+
* `{ representation_fidelity, retrieval_precision, update_correctness,
|
|
2458
|
+
* long_horizon_stability, overall }` (each 0..1), `bottleneck` (one of
|
|
2459
|
+
* `"representation" | "retrieval" | "update_correctness" |
|
|
2460
|
+
* "long_horizon_stability" | "none"`), `recommendation`, and `evaluated`.
|
|
2461
|
+
*/
|
|
2462
|
+
export function memorySystemDiagnose(statsJson: string): string;
|
|
2463
|
+
|
|
2464
|
+
/**
|
|
2465
|
+
* Decide localized-vs-global memory maintenance
|
|
2466
|
+
* (`docs/proposals/agent-native-memory-diagnostic.md`, applying arXiv
|
|
2467
|
+
* 2606.24775's finding that localized maintenance is more cost-efficient than
|
|
2468
|
+
* global reorganization). Both strategies resolve the dirty regions; global only
|
|
2469
|
+
* wins when its store-wide structural gain (valued) clears the extra cost of
|
|
2470
|
+
* touching the whole store.
|
|
2471
|
+
*
|
|
2472
|
+
* `inputJson` is (serde snake_case keys) `{ dirty_regions, total_regions,
|
|
2473
|
+
* localized_cost_per_region, global_cost_per_region, global_structural_gain,
|
|
2474
|
+
* gain_value }` (omitted fields default to 0). Returns the decision JSON:
|
|
2475
|
+
* `{ strategy: "no_op" | "localized" | "global", localized_cost, global_cost,
|
|
2476
|
+
* global_extra_value, global_net_advantage, rationale }`.
|
|
2477
|
+
*/
|
|
2478
|
+
export function maintenanceDecide(inputJson: string): string;
|
|
2479
|
+
|
|
2480
|
+
/**
|
|
2481
|
+
* Plan an evolution cycle — the survey's *when + what to evolve* (arXiv
|
|
2482
|
+
* 2507.21046, *A Survey of Self-Evolving Agents*). `requestJson` is `{ components:
|
|
2483
|
+
* [{ component: "memory" | "skills" | "harness" | "context" | "tools", pressure?,
|
|
2484
|
+
* evidence?, min_evidence?, cost? }], policy?: { pressure_threshold?, budget? } }`.
|
|
2485
|
+
* Returns the `EvolutionPlan` JSON `{ decisions: [{ component, action:
|
|
2486
|
+
* "evolve_now" | "defer" | "skip", priority, defer_reason?, reason }], spent,
|
|
2487
|
+
* evolve_now }`. Evolves only under pressure, only with enough evidence,
|
|
2488
|
+
* prioritized by `pressure / cost` within the budget.
|
|
2489
|
+
*/
|
|
2490
|
+
export function planEvolution(requestJson: string): string;
|
|
2491
|
+
|
|
2492
|
+
/**
|
|
2493
|
+
* Rebuild `(stateBefore, action, stateAfter)` transitions from a JSONL tail
|
|
2494
|
+
* of a session's event log — the trajectories CAR already records, turned
|
|
2495
|
+
* into the unit-test records `cwmScore` consumes. Folds the recorded
|
|
2496
|
+
* `StateChanged` deltas (`data.changes`) over `initialStateJson` in log
|
|
2497
|
+
* order.
|
|
2498
|
+
*
|
|
2499
|
+
* `actionsJson` (optional) is a JSON object mapping an action id → the action
|
|
2500
|
+
* JSON to attach (pass a proposal's actions so a transition carries
|
|
2501
|
+
* `tool`/`parameters`); absent a match the action is `{ id }`. Lines that
|
|
2502
|
+
* don't parse as events are skipped. Returns a JSON array of transitions.
|
|
2503
|
+
*/
|
|
2504
|
+
export function cwmTransitionsFromEvents(
|
|
2505
|
+
eventsJsonl: string,
|
|
2506
|
+
initialStateJson?: string | null,
|
|
2507
|
+
actionsJson?: string | null,
|
|
2508
|
+
): string;
|
|
2509
|
+
|
|
2510
|
+
/**
|
|
2511
|
+
* Predictive simulation (Code World Models Slice 2 of
|
|
2512
|
+
* `docs/proposals/code-world-models.md`). Like the static simulator, but
|
|
2513
|
+
* applies per-action effect predictions from a verified Code World Model,
|
|
2514
|
+
* gated by accuracy — turning `simulate`'s placeholder-propagation into a
|
|
2515
|
+
* predicted final state.
|
|
2516
|
+
*
|
|
2517
|
+
* `proposalJson` is an `ActionProposal`; `initialStateJson` (optional) seeds
|
|
2518
|
+
* state; `predictionsJson` maps `actionId` → `{ effects: { key: value, ... },
|
|
2519
|
+
* accuracy: number }`, where `effects` are what the caller's run of the
|
|
2520
|
+
* generated model predicts the action writes. A prediction is applied only
|
|
2521
|
+
* when `accuracy >= minAccuracy`; otherwise — and for any action with no
|
|
2522
|
+
* prediction — the simulator falls back to that action's declared
|
|
2523
|
+
* `expectedEffects` (i.e. the static `simulate` behavior). An under-accurate
|
|
2524
|
+
* model therefore can never worsen the result; at worst it is ignored.
|
|
2525
|
+
*
|
|
2526
|
+
* Returns the final state as a JSON object.
|
|
2527
|
+
*/
|
|
2528
|
+
export function simulateWithPredictions(
|
|
2529
|
+
proposalJson: string,
|
|
2530
|
+
initialStateJson: string | null | undefined,
|
|
2531
|
+
predictionsJson: string,
|
|
2532
|
+
minAccuracy: number,
|
|
2533
|
+
): string;
|
|
2534
|
+
|
|
1843
2535
|
/**
|
|
1844
2536
|
* Compute harness-level evaluation metrics (survey "Code as Agent Harness"
|
|
1845
2537
|
* §5.2.1) from a JSONL tail of a session's event log (one event per line).
|
|
@@ -1853,6 +2545,53 @@ export function transactionCheck(
|
|
|
1853
2545
|
*/
|
|
1854
2546
|
export function harnessMetrics(eventsJsonl: string): string;
|
|
1855
2547
|
|
|
2548
|
+
/**
|
|
2549
|
+
* Detect tool-result hallucinations by cross-checking the model's claims about
|
|
2550
|
+
* tool use against the runtime's receipts of what actually executed
|
|
2551
|
+
* (`docs/proposals/tool-receipt-verification.md`, applying arXiv 2603.10060
|
|
2552
|
+
* "Tool Receipts"). Deterministic and zero-inference — the runtime owns the
|
|
2553
|
+
* ground truth, so the model can't fake a receipt.
|
|
2554
|
+
*
|
|
2555
|
+
* `claimsJson` is a JSON array of `ToolClaim` `{ kind: "invoked" | "count" |
|
|
2556
|
+
* "absence", tool: string, call_id?, count?, text? }`; `receiptsJson` is a JSON
|
|
2557
|
+
* array of `ToolReceipt` `{ tool: string, call_id?, ok?, result_count? }`.
|
|
2558
|
+
* `windowComplete` (default `true`) declares whether the receipts cover the
|
|
2559
|
+
* full window the claims are about — pass `false` when they were projected
|
|
2560
|
+
* from a retention-trimmed log, so a receiptless claim is reported in
|
|
2561
|
+
* `ungroundable` ("window evicted") instead of accused as fabricated.
|
|
2562
|
+
* Returns the `ReceiptReport` JSON `{ grounded: boolean, hallucinations: [{
|
|
2563
|
+
* kind: "fabricated_tool_reference" | "count_misstatement" | "false_absence",
|
|
2564
|
+
* tool, claim_text?, explanation }], ungroundable?: [{ tool, claim_text?,
|
|
2565
|
+
* explanation }] }`.
|
|
2566
|
+
*/
|
|
2567
|
+
export function verifyToolReceipts(
|
|
2568
|
+
claimsJson: string,
|
|
2569
|
+
receiptsJson: string,
|
|
2570
|
+
windowComplete?: boolean | undefined | null,
|
|
2571
|
+
): string;
|
|
2572
|
+
|
|
2573
|
+
/**
|
|
2574
|
+
* Diagnose runtime-harness interventions from a JSONL event-log tail
|
|
2575
|
+
* (`docs/proposals/runtime-harness-adaptation.md`, applying arXiv 2605.22166
|
|
2576
|
+
* "Adapting the Interface, Not the Model"). Converts *recurring* interaction
|
|
2577
|
+
* failures into typed, reusable fixes across Life-Harness's four lifecycle
|
|
2578
|
+
* layers — `environment_contract` (calibrate a tool's description/constraints),
|
|
2579
|
+
* `action_realization` (normalize malformed calls), `trajectory_regulation`
|
|
2580
|
+
* (circuit-break runtime-failure / retry / replan thrash), and
|
|
2581
|
+
* `procedural_skill` — i.e. "fix the harness, not the model". Complements
|
|
2582
|
+
* `evolutionDiagnose` (which gates/applies mutations); this is the diagnosis
|
|
2583
|
+
* pass over trajectories.
|
|
2584
|
+
*
|
|
2585
|
+
* `minOccurrences` is the recurrence threshold (one-offs are noise; pass 2 for
|
|
2586
|
+
* "recurring"). Returns the `AdaptationReport` JSON `{ interventions: [{ layer,
|
|
2587
|
+
* target, trigger, intervention, evidence_count }], parse_errors }`, sorted by
|
|
2588
|
+
* evidence descending.
|
|
2589
|
+
*/
|
|
2590
|
+
export function diagnoseHarnessInterventions(
|
|
2591
|
+
eventsJsonl: string,
|
|
2592
|
+
minOccurrences: number,
|
|
2593
|
+
): string;
|
|
2594
|
+
|
|
1856
2595
|
// --- Agentic Harness Engineering: Evolution Agent (survey §3.5, §5.2.3) ---
|
|
1857
2596
|
//
|
|
1858
2597
|
// A governed meta-agent that proposes harness mutations from telemetry and
|
|
@@ -2095,6 +2834,21 @@ export function createTask(
|
|
|
2095
2834
|
*/
|
|
2096
2835
|
export function renderOsSchedule(taskJson: string, program: string, argsJson: string): string;
|
|
2097
2836
|
|
|
2837
|
+
/**
|
|
2838
|
+
* Analyze a static execution DAG as a scheduler
|
|
2839
|
+
* (`docs/proposals/scheduler-graph-analysis.md`, applying arXiv 2604.11378 "From
|
|
2840
|
+
* Agent Loops to Structured Graphs"). Makes a plan's schedule inspectable before
|
|
2841
|
+
* running it: critical path, makespan, available parallelism, topological waves,
|
|
2842
|
+
* cycle detection, and the serial "Agent-Loop pathology" flag.
|
|
2843
|
+
*
|
|
2844
|
+
* `graphJson` is a `ScheduleGraph` `{ units: [{ id: string, duration?: number,
|
|
2845
|
+
* depends_on?: string[] }] }`. Returns the `ScheduleAnalysis` JSON `{ has_cycle:
|
|
2846
|
+
* boolean, critical_path: string[], makespan: number, max_parallelism: number,
|
|
2847
|
+
* levels: string[][], serial: boolean }`. `serial` is true when the plan
|
|
2848
|
+
* collapses to one-unit-at-a-time; `has_cycle` flags a never-terminating plan.
|
|
2849
|
+
*/
|
|
2850
|
+
export function analyzeSchedule(graphJson: string): string;
|
|
2851
|
+
|
|
2098
2852
|
/**
|
|
2099
2853
|
* Install a durable OS-level schedule (launchd on macOS, crontab on Linux) so
|
|
2100
2854
|
* the task fires even when the CAR daemon is down. Idempotent. Returns the
|