@botbotgo/agent-harness 0.0.110 → 0.0.112
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 +0 -2
- package/README.zh.md +0 -2
- package/dist/config/agents/direct.yaml +58 -59
- package/dist/config/agents/orchestra.yaml +68 -70
- package/dist/contracts/core.d.ts +0 -2
- package/dist/contracts/runtime.d.ts +0 -17
- package/dist/contracts/workspace.d.ts +2 -7
- package/dist/init-project.js +10 -8
- package/dist/package-version.d.ts +1 -1
- package/dist/package-version.js +1 -1
- package/dist/persistence/file-store.d.ts +1 -5
- package/dist/persistence/file-store.js +1 -34
- package/dist/runtime/adapter/compat/deepagent-compat.d.ts +6 -0
- package/dist/runtime/adapter/compat/deepagent-compat.js +3 -0
- package/dist/runtime/adapter/{execution-context.d.ts → flow/execution-context.d.ts} +17 -3
- package/dist/runtime/adapter/{execution-context.js → flow/execution-context.js} +20 -2
- package/dist/runtime/adapter/flow/invocation-flow.d.ts +24 -0
- package/dist/runtime/adapter/flow/invocation-flow.js +42 -0
- package/dist/runtime/adapter/{invoke-runtime.d.ts → flow/invoke-runtime.d.ts} +3 -3
- package/dist/runtime/adapter/{invoke-runtime.js → flow/invoke-runtime.js} +1 -1
- package/dist/runtime/adapter/flow/runnable-assembly.d.ts +51 -0
- package/dist/runtime/adapter/flow/runnable-assembly.js +52 -0
- package/dist/runtime/adapter/{stream-runtime.d.ts → flow/stream-runtime.d.ts} +3 -3
- package/dist/runtime/adapter/{stream-runtime.js → flow/stream-runtime.js} +6 -6
- package/dist/runtime/adapter/invocation-result.js +4 -2
- package/dist/runtime/adapter/middleware-assembly.d.ts +1 -1
- package/dist/runtime/adapter/middleware-assembly.js +5 -8
- package/dist/runtime/adapter/runnable-config.d.ts +0 -2
- package/dist/runtime/adapter/runnable-config.js +0 -2
- package/dist/runtime/adapter/runtime-adapter-support.d.ts +0 -7
- package/dist/runtime/adapter/runtime-adapter-support.js +1 -23
- package/dist/runtime/adapter/runtime-shell.js +1 -1
- package/dist/runtime/adapter/tool/builtin-middleware-tools.js +10 -9
- package/dist/runtime/adapter/tool/tool-arguments.js +1 -3
- package/dist/runtime/adapter/tool-resolution.d.ts +1 -1
- package/dist/runtime/agent-runtime-adapter.d.ts +1 -1
- package/dist/runtime/agent-runtime-adapter.js +52 -81
- package/dist/runtime/harness/system/inventory.d.ts +2 -2
- package/dist/runtime/harness/system/inventory.js +5 -6
- package/dist/runtime/parsing/stream-event-parsing.js +2 -2
- package/dist/runtime/support/compiled-binding.d.ts +8 -2
- package/dist/runtime/support/compiled-binding.js +22 -10
- package/dist/runtime/support/skill-metadata.js +1 -3
- package/dist/utils/object.d.ts +3 -0
- package/dist/utils/object.js +6 -0
- package/dist/workspace/agent-binding-compiler.js +2 -22
- package/dist/workspace/object-loader.js +94 -23
- package/dist/workspace/support/agent-execution-config.js +16 -7
- package/dist/workspace/support/workspace-ref-utils.d.ts +1 -2
- package/dist/workspace/support/workspace-ref-utils.js +0 -12
- package/package.json +1 -1
|
@@ -1,28 +1,23 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { Command, MemorySaver } from "@langchain/langgraph";
|
|
3
2
|
import { createDeepAgent, FilesystemBackend, } from "deepagents";
|
|
4
3
|
import { createAgent } from "langchain";
|
|
5
4
|
import { wrapResolvedModel, } from "./parsing/output-parsing.js";
|
|
6
|
-
import {
|
|
5
|
+
import { assembleDeepAgentRunnable, assembleLangChainRunnable, } from "./adapter/flow/runnable-assembly.js";
|
|
7
6
|
import { buildToolNameMapping, } from "./adapter/tool/tool-name-mapping.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { streamRuntimeExecution } from "./adapter/stream-runtime.js";
|
|
7
|
+
import { executeRuntimeInvocation } from "./adapter/flow/invocation-flow.js";
|
|
8
|
+
import { streamRuntimeExecution } from "./adapter/flow/stream-runtime.js";
|
|
11
9
|
import { buildDeepAgentRunnableConfig, buildLangChainRunnableConfig } from "./adapter/runnable-config.js";
|
|
12
10
|
import { applyStrictToolJsonInstruction as applyStrictToolJsonInstructionHelper, callRuntimeWithToolParseRecovery as callRuntimeWithToolParseRecoveryHelper, createModelFallbackRunnable as createModelFallbackRunnableHelper, invokeWithProviderRetry as invokeWithProviderRetryHelper, iterateWithTimeout as iterateWithTimeoutHelper, materializeModelStream as materializeModelStreamHelper, RuntimeOperationTimeoutError, withRuntimeTimeout, } from "./adapter/runtime-shell.js";
|
|
13
11
|
import { invokeBuiltinTaskTool as invokeBuiltinTaskToolHelper, resolveAutomaticSummarizationMiddleware as resolveAutomaticSummarizationMiddlewareHelper, resolveBuiltinMiddlewareBackend as resolveBuiltinMiddlewareBackendHelper, resolveBuiltinMiddlewareTools as resolveBuiltinMiddlewareToolsHelper, resolveLangChainAutomaticMiddleware as resolveLangChainAutomaticMiddlewareHelper, resolveMiddleware as resolveMiddlewareHelper, resolveSubagents as resolveSubagentsHelper, } from "./adapter/middleware-assembly.js";
|
|
14
12
|
import { computeRemainingTimeoutMs, resolveBindingTimeout, resolveStreamIdleTimeout, } from "./adapter/resilience.js";
|
|
15
13
|
import { createResolvedModel } from "./adapter/model/model-providers.js";
|
|
16
|
-
import { buildInvocationRequest, } from "./adapter/model/invocation-request.js";
|
|
17
|
-
import { compileInterruptOn } from "./adapter/tool/interrupt-policy.js";
|
|
18
|
-
import { countConfiguredTools, } from "./adapter/runtime-adapter-support.js";
|
|
19
14
|
import { resolveAdapterTools } from "./adapter/tool-resolution.js";
|
|
20
|
-
import {
|
|
21
|
-
export { applyDeepAgentDelegationPromptCompatibility, materializeDeepAgentSkillSourcePaths, relativizeDeepAgentSkillSourcePaths, shouldRelaxDeepAgentDelegationPrompt, } from "./adapter/compat/deepagent-compat.js";
|
|
15
|
+
import { resolveRuntimeStreamExecutionContext, } from "./adapter/flow/execution-context.js";
|
|
16
|
+
export { applyDeepAgentDelegationPromptCompatibility, materializeDeepAgentSkillSourcePaths, resolveDeepAgentSkillSourcePaths, relativizeDeepAgentSkillSourcePaths, shouldRelaxDeepAgentDelegationPrompt, } from "./adapter/compat/deepagent-compat.js";
|
|
22
17
|
export { buildAuthOmittingFetch, normalizeOpenAICompatibleInit } from "./adapter/compat/openai-compatible.js";
|
|
23
18
|
export { buildToolNameMapping, createModelFacingToolNameCandidates, createModelFacingToolNameLookupCandidates, resolveModelFacingToolName, sanitizeToolNameForModel, } from "./adapter/tool/tool-name-mapping.js";
|
|
24
19
|
export { computeRemainingTimeoutMs, isRetryableProviderError, resolveBindingTimeout, resolveProviderRetryPolicy, resolveStreamIdleTimeout, resolveTimeoutMs, } from "./adapter/resilience.js";
|
|
25
|
-
import { getBindingAdapterKind,
|
|
20
|
+
import { getBindingAdapterKind, getBindingLangChainParams, getBindingToolCount, getBindingPrimaryTools, getBindingSystemPrompt, isDeepAgentBinding, isLangChainBinding, } from "./support/compiled-binding.js";
|
|
26
21
|
const AGENT_INTERRUPT_SENTINEL_PREFIX = "__agent_harness_interrupt__:";
|
|
27
22
|
const UPSTREAM_BUILTIN_MIDDLEWARE_TOOL_NAMES = Object.freeze([
|
|
28
23
|
"write_todos",
|
|
@@ -35,12 +30,6 @@ const UPSTREAM_BUILTIN_MIDDLEWARE_TOOL_NAMES = Object.freeze([
|
|
|
35
30
|
"execute",
|
|
36
31
|
"task",
|
|
37
32
|
]);
|
|
38
|
-
function resolveBindingCheckpointer(options, binding) {
|
|
39
|
-
return options.checkpointerResolver ? options.checkpointerResolver(binding) : new MemorySaver();
|
|
40
|
-
}
|
|
41
|
-
function resolveBindingInterruptOn(binding) {
|
|
42
|
-
return compileInterruptOn(getBindingPrimaryTools(binding), getBindingInterruptCompatibilityRules(binding));
|
|
43
|
-
}
|
|
44
33
|
export class AgentRuntimeAdapter {
|
|
45
34
|
options;
|
|
46
35
|
modelCache = new Map();
|
|
@@ -222,22 +211,29 @@ export class AgentRuntimeAdapter {
|
|
|
222
211
|
});
|
|
223
212
|
}
|
|
224
213
|
async createLangChainRunnable(binding, options = {}) {
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
214
|
+
const assembly = await assembleLangChainRunnable({
|
|
215
|
+
binding,
|
|
216
|
+
runtimeAdapterOptions: this.options,
|
|
217
|
+
resolveModel: (model) => this.resolveModel(model),
|
|
218
|
+
resolveTools: (tools, currentBinding) => this.resolveTools(tools, currentBinding),
|
|
219
|
+
resolveMiddleware: (currentBinding, interruptOn) => this.resolveMiddleware(currentBinding, interruptOn),
|
|
220
|
+
passthroughOverride: options.passthroughOverride,
|
|
221
|
+
systemPromptOverride: options.systemPromptOverride,
|
|
222
|
+
});
|
|
223
|
+
const model = assembly.resolvedModel;
|
|
224
|
+
const tools = assembly.resolvedTools;
|
|
229
225
|
if (tools.length > 0 && typeof model.bindTools !== "function") {
|
|
230
|
-
throw new Error(`Agent ${binding.agent.id} configures ${tools.length} tool(s), but resolved model ${
|
|
226
|
+
throw new Error(`Agent ${binding.agent.id} configures ${tools.length} tool(s), but resolved model ${assembly.langchainParams.model.id} does not support tool binding.`);
|
|
231
227
|
}
|
|
232
228
|
return createAgent(buildLangChainRunnableConfig({
|
|
233
|
-
langchainParams:
|
|
229
|
+
langchainParams: assembly.langchainParams,
|
|
234
230
|
resolvedModel: model,
|
|
235
231
|
resolvedTools: tools,
|
|
236
|
-
resolvedMiddleware:
|
|
237
|
-
resolvedCheckpointer:
|
|
238
|
-
resolvedStore:
|
|
239
|
-
passthroughOverride:
|
|
240
|
-
systemPromptOverride:
|
|
232
|
+
resolvedMiddleware: assembly.resolvedMiddleware,
|
|
233
|
+
resolvedCheckpointer: assembly.resolvedCheckpointer,
|
|
234
|
+
resolvedStore: assembly.resolvedStore,
|
|
235
|
+
passthroughOverride: assembly.passthroughOverride,
|
|
236
|
+
systemPromptOverride: assembly.systemPromptOverride,
|
|
241
237
|
}));
|
|
242
238
|
}
|
|
243
239
|
async createRunnable(binding) {
|
|
@@ -250,27 +246,25 @@ export class AgentRuntimeAdapter {
|
|
|
250
246
|
return this.createDeepAgentRunnable(binding);
|
|
251
247
|
}
|
|
252
248
|
async createDeepAgentRunnable(binding) {
|
|
253
|
-
const
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
249
|
+
const assembly = await assembleDeepAgentRunnable({
|
|
250
|
+
binding,
|
|
251
|
+
runtimeAdapterOptions: this.options,
|
|
252
|
+
resolveModel: (model) => this.resolveModel(model),
|
|
253
|
+
resolveTools: (tools, currentBinding) => this.resolveTools(tools, currentBinding),
|
|
254
|
+
resolveMiddleware: (currentBinding, interruptOn) => this.resolveMiddleware(currentBinding, interruptOn),
|
|
255
|
+
resolveSubagents: (subagents, currentBinding) => this.resolveSubagents(subagents, currentBinding),
|
|
256
|
+
});
|
|
258
257
|
const deepAgentConfig = buildDeepAgentRunnableConfig({
|
|
259
|
-
compatibleParams,
|
|
260
|
-
resolvedModel:
|
|
261
|
-
resolvedTools:
|
|
262
|
-
resolvedMiddleware:
|
|
263
|
-
resolvedSubagents:
|
|
264
|
-
resolvedCheckpointer:
|
|
265
|
-
resolvedStore:
|
|
266
|
-
resolvedBackend:
|
|
267
|
-
resolvedInterruptOn:
|
|
268
|
-
resolvedSkills:
|
|
269
|
-
workspaceRoot: binding.harnessRuntime.workspaceRoot,
|
|
270
|
-
runRoot: binding.harnessRuntime.runRoot,
|
|
271
|
-
ownerId: binding.agent.id,
|
|
272
|
-
skillPaths: compatibleParams.skills,
|
|
273
|
-
})) ?? [],
|
|
258
|
+
compatibleParams: assembly.compatibleParams,
|
|
259
|
+
resolvedModel: assembly.resolvedModel,
|
|
260
|
+
resolvedTools: assembly.resolvedTools,
|
|
261
|
+
resolvedMiddleware: assembly.resolvedMiddleware,
|
|
262
|
+
resolvedSubagents: assembly.resolvedSubagents,
|
|
263
|
+
resolvedCheckpointer: assembly.resolvedCheckpointer,
|
|
264
|
+
resolvedStore: assembly.resolvedStore,
|
|
265
|
+
resolvedBackend: assembly.resolvedBackend,
|
|
266
|
+
resolvedInterruptOn: assembly.resolvedInterruptOn,
|
|
267
|
+
resolvedSkills: assembly.resolvedSkills,
|
|
274
268
|
});
|
|
275
269
|
return createDeepAgent(deepAgentConfig);
|
|
276
270
|
}
|
|
@@ -290,9 +284,6 @@ export class AgentRuntimeAdapter {
|
|
|
290
284
|
}
|
|
291
285
|
}
|
|
292
286
|
async invoke(binding, input, threadId, runId, resumePayload, history = [], options = {}) {
|
|
293
|
-
const request = resumePayload === undefined
|
|
294
|
-
? buildInvocationRequest(binding, history, input, options)
|
|
295
|
-
: new Command({ resume: resumePayload });
|
|
296
287
|
const callRuntime = async (activeBinding, activeRequest) => {
|
|
297
288
|
return this.invokeWithProviderRetry(activeBinding, async () => {
|
|
298
289
|
const runnable = await this.create(activeBinding);
|
|
@@ -307,47 +298,27 @@ export class AgentRuntimeAdapter {
|
|
|
307
298
|
callRuntime,
|
|
308
299
|
});
|
|
309
300
|
};
|
|
310
|
-
|
|
301
|
+
return executeRuntimeInvocation({
|
|
311
302
|
binding,
|
|
303
|
+
input,
|
|
304
|
+
threadId,
|
|
305
|
+
runId,
|
|
306
|
+
resumePayload,
|
|
307
|
+
history,
|
|
308
|
+
invokeOptions: options,
|
|
312
309
|
resolveTools: (tools, currentBinding) => this.resolveTools(tools, currentBinding),
|
|
313
310
|
getToolNameMapping: (currentBinding) => this.getToolNameMapping(currentBinding),
|
|
314
|
-
|
|
315
|
-
});
|
|
316
|
-
const builtinExecutableTools = await this.resolveBuiltinMiddlewareTools(binding, options);
|
|
317
|
-
const localOrUpstreamInvocation = await invokeRuntimeWithLocalTools({
|
|
318
|
-
binding,
|
|
319
|
-
request,
|
|
320
|
-
resumePayload,
|
|
321
|
-
primaryTools,
|
|
322
|
-
defersToUpstreamHitlExecution,
|
|
323
|
-
toolNameMapping,
|
|
324
|
-
executableTools,
|
|
325
|
-
builtinExecutableTools: builtinExecutableTools,
|
|
311
|
+
resolveBuiltinMiddlewareTools: (currentBinding, currentOptions) => this.resolveBuiltinMiddlewareTools(currentBinding, currentOptions),
|
|
326
312
|
callRuntimeWithToolParseRecovery,
|
|
327
313
|
});
|
|
328
|
-
const result = localOrUpstreamInvocation.result;
|
|
329
|
-
const executedToolResults = [...localOrUpstreamInvocation.executedToolResults];
|
|
330
|
-
if (!result) {
|
|
331
|
-
throw new Error("Agent invocation returned no result");
|
|
332
|
-
}
|
|
333
|
-
return finalizeInvocationResult({
|
|
334
|
-
bindingAgentId: binding.agent.id,
|
|
335
|
-
threadId,
|
|
336
|
-
runId,
|
|
337
|
-
result,
|
|
338
|
-
executedToolResults,
|
|
339
|
-
});
|
|
340
314
|
}
|
|
341
315
|
async *stream(binding, input, threadId, history = [], options = {}) {
|
|
342
316
|
const invokeTimeoutMs = resolveBindingTimeout(binding);
|
|
343
317
|
const streamIdleTimeoutMs = resolveStreamIdleTimeout(binding);
|
|
344
318
|
const streamDeadlineAt = invokeTimeoutMs ? Date.now() + invokeTimeoutMs : undefined;
|
|
345
|
-
const { primaryTools, toolNameMapping } =
|
|
319
|
+
const { primaryTools, toolNameMapping, forceInvokeFallback, canUseDirectModelStream, langChainStreamModel, } = await resolveRuntimeStreamExecutionContext({
|
|
346
320
|
binding,
|
|
347
321
|
getToolNameMapping: (currentBinding) => this.getToolNameMapping(currentBinding),
|
|
348
|
-
});
|
|
349
|
-
const { forceInvokeFallback, canUseDirectModelStream, langChainStreamModel, } = await resolveLangChainStreamContext({
|
|
350
|
-
binding,
|
|
351
322
|
resolveModel: (model) => this.resolveModel(model),
|
|
352
323
|
resolveTools: (tools, currentBinding) => this.resolveTools(tools, currentBinding),
|
|
353
324
|
});
|
|
@@ -373,7 +344,7 @@ export class AgentRuntimeAdapter {
|
|
|
373
344
|
getSystemPrompt: (activeBinding) => getBindingSystemPrompt(activeBinding),
|
|
374
345
|
isLangChainBinding,
|
|
375
346
|
isDeepAgentBinding,
|
|
376
|
-
countConfiguredTools,
|
|
347
|
+
countConfiguredTools: getBindingToolCount,
|
|
377
348
|
});
|
|
378
349
|
}
|
|
379
350
|
}
|
|
@@ -20,14 +20,14 @@ export type InventorySkillRecord = {
|
|
|
20
20
|
export type InventoryAgentRecord = {
|
|
21
21
|
id: string;
|
|
22
22
|
description: string;
|
|
23
|
-
|
|
23
|
+
parentAgentId?: string;
|
|
24
24
|
tools: InventoryToolRecord[];
|
|
25
25
|
skills: InventorySkillRecord[];
|
|
26
26
|
};
|
|
27
27
|
export declare function findAgentBinding(workspace: WorkspaceBundle, agentId: string): CompiledAgentBinding | undefined;
|
|
28
28
|
export declare function listAgentTools(workspace: WorkspaceBundle, agentId: string): InventoryToolRecord[];
|
|
29
29
|
export declare function listAgentSkills(workspace: WorkspaceBundle, agentId: string, options?: RequirementAssessmentOptions): InventorySkillRecord[];
|
|
30
|
-
export declare function
|
|
30
|
+
export declare function listSubagents(workspace: WorkspaceBundle, options?: RequirementAssessmentOptions): InventoryAgentRecord[];
|
|
31
31
|
export declare function listAvailableAgents(workspace: WorkspaceBundle, options?: RequirementAssessmentOptions): InventoryAgentRecord[];
|
|
32
32
|
export declare function describeWorkspaceInventory(workspace: WorkspaceBundle, options?: RequirementAssessmentOptions): {
|
|
33
33
|
workspaceRoot: string;
|
|
@@ -77,30 +77,29 @@ export function listAgentSkills(workspace, agentId, options = {}) {
|
|
|
77
77
|
const resolvedOptions = mergeRequirementOptions(binding, options);
|
|
78
78
|
return toSkillRecords(binding.deepAgentParams?.skills ?? binding.langchainAgentParams?.skills ?? [], resolvedOptions);
|
|
79
79
|
}
|
|
80
|
-
function describeSubagent(subagent, options = {}) {
|
|
80
|
+
function describeSubagent(subagent, parentAgentId, options = {}) {
|
|
81
81
|
return {
|
|
82
82
|
id: subagent.name,
|
|
83
83
|
description: subagent.description,
|
|
84
|
-
|
|
84
|
+
parentAgentId,
|
|
85
85
|
tools: dedupeTools(subagent.tools ?? []),
|
|
86
86
|
skills: toSkillRecords(subagent.skills ?? [], options),
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
-
export function
|
|
89
|
+
export function listSubagents(workspace, options = {}) {
|
|
90
90
|
return listHostBindings(workspace).flatMap((binding) => {
|
|
91
91
|
const resolvedOptions = mergeRequirementOptions(binding, options);
|
|
92
|
-
return (binding.deepAgentParams?.subagents ?? []).map((subagent) => describeSubagent(subagent, resolvedOptions));
|
|
92
|
+
return (binding.deepAgentParams?.subagents ?? []).map((subagent) => describeSubagent(subagent, binding.agent.id, resolvedOptions));
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
95
|
export function listAvailableAgents(workspace, options = {}) {
|
|
96
96
|
const topLevel = listHostBindings(workspace).map((binding) => ({
|
|
97
97
|
id: binding.agent.id,
|
|
98
98
|
description: binding.agent.description,
|
|
99
|
-
role: "agent",
|
|
100
99
|
tools: listAgentTools(workspace, binding.agent.id),
|
|
101
100
|
skills: listAgentSkills(workspace, binding.agent.id, options),
|
|
102
101
|
}));
|
|
103
|
-
return [...topLevel, ...
|
|
102
|
+
return [...topLevel, ...listSubagents(workspace, options)];
|
|
104
103
|
}
|
|
105
104
|
export function describeWorkspaceInventory(workspace, options = {}) {
|
|
106
105
|
return {
|
|
@@ -390,13 +390,13 @@ export function extractAgentStep(event) {
|
|
|
390
390
|
return "preparing model request…";
|
|
391
391
|
if (/RunnableLambda/i.test(name) || /^__start__$/.test(name))
|
|
392
392
|
return null;
|
|
393
|
-
if (/specialist/i.test(name))
|
|
393
|
+
if (/(subagent|specialist)/i.test(name))
|
|
394
394
|
return `starting ${humanizeEventName(name)}…`;
|
|
395
395
|
if (/agent$/i.test(name))
|
|
396
396
|
return `running ${humanizeEventName(name)}…`;
|
|
397
397
|
}
|
|
398
398
|
if (typed.event === "on_chain_end") {
|
|
399
|
-
if (/specialist/i.test(name))
|
|
399
|
+
if (/(subagent|specialist)/i.test(name))
|
|
400
400
|
return `${humanizeEventName(name)} done`;
|
|
401
401
|
if (/agent$/i.test(name) && !/^__start__$/.test(name))
|
|
402
402
|
return `${humanizeEventName(name)} done`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CompiledAgentBinding, CompiledModel, CompiledTool, DeepAgentParams, LangChainAgentParams
|
|
1
|
+
import type { CompiledAgentBinding, CompiledModel, CompiledTool, DeepAgentParams, LangChainAgentParams } from "../../contracts/types.js";
|
|
2
2
|
export type BindingExecutionView = {
|
|
3
3
|
adapterKind: string;
|
|
4
4
|
adapterConfig: Record<string, unknown>;
|
|
@@ -9,8 +9,12 @@ export type BindingExecutionView = {
|
|
|
9
9
|
primaryModel?: CompiledModel;
|
|
10
10
|
systemPrompt?: string;
|
|
11
11
|
middlewareConfigs?: Array<Record<string, unknown>>;
|
|
12
|
+
middlewareKinds: Set<string>;
|
|
12
13
|
interruptCompatibilityRules?: Record<string, boolean | object>;
|
|
13
14
|
storeConfig?: Record<string, unknown>;
|
|
15
|
+
toolCount: number;
|
|
16
|
+
langChainSubagentSupport: boolean;
|
|
17
|
+
deepAgentSubagentCount: number;
|
|
14
18
|
};
|
|
15
19
|
export declare function getBindingExecutionView(binding: CompiledAgentBinding): BindingExecutionView;
|
|
16
20
|
export declare function getBindingAdapterKind(binding: CompiledAgentBinding): string;
|
|
@@ -21,9 +25,11 @@ export declare function isLangChainBinding(binding: CompiledAgentBinding): boole
|
|
|
21
25
|
export declare function isDeepAgentBinding(binding: CompiledAgentBinding): boolean;
|
|
22
26
|
export declare function getBindingPrimaryTools(binding: CompiledAgentBinding): CompiledTool[];
|
|
23
27
|
export declare function getBindingPrimaryModel(binding: CompiledAgentBinding): CompiledModel | undefined;
|
|
24
|
-
export declare function getBindingRuntimeModel(binding: CompiledAgentBinding, slot: RuntimeModelSlot): CompiledModel | undefined;
|
|
25
28
|
export declare function getBindingSystemPrompt(binding: CompiledAgentBinding): string | undefined;
|
|
26
29
|
export declare function getBindingMiddlewareConfigs(binding: CompiledAgentBinding): Array<Record<string, unknown>> | undefined;
|
|
30
|
+
export declare function getBindingToolCount(binding: CompiledAgentBinding): number;
|
|
31
|
+
export declare function bindingHasMiddlewareKind(binding: CompiledAgentBinding, kind: string): boolean;
|
|
32
|
+
export declare function bindingHasLangChainSubagentSupport(binding: CompiledAgentBinding): boolean;
|
|
27
33
|
export declare function getBindingInterruptCompatibilityRules(binding: CompiledAgentBinding): Record<string, boolean | object> | undefined;
|
|
28
34
|
export declare function getBindingModelInit(binding: CompiledAgentBinding): Record<string, unknown> | undefined;
|
|
29
35
|
export declare function getBindingStoreConfig(binding: CompiledAgentBinding): Record<string, unknown> | undefined;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
return typeof value === "object" && value !== null && !Array.isArray(value)
|
|
3
|
-
? value
|
|
4
|
-
: undefined;
|
|
5
|
-
}
|
|
1
|
+
import { asRecord } from "../../utils/object.js";
|
|
6
2
|
const bindingExecutionViewCache = new WeakMap();
|
|
7
3
|
function deriveBindingExecutionView(binding) {
|
|
8
4
|
const cached = bindingExecutionViewCache.get(binding);
|
|
@@ -19,6 +15,10 @@ function deriveBindingExecutionView(binding) {
|
|
|
19
15
|
? adapterParams
|
|
20
16
|
: binding.deepAgentParams;
|
|
21
17
|
const primaryTools = langchainParams?.tools ?? deepAgentParams?.tools ?? [];
|
|
18
|
+
const middlewareConfigs = langchainParams?.middleware ?? deepAgentParams?.middleware;
|
|
19
|
+
const middlewareKinds = new Set((middlewareConfigs ?? [])
|
|
20
|
+
.map((entry) => typeof entry.kind === "string" ? entry.kind : "")
|
|
21
|
+
.filter(Boolean));
|
|
22
22
|
const view = {
|
|
23
23
|
adapterKind,
|
|
24
24
|
adapterConfig,
|
|
@@ -26,12 +26,18 @@ function deriveBindingExecutionView(binding) {
|
|
|
26
26
|
deepAgentParams,
|
|
27
27
|
executionParams: langchainParams ?? deepAgentParams,
|
|
28
28
|
primaryTools,
|
|
29
|
+
toolCount: primaryTools.length,
|
|
29
30
|
primaryModel: langchainParams?.model ?? deepAgentParams?.model,
|
|
30
31
|
systemPrompt: langchainParams?.systemPrompt ?? deepAgentParams?.systemPrompt,
|
|
31
|
-
middlewareConfigs
|
|
32
|
+
middlewareConfigs,
|
|
33
|
+
middlewareKinds,
|
|
32
34
|
interruptCompatibilityRules: deepAgentParams?.interruptOn ??
|
|
33
35
|
binding.agent.langchainAgentConfig?.interruptOn,
|
|
34
36
|
storeConfig: deepAgentParams?.store ?? binding.harnessRuntime?.store,
|
|
37
|
+
langChainSubagentSupport: (langchainParams?.subagents?.length ?? 0) > 0 ||
|
|
38
|
+
langchainParams?.generalPurposeAgent === true ||
|
|
39
|
+
Boolean(langchainParams?.taskDescription?.trim()),
|
|
40
|
+
deepAgentSubagentCount: deepAgentParams?.subagents?.length ?? 0,
|
|
35
41
|
};
|
|
36
42
|
bindingExecutionViewCache.set(binding, view);
|
|
37
43
|
return view;
|
|
@@ -63,15 +69,21 @@ export function getBindingPrimaryTools(binding) {
|
|
|
63
69
|
export function getBindingPrimaryModel(binding) {
|
|
64
70
|
return getBindingExecutionView(binding).primaryModel;
|
|
65
71
|
}
|
|
66
|
-
export function getBindingRuntimeModel(binding, slot) {
|
|
67
|
-
return binding.harnessRuntime.models?.[slot];
|
|
68
|
-
}
|
|
69
72
|
export function getBindingSystemPrompt(binding) {
|
|
70
73
|
return getBindingExecutionView(binding).systemPrompt;
|
|
71
74
|
}
|
|
72
75
|
export function getBindingMiddlewareConfigs(binding) {
|
|
73
76
|
return getBindingExecutionView(binding).middlewareConfigs;
|
|
74
77
|
}
|
|
78
|
+
export function getBindingToolCount(binding) {
|
|
79
|
+
return getBindingExecutionView(binding).toolCount;
|
|
80
|
+
}
|
|
81
|
+
export function bindingHasMiddlewareKind(binding, kind) {
|
|
82
|
+
return getBindingExecutionView(binding).middlewareKinds.has(kind);
|
|
83
|
+
}
|
|
84
|
+
export function bindingHasLangChainSubagentSupport(binding) {
|
|
85
|
+
return getBindingExecutionView(binding).langChainSubagentSupport;
|
|
86
|
+
}
|
|
75
87
|
export function getBindingInterruptCompatibilityRules(binding) {
|
|
76
88
|
return getBindingExecutionView(binding).interruptCompatibilityRules;
|
|
77
89
|
}
|
|
@@ -82,5 +94,5 @@ export function getBindingStoreConfig(binding) {
|
|
|
82
94
|
return getBindingExecutionView(binding).storeConfig;
|
|
83
95
|
}
|
|
84
96
|
export function bindingHasSubagents(binding) {
|
|
85
|
-
return (
|
|
97
|
+
return getBindingExecutionView(binding).deepAgentSubagentCount > 0;
|
|
86
98
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { parse } from "yaml";
|
|
4
|
+
import { isRecord } from "../../utils/object.js";
|
|
4
5
|
const skillMetadataCache = new Map();
|
|
5
6
|
const skillValidationCache = new Map();
|
|
6
7
|
const SKILL_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
@@ -8,9 +9,6 @@ function parseFrontmatterSource(document) {
|
|
|
8
9
|
const match = document.match(/^---\s*\n([\s\S]*?)\n---\s*(?:\n|$)/);
|
|
9
10
|
return match?.[1];
|
|
10
11
|
}
|
|
11
|
-
function isRecord(value) {
|
|
12
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13
|
-
}
|
|
14
12
|
function isJsonLikeValue(value) {
|
|
15
13
|
if (value === null ||
|
|
16
14
|
typeof value === "string" ||
|
|
@@ -4,7 +4,7 @@ import { compileModel, compileTool } from "./resource-compilers.js";
|
|
|
4
4
|
import { inferAgentCapabilities } from "./support/agent-capabilities.js";
|
|
5
5
|
import { getAgentExecutionConfigValue, getAgentExecutionObject, getAgentExecutionString } from "./support/agent-execution-config.js";
|
|
6
6
|
import { discoverSkillPaths } from "./support/discovery.js";
|
|
7
|
-
import { compileAgentMemories, getResilienceConfig, getRuntimeDefaults, getRuntimeMemoryDefaults,
|
|
7
|
+
import { compileAgentMemories, getResilienceConfig, getRuntimeDefaults, getRuntimeMemoryDefaults, getWorkspaceObject, resolvePromptValue, resolveRefId } from "./support/workspace-ref-utils.js";
|
|
8
8
|
const WORKSPACE_BOUNDARY_GUIDANCE = "Keep repository and file exploration bounded to the current workspace root unless the user explicitly asks for broader host or filesystem access. " +
|
|
9
9
|
"Do not inspect absolute paths outside the workspace, system directories, or unrelated repos by default. " +
|
|
10
10
|
"Prefer workspace-local tools, relative paths, and the current repository checkout when analyzing code.";
|
|
@@ -233,7 +233,7 @@ function resolveCheckpointerConfig(agent, refs) {
|
|
|
233
233
|
return { config: inlineAgentCheckpointer };
|
|
234
234
|
}
|
|
235
235
|
function resolveRuntimeMemoryConfig(agent, refs) {
|
|
236
|
-
const inlineRuntimeMemory = getAgentExecutionObject(agent, "runtimeMemory");
|
|
236
|
+
const inlineRuntimeMemory = agent.runtimeMemory ?? getAgentExecutionObject(agent, "runtimeMemory");
|
|
237
237
|
if (inlineRuntimeMemory) {
|
|
238
238
|
if (isRefConfig(inlineRuntimeMemory)) {
|
|
239
239
|
return {
|
|
@@ -245,20 +245,6 @@ function resolveRuntimeMemoryConfig(agent, refs) {
|
|
|
245
245
|
const runtimeMemoryDefaults = getRuntimeMemoryDefaults(refs);
|
|
246
246
|
return runtimeMemoryDefaults ? { config: runtimeMemoryDefaults } : undefined;
|
|
247
247
|
}
|
|
248
|
-
function resolveRuntimeModelRefs(agent, refs) {
|
|
249
|
-
const merged = {
|
|
250
|
-
...(getRuntimeModelDefaults(refs) ?? {}),
|
|
251
|
-
...(agent.runtimeModelRefs ?? {}),
|
|
252
|
-
};
|
|
253
|
-
return Object.keys(merged).length > 0 ? merged : undefined;
|
|
254
|
-
}
|
|
255
|
-
function compileRuntimeModels(modelRefs, models, ownerId) {
|
|
256
|
-
if (!modelRefs) {
|
|
257
|
-
return undefined;
|
|
258
|
-
}
|
|
259
|
-
const compiled = Object.fromEntries(Object.entries(modelRefs).map(([slot, modelRef]) => [slot, requireModel(models, modelRef, ownerId)]));
|
|
260
|
-
return Object.keys(compiled).length > 0 ? compiled : undefined;
|
|
261
|
-
}
|
|
262
248
|
export function compileBinding(workspaceRoot, agent, agents, referencedSubagentIds, refs, models, tools) {
|
|
263
249
|
const internalSubagent = referencedSubagentIds.has(agent.id);
|
|
264
250
|
const runtimeDefaults = getRuntimeDefaults(refs);
|
|
@@ -274,8 +260,6 @@ export function compileBinding(workspaceRoot, agent, agents, referencedSubagentI
|
|
|
274
260
|
const store = resolveStoreConfig(agent, refs);
|
|
275
261
|
const checkpointer = resolveCheckpointerConfig(agent, refs);
|
|
276
262
|
const runtimeMemory = resolveRuntimeMemoryConfig(agent, refs);
|
|
277
|
-
const runtimeModelRefs = resolveRuntimeModelRefs(agent, refs);
|
|
278
|
-
const runtimeModels = compileRuntimeModels(runtimeModelRefs, models, agent.id);
|
|
279
263
|
const runRoot = typeof agent.runRoot === "string" && agent.runRoot.trim().length > 0
|
|
280
264
|
? path.resolve(workspaceRoot, agent.runRoot)
|
|
281
265
|
: typeof runtimeDefaults?.runRoot === "string" && runtimeDefaults.runRoot.trim().length > 0
|
|
@@ -296,8 +280,6 @@ export function compileBinding(workspaceRoot, agent, agents, referencedSubagentI
|
|
|
296
280
|
harnessRuntime: {
|
|
297
281
|
runRoot,
|
|
298
282
|
workspaceRoot,
|
|
299
|
-
...(runtimeModelRefs ? { modelRefs: runtimeModelRefs } : {}),
|
|
300
|
-
...(runtimeModels ? { models: runtimeModels } : {}),
|
|
301
283
|
capabilities: inferAgentCapabilities(agent),
|
|
302
284
|
resilience,
|
|
303
285
|
...(checkpointer ? { checkpointer: checkpointer.config } : {}),
|
|
@@ -356,8 +338,6 @@ export function compileBinding(workspaceRoot, agent, agents, referencedSubagentI
|
|
|
356
338
|
name: resolveAgentRuntimeName(agent),
|
|
357
339
|
memory: compiledAgentMemory,
|
|
358
340
|
skills: compiledAgentSkills,
|
|
359
|
-
generalPurposeAgent: getAgentExecutionConfigValue(agent, "generalPurposeAgent", { executionMode: "deepagent" }),
|
|
360
|
-
taskDescription: getAgentExecutionString(agent, "taskDescription", { executionMode: "deepagent" }),
|
|
361
341
|
};
|
|
362
342
|
return {
|
|
363
343
|
...base,
|