@botbotgo/agent-harness 0.0.475 → 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 +1 -1
- 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 -425
- 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 -1115
- 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,374 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
function asObject(value) {
|
|
3
|
-
return typeof value === "object" && value ? value : undefined;
|
|
4
|
-
}
|
|
5
|
-
function asStringArray(value) {
|
|
6
|
-
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
7
|
-
}
|
|
8
|
-
function asRefArray(value) {
|
|
9
|
-
return toArray(value)
|
|
10
|
-
.map((item) => typeof item === "string" ? item : typeof item === "object" && item && "ref" in item ? String(item.ref) : undefined)
|
|
11
|
-
.filter((item) => Boolean(item));
|
|
12
|
-
}
|
|
13
|
-
function toArray(value) {
|
|
14
|
-
return Array.isArray(value) ? value : [];
|
|
15
|
-
}
|
|
16
|
-
function mergeObjects(base, extra) {
|
|
17
|
-
if (!base && !extra) {
|
|
18
|
-
return undefined;
|
|
19
|
-
}
|
|
20
|
-
return {
|
|
21
|
-
...(base ?? {}),
|
|
22
|
-
...(extra ?? {}),
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
function extractTopLevelInitFields(value, reservedKeys) {
|
|
26
|
-
const reserved = new Set(reservedKeys);
|
|
27
|
-
const entries = Object.entries(value).filter(([key]) => !reserved.has(key));
|
|
28
|
-
if (entries.length === 0) {
|
|
29
|
-
return undefined;
|
|
30
|
-
}
|
|
31
|
-
return Object.fromEntries(entries);
|
|
32
|
-
}
|
|
33
|
-
const NUMERIC_MODEL_INIT_FIELDS = new Set([
|
|
34
|
-
"maxRetries",
|
|
35
|
-
"maxTokens",
|
|
36
|
-
"numCtx",
|
|
37
|
-
"numGpu",
|
|
38
|
-
"numPredict",
|
|
39
|
-
"numThread",
|
|
40
|
-
"repeatPenalty",
|
|
41
|
-
"temperature",
|
|
42
|
-
"timeout",
|
|
43
|
-
"topK",
|
|
44
|
-
"topP",
|
|
45
|
-
]);
|
|
46
|
-
const BOOLEAN_MODEL_INIT_FIELDS = new Set([
|
|
47
|
-
"omitAuthHeader",
|
|
48
|
-
"think",
|
|
49
|
-
]);
|
|
50
|
-
function normalizeModelInitFields(init) {
|
|
51
|
-
return Object.fromEntries(Object.entries(init).map(([key, value]) => {
|
|
52
|
-
if (NUMERIC_MODEL_INIT_FIELDS.has(key) && typeof value === "string") {
|
|
53
|
-
const trimmed = value.trim();
|
|
54
|
-
if (/^-?(?:\d+|\d*\.\d+)$/.test(trimmed)) {
|
|
55
|
-
return [key, Number(trimmed)];
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
if (BOOLEAN_MODEL_INIT_FIELDS.has(key) && typeof value === "string") {
|
|
59
|
-
const trimmed = value.trim().toLowerCase();
|
|
60
|
-
if (trimmed === "true") {
|
|
61
|
-
return [key, true];
|
|
62
|
-
}
|
|
63
|
-
if (trimmed === "false") {
|
|
64
|
-
return [key, false];
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return [key, value];
|
|
68
|
-
}));
|
|
69
|
-
}
|
|
70
|
-
function assertNoInitBlock(value, kind, id) {
|
|
71
|
-
if (value.init !== undefined) {
|
|
72
|
-
throw new Error(`${kind} ${id} must define provider options at the top level; nested init is not supported`);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
function parseHitlPolicy(value) {
|
|
76
|
-
const record = asObject(value);
|
|
77
|
-
if (!record) {
|
|
78
|
-
return undefined;
|
|
79
|
-
}
|
|
80
|
-
const enabled = record.enabled === true;
|
|
81
|
-
const allow = Array.isArray(record.allow)
|
|
82
|
-
? record.allow.filter((item) => item === "approve" || item === "edit" || item === "reject")
|
|
83
|
-
: undefined;
|
|
84
|
-
return {
|
|
85
|
-
enabled,
|
|
86
|
-
allow: allow && allow.length > 0 ? allow : undefined,
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
function deriveParsedToolName(inferredType, rawName, implementationName) {
|
|
90
|
-
const explicitName = String(rawName ?? "").trim();
|
|
91
|
-
if (explicitName) {
|
|
92
|
-
return explicitName;
|
|
93
|
-
}
|
|
94
|
-
if (inferredType !== "function") {
|
|
95
|
-
return "";
|
|
96
|
-
}
|
|
97
|
-
return typeof implementationName === "string" ? implementationName.trim() : "";
|
|
98
|
-
}
|
|
99
|
-
export function parseModelObject(object) {
|
|
100
|
-
const value = object.value;
|
|
101
|
-
assertNoInitBlock(value, "Model", object.id);
|
|
102
|
-
const provider = String(value.provider ?? "").trim();
|
|
103
|
-
const model = String((value.model ?? value.name) ?? "").trim();
|
|
104
|
-
const init = normalizeModelInitFields(extractTopLevelInitFields(value, ["apiVersion", "id", "kind", "provider", "model", "name", "init", "clientRef", "fallbacks", "metadata"]) ?? {});
|
|
105
|
-
const fallbacks = Array.isArray(value.fallbacks)
|
|
106
|
-
? value.fallbacks
|
|
107
|
-
.map((item) => (typeof item === "object" && item && "ref" in item ? String(item.ref) : undefined))
|
|
108
|
-
.filter((item) => Boolean(item))
|
|
109
|
-
: [];
|
|
110
|
-
return {
|
|
111
|
-
id: object.id,
|
|
112
|
-
provider,
|
|
113
|
-
model,
|
|
114
|
-
init,
|
|
115
|
-
clientRef: typeof value.clientRef === "string" ? value.clientRef : undefined,
|
|
116
|
-
fallbacks,
|
|
117
|
-
metadata: asObject(value.metadata),
|
|
118
|
-
sourcePath: object.sourcePath,
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
export function parseEmbeddingModelObject(object) {
|
|
122
|
-
const value = object.value;
|
|
123
|
-
assertNoInitBlock(value, "EmbeddingModel", object.id);
|
|
124
|
-
const provider = String(value.provider ?? "").trim();
|
|
125
|
-
const model = String((value.model ?? value.name) ?? "").trim();
|
|
126
|
-
const init = normalizeModelInitFields(extractTopLevelInitFields(value, ["apiVersion", "id", "kind", "provider", "model", "name", "init", "clientRef", "metadata"]) ?? {});
|
|
127
|
-
return {
|
|
128
|
-
id: object.id,
|
|
129
|
-
provider,
|
|
130
|
-
model,
|
|
131
|
-
init,
|
|
132
|
-
clientRef: typeof value.clientRef === "string" ? value.clientRef : undefined,
|
|
133
|
-
metadata: asObject(value.metadata),
|
|
134
|
-
sourcePath: object.sourcePath,
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
export function parseVectorStoreObject(object) {
|
|
138
|
-
const value = object.value;
|
|
139
|
-
const port = typeof value.port === "number" && Number.isInteger(value.port) ? value.port : undefined;
|
|
140
|
-
return {
|
|
141
|
-
id: object.id,
|
|
142
|
-
kind: String(value.storeKind ?? value.kind ?? "LibSQLVectorStore").trim(),
|
|
143
|
-
url: typeof value.url === "string" ? value.url : undefined,
|
|
144
|
-
host: typeof value.host === "string" ? value.host : undefined,
|
|
145
|
-
port,
|
|
146
|
-
authToken: typeof value.authToken === "string" ? value.authToken : undefined,
|
|
147
|
-
table: typeof value.table === "string" ? value.table : undefined,
|
|
148
|
-
column: typeof value.column === "string" ? value.column : undefined,
|
|
149
|
-
collection: typeof value.collection === "string"
|
|
150
|
-
? value.collection
|
|
151
|
-
: typeof value.collectionName === "string"
|
|
152
|
-
? value.collectionName
|
|
153
|
-
: undefined,
|
|
154
|
-
embeddingModelRef: typeof value.embeddingModelRef === "string"
|
|
155
|
-
? value.embeddingModelRef
|
|
156
|
-
: typeof asObject(value.embeddingModel)?.ref === "string"
|
|
157
|
-
? String(asObject(value.embeddingModel)?.ref)
|
|
158
|
-
: undefined,
|
|
159
|
-
metadata: asObject(value.metadata),
|
|
160
|
-
sourcePath: object.sourcePath,
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
export function parseMcpServerObject(object) {
|
|
164
|
-
const value = object.value;
|
|
165
|
-
const env = asObject(value.env);
|
|
166
|
-
const headers = asObject(value.headers);
|
|
167
|
-
const oauth = asObject(value.oauth);
|
|
168
|
-
const transport = String(value.transport ??
|
|
169
|
-
(typeof value.url === "string" && value.url.trim() ? "http" : undefined) ??
|
|
170
|
-
(typeof value.command === "string" && value.command.trim() ? "stdio" : undefined) ??
|
|
171
|
-
"stdio").trim();
|
|
172
|
-
return {
|
|
173
|
-
id: object.id,
|
|
174
|
-
transport,
|
|
175
|
-
url: typeof value.url === "string" ? value.url : undefined,
|
|
176
|
-
command: typeof value.command === "string" ? value.command : undefined,
|
|
177
|
-
args: asStringArray(value.args),
|
|
178
|
-
env: env ? Object.fromEntries(Object.entries(env).filter((entry) => typeof entry[1] === "string")) : undefined,
|
|
179
|
-
cwd: typeof value.cwd === "string" ? value.cwd : undefined,
|
|
180
|
-
token: typeof value.token === "string" ? value.token : undefined,
|
|
181
|
-
headers: headers ? Object.fromEntries(Object.entries(headers).filter((entry) => typeof entry[1] === "string")) : undefined,
|
|
182
|
-
trustTier: value.trustTier === "trusted" || value.trustTier === "reviewed" || value.trustTier === "untrusted"
|
|
183
|
-
? value.trustTier
|
|
184
|
-
: undefined,
|
|
185
|
-
access: value.access === "read-only" || value.access === "read-write" ? value.access : undefined,
|
|
186
|
-
tenantScope: value.tenantScope === "workspace" ||
|
|
187
|
-
value.tenantScope === "project" ||
|
|
188
|
-
value.tenantScope === "tenant" ||
|
|
189
|
-
value.tenantScope === "cross-tenant"
|
|
190
|
-
? value.tenantScope
|
|
191
|
-
: undefined,
|
|
192
|
-
approvalPolicy: value.approvalPolicy === "always" || value.approvalPolicy === "write" || value.approvalPolicy === "never"
|
|
193
|
-
? value.approvalPolicy
|
|
194
|
-
: undefined,
|
|
195
|
-
promptInjectionRisk: value.promptInjectionRisk === "low" || value.promptInjectionRisk === "medium" || value.promptInjectionRisk === "high"
|
|
196
|
-
? value.promptInjectionRisk
|
|
197
|
-
: undefined,
|
|
198
|
-
oauth: oauth
|
|
199
|
-
? {
|
|
200
|
-
provider: typeof oauth.provider === "string" ? oauth.provider : undefined,
|
|
201
|
-
scopes: asStringArray(oauth.scopes),
|
|
202
|
-
}
|
|
203
|
-
: undefined,
|
|
204
|
-
labels: asStringArray(value.labels),
|
|
205
|
-
sourcePath: object.sourcePath,
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
export function validateModelObject(model, models) {
|
|
209
|
-
if (!model.provider) {
|
|
210
|
-
throw new Error(`Model ${model.id} provider must not be empty`);
|
|
211
|
-
}
|
|
212
|
-
if (!model.model) {
|
|
213
|
-
throw new Error(`Model ${model.id} model must not be empty`);
|
|
214
|
-
}
|
|
215
|
-
for (const fallback of model.fallbacks) {
|
|
216
|
-
const targetId = fallback.split("/").slice(1).join("/");
|
|
217
|
-
if (!models.has(targetId)) {
|
|
218
|
-
throw new Error(`Model ${model.id} fallback ${fallback} does not exist`);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
export function validateEmbeddingModelObject(model) {
|
|
223
|
-
if (!model.provider) {
|
|
224
|
-
throw new Error(`Embedding model ${model.id} provider must not be empty`);
|
|
225
|
-
}
|
|
226
|
-
if (!model.model) {
|
|
227
|
-
throw new Error(`Embedding model ${model.id} model must not be empty`);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
export function validateVectorStoreObject(vectorStore) {
|
|
231
|
-
if (!vectorStore.kind) {
|
|
232
|
-
throw new Error(`Vector store ${vectorStore.id} kind must not be empty`);
|
|
233
|
-
}
|
|
234
|
-
if ((vectorStore.kind === "LibSQLVectorStore" || vectorStore.kind === "LlamaIndexSimpleVectorStore") && !vectorStore.url) {
|
|
235
|
-
throw new Error(`Vector store ${vectorStore.id} url must not be empty for ${vectorStore.kind}`);
|
|
236
|
-
}
|
|
237
|
-
if (vectorStore.kind === "QdrantVectorStore") {
|
|
238
|
-
if (!vectorStore.url && !vectorStore.host) {
|
|
239
|
-
throw new Error(`Vector store ${vectorStore.id} must define url or host for QdrantVectorStore`);
|
|
240
|
-
}
|
|
241
|
-
if (!vectorStore.collection) {
|
|
242
|
-
throw new Error(`Vector store ${vectorStore.id} collection must not be empty for QdrantVectorStore`);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
export function validateMcpServerObject(server) {
|
|
247
|
-
if (!server.id.trim()) {
|
|
248
|
-
throw new Error("MCP server id must not be empty");
|
|
249
|
-
}
|
|
250
|
-
if (server.transport === "stdio") {
|
|
251
|
-
if (!server.command?.trim()) {
|
|
252
|
-
throw new Error(`MCP server ${server.id} command must not be empty for stdio transport`);
|
|
253
|
-
}
|
|
254
|
-
return;
|
|
255
|
-
}
|
|
256
|
-
if (!server.url?.trim()) {
|
|
257
|
-
throw new Error(`MCP server ${server.id} url must not be empty for ${server.transport} transport`);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
export function compileModel(model) {
|
|
261
|
-
return {
|
|
262
|
-
id: model.id,
|
|
263
|
-
provider: model.provider,
|
|
264
|
-
model: model.model,
|
|
265
|
-
init: normalizeModelInitFields(model.init),
|
|
266
|
-
clientRef: model.clientRef,
|
|
267
|
-
fallbacks: model.fallbacks,
|
|
268
|
-
runtimeValue: `${model.provider}:${model.model}`,
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
export function compileVectorStore(vectorStore) {
|
|
272
|
-
return {
|
|
273
|
-
id: vectorStore.id,
|
|
274
|
-
kind: vectorStore.kind,
|
|
275
|
-
url: vectorStore.url,
|
|
276
|
-
host: vectorStore.host,
|
|
277
|
-
port: vectorStore.port,
|
|
278
|
-
authToken: vectorStore.authToken,
|
|
279
|
-
table: vectorStore.table,
|
|
280
|
-
column: vectorStore.column,
|
|
281
|
-
collection: vectorStore.collection,
|
|
282
|
-
embeddingModelRef: vectorStore.embeddingModelRef,
|
|
283
|
-
runtimeValue: vectorStore.kind,
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
export function compileEmbeddingModel(model) {
|
|
287
|
-
return {
|
|
288
|
-
id: model.id,
|
|
289
|
-
provider: model.provider,
|
|
290
|
-
model: model.model,
|
|
291
|
-
init: normalizeModelInitFields(model.init),
|
|
292
|
-
clientRef: model.clientRef,
|
|
293
|
-
runtimeValue: `${model.provider}:${model.model}`,
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
export function parseToolObject(object) {
|
|
297
|
-
const value = object.value;
|
|
298
|
-
const backend = asObject(value.backend);
|
|
299
|
-
const mcp = asObject(value.mcp);
|
|
300
|
-
const providerTool = asObject(value.providerTool) ?? asObject(value.provider);
|
|
301
|
-
const mcpReferenceConfig = mcp
|
|
302
|
-
? {
|
|
303
|
-
...(typeof mcp.serverRef === "string"
|
|
304
|
-
? { serverRef: mcp.serverRef }
|
|
305
|
-
: typeof mcp.server === "string"
|
|
306
|
-
? { serverRef: mcp.server }
|
|
307
|
-
: {}),
|
|
308
|
-
}
|
|
309
|
-
: undefined;
|
|
310
|
-
const mcpServerConfig = mcp
|
|
311
|
-
? Object.fromEntries(Object.entries(mcp).filter(([key]) => key !== "ref" && key !== "serverRef" && key !== "tool"))
|
|
312
|
-
: undefined;
|
|
313
|
-
const bundleRefs = asRefArray(value.tools ?? value.refs ?? value.bundle);
|
|
314
|
-
const inferredType = typeof value.type === "string"
|
|
315
|
-
? value.type
|
|
316
|
-
: bundleRefs.length > 0
|
|
317
|
-
? "bundle"
|
|
318
|
-
: mcp
|
|
319
|
-
? "mcp"
|
|
320
|
-
: providerTool
|
|
321
|
-
? "provider"
|
|
322
|
-
: backend
|
|
323
|
-
? "backend"
|
|
324
|
-
: "function";
|
|
325
|
-
const implementationName = typeof value.implementationName === "string" ? value.implementationName : undefined;
|
|
326
|
-
return {
|
|
327
|
-
id: object.id,
|
|
328
|
-
type: String(inferredType),
|
|
329
|
-
name: deriveParsedToolName(String(inferredType), value.name, implementationName),
|
|
330
|
-
description: String(value.description ?? "").trim(),
|
|
331
|
-
implementationName,
|
|
332
|
-
config: mergeObjects(mergeObjects(asObject(value.config), providerTool
|
|
333
|
-
? {
|
|
334
|
-
providerTool,
|
|
335
|
-
}
|
|
336
|
-
: undefined), (mcpReferenceConfig && Object.keys(mcpReferenceConfig).length > 0) || (mcpServerConfig && Object.keys(mcpServerConfig).length > 0)
|
|
337
|
-
? {
|
|
338
|
-
mcp: mcpReferenceConfig,
|
|
339
|
-
...(mcpServerConfig && Object.keys(mcpServerConfig).length > 0 ? { mcpServer: mcpServerConfig } : {}),
|
|
340
|
-
}
|
|
341
|
-
: undefined),
|
|
342
|
-
subprocess: value.subprocess === true ? true : undefined,
|
|
343
|
-
inputSchemaRef: typeof asObject(value.inputSchema)?.ref === "string" ? String(asObject(value.inputSchema)?.ref) : undefined,
|
|
344
|
-
hasModuleSchema: value.hasModuleSchema === true ? true : undefined,
|
|
345
|
-
modelSchema: asObject(value.modelSchema),
|
|
346
|
-
embeddingModelRef: typeof value.embeddingModelRef === "string"
|
|
347
|
-
? value.embeddingModelRef
|
|
348
|
-
: typeof value.embeddingModel === "string"
|
|
349
|
-
? `embedding-model/${String(value.embeddingModel).trim()}`
|
|
350
|
-
: typeof asObject(value.embeddingModel)?.ref === "string"
|
|
351
|
-
? String(asObject(value.embeddingModel)?.ref)
|
|
352
|
-
: undefined,
|
|
353
|
-
backendOperation: typeof backend?.operation === "string"
|
|
354
|
-
? backend.operation
|
|
355
|
-
: typeof value.operation === "string"
|
|
356
|
-
? value.operation
|
|
357
|
-
: undefined,
|
|
358
|
-
mcpRef: typeof mcp?.tool === "string"
|
|
359
|
-
? mcp.tool
|
|
360
|
-
: typeof mcp?.ref === "string"
|
|
361
|
-
? mcp.ref
|
|
362
|
-
: undefined,
|
|
363
|
-
bundleRefs,
|
|
364
|
-
hitl: parseHitlPolicy(value.hitl),
|
|
365
|
-
retryable: value.retryable === true ? true : undefined,
|
|
366
|
-
sourcePath: object.sourcePath,
|
|
367
|
-
};
|
|
368
|
-
}
|
|
369
|
-
export function validateToolObject(tool, tools) {
|
|
370
|
-
validateToolWithRegistry(tool, tools);
|
|
371
|
-
}
|
|
372
|
-
export function compileTool(tool, tools) {
|
|
373
|
-
return compileToolWithRegistry(tool, tools);
|
|
374
|
-
}
|
|
1
|
+
import{compileToolWithRegistry as y,validateToolWithRegistry as h}from"../tooling/extensions.js";function i(t){return typeof t=="object"&&t?t:void 0}function c(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}function w(t){return k(t).map(e=>typeof e=="string"?e:typeof e=="object"&&e&&"ref"in e?String(e.ref):void 0).filter(e=>!!e)}function k(t){return Array.isArray(t)?t:[]}function m(t,e){if(!(!t&&!e))return{...t??{},...e??{}}}function g(t,e){const r=new Set(e),n=Object.entries(t).filter(([o])=>!r.has(o));if(n.length!==0)return Object.fromEntries(n)}const R=new Set(["maxRetries","maxTokens","numCtx","numGpu","numPredict","numThread","repeatPenalty","temperature","timeout","topK","topP"]),M=new Set(["omitAuthHeader","think"]);function f(t){return Object.fromEntries(Object.entries(t).map(([e,r])=>{if(R.has(e)&&typeof r=="string"){const n=r.trim();if(/^-?(?:\d+|\d*\.\d+)$/.test(n))return[e,Number(n)]}if(M.has(e)&&typeof r=="string"){const n=r.trim().toLowerCase();if(n==="true")return[e,!0];if(n==="false")return[e,!1]}return[e,r]}))}function b(t,e,r){if(t.init!==void 0)throw new Error(`${e} ${r} must define provider options at the top level; nested init is not supported`)}function v(t){const e=i(t);if(!e)return;const r=e.enabled===!0,n=Array.isArray(e.allow)?e.allow.filter(o=>o==="approve"||o==="edit"||o==="reject"):void 0;return{enabled:r,allow:n&&n.length>0?n:void 0}}function E(t,e,r){const n=String(e??"").trim();return n||(t!=="function"?"":typeof r=="string"?r.trim():"")}function S(t){const e=t.value;b(e,"Model",t.id);const r=String(e.provider??"").trim(),n=String(e.model??e.name??"").trim(),o=f(g(e,["apiVersion","id","kind","provider","model","name","init","clientRef","fallbacks","metadata"])??{}),s=Array.isArray(e.fallbacks)?e.fallbacks.map(d=>typeof d=="object"&&d&&"ref"in d?String(d.ref):void 0).filter(d=>!!d):[];return{id:t.id,provider:r,model:n,init:o,clientRef:typeof e.clientRef=="string"?e.clientRef:void 0,fallbacks:s,metadata:i(e.metadata),sourcePath:t.sourcePath}}function j(t){const e=t.value;b(e,"EmbeddingModel",t.id);const r=String(e.provider??"").trim(),n=String(e.model??e.name??"").trim(),o=f(g(e,["apiVersion","id","kind","provider","model","name","init","clientRef","metadata"])??{});return{id:t.id,provider:r,model:n,init:o,clientRef:typeof e.clientRef=="string"?e.clientRef:void 0,metadata:i(e.metadata),sourcePath:t.sourcePath}}function T(t){const e=t.value,r=typeof e.port=="number"&&Number.isInteger(e.port)?e.port:void 0;return{id:t.id,kind:String(e.storeKind??e.kind??"LibSQLVectorStore").trim(),url:typeof e.url=="string"?e.url:void 0,host:typeof e.host=="string"?e.host:void 0,port:r,authToken:typeof e.authToken=="string"?e.authToken:void 0,table:typeof e.table=="string"?e.table:void 0,column:typeof e.column=="string"?e.column:void 0,collection:typeof e.collection=="string"?e.collection:typeof e.collectionName=="string"?e.collectionName:void 0,embeddingModelRef:typeof e.embeddingModelRef=="string"?e.embeddingModelRef:typeof i(e.embeddingModel)?.ref=="string"?String(i(e.embeddingModel)?.ref):void 0,metadata:i(e.metadata),sourcePath:t.sourcePath}}function P(t){const e=t.value,r=i(e.env),n=i(e.headers),o=i(e.oauth),s=String(e.transport??(typeof e.url=="string"&&e.url.trim()?"http":void 0)??(typeof e.command=="string"&&e.command.trim()?"stdio":void 0)??"stdio").trim();return{id:t.id,transport:s,url:typeof e.url=="string"?e.url:void 0,command:typeof e.command=="string"?e.command:void 0,args:c(e.args),env:r?Object.fromEntries(Object.entries(r).filter(d=>typeof d[1]=="string")):void 0,cwd:typeof e.cwd=="string"?e.cwd:void 0,token:typeof e.token=="string"?e.token:void 0,headers:n?Object.fromEntries(Object.entries(n).filter(d=>typeof d[1]=="string")):void 0,trustTier:e.trustTier==="trusted"||e.trustTier==="reviewed"||e.trustTier==="untrusted"?e.trustTier:void 0,access:e.access==="read-only"||e.access==="read-write"?e.access:void 0,tenantScope:e.tenantScope==="workspace"||e.tenantScope==="project"||e.tenantScope==="tenant"||e.tenantScope==="cross-tenant"?e.tenantScope:void 0,approvalPolicy:e.approvalPolicy==="always"||e.approvalPolicy==="write"||e.approvalPolicy==="never"?e.approvalPolicy:void 0,promptInjectionRisk:e.promptInjectionRisk==="low"||e.promptInjectionRisk==="medium"||e.promptInjectionRisk==="high"?e.promptInjectionRisk:void 0,oauth:o?{provider:typeof o.provider=="string"?o.provider:void 0,scopes:c(o.scopes)}:void 0,labels:c(e.labels),sourcePath:t.sourcePath}}function $(t,e){if(!t.provider)throw new Error(`Model ${t.id} provider must not be empty`);if(!t.model)throw new Error(`Model ${t.id} model must not be empty`);for(const r of t.fallbacks){const n=r.split("/").slice(1).join("/");if(!e.has(n))throw new Error(`Model ${t.id} fallback ${r} does not exist`)}}function x(t){if(!t.provider)throw new Error(`Embedding model ${t.id} provider must not be empty`);if(!t.model)throw new Error(`Embedding model ${t.id} model must not be empty`)}function I(t){if(!t.kind)throw new Error(`Vector store ${t.id} kind must not be empty`);if((t.kind==="LibSQLVectorStore"||t.kind==="LlamaIndexSimpleVectorStore")&&!t.url)throw new Error(`Vector store ${t.id} url must not be empty for ${t.kind}`);if(t.kind==="QdrantVectorStore"){if(!t.url&&!t.host)throw new Error(`Vector store ${t.id} must define url or host for QdrantVectorStore`);if(!t.collection)throw new Error(`Vector store ${t.id} collection must not be empty for QdrantVectorStore`)}}function V(t){if(!t.id.trim())throw new Error("MCP server id must not be empty");if(t.transport==="stdio"){if(!t.command?.trim())throw new Error(`MCP server ${t.id} command must not be empty for stdio transport`);return}if(!t.url?.trim())throw new Error(`MCP server ${t.id} url must not be empty for ${t.transport} transport`)}function A(t){return{id:t.id,provider:t.provider,model:t.model,init:f(t.init),clientRef:t.clientRef,fallbacks:t.fallbacks,runtimeValue:`${t.provider}:${t.model}`}}function N(t){return{id:t.id,kind:t.kind,url:t.url,host:t.host,port:t.port,authToken:t.authToken,table:t.table,column:t.column,collection:t.collection,embeddingModelRef:t.embeddingModelRef,runtimeValue:t.kind}}function L(t){return{id:t.id,provider:t.provider,model:t.model,init:f(t.init),clientRef:t.clientRef,runtimeValue:`${t.provider}:${t.model}`}}function C(t){const e=t.value,r=i(e.backend),n=i(e.mcp),o=i(e.providerTool)??i(e.provider),s=n?{...typeof n.serverRef=="string"?{serverRef:n.serverRef}:typeof n.server=="string"?{serverRef:n.server}:{}}:void 0,d=n?Object.fromEntries(Object.entries(n).filter(([a])=>a!=="ref"&&a!=="serverRef"&&a!=="tool")):void 0,l=w(e.tools??e.refs??e.bundle),u=typeof e.type=="string"?e.type:l.length>0?"bundle":n?"mcp":o?"provider":r?"backend":"function",p=typeof e.implementationName=="string"?e.implementationName:void 0;return{id:t.id,type:String(u),name:E(String(u),e.name,p),description:String(e.description??"").trim(),implementationName:p,config:m(m(i(e.config),o?{providerTool:o}:void 0),s&&Object.keys(s).length>0||d&&Object.keys(d).length>0?{mcp:s,...d&&Object.keys(d).length>0?{mcpServer:d}:{}}:void 0),subprocess:e.subprocess===!0?!0:void 0,inputSchemaRef:typeof i(e.inputSchema)?.ref=="string"?String(i(e.inputSchema)?.ref):void 0,hasModuleSchema:e.hasModuleSchema===!0?!0:void 0,modelSchema:i(e.modelSchema),embeddingModelRef:typeof e.embeddingModelRef=="string"?e.embeddingModelRef:typeof e.embeddingModel=="string"?`embedding-model/${String(e.embeddingModel).trim()}`:typeof i(e.embeddingModel)?.ref=="string"?String(i(e.embeddingModel)?.ref):void 0,backendOperation:typeof r?.operation=="string"?r.operation:typeof e.operation=="string"?e.operation:void 0,mcpRef:typeof n?.tool=="string"?n.tool:typeof n?.ref=="string"?n.ref:void 0,bundleRefs:l,hitl:v(e.hitl),retryable:e.retryable===!0?!0:void 0,sourcePath:t.sourcePath}}function _(t,e){h(t,e)}function Q(t,e){return y(t,e)}export{L as compileEmbeddingModel,A as compileModel,Q as compileTool,N as compileVectorStore,j as parseEmbeddingModelObject,P as parseMcpServerObject,S as parseModelObject,C as parseToolObject,T as parseVectorStoreObject,x as validateEmbeddingModelObject,V as validateMcpServerObject,$ as validateModelObject,_ as validateToolObject,I as validateVectorStoreObject};
|
|
@@ -1,37 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
function normalizeCapabilities(capabilities) {
|
|
3
|
-
return {
|
|
4
|
-
delegation: capabilities?.delegation === true,
|
|
5
|
-
memory: capabilities?.memory === true,
|
|
6
|
-
};
|
|
7
|
-
}
|
|
8
|
-
export function inferAgentCapabilities(agent) {
|
|
9
|
-
if (agent.capabilities) {
|
|
10
|
-
return normalizeCapabilities(agent.capabilities);
|
|
11
|
-
}
|
|
12
|
-
return {
|
|
13
|
-
delegation: agent.executionMode === "deepagent" || agent.executionMode === "langchain-v1",
|
|
14
|
-
memory: agent.executionMode === "deepagent" || agent.executionMode === "langchain-v1",
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
export function inferBindingCapabilities(binding) {
|
|
18
|
-
return normalizeCapabilities(binding.harnessRuntime.capabilities ?? binding.agent.capabilities ?? inferAgentCapabilities(binding.agent));
|
|
19
|
-
}
|
|
20
|
-
export function isDelegationCapableAgent(agent) {
|
|
21
|
-
return inferAgentCapabilities(agent).delegation === true;
|
|
22
|
-
}
|
|
23
|
-
export function isMemoryCapableAgent(agent) {
|
|
24
|
-
return inferAgentCapabilities(agent).memory === true;
|
|
25
|
-
}
|
|
26
|
-
export function isDelegationCapableBinding(binding) {
|
|
27
|
-
return inferBindingCapabilities(binding).delegation === true;
|
|
28
|
-
}
|
|
29
|
-
export function isMemoryCapableBinding(binding) {
|
|
30
|
-
return inferBindingCapabilities(binding).memory === true;
|
|
31
|
-
}
|
|
32
|
-
export function getAgentSystemPrompt(agent) {
|
|
33
|
-
return getAgentExecutionString(agent, "systemPrompt");
|
|
34
|
-
}
|
|
35
|
-
export function hasAgentSystemPrompt(agent) {
|
|
36
|
-
return typeof getAgentSystemPrompt(agent) === "string";
|
|
37
|
-
}
|
|
1
|
+
import{getAgentExecutionString as r}from"./agent-execution-config.js";function n(e){return{delegation:e?.delegation===!0,memory:e?.memory===!0}}function t(e){return e.capabilities?n(e.capabilities):{delegation:e.executionMode==="deepagent"||e.executionMode==="langchain-v1",memory:e.executionMode==="deepagent"||e.executionMode==="langchain-v1"}}function i(e){return n(e.harnessRuntime.capabilities??e.agent.capabilities??t(e.agent))}function u(e){return t(e).delegation===!0}function p(e){return t(e).memory===!0}function m(e){return i(e).delegation===!0}function l(e){return i(e).memory===!0}function o(e){return r(e,"systemPrompt")}function c(e){return typeof o(e)=="string"}export{o as getAgentSystemPrompt,c as hasAgentSystemPrompt,t as inferAgentCapabilities,i as inferBindingCapabilities,u as isDelegationCapableAgent,m as isDelegationCapableBinding,p as isMemoryCapableAgent,l as isMemoryCapableBinding};
|
|
@@ -1,44 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
const agentExecutionViewsCache = new WeakMap();
|
|
3
|
-
function deriveAgentExecutionViews(agent) {
|
|
4
|
-
const cached = agentExecutionViewsCache.get(agent);
|
|
5
|
-
if (cached) {
|
|
6
|
-
return cached;
|
|
7
|
-
}
|
|
8
|
-
const langchainConfig = asRecord(agent.langchainAgentConfig);
|
|
9
|
-
const deepAgentConfig = asRecord(agent.deepAgentConfig);
|
|
10
|
-
const views = {
|
|
11
|
-
"langchain-v1": [langchainConfig ?? {}],
|
|
12
|
-
deepagent: [deepAgentConfig ?? {}],
|
|
13
|
-
};
|
|
14
|
-
agentExecutionViewsCache.set(agent, views);
|
|
15
|
-
return views;
|
|
16
|
-
}
|
|
17
|
-
function getConfigsForMode(agent, executionMode = agent.executionMode) {
|
|
18
|
-
return deriveAgentExecutionViews(agent)[executionMode];
|
|
19
|
-
}
|
|
20
|
-
export function getAgentExecutionConfigs(agent, executionMode = agent.executionMode) {
|
|
21
|
-
return getConfigsForMode(agent, executionMode);
|
|
22
|
-
}
|
|
23
|
-
export function getAgentExecutionConfigValue(agent, key, options = {}) {
|
|
24
|
-
const keys = [key, ...(options.aliases ?? [])];
|
|
25
|
-
for (const config of getConfigsForMode(agent, options.executionMode)) {
|
|
26
|
-
for (const candidate of keys) {
|
|
27
|
-
const value = config[candidate];
|
|
28
|
-
if (value !== undefined) {
|
|
29
|
-
return value;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return undefined;
|
|
34
|
-
}
|
|
35
|
-
export function getAgentExecutionObject(agent, key, options = {}) {
|
|
36
|
-
return asRecord(getAgentExecutionConfigValue(agent, key, options));
|
|
37
|
-
}
|
|
38
|
-
export function getAgentExecutionString(agent, key, options = {}) {
|
|
39
|
-
const value = getAgentExecutionConfigValue(agent, key, options);
|
|
40
|
-
if (typeof value !== "string") {
|
|
41
|
-
return undefined;
|
|
42
|
-
}
|
|
43
|
-
return options.trim === false ? value : value.trim() || undefined;
|
|
44
|
-
}
|
|
1
|
+
import{asRecord as c}from"../../utils/object.js";const u=new WeakMap;function s(e){const n=u.get(e);if(n)return n;const t=c(e.langchainAgentConfig),o=c(e.deepAgentConfig),i={"langchain-v1":[t??{}],deepagent:[o??{}]};return u.set(e,i),i}function f(e,n=e.executionMode){return s(e)[n]}function x(e,n=e.executionMode){return f(e,n)}function g(e,n,t={}){const o=[n,...t.aliases??[]];for(const i of f(e,t.executionMode))for(const d of o){const r=i[d];if(r!==void 0)return r}}function l(e,n,t={}){return c(g(e,n,t))}function p(e,n,t={}){const o=g(e,n,t);if(typeof o=="string")return t.trim===!1?o:o.trim()||void 0}export{g as getAgentExecutionConfigValue,x as getAgentExecutionConfigs,l as getAgentExecutionObject,p as getAgentExecutionString};
|
|
@@ -1,147 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { defaultResourceConfigRoot, defaultResourceSkillsRoot } from "../../resource/resource.js";
|
|
4
|
-
import { validateSkillMetadata } from "../../runtime/skills/skill-metadata.js";
|
|
5
|
-
import { ensureExternalResourceSource, isDirectoryPath, isExternalSourceLocator, resolveExternalResourcePath, resolveResourcePackageRoot, } from "../../resource/sources.js";
|
|
6
|
-
import { parseAgentItem, readYamlItems } from "../object-loader.js";
|
|
7
|
-
function isBundledResourceRef(ref) {
|
|
8
|
-
return ref.startsWith("resource://") || ref.startsWith("builtin://");
|
|
9
|
-
}
|
|
10
|
-
function resolveBundledResourcePath(kind, ref) {
|
|
11
|
-
const normalized = ref.replace(/^(resource|builtin):\/\//, "").replace(/^\/+/, "");
|
|
12
|
-
if (kind === "skills") {
|
|
13
|
-
if (!normalized.startsWith("skills")) {
|
|
14
|
-
throw new Error(`Unsupported resource skill discovery path ${ref}`);
|
|
15
|
-
}
|
|
16
|
-
const suffix = normalized.replace(/^skills\/?/, "");
|
|
17
|
-
const root = defaultResourceSkillsRoot();
|
|
18
|
-
if (!suffix) {
|
|
19
|
-
return root;
|
|
20
|
-
}
|
|
21
|
-
const candidate = path.join(root, suffix);
|
|
22
|
-
if (existsSync(candidate)) {
|
|
23
|
-
return candidate;
|
|
24
|
-
}
|
|
25
|
-
const sourceFallback = root.includes(`${path.sep}dist${path.sep}resources${path.sep}skills`)
|
|
26
|
-
? path.join(path.resolve(root, "..", "..", ".."), "resources", "skills", suffix)
|
|
27
|
-
: null;
|
|
28
|
-
if (sourceFallback && existsSync(sourceFallback)) {
|
|
29
|
-
return sourceFallback;
|
|
30
|
-
}
|
|
31
|
-
return candidate;
|
|
32
|
-
}
|
|
33
|
-
if (!normalized.startsWith("agents")) {
|
|
34
|
-
throw new Error(`Unsupported resource subagent discovery path ${ref}`);
|
|
35
|
-
}
|
|
36
|
-
const suffix = normalized.replace(/^agents\/?/, "");
|
|
37
|
-
const root = path.join(defaultResourceConfigRoot(), "agents");
|
|
38
|
-
if (!suffix) {
|
|
39
|
-
return root;
|
|
40
|
-
}
|
|
41
|
-
const candidate = path.join(root, suffix);
|
|
42
|
-
if (existsSync(candidate)) {
|
|
43
|
-
return candidate;
|
|
44
|
-
}
|
|
45
|
-
const sourceFallback = root.includes(`${path.sep}dist${path.sep}config${path.sep}agents`)
|
|
46
|
-
? path.join(path.resolve(root, "..", "..", ".."), "config", "agents", suffix)
|
|
47
|
-
: null;
|
|
48
|
-
if (sourceFallback && existsSync(sourceFallback)) {
|
|
49
|
-
return sourceFallback;
|
|
50
|
-
}
|
|
51
|
-
return candidate;
|
|
52
|
-
}
|
|
53
|
-
function preferPackageConvention(root, kind) {
|
|
54
|
-
const resourceRoot = resolveResourcePackageRoot(root);
|
|
55
|
-
const candidates = resourceRoot
|
|
56
|
-
? kind === "skills"
|
|
57
|
-
? [path.join(root, "config", "skills"), path.join(resourceRoot, "skills"), resourceRoot]
|
|
58
|
-
: [path.join(root, "config", "agents"), path.join(root, "agents"), path.join(resourceRoot, "agents"), resourceRoot]
|
|
59
|
-
: kind === "skills"
|
|
60
|
-
? [path.join(root, "config", "skills"), path.join(root, "skills"), root]
|
|
61
|
-
: [path.join(root, "config", "agents"), path.join(root, "agents"), root];
|
|
62
|
-
for (const candidate of candidates) {
|
|
63
|
-
if (isDirectoryPath(candidate)) {
|
|
64
|
-
return candidate;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return root;
|
|
68
|
-
}
|
|
69
|
-
export async function ensureDiscoverySources(locators, workspaceRoot) {
|
|
70
|
-
await Promise.all(Array.from(new Set(locators))
|
|
71
|
-
.filter((locator) => isExternalSourceLocator(locator))
|
|
72
|
-
.map((locator) => ensureExternalResourceSource(locator, workspaceRoot)));
|
|
73
|
-
}
|
|
74
|
-
export function resolveDiscoveryRoot(ref, workspaceRoot, kind) {
|
|
75
|
-
if (isBundledResourceRef(ref)) {
|
|
76
|
-
return resolveBundledResourcePath(kind, ref);
|
|
77
|
-
}
|
|
78
|
-
if (isExternalSourceLocator(ref)) {
|
|
79
|
-
return preferPackageConvention(resolveExternalResourcePath(ref, workspaceRoot), kind);
|
|
80
|
-
}
|
|
81
|
-
return preferPackageConvention(path.resolve(workspaceRoot, ref), kind);
|
|
82
|
-
}
|
|
83
|
-
async function resolveDiscoveryRootAsync(ref, workspaceRoot, kind) {
|
|
84
|
-
if (isBundledResourceRef(ref)) {
|
|
85
|
-
return resolveBundledResourcePath(kind, ref);
|
|
86
|
-
}
|
|
87
|
-
if (isExternalSourceLocator(ref)) {
|
|
88
|
-
return preferPackageConvention(await ensureExternalResourceSource(ref, workspaceRoot), kind);
|
|
89
|
-
}
|
|
90
|
-
return preferPackageConvention(path.resolve(workspaceRoot, ref), kind);
|
|
91
|
-
}
|
|
92
|
-
export function discoverSkillPaths(rootRefs, workspaceRoot) {
|
|
93
|
-
const discovered = new Map();
|
|
94
|
-
for (const rootRef of rootRefs) {
|
|
95
|
-
const root = resolveDiscoveryRoot(rootRef, workspaceRoot, "skills");
|
|
96
|
-
if (!existsSync(root) || !statSync(root).isDirectory()) {
|
|
97
|
-
throw new Error(`Skill discovery root ${rootRef} does not exist`);
|
|
98
|
-
}
|
|
99
|
-
if (existsSync(path.join(root, "SKILL.md"))) {
|
|
100
|
-
validateSkillMetadata(root);
|
|
101
|
-
discovered.set(path.basename(root), root);
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
for (const entry of readdirSync(root, { withFileTypes: true })) {
|
|
105
|
-
if (!entry.isDirectory()) {
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
const skillRoot = path.join(root, entry.name);
|
|
109
|
-
if (existsSync(path.join(skillRoot, "SKILL.md"))) {
|
|
110
|
-
validateSkillMetadata(skillRoot);
|
|
111
|
-
discovered.set(entry.name, skillRoot);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return Array.from(discovered.values());
|
|
116
|
-
}
|
|
117
|
-
export async function discoverSubagents(agents, workspaceRoot) {
|
|
118
|
-
const discovered = new Map(agents.map((agent) => [agent.id, agent]));
|
|
119
|
-
const visitedRoots = new Set();
|
|
120
|
-
let cursor = 0;
|
|
121
|
-
const queue = [...agents];
|
|
122
|
-
while (cursor < queue.length) {
|
|
123
|
-
const agent = queue[cursor++];
|
|
124
|
-
for (const rootRef of agent.subagentPathRefs) {
|
|
125
|
-
const root = await resolveDiscoveryRootAsync(rootRef, workspaceRoot, "subagents");
|
|
126
|
-
const cacheKey = `${agent.id}:${root}`;
|
|
127
|
-
if (visitedRoots.has(cacheKey)) {
|
|
128
|
-
continue;
|
|
129
|
-
}
|
|
130
|
-
visitedRoots.add(cacheKey);
|
|
131
|
-
if (!existsSync(root) || !statSync(root).isDirectory()) {
|
|
132
|
-
throw new Error(`Subagent discovery root ${rootRef} does not exist`);
|
|
133
|
-
}
|
|
134
|
-
const discoveredRefs = [];
|
|
135
|
-
for (const { item, sourcePath } of await readYamlItems(root, undefined, { recursive: true })) {
|
|
136
|
-
const discoveredAgent = parseAgentItem(item, sourcePath);
|
|
137
|
-
discovered.set(discoveredAgent.id, discoveredAgent);
|
|
138
|
-
discoveredRefs.push(`agent/${discoveredAgent.id}`);
|
|
139
|
-
if (!queue.some((queued) => queued.id === discoveredAgent.id)) {
|
|
140
|
-
queue.push(discoveredAgent);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
agent.subagentRefs = Array.from(new Set([...agent.subagentRefs, ...discoveredRefs]));
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
return Array.from(discovered.values());
|
|
147
|
-
}
|
|
1
|
+
import{existsSync as u,readdirSync as $,statSync as v}from"node:fs";import t from"node:path";import{defaultResourceConfigRoot as b,defaultResourceSkillsRoot as x}from"../../resource/resource.js";import{validateSkillMetadata as y}from"../../runtime/skills/skill-metadata.js";import{ensureExternalResourceSource as h,isDirectoryPath as P,isExternalSourceLocator as g,resolveExternalResourcePath as A,resolveResourcePackageRoot as D}from"../../resource/sources.js";import{parseAgentItem as E,readYamlItems as L}from"../object-loader.js";function R(e){return e.startsWith("resource://")||e.startsWith("builtin://")}function j(e,r){const s=r.replace(/^(resource|builtin):\/\//,"").replace(/^\/+/,"");if(e==="skills"){if(!s.startsWith("skills"))throw new Error(`Unsupported resource skill discovery path ${r}`);const l=s.replace(/^skills\/?/,""),a=x();if(!l)return a;const f=t.join(a,l);if(u(f))return f;const d=a.includes(`${t.sep}dist${t.sep}resources${t.sep}skills`)?t.join(t.resolve(a,"..","..",".."),"resources","skills",l):null;return d&&u(d)?d:f}if(!s.startsWith("agents"))throw new Error(`Unsupported resource subagent discovery path ${r}`);const c=s.replace(/^agents\/?/,""),o=t.join(b(),"agents");if(!c)return o;const i=t.join(o,c);if(u(i))return i;const n=o.includes(`${t.sep}dist${t.sep}config${t.sep}agents`)?t.join(t.resolve(o,"..","..",".."),"config","agents",c):null;return n&&u(n)?n:i}function m(e,r){const s=D(e),c=s?r==="skills"?[t.join(e,"config","skills"),t.join(s,"skills"),s]:[t.join(e,"config","agents"),t.join(e,"agents"),t.join(s,"agents"),s]:r==="skills"?[t.join(e,"config","skills"),t.join(e,"skills"),e]:[t.join(e,"config","agents"),t.join(e,"agents"),e];for(const o of c)if(P(o))return o;return e}async function q(e,r){await Promise.all(Array.from(new Set(e)).filter(s=>g(s)).map(s=>h(s,r)))}function I(e,r,s){return R(e)?j(s,e):g(e)?m(A(e,r),s):m(t.resolve(r,e),s)}async function W(e,r,s){return R(e)?j(s,e):g(e)?m(await h(e,r),s):m(t.resolve(r,e),s)}function z(e,r){const s=new Map;for(const c of e){const o=I(c,r,"skills");if(!u(o)||!v(o).isDirectory())throw new Error(`Skill discovery root ${c} does not exist`);if(u(t.join(o,"SKILL.md"))){y(o),s.set(t.basename(o),o);continue}for(const i of $(o,{withFileTypes:!0})){if(!i.isDirectory())continue;const n=t.join(o,i.name);u(t.join(n,"SKILL.md"))&&(y(n),s.set(i.name,n))}}return Array.from(s.values())}async function T(e,r){const s=new Map(e.map(n=>[n.id,n])),c=new Set;let o=0;const i=[...e];for(;o<i.length;){const n=i[o++];for(const l of n.subagentPathRefs){const a=await W(l,r,"subagents"),f=`${n.id}:${a}`;if(c.has(f))continue;if(c.add(f),!u(a)||!v(a).isDirectory())throw new Error(`Subagent discovery root ${l} does not exist`);const d=[];for(const{item:w,sourcePath:S}of await L(a,void 0,{recursive:!0})){const p=E(w,S);s.set(p.id,p),d.push(`agent/${p.id}`),i.some(k=>k.id===p.id)||i.push(p)}n.subagentRefs=Array.from(new Set([...n.subagentRefs,...d]))}}return Array.from(s.values())}export{z as discoverSkillPaths,T as discoverSubagents,q as ensureDiscoverySources,I as resolveDiscoveryRoot};
|
|
@@ -1,30 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
export function collectToolSourceRefs(tools, agents, options) {
|
|
3
|
-
const refs = new Set(options.resources ?? []);
|
|
4
|
-
for (const tool of tools.values()) {
|
|
5
|
-
for (const ref of tool.bundleRefs) {
|
|
6
|
-
if (isExternalSourceLocator(ref)) {
|
|
7
|
-
refs.add(ref);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
for (const agent of agents) {
|
|
12
|
-
for (const ref of agent.toolRefs) {
|
|
13
|
-
if (isExternalSourceLocator(ref)) {
|
|
14
|
-
refs.add(ref);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return Array.from(refs);
|
|
19
|
-
}
|
|
20
|
-
export function collectAgentDiscoverySourceRefs(agents) {
|
|
21
|
-
const refs = new Set();
|
|
22
|
-
for (const agent of agents) {
|
|
23
|
-
for (const ref of [...agent.skillPathRefs, ...agent.subagentPathRefs]) {
|
|
24
|
-
if (isExternalSourceLocator(ref)) {
|
|
25
|
-
refs.add(ref);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return Array.from(refs);
|
|
30
|
-
}
|
|
1
|
+
import{isExternalSourceLocator as n}from"../../resource/sources.js";function a(t,r,f){const o=new Set(f.resources??[]);for(const s of t.values())for(const e of s.bundleRefs)n(e)&&o.add(e);for(const s of r)for(const e of s.toolRefs)n(e)&&o.add(e);return Array.from(o)}function l(t){const r=new Set;for(const f of t)for(const o of[...f.skillPathRefs,...f.subagentPathRefs])n(o)&&r.add(o);return Array.from(r)}export{l as collectAgentDiscoverySourceRefs,a as collectToolSourceRefs};
|