@clearideas/agent-runtime-cli 0.5.0 → 0.6.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/README.md CHANGED
@@ -15,6 +15,7 @@ The CLI stores run state and events locally by default.
15
15
  ```sh
16
16
  npx agent-runtime validate ./agent.yaml
17
17
  npx agent-runtime config validate ./agent-runtime.config.yaml
18
+ npx agent-runtime connections inspect ./agent-runtime.config.yaml --format yaml
18
19
  npx agent-runtime run ./agent.yaml --config ./agent-runtime.config.yaml --store ./.agent-runtime
19
20
  npx agent-runtime run ./agent.yaml --max-total-tokens 100000 --store ./.agent-runtime
20
21
  npx agent-runtime resume run_123 --max-total-tokens 150000 --store ./.agent-runtime
@@ -47,7 +48,9 @@ The Ollama configuration uses its OpenAI-compatible endpoint at
47
48
  The CLI automatically loads `agent-runtime.config.yaml`, `agent-runtime.config.yml`,
48
49
  or `agent-runtime.config.json` beside the agent manifest.
49
50
  Use `--config` to select another file. The CLI configures built-in providers,
50
- model profiles, and MCP connections without a JavaScript runtime module.
51
+ model profiles, MCP connections, host workspaces, and the run sandbox
52
+ (`sandbox.driver: bubblewrap` or `docker`) without a JavaScript runtime
53
+ module.
51
54
 
52
55
  ```yaml
53
56
  version: "1.0"
@@ -103,6 +106,16 @@ Configuration files contain secret references, not secret values. Native
103
106
  provider drivers use their conventional environment variables by default.
104
107
  An agent cannot elevate a connection beyond the host-configured mode.
105
108
 
109
+ MCP tool descriptions and schemas are supplied by the server and reach the
110
+ model. To pin the definitions you reviewed, run
111
+ `connections inspect <config> --format yaml`, check the printed tools, and
112
+ paste the `toolIntegrity` block into the connection. Discovery then refuses a
113
+ changed or unpinned tool before any model sees it (`onFailure: fail`, the
114
+ default) or drops only that tool (`onFailure: exclude`). The default JSON
115
+ format includes full tool metadata, digests, and `verified`, `mismatch`, or
116
+ `unpinned` status. Use `--connection <name>` for one connection and
117
+ `--runtime-module` to supply `connectionCredentials` for OAuth connections.
118
+
106
119
  ## Local storage and output
107
120
 
108
121
  Runs persist state beneath `.agent-runtime` and events in
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import type { AgentManifest, RunResult } from "@clearideas/agent-runtime-contracts";
2
- import { type ArtifactStore, type ApprovalAdapter, type ConnectionCredentialProvider, type EventSink, type ModelAdapter, type RunStore, type SandboxAdapter, type StepExecutor, type SubRunAdapter, type ToolAdapter } from "@clearideas/agent-runtime-core";
2
+ import { type ArtifactStore, type ApprovalAdapter, type ConnectionCredentialProvider, type EventSink, type ModelAdapter, type RunSandboxProvider, type RunStore, type SandboxAdapter, type StepExecutor, type SubRunAdapter, type ToolAdapter, type WorkspaceProvider } from "@clearideas/agent-runtime-core";
3
+ import type { SandboxProvider } from "@clearideas/agent-runtime-sandbox";
3
4
  import { type ExecutionRequest, type WorkerInvocation, type WorkerMessage } from "@clearideas/agent-runtime-execution";
