@botbotgo/agent-harness 0.0.267 → 0.0.269

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 (47) hide show
  1. package/README.md +8 -0
  2. package/README.zh.md +7 -0
  3. package/dist/acp.js +2 -2
  4. package/dist/api.d.ts +6 -11
  5. package/dist/api.js +20 -23
  6. package/dist/contracts/runtime.d.ts +38 -70
  7. package/dist/flow/build-flow-graph.js +29 -45
  8. package/dist/flow/types.d.ts +0 -6
  9. package/dist/package-version.d.ts +1 -1
  10. package/dist/package-version.js +1 -1
  11. package/dist/persistence/file-store.js +24 -17
  12. package/dist/persistence/sqlite-run-context-store.js +2 -2
  13. package/dist/persistence/sqlite-store.js +18 -16
  14. package/dist/protocol/a2a/http.js +48 -46
  15. package/dist/protocol/ag-ui/http.js +9 -9
  16. package/dist/runtime/adapter/invocation-result.js +2 -2
  17. package/dist/runtime/harness/events/listener-runtime.d.ts +2 -2
  18. package/dist/runtime/harness/events/streaming.d.ts +8 -8
  19. package/dist/runtime/harness/events/streaming.js +10 -10
  20. package/dist/runtime/harness/events/timeline.js +4 -4
  21. package/dist/runtime/harness/run/helpers.js +2 -2
  22. package/dist/runtime/harness/run/recovery.js +20 -20
  23. package/dist/runtime/harness/run/resume.js +3 -3
  24. package/dist/runtime/harness/run/run-lifecycle.js +5 -5
  25. package/dist/runtime/harness/run/run-operations.d.ts +2 -2
  26. package/dist/runtime/harness/run/run-operations.js +21 -21
  27. package/dist/runtime/harness/run/start-run.d.ts +3 -3
  28. package/dist/runtime/harness/run/start-run.js +3 -3
  29. package/dist/runtime/harness/run/startup-runtime.js +1 -1
  30. package/dist/runtime/harness/run/stream-run.js +37 -27
  31. package/dist/runtime/harness/run/thread-records.js +12 -33
  32. package/dist/runtime/harness/system/mem0-ingestion-sync.js +2 -2
  33. package/dist/runtime/harness/system/runtime-memory-manager.js +4 -4
  34. package/dist/runtime/harness/system/runtime-memory-records.js +6 -6
  35. package/dist/runtime/harness/system/runtime-memory-sync.js +6 -4
  36. package/dist/runtime/harness/system/thread-memory-sync.js +7 -5
  37. package/dist/runtime/harness.d.ts +2 -2
  38. package/dist/runtime/harness.js +161 -156
  39. package/dist/runtime/support/harness-support.js +4 -4
  40. package/dist/workspace/compile.js +6 -5
  41. package/dist/workspace/object-loader.d.ts +4 -1
  42. package/dist/workspace/object-loader.js +13 -5
  43. package/dist/workspace/support/workspace-ref-utils.d.ts +5 -0
  44. package/dist/workspace/support/workspace-ref-utils.js +9 -0
  45. package/dist/workspace/tool-hydration.d.ts +2 -1
  46. package/dist/workspace/tool-hydration.js +4 -4
  47. package/package.json +1 -1
package/README.md CHANGED
@@ -752,6 +752,7 @@ Important fields:
752
752
  - `concurrency.maxConcurrentRuns`
753
753
  - `routing.defaultAgentId`
754
754
  - `routing.rules`
755
+ - `toolModuleDiscovery.scope`
755
756
  - `maintenance.checkpoints`
756
757
  - `maintenance.records`
757
758
  - `recovery.enabled`
@@ -765,6 +766,11 @@ Important fields:
765
766
  - `maintenance.checkpoints` trims backend checkpoint state used for resume/recovery
766
767
  - `maintenance.records` trims harness-owned terminal session/request records stored in `runtime.sqlite`
767
768
 
