@clearideas/agent-runtime-cli 0.7.0 → 0.8.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 +15 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +98 -6
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -131,7 +131,7 @@ events and must define their retention and redaction policy.
|
|
|
131
131
|
The default file store is intended for one process. Select
|
|
132
132
|
`--store-driver sqlite --store ./runs.sqlite` for a transactional local store
|
|
133
133
|
that can safely fence resume attempts across processes. The SQLite driver uses
|
|
134
|
-
Node's built-in SQLite API and therefore requires Node
|
|
134
|
+
Node's built-in SQLite API and therefore requires Node.js 22.20.0 or newer.
|
|
135
135
|
|
|
136
136
|
For a reusable invocation, define an agent run manifest that references an
|
|
137
137
|
agent:
|
|
@@ -155,6 +155,20 @@ For an ad hoc run, `--variables ./overrides.json` accepts the override array
|
|
|
155
155
|
directly. Agent Runtime rejects undeclared keys, duplicate keys, dotted override
|
|
156
156
|
keys, and values that do not match the declared type.
|
|
157
157
|
|
|
158
|
+
For an agent that declares conversation messages, `--messages ./turn.json`
|
|
159
|
+
supplies the history (an array, or `{ messages, signature }`),
|
|
160
|
+
`--messages-scope` binds signatures to a conversation, and
|
|
161
|
+
`--messages-out ./next.json` writes the returned history and signature in the
|
|
162
|
+
form the next turn reads. The completion summary reports only the message
|
|
163
|
+
count and whether the history is signed. Signing keys come from the
|
|
164
|
+
configuration's `messages.signing` section:
|
|
165
|
+
|
|
166
|
+
```sh
|
|
167
|
+
npx agent-runtime run ./chat.agent.yaml --config ./agent-runtime.config.yaml \
|
|
168
|
+
--messages ./turn-3.json --messages-scope conversation:42 \
|
|
169
|
+
--messages-out ./turn-3.out.json
|
|
170
|
+
```
|
|
171
|
+
|
|
158
172
|
## Runtime modules
|
|
159
173
|
|
|
160
174
|
Capabilities that depend on the host are supplied by an optional local ESM
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AgentManifest, RunResult, ExecutionPolicies } from "@clearideas/agent-runtime-contracts";
|
|
2
|
-
import { type ArtifactStore, type ApprovalAdapter, type ConnectionCredentialProvider, type EventSink, type ModelAdapter, type RunSandboxProvider, type RunStore, type SandboxAdapter, type StepExecutor, type SubRunAdapter, type ContextSummarizerAdapter, type ToolAdapter, type WorkspaceProvider } 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 ContextSummarizerAdapter, type AgentRuntimeMessagesOptions, type ToolAdapter, type WorkspaceProvider } from "@clearideas/agent-runtime-core";
|
|
3
3
|
import type { SandboxProvider } from "@clearideas/agent-runtime-sandbox";
|
|
4
4
|
import { type ExecutionRequest, type WorkerInvocation, type WorkerMessage } from "@clearideas/agent-runtime-execution";
|
|
5
5
|
import { type AgentRuntimeConfig, type ConfiguredMcpToolAdapterOptions, type ModelAuthorizationPolicy, type WorkspaceCompositionOptions } from "@clearideas/agent-runtime-config";
|
|
@@ -34,6 +34,11 @@ export interface CliRuntime {
|
|
|
34
34
|
enforcedPolicies?: ExecutionPolicies;
|
|
35
35
|
/** Observes, changes, or replaces context summarization. */
|
|
36
36
|
summarizer?: ContextSummarizerAdapter;
|
|
37
|
+
/**
|
|
38
|
+
* Conversation message options, merged over the configuration's `messages`
|
|
39
|
+
* section: for example `authorizeArtifact` or a KMS-backed signer.
|
|
40
|
+
*/
|
|
41
|
+
messages?: AgentRuntimeMessagesOptions;
|
|
37
42
|
}
|
|
38
43
|
export interface CliRuntimeContext {
|
|
39
44
|
manifest: AgentManifest;
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { access, readFile } from "node:fs/promises";
|
|
1
|
+
import { access, readFile, writeFile } from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
4
|
import { JexlConditionEvaluator } from "@clearideas/agent-runtime-condition-jexl";
|
|
5
|
-
import { executionPoliciesSchema, parseAgentVariableOverrides, } from "@clearideas/agent-runtime-contracts";
|
|
5
|
+
import { executionPoliciesSchema, messagesSignatureSchema, parseAgentVariableOverrides, parseConversationMessages, } 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
8
|
import { composeRuntime, discoverMcpConnectionTools, emptyAgentRuntimeConfig, loadAgentRuntimeConfig, parseAgentRuntimeConfig, validateRuntimeConfiguration, } from "@clearideas/agent-runtime-config";
|
|
9
9
|
import { LoopStepExecutor } from "@clearideas/agent-runtime-step-loop";
|
|
10
|
-
import { PromptStepExecutor } from "@clearideas/agent-runtime-step-prompt";
|
|
10
|
+
import { PromptMessageHistoryCompactor, 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
|
+
import { Document as YamlDocument, YAMLMap, isPair, isScalar, parse as parseYamlDocument, } from "yaml";
|
|
14
14
|
const defaultIo = {
|
|
15
15
|
stdout: (text) => process.stdout.write(text),
|
|
16
16
|
stderr: (text) => process.stderr.write(text),
|
|
@@ -21,8 +21,8 @@ Usage:
|
|
|
21
21
|
agent-runtime validate <manifest.json|manifest.yaml> [--config <config.yaml>]
|
|
22
22
|
agent-runtime config validate <config.json|config.yaml>
|
|
23
23
|
agent-runtime connections inspect <config.json|config.yaml> [--connection <name>] [--runtime-module <local-js-file>] [--format <json|yaml>]
|
|
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]
|
|
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
|
+
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]
|
|
25
|
+
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]
|
|
26
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]
|
|
27
27
|
agent-runtime inspect <run-id> [--store <path>] [--store-driver <file|sqlite>] [--runtime-module <local-js-file>]
|
|
28
28
|
agent-runtime events <events.jsonl> [--run <run-id>] [--type <event-type>] [--tail <count>]
|
|
@@ -529,6 +529,9 @@ const workspaceCompositionOptions = (...runtimes) => {
|
|
|
529
529
|
const mergeRuntimes = (configured, moduleRuntime) => validateRuntime({
|
|
530
530
|
...configured,
|
|
531
531
|
...moduleRuntime,
|
|
532
|
+
...(configured.messages || moduleRuntime.messages
|
|
533
|
+
? { messages: { ...configured.messages, ...moduleRuntime.messages } }
|
|
534
|
+
: {}),
|
|
532
535
|
...((configured.eventSinks?.length ?? 0) > 0 ||
|
|
533
536
|
(moduleRuntime.eventSinks?.length ?? 0) > 0
|
|
534
537
|
? {
|
|
@@ -671,9 +674,42 @@ class CliStreamingEventSink {
|
|
|
671
674
|
this.#io.stderr(`${label}\n`);
|
|
672
675
|
}
|
|
673
676
|
}
|
|
677
|
+
/** The run's message options with the prompt package's history compactor. */
|
|
678
|
+
const withHistoryCompactor = (options) => ({
|
|
679
|
+
compactor: new PromptMessageHistoryCompactor(),
|
|
680
|
+
...options,
|
|
681
|
+
});
|
|
682
|
+
/**
|
|
683
|
+
* Read `--messages`: a JSON or YAML array of messages, or `{ messages,
|
|
684
|
+
* signature }` as written by `--messages-out`.
|
|
685
|
+
*/
|
|
686
|
+
const readMessagesFile = async (file) => {
|
|
687
|
+
const source = await readFile(file, "utf8");
|
|
688
|
+
let value;
|
|
689
|
+
try {
|
|
690
|
+
value = file.endsWith(".json")
|
|
691
|
+
? JSON.parse(source)
|
|
692
|
+
: parseYamlDocument(source);
|
|
693
|
+
}
|
|
694
|
+
catch (error) {
|
|
695
|
+
throw new Error(`Could not parse conversation messages ${file}: ${error instanceof Error ? error.message : String(error)}`);
|
|
696
|
+
}
|
|
697
|
+
const envelope = value != null && typeof value === "object" && !Array.isArray(value)
|
|
698
|
+
? value
|
|
699
|
+
: { messages: value };
|
|
700
|
+
return {
|
|
701
|
+
messages: parseConversationMessages(envelope.messages),
|
|
702
|
+
...(envelope.signature != null
|
|
703
|
+
? { signature: messagesSignatureSchema.parse(envelope.signature) }
|
|
704
|
+
: {}),
|
|
705
|
+
};
|
|
706
|
+
};
|
|
674
707
|
const executionOptions = new Set([
|
|
675
708
|
"config",
|
|
676
709
|
"variables",
|
|
710
|
+
"messages",
|
|
711
|
+
"messages-scope",
|
|
712
|
+
"messages-out",
|
|
677
713
|
"run-id",
|
|
678
714
|
"store",
|
|
679
715
|
"store-driver",
|
|
@@ -699,6 +735,15 @@ const execute = async (command, args, io, signal) => {
|
|
|
699
735
|
if (command === "resume" && parsed.options.has("variables")) {
|
|
700
736
|
throw new Error("--variables is only valid with the run command.");
|
|
701
737
|
}
|
|
738
|
+
if (command === "resume" &&
|
|
739
|
+
(parsed.options.has("messages") ||
|
|
740
|
+
parsed.options.has("messages-scope") ||
|
|
741
|
+
parsed.options.has("messages-out"))) {
|
|
742
|
+
throw new Error("Conversation messages are fixed when a run is created; --messages, --messages-scope, and --messages-out are not valid with resume.");
|
|
743
|
+
}
|
|
744
|
+
if (command === "run-manifest" && parsed.options.has("messages")) {
|
|
745
|
+
throw new Error("--messages cannot be combined with an agent run manifest; declare messages in the agent run manifest.");
|
|
746
|
+
}
|
|
702
747
|
if (command === "run-manifest" &&
|
|
703
748
|
(parsed.options.has("variables") ||
|
|
704
749
|
parsed.options.has("run-id") ||
|
|
@@ -737,6 +782,10 @@ const execute = async (command, args, io, signal) => {
|
|
|
737
782
|
const variableOverrides = command === "run" && parsed.options.has("variables")
|
|
738
783
|
? parseAgentVariableOverrides(JSON.parse(await readFile(path.resolve(parsed.options.get("variables")), "utf8")))
|
|
739
784
|
: undefined;
|
|
785
|
+
const suppliedMessages = command === "run" && parsed.options.has("messages")
|
|
786
|
+
? await readMessagesFile(path.resolve(parsed.options.get("messages")))
|
|
787
|
+
: undefined;
|
|
788
|
+
const messagesScope = parsed.options.get("messages-scope");
|
|
740
789
|
let configSearchDirectory = process.cwd();
|
|
741
790
|
if (command === "run") {
|
|
742
791
|
const manifestFile = path.resolve(target);
|
|
@@ -828,6 +877,7 @@ const execute = async (command, args, io, signal) => {
|
|
|
828
877
|
? { enforcedPolicies: runtime.enforcedPolicies }
|
|
829
878
|
: {}),
|
|
830
879
|
...(runtime.summarizer ? { summarizer: runtime.summarizer } : {}),
|
|
880
|
+
messages: withHistoryCompactor(runtime.messages),
|
|
831
881
|
...(runtime.artifactStore
|
|
832
882
|
? { artifacts: runtime.artifactStore }
|
|
833
883
|
: artifactDirectory
|
|
@@ -838,16 +888,38 @@ const execute = async (command, args, io, signal) => {
|
|
|
838
888
|
const result = await runner.run(command === "run-manifest" && agentRunManifest
|
|
839
889
|
? {
|
|
840
890
|
agentRunManifest,
|
|
891
|
+
...(messagesScope != null ? { messagesScope } : {}),
|
|
841
892
|
...(signal ? { signal } : {}),
|
|
842
893
|
}
|
|
843
894
|
: {
|
|
844
895
|
manifest,
|
|
845
896
|
...(runId ? { runId } : {}),
|
|
846
897
|
...(variableOverrides ? { variables: variableOverrides } : {}),
|
|
898
|
+
...(suppliedMessages
|
|
899
|
+
? { messages: suppliedMessages.messages }
|
|
900
|
+
: {}),
|
|
901
|
+
...(suppliedMessages?.signature
|
|
902
|
+
? { messagesSignature: suppliedMessages.signature }
|
|
903
|
+
: {}),
|
|
904
|
+
...(messagesScope != null ? { messagesScope } : {}),
|
|
847
905
|
...(maxTotalTokens ? { budget: { maxTotalTokens } } : {}),
|
|
848
906
|
...(signal ? { signal } : {}),
|
|
849
907
|
...(command === "resume" ? { resume: true } : {}),
|
|
850
908
|
});
|
|
909
|
+
// The output history contains model output, so it is written only to
|
|
910
|
+
// an explicitly requested file, in the format --messages reads.
|
|
911
|
+
const messagesOut = parsed.options.get("messages-out");
|
|
912
|
+
if (messagesOut) {
|
|
913
|
+
if (!result.messages) {
|
|
914
|
+
throw new Error("--messages-out requires an agent manifest that declares messages.");
|
|
915
|
+
}
|
|
916
|
+
await writeFile(path.resolve(messagesOut), `${JSON.stringify({
|
|
917
|
+
messages: result.messages,
|
|
918
|
+
...(result.messagesSignature
|
|
919
|
+
? { signature: result.messagesSignature }
|
|
920
|
+
: {}),
|
|
921
|
+
}, null, 2)}\n`, { encoding: "utf8", mode: 0o600 });
|
|
922
|
+
}
|
|
851
923
|
// Deliberately exclude variables, transcript and model output. They may
|
|
852
924
|
// contain secrets; inspect is an explicit command for persisted details.
|
|
853
925
|
if (outputFormat === "ndjson") {
|
|
@@ -870,6 +942,12 @@ const execute = async (command, args, io, signal) => {
|
|
|
870
942
|
status: "completed",
|
|
871
943
|
stepCount: result.stepResults.length,
|
|
872
944
|
artifactCount: result.artifacts.length,
|
|
945
|
+
...(result.messages
|
|
946
|
+
? {
|
|
947
|
+
messageCount: result.messages.length,
|
|
948
|
+
messagesSigned: result.messagesSignature != null,
|
|
949
|
+
}
|
|
950
|
+
: {}),
|
|
873
951
|
}, null, 2)}\n`);
|
|
874
952
|
}
|
|
875
953
|
}
|
|
@@ -903,6 +981,9 @@ const assertSafeInlineWorkerConfiguration = (config) => {
|
|
|
903
981
|
if (Object.keys(config.workspaces ?? {}).length > 0 || config.sandbox) {
|
|
904
982
|
throw new Error("Inline worker configuration cannot define workspaces or a sandbox; use a trusted configReference.");
|
|
905
983
|
}
|
|
984
|
+
if (config.messages?.signing) {
|
|
985
|
+
throw new Error("Inline worker configuration cannot define message signing keys; use a trusted configReference.");
|
|
986
|
+
}
|
|
906
987
|
};
|
|
907
988
|
const MAXIMUM_WORKER_INPUT_BYTES = 16 * 1024 * 1024;
|
|
908
989
|
class PortableWorkerEventSink {
|
|
@@ -924,6 +1005,7 @@ export const executeWorkerInvocation = async (invocation, options) => {
|
|
|
924
1005
|
const invocationVariables = invocation.action === "run"
|
|
925
1006
|
? request.variables
|
|
926
1007
|
: undefined;
|
|
1008
|
+
const invocationMessages = invocation.action === "run" ? request : undefined;
|
|
927
1009
|
const manifest = request.manifest;
|
|
928
1010
|
const storeLocation = path.resolve(options.storeDirectory);
|
|
929
1011
|
const storeDriver = options.storeDriver ?? "file";
|
|
@@ -1060,6 +1142,7 @@ export const executeWorkerInvocation = async (invocation, options) => {
|
|
|
1060
1142
|
? { enforcedPolicies: runtime.enforcedPolicies }
|
|
1061
1143
|
: {}),
|
|
1062
1144
|
...(runtime.summarizer ? { summarizer: runtime.summarizer } : {}),
|
|
1145
|
+
messages: withHistoryCompactor(runtime.messages),
|
|
1063
1146
|
artifacts,
|
|
1064
1147
|
...(options.maxParallelSteps
|
|
1065
1148
|
? { maxParallelSteps: options.maxParallelSteps }
|
|
@@ -1072,6 +1155,15 @@ export const executeWorkerInvocation = async (invocation, options) => {
|
|
|
1072
1155
|
manifest,
|
|
1073
1156
|
...(request.runId ? { runId: request.runId } : {}),
|
|
1074
1157
|
...(invocationVariables ? { variables: invocationVariables } : {}),
|
|
1158
|
+
...(invocationMessages?.messages
|
|
1159
|
+
? { messages: invocationMessages.messages }
|
|
1160
|
+
: {}),
|
|
1161
|
+
...(invocationMessages?.messagesSignature
|
|
1162
|
+
? { messagesSignature: invocationMessages.messagesSignature }
|
|
1163
|
+
: {}),
|
|
1164
|
+
...(invocationMessages?.messagesScope != null
|
|
1165
|
+
? { messagesScope: invocationMessages.messagesScope }
|
|
1166
|
+
: {}),
|
|
1075
1167
|
...(request.execution ? { execution: request.execution } : {}),
|
|
1076
1168
|
...(request.budget ? { budget: request.budget } : {}),
|
|
1077
1169
|
...(options.signal ? { signal: options.signal } : {}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clearideas/agent-runtime-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.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,17 +40,17 @@
|
|
|
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-sandbox": "0.
|
|
49
|
-
"@clearideas/agent-runtime-step-loop": "0.
|
|
50
|
-
"@clearideas/agent-runtime-step-prompt": "0.
|
|
51
|
-
"@clearideas/agent-runtime-step-standard": "0.
|
|
52
|
-
"@clearideas/agent-runtime-store-local": "0.
|
|
53
|
-
"@clearideas/agent-runtime-store-sqlite": "0.
|
|
43
|
+
"@clearideas/agent-runtime-condition-jexl": "0.8.0",
|
|
44
|
+
"@clearideas/agent-runtime-config": "0.8.0",
|
|
45
|
+
"@clearideas/agent-runtime-contracts": "0.8.0",
|
|
46
|
+
"@clearideas/agent-runtime-core": "0.8.0",
|
|
47
|
+
"@clearideas/agent-runtime-execution": "0.8.0",
|
|
48
|
+
"@clearideas/agent-runtime-sandbox": "0.8.0",
|
|
49
|
+
"@clearideas/agent-runtime-step-loop": "0.8.0",
|
|
50
|
+
"@clearideas/agent-runtime-step-prompt": "0.8.0",
|
|
51
|
+
"@clearideas/agent-runtime-step-standard": "0.8.0",
|
|
52
|
+
"@clearideas/agent-runtime-store-local": "0.8.0",
|
|
53
|
+
"@clearideas/agent-runtime-store-sqlite": "0.8.0",
|
|
54
54
|
"yaml": "^2.9.1"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"vitest": "^5.1.0"
|
|
60
60
|
},
|
|
61
61
|
"engines": {
|
|
62
|
-
"node": ">=
|
|
62
|
+
"node": ">=22.20.0"
|
|
63
63
|
},
|
|
64
64
|
"homepage": "https://github.com/clearideas/agent-runtime#readme",
|
|
65
65
|
"bugs": {
|