@clearideas/agent-runtime-cli 0.9.0 → 0.10.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/NOTICE +2 -2
- package/README.md +14 -0
- package/dist/index.js +104 -10
- package/package.json +8 -8
package/NOTICE
CHANGED
|
@@ -3,6 +3,6 @@ Copyright 2026 Clear Ideas Incorporated
|
|
|
3
3
|
|
|
4
4
|
Clear Ideas is a trademark of Clear Ideas Incorporated.
|
|
5
5
|
|
|
6
|
-
The documentation site includes @clearideas/analytics 1.
|
|
6
|
+
The documentation site includes @clearideas/consent-analytics 0.1.0-rc.1, distributed
|
|
7
7
|
under the MIT License. Its license text is available at
|
|
8
|
-
docs/public/assets/analytics/LICENSE.clearideas-analytics.txt.
|
|
8
|
+
docs/public/assets/analytics/LICENSE.clearideas-consent-analytics.txt.
|
package/README.md
CHANGED
|
@@ -20,6 +20,9 @@ npx agent-runtime connections inspect ./agent-runtime.config.yaml --format yaml
|
|
|
20
20
|
npx agent-runtime run ./agent.yaml --config ./agent-runtime.config.yaml --store ./.agent-runtime
|
|
21
21
|
npx agent-runtime run ./agent.yaml --max-total-tokens 100000 --store ./.agent-runtime
|
|
22
22
|
npx agent-runtime resume run_123 --max-total-tokens 150000 --store ./.agent-runtime
|
|
23
|
+
npx agent-runtime resume run_123 --limits ./raised-limits.yaml --store ./.agent-runtime
|
|
24
|
+
npx agent-runtime restart run_123 --list --store ./.agent-runtime
|
|
25
|
+
npx agent-runtime restart run_123 --from review --run-id run_124 --store ./.agent-runtime
|
|
23
26
|
npx agent-runtime inspect run_123 --store ./.agent-runtime
|
|
24
27
|
npx agent-runtime events ./.agent-runtime/events.jsonl --run run_123 --tail 20
|
|
25
28
|
npx agent-runtime examples run variables --stream
|
|
@@ -30,6 +33,17 @@ npx agent-runtime serve --server-config ./agent-runtime.server.yaml
|
|
|
30
33
|
|
|
31
34
|
Options accept `--name value` or `--name=value`.
|
|
32
35
|
|
|
36
|
+
A run that reaches one of its limits, or whose step fails with an error that is
|
|
37
|
+
not fatal, is blocked rather than failed; the pretty view prints why. A
|
|
38
|
+
runtime module can export `limits` (replacing default run limits) and
|
|
39
|
+
`enforcedLimits` (ceilings) for every run.
|
|
40
|
+
`--limits` grants higher limits from a JSON or YAML file (for example
|
|
41
|
+
`maxTotalTokens: 50000000`) for that attempt and later ones. `inspect` shows
|
|
42
|
+
the run, its latest checkpoint (including `ledger.blocked`), and its restart
|
|
43
|
+
points. `restart` starts a new run from a completed step of another run: the
|
|
44
|
+
last one by default, or the one `--from` names by step path, execution key, or
|
|
45
|
+
checkpoint sequence.
|
|
46
|
+
|
|
33
47
|
`--stream` shows model text on stdout and lifecycle progress on stderr. Use
|
|
34
48
|
`--format ndjson` for a machine-readable stream containing event and result
|
|
35
49
|
messages, and `--show-reasoning` to opt into reasoning deltas in the pretty
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFile, writeFile } from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
-
import { messagesSignatureSchema, parseAgentVariableOverrides, parseConversationMessages, } from "@clearideas/agent-runtime-contracts";
|
|
4
|
+
import { messagesSignatureSchema, parseAgentVariableOverrides, parseConversationMessages, runLimitsSchema, } from "@clearideas/agent-runtime-contracts";
|
|
5
5
|
import { AgentRuntime, } from "@clearideas/agent-runtime-core";
|
|
6
6
|
import { EXECUTION_PROTOCOL_VERSION, parseWorkerInvocation, serializeWorkerMessage, } from "@clearideas/agent-runtime-execution";
|
|
7
7
|
import { discoverMcpConnectionTools, loadAgentRuntimeConfig, parseAgentRuntimeConfig, validateRuntimeConfiguration, } from "@clearideas/agent-runtime-config";
|
|
@@ -18,9 +18,10 @@ Usage:
|
|
|
18
18
|
agent-runtime validate <manifest.json|manifest.yaml> [--config <config.yaml>]
|
|
19
19
|
agent-runtime config validate <config.json|config.yaml>
|
|
20
20
|
agent-runtime connections inspect <config.json|config.yaml> [--connection <name>] [--runtime-module <local-js-file>] [--format <json|yaml>]
|
|
21
|
-
agent-runtime run <manifest.json|manifest.yaml> [--variables <overrides.json>] [--messages <messages.json|messages.yaml>] [--messages-scope <scope>] [--messages-out <file>] [--max-total-tokens <count>] [--config <config.yaml>] [--run-id <id>] [--store <path>] [--store-driver <file|sqlite>] [--events <file|none>] [--artifacts <directory|none>] [--runtime-module <local-js-file>] [--stream] [--format <json|pretty|ndjson>] [--show-reasoning]
|
|
21
|
+
agent-runtime run <manifest.json|manifest.yaml> [--variables <overrides.json>] [--messages <messages.json|messages.yaml>] [--messages-scope <scope>] [--messages-out <file>] [--max-total-tokens <count>] [--limits <limits.json|limits.yaml>] [--config <config.yaml>] [--run-id <id>] [--store <path>] [--store-driver <file|sqlite>] [--events <file|none>] [--artifacts <directory|none>] [--runtime-module <local-js-file>] [--stream] [--format <json|pretty|ndjson>] [--show-reasoning]
|
|
22
22
|
agent-runtime run-manifest <run.json|run.yaml> [--messages-scope <scope>] [--messages-out <file>] [--config <config.yaml>] [--store <path>] [--store-driver <file|sqlite>] [--events <file|none>] [--artifacts <directory|none>] [--runtime-module <local-js-file>] [--stream] [--format <json|pretty|ndjson>] [--show-reasoning]
|
|
23
|
-
agent-runtime resume <run-id> [--max-total-tokens <count>] [--config <config.yaml>] [--store <path>] [--store-driver <file|sqlite>] [--events <file|none>] [--artifacts <directory|none>] [--runtime-module <local-js-file>] [--stream] [--format <json|pretty|ndjson>] [--show-reasoning]
|
|
23
|
+
agent-runtime resume <run-id> [--max-total-tokens <count>] [--limits <limits.json|limits.yaml>] [--config <config.yaml>] [--store <path>] [--store-driver <file|sqlite>] [--events <file|none>] [--artifacts <directory|none>] [--runtime-module <local-js-file>] [--stream] [--format <json|pretty|ndjson>] [--show-reasoning]
|
|
24
|
+
agent-runtime restart <run-id> [--from <step-path|execution-key|sequence>] [--list] [--run-id <new-id>] [--max-total-tokens <count>] [--limits <limits.json|limits.yaml>] [--config <config.yaml>] [--store <path>] [--store-driver <file|sqlite>] [--events <file|none>] [--artifacts <directory|none>] [--runtime-module <local-js-file>] [--stream] [--format <json|pretty|ndjson>] [--show-reasoning]
|
|
24
25
|
agent-runtime inspect <run-id> [--store <path>] [--store-driver <file|sqlite>] [--runtime-module <local-js-file>]
|
|
25
26
|
agent-runtime events <events.jsonl> [--run <run-id>] [--type <event-type>] [--tail <count>]
|
|
26
27
|
agent-runtime examples list
|
|
@@ -292,7 +293,11 @@ const inspect = async (args, io) => {
|
|
|
292
293
|
if (!run)
|
|
293
294
|
throw new Error(`Run not found: ${runId}`);
|
|
294
295
|
const checkpoint = await store.loadLatestCheckpoint(runId);
|
|
295
|
-
|
|
296
|
+
// The steps a new run can restart from (agent-runtime restart --from).
|
|
297
|
+
const restartPoints = store.listCheckpoints
|
|
298
|
+
? await store.listCheckpoints(runId, { boundaries: true })
|
|
299
|
+
: undefined;
|
|
300
|
+
io.stdout(`${JSON.stringify({ run, checkpoint, ...(restartPoints ? { restartPoints } : {}) }, null, 2)}\n`);
|
|
296
301
|
}
|
|
297
302
|
finally {
|
|
298
303
|
resolved.close();
|
|
@@ -434,8 +439,24 @@ class CliStreamingEventSink {
|
|
|
434
439
|
return `✓ run completed (${event.runId})`;
|
|
435
440
|
case "run.failed":
|
|
436
441
|
return `✗ run failed (${event.runId})`;
|
|
437
|
-
case "run.suspended":
|
|
442
|
+
case "run.suspended": {
|
|
443
|
+
const details = event.data?.details != null &&
|
|
444
|
+
typeof event.data.details === "object" &&
|
|
445
|
+
!Array.isArray(event.data.details)
|
|
446
|
+
? event.data.details
|
|
447
|
+
: {};
|
|
448
|
+
if (event.data?.kind === "awaiting-host" && details.cause === "limit")
|
|
449
|
+
return `Ⅱ run blocked (${event.runId}): reached ${String(details.limit)} (${String(details.used)} of ${String(details.value)}); grant a higher limit with agent-runtime resume ${event.runId} --limits <file>`;
|
|
450
|
+
if (event.data?.kind === "awaiting-host") {
|
|
451
|
+
const error = details.error != null &&
|
|
452
|
+
typeof details.error === "object" &&
|
|
453
|
+
!Array.isArray(details.error)
|
|
454
|
+
? details.error
|
|
455
|
+
: {};
|
|
456
|
+
return `Ⅱ run blocked (${event.runId}): ${String(error.code ?? "error")}: ${String(error.message ?? "")}; fix the cause, then agent-runtime resume ${event.runId}`;
|
|
457
|
+
}
|
|
438
458
|
return `Ⅱ run suspended (${event.runId}): ${String(event.data?.reason ?? "awaiting input")}; resume with agent-runtime resume ${event.runId}`;
|
|
459
|
+
}
|
|
439
460
|
case "run.interrupted":
|
|
440
461
|
return `↯ run interrupted (${event.runId}): ${String(event.data?.reason ?? "interrupted")}; resume with agent-runtime resume ${event.runId}`;
|
|
441
462
|
case "step.failed":
|
|
@@ -462,6 +483,24 @@ class CliStreamingEventSink {
|
|
|
462
483
|
* Read `--messages`: a JSON or YAML array of messages, or `{ messages,
|
|
463
484
|
* signature }` as written by `--messages-out`.
|
|
464
485
|
*/
|
|
486
|
+
/** Run limits to grant, from a JSON or YAML file (`--limits`). */
|
|
487
|
+
const readLimitsFile = async (file) => {
|
|
488
|
+
const source = await readFile(file, "utf8");
|
|
489
|
+
let value;
|
|
490
|
+
try {
|
|
491
|
+
value = file.endsWith(".json")
|
|
492
|
+
? JSON.parse(source)
|
|
493
|
+
: parseYamlDocument(source);
|
|
494
|
+
}
|
|
495
|
+
catch (error) {
|
|
496
|
+
throw new Error(`Could not parse run limits ${file}: ${error instanceof Error ? error.message : String(error)}`);
|
|
497
|
+
}
|
|
498
|
+
const parsed = runLimitsSchema.safeParse(value);
|
|
499
|
+
if (!parsed.success) {
|
|
500
|
+
throw new Error(`Run limits in ${file} are invalid: ${parsed.error.issues.map((issue) => `${issue.path.join(".") || "limits"}: ${issue.message}`).join("; ")}`);
|
|
501
|
+
}
|
|
502
|
+
return parsed.data;
|
|
503
|
+
};
|
|
465
504
|
const readMessagesFile = async (file) => {
|
|
466
505
|
const source = await readFile(file, "utf8");
|
|
467
506
|
let value;
|
|
@@ -499,8 +538,11 @@ const executionOptions = new Set([
|
|
|
499
538
|
"format",
|
|
500
539
|
"show-reasoning",
|
|
501
540
|
"max-total-tokens",
|
|
541
|
+
"limits",
|
|
542
|
+
"from",
|
|
543
|
+
"list",
|
|
502
544
|
]);
|
|
503
|
-
const executionFlags = new Set(["stream", "show-reasoning"]);
|
|
545
|
+
const executionFlags = new Set(["stream", "show-reasoning", "list"]);
|
|
504
546
|
const execute = async (command, args, io, signal) => {
|
|
505
547
|
const parsed = parseOptions(args, executionOptions, executionFlags);
|
|
506
548
|
const target = requireOnePositional(parsed, command === "run"
|
|
@@ -508,6 +550,14 @@ const execute = async (command, args, io, signal) => {
|
|
|
508
550
|
: command === "run-manifest"
|
|
509
551
|
? "agent run manifest path"
|
|
510
552
|
: "run id");
|
|
553
|
+
if (command !== "restart" &&
|
|
554
|
+
(parsed.options.has("from") || parsed.options.has("list"))) {
|
|
555
|
+
throw new Error("--from and --list are only valid with the restart command.");
|
|
556
|
+
}
|
|
557
|
+
if (command === "restart" &&
|
|
558
|
+
(parsed.options.has("variables") || parsed.options.has("messages"))) {
|
|
559
|
+
throw new Error("A restarted run takes its state and history from the step it restarts from; --variables and --messages are not valid with restart.");
|
|
560
|
+
}
|
|
511
561
|
if (command === "resume" && parsed.options.has("run-id")) {
|
|
512
562
|
throw new Error("--run-id is only valid with the run command.");
|
|
513
563
|
}
|
|
@@ -526,8 +576,9 @@ const execute = async (command, args, io, signal) => {
|
|
|
526
576
|
if (command === "run-manifest" &&
|
|
527
577
|
(parsed.options.has("variables") ||
|
|
528
578
|
parsed.options.has("run-id") ||
|
|
529
|
-
parsed.options.has("max-total-tokens")
|
|
530
|
-
|
|
579
|
+
parsed.options.has("max-total-tokens") ||
|
|
580
|
+
parsed.options.has("limits"))) {
|
|
581
|
+
throw new Error("--variables, --run-id, --max-total-tokens, and --limits cannot be combined with an agent run manifest; declare them in the agent run manifest or the agent manifest.");
|
|
531
582
|
}
|
|
532
583
|
const agentRunManifestFile = command === "run-manifest" ? path.resolve(target) : undefined;
|
|
533
584
|
const agentRunManifestSource = agentRunManifestFile
|
|
@@ -546,9 +597,10 @@ const execute = async (command, args, io, signal) => {
|
|
|
546
597
|
const runId = command === "resume"
|
|
547
598
|
? target
|
|
548
599
|
: (agentRunManifest?.runId ?? parsed.options.get("run-id"));
|
|
600
|
+
const sourceRunId = command === "restart" ? target : undefined;
|
|
549
601
|
const maxTotalTokens = positiveSafeIntegerOption(parsed, "max-total-tokens");
|
|
550
602
|
const runtimeModulePath = parsed.options.get("runtime-module");
|
|
551
|
-
const runtimeStore = command === "resume"
|
|
603
|
+
const runtimeStore = command === "resume" || command === "restart"
|
|
552
604
|
? await loadHostRunStore(runtimeModulePath, {
|
|
553
605
|
runId: target,
|
|
554
606
|
storeDirectory,
|
|
@@ -561,6 +613,9 @@ const execute = async (command, args, io, signal) => {
|
|
|
561
613
|
const variableOverrides = command === "run" && parsed.options.has("variables")
|
|
562
614
|
? parseAgentVariableOverrides(JSON.parse(await readFile(path.resolve(parsed.options.get("variables")), "utf8")))
|
|
563
615
|
: undefined;
|
|
616
|
+
const grantedLimits = parsed.options.has("limits")
|
|
617
|
+
? await readLimitsFile(path.resolve(parsed.options.get("limits")))
|
|
618
|
+
: undefined;
|
|
564
619
|
const suppliedMessages = command === "run" && parsed.options.has("messages")
|
|
565
620
|
? await readMessagesFile(path.resolve(parsed.options.get("messages")))
|
|
566
621
|
: undefined;
|
|
@@ -583,6 +638,41 @@ const execute = async (command, args, io, signal) => {
|
|
|
583
638
|
throw new Error(`Run not found: ${target}`);
|
|
584
639
|
manifest = record.manifest;
|
|
585
640
|
}
|
|
641
|
+
// restart: choose the step checkpoint to start the new run from.
|
|
642
|
+
let seed;
|
|
643
|
+
if (sourceRunId) {
|
|
644
|
+
if (!store.listCheckpoints || !store.loadCheckpoint) {
|
|
645
|
+
throw new Error("This run store cannot list checkpoints, so runs cannot be restarted from a step.");
|
|
646
|
+
}
|
|
647
|
+
const points = await store.listCheckpoints(sourceRunId, {
|
|
648
|
+
boundaries: true,
|
|
649
|
+
});
|
|
650
|
+
if (parsed.options.has("list")) {
|
|
651
|
+
io.stdout(points.length === 0
|
|
652
|
+
? `No restart points for run ${sourceRunId}.\n`
|
|
653
|
+
: `${points
|
|
654
|
+
.map((point) => `${String(point.sequence).padStart(6)} ${point.boundary?.executionKey ?? point.boundary?.stepPath ?? ""} ${point.createdAt}`)
|
|
655
|
+
.join("\n")}\n`);
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
const from = parsed.options.get("from");
|
|
659
|
+
const chosen = from
|
|
660
|
+
? [...points]
|
|
661
|
+
.reverse()
|
|
662
|
+
.find((point) => point.boundary?.executionKey === from ||
|
|
663
|
+
point.boundary?.stepPath === from ||
|
|
664
|
+
String(point.sequence) === from)
|
|
665
|
+
: points.at(-1);
|
|
666
|
+
if (!chosen) {
|
|
667
|
+
throw new Error(from
|
|
668
|
+
? `Run ${sourceRunId} has no restart point matching ${from}; list them with agent-runtime restart ${sourceRunId} --list.`
|
|
669
|
+
: `Run ${sourceRunId} has no completed step to restart from.`);
|
|
670
|
+
}
|
|
671
|
+
seed =
|
|
672
|
+
(await store.loadCheckpoint(sourceRunId, chosen.sequence)) ?? undefined;
|
|
673
|
+
if (!seed)
|
|
674
|
+
throw new Error(`Checkpoint ${chosen.sequence} is no longer retained.`);
|
|
675
|
+
}
|
|
586
676
|
const eventsOption = parsed.options.get("events");
|
|
587
677
|
const eventFile = eventsOption === "none"
|
|
588
678
|
? undefined
|
|
@@ -657,6 +747,8 @@ const execute = async (command, args, io, signal) => {
|
|
|
657
747
|
: {}),
|
|
658
748
|
...(messagesScope != null ? { messagesScope } : {}),
|
|
659
749
|
...(maxTotalTokens ? { budget: { maxTotalTokens } } : {}),
|
|
750
|
+
...(grantedLimits ? { limits: grantedLimits } : {}),
|
|
751
|
+
...(seed ? { seed } : {}),
|
|
660
752
|
...(signal ? { signal } : {}),
|
|
661
753
|
...(command === "resume" ? { resume: true } : {}),
|
|
662
754
|
});
|
|
@@ -881,6 +973,7 @@ export const executeWorkerInvocation = async (invocation, options) => {
|
|
|
881
973
|
: {}),
|
|
882
974
|
...(request.execution ? { execution: request.execution } : {}),
|
|
883
975
|
...(request.budget ? { budget: request.budget } : {}),
|
|
976
|
+
...(request.limits ? { limits: request.limits } : {}),
|
|
884
977
|
...(options.signal ? { signal: options.signal } : {}),
|
|
885
978
|
...(invocation.action === "resume"
|
|
886
979
|
? {
|
|
@@ -1139,7 +1232,8 @@ export const runCli = async (args, io = defaultIo, options = {}) => {
|
|
|
1139
1232
|
await examples(commandArgs, io, options.signal);
|
|
1140
1233
|
else if (command === "run" ||
|
|
1141
1234
|
command === "run-manifest" ||
|
|
1142
|
-
command === "resume"
|
|
1235
|
+
command === "resume" ||
|
|
1236
|
+
command === "restart") {
|
|
1143
1237
|
await execute(command, commandArgs, io, options.signal);
|
|
1144
1238
|
}
|
|
1145
1239
|
else if (command === "worker")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clearideas/agent-runtime-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Standalone CLI for validating, running, resuming, and inspecting declarative agents.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Clear Ideas Incorporated",
|
|
@@ -40,13 +40,13 @@
|
|
|
40
40
|
"postpack": "node ../../scripts/cleanup-package-license.mjs"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@clearideas/agent-runtime-config": "0.
|
|
44
|
-
"@clearideas/agent-runtime-contracts": "0.
|
|
45
|
-
"@clearideas/agent-runtime-core": "0.
|
|
46
|
-
"@clearideas/agent-runtime-execution": "0.
|
|
47
|
-
"@clearideas/agent-runtime-server": "0.
|
|
48
|
-
"@clearideas/agent-runtime-store-local": "0.
|
|
49
|
-
"@clearideas/agent-runtime-store-sqlite": "0.
|
|
43
|
+
"@clearideas/agent-runtime-config": "0.10.0",
|
|
44
|
+
"@clearideas/agent-runtime-contracts": "0.10.0",
|
|
45
|
+
"@clearideas/agent-runtime-core": "0.10.0",
|
|
46
|
+
"@clearideas/agent-runtime-execution": "0.10.0",
|
|
47
|
+
"@clearideas/agent-runtime-server": "0.10.0",
|
|
48
|
+
"@clearideas/agent-runtime-store-local": "0.10.0",
|
|
49
|
+
"@clearideas/agent-runtime-store-sqlite": "0.10.0",
|
|
50
50
|
"yaml": "^2.9.1"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|