@clearideas/agent-runtime-cli 0.3.1 → 0.4.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.
Files changed (3) hide show
  1. package/README.md +10 -1
  2. package/dist/index.js +20 -4
  3. package/package.json +11 -11
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 resume run_123 --store ./.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") || parsed.options.has("run-id"))) {
513
- throw new Error("--variables and --run-id cannot be combined with an agent run manifest; declare them in the agent run manifest.");
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
  });
@@ -815,6 +830,7 @@ export const executeWorkerInvocation = async (invocation, options) => {
815
830
  ...(request.runId ? { runId: request.runId } : {}),
816
831
  ...(invocationVariables ? { variables: invocationVariables } : {}),
817
832
  ...(request.execution ? { execution: request.execution } : {}),
833
+ ...(request.budget ? { budget: request.budget } : {}),
818
834
  ...(options.signal ? { signal: options.signal } : {}),
819
835
  ...(invocation.action === "resume"
820
836
  ? {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clearideas/agent-runtime-cli",
3
- "version": "0.3.1",
3
+ "version": "0.4.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,16 +40,16 @@
40
40
  "postpack": "node ../../scripts/cleanup-package-license.mjs"
41
41
  },
42
42
  "dependencies": {
43
- "@clearideas/agent-runtime-condition-jexl": "0.3.1",
44
- "@clearideas/agent-runtime-config": "0.3.1",
45
- "@clearideas/agent-runtime-contracts": "0.3.1",
46
- "@clearideas/agent-runtime-core": "0.3.1",
47
- "@clearideas/agent-runtime-execution": "0.3.1",
48
- "@clearideas/agent-runtime-step-loop": "0.3.1",
49
- "@clearideas/agent-runtime-step-prompt": "0.3.1",
50
- "@clearideas/agent-runtime-step-standard": "0.3.1",
51
- "@clearideas/agent-runtime-store-local": "0.3.1",
52
- "@clearideas/agent-runtime-store-sqlite": "0.3.1"
43
+ "@clearideas/agent-runtime-condition-jexl": "0.4.0",
44
+ "@clearideas/agent-runtime-config": "0.4.0",
45
+ "@clearideas/agent-runtime-contracts": "0.4.0",
46
+ "@clearideas/agent-runtime-core": "0.4.0",
47
+ "@clearideas/agent-runtime-execution": "0.4.0",
48
+ "@clearideas/agent-runtime-step-loop": "0.4.0",
49
+ "@clearideas/agent-runtime-step-prompt": "0.4.0",
50
+ "@clearideas/agent-runtime-step-standard": "0.4.0",
51
+ "@clearideas/agent-runtime-store-local": "0.4.0",
52
+ "@clearideas/agent-runtime-store-sqlite": "0.4.0"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/node": "^26.1.2",