@botbotgo/agent-harness 0.0.290 → 0.0.291

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 (134) hide show
  1. package/README.md +20 -20
  2. package/README.zh.md +14 -14
  3. package/dist/acp.d.ts +5 -5
  4. package/dist/acp.js +3 -3
  5. package/dist/api.d.ts +20 -21
  6. package/dist/api.js +38 -50
  7. package/dist/cli.js +47 -43
  8. package/dist/config/agents/orchestra.yaml +3 -3
  9. package/dist/config/knowledge/knowledge-runtime.yaml +4 -4
  10. package/dist/config/runtime/runtime-memory.yaml +7 -7
  11. package/dist/config/runtime/workspace.yaml +7 -7
  12. package/dist/contracts/core.d.ts +1 -1
  13. package/dist/contracts/runtime.d.ts +35 -40
  14. package/dist/contracts/workspace.d.ts +2 -2
  15. package/dist/flow/build-flow-graph.js +20 -33
  16. package/dist/flow/export-sequence-mermaid.js +4 -4
  17. package/dist/flow/types.d.ts +2 -2
  18. package/dist/index.d.ts +4 -4
  19. package/dist/index.js +1 -1
  20. package/dist/init-project.js +10 -10
  21. package/dist/knowledge/module.js +37 -45
  22. package/dist/mcp.d.ts +9 -9
  23. package/dist/mcp.js +6 -6
  24. package/dist/package-version.d.ts +1 -1
  25. package/dist/package-version.js +1 -1
  26. package/dist/persistence/file-store.d.ts +69 -69
  27. package/dist/persistence/file-store.js +224 -221
  28. package/dist/persistence/sqlite-request-context-store.d.ts +22 -0
  29. package/dist/persistence/sqlite-request-context-store.js +64 -0
  30. package/dist/persistence/sqlite-request-queue-store.d.ts +41 -0
  31. package/dist/persistence/sqlite-request-queue-store.js +120 -0
  32. package/dist/persistence/sqlite-store.d.ts +72 -72
  33. package/dist/persistence/sqlite-store.js +361 -361
  34. package/dist/persistence/types.d.ts +84 -84
  35. package/dist/protocol/a2a/http.js +79 -74
  36. package/dist/protocol/ag-ui/http.d.ts +7 -7
  37. package/dist/protocol/ag-ui/http.js +20 -20
  38. package/dist/resource/resource-impl.js +1 -1
  39. package/dist/runtime/adapter/compat/deepagent-compat.d.ts +2 -2
  40. package/dist/runtime/adapter/flow/invocation-flow.d.ts +6 -5
  41. package/dist/runtime/adapter/flow/invocation-flow.js +6 -5
  42. package/dist/runtime/adapter/flow/stream-runtime.d.ts +3 -3
  43. package/dist/runtime/adapter/flow/stream-runtime.js +5 -4
  44. package/dist/runtime/adapter/invocation-result.d.ts +6 -5
  45. package/dist/runtime/adapter/invocation-result.js +5 -4
  46. package/dist/runtime/adapter/middleware-assembly.js +3 -2
  47. package/dist/runtime/adapter/tool/tool-hitl.js +1 -1
  48. package/dist/runtime/adapter/upstream-configurable-keys.d.ts +2 -0
  49. package/dist/runtime/adapter/upstream-configurable-keys.js +2 -0
  50. package/dist/runtime/agent-runtime-adapter.d.ts +11 -8
  51. package/dist/runtime/agent-runtime-adapter.js +36 -32
  52. package/dist/runtime/harness/events/events.d.ts +8 -8
  53. package/dist/runtime/harness/events/events.js +25 -19
  54. package/dist/runtime/harness/events/listener-runtime.d.ts +5 -4
  55. package/dist/runtime/harness/events/listener-runtime.js +7 -3
  56. package/dist/runtime/harness/events/runtime-event-operations.d.ts +7 -7
  57. package/dist/runtime/harness/events/runtime-event-operations.js +5 -5
  58. package/dist/runtime/harness/events/streaming.d.ts +8 -7
  59. package/dist/runtime/harness/events/streaming.js +20 -19
  60. package/dist/runtime/harness/events/timeline.js +6 -6
  61. package/dist/runtime/harness/index.d.ts +1 -1
  62. package/dist/runtime/harness/index.js +1 -1
  63. package/dist/runtime/harness/run/helpers.d.ts +14 -11
  64. package/dist/runtime/harness/run/helpers.js +10 -7
  65. package/dist/runtime/harness/run/inspection.d.ts +3 -2
  66. package/dist/runtime/harness/run/inspection.js +7 -7
  67. package/dist/runtime/harness/run/operator-overview.d.ts +2 -2
  68. package/dist/runtime/harness/run/operator-overview.js +18 -17
  69. package/dist/runtime/harness/run/queue-diagnostics.js +6 -6
  70. package/dist/runtime/harness/run/recovery.d.ts +15 -15
  71. package/dist/runtime/harness/run/recovery.js +53 -50
  72. package/dist/runtime/harness/run/resources.d.ts +2 -2
  73. package/dist/runtime/harness/run/resources.js +8 -8
  74. package/dist/runtime/harness/run/resume.d.ts +3 -3
  75. package/dist/runtime/harness/run/resume.js +4 -4
  76. package/dist/runtime/harness/run/routing.d.ts +4 -4
  77. package/dist/runtime/harness/run/routing.js +8 -8
  78. package/dist/runtime/harness/run/run-lifecycle.d.ts +12 -12
  79. package/dist/runtime/harness/run/run-lifecycle.js +26 -26
  80. package/dist/runtime/harness/run/run-operations.d.ts +45 -45
  81. package/dist/runtime/harness/run/run-operations.js +79 -78
  82. package/dist/runtime/harness/run/run-queue.d.ts +8 -8
  83. package/dist/runtime/harness/run/run-queue.js +16 -16
  84. package/dist/runtime/harness/run/run-slot-acquisition.d.ts +32 -32
  85. package/dist/runtime/harness/run/run-slot-acquisition.js +41 -41
  86. package/dist/runtime/harness/run/{thread-records.d.ts → session-records.d.ts} +6 -13
  87. package/dist/runtime/harness/run/{thread-records.js → session-records.js} +14 -60
  88. package/dist/runtime/harness/run/start-run.d.ts +36 -36
  89. package/dist/runtime/harness/run/start-run.js +55 -36
  90. package/dist/runtime/harness/run/startup-runtime.d.ts +9 -9
  91. package/dist/runtime/harness/run/startup-runtime.js +22 -20
  92. package/dist/runtime/harness/run/stream-run.d.ts +18 -18
  93. package/dist/runtime/harness/run/stream-run.js +52 -52
  94. package/dist/runtime/harness/runtime-defaults.d.ts +2 -2
  95. package/dist/runtime/harness/runtime-defaults.js +7 -7
  96. package/dist/runtime/harness/system/health-monitor.d.ts +3 -3
  97. package/dist/runtime/harness/system/health-monitor.js +18 -18
  98. package/dist/runtime/harness/system/mem0-ingestion-sync.d.ts +6 -6
  99. package/dist/runtime/harness/system/mem0-ingestion-sync.js +36 -27
  100. package/dist/runtime/harness/system/runtime-memory-candidates.js +2 -2
  101. package/dist/runtime/harness/system/runtime-memory-manager.d.ts +13 -13
  102. package/dist/runtime/harness/system/runtime-memory-manager.js +41 -38
  103. package/dist/runtime/harness/system/runtime-memory-policy.d.ts +1 -1
  104. package/dist/runtime/harness/system/runtime-memory-policy.js +1 -1
  105. package/dist/runtime/harness/system/runtime-memory-records.d.ts +4 -2
  106. package/dist/runtime/harness/system/runtime-memory-records.js +21 -8
  107. package/dist/runtime/harness/system/runtime-memory-sync.d.ts +6 -6
  108. package/dist/runtime/harness/system/runtime-memory-sync.js +47 -44
  109. package/dist/runtime/harness/system/{thread-memory-sync.d.ts → session-memory-sync.d.ts} +7 -7
  110. package/dist/runtime/harness/system/{thread-memory-sync.js → session-memory-sync.js} +28 -28
  111. package/dist/runtime/harness.d.ts +33 -45
  112. package/dist/runtime/harness.js +273 -291
  113. package/dist/runtime/maintenance/checkpoint-maintenance.js +2 -2
  114. package/dist/runtime/maintenance/file-checkpoint-saver.d.ts +1 -1
  115. package/dist/runtime/maintenance/file-checkpoint-saver.js +6 -6
  116. package/dist/runtime/maintenance/runtime-record-maintenance.d.ts +1 -1
  117. package/dist/runtime/maintenance/runtime-record-maintenance.js +33 -33
  118. package/dist/runtime/maintenance/sqlite-checkpoint-saver.d.ts +1 -1
  119. package/dist/runtime/maintenance/sqlite-checkpoint-saver.js +30 -10
  120. package/dist/runtime/support/harness-support.d.ts +2 -2
  121. package/dist/runtime/support/harness-support.js +7 -7
  122. package/dist/runtime/support/runtime-adapter-options.d.ts +2 -2
  123. package/dist/runtime/support/runtime-adapter-options.js +3 -3
  124. package/dist/runtime/support/runtime-factories.d.ts +2 -2
  125. package/dist/runtime/support/runtime-factories.js +10 -10
  126. package/dist/workspace/agent-binding-compiler.js +3 -3
  127. package/dist/workspace/object-loader.js +1 -1
  128. package/dist/workspace/support/workspace-ref-utils.d.ts +4 -3
  129. package/dist/workspace/support/workspace-ref-utils.js +5 -4
  130. package/package.json +1 -1
  131. package/dist/persistence/sqlite-run-context-store.d.ts +0 -22
  132. package/dist/persistence/sqlite-run-context-store.js +0 -64
  133. package/dist/persistence/sqlite-run-queue-store.d.ts +0 -41
  134. package/dist/persistence/sqlite-run-queue-store.js +0 -120
