cool-workflow 0.1.78
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/.claude-plugin/plugin.json +20 -0
- package/.codex-plugin/mcp.json +10 -0
- package/.codex-plugin/plugin.json +38 -0
- package/.mcp.json +10 -0
- package/LICENSE +24 -0
- package/README.md +638 -0
- package/apps/architecture-review/app.json +51 -0
- package/apps/architecture-review/workflow.js +116 -0
- package/apps/end-to-end-golden-path/app.json +30 -0
- package/apps/end-to-end-golden-path/workflow.js +33 -0
- package/apps/pr-review-fix-ci/app.json +59 -0
- package/apps/pr-review-fix-ci/workflow.js +90 -0
- package/apps/release-cut/app.json +54 -0
- package/apps/release-cut/workflow.js +82 -0
- package/apps/research-synthesis/app.json +50 -0
- package/apps/research-synthesis/workflow.js +76 -0
- package/apps/workflow-app-framework-demo/app.json +29 -0
- package/apps/workflow-app-framework-demo/workflow.js +44 -0
- package/dist/agent-config.js +223 -0
- package/dist/candidate-scoring.js +715 -0
- package/dist/capability-core.js +630 -0
- package/dist/capability-dispatcher.js +86 -0
- package/dist/capability-registry.js +523 -0
- package/dist/cli.js +1276 -0
- package/dist/collaboration.js +727 -0
- package/dist/commit.js +570 -0
- package/dist/contract-migration.js +234 -0
- package/dist/coordinator.js +1163 -0
- package/dist/daemon.js +44 -0
- package/dist/dispatch.js +201 -0
- package/dist/drive.js +503 -0
- package/dist/error-feedback.js +415 -0
- package/dist/evidence-grounding.js +179 -0
- package/dist/evidence-reasoning.js +733 -0
- package/dist/execution-backend.js +1279 -0
- package/dist/harness.js +61 -0
- package/dist/mcp-server.js +1615 -0
- package/dist/multi-agent-eval.js +857 -0
- package/dist/multi-agent-host.js +764 -0
- package/dist/multi-agent-operator-ux.js +537 -0
- package/dist/multi-agent-trust.js +366 -0
- package/dist/multi-agent.js +1173 -0
- package/dist/node-snapshot.js +270 -0
- package/dist/observability.js +922 -0
- package/dist/operator-ux.js +971 -0
- package/dist/orchestrator/audit-operations.js +182 -0
- package/dist/orchestrator/candidate-operations.js +117 -0
- package/dist/orchestrator/cli-options.js +288 -0
- package/dist/orchestrator/collaboration-operations.js +86 -0
- package/dist/orchestrator/feedback-operations.js +81 -0
- package/dist/orchestrator/host-operations.js +78 -0
- package/dist/orchestrator/lifecycle-operations.js +462 -0
- package/dist/orchestrator/migration-operations.js +44 -0
- package/dist/orchestrator/multi-agent-operations.js +362 -0
- package/dist/orchestrator/report.js +369 -0
- package/dist/orchestrator/topology-operations.js +84 -0
- package/dist/orchestrator.js +874 -0
- package/dist/pipeline-contract.js +92 -0
- package/dist/pipeline-runner.js +285 -0
- package/dist/reclamation.js +882 -0
- package/dist/result-normalize.js +194 -0
- package/dist/run-export.js +64 -0
- package/dist/run-registry.js +1347 -0
- package/dist/run-state-schema.js +67 -0
- package/dist/sandbox-profile.js +471 -0
- package/dist/scheduler.js +266 -0
- package/dist/scheduling.js +184 -0
- package/dist/schema-validate.js +98 -0
- package/dist/state-explosion.js +1213 -0
- package/dist/state-migrations.js +463 -0
- package/dist/state-node.js +301 -0
- package/dist/state.js +308 -0
- package/dist/telemetry-attestation.js +156 -0
- package/dist/telemetry-ledger.js +145 -0
- package/dist/topology.js +527 -0
- package/dist/triggers.js +159 -0
- package/dist/trust-audit.js +475 -0
- package/dist/types/blackboard.js +2 -0
- package/dist/types/boundary.js +29 -0
- package/dist/types/candidate.js +2 -0
- package/dist/types/collaboration.js +2 -0
- package/dist/types/core.js +2 -0
- package/dist/types/drive.js +10 -0
- package/dist/types/error-feedback.js +2 -0
- package/dist/types/evidence-reasoning.js +2 -0
- package/dist/types/execution-backend.js +2 -0
- package/dist/types/multi-agent.js +2 -0
- package/dist/types/observability.js +2 -0
- package/dist/types/pipeline.js +2 -0
- package/dist/types/reclamation.js +8 -0
- package/dist/types/result.js +2 -0
- package/dist/types/run-registry.js +2 -0
- package/dist/types/run.js +2 -0
- package/dist/types/sandbox.js +2 -0
- package/dist/types/schedule.js +2 -0
- package/dist/types/state-node.js +2 -0
- package/dist/types/topology.js +2 -0
- package/dist/types/trust.js +2 -0
- package/dist/types/workbench.js +2 -0
- package/dist/types/worker.js +2 -0
- package/dist/types/workflow-app.js +2 -0
- package/dist/types.js +43 -0
- package/dist/verifier-registry.js +46 -0
- package/dist/verifier.js +78 -0
- package/dist/version.js +8 -0
- package/dist/workbench-host.js +172 -0
- package/dist/workbench.js +190 -0
- package/dist/worker-isolation.js +1028 -0
- package/dist/workflow-api.js +98 -0
- package/dist/workflow-app-framework.js +626 -0
- package/docs/agent-delegation-drive.7.md +190 -0
- package/docs/agent-framework.md +176 -0
- package/docs/candidate-scoring.7.md +106 -0
- package/docs/canonical-workflow-apps.7.md +137 -0
- package/docs/capability-topology-registry.7.md +168 -0
- package/docs/cli-mcp-parity.7.md +373 -0
- package/docs/contract-migration-tooling.7.md +123 -0
- package/docs/control-plane-scheduling.7.md +110 -0
- package/docs/coordinator-blackboard.7.md +183 -0
- package/docs/dogfood/architecture-review-cool-workflow.md +16 -0
- package/docs/dogfood-one-real-repo.7.md +168 -0
- package/docs/durable-state-and-locking.7.md +107 -0
- package/docs/end-to-end-golden-path.7.md +117 -0
- package/docs/error-feedback.7.md +153 -0
- package/docs/evidence-adoption-reasoning-chain.7.md +270 -0
- package/docs/execution-backends.7.md +300 -0
- package/docs/getting-started.md +99 -0
- package/docs/index.md +41 -0
- package/docs/mcp-app-surface.7.md +235 -0
- package/docs/multi-agent-cli-mcp-surface.7.md +265 -0
- package/docs/multi-agent-eval-replay-harness.7.md +302 -0
- package/docs/multi-agent-operator-ux.7.md +314 -0
- package/docs/multi-agent-runtime-core.7.md +231 -0
- package/docs/multi-agent-topologies.7.md +103 -0
- package/docs/multi-agent-trust-policy-audit.7.md +154 -0
- package/docs/node-snapshot-diff-replay.7.md +135 -0
- package/docs/observability-cost-accounting.7.md +194 -0
- package/docs/operator-ux.7.md +180 -0
- package/docs/pipeline-runner.7.md +136 -0
- package/docs/project-index.md +261 -0
- package/docs/real-execution-backends.7.md +142 -0
- package/docs/release-and-migration.7.md +280 -0
- package/docs/release-tooling.7.md +159 -0
- package/docs/routines.md +48 -0
- package/docs/run-registry-control-plane.7.md +312 -0
- package/docs/run-retention-reclamation.7.md +191 -0
- package/docs/sandbox-profiles.7.md +137 -0
- package/docs/scheduled-tasks.md +80 -0
- package/docs/security-trust-hardening.7.md +117 -0
- package/docs/state-explosion-management.7.md +264 -0
- package/docs/state-node.7.md +96 -0
- package/docs/team-collaboration.7.md +207 -0
- package/docs/unix-principles.md +192 -0
- package/docs/verifier-gated-commit.7.md +140 -0
- package/docs/web-desktop-workbench.7.md +215 -0
- package/docs/worker-isolation.7.md +167 -0
- package/docs/workflow-app-framework.7.md +274 -0
- package/manifest/README.md +43 -0
- package/manifest/plugin.manifest.json +316 -0
- package/manifest/pricing.policy.json +14 -0
- package/package.json +79 -0
- package/scripts/agents/claude-p-agent.js +104 -0
- package/scripts/agents/claude-p-agent.sh +9 -0
- package/scripts/agents/cw-attest-keygen.js +55 -0
- package/scripts/agents/cw-attest-wrap.js +143 -0
- package/scripts/block-unapproved-tag.sh +39 -0
- package/scripts/bump-version.js +249 -0
- package/scripts/canonical-apps.js +171 -0
- package/scripts/cw.js +4 -0
- package/scripts/dist-drift-check.js +79 -0
- package/scripts/dogfood-architecture-review.js +237 -0
- package/scripts/dogfood-release.js +624 -0
- package/scripts/forward-ref-docs.js +73 -0
- package/scripts/gen-manifests.js +232 -0
- package/scripts/golden-path.js +300 -0
- package/scripts/mcp-server.js +4 -0
- package/scripts/new-feature.js +121 -0
- package/scripts/parity-check.js +213 -0
- package/scripts/release-check.js +118 -0
- package/scripts/release-flow.js +272 -0
- package/scripts/release-gate.sh +85 -0
- package/scripts/sync-project-index.js +387 -0
- package/scripts/validate-run-state-schema.js +126 -0
- package/scripts/verify-container-selfref.js +64 -0
- package/scripts/version-sync-check.js +237 -0
- package/skills/cool-workflow/SKILL.md +162 -0
- package/skills/cool-workflow/references/commands.md +282 -0
- package/tsconfig.json +16 -0
- package/ui/workbench/app.css +76 -0
- package/ui/workbench/app.js +159 -0
- package/ui/workbench/index.html +32 -0
- package/workflows/architecture-review.workflow.js +84 -0
- package/workflows/research-synthesis.workflow.js +47 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
module.exports = ({ workflow, phase, agent, artifact, input }) => {
|
|
2
|
+
const inputs = [
|
|
3
|
+
input("question", {
|
|
4
|
+
type: "string",
|
|
5
|
+
required: true,
|
|
6
|
+
description: "Question or implementation task this app should plan."
|
|
7
|
+
})
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
return workflow({
|
|
11
|
+
id: "workflow-app-framework-demo",
|
|
12
|
+
title: "Workflow App framework Demo",
|
|
13
|
+
summary: "Small framework app showing inputs, phases, evidence gates, and sandbox profile hints.",
|
|
14
|
+
limits: {
|
|
15
|
+
maxAgents: 6,
|
|
16
|
+
maxConcurrentAgents: 2
|
|
17
|
+
},
|
|
18
|
+
inputs,
|
|
19
|
+
sandboxProfiles: ["readonly", "workspace-write"],
|
|
20
|
+
phases: [
|
|
21
|
+
phase("Inspect", [
|
|
22
|
+
agent(
|
|
23
|
+
"inspect:contract",
|
|
24
|
+
"Inspect the repository context for {{question}}. Return relevant files, current contracts, and unknowns.",
|
|
25
|
+
{ sandboxProfileId: "readonly" }
|
|
26
|
+
)
|
|
27
|
+
]),
|
|
28
|
+
phase("Implement", [
|
|
29
|
+
agent(
|
|
30
|
+
"implement:change",
|
|
31
|
+
"Implement the smallest coherent change for {{question}} and report edited files and risks.",
|
|
32
|
+
{ sandboxProfileId: "workspace-write" }
|
|
33
|
+
)
|
|
34
|
+
]),
|
|
35
|
+
phase("Verify", [
|
|
36
|
+
artifact(
|
|
37
|
+
"verify:evidence",
|
|
38
|
+
"Verify the implementation for {{question}} with commands, state evidence, and remaining risks.",
|
|
39
|
+
{ requiresEvidence: true, sandboxProfileId: "readonly" }
|
|
40
|
+
)
|
|
41
|
+
])
|
|
42
|
+
]
|
|
43
|
+
});
|
|
44
|
+
};
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Agent Delegation Config (v0.1.38) — POLICY expressed as DATA. WHICH agent
|
|
3
|
+
// (claude / codex / ollama / an HTTP endpoint) fulfills each worker is a plain,
|
|
4
|
+
// diffable config record, NEVER a CW dependency. Resolution order is
|
|
5
|
+
// flags > env > a durable $CW_HOME/agent-config.json > fail-closed.
|
|
6
|
+
//
|
|
7
|
+
// BSD discipline:
|
|
8
|
+
// - MECHANISM vs POLICY: the `agent` backend is mechanism; this file is the
|
|
9
|
+
// policy data it reads. The kernel never learns which vendor was chosen.
|
|
10
|
+
// - NO SECRETS IN COMMITTED STATE [load-bearing]: the durable config holds a
|
|
11
|
+
// command-TEMPLATE + endpoint + operator-chosen model only. API keys come from
|
|
12
|
+
// the AGENT's own inherited env, never written into .cw/ or the config file.
|
|
13
|
+
// Any secret-looking arg is stripped before it is persisted OR shown.
|
|
14
|
+
// - DETERMINISTIC SHOW: `agentConfigShow` is a pure projection of env + file —
|
|
15
|
+
// no now-derived field — so `cw backend agent config show --json` is
|
|
16
|
+
// byte-identical to the MCP tool (CLI<->MCP parity).
|
|
17
|
+
//
|
|
18
|
+
// See docs/agent-delegation-drive.7.md.
|
|
19
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
20
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.AGENT_CONFIG_SCHEMA_VERSION = void 0;
|
|
24
|
+
exports.agentConfigPath = agentConfigPath;
|
|
25
|
+
exports.loadAgentConfigFile = loadAgentConfigFile;
|
|
26
|
+
exports.resolveAgentConfig = resolveAgentConfig;
|
|
27
|
+
exports.agentConfigured = agentConfigured;
|
|
28
|
+
exports.setAgentConfigFile = setAgentConfigFile;
|
|
29
|
+
exports.agentConfigShow = agentConfigShow;
|
|
30
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
31
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
32
|
+
const run_registry_1 = require("./run-registry");
|
|
33
|
+
const execution_backend_1 = require("./execution-backend");
|
|
34
|
+
exports.AGENT_CONFIG_SCHEMA_VERSION = 1;
|
|
35
|
+
function agentConfigPath(env = process.env) {
|
|
36
|
+
return node_path_1.default.join((0, run_registry_1.resolveCwHome)(env), "agent-config.json");
|
|
37
|
+
}
|
|
38
|
+
function trimmed(value) {
|
|
39
|
+
if (typeof value !== "string")
|
|
40
|
+
return undefined;
|
|
41
|
+
const out = value.trim();
|
|
42
|
+
return out ? out : undefined;
|
|
43
|
+
}
|
|
44
|
+
/** Parse a boolean from a flag (boolean) or an env/file string. Returns undefined
|
|
45
|
+
* for unset/unrecognized so `firstDefined` falls through to the next layer. */
|
|
46
|
+
function boolish(value) {
|
|
47
|
+
if (typeof value === "boolean")
|
|
48
|
+
return value;
|
|
49
|
+
if (typeof value === "string") {
|
|
50
|
+
const v = value.trim().toLowerCase();
|
|
51
|
+
if (["1", "true", "yes", "on"].includes(v))
|
|
52
|
+
return true;
|
|
53
|
+
if (["0", "false", "no", "off"].includes(v))
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
function asStringArray(value) {
|
|
59
|
+
if (!Array.isArray(value))
|
|
60
|
+
return undefined;
|
|
61
|
+
const out = value.map((entry) => String(entry));
|
|
62
|
+
return out.length ? out : undefined;
|
|
63
|
+
}
|
|
64
|
+
function firstDefined(...values) {
|
|
65
|
+
for (const value of values)
|
|
66
|
+
if (value !== undefined)
|
|
67
|
+
return value;
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
/** Split a single command string ("claude -p {{manifest}}") into binary + argv
|
|
71
|
+
* template — NEVER shell-interpreted. An explicit args array always wins. */
|
|
72
|
+
function splitCommand(command, args) {
|
|
73
|
+
if (!command)
|
|
74
|
+
return { command: undefined, args };
|
|
75
|
+
if (args && args.length)
|
|
76
|
+
return { command, args };
|
|
77
|
+
if (/\s/.test(command)) {
|
|
78
|
+
const parts = command.split(/\s+/).filter(Boolean);
|
|
79
|
+
return { command: parts[0], args: parts.slice(1) };
|
|
80
|
+
}
|
|
81
|
+
return { command, args };
|
|
82
|
+
}
|
|
83
|
+
/** Read the durable config FILE (if any). Never throws — a corrupt file is
|
|
84
|
+
* treated as absent (fail closed). */
|
|
85
|
+
function loadAgentConfigFile(env = process.env) {
|
|
86
|
+
const file = agentConfigPath(env);
|
|
87
|
+
if (!node_fs_1.default.existsSync(file))
|
|
88
|
+
return undefined;
|
|
89
|
+
try {
|
|
90
|
+
const parsed = JSON.parse(node_fs_1.default.readFileSync(file, "utf8"));
|
|
91
|
+
return {
|
|
92
|
+
schemaVersion: 1,
|
|
93
|
+
command: trimmed(parsed.command),
|
|
94
|
+
args: asStringArray(parsed.args),
|
|
95
|
+
endpoint: trimmed(parsed.endpoint),
|
|
96
|
+
model: trimmed(parsed.model),
|
|
97
|
+
timeoutMs: typeof parsed.timeoutMs === "number" ? parsed.timeoutMs : undefined,
|
|
98
|
+
attestPublicKey: trimmed(parsed.attestPublicKey),
|
|
99
|
+
requireAttestedTelemetry: boolish(parsed.requireAttestedTelemetry),
|
|
100
|
+
source: "file"
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function agentConfigFromEnv(env) {
|
|
108
|
+
const split = splitCommand(trimmed(env.CW_AGENT_COMMAND), undefined);
|
|
109
|
+
return {
|
|
110
|
+
schemaVersion: 1,
|
|
111
|
+
command: split.command,
|
|
112
|
+
args: split.args,
|
|
113
|
+
endpoint: trimmed(env.CW_AGENT_ENDPOINT),
|
|
114
|
+
model: trimmed(env.CW_AGENT_MODEL),
|
|
115
|
+
timeoutMs: trimmed(env.CW_AGENT_TIMEOUT_MS) ? Number(env.CW_AGENT_TIMEOUT_MS) : undefined,
|
|
116
|
+
attestPublicKey: trimmed(env.CW_AGENT_ATTEST_PUBKEY),
|
|
117
|
+
requireAttestedTelemetry: boolish(env.CW_REQUIRE_ATTESTED_TELEMETRY),
|
|
118
|
+
source: "env"
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function agentConfigFromArgs(args) {
|
|
122
|
+
const rawCommand = trimmed(args.agentCommand ?? args["agent-command"]);
|
|
123
|
+
const rawArgs = asStringArray(args.agentArgs ?? args["agent-args"]);
|
|
124
|
+
const split = splitCommand(rawCommand, rawArgs);
|
|
125
|
+
const rawTimeout = args.agentTimeoutMs ?? args["agent-timeout-ms"];
|
|
126
|
+
return {
|
|
127
|
+
schemaVersion: 1,
|
|
128
|
+
command: split.command,
|
|
129
|
+
args: split.args,
|
|
130
|
+
endpoint: trimmed(args.agentEndpoint ?? args["agent-endpoint"]),
|
|
131
|
+
model: trimmed(args.agentModel ?? args["agent-model"]),
|
|
132
|
+
timeoutMs: rawTimeout !== undefined ? Number(rawTimeout) : undefined,
|
|
133
|
+
attestPublicKey: trimmed(args.agentAttestPublicKey ?? args["agent-attest-public-key"]),
|
|
134
|
+
requireAttestedTelemetry: boolish(args.requireAttestedTelemetry ?? args["require-attested-telemetry"]),
|
|
135
|
+
source: "flag"
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
// Bundled agent templates, addressable by a stable name so an operator (or an
|
|
139
|
+
// npx/global install, where $(pwd)-relative paths don't exist) can configure a
|
|
140
|
+
// WORKING agent without knowing where the package landed on disk:
|
|
141
|
+
// --agent-command builtin:claude (or CW_AGENT_COMMAND=builtin:claude)
|
|
142
|
+
// resolves to the packaged claude wrapper invocation. Still pure config — the
|
|
143
|
+
// template is an out-of-process delegation script; CW never calls a model API.
|
|
144
|
+
const BUILTIN_AGENT_TEMPLATES = {
|
|
145
|
+
claude: `node ${node_path_1.default.join(__dirname, "..", "scripts", "agents", "claude-p-agent.js")} {{input}} {{result}}`
|
|
146
|
+
};
|
|
147
|
+
function expandBuiltinAgentCommand(command) {
|
|
148
|
+
if (!command || !command.startsWith("builtin:"))
|
|
149
|
+
return command;
|
|
150
|
+
const name = command.slice("builtin:".length).trim();
|
|
151
|
+
const template = BUILTIN_AGENT_TEMPLATES[name];
|
|
152
|
+
if (!template) {
|
|
153
|
+
throw new Error(`Unknown builtin agent template "${name}" — available: ${Object.keys(BUILTIN_AGENT_TEMPLATES).join(", ")}`);
|
|
154
|
+
}
|
|
155
|
+
return template;
|
|
156
|
+
}
|
|
157
|
+
/** Resolve the EFFECTIVE agent config: flags > env > file > none. The returned
|
|
158
|
+
* `source` names the layer the command/endpoint came from. */
|
|
159
|
+
function resolveAgentConfig(args = {}, env = process.env) {
|
|
160
|
+
const flagCfg = agentConfigFromArgs(args);
|
|
161
|
+
const envCfg = agentConfigFromEnv(env);
|
|
162
|
+
const fileCfg = loadAgentConfigFile(env);
|
|
163
|
+
const command = expandBuiltinAgentCommand(firstDefined(flagCfg.command, envCfg.command, fileCfg?.command));
|
|
164
|
+
const cfgArgs = firstDefined(flagCfg.args, envCfg.args, fileCfg?.args);
|
|
165
|
+
const endpoint = firstDefined(flagCfg.endpoint, envCfg.endpoint, fileCfg?.endpoint);
|
|
166
|
+
const model = firstDefined(flagCfg.model, envCfg.model, fileCfg?.model);
|
|
167
|
+
const timeoutMs = firstDefined(flagCfg.timeoutMs, envCfg.timeoutMs, fileCfg?.timeoutMs);
|
|
168
|
+
const attestPublicKey = firstDefined(flagCfg.attestPublicKey, envCfg.attestPublicKey, fileCfg?.attestPublicKey);
|
|
169
|
+
const requireAttestedTelemetry = firstDefined(flagCfg.requireAttestedTelemetry, envCfg.requireAttestedTelemetry, fileCfg?.requireAttestedTelemetry);
|
|
170
|
+
const source = flagCfg.command || flagCfg.endpoint
|
|
171
|
+
? "flag"
|
|
172
|
+
: envCfg.command || envCfg.endpoint
|
|
173
|
+
? "env"
|
|
174
|
+
: fileCfg && (fileCfg.command || fileCfg.endpoint)
|
|
175
|
+
? "file"
|
|
176
|
+
: "none";
|
|
177
|
+
return { schemaVersion: 1, command, args: cfgArgs, endpoint, model, timeoutMs, attestPublicKey, requireAttestedTelemetry, source };
|
|
178
|
+
}
|
|
179
|
+
/** True iff a command-template OR endpoint is configured (after resolution). */
|
|
180
|
+
function agentConfigured(args = {}, env = process.env) {
|
|
181
|
+
const resolved = resolveAgentConfig(args, env);
|
|
182
|
+
return Boolean(resolved.command || resolved.endpoint);
|
|
183
|
+
}
|
|
184
|
+
/** Secret-stripped copy safe to persist or show — never carries raw credentials. */
|
|
185
|
+
function redacted(config) {
|
|
186
|
+
return {
|
|
187
|
+
...config,
|
|
188
|
+
args: config.args ? (0, execution_backend_1.stripSecretArgs)(config.args) : undefined
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
/** Persist the durable config (secret-stripped). Returns the stored, redacted
|
|
192
|
+
* config. API keys are NEVER written — they come from the agent's own env. */
|
|
193
|
+
function setAgentConfigFile(patch, env = process.env) {
|
|
194
|
+
const current = loadAgentConfigFile(env) || { schemaVersion: 1 };
|
|
195
|
+
const incoming = agentConfigFromArgs(patch);
|
|
196
|
+
const merged = {
|
|
197
|
+
schemaVersion: 1,
|
|
198
|
+
command: firstDefined(incoming.command, current.command),
|
|
199
|
+
args: firstDefined(incoming.args, current.args),
|
|
200
|
+
endpoint: firstDefined(incoming.endpoint, current.endpoint),
|
|
201
|
+
model: firstDefined(incoming.model, current.model),
|
|
202
|
+
timeoutMs: firstDefined(incoming.timeoutMs, current.timeoutMs),
|
|
203
|
+
source: "file"
|
|
204
|
+
};
|
|
205
|
+
const stored = redacted(merged);
|
|
206
|
+
const file = agentConfigPath(env);
|
|
207
|
+
node_fs_1.default.mkdirSync(node_path_1.default.dirname(file), { recursive: true });
|
|
208
|
+
node_fs_1.default.writeFileSync(file, `${JSON.stringify(stored, null, 2)}\n`, "utf8");
|
|
209
|
+
return stored;
|
|
210
|
+
}
|
|
211
|
+
/** Read-only, deterministic projection of the effective config (secret-stripped).
|
|
212
|
+
* No now-derived field — safe for CLI<->MCP payload parity. */
|
|
213
|
+
function agentConfigShow(args = {}, env = process.env) {
|
|
214
|
+
const resolved = resolveAgentConfig(args, env);
|
|
215
|
+
return {
|
|
216
|
+
schemaVersion: 1,
|
|
217
|
+
configured: Boolean(resolved.command || resolved.endpoint),
|
|
218
|
+
source: resolved.source,
|
|
219
|
+
config: redacted(resolved),
|
|
220
|
+
path: agentConfigPath(env),
|
|
221
|
+
fileExists: node_fs_1.default.existsSync(agentConfigPath(env))
|
|
222
|
+
};
|
|
223
|
+
}
|