4
- import { type AgentRuntimeConfig, type ConfiguredMcpToolAdapterOptions, type ModelAuthorizationPolicy } from "@clearideas/agent-runtime-config";
5
+ import { type AgentRuntimeConfig, type ConfiguredMcpToolAdapterOptions, type ModelAuthorizationPolicy, type WorkspaceCompositionOptions } from "@clearideas/agent-runtime-config";
5
6
  export interface CliIo {
6
7
  stdout: (text: string) => void;
7
8
  stderr: (text: string) => void;
@@ -19,6 +20,12 @@ export interface CliRuntime {
19
20
  approvals?: ApprovalAdapter;
20
21
  sandbox?: SandboxAdapter;
21
22
  subRuns?: SubRunAdapter;
23
+ /** Resolves manifest workspace bindings instead of the configuration's `workspaces` section. */
24
+ workspaces?: WorkspaceProvider;
25
+ /** Opens run sandboxes instead of the configuration's `sandbox` section. */
26
+ runSandbox?: RunSandboxProvider;
27
+ /** Backs `sandbox.driver: host` in the configuration. */
28
+ sandboxProvider?: SandboxProvider;
22
29
  eventSinks?: EventSink[];
23
30
  stepExecutors?: StepExecutor[];
24
31
  }
@@ -41,6 +48,8 @@ export interface CliRuntimeModule extends CliRuntime {
41
48
  approvalAdapter?: ApprovalAdapter;
42
49
  sandboxAdapter?: SandboxAdapter;
43
50
  subRunAdapter?: SubRunAdapter;
51
+ workspaceProvider?: WorkspaceProvider;
52
+ runSandboxProvider?: RunSandboxProvider;
44
53
  eventSink?: EventSink;
45
54
  executors?: StepExecutor[];
46
55
  }
@@ -75,6 +84,8 @@ export interface PortableWorkerOptions {
75
84
  modelPolicy?: ModelAuthorizationPolicy;
76
85
  /** Host policy and credentials applied to configured MCP adapters. */
77
86
  toolOptions?: ConfiguredMcpToolAdapterOptions;
87
+ /** Host policy, hooks, and providers applied to configured workspaces and the run sandbox. */
88
+ workspaceOptions?: WorkspaceCompositionOptions;
78
89
  /** Host-supplied adapters for embedded workers such as managed compute runtimes. */
79
90
  runtime?: CliRuntime;
80
91
  eventSinkFailurePolicy?: "continue" | "fail-run";
package/dist/index.js CHANGED
@@ -5,11 +5,12 @@ import { JexlConditionEvaluator } from "@clearideas/agent-runtime-condition-jexl
5
5
  import { parseAgentVariableOverrides } from "@clearideas/agent-runtime-contracts";
6
6
  import { AgentRuntime, } from "@clearideas/agent-runtime-core";
7
7
  import { EXECUTION_PROTOCOL_VERSION, parseWorkerInvocation, serializeWorkerMessage, } from "@clearideas/agent-runtime-execution";
8
- import { composeRuntime, emptyAgentRuntimeConfig, loadAgentRuntimeConfig, parseAgentRuntimeConfig, validateRuntimeConfiguration, } from "@clearideas/agent-runtime-config";
8
+ import { composeRuntime, discoverMcpConnectionTools, emptyAgentRuntimeConfig, loadAgentRuntimeConfig, parseAgentRuntimeConfig, validateRuntimeConfiguration, } from "@clearideas/agent-runtime-config";
9
9
  import { LoopStepExecutor } from "@clearideas/agent-runtime-step-loop";
10
10
  import { PromptStepExecutor } from "@clearideas/agent-runtime-step-prompt";
11
11
  import { ApprovalStepExecutor, CodeStepExecutor, SubRunStepExecutor, WebhookStepExecutor, } from "@clearideas/agent-runtime-step-standard";
12
12
  import { FileArtifactStore, FileAgentManifestSource, FileAgentRunManifestSource, FileRunStore, JsonlEventSink, } from "@clearideas/agent-runtime-store-local";
13
+ import { Document as YamlDocument, YAMLMap, isPair, isScalar } from "yaml";
13
14
  const defaultIo = {
14
15
  stdout: (text) => process.stdout.write(text),
15
16
  stderr: (text) => process.stderr.write(text),
@@ -19,6 +20,7 @@ const usage = `Clear Ideas Agent Runtime
19
20
  Usage:
20
21
  agent-runtime validate <manifest.json|manifest.yaml> [--config <config.yaml>]
21
22
  agent-runtime config validate <config.json|config.yaml>
23
+ agent-runtime connections inspect <config.json|config.yaml> [--connection <name>] [--runtime-module <local-js-file>] [--format <json|yaml>]
22
24
  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
25
  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
26
  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]
@@ -149,6 +151,108 @@ const validateConfig = async (args, io) => {
149
151
  providerCount: Object.keys(config.providers).length,
150
152
  modelCount: Object.keys(config.models).length,
151
153
  connectionCount: Object.keys(config.connections).length,
154
+ workspaceCount: Object.keys(config.workspaces ?? {}).length,
155
+ ...(config.sandbox ? { sandbox: config.sandbox.driver } : {}),
156
+ }, null, 2)}\n`);
157
+ };
158
+ const firstLine = (value) => value?.split(/\r?\n/u)[0]?.trim().slice(0, 100);
159
+ /** Renders a paste-ready toolIntegrity block with tool descriptions as comments. */
160
+ const toolIntegrityYaml = (discovered) => {
161
+ const document = new YamlDocument({
162
+ connections: Object.fromEntries(Object.entries(discovered).map(([name, tools]) => [
163
+ name,
164
+ {
165
+ toolIntegrity: {
166
+ digests: Object.fromEntries(tools
167
+ .filter((tool) => tool.allowed)
168
+ .map((tool) => [tool.name, tool.digest])),
169
+ },
170
+ },
171
+ ])),
172
+ });
173
+ for (const [name, tools] of Object.entries(discovered)) {
174
+ const digests = document.getIn([
175
+ "connections",
176
+ name,
177
+ "toolIntegrity",
178
+ "digests",
179
+ ]);
180
+ if (!(digests instanceof YAMLMap))
181
+ continue;
182
+ for (const item of digests.items) {
183
+ if (!isPair(item))
184
+ continue;
185
+ const key = item.key;
186
+ if (!isScalar(key))
187
+ continue;
188
+ const tool = tools.find((candidate) => candidate.name === key.value);
189
+ const summary = firstLine(tool?.description ?? tool?.title);
190
+ if (summary)
191
+ key.commentBefore = ` ${summary}`;
192
+ }
193
+ }
194
+ return document.toString({ lineWidth: 0 });
195
+ };
196
+ const inspectConnections = async (args, io) => {
197
+ const [subcommand, ...subcommandArgs] = args;
198
+ if (subcommand !== "inspect")
199
+ throw new Error("Expected connections inspect <Agent Runtime config path>.");
200
+ const parsed = parseOptions(subcommandArgs, new Set(["connection", "runtime-module", "format"]));
201
+ const file = path.resolve(requireOnePositional(parsed, "Agent Runtime config path"));
202
+ const format = parsed.options.get("format") ?? "json";
203
+ if (format !== "json" && format !== "yaml")
204
+ throw new Error("--format must be json or yaml.");
205
+ const config = await loadAgentRuntimeConfig(file);
206
+ const requested = parsed.options.get("connection");
207
+ const names = requested ? [requested] : Object.keys(config.connections);
208
+ for (const name of names) {
209
+ if (!config.connections[name])
210
+ throw new Error(`Unknown connection "${name}".`);
211
+ }
212
+ const runtimeModulePath = parsed.options.get("runtime-module");
213
+ const moduleRuntime = await loadRuntime(runtimeModulePath, {
214
+ manifest: {
215
+ schemaVersion: "1.0",
216
+ connections: names.map((ref) => ({ ref })),
217
+ steps: [],
218
+ },
219
+ storeDirectory: resolveCliStoreLocation(parsed).baseDirectory,
220
+ });
221
+ let shutdownError;
222
+ const discovered = {};
223
+ try {
224
+ for (const name of names) {
225
+ discovered[name] = await discoverMcpConnectionTools(config, name, {}, moduleRuntime.connectionCredentials
226
+ ? { credentialProvider: moduleRuntime.connectionCredentials }
227
+ : {});
228
+ }
229
+ }
230
+ finally {
231
+ try {
232
+ await moduleRuntime.shutdown?.();
233
+ }
234
+ catch (error) {
235
+ shutdownError = error;
236
+ }
237
+ }
238
+ if (shutdownError)
239
+ throw shutdownError;
240
+ if (format === "yaml") {
241
+ io.stdout(toolIntegrityYaml(discovered));
242
+ return;
243
+ }
244
+ io.stdout(`${JSON.stringify({
245
+ connections: Object.fromEntries(Object.entries(discovered).map(([name, tools]) => [
246
+ name,
247
+ {
248
+ tools,
249
+ toolIntegrity: {
250
+ digests: Object.fromEntries(tools
251
+ .filter((tool) => tool.allowed)
252
+ .map((tool) => [tool.name, tool.digest])),
253
+ },
254
+ },
255
+ ])),
152
256
  }, null, 2)}\n`);
153
257
  };
154
258
  const inspect = async (args, io) => {
@@ -234,6 +338,22 @@ const validateRuntime = (runtime) => {
234
338
  throw new Error("Runtime sandbox must implement SandboxAdapter.execute().");
235
339
  if (runtime.subRuns && !adapterMethod(runtime.subRuns, "execute"))
236
340
  throw new Error("Runtime subRuns must implement SubRunAdapter.execute().");
341
+ if (runtime.workspaces &&
342
+ !adapterMethod(runtime.workspaces, "resolveWorkspace")) {
343
+ throw new Error("Runtime workspaces must implement WorkspaceProvider.resolveWorkspace().");
344
+ }
345
+ if (runtime.runSandbox &&
346
+ (!adapterMethod(runtime.runSandbox, "open") ||
347
+ !adapterMethod(runtime.runSandbox, "validate") ||
348
+ !adapterMethod(runtime.runSandbox, "tools"))) {
349
+ throw new Error("Runtime runSandbox must implement RunSandboxProvider.tools(), validate(), and open().");
350
+ }
351
+ if (runtime.sandboxProvider &&
352
+ (!adapterMethod(runtime.sandboxProvider, "create") ||
353
+ !adapterMethod(runtime.sandboxProvider, "execute") ||
354
+ !adapterMethod(runtime.sandboxProvider, "terminate"))) {
355
+ throw new Error("Runtime sandboxProvider must implement the SandboxProvider lifecycle methods.");
356
+ }
237
357
  if (runtime.eventSinks &&
238
358
  (!Array.isArray(runtime.eventSinks) ||
239
359
  runtime.eventSinks.some((sink) => !adapterMethod(sink, "emit")))) {
@@ -277,6 +397,15 @@ const normalizeRuntime = (runtime) => ({
277
397
  ...((runtime.subRuns ?? runtime.subRunAdapter)
278
398
  ? { subRuns: runtime.subRuns ?? runtime.subRunAdapter }
279
399
  : {}),
400
+ ...((runtime.workspaces ?? runtime.workspaceProvider)
401
+ ? { workspaces: runtime.workspaces ?? runtime.workspaceProvider }
402
+ : {}),
403
+ ...((runtime.runSandbox ?? runtime.runSandboxProvider)
404
+ ? { runSandbox: runtime.runSandbox ?? runtime.runSandboxProvider }
405
+ : {}),
406
+ ...(runtime.sandboxProvider
407
+ ? { sandboxProvider: runtime.sandboxProvider }
408
+ : {}),
280
409
  ...((runtime.eventSinks?.length ?? 0) > 0 || runtime.eventSink
281
410
  ? {
282
411
  eventSinks: [
@@ -373,6 +502,19 @@ const resolveConfig = async (requested, searchDirectory = process.cwd()) => {
373
502
  }
374
503
  return emptyAgentRuntimeConfig();
375
504
  };
505
+ /** Host-supplied workspace and sandbox adapters take precedence over configuration. */
506
+ const workspaceCompositionOptions = (...runtimes) => {
507
+ const options = {};
508
+ for (const runtime of runtimes) {
509
+ if (runtime.workspaces && !options.provider)
510
+ options.provider = runtime.workspaces;
511
+ if (runtime.runSandbox && !options.runSandbox)
512
+ options.runSandbox = runtime.runSandbox;
513
+ if (runtime.sandboxProvider && !options.sandboxProvider)
514
+ options.sandboxProvider = runtime.sandboxProvider;
515
+ }
516
+ return options;
517
+ };
376
518
  const mergeRuntimes = (configured, moduleRuntime) => validateRuntime({
377
519
  ...configured,
378
520
  ...moduleRuntime,
@@ -621,6 +763,7 @@ const execute = async (command, args, io, signal) => {
621
763
  ...(moduleRuntime.connectionCredentials
622
764
  ? { connectionCredentials: moduleRuntime.connectionCredentials }
623
765
  : {}),
766
+ workspaceOptions: workspaceCompositionOptions(moduleRuntime),
624
767
  });
625
768
  const runtime = mergeRuntimes(configuredRuntime, moduleRuntime);
626
769
  const jsonlSink = eventFile ? new JsonlEventSink(eventFile) : undefined;
@@ -657,6 +800,8 @@ const execute = async (command, args, io, signal) => {
657
800
  ...(runtime.approvals ? { approvals: runtime.approvals } : {}),
658
801
  ...(runtime.sandbox ? { sandbox: runtime.sandbox } : {}),
659
802
  ...(runtime.subRuns ? { subRuns: runtime.subRuns } : {}),
803
+ ...(runtime.workspaces ? { workspaces: runtime.workspaces } : {}),
804
+ ...(runtime.runSandbox ? { runSandbox: runtime.runSandbox } : {}),
660
805
  ...(runtime.artifactStore
661
806
  ? { artifacts: runtime.artifactStore }
662
807
  : artifactDirectory
@@ -729,6 +874,9 @@ const assertSafeInlineWorkerConfiguration = (config) => {
729
874
  if (Object.keys(config.connections).length > 0) {
730
875
  throw new Error("Inline worker configuration cannot define MCP connections; use a trusted configReference.");
731
876
  }
877
+ if (Object.keys(config.workspaces ?? {}).length > 0 || config.sandbox) {
878
+ throw new Error("Inline worker configuration cannot define workspaces or a sandbox; use a trusted configReference.");
879
+ }
732
880
  };
733
881
  const MAXIMUM_WORKER_INPUT_BYTES = 16 * 1024 * 1024;
734
882
  class PortableWorkerEventSink {
@@ -800,6 +948,10 @@ export const executeWorkerInvocation = async (invocation, options) => {
800
948
  : {}, {
801
949
  model: !moduleRuntime.model && !hostRuntime.model,
802
950
  tools: !moduleRuntime.tools && !hostRuntime.tools,
951
+ workspaceOptions: {
952
+ ...options.workspaceOptions,
953
+ ...workspaceCompositionOptions(hostRuntime, moduleRuntime),
954
+ },
803
955
  ...(options.modelPolicy ? { modelPolicy: options.modelPolicy } : {}),
804
956
  ...(options.toolOptions ||
805
957
  hostRuntime.connectionCredentials ||
@@ -875,6 +1027,8 @@ export const executeWorkerInvocation = async (invocation, options) => {
875
1027
  ...(runtime.approvals ? { approvals: runtime.approvals } : {}),
876
1028
  ...(runtime.sandbox ? { sandbox: runtime.sandbox } : {}),
877
1029
  ...(runtime.subRuns ? { subRuns: runtime.subRuns } : {}),
1030
+ ...(runtime.workspaces ? { workspaces: runtime.workspaces } : {}),
1031
+ ...(runtime.runSandbox ? { runSandbox: runtime.runSandbox } : {}),
878
1032
  artifacts,
879
1033
  ...(options.maxParallelSteps
880
1034
  ? { maxParallelSteps: options.maxParallelSteps }
@@ -1004,6 +1158,8 @@ export const runCli = async (args, io = defaultIo, options = {}) => {
1004
1158
  await validateManifest(commandArgs, io);
1005
1159
  else if (command === "config")
1006
1160
  await validateConfig(commandArgs, io);
1161
+ else if (command === "connections")
1162
+ await inspectConnections(commandArgs, io);
1007
1163
  else if (command === "inspect")
1008
1164
  await inspect(commandArgs, io);
1009
1165
  else if (command === "events")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clearideas/agent-runtime-cli",
3
- "version": "0.5.0",
3
+ "version": "0.6.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,18 @@
40
40
  "postpack": "node ../../scripts/cleanup-package-license.mjs"
41
41
  },
42
42
  "dependencies": {
43
- "@clearideas/agent-runtime-condition-jexl": "0.5.0",
44
- "@clearideas/agent-runtime-config": "0.5.0",
45
- "@clearideas/agent-runtime-contracts": "0.5.0",
46
- "@clearideas/agent-runtime-core": "0.5.0",
47
- "@clearideas/agent-runtime-execution": "0.5.0",
48
- "@clearideas/agent-runtime-step-loop": "0.5.0",
49
- "@clearideas/agent-runtime-step-prompt": "0.5.0",
50
- "@clearideas/agent-runtime-step-standard": "0.5.0",
51
- "@clearideas/agent-runtime-store-local": "0.5.0",
52
- "@clearideas/agent-runtime-store-sqlite": "0.5.0"
43
+ "@clearideas/agent-runtime-condition-jexl": "0.6.0",
44
+ "@clearideas/agent-runtime-config": "0.6.0",
45
+ "@clearideas/agent-runtime-contracts": "0.6.0",
46
+ "@clearideas/agent-runtime-core": "0.6.0",
47
+ "@clearideas/agent-runtime-execution": "0.6.0",
48
+ "@clearideas/agent-runtime-sandbox": "0.6.0",
49
+ "@clearideas/agent-runtime-step-loop": "0.6.0",
50
+ "@clearideas/agent-runtime-step-prompt": "0.6.0",
51
+ "@clearideas/agent-runtime-step-standard": "0.6.0",
52
+ "@clearideas/agent-runtime-store-local": "0.6.0",
53
+ "@clearideas/agent-runtime-store-sqlite": "0.6.0",
54
+ "yaml": "^2.9.1"
53
55
  },
54
56
  "devDependencies": {
55
57
  "@types/node": "^26.4.0",