ai-runtime-engine 2.7.0 → 2.9.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/CHANGELOG.md +108 -0
- package/dist/agents/roles.d.ts +36 -0
- package/dist/agents/roles.js +44 -0
- package/dist/agents/synthesize.d.ts +44 -0
- package/dist/agents/synthesize.js +60 -0
- package/dist/agents/task.d.ts +95 -6
- package/dist/agents/task.js +40 -2
- package/dist/agents/worker.d.ts +32 -1
- package/dist/agents/worker.js +150 -19
- package/dist/cli/cli.js +1 -1
- package/dist/cli/interactive/lanes.d.ts +69 -0
- package/dist/cli/interactive/lanes.js +181 -0
- package/dist/cli/interactive/repl.js +52 -0
- package/dist/cli/interactive/session.d.ts +8 -1
- package/dist/cli/interactive/session.js +62 -10
- package/dist/executions/agentTasks.d.ts +628 -0
- package/dist/executions/agentTasks.js +149 -0
- package/dist/executions/checkpoint.d.ts +5 -1
- package/dist/executions/checkpoint.js +13 -1
- package/dist/executions/execution.d.ts +23 -0
- package/dist/executions/store.d.ts +37 -0
- package/dist/executions/store.js +33 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +7 -0
- package/dist/orchestration/executor.d.ts +26 -1
- package/dist/orchestration/executor.js +50 -9
- package/dist/orchestration/orchestrator.d.ts +6 -0
- package/dist/orchestration/orchestrator.js +18 -1
- package/dist/runtime/events.d.ts +44 -0
- package/dist/runtime/events.js +4 -0
- package/dist/runtime/runtime.d.ts +90 -0
- package/dist/runtime/runtime.js +510 -20
- package/dist/security/redact.js +22 -10
- package/dist/util/hash.d.ts +19 -0
- package/dist/util/hash.js +39 -0
- package/package.json +1 -1
package/dist/runtime/events.js
CHANGED
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
* Token-streaming extension point: `response.delta` is reserved here (content-bearing, redacted like
|
|
7
7
|
* everything else). Provider token streaming is NOT implemented in 1.0 — no delta is ever emitted yet —
|
|
8
8
|
* but declaring the arm keeps the host/emitter architecture ready for it without a breaking change.
|
|
9
|
+
*
|
|
10
|
+
* EVOLUTION CONTRACT: this union GROWS. A new arm is additive at runtime — an existing consumer keeps
|
|
11
|
+
* receiving the events it knows — but it breaks an exhaustive `switch` at COMPILE time. Consumers must
|
|
12
|
+
* carry a default case. Arms added this way are announced in the CHANGELOG.
|
|
9
13
|
*/
|
|
10
14
|
import { systemClock } from '../util/clock.js';
|
|
11
15
|
import { redact } from '../security/redact.js';
|
|
@@ -25,6 +25,7 @@ import type { SkillSource, LoadedSource } from '../skills/discovery.js';
|
|
|
25
25
|
import type { AgentDefinition } from '../agents/definition.js';
|
|
26
26
|
import { ExecutionStore } from '../executions/store.js';
|
|
27
27
|
import type { Execution } from '../executions/execution.js';
|
|
28
|
+
import type { AgentTaskState, AgentTaskView } from '../agents/task.js';
|
|
28
29
|
import { ArtifactStore } from '../artifacts/artifacts.js';
|
|
29
30
|
import type { CompareInput } from '../comparison/comparator.js';
|
|
30
31
|
import type { ComparisonResult } from '../comparison/comparison.js';
|
|
@@ -87,6 +88,8 @@ export declare class Runtime {
|
|
|
87
88
|
/** Live runs, so a pause/cancel can abort the agent tasks actually in flight. Only ever populated
|
|
88
89
|
* when agents are enabled, so pause/cancel are unchanged with the flag off. */
|
|
89
90
|
private readonly liveRuns;
|
|
91
|
+
/** Phase 3.6: agent tasks running RIGHT NOW in this process, and how to stop each one on its own. */
|
|
92
|
+
private readonly liveAgentTasks;
|
|
90
93
|
/** The config file's `budget:` ceilings, kept only so the 3.3 pre-pass can decline a model call. */
|
|
91
94
|
private readonly _configBudget?;
|
|
92
95
|
private readonly approval?;
|
|
@@ -268,8 +271,29 @@ export declare class Runtime {
|
|
|
268
271
|
executions(): Execution[];
|
|
269
272
|
/** plan/execute/orchestrate/agent/debug: run the orchestrator and persist a resumable Execution. */
|
|
270
273
|
private runOrchestration;
|
|
274
|
+
/**
|
|
275
|
+
* THE mid-run persistence sink (Phase 3.5) — the only thing that writes an execution while it runs.
|
|
276
|
+
*
|
|
277
|
+
* Invariant 18 says everything needed for resume is on disk before the next wave starts, and the
|
|
278
|
+
* non-obvious part is WHAT that includes. Committing the plan, the completed steps and the agent
|
|
279
|
+
* records is not enough: the resume gate is `!recon.drifted && !!exec.plan`, and `recon` defaults to
|
|
280
|
+
* DRIFTED whenever `checkpoints` is empty. Since checkpoints were captured only after orchestration
|
|
281
|
+
* returned, a crash mid-run always drifted, always replanned, and re-ran every completed agent task —
|
|
282
|
+
* the exact thing this phase exists to prevent. So the sink captures a checkpoint too.
|
|
283
|
+
*
|
|
284
|
+
* Every refusal from the funnel ABORTS the run. A refused commit means another owner now owns this
|
|
285
|
+
* execution's fate; carrying on would call the same tools and burn the same model calls twice while
|
|
286
|
+
* that owner re-runs the identical steps, and every result would be discarded at the end anyway.
|
|
287
|
+
*/
|
|
288
|
+
private runPersistence;
|
|
271
289
|
/** Run `fn` while heartbeating the execution lease so a long run never lets the lease expire. */
|
|
272
290
|
private withHeartbeat;
|
|
291
|
+
/**
|
|
292
|
+
* Build the OrchestrateInput. The optional half is an OBJECT, not a positional tail: this function
|
|
293
|
+
* grew to ten parameters and a caller that passed five of them silently got no sink, no signal and no
|
|
294
|
+
* provenance — a replan that persisted nothing and could not be cancelled. Named fields cannot be
|
|
295
|
+
* short-counted.
|
|
296
|
+
*/
|
|
273
297
|
private orchestrateInput;
|
|
274
298
|
/** Record an EXECUTED orchestration outcome for learning. plan-only, dry-run, and waiting states are
|
|
275
299
|
* skipped — no skill ran, so there is no success/failure to learn (recording them would teach noise). */
|
|
@@ -349,6 +373,72 @@ export declare class Runtime {
|
|
|
349
373
|
* an agent step would have failed every one of those steps.
|
|
350
374
|
*/
|
|
351
375
|
private orchestrateRunners;
|
|
376
|
+
/**
|
|
377
|
+
* A bounded, fenced brief of what the agents have already established (Phase 3.5).
|
|
378
|
+
*
|
|
379
|
+
* On drift the plan is thrown away and the goal is replanned — but validated findings are facts about
|
|
380
|
+
* the WORKSPACE, not about the plan's structure, so discarding them silently would make the run redo
|
|
381
|
+
* work it had already proved. They are agent-authored text, so they cross a prompt boundary fenced,
|
|
382
|
+
* exactly like every other untrusted string.
|
|
383
|
+
*/
|
|
384
|
+
private findingsBrief;
|
|
385
|
+
/**
|
|
386
|
+
* Fingerprint the MCP tools a plan actually references (Phase 3.5). An MCP server is remote and
|
|
387
|
+
* mutable: while a plan sits paused it can change a tool's input schema, change what it does, or drop
|
|
388
|
+
* it entirely — and the plan would then be resumed against a tool that is no longer the tool it was
|
|
389
|
+
* planned for. Hashing the live declaration makes that visible as ordinary drift.
|
|
390
|
+
*
|
|
391
|
+
* Non-MCP tools are deliberately absent: they are in-tree code covered by the config/skill hashes.
|
|
392
|
+
*/
|
|
393
|
+
private mcpToolHashes;
|
|
394
|
+
/**
|
|
395
|
+
* Crash / pause / cancel reconciliation (Phase 3.5). A record left `running` or `created` describes a
|
|
396
|
+
* worker that no longer exists — the process died, or the parent stopped it — so it goes back to
|
|
397
|
+
* `queued` with an auditable reason. An interruption is deliberately NOT a state: the lifecycle does
|
|
398
|
+
* not grow, only the explanation does.
|
|
399
|
+
*
|
|
400
|
+
* This runs on the RESUME path and inside pause/cancel. Resume alone is not enough: `cancelExecution`
|
|
401
|
+
* writes a terminal status and resume early-returns on terminal, so a cancelled execution's `running`
|
|
402
|
+
* records would stay `running` on disk forever, unstamped and unexplained.
|
|
403
|
+
*
|
|
404
|
+
* Records that fail validation are preserved in place, never dropped — reconciling is not a licence to
|
|
405
|
+
* delete what this version could not parse.
|
|
406
|
+
*/
|
|
407
|
+
private reconcileAgentTasks;
|
|
408
|
+
/**
|
|
409
|
+
* FIRST-WINS PENDING. `Execution.pending` is a single slot but two agents can be waiting at once, so
|
|
410
|
+
* the earliest-created waiting task claims it. The others are not lost: once this one is answered and
|
|
411
|
+
* the run continues, the next resume re-elects whichever task is still waiting — rediscovery, rather
|
|
412
|
+
* than a queue that has to be kept in sync with the records that are already the source of truth.
|
|
413
|
+
*/
|
|
414
|
+
private electWaitingAgent;
|
|
415
|
+
/**
|
|
416
|
+
* Which persisted task, if any, a plan step should CONTINUE. Bound by step-input hash, never by step
|
|
417
|
+
* id: plan step ids (`s1`, `auto1`) are model-authored and recur across replans, so an id match would
|
|
418
|
+
* hand one step's completed inner work to a different step with the same id and a different input.
|
|
419
|
+
*/
|
|
420
|
+
private agentResumeLookup;
|
|
421
|
+
/**
|
|
422
|
+
* Every agent task this Runtime can see, newest execution first (Phase 3.6). Live ones (running in
|
|
423
|
+
* this process) and persisted ones are the same list: a task's record IS its status, so there is no
|
|
424
|
+
* second source to disagree with.
|
|
425
|
+
*/
|
|
426
|
+
agentTasks(executionId?: string): AgentTaskView[];
|
|
427
|
+
/**
|
|
428
|
+
* Stop one agent task. Four cases, and NONE of them is a silent no-op — a `stop` that appears to do
|
|
429
|
+
* nothing is indistinguishable from a bug:
|
|
430
|
+
*
|
|
431
|
+
* - running in this process: abort it, then let the worker record `cancelled` as it unwinds;
|
|
432
|
+
* - persisted and not finished (another process, or a dead one): write `cancelled` with a
|
|
433
|
+
* `parent-cancel` interruption, so the record stops claiming it is queued or running;
|
|
434
|
+
* - already finished: report that, and change nothing — a terminal state is sticky;
|
|
435
|
+
* - unknown id: say so.
|
|
436
|
+
*/
|
|
437
|
+
stopAgentTask(agentTaskId: string): {
|
|
438
|
+
ok: boolean;
|
|
439
|
+
state?: AgentTaskState;
|
|
440
|
+
reason: string;
|
|
441
|
+
};
|
|
352
442
|
/** Abort a run that is in flight, recording WHY so a task can tell a pause from a cancellation. */
|
|
353
443
|
private abortLiveRun;
|
|
354
444
|
/** Mark an execution paused (it can be resumed later). */
|