@clearideas/agent-runtime-cli 0.3.1 → 0.4.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/README.md +10 -1
- package/dist/index.js +40 -5
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -16,7 +16,8 @@ The CLI stores run state and events locally by default.
|
|
|
16
16
|
npx agent-runtime validate ./agent.yaml
|
|
17
17
|
npx agent-runtime config validate ./agent-runtime.config.yaml
|
|
18
18
|
npx agent-runtime run ./agent.yaml --config ./agent-runtime.config.yaml --store ./.agent-runtime
|
|
19
|
-
npx agent-runtime
|
|
19
|
+
npx agent-runtime run ./agent.yaml --max-total-tokens 100000 --store ./.agent-runtime
|
|
20
|
+
npx agent-runtime resume run_123 --max-total-tokens 150000 --store ./.agent-runtime
|
|
20
21
|
npx agent-runtime inspect run_123 --store ./.agent-runtime
|
|
21
22
|
npx agent-runtime events ./.agent-runtime/events.jsonl --run run_123 --tail 20
|
|
22
23
|
npx agent-runtime examples run variables --stream
|
|
@@ -126,6 +127,8 @@ agent:
|
|
|
126
127
|
schemaVersion: "1.0"
|
|
127
128
|
agent:
|
|
128
129
|
ref: release.agent.yaml
|
|
130
|
+
budget:
|
|
131
|
+
maxTotalTokens: 100000
|
|
129
132
|
variables:
|
|
130
133
|
- key: audience
|
|
131
134
|
value: partners
|
|
@@ -204,6 +207,12 @@ Agent run manifests may select sequential or dependency-safe parallel step
|
|
|
204
207
|
scheduling. Resume uses the latest checkpoint and rejects a completed run or a
|
|
205
208
|
manifest/checkpoint mismatch.
|
|
206
209
|
|
|
210
|
+
`--max-total-tokens` sets the cumulative reported-token limit for a direct run
|
|
211
|
+
or replaces the persisted limit during resume. Agent run manifests declare the
|
|
212
|
+
same value as `budget.maxTotalTokens`. A resume without a higher effective
|
|
213
|
+
limit suspends again before another model call. Budgeted runs are scheduled
|
|
214
|
+
sequentially to keep enforcement deterministic.
|
|
215
|
+
|
|
207
216
|
## Worker command
|
|
208
217
|
|
|
209
218
|
`agent-runtime worker` reads one versioned invocation from stdin and writes
|
package/dist/index.js
CHANGED
|
@@ -19,9 +19,9 @@ const usage = `Clear Ideas Agent Runtime
|
|
|
19
19
|
Usage:
|
|
20
20
|
agent-runtime validate <manifest.json|manifest.yaml> [--config <config.yaml>]
|
|
21
21
|
agent-runtime config validate <config.json|config.yaml>
|
|
22
|
-
agent-runtime run <manifest.json|manifest.yaml> [--variables <overrides.json>] [--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
|
+
agent-runtime run <manifest.json|manifest.yaml> [--variables <overrides.json>] [--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]
|
|
23
23
|
agent-runtime run-manifest <run.json|run.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 resume <run-id> [--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 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]
|
|
25
25
|
agent-runtime inspect <run-id> [--store <path>] [--store-driver <file|sqlite>] [--runtime-module <local-js-file>]
|
|
26
26
|
agent-runtime events <events.jsonl> [--run <run-id>] [--type <event-type>] [--tail <count>]
|
|
27
27
|
agent-runtime examples list
|
|
@@ -107,6 +107,16 @@ const requireOnePositional = (parsed, label) => {
|
|
|
107
107
|
throw new Error(`Expected exactly one ${label}.`);
|
|
108
108
|
return parsed.positional[0];
|
|
109
109
|
};
|
|
110
|
+
const positiveSafeIntegerOption = (parsed, name) => {
|
|
111
|
+
const value = parsed.options.get(name);
|
|
112
|
+
if (value == null)
|
|
113
|
+
return undefined;
|
|
114
|
+
const parsedValue = Number(value);
|
|
115
|
+
if (!Number.isSafeInteger(parsedValue) || parsedValue <= 0) {
|
|
116
|
+
throw new Error(`--${name} must be a positive safe integer.`);
|
|
117
|
+
}
|
|
118
|
+
return parsedValue;
|
|
119
|
+
};
|
|
110
120
|
const validateManifest = async (args, io) => {
|
|
111
121
|
const parsed = parseOptions(args, new Set(["config"]));
|
|
112
122
|
const file = path.resolve(requireOnePositional(parsed, "manifest path"));
|
|
@@ -493,6 +503,7 @@ const executionOptions = new Set([
|
|
|
493
503
|
"stream",
|
|
494
504
|
"format",
|
|
495
505
|
"show-reasoning",
|
|
506
|
+
"max-total-tokens",
|
|
496
507
|
]);
|
|
497
508
|
const executionFlags = new Set(["stream", "show-reasoning"]);
|
|
498
509
|
const execute = async (command, args, io, signal) => {
|
|
@@ -509,8 +520,10 @@ const execute = async (command, args, io, signal) => {
|
|
|
509
520
|
throw new Error("--variables is only valid with the run command.");
|
|
510
521
|
}
|
|
511
522
|
if (command === "run-manifest" &&
|
|
512
|
-
(parsed.options.has("variables") ||
|
|
513
|
-
|
|
523
|
+
(parsed.options.has("variables") ||
|
|
524
|
+
parsed.options.has("run-id") ||
|
|
525
|
+
parsed.options.has("max-total-tokens"))) {
|
|
526
|
+
throw new Error("--variables, --run-id, and --max-total-tokens cannot be combined with an agent run manifest; declare them in the agent run manifest.");
|
|
514
527
|
}
|
|
515
528
|
const agentRunManifestFile = command === "run-manifest" ? path.resolve(target) : undefined;
|
|
516
529
|
const agentRunManifestSource = agentRunManifestFile
|
|
@@ -527,6 +540,7 @@ const execute = async (command, args, io, signal) => {
|
|
|
527
540
|
const runId = command === "resume"
|
|
528
541
|
? target
|
|
529
542
|
: (agentRunManifest?.runId ?? parsed.options.get("run-id"));
|
|
543
|
+
const maxTotalTokens = positiveSafeIntegerOption(parsed, "max-total-tokens");
|
|
530
544
|
const runtimeModulePath = parsed.options.get("runtime-module");
|
|
531
545
|
const runtimeStore = command === "resume"
|
|
532
546
|
? await loadRuntimeStore(runtimeModulePath, {
|
|
@@ -630,6 +644,7 @@ const execute = async (command, args, io, signal) => {
|
|
|
630
644
|
manifest,
|
|
631
645
|
...(runId ? { runId } : {}),
|
|
632
646
|
...(variableOverrides ? { variables: variableOverrides } : {}),
|
|
647
|
+
...(maxTotalTokens ? { budget: { maxTotalTokens } } : {}),
|
|
633
648
|
...(signal ? { signal } : {}),
|
|
634
649
|
...(command === "resume" ? { resume: true } : {}),
|
|
635
650
|
});
|
|
@@ -662,6 +677,16 @@ const execute = async (command, args, io, signal) => {
|
|
|
662
677
|
await jsonlSink?.flush();
|
|
663
678
|
}
|
|
664
679
|
};
|
|
680
|
+
const assertSafeInlineWorkerConfiguration = (config) => {
|
|
681
|
+
const customDestinationProvider = Object.entries(config.providers).find(([, definition]) => definition.baseURL != null);
|
|
682
|
+
if (customDestinationProvider) {
|
|
683
|
+
throw new Error(`Inline worker configuration cannot define provider baseURL values; use a trusted configReference for provider "${customDestinationProvider[0]}".`);
|
|
684
|
+
}
|
|
685
|
+
if (Object.keys(config.connections).length > 0) {
|
|
686
|
+
throw new Error("Inline worker configuration cannot define MCP connections; use a trusted configReference.");
|
|
687
|
+
}
|
|
688
|
+
};
|
|
689
|
+
const MAXIMUM_WORKER_INPUT_BYTES = 16 * 1024 * 1024;
|
|
665
690
|
class PortableWorkerEventSink {
|
|
666
691
|
#onMessage;
|
|
667
692
|
constructor(onMessage) {
|
|
@@ -721,6 +746,9 @@ export const executeWorkerInvocation = async (invocation, options) => {
|
|
|
721
746
|
throw new Error("Worker request configReference requires a host resolveConfigReference callback.");
|
|
722
747
|
})()
|
|
723
748
|
: await resolveConfig(undefined, process.cwd());
|
|
749
|
+
if (requestSuppliedConfiguration) {
|
|
750
|
+
assertSafeInlineWorkerConfiguration(config);
|
|
751
|
+
}
|
|
724
752
|
const configuredRuntime = composeRuntime(manifest, config, requestSuppliedConfiguration
|
|
725
753
|
? { environment: options.environment ?? {} }
|
|
726
754
|
: options.environment
|
|
@@ -815,6 +843,7 @@ export const executeWorkerInvocation = async (invocation, options) => {
|
|
|
815
843
|
...(request.runId ? { runId: request.runId } : {}),
|
|
816
844
|
...(invocationVariables ? { variables: invocationVariables } : {}),
|
|
817
845
|
...(request.execution ? { execution: request.execution } : {}),
|
|
846
|
+
...(request.budget ? { budget: request.budget } : {}),
|
|
818
847
|
...(options.signal ? { signal: options.signal } : {}),
|
|
819
848
|
...(invocation.action === "resume"
|
|
820
849
|
? {
|
|
@@ -829,8 +858,14 @@ export const executeWorkerInvocation = async (invocation, options) => {
|
|
|
829
858
|
const readStandardInput = async () => {
|
|
830
859
|
process.stdin.setEncoding("utf8");
|
|
831
860
|
let source = "";
|
|
832
|
-
|
|
861
|
+
let byteLength = 0;
|
|
862
|
+
for await (const chunk of process.stdin) {
|
|
863
|
+
byteLength += Buffer.byteLength(chunk, "utf8");
|
|
864
|
+
if (byteLength > MAXIMUM_WORKER_INPUT_BYTES) {
|
|
865
|
+
throw new Error("Worker invocation exceeds the input size limit.");
|
|
866
|
+
}
|
|
833
867
|
source += chunk;
|
|
868
|
+
}
|
|
834
869
|
return source;
|
|
835
870
|
};
|
|
836
871
|
const worker = async (args, io, signal) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clearideas/agent-runtime-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
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,19 +40,19 @@
|
|
|
40
40
|
"postpack": "node ../../scripts/cleanup-package-license.mjs"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@clearideas/agent-runtime-condition-jexl": "0.
|
|
44
|
-
"@clearideas/agent-runtime-config": "0.
|
|
45
|
-
"@clearideas/agent-runtime-contracts": "0.
|
|
46
|
-
"@clearideas/agent-runtime-core": "0.
|
|
47
|
-
"@clearideas/agent-runtime-execution": "0.
|
|
48
|
-
"@clearideas/agent-runtime-step-loop": "0.
|
|
49
|
-
"@clearideas/agent-runtime-step-prompt": "0.
|
|
50
|
-
"@clearideas/agent-runtime-step-standard": "0.
|
|
51
|
-
"@clearideas/agent-runtime-store-local": "0.
|
|
52
|
-
"@clearideas/agent-runtime-store-sqlite": "0.
|
|
43
|
+
"@clearideas/agent-runtime-condition-jexl": "0.4.1",
|
|
44
|
+
"@clearideas/agent-runtime-config": "0.4.1",
|
|
45
|
+
"@clearideas/agent-runtime-contracts": "0.4.1",
|
|
46
|
+
"@clearideas/agent-runtime-core": "0.4.1",
|
|
47
|
+
"@clearideas/agent-runtime-execution": "0.4.1",
|
|
48
|
+
"@clearideas/agent-runtime-step-loop": "0.4.1",
|
|
49
|
+
"@clearideas/agent-runtime-step-prompt": "0.4.1",
|
|
50
|
+
"@clearideas/agent-runtime-step-standard": "0.4.1",
|
|
51
|
+
"@clearideas/agent-runtime-store-local": "0.4.1",
|
|
52
|
+
"@clearideas/agent-runtime-store-sqlite": "0.4.1"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@types/node": "^26.
|
|
55
|
+
"@types/node": "^26.2.0",
|
|
56
56
|
"typescript": "^7.0.2",
|
|
57
57
|
"vitest": "^4.0.18"
|
|
58
58
|
},
|