769
+ `toolModuleDiscovery.scope` controls how local `resources/tools/`-style module discovery walks tool directories:
770
+
771
+ - `recursive` is the default and keeps scanning nested folders
772
+ - `top-level` limits module discovery to files directly under each tool root while leaving YAML catalogs recursive
773
+
768
774
  When libSQL reports an error against harness runtime persistence, the message is prefixed with the absolute path to `runtime.sqlite`. For constraint-class failures (or whenever you set `AGENT_HARNESS_RUNTIME_SQLITE_DEBUG=1`), the message also includes a truncated copy of the failing SQL so you can tell harness persistence apart from other SQLite databases in the same process.
769
775
 
770
776
  Example:
@@ -776,6 +782,8 @@ metadata:
776
782
  name: default
777
783
  spec:
778
784
  runRoot: ./.agent
785
+ toolModuleDiscovery:
786
+ scope: top-level
779
787
  concurrency:
780
788
  maxConcurrentRuns: 3
781
789
  routing:
package/README.zh.md CHANGED
@@ -724,6 +724,11 @@ await stop(runtime);
724
724
  - `maintenance.checkpoints` 清理后端用于 resume/recovery 的 checkpoint 状态
725
725
  - `maintenance.records` 清理 harness 自己保存在 `runtime.sqlite` 中、已结束的 session/request 记录
726
726
 
727
+ `toolModuleDiscovery.scope` 用来控制本地 `resources/tools/` 这类 tool module 目录的发现范围:
728
+
729
+ - `recursive` 是默认值,会继续扫描嵌套目录
730
+ - `top-level` 只发现每个工具根目录下一层文件,同时保留 YAML catalog 的递归发现
731
+
727
732
  当 libSQL 对 harness 运行时持久化报错时,错误信息会带上 `runtime.sqlite` 的绝对路径。对约束类错误(或设置环境变量 `AGENT_HARNESS_RUNTIME_SQLITE_DEBUG=1` 时),信息中还会包含被截断的失败 SQL,便于在同一进程里区分 harness 与其它 SQLite 数据库。
728
733
 
729
734
  示例:
@@ -735,6 +740,8 @@ metadata:
735
740
  name: default
736
741
  spec:
737
742
  runRoot: ./.agent
743
+ toolModuleDiscovery:
744
+ scope: top-level
738
745
  concurrency:
739
746
  maxConcurrentRuns: 3
740
747
  routing:
