@botbotgo/agent-harness 0.0.92 → 0.0.94

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.
Files changed (41) hide show
  1. package/README.md +153 -31
  2. package/README.zh.md +108 -28
  3. package/dist/benchmark/upstream-runtime-ab-benchmark.d.ts +1 -1
  4. package/dist/benchmark/upstream-runtime-ab-benchmark.js +2 -1
  5. package/dist/config/workflows/langgraph-workflows.yaml +318 -0
  6. package/dist/contracts/types.d.ts +8 -3
  7. package/dist/init-project.js +7 -7
  8. package/dist/package-version.d.ts +1 -1
  9. package/dist/package-version.js +1 -1
  10. package/dist/runtime/agent-runtime-adapter.d.ts +49 -1
  11. package/dist/runtime/agent-runtime-adapter.js +1103 -50
  12. package/dist/runtime/harness.d.ts +2 -0
  13. package/dist/runtime/harness.js +55 -11
  14. package/dist/runtime/inventory.d.ts +1 -1
  15. package/dist/runtime/inventory.js +1 -1
  16. package/dist/runtime/langgraph-presets.d.ts +25 -0
  17. package/dist/runtime/langgraph-presets.js +165 -0
  18. package/dist/runtime/langgraph-profiles.d.ts +6 -0
  19. package/dist/runtime/langgraph-profiles.js +206 -0
  20. package/dist/runtime/policy-engine.js +0 -5
  21. package/dist/runtime/support/compiled-binding.d.ts +4 -1
  22. package/dist/runtime/support/compiled-binding.js +24 -2
  23. package/dist/runtime/support/harness-support.js +3 -3
  24. package/dist/runtime/support/runtime-entry.js +1 -1
  25. package/dist/workspace/agent-binding-compiler.js +111 -8
  26. package/dist/workspace/compile.js +1 -3
  27. package/dist/workspace/object-loader.js +46 -5
  28. package/dist/workspace/support/agent-capabilities.js +2 -2
  29. package/dist/workspace/support/workspace-ref-utils.d.ts +2 -1
  30. package/dist/workspace/support/workspace-ref-utils.js +21 -0
  31. package/dist/workspace/validate.js +1 -1
  32. package/package.json +2 -2
  33. /package/dist/config/{backends.yaml → catalogs/backends.yaml} +0 -0
  34. /package/dist/config/{embedding-models.yaml → catalogs/embedding-models.yaml} +0 -0
  35. /package/dist/config/{mcp.yaml → catalogs/mcp.yaml} +0 -0
  36. /package/dist/config/{models.yaml → catalogs/models.yaml} +0 -0
  37. /package/dist/config/{stores.yaml → catalogs/stores.yaml} +0 -0
  38. /package/dist/config/{tools.yaml → catalogs/tools.yaml} +0 -0
  39. /package/dist/config/{vector-stores.yaml → catalogs/vector-stores.yaml} +0 -0
  40. /package/dist/config/{runtime-memory.yaml → runtime/runtime-memory.yaml} +0 -0
  41. /package/dist/config/{workspace.yaml → runtime/workspace.yaml} +0 -0
