@botbotgo/agent-harness 0.0.474 → 0.0.476
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 +3 -1234
- package/README.zh.md +3 -1191
- package/dist/acp.js +1 -1
- package/dist/api.js +1 -404
- package/dist/benchmark/checkpoint-resume-cost-benchmark.js +1 -55
- package/dist/benchmark/deepagent-local-model-benchmark.js +2 -35
- package/dist/benchmark/upstream-runtime-ab-benchmark.js +1 -179
- package/dist/cli/chat-interactive.js +25 -244
- package/dist/cli/chat-rendering.js +6 -100
- package/dist/cli/chat-stream.js +23 -512
- package/dist/cli/chat-ui.js +21 -199
- package/dist/cli/chat-workspace.js +2 -210
- package/dist/cli/main.js +21 -428
- package/dist/cli/managed-service-commands.js +9 -63
- package/dist/cli/managed-service.js +2 -137
- package/dist/cli/options-init-chat.js +1 -108
- package/dist/cli/options-runtime.js +1 -158
- package/dist/cli/options-serve.js +1 -282
- package/dist/cli/options.js +2 -19
- package/dist/cli/process-guards.js +1 -139
- package/dist/cli/request-tree.js +7 -296
- package/dist/cli/runtime-commands.js +12 -258
- package/dist/cli/runtime-output.js +16 -155
- package/dist/cli/server-commands.js +16 -270
- package/dist/cli/workspace.js +1 -67
- package/dist/cli.js +1 -7
- package/dist/client/acp.js +1 -1
- package/dist/client/in-process.js +1 -67
- package/dist/client/index.js +1 -2
- package/dist/client/types.js +0 -1
- package/dist/client.js +1 -1
- package/dist/contracts/core.js +1 -1
- package/dist/contracts/runtime-evaluation.js +0 -1
- package/dist/contracts/runtime-memory.js +0 -1
- package/dist/contracts/runtime-observability.js +0 -1
- package/dist/contracts/runtime-requests.js +0 -1
- package/dist/contracts/runtime-scheduling.js +0 -1
- package/dist/contracts/runtime.js +1 -27
- package/dist/contracts/types.js +1 -3
- package/dist/contracts/workspace.js +0 -1
- package/dist/flow/build-flow-graph.js +1 -50
- package/dist/flow/export-mermaid.js +2 -464
- package/dist/flow/export-sequence-mermaid.js +2 -325
- package/dist/flow/flow-graph-normalization.js +1 -214
- package/dist/flow/flow-graph-runtime.js +1 -107
- package/dist/flow/flow-graph-upstream.js +1 -494
- package/dist/flow/index.js +1 -3
- package/dist/flow/types.js +0 -1
- package/dist/index.js +1 -5
- package/dist/init-project.js +1 -1
- package/dist/knowledge/config.js +1 -32
- package/dist/knowledge/contracts.js +0 -1
- package/dist/knowledge/index.js +1 -2
- package/dist/knowledge/module.js +12 -909
- package/dist/knowledge/procedural/config.js +1 -125
- package/dist/knowledge/procedural/index.js +1 -2
- package/dist/knowledge/procedural/manager.js +9 -345
- package/dist/mcp.js +1 -2
- package/dist/package-version.d.ts +2 -2
- package/dist/package-version.js +1 -2
- package/dist/persistence/file-store.js +3 -758
- package/dist/persistence/sqlite-request-context-store.js +5 -54
- package/dist/persistence/sqlite-request-queue-store.js +10 -108
- package/dist/persistence/sqlite-runtime.js +1 -86
- package/dist/persistence/sqlite-store.js +62 -810
- package/dist/persistence/types.js +0 -1
- package/dist/projections/presentation.js +37 -206
- package/dist/projections/request-events.js +2 -502
- package/dist/projections/upstream-events.js +1 -201
- package/dist/protocol/a2a/http-discovery.js +1 -178
- package/dist/protocol/a2a/http-rpc.js +6 -622
- package/dist/protocol/a2a/http.js +1 -138
- package/dist/protocol/a2a/task-state.js +3 -317
- package/dist/protocol/acp/client.js +8 -294
- package/dist/protocol/acp/harness-client.js +1 -218
- package/dist/protocol/acp/http.js +5 -130
- package/dist/protocol/acp/server.js +1 -310
- package/dist/protocol/acp/stdio.js +2 -69
- package/dist/protocol/ag-ui/http.js +3 -378
- package/dist/protocol/mcp/server.js +1 -428
- package/dist/resource/backend/workspace-scoped-backend.js +1 -319
- package/dist/resource/isolation.js +1 -237
- package/dist/resource/mcp/tool-support.js +3 -296
- package/dist/resource/mcp-tool-support.js +1 -2
- package/dist/resource/providers/resource-provider.js +1 -215
- package/dist/resource/resource-impl.js +1 -3
- package/dist/resource/resource-types.js +0 -1
- package/dist/resource/resource.js +1 -1
- package/dist/resource/sources.js +1 -247
- package/dist/resource/tools/function-tool-resolver.js +2 -272
- package/dist/runtime/adapter/compat/deepagent-compat.js +1 -29
- package/dist/runtime/adapter/compat/openai-compatible.js +1 -55
- package/dist/runtime/adapter/direct-builtin-utility.js +2 -90
- package/dist/runtime/adapter/flow/execution-context.js +1 -71
- package/dist/runtime/adapter/flow/invocation-flow.js +8 -411
- package/dist/runtime/adapter/flow/invoke-runtime.js +1 -20
- package/dist/runtime/adapter/flow/stream-runtime.js +11 -1395
- package/dist/runtime/adapter/invocation-result.js +2 -473
- package/dist/runtime/adapter/local-tool-invocation.js +6 -638
- package/dist/runtime/adapter/middleware/context-hygiene.js +1 -83
- package/dist/runtime/adapter/middleware-assembly.js +5 -477
- package/dist/runtime/adapter/model/invocation-request.js +3 -183
- package/dist/runtime/adapter/model/message-assembly.js +1 -28
- package/dist/runtime/adapter/model/model-providers.js +23 -1089
- package/dist/runtime/adapter/model/prompted-json-tool-call-capture.js +1 -40
- package/dist/runtime/adapter/model/prompted-json-tool-policy.js +1 -22
- package/dist/runtime/adapter/resilience.js +1 -104
- package/dist/runtime/adapter/runtime-adapter-support.js +3 -141
- package/dist/runtime/adapter/runtime-shell.js +5 -166
- package/dist/runtime/adapter/stream-event-projection.js +2 -622
- package/dist/runtime/adapter/stream-text-consumption.js +1 -18
- package/dist/runtime/adapter/terminal-status.js +2 -67
- package/dist/runtime/adapter/tool/builtin-middleware-tools.js +6 -627
- package/dist/runtime/adapter/tool/declared-middleware.js +1 -154
- package/dist/runtime/adapter/tool/interrupt-policy.js +1 -34
- package/dist/runtime/adapter/tool/provider-tool.js +1 -25
- package/dist/runtime/adapter/tool/resolved-tool.js +1 -225
- package/dist/runtime/adapter/tool/tool-arguments.js +3 -486
- package/dist/runtime/adapter/tool/tool-hitl.js +1 -346
- package/dist/runtime/adapter/tool/tool-name-mapping.js +1 -128
- package/dist/runtime/adapter/tool/tool-output-artifacts.js +2 -88
- package/dist/runtime/adapter/tool/tool-replay.js +1 -37
- package/dist/runtime/adapter/tool-resolution.js +1 -86
- package/dist/runtime/adapter/upstream-configurable-keys.js +1 -2
- package/dist/runtime/agent-runtime-adapter.js +60 -2338
- package/dist/runtime/agent-runtime-assembly.js +7 -249
- package/dist/runtime/env/runtime-env.js +1 -62
- package/dist/runtime/harness/background-runtime.js +1 -8
- package/dist/runtime/harness/bindings.js +1 -58
- package/dist/runtime/harness/events/event-bus.js +1 -16
- package/dist/runtime/harness/events/event-sink.js +1 -61
- package/dist/runtime/harness/events/events.js +1 -80
- package/dist/runtime/harness/events/listener-runtime.js +1 -13
- package/dist/runtime/harness/events/runtime-event-operations.js +1 -9
- package/dist/runtime/harness/events/streaming.js +1 -100
- package/dist/runtime/harness/events/timeline.js +1 -52
- package/dist/runtime/harness/public-shapes.js +1 -186
- package/dist/runtime/harness/run/artifact-paths.js +1 -15
- package/dist/runtime/harness/run/governance.js +1 -295
- package/dist/runtime/harness/run/helpers.js +1 -71
- package/dist/runtime/harness/run/inspection.js +1 -409
- package/dist/runtime/harness/run/operator-overview.js +1 -80
- package/dist/runtime/harness/run/queue-diagnostics.js +1 -15
- package/dist/runtime/harness/run/recovery.js +1 -162
- package/dist/runtime/harness/run/resources.js +1 -60
- package/dist/runtime/harness/run/resume.js +1 -56
- package/dist/runtime/harness/run/routing.js +1 -48
- package/dist/runtime/harness/run/run-lifecycle.js +1 -66
- package/dist/runtime/harness/run/run-operations.js +1 -217
- package/dist/runtime/harness/run/run-queue.js +1 -43
- package/dist/runtime/harness/run/run-slot-acquisition.js +1 -157
- package/dist/runtime/harness/run/session-records.js +1 -97
- package/dist/runtime/harness/run/start-run.js +1 -120
- package/dist/runtime/harness/run/startup-runtime.js +1 -69
- package/dist/runtime/harness/run/stream-run.js +8 -1418
- package/dist/runtime/harness/run/surface-semantics.js +1 -79
- package/dist/runtime/harness/runtime-defaults.js +1 -39
- package/dist/runtime/harness/system/boundary-analysis.js +1 -234
- package/dist/runtime/harness/system/health-monitor.js +1 -258
- package/dist/runtime/harness/system/inventory.js +1 -129
- package/dist/runtime/harness/system/mem0-ingestion-sync.js +5 -345
- package/dist/runtime/harness/system/policy-engine.js +1 -175
- package/dist/runtime/harness/system/runtime-memory-candidates.js +4 -110
- package/dist/runtime/harness/system/runtime-memory-consolidation.js +1 -51
- package/dist/runtime/harness/system/runtime-memory-manager.js +10 -693
- package/dist/runtime/harness/system/runtime-memory-policy.js +1 -155
- package/dist/runtime/harness/system/runtime-memory-records.js +11 -577
- package/dist/runtime/harness/system/runtime-memory-sync.js +5 -206
- package/dist/runtime/harness/system/session-memory-sync.js +3 -113
- package/dist/runtime/harness/system/skill-requirements.js +1 -112
- package/dist/runtime/harness/system/store.js +9 -365
- package/dist/runtime/harness/tool-gateway/index.js +1 -2
- package/dist/runtime/harness/tool-gateway/policy.js +1 -45
- package/dist/runtime/harness/tool-gateway/validation.js +1 -176
- package/dist/runtime/harness/tool-schema.js +1 -3
- package/dist/runtime/harness.js +3 -1490
- package/dist/runtime/index.js +1 -3
- package/dist/runtime/layout/runtime-layout.js +1 -31
- package/dist/runtime/maintenance/checkpoint-maintenance.js +2 -178
- package/dist/runtime/maintenance/file-checkpoint-saver.js +1 -106
- package/dist/runtime/maintenance/runtime-record-maintenance.js +2 -169
- package/dist/runtime/maintenance/sqlite-checkpoint-saver.js +4 -289
- package/dist/runtime/parsing/output-content.js +10 -550
- package/dist/runtime/parsing/output-parsing.js +1 -4
- package/dist/runtime/parsing/output-recovery.js +3 -213
- package/dist/runtime/parsing/output-tool-args.js +7 -663
- package/dist/runtime/parsing/stream-event-parsing.js +3 -362
- package/dist/runtime/prompts/runtime-prompts.js +4 -73
- package/dist/runtime/scheduling/system-schedule-manager.js +11 -532
- package/dist/runtime/skills/skill-metadata.js +1 -197
- package/dist/runtime/startup-tracing.js +2 -37
- package/dist/runtime/support/compiled-binding.js +1 -290
- package/dist/runtime/support/embedding-models.js +1 -118
- package/dist/runtime/support/harness-support.js +5 -137
- package/dist/runtime/support/llamaindex.js +1 -108
- package/dist/runtime/support/runtime-adapter-options.js +1 -29
- package/dist/runtime/support/runtime-factories.js +1 -51
- package/dist/runtime/support/vector-stores.js +9 -270
- package/dist/scaffold/init-project.js +54 -233
- package/dist/tooling/extensions.js +1 -311
- package/dist/tooling/module-loader.js +1 -55
- package/dist/tools.js +1 -176
- package/dist/utils/agent-display.js +1 -18
- package/dist/utils/bundled-text.js +4 -39
- package/dist/utils/compiled-binding.js +1 -33
- package/dist/utils/fs.js +2 -45
- package/dist/utils/id.js +1 -9
- package/dist/utils/message-content.js +1 -30
- package/dist/utils/object.js +1 -6
- package/dist/workspace/agent-binding-compiler.js +3 -613
- package/dist/workspace/compile.js +1 -472
- package/dist/workspace/framework-contract-validation.js +2 -322
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/object-loader-paths.js +1 -71
- package/dist/workspace/object-loader-readers.js +1 -187
- package/dist/workspace/object-loader.js +1 -754
- package/dist/workspace/resource-compilers.js +1 -374
- package/dist/workspace/support/agent-capabilities.js +1 -37
- package/dist/workspace/support/agent-execution-config.js +1 -44
- package/dist/workspace/support/discovery.js +1 -147
- package/dist/workspace/support/source-collectors.js +1 -30
- package/dist/workspace/support/source-protocols.js +2 -192
- package/dist/workspace/support/workspace-ref-utils.js +1 -362
- package/dist/workspace/tool-hydration.js +1 -280
- package/dist/workspace/validate.js +1 -99
- package/dist/workspace/yaml-object-reader.js +1 -285
- package/package.json +7 -3
|
@@ -1,285 +1 @@
|
|
|
1
|
-
import path from "node:
|
|
2
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
-
import { readdir } from "node:fs/promises";
|
|
4
|
-
import { parseAllDocuments } from "yaml";
|
|
5
|
-
import { fileExists, listFilesRecursive, readYamlOrJson } from "../utils/fs.js";
|
|
6
|
-
const ENV_PLACEHOLDER_PATTERN = /\$\{env:([A-Za-z_][A-Za-z0-9_]*)(?::-(.*?))?\}/g;
|
|
7
|
-
const DOTENV_LINE_PATTERN = /^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)?\s*$/;
|
|
8
|
-
function asObject(value) {
|
|
9
|
-
return typeof value === "object" && value ? value : undefined;
|
|
10
|
-
}
|
|
11
|
-
function stripMatchingQuotes(value) {
|
|
12
|
-
const trimmed = value.trim();
|
|
13
|
-
if (trimmed.length >= 2 &&
|
|
14
|
-
((trimmed.startsWith("\"") && trimmed.endsWith("\"")) || (trimmed.startsWith("'") && trimmed.endsWith("'")))) {
|
|
15
|
-
return trimmed.slice(1, -1);
|
|
16
|
-
}
|
|
17
|
-
return trimmed;
|
|
18
|
-
}
|
|
19
|
-
function parseDotenvFile(content) {
|
|
20
|
-
const parsed = {};
|
|
21
|
-
for (const rawLine of content.split(/\r?\n/u)) {
|
|
22
|
-
const line = rawLine.trim();
|
|
23
|
-
if (!line || line.startsWith("#")) {
|
|
24
|
-
continue;
|
|
25
|
-
}
|
|
26
|
-
const match = DOTENV_LINE_PATTERN.exec(rawLine);
|
|
27
|
-
if (!match) {
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
const [, key, rawValue = ""] = match;
|
|
31
|
-
parsed[key] = stripMatchingQuotes(rawValue);
|
|
32
|
-
}
|
|
33
|
-
return parsed;
|
|
34
|
-
}
|
|
35
|
-
function readNearestDotenvSync(startDirectory) {
|
|
36
|
-
const normalizedStart = path.resolve(startDirectory);
|
|
37
|
-
let current = normalizedStart;
|
|
38
|
-
while (true) {
|
|
39
|
-
const dotenvPath = path.join(current, ".env");
|
|
40
|
-
if (existsSync(dotenvPath)) {
|
|
41
|
-
return Object.freeze(parseDotenvFile(readFileSync(dotenvPath, "utf8")));
|
|
42
|
-
}
|
|
43
|
-
const parent = path.dirname(current);
|
|
44
|
-
if (parent === current) {
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
current = parent;
|
|
48
|
-
}
|
|
49
|
-
return Object.freeze({});
|
|
50
|
-
}
|
|
51
|
-
function resolveInterpolationEnv(sourcePath, envOverrides) {
|
|
52
|
-
const merged = { ...readNearestDotenvSync(path.dirname(sourcePath)) };
|
|
53
|
-
for (const [key, value] of Object.entries(process.env)) {
|
|
54
|
-
if (typeof value === "string") {
|
|
55
|
-
merged[key] = value;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
if (envOverrides) {
|
|
59
|
-
for (const [key, value] of Object.entries(envOverrides)) {
|
|
60
|
-
if (typeof value === "string") {
|
|
61
|
-
merged[key] = value;
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
delete merged[key];
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return merged;
|
|
69
|
-
}
|
|
70
|
-
function interpolateEnvString(value, sourcePath, envValues) {
|
|
71
|
-
return value.replaceAll(ENV_PLACEHOLDER_PATTERN, (_match, envName, defaultValue) => {
|
|
72
|
-
const resolved = envValues[envName];
|
|
73
|
-
if (typeof resolved === "string" && resolved.length > 0) {
|
|
74
|
-
return resolved;
|
|
75
|
-
}
|
|
76
|
-
if (typeof defaultValue === "string") {
|
|
77
|
-
return defaultValue;
|
|
78
|
-
}
|
|
79
|
-
if (typeof resolved !== "string" || resolved.length === 0) {
|
|
80
|
-
throw new Error(`YAML document ${sourcePath} references missing environment variable ${envName}`);
|
|
81
|
-
}
|
|
82
|
-
return resolved;
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
export function interpolateEnvPlaceholders(value, sourcePath, envOverrides) {
|
|
86
|
-
const envValues = resolveInterpolationEnv(sourcePath, envOverrides);
|
|
87
|
-
return interpolateEnvPlaceholdersWithEnv(value, sourcePath, envValues);
|
|
88
|
-
}
|
|
89
|
-
function interpolateEnvPlaceholdersWithEnv(value, sourcePath, envValues) {
|
|
90
|
-
if (typeof value === "string") {
|
|
91
|
-
return interpolateEnvString(value, sourcePath, envValues);
|
|
92
|
-
}
|
|
93
|
-
if (Array.isArray(value)) {
|
|
94
|
-
return value.map((entry) => interpolateEnvPlaceholdersWithEnv(entry, sourcePath, envValues));
|
|
95
|
-
}
|
|
96
|
-
if (typeof value === "object" && value !== null) {
|
|
97
|
-
return Object.fromEntries(Object.entries(value).map(([key, entry]) => [
|
|
98
|
-
key,
|
|
99
|
-
interpolateEnvPlaceholdersWithEnv(entry, sourcePath, envValues),
|
|
100
|
-
]));
|
|
101
|
-
}
|
|
102
|
-
return value;
|
|
103
|
-
}
|
|
104
|
-
function normalizeCatalogSpec(document, options = {}) {
|
|
105
|
-
const typed = asObject(document);
|
|
106
|
-
const spec = typed?.spec;
|
|
107
|
-
if (!Array.isArray(spec)) {
|
|
108
|
-
return [];
|
|
109
|
-
}
|
|
110
|
-
const normalized = spec
|
|
111
|
-
.filter((item) => typeof item === "object" && item !== null && !Array.isArray(item))
|
|
112
|
-
.map((item) => {
|
|
113
|
-
const id = typeof item.id === "string" && item.id.trim()
|
|
114
|
-
? item.id
|
|
115
|
-
: typeof item.name === "string" && item.name.trim()
|
|
116
|
-
? item.name
|
|
117
|
-
: undefined;
|
|
118
|
-
const itemKind = typeof item.kind === "string" && item.kind.trim()
|
|
119
|
-
? item.kind
|
|
120
|
-
: options.defaultKind;
|
|
121
|
-
if (!id || !itemKind) {
|
|
122
|
-
return null;
|
|
123
|
-
}
|
|
124
|
-
return {
|
|
125
|
-
...item,
|
|
126
|
-
kind: itemKind,
|
|
127
|
-
id,
|
|
128
|
-
};
|
|
129
|
-
});
|
|
130
|
-
return normalized.filter((item) => item !== null);
|
|
131
|
-
}
|
|
132
|
-
function normalizeKind(kind) {
|
|
133
|
-
switch (kind) {
|
|
134
|
-
case "Agent":
|
|
135
|
-
return "agent";
|
|
136
|
-
case "FileStore":
|
|
137
|
-
return "file-store";
|
|
138
|
-
case "SqliteStore":
|
|
139
|
-
return "sqlite-store";
|
|
140
|
-
case "InMemoryStore":
|
|
141
|
-
return "in-memory-store";
|
|
142
|
-
case "RedisStore":
|
|
143
|
-
return "redis-store";
|
|
144
|
-
case "PostgresStore":
|
|
145
|
-
return "postgres-store";
|
|
146
|
-
case "SqliteSaver":
|
|
147
|
-
return "sqlite-saver";
|
|
148
|
-
case "FileCheckpointer":
|
|
149
|
-
return "file-checkpointer";
|
|
150
|
-
case "Checkpointer":
|
|
151
|
-
return "checkpointer";
|
|
152
|
-
case "Model":
|
|
153
|
-
return "model";
|
|
154
|
-
case "EmbeddingModel":
|
|
155
|
-
return "embedding-model";
|
|
156
|
-
case "VectorStore":
|
|
157
|
-
return "vector-store";
|
|
158
|
-
case "ResponseFormat":
|
|
159
|
-
return "response-format";
|
|
160
|
-
case "Backend":
|
|
161
|
-
return "backend";
|
|
162
|
-
case "Store":
|
|
163
|
-
return "store";
|
|
164
|
-
case "Memory":
|
|
165
|
-
return "memory";
|
|
166
|
-
case "Tool":
|
|
167
|
-
return "tool";
|
|
168
|
-
case "Skill":
|
|
169
|
-
return "skill";
|
|
170
|
-
case "Runtime":
|
|
171
|
-
return "runtime";
|
|
172
|
-
case "RuntimeMemory":
|
|
173
|
-
return "runtime-memory";
|
|
174
|
-
case "ProceduralMemoryRuntime":
|
|
175
|
-
return "procedural-memory";
|
|
176
|
-
case "Prompt":
|
|
177
|
-
return "prompt";
|
|
178
|
-
case "McpServer":
|
|
179
|
-
return "mcp";
|
|
180
|
-
default:
|
|
181
|
-
return kind;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
export function normalizeYamlItem(item) {
|
|
185
|
-
if (item.kind === "DeepAgent" || item.kind === "LangChainAgent") {
|
|
186
|
-
throw new Error(`YAML object kind ${String(item.kind)} is no longer supported; use kind: Agent with spec.backend instead`);
|
|
187
|
-
}
|
|
188
|
-
const metadata = asObject(item.metadata);
|
|
189
|
-
const spec = asObject(item.spec);
|
|
190
|
-
const kind = typeof item.kind === "string" ? normalizeKind(item.kind) : undefined;
|
|
191
|
-
const name = typeof metadata?.name === "string" ? metadata.name : undefined;
|
|
192
|
-
const description = typeof metadata?.description === "string" ? metadata.description : undefined;
|
|
193
|
-
if (!spec && !metadata) {
|
|
194
|
-
return kind ? { ...item, kind } : item;
|
|
195
|
-
}
|
|
196
|
-
if (!spec && metadata) {
|
|
197
|
-
return {
|
|
198
|
-
...item,
|
|
199
|
-
...(description ? { description } : {}),
|
|
200
|
-
...(name ? { id: name } : {}),
|
|
201
|
-
...(kind ? { kind } : {}),
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
return {
|
|
205
|
-
...(spec ?? {}),
|
|
206
|
-
...(description ? { description } : {}),
|
|
207
|
-
...(name ? { id: name } : {}),
|
|
208
|
-
...(kind ? { kind } : {}),
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
async function objectItemsFromDocument(document, sourcePath) {
|
|
212
|
-
if (typeof document !== "object" || !document) {
|
|
213
|
-
return [];
|
|
214
|
-
}
|
|
215
|
-
const catalogKind = typeof document.kind === "string"
|
|
216
|
-
? String(document.kind)
|
|
217
|
-
: undefined;
|
|
218
|
-
const catalogItems = catalogKind === "Models"
|
|
219
|
-
? normalizeCatalogSpec(document, { defaultKind: "Model" })
|
|
220
|
-
: catalogKind === "EmbeddingModels"
|
|
221
|
-
? normalizeCatalogSpec(document, { defaultKind: "EmbeddingModel" })
|
|
222
|
-
: catalogKind === "VectorStores"
|
|
223
|
-
? normalizeCatalogSpec(document, { defaultKind: "VectorStore" })
|
|
224
|
-
: catalogKind === "ResponseFormats"
|
|
225
|
-
? normalizeCatalogSpec(document, { defaultKind: "ResponseFormat" })
|
|
226
|
-
: catalogKind === "Stores"
|
|
227
|
-
? normalizeCatalogSpec(document)
|
|
228
|
-
: catalogKind === "Backends"
|
|
229
|
-
? normalizeCatalogSpec(document, { defaultKind: "Backend" })
|
|
230
|
-
: catalogKind === "Tools" || catalogKind === "ToolSets"
|
|
231
|
-
? normalizeCatalogSpec(document, { defaultKind: "Tool" })
|
|
232
|
-
: catalogKind === "McpServers"
|
|
233
|
-
? normalizeCatalogSpec(document, { defaultKind: "McpServer" })
|
|
234
|
-
: [];
|
|
235
|
-
if (catalogItems.length > 0) {
|
|
236
|
-
return catalogItems;
|
|
237
|
-
}
|
|
238
|
-
if ("items" in document) {
|
|
239
|
-
throw new Error(`YAML document ${sourcePath} uses unsupported legacy items wrapper; use kind/spec catalog documents or metadata/spec objects instead`);
|
|
240
|
-
}
|
|
241
|
-
return [document];
|
|
242
|
-
}
|
|
243
|
-
export async function readYamlItems(root, relativeDir, options = {}) {
|
|
244
|
-
const targetRoot = relativeDir ? path.join(root, relativeDir) : root;
|
|
245
|
-
if (!(await fileExists(targetRoot))) {
|
|
246
|
-
return [];
|
|
247
|
-
}
|
|
248
|
-
const files = options.recursive
|
|
249
|
-
? Array.from(new Set([
|
|
250
|
-
...(await listFilesRecursive(targetRoot, ".yaml")),
|
|
251
|
-
...(await listFilesRecursive(targetRoot, ".yml")),
|
|
252
|
-
])).sort()
|
|
253
|
-
: (await readdir(targetRoot, { withFileTypes: true }))
|
|
254
|
-
.filter((entry) => entry.isFile() && /\.ya?ml$/i.test(entry.name))
|
|
255
|
-
.map((entry) => path.join(targetRoot, entry.name))
|
|
256
|
-
.sort();
|
|
257
|
-
const records = [];
|
|
258
|
-
for (const filePath of files) {
|
|
259
|
-
const parsedDocuments = parseAllDocuments(await readYamlOrJson(filePath));
|
|
260
|
-
for (const parsedDocument of parsedDocuments) {
|
|
261
|
-
const resolvedDocument = interpolateEnvPlaceholders(parsedDocument.toJSON(), filePath);
|
|
262
|
-
for (const item of await objectItemsFromDocument(resolvedDocument, filePath)) {
|
|
263
|
-
records.push({ item: normalizeYamlItem(item), sourcePath: filePath });
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
return records;
|
|
268
|
-
}
|
|
269
|
-
export async function readNamedYamlItems(root, filenames) {
|
|
270
|
-
const records = [];
|
|
271
|
-
for (const filename of filenames) {
|
|
272
|
-
const filePath = path.join(root, filename);
|
|
273
|
-
if (!(await fileExists(filePath))) {
|
|
274
|
-
continue;
|
|
275
|
-
}
|
|
276
|
-
const parsedDocuments = parseAllDocuments(await readYamlOrJson(filePath));
|
|
277
|
-
for (const parsedDocument of parsedDocuments) {
|
|
278
|
-
const resolvedDocument = interpolateEnvPlaceholders(parsedDocument.toJSON(), filePath);
|
|
279
|
-
for (const item of await objectItemsFromDocument(resolvedDocument, filePath)) {
|
|
280
|
-
records.push({ item: normalizeYamlItem(item), sourcePath: filePath });
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
return records;
|
|
285
|
-
}
|
|
1
|
+
import c from"node:path";import{existsSync as b,readFileSync as E}from"node:fs";import{readdir as j}from"node:fs/promises";import{parseAllDocuments as p}from"yaml";import{fileExists as m,listFilesRecursive as y,readYamlOrJson as g}from"../utils/fs.js";const M=/\$\{env:([A-Za-z_][A-Za-z0-9_]*)(?::-(.*?))?\}/g,v=/^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)?\s*$/;function u(e){return typeof e=="object"&&e?e:void 0}function z(e){const r=e.trim();return r.length>=2&&(r.startsWith('"')&&r.endsWith('"')||r.startsWith("'")&&r.endsWith("'"))?r.slice(1,-1):r}function D(e){const r={};for(const t of e.split(/\r?\n/u)){const n=t.trim();if(!n||n.startsWith("#"))continue;const s=v.exec(t);if(!s)continue;const[,o,i=""]=s;r[o]=z(i)}return r}function R(e){let t=c.resolve(e);for(;;){const n=c.join(t,".env");if(b(n))return Object.freeze(D(E(n,"utf8")));const s=c.dirname(t);if(s===t)break;t=s}return Object.freeze({})}function F(e,r){const t={...R(c.dirname(e))};for(const[n,s]of Object.entries(process.env))typeof s=="string"&&(t[n]=s);if(r)for(const[n,s]of Object.entries(r))typeof s=="string"?t[n]=s:delete t[n];return t}function K(e,r,t){return e.replaceAll(M,(n,s,o)=>{const i=t[s];if(typeof i=="string"&&i.length>0)return i;if(typeof o=="string")return o;if(typeof i!="string"||i.length===0)throw new Error(`YAML document ${r} references missing environment variable ${s}`);return i})}function h(e,r,t){const n=F(r,t);return l(e,r,n)}function l(e,r,t){return typeof e=="string"?K(e,r,t):Array.isArray(e)?e.map(n=>l(n,r,t)):typeof e=="object"&&e!==null?Object.fromEntries(Object.entries(e).map(([n,s])=>[n,l(s,r,t)])):e}function a(e,r={}){const n=u(e)?.spec;return Array.isArray(n)?n.filter(o=>typeof o=="object"&&o!==null&&!Array.isArray(o)).map(o=>{const i=typeof o.id=="string"&&o.id.trim()?o.id:typeof o.name=="string"&&o.name.trim()?o.name:void 0,d=typeof o.kind=="string"&&o.kind.trim()?o.kind:r.defaultKind;return!i||!d?null:{...o,kind:d,id:i}}).filter(o=>o!==null):[]}function O(e){switch(e){case"Agent":return"agent";case"FileStore":return"file-store";case"SqliteStore":return"sqlite-store";case"InMemoryStore":return"in-memory-store";case"RedisStore":return"redis-store";case"PostgresStore":return"postgres-store";case"SqliteSaver":return"sqlite-saver";case"FileCheckpointer":return"file-checkpointer";case"Checkpointer":return"checkpointer";case"Model":return"model";case"EmbeddingModel":return"embedding-model";case"VectorStore":return"vector-store";case"ResponseFormat":return"response-format";case"Backend":return"backend";case"Store":return"store";case"Memory":return"memory";case"Tool":return"tool";case"Skill":return"skill";case"Runtime":return"runtime";case"RuntimeMemory":return"runtime-memory";case"ProceduralMemoryRuntime":return"procedural-memory";case"Prompt":return"prompt";case"McpServer":return"mcp";default:return e}}function S(e){if(e.kind==="DeepAgent"||e.kind==="LangChainAgent")throw new Error(`YAML object kind ${String(e.kind)} is no longer supported; use kind: Agent with spec.backend instead`);const r=u(e.metadata),t=u(e.spec),n=typeof e.kind=="string"?O(e.kind):void 0,s=typeof r?.name=="string"?r.name:void 0,o=typeof r?.description=="string"?r.description:void 0;return!t&&!r?n?{...e,kind:n}:e:!t&&r?{...e,...o?{description:o}:{},...s?{id:s}:{},...n?{kind:n}:{}}:{...t??{},...o?{description:o}:{},...s?{id:s}:{},...n?{kind:n}:{}}}async function k(e,r){if(typeof e!="object"||!e)return[];const t=typeof e.kind=="string"?String(e.kind):void 0,n=t==="Models"?a(e,{defaultKind:"Model"}):t==="EmbeddingModels"?a(e,{defaultKind:"EmbeddingModel"}):t==="VectorStores"?a(e,{defaultKind:"VectorStore"}):t==="ResponseFormats"?a(e,{defaultKind:"ResponseFormat"}):t==="Stores"?a(e):t==="Backends"?a(e,{defaultKind:"Backend"}):t==="Tools"||t==="ToolSets"?a(e,{defaultKind:"Tool"}):t==="McpServers"?a(e,{defaultKind:"McpServer"}):[];if(n.length>0)return n;if("items"in e)throw new Error(`YAML document ${r} uses unsupported legacy items wrapper; use kind/spec catalog documents or metadata/spec objects instead`);return[e]}async function L(e,r,t={}){const n=r?c.join(e,r):e;if(!await m(n))return[];const s=t.recursive?Array.from(new Set([...await y(n,".yaml"),...await y(n,".yml")])).sort():(await j(n,{withFileTypes:!0})).filter(i=>i.isFile()&&/\.ya?ml$/i.test(i.name)).map(i=>c.join(n,i.name)).sort(),o=[];for(const i of s){const d=p(await g(i));for(const f of d){const w=h(f.toJSON(),i);for(const A of await k(w,i))o.push({item:S(A),sourcePath:i})}}return o}async function N(e,r){const t=[];for(const n of r){const s=c.join(e,n);if(!await m(s))continue;const o=p(await g(s));for(const i of o){const d=h(i.toJSON(),s);for(const f of await k(d,s))t.push({item:S(f),sourcePath:s})}}return t}export{h as interpolateEnvPlaceholders,S as normalizeYamlItem,N as readNamedYamlItems,L as readYamlItems};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botbotgo/agent-harness",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.476",
|
|
4
4
|
"description": "Workspace runtime for multi-agent applications",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"scripts": {
|
|
68
68
|
"agent-harness": "npm run build --silent && node dist/cli.js",
|
|
69
69
|
"chat": "npm run build --silent && node dist/cli.js chat",
|
|
70
|
-
"build": "rm -rf dist tsconfig.tsbuildinfo && tsc -p tsconfig.json && cp -R config resources dist/ && chmod +x dist/cli.js",
|
|
70
|
+
"build": "rm -rf dist tsconfig.tsbuildinfo && tsc -p tsconfig.json && cp -R config resources dist/ && node ./scripts/minify-dist-js.mjs && chmod +x dist/cli.js",
|
|
71
71
|
"check": "tsc -p tsconfig.json --noEmit",
|
|
72
72
|
"test": "vitest run $(find test -name '*.test.ts' -print | sort)",
|
|
73
73
|
"test:ci:runtime": "node ./scripts/run-vitest-suite.mjs ci-runtime",
|
|
@@ -82,13 +82,17 @@
|
|
|
82
82
|
"docs:sync-dev-nav": "node ./scripts/sync-developer-docs-nav.mjs",
|
|
83
83
|
"docs:sync-release-notes": "node ./scripts/sync-release-notes-html.mjs",
|
|
84
84
|
"docs:sync-docs-html": "node ./scripts/sync-release-notes-html.mjs && node ./scripts/sync-developer-docs-nav.mjs",
|
|
85
|
+
"prepublishOnly": "node ./scripts/npm-package-readme.mjs apply",
|
|
86
|
+
"postpack": "node ./scripts/npm-package-readme.mjs restore",
|
|
87
|
+
"postpublish": "node ./scripts/npm-package-readme.mjs restore",
|
|
85
88
|
"release:prepare": "node ./scripts/prepare-release-version.mjs && node ./scripts/sync-example-version.mjs && node ./scripts/archive-release-notes.mjs && node ./scripts/sync-release-notes-html.mjs",
|
|
86
|
-
"release:pack": "npm pack --dry-run",
|
|
89
|
+
"release:pack": "node ./scripts/npm-package-readme.mjs apply && npm pack --dry-run",
|
|
87
90
|
"release:publish": "npm publish --access public --registry https://registry.npmjs.org/"
|
|
88
91
|
},
|
|
89
92
|
"devDependencies": {
|
|
90
93
|
"@langchain/community": "^1.1.27",
|
|
91
94
|
"@types/node": "^25.6.0",
|
|
95
|
+
"esbuild": "^0.27.7",
|
|
92
96
|
"typescript": "^6.0.2",
|
|
93
97
|
"vite": "^8.0.10",
|
|
94
98
|
"vitest": "^4.1.5"
|