package/dist/acp.js CHANGED
@@ -31,8 +31,8 @@ function toNotification(event) {
31
31
  eventId: event.eventId,
32
32
  eventType: event.eventType,
33
33
  timestamp: event.timestamp,
34
- sessionId: event.threadId,
35
- requestId: event.runId,
34
+ sessionId: event.sessionId,
35
+ requestId: event.requestId,
36
36
  sequence: event.sequence,
37
37
  source: event.source,
38
38
  payload: event.payload,
package/dist/api.d.ts CHANGED
@@ -55,7 +55,7 @@ export type Approval = {
55
55
  allowedDecisions: Array<"approve" | "edit" | "reject">;
56
56
  inputPreview: Record<string, unknown>;
57
57
  };
58
- export type RequestArtifactListing = Omit<ArtifactListing, "threadId" | "runId"> & {
58
+ export type RequestArtifactListing = Omit<ArtifactListing, "sessionId" | "requestId"> & {
59
59
  sessionId: string;
60
60
  requestId: string;
61
61
  };
@@ -97,17 +97,17 @@ type PublicApprovalFilter = {
97
97
  sessionId?: string;
98
98
  requestId?: string;
99
99
  };
100
- type PublicRequestStartOptions = Omit<RunStartOptions, "threadId" | "listeners"> & {
100
+ type PublicRequestStartOptions = Omit<RunStartOptions, "sessionId" | "listeners"> & {
101
101
  sessionId?: string;
102
102
  listeners?: PublicRunListeners;
103
103
  };
104
- type PublicRequestDecisionOptions = Omit<RunDecisionOptions, "threadId" | "runId" | "listeners"> & {
104
+ type PublicRequestDecisionOptions = Omit<RunDecisionOptions, "sessionId" | "requestId" | "listeners"> & {
105
105
  sessionId: string;
106
106
  requestId?: string;
107
107
  listeners?: PublicRunListeners;
108
108
  };
109
109
  type PublicRequestOptions = PublicRequestStartOptions | PublicRequestDecisionOptions;
110
- type PublicRequestResult = Omit<RunResult, "threadId" | "runId"> & {
110
+ type PublicRequestResult = Omit<RunResult, "sessionId" | "requestId"> & {
111
111
  sessionId: string;
112
112
  requestId: string;
113
113
  };
@@ -188,13 +188,8 @@ export declare function describeInventory(runtime: AgentHarnessRuntime, options?
188
188
  workspaceRoot: string;
189
189
  agents: InventoryAgentRecord[];
190
190
  };
191
- export declare function resolveApproval(runtime: AgentHarnessRuntime, options: ResumeOptions & {
192
- sessionId?: string;
193
- requestId?: string;
194
- }): Promise<PublicRunResult>;
195
- export declare function cancelRun(runtime: AgentHarnessRuntime, options: CancelOptions & {
196
- requestId?: string;
197
- }): Promise<PublicRunResult>;
191
+ export declare function resolveApproval(runtime: AgentHarnessRuntime, options: ResumeOptions): Promise<PublicRunResult>;
192
+ export declare function cancelRun(runtime: AgentHarnessRuntime, options: CancelOptions): Promise<PublicRunResult>;
198
193
  export declare function stop(runtime: AgentHarnessRuntime): Promise<void>;
199
194
  export declare function createToolMcpServer(runtime: AgentHarnessRuntime, options: ToolMcpServerOptions): Promise<import("@modelcontextprotocol/sdk/server/mcp").McpServer>;
200
195
  export declare function serveToolsOverStdio(runtime: AgentHarnessRuntime, options: ToolMcpServerOptions): Promise<import("@modelcontextprotocol/sdk/server/mcp").McpServer>;
package/dist/api.js CHANGED
@@ -15,8 +15,8 @@ function toApprovalRecord(record) {
15
15
  return {
16
16
  approvalId: record.approvalId,
17
17
  pendingActionId: record.pendingActionId,
18
- sessionId: record.threadId,
19
- requestId: record.runId,
18
+ sessionId: record.sessionId,
19
+ requestId: record.requestId,
20
20
  toolName: record.toolName,
21
21
  ...(record.approvalReason ? { approvalReason: record.approvalReason } : {}),
22
22
  status: record.status,
@@ -47,8 +47,8 @@ function toPublicEvent(event) {
47
47
  eventId: event.eventId,
48
48
  eventType: toPublicEventType(event.eventType),
49
49
  timestamp: event.timestamp,
50
- sessionId: event.threadId,
51
- requestId: event.runId,
50
+ sessionId: event.sessionId,
51
+ requestId: event.requestId,
52
52
  sequence: event.sequence,
53
53
  source: event.source,
54
54
  payload: event.payload,
@@ -77,8 +77,8 @@ function toPublicRunListeners(listeners) {
77
77
  onUpstreamEvent: listeners.onUpstreamEvent,
78
78
  onTraceItem: listeners.onTraceItem
79
79
  ? async (item) => listeners.onTraceItem({
80
- sessionId: item.threadId,
81
- requestId: item.runId,
80
+ sessionId: item.sessionId,
81
+ requestId: item.requestId,
82
82
  surfaceItem: item.surfaceItem,
83
83
  event: item.event,
84
84
  })
@@ -87,8 +87,8 @@ function toPublicRunListeners(listeners) {
87
87
  }
88
88
  function toRequestArtifactListing(listing) {
89
89
  return {
90
- sessionId: listing.threadId,
91
- requestId: listing.runId,
90
+ sessionId: listing.sessionId,
91
+ requestId: listing.requestId,
92
92
  items: listing.items,
93
93
  };
94
94
  }
@@ -106,8 +106,8 @@ function toRequestPackage(pkg) {
106
106
  }
107
107
  function toPublicRunResult(result) {
108
108
  return {
109
- sessionId: result.threadId,
110
- requestId: result.runId,
109
+ sessionId: result.sessionId,
110
+ requestId: result.requestId,
111
111
  state: result.state,
112
112
  output: result.output,
113
113
  finalMessageText: result.finalMessageText,
@@ -130,8 +130,8 @@ function toInternalRunOptions(options) {
130
130
  decision: options.decision,
131
131
  editedInput: options.editedInput,
132
132
  listeners: toPublicRunListeners(options.listeners),
133
- runId: options.requestId,
134
- threadId: options.sessionId,
133
+ requestId: options.requestId,
134
+ sessionId: options.sessionId,
135
135
  };
136
136
  }
137
137
  return {
@@ -140,7 +140,7 @@ function toInternalRunOptions(options) {
140
140
  invocation: options.invocation,
141
141
  listeners: toPublicRunListeners(options.listeners),
142
142
  priority: options.priority,
143
- threadId: options.sessionId,
143
+ sessionId: options.sessionId,
144
144
  };
145
145
  }
146
146
  function toInternalResumeOptions(options) {
@@ -148,14 +148,14 @@ function toInternalResumeOptions(options) {
148
148
  approvalId: options.approvalId,
149
149
  decision: options.decision,
150
150
  editedInput: options.editedInput,
151
- runId: options.requestId ?? options.runId,
152
- threadId: options.sessionId ?? options.threadId,
151
+ requestId: options.requestId,
152
+ sessionId: options.sessionId,
153
153
  };
154
154
  }
155
155
  function toPublicRequestSummary(run) {
156
156
  return {
157
- requestId: run.runId,
158
- sessionId: run.threadId,
157
+ requestId: run.requestId,
158
+ sessionId: run.sessionId,
159
159
  agentId: run.agentId,
160
160
  parentRunId: run.parentRunId,
161
161
  executionMode: run.executionMode,
@@ -270,9 +270,9 @@ export async function deleteSession(runtime, sessionId) {
270
270
  }
271
271
  export async function listApprovals(runtime, filter) {
272
272
  return (await runtime.listApprovals({
273
- runId: filter?.requestId,
273
+ requestId: filter?.requestId,
274
274
  status: filter?.status,
275
- threadId: filter?.sessionId,
275
+ sessionId: filter?.sessionId,
276
276
  })).map(toApprovalRecord);
277
277
  }
278
278
  export async function getApproval(runtime, approvalId) {
@@ -363,10 +363,7 @@ export async function resolveApproval(runtime, options) {
363
363
  return toPublicRunResult(await runtime.resume(toInternalResumeOptions(options)));
364
364
  }
365
365
  export async function cancelRun(runtime, options) {
366
- return toPublicRunResult(await runtime.cancelRun({
367
- ...options,
368
- runId: options.requestId ?? options.runId,
369
- }));
366
+ return toPublicRunResult(await runtime.cancelRun(options));
370
367
  }
371
368
  export async function stop(runtime) {
372
369
  return runtime.stop();
@@ -25,17 +25,8 @@ export type SessionListSummary = SessionSummary & {
25
25
  title?: string;
26
26
  snippet?: string;
27
27
  };
28
- /**
29
- * Backward-compatible alias for older thread/run terminology.
30
- */
31
- export type ThreadSummary = Omit<SessionSummary, "sessionId" | "latestRequestId"> & {
32
- threadId: string;
33
- latestRunId: string;
34
- };
35
- export type ThreadListSummary = Omit<SessionListSummary, "sessionId" | "latestRequestId"> & {
36
- threadId: string;
37
- latestRunId: string;
38
- };
28
+ export type ThreadSummary = SessionSummary;
29
+ export type ThreadListSummary = SessionListSummary;
39
30
  export type KnownHarnessEventType = "run.created" | "run.queued" | "run.dequeued" | "run.state.changed" | "run.resumed" | "approval.requested" | "approval.resolved" | "artifact.created" | "output.delta" | "runtime.health.changed" | "runtime.synthetic_fallback";
40
31
  export type HarnessEventType = KnownHarnessEventType | (string & {});
41
32
  /**
@@ -47,8 +38,8 @@ export type HarnessEvent = {
47
38
  eventId: string;
48
39
  eventType: HarnessEventType;
49
40
  timestamp: string;
50
- threadId: string;
51
- runId: string;
41
+ sessionId: string;
42
+ requestId: string;
52
43
  sequence: number;
53
44
  source: "runtime" | "policy" | "surface" | "worker";
54
45
  payload: Record<string, unknown>;
@@ -65,8 +56,8 @@ export type HarnessEventProjection = {
65
56
  */
66
57
  export type RuntimeTimelineItem = {
67
58
  eventId: string;
68
- threadId: string;
69
- runId: string;
59
+ sessionId: string;
60
+ requestId: string;
70
61
  eventType: HarnessEventType;
71
62
  timestamp: string;
72
63
  sequence: number;
@@ -75,8 +66,8 @@ export type RuntimeTimelineItem = {
75
66
  payload: Record<string, unknown>;
76
67
  };
77
68
  export type RuntimeTimelineProjectionOptions = {
78
- threadId?: string;
79
- runId?: string;
69
+ sessionId?: string;
70
+ requestId?: string;
80
71
  };
81
72
  /**
82
73
  * Ordered upstream/runtime execution trace projected from persisted upstream events.
@@ -281,8 +272,6 @@ export type MemorizeInput = {
281
272
  records: MemorizeInputRecord[];
282
273
  sessionId?: string;
283
274
  requestId?: string;
284
- threadId?: string;
285
- runId?: string;
286
275
  agentId?: string;
287
276
  userId?: string;
288
277
  projectId?: string;
@@ -299,7 +288,6 @@ export type RecallInput = {
299
288
  topK?: number;
300
289
  includeStale?: boolean;
301
290
  sessionId?: string;
302
- threadId?: string;
303
291
  agentId?: string;
304
292
  workspaceId?: string;
305
293
  userId?: string;
@@ -313,7 +301,6 @@ export type ListMemoriesInput = {
313
301
  kinds?: MemoryKind[];
314
302
  status?: MemoryRecordStatus[];
315
303
  sessionId?: string;
316
- threadId?: string;
317
304
  agentId?: string;
318
305
  workspaceId?: string;
319
306
  userId?: string;
@@ -411,8 +398,8 @@ export type RuntimeHealthSnapshot = {
411
398
  };
412
399
  };
413
400
  export type RunResult = {
414
- threadId: string;
415
- runId: string;
401
+ sessionId: string;
402
+ requestId: string;
416
403
  state: RunState;
417
404
  output: string;
418
405
  finalMessageText?: string;
@@ -429,8 +416,8 @@ export type RunResult = {
429
416
  };
430
417
  export type UpstreamRuntimeEvent = unknown;
431
418
  export type UpstreamRuntimeEventItem = {
432
- threadId: string;
433
- runId: string;
419
+ sessionId: string;
420
+ requestId: string;
434
421
  surfaceItem: RuntimeSurfaceItem;
435
422
  event: UpstreamRuntimeEvent;
436
423
  };
@@ -457,14 +444,14 @@ export type InvocationEnvelope = {
457
444
  export type RunStartOptions = {
458
445
  agentId?: string;
459
446
  input: MessageContent;
460
- threadId?: string;
447
+ sessionId?: string;
461
448
  priority?: number;
462
449
  invocation?: InvocationEnvelope;
463
450
  listeners?: RunListeners;
464
451
  };
465
452
  export type RunDecisionOptions = {
466
- threadId: string;
467
- runId?: string;
453
+ sessionId: string;
454
+ requestId?: string;
468
455
  approvalId?: string;
469
456
  decision: "approve" | "edit" | "reject";
470
457
  editedInput?: Record<string, unknown>;
@@ -476,28 +463,28 @@ export type HarnessStreamItem = {
476
463
  event: HarnessEvent;
477
464
  } | {
478
465
  type: "content";
479
- threadId: string;
480
- runId: string;
466
+ sessionId: string;
467
+ requestId: string;
481
468
  agentId: string;
482
469
  content: string;
483
470
  } | {
484
471
  type: "content-blocks";
485
- threadId: string;
486
- runId: string;
472
+ sessionId: string;
473
+ requestId: string;
487
474
  agentId: string;
488
475
  contentBlocks: unknown[];
489
476
  } | {
490
477
  type: "tool-result";
491
- threadId: string;
492
- runId: string;
478
+ sessionId: string;
479
+ requestId: string;
493
480
  agentId: string;
494
481
  toolName: string;
495
482
  output: unknown;
496
483
  isError?: boolean;
497
484
  } | {
498
485
  type: "upstream-event";
499
- threadId: string;
500
- runId: string;
486
+ sessionId: string;
487
+ requestId: string;
501
488
  surfaceItem?: RuntimeSurfaceItem;
502
489
  event: UpstreamRuntimeEvent;
503
490
  } | {
@@ -507,12 +494,12 @@ export type HarnessStreamItem = {
507
494
  export type TranscriptMessage = {
508
495
  role: "user" | "assistant";
509
496
  content: MessageContent;
510
- runId: string;
497
+ requestId: string;
511
498
  createdAt: string;
512
499
  };
513
500
  export type ThreadRunRecord = {
514
- runId: string;
515
- threadId: string;
501
+ requestId: string;
502
+ sessionId: string;
516
503
  agentId: string;
517
504
  parentRunId?: string;
518
505
  executionMode: string;
@@ -533,25 +520,13 @@ export type ThreadRunRecord = {
533
520
  * Persisted request summary projected from upstream execution state plus runtime lifecycle metadata.
534
521
  * This is the canonical runtime-facing execution record.
535
522
  */
536
- export type RequestSummary = Omit<ThreadRunRecord, "threadId" | "runId"> & {
537
- sessionId: string;
538
- requestId: string;
539
- };
523
+ export type RequestSummary = ThreadRunRecord;
540
524
  export type RequestRecord = RequestSummary & {
541
525
  traceItems?: unknown[];
542
526
  runtimeTimeline?: RuntimeTimelineItem[];
543
527
  };
544
- /**
545
- * Backward-compatible alias for older thread/run terminology.
546
- */
547
- export type RunSummary = Omit<RequestSummary, "sessionId" | "requestId"> & {
548
- threadId: string;
549
- runId: string;
550
- };
551
- export type RunRecord = RunSummary & {
552
- traceItems?: unknown[];
553
- runtimeTimeline?: RuntimeTimelineItem[];
554
- };
528
+ export type RunSummary = RequestSummary;
529
+ export type RunRecord = RequestRecord;
555
530
  /**
556
531
  * Persisted session inspection record assembled from runtime records.
557
532
  * This is an inspectable projection, not a second session semantic model.
@@ -574,27 +549,20 @@ export type SessionRecord = {
574
549
  requestedAt: string;
575
550
  };
576
551
  };
577
- /**
578
- * Backward-compatible alias for older thread/run terminology.
579
- */
580
- export type ThreadRecord = Omit<SessionRecord, "sessionId" | "latestRequestId" | "requests"> & {
581
- threadId: string;
582
- latestRunId: string;
583
- runs: RunRecord[];
584
- };
552
+ export type ThreadRecord = SessionRecord;
585
553
  export type ResumeOptions = {
586
- threadId?: string;
587
- runId?: string;
554
+ sessionId?: string;
555
+ requestId?: string;
588
556
  approvalId?: string;
589
557
  decision?: "approve" | "edit" | "reject";
590
558
  editedInput?: Record<string, unknown>;
591
559
  };
592
560
  export type CancelOptions = {
593
- runId: string;
561
+ requestId: string;
594
562
  reason?: string;
595
563
  };
596
564
  export type RestartConversationOptions = {
597
- threadId: string;
565
+ sessionId: string;
598
566
  mode: "restart-in-thread" | "restart-new-thread";
599
567
  input: string;
600
568
  };
@@ -606,8 +574,8 @@ export type RestartConversationOptions = {
606
574
  export type ApprovalRecord = {
607
575
  approvalId: string;
608
576
  pendingActionId: string;
609
- threadId: string;
610
- runId: string;
577
+ sessionId: string;
578
+ requestId: string;
611
579
  toolName: string;
612
580
  approvalReason?: string;
613
581
  status: "pending" | "approved" | "edited" | "rejected" | "expired";
@@ -628,8 +596,8 @@ export type ArtifactRecord = {
628
596
  createdAt: string;
629
597
  };
630
598
  export type ArtifactListing = {
631
- threadId: string;
632
- runId: string;
599
+ sessionId: string;
600
+ requestId: string;
633
601
  items: ArtifactRecord[];
634
602
  };
635
603
  export type RuntimeToolResolver = (toolIds: string[], binding?: CompiledAgentBinding) => unknown[];