@@ -0,0 +1,318 @@
1
+ # agent-harness feature: schema version for this declarative config object.
2
+ apiVersion: agent-harness/v1alpha1
3
+ # agent-harness feature: catalog of reusable LangGraph-shaped workflow resources.
4
+ kind: LangGraphWorkflows
5
+ spec:
6
+ - id: default
7
+ entryNode: planner
8
+ nodes:
9
+ - id: planner
10
+ kind: llm
11
+ role: planner
12
+ prompt: >-
13
+ You are the workflow planner. Produce a concise plan for the user request
14
+ before execution starts.
15
+ - id: executor
16
+ kind: agent
17
+ - id: reviewer
18
+ kind: llm
19
+ role: reviewer
20
+ prompt: >-
21
+ Review the current result, call out missing verification or obvious gaps,
22
+ and state whether the work looks sufficient.
23
+ - id: replanner
24
+ kind: llm
25
+ role: replanner
26
+ prompt: >-
27
+ Refine the plan based on the reviewer feedback and current result.
28
+ Return only the updated plan.
29
+ - id: finalizer
30
+ kind: llm
31
+ role: finalizer
32
+ prompt: >-
33
+ Rewrite the current result into a concise user-facing final answer.
34
+ Preserve facts and caveats.
35
+ edges:
36
+ - from: planner
37
+ to: executor
38
+ - from: executor
39
+ to: reviewer
40
+ when: has_result
41
+ - from: reviewer
42
+ to: finalizer
43
+ when: review_ok
44
+ - from: reviewer
45
+ to: replanner
46
+ when: review_incomplete
47
+ - from: replanner
48
+ to: executor
49
+ when: has_plan
50
+ - id: react
51
+ entryNode: executor
52
+ nodes:
53
+ - id: executor
54
+ kind: agent
55
+ edges: []
56
+ - id: prompt-chaining
57
+ entryNode: planner
58
+ nodes:
59
+ - id: planner
60
+ kind: llm
61
+ role: planner
62
+ prompt: >-
63
+ You are the workflow planner. Produce a concise execution plan for the user request
64
+ before execution starts.
65
+ - id: executor
66
+ kind: agent
67
+ - id: finalizer
68
+ kind: llm
69
+ role: finalizer
70
+ prompt: >-
71
+ Rewrite the current result into a concise user-facing final answer.
72
+ Preserve facts and caveats.
73
+ edges:
74
+ - from: planner
75
+ to: executor
76
+ - from: executor
77
+ to: finalizer
78
+ when: has_result
79
+ - id: routing
80
+ entryNode: planner
81
+ nodes:
82
+ - id: planner
83
+ kind: llm
84
+ role: planner
85
+ prompt: >-
86
+ You are the workflow planner. Produce a concise execution plan for the user request
87
+ before execution starts.
88
+ - id: worker
89
+ kind: agent
90
+ agent: worker
91
+ - id: finalizer
92
+ kind: llm
93
+ role: finalizer
94
+ prompt: >-
95
+ Rewrite the current result into a concise user-facing final answer.
96
+ Preserve facts and caveats.
97
+ edges:
98
+ - from: planner
99
+ to: worker
100
+ - from: worker
101
+ to: finalizer
102
+ when: has_result
103
+ - id: parallelization
104
+ entryNode: planner
105
+ nodes:
106
+ - id: planner
107
+ kind: llm
108
+ role: planner
109
+ prompt: >-
110
+ You are the workflow planner. Produce a concise execution plan for the user request
111
+ before execution starts.
112
+ - id: worker
113
+ kind: agent
114
+ agent: worker
115
+ - id: reviewer
116
+ kind: llm
117
+ role: reviewer
118
+ prompt: >-
119
+ Review the current result, call out missing verification or obvious gaps,
120
+ and state whether the work looks sufficient.
121
+ - id: finalizer
122
+ kind: llm
123
+ role: finalizer
124
+ prompt: >-
125
+ Rewrite the current result into a concise user-facing final answer.
126
+ Preserve facts and caveats.
127
+ edges:
128
+ - from: planner
129
+ to: worker
130
+ - from: worker
131
+ to: reviewer
132
+ when: has_result
133
+ - from: reviewer
134
+ to: finalizer
135
+ when: review_ok
136
+ - id: plan-execute
137
+ entryNode: planner
138
+ nodes:
139
+ - id: planner
140
+ kind: llm
141
+ role: planner
142
+ prompt: >-
143
+ You are the workflow planner. Produce a concise execution plan for the user request
144
+ before execution starts.
145
+ - id: executor
146
+ kind: agent
147
+ - id: finalizer
148
+ kind: llm
149
+ role: finalizer
150
+ prompt: >-
151
+ Rewrite the current result into a concise user-facing final answer.
152
+ Preserve facts and caveats.
153
+ edges:
154
+ - from: planner
155
+ to: executor
156
+ - from: executor
157
+ to: finalizer
158
+ when: has_result
159
+ - id: review-loop
160
+ entryNode: planner
161
+ nodes:
162
+ - id: planner
163
+ kind: llm
164
+ role: planner
165
+ prompt: >-
166
+ You are the workflow planner. Produce a concise plan for the user request
167
+ before execution starts.
168
+ - id: executor
169
+ kind: agent
170
+ - id: reviewer
171
+ kind: llm
172
+ role: reviewer
173
+ prompt: >-
174
+ Review the current result, call out missing verification or obvious gaps,
175
+ and state whether the work looks sufficient.
176
+ - id: replanner
177
+ kind: llm
178
+ role: replanner
179
+ prompt: >-
180
+ Refine the plan based on the reviewer feedback and current result.
181
+ Return only the updated plan.
182
+ - id: finalizer
183
+ kind: llm
184
+ role: finalizer
185
+ prompt: >-
186
+ Rewrite the current result into a concise user-facing final answer.
187
+ Preserve facts and caveats.
188
+ edges:
189
+ - from: planner
190
+ to: executor
191
+ - from: executor
192
+ to: reviewer
193
+ when: has_result
194
+ - from: reviewer
195
+ to: finalizer
196
+ when: review_ok
197
+ - from: reviewer
198
+ to: replanner
199
+ when: review_incomplete
200
+ - from: replanner
201
+ to: executor
202
+ when: has_plan
203
+ - id: evaluator-optimizer
204
+ entryNode: executor
205
+ nodes:
206
+ - id: executor
207
+ kind: agent
208
+ - id: reviewer
209
+ kind: llm
210
+ role: reviewer
211
+ prompt: >-
212
+ Review the current result, call out missing verification or obvious gaps,
213
+ and state whether the work looks sufficient.
214
+ - id: replanner
215
+ kind: llm
216
+ role: replanner
217
+ prompt: >-
218
+ Refine the plan based on the reviewer feedback and current result.
219
+ Return only the updated plan.
220
+ - id: finalizer
221
+ kind: llm
222
+ role: finalizer
223
+ prompt: >-
224
+ Rewrite the current result into a concise user-facing final answer.
225
+ Preserve facts and caveats.
226
+ edges:
227
+ - from: executor
228
+ to: reviewer
229
+ when: has_result
230
+ - from: reviewer
231
+ to: finalizer
232
+ when: review_ok
233
+ - from: reviewer
234
+ to: replanner
235
+ when: review_incomplete
236
+ - from: replanner
237
+ to: executor
238
+ when: has_plan
239
+ - id: approval-gate
240
+ entryNode: planner
241
+ nodes:
242
+ - id: planner
243
+ kind: llm
244
+ role: planner
245
+ prompt: >-
246
+ You are the workflow planner. Produce a concise execution plan for the user request
247
+ before execution starts.
248
+ - id: approval
249
+ kind: approval
250
+ - id: executor
251
+ kind: agent
252
+ - id: finalizer
253
+ kind: llm
254
+ role: finalizer
255
+ prompt: >-
256
+ Rewrite the current result into a concise user-facing final answer.
257
+ Preserve facts and caveats.
258
+ edges:
259
+ - from: planner
260
+ to: approval
261
+ - from: approval
262
+ to: executor
263
+ when: approval_approved
264
+ - from: approval
265
+ to: executor
266
+ when: approval_edited
267
+ - from: executor
268
+ to: finalizer
269
+ when: has_result
270
+ - id: handoff
271
+ entryNode: worker
272
+ nodes:
273
+ - id: worker
274
+ kind: agent
275
+ agent: worker
276
+ - id: finalizer
277
+ kind: llm
278
+ role: finalizer
279
+ prompt: >-
280
+ Rewrite the current result into a concise user-facing final answer.
281
+ Preserve facts and caveats.
282
+ edges:
283
+ - from: worker
284
+ to: finalizer
285
+ when: has_result
286
+ - id: orchestrator-workers
287
+ entryNode: planner
288
+ nodes:
289
+ - id: planner
290
+ kind: llm
291
+ role: planner
292
+ prompt: >-
293
+ You are the workflow planner. Produce a concise plan for the user request
294
+ before execution starts.
295
+ - id: worker
296
+ kind: agent
297
+ agent: worker
298
+ - id: reviewer
299
+ kind: llm
300
+ role: reviewer
301
+ prompt: >-
302
+ Review the current result, call out missing verification or obvious gaps,
303
+ and state whether the work looks sufficient.
304
+ - id: finalizer
305
+ kind: llm
306
+ role: finalizer
307
+ prompt: >-
308
+ Rewrite the current result into a concise user-facing final answer.
309
+ Preserve facts and caveats.
310
+ edges:
311
+ - from: planner
312
+ to: worker
313
+ - from: worker
314
+ to: reviewer
315
+ when: has_result
316
+ - from: reviewer
317
+ to: finalizer
318
+ when: review_ok
@@ -1,5 +1,8 @@
1
- export type ExecutionMode = "deepagent" | "langchain-v1";
1
+ export type ExecutionMode = "deepagent" | "langchain-v1" | "langgraph";
2
2
  export declare const AUTO_AGENT_ID = "auto";