@@ -28,20 +28,7 @@ function extractUpstreamEventEnvelope(value) {
28
28
  };
29
29
  }
30
30
  function normalizeRuntimeEventType(eventType) {
31
- switch (eventType) {
32
- case "request.created":
33
- return "run.created";
34
- case "request.queued":
35
- return "run.queued";
36
- case "request.dequeued":
37
- return "run.dequeued";
38
- case "request.state.changed":
39
- return "run.state.changed";
40
- case "request.resumed":
41
- return "run.resumed";
42
- default:
43
- return eventType;
44
- }
31
+ return eventType;
45
32
  }
46
33
  function normalizeRuntimeEvents(events) {
47
34
  return events.map((event) => {
@@ -133,15 +120,15 @@ function deriveStatusFromProjection(projection) {
133
120
  return projection.category === "approval" && projection.status === "started" ? "waiting" : projection.status;
134
121
  }
135
122
  function deriveRuntimeNode(input) {
136
- if (input.eventType === "run.created") {
123
+ if (input.eventType === "request.created") {
137
124
  return {
138
- kind: "run",
125
+ kind: "request",
139
126
  status: "started",
140
- label: "Run created",
127
+ label: "Request created",
141
128
  detail: input.payload,
142
129
  };
143
130
  }
144
- if (input.eventType === "run.queued") {
131
+ if (input.eventType === "request.queued") {
145
132
  return {
146
133
  kind: "queue",
147
134
  status: "waiting",
@@ -149,7 +136,7 @@ function deriveRuntimeNode(input) {
149
136
  detail: input.payload,
150
137
  };
151
138
  }
152
- if (input.eventType === "run.dequeued") {
139
+ if (input.eventType === "request.dequeued") {
153
140
  return {
154
141
  kind: "queue",
155
142
  status: "completed",
@@ -173,11 +160,11 @@ function deriveRuntimeNode(input) {
173
160
  detail: input.payload,
174
161
  };
175
162
  }
176
- if (input.eventType === "run.resumed") {
163
+ if (input.eventType === "request.resumed") {
177
164
  return {
178
165
  kind: "recovery",
179
166
  status: "completed",
180
- label: "Run resumed",
167
+ label: "Request resumed",
181
168
  detail: input.payload,
182
169
  };
183
170
  }
@@ -189,7 +176,7 @@ function deriveRuntimeNode(input) {
189
176
  detail: input.payload,
190
177
  };
191
178
  }
192
- if (input.eventType === "run.state.changed") {
179
+ if (input.eventType === "request.state.changed") {
193
180
  const state = typeof input.payload.state === "string" ? input.payload.state : "";
194
181
  if (state === "waiting_for_approval") {
195
182
  return {
@@ -201,24 +188,24 @@ function deriveRuntimeNode(input) {
201
188
  }
202
189
  if (state === "failed") {
203
190
  return {
204
- kind: "run",
191
+ kind: "request",
205
192
  status: "failed",
206
- label: "Run failed",
193
+ label: "Request failed",
207
194
  detail: input.payload,
208
195
  };
209
196
  }
210
197
  if (state === "completed") {
211
198
  return {
212
- kind: "run",
199
+ kind: "request",
213
200
  status: "completed",
214
- label: "Run completed",
201
+ label: "Request completed",
215
202
  detail: input.payload,
216
203
  };
217
204
  }
218
205
  return {
219
- kind: "run",
206
+ kind: "request",
220
207
  status: "started",
221
- label: state ? `Run ${state}` : "Run state changed",
208
+ label: state ? `Request ${state}` : "Request state changed",
222
209
  detail: input.payload,
223
210
  };
224
211
  }
@@ -259,7 +246,7 @@ function buildRuntimeNodes(timeline) {
259
246
  if (previousNode) {
260
247
  const kind = item.eventType === "approval.resolved"
261
248
  ? "approval"
262
- : item.eventType === "run.resumed"
249
+ : item.eventType === "request.resumed"
263
250
  ? "resume"
264
251
  : "sequence";
265
252
  edges.push({
@@ -272,14 +259,14 @@ function buildRuntimeNodes(timeline) {
272
259
  });
273
260
  }
274
261
  previousNode = node;
275
- if (item.eventType === "run.created" || item.eventType === "run.dequeued" || item.eventType === "run.resumed") {
262
+ if (item.eventType === "request.created" || item.eventType === "request.dequeued" || item.eventType === "request.resumed") {
276
263
  segmentOrdinal += 1;
277
264
  activeExecutionGroup = {
278
265
  id: `group:${item.requestId}:segment:${segmentOrdinal}`,
279
266
  kind: "segment",
280
- label: item.eventType === "run.created"
267
+ label: item.eventType === "request.created"
281
268
  ? `Execution segment ${segmentOrdinal}`
282
- : item.eventType === "run.resumed"
269
+ : item.eventType === "request.resumed"
283
270
  ? `Resumed segment ${segmentOrdinal}`
284
271
  : `Dequeued segment ${segmentOrdinal}`,
285
272
  nodeIds: [node.id],
@@ -915,7 +902,7 @@ export function buildFlowGraph(input) {
915
902
  }));
916
903
  return {
917
904
  graphId: `${sessionId}/${requestId}`,
918
- scope: input.scope ?? "run",
905
+ scope: input.scope === "session" || input.scope === "request" ? input.scope : "request",
919
906
  sessionId,
920
907
  requestId,
921
908
  nodes: [...runtimeNodes, ...attemptNodes],
@@ -122,7 +122,7 @@ function selectNodes(graph, options) {
122
122
  if (includedKinds) {
123
123
  return includedKinds.has(node.kind);
124
124
  }
125
- return node.kind === "run"
125
+ return node.kind === "request"
126
126
  || node.kind === "agent"
127
127
  || node.kind === "approval"
128
128
  || node.kind === "recovery"
@@ -150,7 +150,7 @@ function getParticipantsForNode(node) {
150
150
  alias: sanitizeAlias(`Agent_${node.agentId ?? "agent"}`),
151
151
  label: formatAgentParticipantLabel(node),
152
152
  };
153
- if (node.kind === "run") {
153
+ if (node.kind === "request") {
154
154
  return [
155
155
  { id: "user", alias: "User", label: "User" },
156
156
  runtimeParticipant,
@@ -219,10 +219,10 @@ function getParticipantsForNode(node) {
219
219
  return [runtimeParticipant, agentParticipant];
220
220
  }
221
221
  function renderArrowForNode(node) {
222
- if (node.kind === "run" && node.status === "started") {
222
+ if (node.kind === "request" && node.status === "started") {
223
223
  return { from: "User", to: "Runtime", text: node.label };
224
224
  }
225
- if (node.kind === "run" && (node.status === "completed" || node.status === "failed")) {
225
+ if (node.kind === "request" && (node.status === "completed" || node.status === "failed")) {
226
226
  return { from: "Runtime", to: "User", text: node.label };
227
227
  }
228
228
  if (node.kind === "agent") {
@@ -11,7 +11,7 @@ export type BuildFlowGraphRuntimeEvent = HarnessEvent | {
11
11
  payload: Record<string, unknown>;
12
12
  };
13
13
  export type FlowNodeLayer = "runtime" | "execution" | "attempt" | "detail";
14
- export type FlowNodeKind = "run" | "agent" | "queue" | "approval" | "recovery" | "artifact" | "llm" | "tool" | "skill" | "memory" | "chain" | "result" | "thinking" | "other";
14
+ export type FlowNodeKind = "request" | "agent" | "queue" | "approval" | "recovery" | "artifact" | "llm" | "tool" | "skill" | "memory" | "chain" | "result" | "thinking" | "other";
15
15
  export type FlowNodeStatus = "pending" | "started" | "completed" | "failed" | "waiting" | "resolved" | "skipped";
16
16
  export type FlowEdgeKind = "sequence" | "contains" | "approval" | "resume" | "retry" | "fallback" | "result" | "spawn";
17
17
  export type FlowGroupKind = "segment" | "approval-window" | "attempt-set" | "agent-scope";
@@ -54,7 +54,7 @@ export type FlowGroup = {
54
54
  };
55
55
  export type FlowGraph = {
56
56
  graphId: string;
57
- scope: "run" | "thread";
57
+ scope: "request" | "session";
58
58
  sessionId: string;
59
59
  requestId: string;
60
60
  nodes: FlowNode[];
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- export { AgentHarnessAcpServer, AgentHarnessRuntime, cancelRun, createAgentHarness, createAcpServer, createAcpStdioClient, createRuntimeMcpServer, createUpstreamTimelineReducer, createToolMcpServer, deleteSession, describeInventory, exportEvaluationBundle, exportFlow, exportSequence, exportRequestPackage, exportSessionPackage, replayEvaluationBundle, getArtifact, getAgent, getApproval, getOperatorOverview, getRequest, getHealth, listMemories, listRequestTraceItems, getSession, listAgentSkills, listArtifacts, listApprovals, listRequests, listRequestEvents, listSessionSummaries, listSessions, memorize, normalizeUserChatInput, recordArtifact, request, recall, removeMemory, resolveApproval, serveA2aHttp, serveAcpHttp, serveAcpStdio, serveAgUiHttp, serveRuntimeMcpOverStdio, serveToolsOverStdio, subscribe, stop, updateMemory, } from "./api.js";
1
+ export { AgentHarnessAcpServer, AgentHarnessRuntime, cancelRequest, createAgentHarness, createAcpServer, createAcpStdioClient, createRuntimeMcpServer, createUpstreamTimelineReducer, createToolMcpServer, deleteSession, describeInventory, exportEvaluationBundle, exportFlow, exportSequence, exportRequestPackage, exportSessionPackage, replayEvaluationBundle, getArtifact, getAgent, getApproval, getOperatorOverview, getRequest, getHealth, listMemories, listRequestTraceItems, getSession, listAgentSkills, listRequestArtifacts, listApprovals, listRequests, listRequestEvents, listSessionSummaries, listSessions, memorize, normalizeUserChatInput, recordArtifact, request, recall, removeMemory, resolveApproval, serveA2aHttp, serveAcpHttp, serveAcpStdio, serveAgUiHttp, serveRuntimeMcpOverStdio, serveToolsOverStdio, subscribe, stop, updateMemory, } from "./api.js";
2
2
  export { createKnowledgeModule, readKnowledgeRuntimeConfig } from "./knowledge/index.js";
3
- export type { AcpApproval, AcpArtifact, AcpEventNotification, AcpJsonRpcError, AcpJsonRpcRequest, AcpJsonRpcResponse, AcpJsonRpcSuccess, AcpRequestRecord, AcpRunRequestParams, AcpServerCapabilities, AcpSessionRecord, AcpStdioClient, AcpStdioClientOptions, } from "./acp.js";
4
- export type { Approval, ListMemoriesInput, ListMemoriesResult, MemoryDecision, MemoryKind, MemoryRecord, MemoryScope, MemorizeInput, MemorizeResult, NormalizeUserChatInputOptions, OperatorOverview, PublicRunListeners, RecordArtifactInput, RequestArtifactListing, RequestEvent, RequestEventType, RequestPackage, RequestPackageInput, RequestFlowGraphInput, RequestResult, RequestTraceItem, RecallInput, RecallResult, RemoveMemoryInput, RuntimeEvaluationExport, RuntimeEvaluationExportInput, RuntimeEvaluationReplayInput, RuntimeEvaluationReplayResult, SessionListSummary, RuntimeSessionPackage, RuntimeSessionPackageInput, UpdateMemoryInput, UserChatInput, UserChatMessage, } from "./api.js";
3
+ export type { AcpApproval, AcpArtifact, AcpEventNotification, AcpJsonRpcError, AcpJsonRpcRequest, AcpJsonRpcResponse, AcpJsonRpcSuccess, AcpRequestRecord, AcpRequestParams, AcpServerCapabilities, AcpSessionRecord, AcpStdioClient, AcpStdioClientOptions, } from "./acp.js";
4
+ export type { Approval, ListMemoriesInput, ListMemoriesResult, MemoryDecision, MemoryKind, MemoryRecord, MemoryScope, MemorizeInput, MemorizeResult, NormalizeUserChatInputOptions, OperatorOverview, RecordArtifactInput, PublicRequestListeners, RequestArtifactListing, RequestEvent, RequestEventType, RequestPackage, RequestPackageInput, RequestFlowGraphInput, RequestResult, RequestTraceItem, RecallInput, RecallResult, RemoveMemoryInput, RuntimeEvaluationExport, RuntimeEvaluationExportInput, RuntimeEvaluationReplayInput, RuntimeEvaluationReplayResult, SessionListSummary, RuntimeSessionPackage, RuntimeSessionPackageInput, UpdateMemoryInput, UserChatInput, UserChatMessage, } from "./api.js";
5
5
  export type { KnowledgeListInput, KnowledgeMemorizeInput, KnowledgeModule, KnowledgeModuleDependencies, KnowledgeRecallInput, KnowledgeRuntimeConfig, KnowledgeRuntimeContext, } from "./knowledge/index.js";
6
- export type { A2aAgentCard, A2aHttpServer, A2aHttpServerOptions, A2aTask, A2aTaskState, AcpHttpServer, AcpHttpServerOptions, AcpStdioServer, AcpStdioServerOptions, AgUiEvent, AgUiHttpServer, AgUiHttpServerOptions, AgUiRunAgentInput, } from "./api.js";
6
+ export type { A2aAgentCard, A2aHttpServer, A2aHttpServerOptions, A2aTask, A2aTaskState, AcpHttpServer, AcpHttpServerOptions, AcpStdioServer, AcpStdioServerOptions, AgUiEvent, AgUiHttpServer, AgUiHttpServerOptions, AgUiRequestAgentInput, } from "./api.js";
7
7
  export type { RuntimeMcpServerOptions, ToolMcpServerOptions } from "./mcp.js";
8
8
  export { tool } from "./tools.js";
9
9
  export type { UpstreamTimelineProjection, UpstreamTimelineReducer } from "./upstream-events.js";
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { AgentHarnessAcpServer, AgentHarnessRuntime, cancelRun, createAgentHarness, createAcpServer, createAcpStdioClient, createRuntimeMcpServer, createUpstreamTimelineReducer, createToolMcpServer, deleteSession, describeInventory, exportEvaluationBundle, exportFlow, exportSequence, exportRequestPackage, exportSessionPackage, replayEvaluationBundle, getArtifact, getAgent, getApproval, getOperatorOverview, getRequest, getHealth, listMemories, listRequestTraceItems, getSession, listAgentSkills, listArtifacts, listApprovals, listRequests, listRequestEvents, listSessionSummaries, listSessions, memorize, normalizeUserChatInput, recordArtifact, request, recall, removeMemory, resolveApproval, serveA2aHttp, serveAcpHttp, serveAcpStdio, serveAgUiHttp, serveRuntimeMcpOverStdio, serveToolsOverStdio, subscribe, stop, updateMemory, } from "./api.js";
1
+ export { AgentHarnessAcpServer, AgentHarnessRuntime, cancelRequest, createAgentHarness, createAcpServer, createAcpStdioClient, createRuntimeMcpServer, createUpstreamTimelineReducer, createToolMcpServer, deleteSession, describeInventory, exportEvaluationBundle, exportFlow, exportSequence, exportRequestPackage, exportSessionPackage, replayEvaluationBundle, getArtifact, getAgent, getApproval, getOperatorOverview, getRequest, getHealth, listMemories, listRequestTraceItems, getSession, listAgentSkills, listRequestArtifacts, listApprovals, listRequests, listRequestEvents, listSessionSummaries, listSessions, memorize, normalizeUserChatInput, recordArtifact, request, recall, removeMemory, resolveApproval, serveA2aHttp, serveAcpHttp, serveAcpStdio, serveAgUiHttp, serveRuntimeMcpOverStdio, serveToolsOverStdio, subscribe, stop, updateMemory, } from "./api.js";
2
2
  export { createKnowledgeModule, readKnowledgeRuntimeConfig } from "./knowledge/index.js";
3
3
  export { tool } from "./tools.js";
@@ -169,7 +169,7 @@ spec:
169
169
  ingestion:
170
170
  backgroundConsolidation: true
171
171
  writeOnApprovalResolution: true
172
- writeOnRunCompletion: true
172
+ writeOnRequestCompletion: true
173
173
  formation:
174
174
  hotPath:
175
175
  enabled: true
@@ -180,19 +180,19 @@ spec:
180
180
  background:
181
181
  enabled: true
182
182
  scopes:
183
- - thread
183
+ - session
184
184
  stateStorePath: knowledge/formation-state.json
185
- maxMessagesPerRun: 40
185
+ maxMessagesPerRequest: 40
186
186
  writeOnApprovalResolution: true
187
- writeOnRunCompletion: true
188
- threadMemorySync:
187
+ writeOnRequestCompletion: true
188
+ sessionMemorySync:
189
189
  enabled: true
190
190
  mem0:
191
191
  enabled: false
192
192
  apiKeyEnv: MEM0_API_KEY
193
193
  appId: ${projectSlug}
194
194
  stateStorePath: knowledge/mem0-sync-state.json
195
- maxMessagesPerRun: 200
195
+ maxMessagesPerRequest: 200
196
196
  `;
197
197
  }
198
198
  function renderKnowledgeRuntimeYaml(projectSlug) {
@@ -224,17 +224,17 @@ spec:
224
224
  background:
225
225
  enabled: true
226
226
  scopes:
227
- - thread
227
+ - session
228
228
  stateStorePath: knowledge/formation-state.json
229
- maxMessagesPerRun: 40
229
+ maxMessagesPerRequest: 40
230
230
  writeOnApprovalResolution: true
231
- writeOnRunCompletion: true
231
+ writeOnRequestCompletion: true
232
232
  mem0:
233
233
  enabled: false
234
234
  apiKeyEnv: MEM0_API_KEY
235
235
  appId: ${projectSlug}
236
236
  stateStorePath: knowledge/mem0-sync-state.json
237
- maxMessagesPerRun: 200
237
+ maxMessagesPerRequest: 200
238
238
  `;
239
239
  }
240
240
  function renderToolsYaml(options) {
@@ -3,9 +3,9 @@ import { findMemoryRecordById, getMemoryRecord, listMemoryRecordsForScopes, pers
3
3
  import { consolidateStructuredMemoryScope } from "../runtime/harness/system/runtime-memory-consolidation.js";
4
4
  import { renderMemoryCandidatesMarkdown } from "../runtime/harness/system/runtime-memory-candidates.js";
5
5
  import { normalizeLangMemMemoryKind, scoreMemoryText, } from "../runtime/harness/system/runtime-memory-policy.js";
6
- const ALL_SCOPES = ["thread", "agent", "workspace", "user", "project"];
6
+ const ALL_SCOPES = ["session", "agent", "workspace", "user", "project"];
7
7
  const TITLE_BY_SCOPE = {
8
- thread: "Thread Structured Memory",
8
+ session: "Session Structured Memory",
9
9
  agent: "Agent Structured Memory",
10
10
  workspace: "Workspace Structured Memory",
11
11
  user: "User Structured Memory",
@@ -29,7 +29,7 @@ function resolveRecallScopes(input, context) {
29
29
  if (Array.isArray(input.scopes) && input.scopes.length > 0) {
30
30
  return Array.from(new Set(input.scopes));
31
31
  }
32
- const scopes = new Set(["thread", "agent", "workspace"]);
32
+ const scopes = new Set(["session", "agent", "workspace"]);
33
33
  if (context.userId) {
34
34
  scopes.add("user");
35
35
  }
@@ -39,8 +39,8 @@ function resolveRecallScopes(input, context) {
39
39
  return Array.from(scopes);
40
40
  }
41
41
  function matchesMemoryFilters(record, filters) {
42
- const sessionId = String(record.provenance.sessionId ?? record.provenance.threadId ?? "");
43
- if (filters.threadId && sessionId !== filters.threadId) {
42
+ const sessionId = String(record.provenance.sessionId ?? "");
43
+ if (filters.sessionId && sessionId !== filters.sessionId) {
44
44
  return false;
45
45
  }
46
46
  if (filters.agentId && record.provenance.agentId !== filters.agentId) {
@@ -58,9 +58,9 @@ function matchesMemoryFilters(record, filters) {
58
58
  return true;
59
59
  }
60
60
  function matchesRecallScope(record, filters) {
61
- if (record.scope === "thread") {
62
- return typeof filters.threadId === "string"
63
- && String(record.provenance.sessionId ?? record.provenance.threadId ?? "") === filters.threadId;
61
+ if (record.scope === "session") {
62
+ return typeof filters.sessionId === "string"
63
+ && String(record.provenance.sessionId ?? "") === filters.sessionId;
64
64
  }
65
65
  if (record.scope === "agent") {
66
66
  return String(record.provenance.agentId ?? "") === filters.agentId;
@@ -74,7 +74,7 @@ function matchesRecallScope(record, filters) {
74
74
  return String(record.provenance.projectId ?? filters.workspaceId) === filters.projectId;
75
75
  }
76
76
  function getMemoryScopeBoost(scope) {
77
- if (scope === "thread") {
77
+ if (scope === "session") {
78
78
  return 4;
79
79
  }
80
80
  if (scope === "agent") {
@@ -112,11 +112,11 @@ function inferMem0MemoryKind(hit) {
112
112
  }
113
113
  function inferMem0MemoryScope(hit, filters) {
114
114
  const metadataScope = typeof hit.metadata.scope === "string" ? hit.metadata.scope : undefined;
115
- if (metadataScope === "thread" || metadataScope === "agent" || metadataScope === "workspace" || metadataScope === "user" || metadataScope === "project") {
115
+ if (metadataScope === "session" || metadataScope === "agent" || metadataScope === "workspace" || metadataScope === "user" || metadataScope === "project") {
116
116
  return metadataScope;
117
117
  }
118
- if (typeof hit.metadata.threadId === "string" && filters.threadId && hit.metadata.threadId === filters.threadId) {
119
- return "thread";
118
+ if (typeof hit.metadata.sessionId === "string" && filters.sessionId && hit.metadata.sessionId === filters.sessionId) {
119
+ return "session";
120
120
  }
121
121
  if (hit.agentId === filters.agentId || hit.metadata.agentId === filters.agentId) {
122
122
  return "agent";
@@ -144,16 +144,8 @@ function createMem0MemoryRecord(hit, filters) {
144
144
  tags: hit.categories,
145
145
  provenance: {
146
146
  source: "mem0",
147
- sessionId: typeof hit.metadata.sessionId === "string"
148
- ? hit.metadata.sessionId
149
- : typeof hit.metadata.threadId === "string"
150
- ? hit.metadata.threadId
151
- : filters.threadId,
152
- requestId: (typeof hit.metadata.requestId === "string"
153
- ? hit.metadata.requestId
154
- : typeof hit.metadata.runId === "string"
155
- ? hit.metadata.runId
156
- : undefined),
147
+ sessionId: typeof hit.metadata.sessionId === "string" ? hit.metadata.sessionId : filters.sessionId,
148
+ requestId: typeof hit.metadata.requestId === "string" ? hit.metadata.requestId : undefined,
157
149
  agentId: hit.agentId ?? (typeof hit.metadata.agentId === "string" ? hit.metadata.agentId : filters.agentId),
158
150
  workspaceId: filters.workspaceId,
159
151
  userId: filters.userId,
@@ -184,8 +176,8 @@ export class DefaultKnowledgeModule {
184
176
  if (candidates.some((record) => typeof record.content !== "string" || record.content.trim().length === 0)) {
185
177
  throw new Error("memorize requires every record to include non-empty content.");
186
178
  }
187
- if (candidates.some((record) => (record.scope ?? "thread") === "thread") && !normalizedContext.sessionId) {
188
- throw new Error("memorize requires sessionId when storing thread-scoped memory.");
179
+ if (candidates.some((record) => (record.scope ?? "session") === "session") && !normalizedContext.sessionId) {
180
+ throw new Error("memorize requires sessionId when storing session-scoped memory.");
189
181
  }
190
182
  const recordedAt = normalizedContext.recordedAt ?? new Date().toISOString();
191
183
  const requestId = normalizedContext.requestId ?? createPersistentId(new Date(recordedAt));
@@ -230,7 +222,7 @@ export class DefaultKnowledgeModule {
230
222
  context: normalizedContext,
231
223
  }))
232
224
  .map((item) => {
233
- const scopeBoost = item.record.scope === "thread"
225
+ const scopeBoost = item.record.scope === "session"
234
226
  ? 4
235
227
  : item.record.scope === "agent"
236
228
  ? 3
@@ -274,7 +266,7 @@ export class DefaultKnowledgeModule {
274
266
  .filter((record) => statuses.has(record.status))
275
267
  .filter((record) => !kinds || kinds.has(record.kind))
276
268
  .filter((record) => matchesMemoryFilters(record, {
277
- threadId: normalizedContext.sessionId,
269
+ sessionId: normalizedContext.sessionId,
278
270
  agentId: normalizedContext.agentId,
279
271
  workspaceId: normalizedContext.workspaceId,
280
272
  userId: normalizedContext.userId,
@@ -353,8 +345,8 @@ export class DefaultKnowledgeModule {
353
345
  : validCandidates;
354
346
  if (options.storeCandidateLog) {
355
347
  await this.deps.store.put(["memories", "candidates", normalizedContext.sessionId ?? `memory-api-${normalizedContext.requestId ?? "unknown"}`], `${normalizedContext.requestId}.json`, {
356
- runId: normalizedContext.requestId,
357
- threadId: normalizedContext.sessionId,
348
+ requestId: normalizedContext.requestId,
349
+ sessionId: normalizedContext.sessionId,
358
350
  storedAt: normalizedContext.recordedAt,
359
351
  candidates: transformedCandidates,
360
352
  });
@@ -362,8 +354,8 @@ export class DefaultKnowledgeModule {
362
354
  const persisted = await persistStructuredMemoryRecords({
363
355
  store: this.deps.store,
364
356
  candidates: transformedCandidates,
365
- threadId: normalizedContext.sessionId ?? `memory-api-${normalizedContext.requestId ?? "unknown"}`,
366
- runId: normalizedContext.requestId ?? createPersistentId(new Date(normalizedContext.recordedAt ?? new Date().toISOString())),
357
+ sessionId: normalizedContext.sessionId ?? `memory-api-${normalizedContext.requestId ?? "unknown"}`,
358
+ requestId: normalizedContext.requestId ?? createPersistentId(new Date(normalizedContext.recordedAt ?? new Date().toISOString())),
367
359
  agentId: normalizedContext.agentId,
368
360
  workspaceId: normalizedContext.workspaceId,
369
361
  userId: normalizedContext.userId ?? "default",
@@ -376,18 +368,18 @@ export class DefaultKnowledgeModule {
376
368
  }
377
369
  async refreshAfterWrite(candidates, context) {
378
370
  const buckets = {
379
- thread: candidates.filter((candidate) => (candidate.scope ?? "thread") === "thread"),
380
- agent: candidates.filter((candidate) => (candidate.scope ?? "thread") === "agent"),
381
- workspace: candidates.filter((candidate) => (candidate.scope ?? "thread") === "workspace"),
382
- user: candidates.filter((candidate) => (candidate.scope ?? "thread") === "user"),
383
- project: candidates.filter((candidate) => (candidate.scope ?? "thread") === "project"),
371
+ session: candidates.filter((candidate) => (candidate.scope ?? "session") === "session"),
372
+ agent: candidates.filter((candidate) => (candidate.scope ?? "session") === "agent"),
373
+ workspace: candidates.filter((candidate) => (candidate.scope ?? "session") === "workspace"),
374
+ user: candidates.filter((candidate) => (candidate.scope ?? "session") === "user"),
375
+ project: candidates.filter((candidate) => (candidate.scope ?? "session") === "project"),
384
376
  };
385
377
  const writes = [];
386
378
  for (const scope of ALL_SCOPES) {
387
379
  if (buckets[scope].length === 0) {
388
380
  continue;
389
381
  }
390
- const maxEntries = scope === "thread" ? 12 : 20;
382
+ const maxEntries = scope === "session" ? 12 : 20;
391
383
  writes.push(this.appendMemoryDigest(this.deps.resolveNamespace(scope, context), "tool-memory.md", buckets[scope], maxEntries, TITLE_BY_SCOPE[scope].replace("Structured", "Tool")));
392
384
  writes.push(consolidateStructuredMemoryScope({
393
385
  store: this.deps.store,
@@ -407,7 +399,7 @@ export class DefaultKnowledgeModule {
407
399
  : [];
408
400
  const merged = [...existingItems];
409
401
  for (const candidate of candidates) {
410
- if (merged.some((entry) => entry.content === candidate.content && (entry.scope ?? "thread") === (candidate.scope ?? "thread"))) {
402
+ if (merged.some((entry) => entry.content === candidate.content && (entry.scope ?? "session") === (candidate.scope ?? "session"))) {
411
403
  continue;
412
404
  }
413
405
  merged.push(candidate);
@@ -440,7 +432,7 @@ export class DefaultKnowledgeModule {
440
432
  userId: provenance.userId ?? context.userId,
441
433
  projectId: provenance.projectId ?? context.projectId,
442
434
  };
443
- const maxEntries = record.scope === "thread" ? 12 : 20;
435
+ const maxEntries = record.scope === "session" ? 12 : 20;
444
436
  await consolidateStructuredMemoryScope({
445
437
  store: this.deps.store,
446
438
  namespace: this.deps.resolveNamespace(record.scope, normalizeRuntimeContext(namespaceContext)),
@@ -469,7 +461,7 @@ export class DefaultKnowledgeModule {
469
461
  scope: record.scope,
470
462
  kind: record.kind,
471
463
  status: record.status,
472
- sessionId: record.provenance.sessionId ?? record.provenance.threadId,
464
+ sessionId: record.provenance.sessionId,
473
465
  agentId: record.provenance.agentId,
474
466
  workspaceId: record.provenance.workspaceId,
475
467
  userId: record.provenance.userId,
@@ -487,7 +479,7 @@ export class DefaultKnowledgeModule {
487
479
  const structuredRecords = await listMemoryRecordsForScopes(this.deps.store, input.scopes);
488
480
  const ranked = structuredRecords
489
481
  .filter((record) => matchesRecallScope(record, {
490
- threadId: input.context.sessionId,
482
+ sessionId: input.context.sessionId,
491
483
  agentId: input.context.agentId,
492
484
  workspaceId: input.context.workspaceId,
493
485
  userId: input.context.userId ?? "default",
@@ -513,7 +505,7 @@ export class DefaultKnowledgeModule {
513
505
  : {};
514
506
  const recordId = typeof metadata.recordId === "string" ? metadata.recordId : undefined;
515
507
  const scope = metadata.scope;
516
- if (!recordId || (scope !== "thread" && scope !== "agent" && scope !== "workspace" && scope !== "user" && scope !== "project")) {
508
+ if (!recordId || (scope !== "session" && scope !== "agent" && scope !== "workspace" && scope !== "user" && scope !== "project")) {
517
509
  continue;
518
510
  }
519
511
  const canonical = await getMemoryRecord(this.deps.store, scope, recordId);
@@ -521,7 +513,7 @@ export class DefaultKnowledgeModule {
521
513
  continue;
522
514
  }
523
515
  if (!matchesRecallScope(canonical, {
524
- threadId: input.context.sessionId,
516
+ sessionId: input.context.sessionId,
525
517
  agentId: input.context.agentId,
526
518
  workspaceId: input.context.workspaceId,
527
519
  userId: input.context.userId ?? "default",
@@ -547,7 +539,7 @@ export class DefaultKnowledgeModule {
547
539
  // Fail open to lexical/runtime ranking.
548
540
  }
549
541
  }
550
- const supportsMem0Scope = input.scopes.some((scope) => scope === "thread" || scope === "agent" || scope === "workspace");
542
+ const supportsMem0Scope = input.scopes.some((scope) => scope === "session" || scope === "agent" || scope === "workspace");
551
543
  const mem0SemanticRecall = this.deps.getMem0SemanticRecall?.() ?? null;
552
544
  if (!mem0SemanticRecall || !supportsMem0Scope) {
553
545
  return Array.from(deduped.values()).sort((left, right) => right.score - left.score);
@@ -557,11 +549,11 @@ export class DefaultKnowledgeModule {
557
549
  query: input.query,
558
550
  topK: Math.max(input.topK, this.deps.policy?.retrieval.maxPromptMemories ?? input.topK),
559
551
  agentId: input.context.agentId,
560
- threadId: input.context.sessionId,
552
+ sessionId: input.context.sessionId,
561
553
  });
562
554
  for (const hit of hits) {
563
555
  const record = createMem0MemoryRecord(hit, {
564
- threadId: input.context.sessionId,
556
+ sessionId: input.context.sessionId,
565
557
  agentId: input.context.agentId,
566
558
  workspaceId: input.context.workspaceId,
567
559
  userId: input.context.userId ?? "default",
package/dist/mcp.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
- import type { ApprovalRecord, ArtifactListing, CompiledTool, HarnessEvent, ParsedToolObject, RequestRecord, RunResult, RunState, RequestSummary, RuntimeSessionPackage, RuntimeSessionPackageInput, SessionRecord, SessionSummary } from "./contracts/types.js";
2
+ import type { ApprovalRecord, ArtifactListing, CompiledTool, HarnessEvent, ParsedToolObject, RequestRecord, RequestResult, RequestState, RequestSummary, RuntimeSessionPackage, RuntimeSessionPackageInput, SessionRecord, SessionSummary } from "./contracts/types.js";
3
3
  export type ToolMcpServerOptions = {
4
4
  agentId: string;
5
5
  serverInfo?: {
@@ -27,24 +27,24 @@ type RuntimeMcpRuntime = {
27
27
  listRequests: (filter?: {
28
28
  agentId?: string;
29
29
  sessionId?: string;
30
- state?: RunState;
30
+ state?: RequestState;
31
31
  }) => Promise<RequestSummary[]>;
32
32
  getRequest: (requestId: string) => Promise<RequestRecord | null>;
33
33
  listApprovals: (filter?: {
34
34
  status?: ApprovalRecord["status"];
35
- threadId?: string;
36
- runId?: string;
35
+ sessionId?: string;
36
+ requestId?: string;
37
37
  }) => Promise<ApprovalRecord[]>;
38
38
  getApproval: (approvalId: string) => Promise<ApprovalRecord | null>;
39
39
  resume: (options: {
40
40
  approvalId?: string;
41
- threadId?: string;
42
- runId?: string;
41
+ sessionId?: string;
42
+ requestId?: string;
43
43
  decision?: "approve" | "edit" | "reject";
44
44
  editedInput?: Record<string, unknown>;
45
- }) => Promise<RunResult>;
46
- listArtifacts: (sessionId: string, requestId: string) => Promise<ArtifactListing>;
47
- readArtifact: (sessionId: string, requestId: string, artifactPath: string) => Promise<unknown>;
45
+ }) => Promise<RequestResult>;
46
+ listRequestArtifacts: (sessionId: string, requestId: string) => Promise<ArtifactListing>;
47
+ readRequestArtifact: (sessionId: string, requestId: string, artifactPath: string) => Promise<unknown>;
48
48
  listRequestEvents: (sessionId: string, requestId: string) => Promise<HarnessEvent[]>;
49
49
  exportRequestPackage: (input: {
50
50
  sessionId: string;
package/dist/mcp.js CHANGED
@@ -162,8 +162,8 @@ export async function createRuntimeMcpServer(runtime, options = {}) {
162
162
  type: "text",
163
163
  text: renderToolOutput(await runtime.listApprovals({
164
164
  ...(input.status ? { status: input.status } : {}),
165
- ...(input.sessionId ? { threadId: input.sessionId } : {}),
166
- ...(input.requestId ? { runId: input.requestId } : {}),
165
+ ...(input.sessionId ? { sessionId: input.sessionId } : {}),
166
+ ...(input.requestId ? { requestId: input.requestId } : {}),
167
167
  })),
168
168
  }],
169
169
  }));
@@ -187,8 +187,8 @@ export async function createRuntimeMcpServer(runtime, options = {}) {
187
187
  text: renderToolOutput(await runtime.resume({
188
188
  approvalId: input.approvalId,
189
189
  decision: input.decision,
190
- ...(input.sessionId ? { threadId: input.sessionId } : {}),
191
- ...(input.requestId ? { runId: input.requestId } : {}),
190
+ ...(input.sessionId ? { sessionId: input.sessionId } : {}),
191
+ ...(input.requestId ? { requestId: input.requestId } : {}),
192
192
  ...(input.editedInput ? { editedInput: input.editedInput } : {}),
193
193
  })),
194
194
  }],
@@ -199,7 +199,7 @@ export async function createRuntimeMcpServer(runtime, options = {}) {
199
199
  }, async (input) => ({
200
200
  content: [{
201
201
  type: "text",
202
- text: renderToolOutput(await runtime.listArtifacts(input.sessionId, input.requestId)),
202
+ text: renderToolOutput(await runtime.listRequestArtifacts(input.sessionId, input.requestId)),
203
203
  }],
204
204
  }));
205
205
  server.tool("read_artifact", "Read one runtime artifact.", {
@@ -209,7 +209,7 @@ export async function createRuntimeMcpServer(runtime, options = {}) {
209
209
  }, async (input) => ({
210
210
  content: [{
211
211
  type: "text",
212
- text: renderToolOutput(await runtime.readArtifact(input.sessionId, input.requestId, input.artifactPath)),
212
+ text: renderToolOutput(await runtime.readRequestArtifact(input.sessionId, input.requestId, input.artifactPath)),
213
213
  }],
214
214
  }));
215
215
  server.tool("list_request_events", "List persisted runtime events for one request.", {
@@ -1 +1 @@
1
- export declare const AGENT_HARNESS_VERSION = "0.0.289";
1
+ export declare const AGENT_HARNESS_VERSION = "0.0.290";
@@ -1 +1 @@
1
- export const AGENT_HARNESS_VERSION = "0.0.289";
1
+ export const AGENT_HARNESS_VERSION = "0.0.290";