3
+ export type RuntimeModelSlot = "routing" | "planning" | "execution" | "review" | "final";
4
+ export type RuntimeModelRefMap = Partial<Record<RuntimeModelSlot, string>>;
5
+ export type RuntimeModelMap = Partial<Record<RuntimeModelSlot, CompiledModel>>;
3
6
  export type RuntimeCapabilities = {
4
7
  delegation?: boolean;
5
8
  memory?: boolean;
@@ -8,6 +11,7 @@ export type RunState = "queued" | "claimed" | "running" | "waiting_for_approval"
8
11
  export type ParsedAgentObject = {
9
12
  id: string;
10
13
  executionMode: ExecutionMode;
14
+ runtimeModelRefs?: RuntimeModelRefMap;
11
15
  capabilities?: RuntimeCapabilities;
12
16
  description: string;
13
17
  modelRef: string;
@@ -200,7 +204,8 @@ export type CompiledAgentBinding = {
200
204
  harnessRuntime: {
201
205
  runRoot: string;
202
206
  workspaceRoot?: string;
203
- runtimeEntry: boolean;
207
+ modelRefs?: RuntimeModelRefMap;
208
+ models?: RuntimeModelMap;
204
209
  capabilities?: RuntimeCapabilities;
205
210
  resilience?: Record<string, unknown>;
206
211
  checkpointer?: Record<string, unknown> | boolean;
@@ -239,7 +244,7 @@ export type ThreadSummary = {
239
244
  status: RunState;
240
245
  };
241
246
  export type SessionRecord = ThreadSummary;
242
- export type KnownHarnessEventType = "run.created" | "run.queued" | "run.dequeued" | "run.state.changed" | "run.resumed" | "approval.requested" | "approval.resolved" | "artifact.created" | "output.delta" | "reasoning.delta" | "runtime.health.changed" | "runtime.synthetic_fallback";
247
+ export type KnownHarnessEventType = "run.created" | "run.queued" | "run.dequeued" | "run.state.changed" | "run.reviewed" | "run.resumed" | "approval.requested" | "approval.resolved" | "artifact.created" | "output.delta" | "reasoning.delta" | "runtime.health.changed" | "runtime.synthetic_fallback";
243
248
  export type HarnessEventType = KnownHarnessEventType | (string & {});
244
249
  export type HarnessEvent = {
245
250
  eventId: string;
@@ -43,7 +43,7 @@ function renderPackageJson(projectSlug, template) {
43
43
  }
44
44
  function renderReadme(displayName, projectSlug, options) {
45
45
  const webSearchLine = options.withWebSearch
46
- ? `- ${options.provider} native web search enabled through \`config/tools.yaml\``
46
+ ? `- ${options.provider} native web search enabled through \`config/catalogs/tools.yaml\``
47
47
  : "- no provider-native web search by default";
48
48
  const providerEnvLine = options.provider === "openai" ? "export OPENAI_API_KEY=your_key_here\n" : "";
49
49
  const templateLine = options.template === "deep-research"
@@ -73,7 +73,7 @@ ${providerEnvLine}npm run start -- "Research the latest model serving stack for
73
73
 
74
74
  ## Customize
75
75
 
76
- - change \`config/models.yaml\` to switch models or providers
76
+ - change \`config/catalogs/models.yaml\` to switch models or providers
77
77
  - add local \`tool({...})\` tools under \`resources/tools/\`
78
78
  - add product-specific skills under \`resources/skills/\`
79
79
  - edit the prompts in \`config/agents/\` to turn this into your own product
@@ -316,12 +316,12 @@ export async function initProject(projectRoot, projectName, options = {}) {
316
316
  [".gitignore", renderGitignore()],
317
317
  ["README.md", renderReadme(displayName, projectSlug, resolved)],
318
318
  ["src/run.mjs", renderRunScript(resolved)],
319
- ["config/workspace.yaml", renderWorkspaceYaml()],
319
+ ["config/runtime/workspace.yaml", renderWorkspaceYaml()],
320
320
  ["config/agent-context.md", renderAgentContext(resolved)],
321
- ["config/models.yaml", renderModelsYaml(resolved)],
322
- ["config/runtime-memory.yaml", renderRuntimeMemoryYaml()],
323
- ["config/backends.yaml", renderBackendsYaml()],
324
- ["config/tools.yaml", renderToolsYaml(resolved)],
321
+ ["config/catalogs/models.yaml", renderModelsYaml(resolved)],
322
+ ["config/runtime/runtime-memory.yaml", renderRuntimeMemoryYaml()],
323
+ ["config/catalogs/backends.yaml", renderBackendsYaml()],
324
+ ["config/catalogs/tools.yaml", renderToolsYaml(resolved)],
325
325
  ["config/agents/research.yaml", renderResearchAgentYaml(resolved)],
326
326
  ["resources/package.json", renderResourcePackageJson(projectSlug)],
327
327
  ["resources/skills/deep-research/SKILL.md", renderSkill(resolved)],
@@ -1 +1 @@
1
- export declare const AGENT_HARNESS_VERSION = "0.0.91";
1
+ export declare const AGENT_HARNESS_VERSION = "0.0.93";
@@ -1 +1 @@
1
- export const AGENT_HARNESS_VERSION = "0.0.91";
1
+ export const AGENT_HARNESS_VERSION = "0.0.93";
@@ -1,4 +1,4 @@
1
- import type { CompiledAgentBinding, MessageContent, RunResult, RuntimeAdapterOptions, TranscriptMessage } from "../contracts/types.js";
1
+ import type { CompiledAgentBinding, CompiledModel, CompiledSubAgent, MessageContent, RunResult, RuntimeAdapterOptions, TranscriptMessage } from "../contracts/types.js";
2
2
  import { type RuntimeStreamChunk } from "./parsing/stream-event-parsing.js";
3
3
  type RunnableLike = {
4
4
  invoke: (input: unknown, config?: Record<string, unknown>) => Promise<unknown>;
@@ -19,10 +19,16 @@ export declare function materializeDeepAgentSkillSourcePaths(options: {
19
19
  ownerId: string;
20
20
  skillPaths?: string[];
21
21
  }): Promise<string[] | undefined>;
22
+ export declare function shouldRelaxDeepAgentDelegationPrompt(model: CompiledModel | undefined, params: {
23
+ subagents?: CompiledSubAgent[];
24
+ generalPurposeAgent?: boolean;
25
+ taskDescription?: string;
26
+ }): boolean;
22
27
  export declare class AgentRuntimeAdapter {
23
28
  private readonly options;
24
29
  private readonly modelCache;
25
30
  private readonly runnableCache;
31
+ private readonly langGraphSessions;
26
32
  constructor(options?: RuntimeAdapterOptions);
27
33
  private getModelCacheKey;
28
34
  private resolveBindingTimeout;
@@ -56,13 +62,54 @@ export declare class AgentRuntimeAdapter {
56
62
  private resolveDeepAgentAutomaticMiddleware;
57
63
  private resolveMiddleware;
58
64
  private resolveCheckpointer;
65
+ private resolveLangGraphWorkflowCheckpointer;
59
66
  private buildRouteSystemPrompt;
60
67
  private resolveSubagents;
68
+ private createLangChainRunnable;
69
+ private normalizeLangGraphWorkflowNode;
70
+ private invokeLangGraphToolNode;
71
+ private listLangGraphWorkflowNodes;
72
+ private normalizeLangGraphWorkflowEdge;
73
+ private listLangGraphWorkflowEdges;
74
+ private shouldFollowLangGraphEdge;
75
+ private listLangGraphWorkflowNextNodes;
76
+ private extractInvocationRequestText;
77
+ private prependSystemMessage;
78
+ private replaceLastUserMessage;
79
+ private resolveLangGraphSessionKey;
80
+ private resolveLangGraphSessionIdentity;
81
+ private langGraphCheckpointNamespace;
82
+ private langGraphCheckpointConfig;
83
+ private buildLangGraphWorkflowCheckpoint;
84
+ private saveLangGraphSessionToCheckpointer;
85
+ private loadLangGraphSessionFromCheckpointer;
86
+ private clearLangGraphSessionInCheckpointer;
87
+ private langGraphSessionFilePath;
88
+ private artifactLangGraphSessionFilePath;
89
+ private legacyLangGraphSessionFilePath;
90
+ private saveLangGraphSession;
91
+ private loadLangGraphSession;
92
+ private clearLangGraphSession;
93
+ private invokeWorkflowNodeModel;
94
+ private invokeLangGraphAgentNode;
95
+ private createLangGraphRunnable;
96
+ private extractExecutedToolResults;
97
+ private extractLangGraphResultOutput;
98
+ private streamLangGraphWorkflow;
61
99
  private createRunnable;
62
100
  create(binding: CompiledAgentBinding): Promise<RunnableLike>;
63
101
  route(input: MessageContent, primaryBinding: CompiledAgentBinding, secondaryBinding: CompiledAgentBinding, options?: {
64
102
  systemPrompt?: string;
65
103
  }): Promise<string>;
104
+ reviewRunResult(binding: CompiledAgentBinding, input: MessageContent, result: Pick<RunResult, "output" | "state" | "finalMessageText">): Promise<{
105
+ assessment: string;
106
+ modelId: string;
107
+ } | null>;
108
+ synthesizeFinalResult(binding: CompiledAgentBinding, input: MessageContent, result: Pick<RunResult, "output" | "state" | "finalMessageText">): Promise<{
109
+ output: string;
110
+ finalMessageText: string;
111
+ modelId: string;
112
+ } | null>;
66
113
  invoke(binding: CompiledAgentBinding, input: MessageContent, threadId: string, runId: string, resumePayload?: unknown, history?: TranscriptMessage[], options?: {
67
114
  context?: Record<string, unknown>;
68
115
  state?: Record<string, unknown>;
@@ -72,6 +119,7 @@ export declare class AgentRuntimeAdapter {
72
119
  context?: Record<string, unknown>;
73
120
  state?: Record<string, unknown>;
74
121
  files?: Record<string, unknown>;
122
+ runId?: string;
75
123
  }): AsyncGenerator<RuntimeStreamChunk | string>;
76
124
  }
77
125
  export { AgentRuntimeAdapter as RuntimeAdapter, AGENT_INTERRUPT_SENTINEL_PREFIX, AGENT_INTERRUPT_SENTINEL_PREFIX as INTERRUPT_SENTINEL_PREFIX, RuntimeOperationTimeoutError, };