@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
@@ -1,7 +1,13 @@
1
1
  import { extractMessageText } from "../../../utils/message-content.js";
2
2
  import { createHarnessEvent, createPendingApproval } from "../../support/harness-support.js";
3
- export async function emitHarnessEvent(runtime, threadId, runId, sequence, eventType, payload, source = "runtime") {
4
- const event = createHarnessEvent(threadId, runId, sequence, eventType, payload, source);
3
+ async function updateInspection(persistence, sessionId, requestId, patch) {
4
+ await persistence.updateRequestInspection(sessionId, requestId, patch);
5
+ }
6
+ async function setRequestState(persistence, sessionId, requestId, state, checkpointRef) {
7
+ await persistence.setRequestState(sessionId, requestId, state, checkpointRef);
8
+ }
9
+ export async function emitHarnessEvent(runtime, sessionId, requestId, sequence, eventType, payload, source = "runtime") {
10
+ const event = createHarnessEvent(sessionId, requestId, sequence, eventType, payload, source);
5
11
  if (runtime.backgroundEventTypes.has(event.eventType)) {
6
12
  runtime.trackBackgroundTask(runtime.persistence.appendEvent(event).catch(() => {
7
13
  // Fail open for telemetry-style event persistence.
@@ -13,42 +19,42 @@ export async function emitHarnessEvent(runtime, threadId, runId, sequence, event
13
19
  runtime.publishEvent(event);
14
20
  return event;
15
21
  }
16
- export async function emitRunCreatedEvent(runtime, threadId, runId, payload) {
17
- return emitHarnessEvent(runtime, threadId, runId, 1, "run.created", payload);
22
+ export async function emitRequestCreatedEvent(runtime, sessionId, requestId, payload) {
23
+ return emitHarnessEvent(runtime, sessionId, requestId, 1, "request.created", payload);
18
24
  }
19
- export async function setRunStateAndEmitEvent(runtime, threadId, runId, sequence, state, options) {
20
- await runtime.persistence.setRunState(threadId, runId, state, options.checkpointRef ?? null);
25
+ export async function setRequestStateAndEmitEvent(runtime, sessionId, requestId, sequence, state, options) {
26
+ await setRequestState(runtime.persistence, sessionId, requestId, state, options.checkpointRef ?? null);
21
27
  const now = new Date(Date.now()).toISOString();
22
- await runtime.persistence.updateRunInspection(threadId, runId, {
28
+ await updateInspection(runtime.persistence, sessionId, requestId, {
23
29
  lastActivityAt: now,
24
30
  ...(state === "completed" || state === "failed" || state === "cancelled" ? { endedAt: now } : {}),
25
31
  });
26
- return emitHarnessEvent(runtime, threadId, runId, sequence, "run.state.changed", {
32
+ return emitHarnessEvent(runtime, sessionId, requestId, sequence, "request.state.changed", {
27
33
  previousState: options.previousState,
28
34
  state,
29
35
  checkpointRef: options.checkpointRef ?? null,
30
36
  ...(options.error ? { error: options.error } : {}),
31
37
  });
32
38
  }
33
- export async function persistApproval(runtime, threadId, runId, checkpointRef, input, interruptContent) {
34
- const approval = createPendingApproval(threadId, runId, checkpointRef, extractMessageText(input), interruptContent);
39
+ export async function persistApproval(runtime, sessionId, requestId, checkpointRef, input, interruptContent) {
40
+ const approval = createPendingApproval(sessionId, requestId, checkpointRef, extractMessageText(input), interruptContent);
35
41
  await runtime.persistence.createApproval(approval);
36
- const artifact = await runtime.persistence.createArtifact(threadId, runId, {
37
- artifactId: `artifact-approval-${runId}`,
42
+ const artifact = await runtime.persistence.createRequestArtifact(sessionId, requestId, {
43
+ artifactId: `artifact-approval-${requestId}`,
38
44
  kind: "approval-packet",
39
- path: `artifacts/approval-${runId}.json`,
45
+ path: `artifacts/approval-${requestId}.json`,
40
46
  createdAt: approval.requestedAt,
41
47
  }, approval);
42
- await emitHarnessEvent(runtime, threadId, runId, 5, "artifact.created", {
48
+ await emitHarnessEvent(runtime, sessionId, requestId, 5, "artifact.created", {
43
49
  artifactId: artifact.artifactId,
44
50
  kind: artifact.kind,
45
51
  path: artifact.path,
46
52
  });
47
53
  return approval;
48
54
  }
49
- export async function requestApprovalAndEmitEvent(runtime, threadId, runId, input, interruptContent, checkpointRef, sequence) {
50
- const approval = await persistApproval(runtime, threadId, runId, checkpointRef, input, interruptContent);
51
- const event = await emitHarnessEvent(runtime, threadId, runId, sequence, "approval.requested", {
55
+ export async function requestApprovalAndEmitEvent(runtime, sessionId, requestId, input, interruptContent, checkpointRef, sequence) {
56
+ const approval = await persistApproval(runtime, sessionId, requestId, checkpointRef, input, interruptContent);
57
+ const event = await emitHarnessEvent(runtime, sessionId, requestId, sequence, "approval.requested", {
52
58
  approvalId: approval.approvalId,
53
59
  pendingActionId: approval.pendingActionId,
54
60
  toolName: approval.toolName,
@@ -58,7 +64,7 @@ export async function requestApprovalAndEmitEvent(runtime, threadId, runId, inpu
58
64
  });
59
65
  return { approval, event };
60
66
  }
61
- export async function emitSyntheticFallbackEvent(runtime, threadId, runId, selectedAgentId, error, sequence = 3) {
67
+ export async function emitSyntheticFallbackEvent(runtime, sessionId, requestId, selectedAgentId, error, sequence = 3) {
62
68
  const payload = typeof error === "object" && error !== null && "reason" in error
63
69
  ? {
64
70
  ...error,
@@ -68,7 +74,7 @@ export async function emitSyntheticFallbackEvent(runtime, threadId, runId, selec
68
74
  reason: error instanceof Error ? error.message : String(error),
69
75
  selectedAgentId,
70
76
  };
71
- await emitHarnessEvent(runtime, threadId, runId, sequence, "runtime.synthetic_fallback", {
77
+ await emitHarnessEvent(runtime, sessionId, requestId, sequence, "runtime.synthetic_fallback", {
72
78
  ...payload,
73
79
  });
74
80
  }
@@ -1,9 +1,9 @@
1
- import type { RunListeners, RunResult } from "../../../contracts/types.js";
1
+ import type { RequestListeners, RequestResult } from "../../../contracts/types.js";
2
2
  import { type InternalHarnessStreamItem } from "./streaming.js";
3
3
  export declare function createListenerDispatchRuntime(input: {
4
4
  notifyListener: <T>(listener: ((value: T) => void | Promise<void>) | undefined, value: T) => Promise<void>;
5
- getThread: (threadId: string) => Promise<{
6
- currentState: RunResult["state"];
5
+ getSession: (sessionId: string) => Promise<{
6
+ currentState: RequestResult["state"];
7
7
  latestRequestId: string;
8
8
  entryAgentId: string;
9
9
  currentAgentId?: string;
@@ -16,5 +16,6 @@ export declare function createListenerDispatchRuntime(input: {
16
16
  };
17
17
  } | null>;
18
18
  }): {
19
- dispatchRunListeners: (stream: AsyncGenerator<InternalHarnessStreamItem>, listeners: RunListeners) => Promise<RunResult>;
19
+ dispatchRequestListeners: (stream: AsyncGenerator<InternalHarnessStreamItem>, listeners: RequestListeners) => Promise<RequestResult>;
20
+ dispatchRunListeners: (stream: AsyncGenerator<InternalHarnessStreamItem>, listeners: RequestListeners) => Promise<RequestResult>;
20
21
  };
@@ -1,9 +1,13 @@
1
- import { dispatchRunListeners as dispatchStreamingRunListeners } from "./streaming.js";
1
+ import { dispatchRequestListeners as dispatchStreamingRequestListeners } from "./streaming.js";
2
2
  export function createListenerDispatchRuntime(input) {
3
3
  return {
4
- dispatchRunListeners: (stream, listeners) => dispatchStreamingRunListeners(stream, listeners, {
4
+ dispatchRequestListeners: (stream, listeners) => dispatchStreamingRequestListeners(stream, listeners, {
5
5
  notifyListener: (listener, value) => input.notifyListener(listener, value),
6
- getThread: (threadId) => input.getThread(threadId),
6
+ getSession: (sessionId) => input.getSession(sessionId),
7
+ }),
8
+ dispatchRunListeners: (stream, listeners) => dispatchStreamingRequestListeners(stream, listeners, {
9
+ notifyListener: (listener, value) => input.notifyListener(listener, value),
10
+ getSession: (sessionId) => input.getSession(sessionId),
7
11
  }),
8
12
  };
9
13
  }
@@ -1,17 +1,17 @@
1
- import type { HarnessEvent, MessageContent, RunResult } from "../../../contracts/types.js";
2
- import { emitRunCreatedEvent } from "./events.js";
3
- type EventRuntime = Parameters<typeof emitRunCreatedEvent>[0];
1
+ import type { HarnessEvent, MessageContent, RequestResult } from "../../../contracts/types.js";
2
+ import { emitRequestCreatedEvent } from "./events.js";
3
+ type EventRuntime = Parameters<typeof emitRequestCreatedEvent>[0];
4
4
  export declare function createRuntimeEventOperations(runtime: EventRuntime): {
5
- emitRunCreated: (threadId: string, runId: string, payload: Record<string, unknown>) => Promise<HarnessEvent>;
6
- setRunStateAndEmit: (threadId: string, runId: string, sequence: number, state: RunResult["state"], options: {
5
+ emitRequestCreated: (sessionId: string, requestId: string, payload: Record<string, unknown>) => Promise<HarnessEvent>;
6
+ setRequestStateAndEmit: (sessionId: string, requestId: string, sequence: number, state: RequestResult["state"], options: {
7
7
  previousState: string | null;
8
8
  checkpointRef?: string | null;
9
9
  error?: string;
10
10
  }) => Promise<HarnessEvent>;
11
- requestApprovalAndEmit: (threadId: string, runId: string, input: MessageContent, interruptContent: string | undefined, checkpointRef: string, sequence: number) => Promise<{
11
+ requestApprovalAndEmit: (sessionId: string, requestId: string, input: MessageContent, interruptContent: string | undefined, checkpointRef: string, sequence: number) => Promise<{
12
12
  approval: import("../../../contracts/runtime.js").InternalApprovalRecord;
13
13
  event: HarnessEvent;
14
14
  }>;
15
- emitSyntheticFallback: (threadId: string, runId: string, selectedAgentId: string, error: unknown, sequence?: number) => Promise<void>;
15
+ emitSyntheticFallback: (sessionId: string, requestId: string, selectedAgentId: string, error: unknown, sequence?: number) => Promise<void>;
16
16
  };
17
17
  export {};
@@ -1,9 +1,9 @@
1
- import { emitRunCreatedEvent, emitSyntheticFallbackEvent, requestApprovalAndEmitEvent, setRunStateAndEmitEvent } from "./events.js";
1
+ import { emitRequestCreatedEvent, emitSyntheticFallbackEvent, requestApprovalAndEmitEvent, setRequestStateAndEmitEvent } from "./events.js";
2
2
  export function createRuntimeEventOperations(runtime) {
3
3
  return {
4
- emitRunCreated: (threadId, runId, payload) => emitRunCreatedEvent(runtime, threadId, runId, payload),
5
- setRunStateAndEmit: (threadId, runId, sequence, state, options) => setRunStateAndEmitEvent(runtime, threadId, runId, sequence, state, options),
6
- requestApprovalAndEmit: (threadId, runId, input, interruptContent, checkpointRef, sequence) => requestApprovalAndEmitEvent(runtime, threadId, runId, input, interruptContent, checkpointRef, sequence),
7
- emitSyntheticFallback: (threadId, runId, selectedAgentId, error, sequence) => emitSyntheticFallbackEvent(runtime, threadId, runId, selectedAgentId, error, sequence),
4
+ emitRequestCreated: (sessionId, requestId, payload) => emitRequestCreatedEvent(runtime, sessionId, requestId, payload),
5
+ setRequestStateAndEmit: (sessionId, requestId, sequence, state, options) => setRequestStateAndEmitEvent(runtime, sessionId, requestId, sequence, state, options),
6
+ requestApprovalAndEmit: (sessionId, requestId, input, interruptContent, checkpointRef, sequence) => requestApprovalAndEmitEvent(runtime, sessionId, requestId, input, interruptContent, checkpointRef, sequence),
7
+ emitSyntheticFallback: (sessionId, requestId, selectedAgentId, error, sequence) => emitSyntheticFallbackEvent(runtime, sessionId, requestId, selectedAgentId, error, sequence),
8
8
  };
9
9
  }
@@ -1,4 +1,4 @@
1
- import type { HarnessEvent, HarnessStreamItem, RunListeners, RunResult } from "../../../contracts/types.js";
1
+ import type { HarnessEvent, HarnessStreamItem, RequestListeners, RequestResult } from "../../../contracts/types.js";
2
2
  export type InternalHarnessStreamItem = HarnessStreamItem | {
3
3
  type: "content";
4
4
  sessionId: string;
@@ -20,13 +20,13 @@ export type InternalHarnessStreamItem = HarnessStreamItem | {
20
20
  output: unknown;
21
21
  isError?: boolean;
22
22
  };
23
- export declare function emitOutputDeltaAndCreateItem(emit: (threadId: string, runId: string, sequence: number, eventType: string, payload: Record<string, unknown>) => Promise<HarnessEvent>, threadId: string, runId: string, agentId: string, content: string): Promise<InternalHarnessStreamItem>;
24
- export declare function createContentBlocksItem(threadId: string, runId: string, agentId: string, contentBlocks: unknown[]): InternalHarnessStreamItem;
23
+ export declare function emitOutputDeltaAndCreateItem(emit: (sessionId: string, requestId: string, sequence: number, eventType: string, payload: Record<string, unknown>) => Promise<HarnessEvent>, sessionId: string, requestId: string, agentId: string, content: string): Promise<InternalHarnessStreamItem>;
24
+ export declare function createContentBlocksItem(sessionId: string, requestId: string, agentId: string, contentBlocks: unknown[]): InternalHarnessStreamItem;
25
25
  export declare function createToolResultKey(toolName: string, output: unknown, isError?: boolean): string;
26
- export declare function dispatchRunListeners(stream: AsyncGenerator<InternalHarnessStreamItem>, listeners: RunListeners, options: {
26
+ export declare function dispatchRequestListeners(stream: AsyncGenerator<InternalHarnessStreamItem>, listeners: RequestListeners, options: {
27
27
  notifyListener: <T>(listener: ((value: T) => void | Promise<void>) | undefined, value: T) => Promise<void>;
28
- getThread: (threadId: string) => Promise<{
29
- currentState: RunResult["state"];
28
+ getSession: (sessionId: string) => Promise<{
29
+ currentState: RequestResult["state"];
30
30
  latestRequestId: string;
31
31
  entryAgentId: string;
32
32
  currentAgentId?: string;
@@ -38,4 +38,5 @@ export declare function dispatchRunListeners(stream: AsyncGenerator<InternalHarn
38
38
  pendingActionId?: string;
39
39
  };
40
40
  } | null>;
41
- }): Promise<RunResult>;
41
+ }): Promise<RequestResult>;
42
+ export declare const dispatchRunListeners: typeof dispatchRequestListeners;
@@ -1,21 +1,21 @@
1
- import { createFallbackRunResultFromLatestEvent, mergeRunResultOutput } from "../run/helpers.js";
2
- export async function emitOutputDeltaAndCreateItem(emit, threadId, runId, agentId, content) {
3
- await emit(threadId, runId, 3, "output.delta", {
1
+ import { createFallbackRequestResultFromLatestEvent, mergeRequestResultOutput } from "../run/helpers.js";
2
+ export async function emitOutputDeltaAndCreateItem(emit, sessionId, requestId, agentId, content) {
3
+ await emit(sessionId, requestId, 3, "output.delta", {
4
4
  content,
5
5
  });
6
6
  return {
7
7
  type: "content",
8
- sessionId: threadId,
9
- requestId: runId,
8
+ sessionId,
9
+ requestId,
10
10
  agentId,
11
11
  content,
12
12
  };
13
13
  }
14
- export function createContentBlocksItem(threadId, runId, agentId, contentBlocks) {
14
+ export function createContentBlocksItem(sessionId, requestId, agentId, contentBlocks) {
15
15
  return {
16
16
  type: "content-blocks",
17
- sessionId: threadId,
18
- requestId: runId,
17
+ sessionId,
18
+ requestId,
19
19
  agentId,
20
20
  contentBlocks,
21
21
  };
@@ -30,7 +30,7 @@ export function createToolResultKey(toolName, output, isError) {
30
30
  }
31
31
  return JSON.stringify([toolName, serializedOutput, isError === true]);
32
32
  }
33
- export async function dispatchRunListeners(stream, listeners, options) {
33
+ export async function dispatchRequestListeners(stream, listeners, options) {
34
34
  let latestEvent;
35
35
  let latestResult;
36
36
  let output = "";
@@ -65,20 +65,21 @@ export async function dispatchRunListeners(stream, listeners, options) {
65
65
  throw new Error("run did not emit any events");
66
66
  }
67
67
  if (latestResult) {
68
- return mergeRunResultOutput(latestResult, output);
68
+ return mergeRequestResultOutput(latestResult, output);
69
69
  }
70
- const thread = await options.getThread(latestEvent.sessionId);
71
- if (!thread) {
70
+ const session = await options.getSession(latestEvent.sessionId);
71
+ if (!session) {
72
72
  throw new Error(`Unknown session ${latestEvent.sessionId}`);
73
73
  }
74
- return createFallbackRunResultFromLatestEvent({
74
+ return createFallbackRequestResultFromLatestEvent({
75
75
  latestEvent,
76
- currentState: thread.currentState,
77
- latestRunId: thread.latestRequestId,
78
- entryAgentId: thread.entryAgentId,
79
- latestAgentId: thread.currentAgentId ?? thread.requests[0]?.agentId,
80
- approvalId: thread.pendingDecision?.approvalId,
81
- pendingActionId: thread.pendingDecision?.pendingActionId,
76
+ currentState: session.currentState,
77
+ latestRequestId: session.latestRequestId,
78
+ entryAgentId: session.entryAgentId,
79
+ latestAgentId: session.currentAgentId ?? session.requests[0]?.agentId,
80
+ approvalId: session.pendingDecision?.approvalId,
81
+ pendingActionId: session.pendingDecision?.pendingActionId,
82
82
  output,
83
83
  });
84
84
  }
85
+ export const dispatchRunListeners = dispatchRequestListeners;
@@ -1,18 +1,18 @@
1
1
  function classifyTimelineItem(event) {
2
2
  switch (event.eventType) {
3
- case "run.queued":
4
- case "run.dequeued":
3
+ case "request.queued":
4
+ case "request.dequeued":
5
5
  return "queue";
6
6
  case "approval.requested":
7
7
  case "approval.resolved":
8
8
  return "approval";
9
- case "run.resumed":
9
+ case "request.resumed":
10
10
  return "recovery";
11
11
  case "artifact.created":
12
12
  return "artifact";
13
- case "run.created":
14
- case "run.state.changed":
15
- return "run";
13
+ case "request.created":
14
+ case "request.state.changed":
15
+ return "request";
16
16
  default:
17
17
  return "other";
18
18
  }
@@ -16,4 +16,4 @@ export * from "./run/run-queue.js";
16
16
  export * from "./system/skill-requirements.js";
17
17
  export * from "./system/store.js";
18
18
  export * from "./events/streaming.js";
19
- export * from "./system/thread-memory-sync.js";
19
+ export * from "./system/session-memory-sync.js";
@@ -16,4 +16,4 @@ export * from "./run/run-queue.js";
16
16
  export * from "./system/skill-requirements.js";
17
17
  export * from "./system/store.js";
18
18
  export * from "./events/streaming.js";
19
- export * from "./system/thread-memory-sync.js";
19
+ export * from "./system/session-memory-sync.js";
@@ -1,13 +1,13 @@
1
- import type { ApprovalRecord, HarnessEvent, InternalApprovalRecord, InvocationEnvelope, RunListeners, RunOptions, RunResult, RunStartOptions, MessageContent } from "../../../contracts/types.js";
1
+ import type { ApprovalRecord, HarnessEvent, InternalApprovalRecord, InvocationEnvelope, RequestListeners, RequestOptions, RequestResult, RequestStartOptions, MessageContent } from "../../../contracts/types.js";
2
2
  export declare function toInspectableApprovalRecord(approval: InternalApprovalRecord): ApprovalRecord;
3
- export declare function normalizeInvocationEnvelope(options: RunStartOptions): {
3
+ export declare function normalizeInvocationEnvelope(options: RequestStartOptions): {
4
4
  context?: Record<string, unknown>;
5
5
  state?: Record<string, unknown>;
6
6
  files?: Record<string, unknown>;
7
7
  invocation?: InvocationEnvelope;
8
8
  };
9
- export declare function isTerminalRunState(state: RunResult["state"]): boolean;
10
- export declare function buildPersistedRunRequest(input: MessageContent, invocation: {
9
+ export declare function isTerminalRequestState(state: RequestResult["state"]): boolean;
10
+ export declare function buildPersistedRequestInput(input: MessageContent, invocation: {
11
11
  context?: Record<string, unknown>;
12
12
  state?: Record<string, unknown>;
13
13
  files?: Record<string, unknown>;
@@ -18,16 +18,19 @@ export declare function buildPersistedRunRequest(input: MessageContent, invocati
18
18
  invocation?: InvocationEnvelope;
19
19
  savedAt: string;
20
20
  };
21
- export declare function normalizeRunPriority(priority?: number): number;
22
- export declare function resolveRunListeners(options: RunOptions): RunListeners | undefined;
23
- export declare function mergeRunResultOutput(result: RunResult, streamedOutput: string): RunResult;
24
- export declare function createFallbackRunResultFromLatestEvent(input: {
21
+ export declare function normalizeRequestPriority(priority?: number): number;
22
+ export declare function resolveRequestListeners(options: RequestOptions): RequestListeners | undefined;
23
+ export declare const resolveRunListeners: typeof resolveRequestListeners;
24
+ export declare function mergeRequestResultOutput(result: RequestResult, streamedOutput: string): RequestResult;
25
+ export declare const mergeRunResultOutput: typeof mergeRequestResultOutput;
26
+ export declare function createFallbackRequestResultFromLatestEvent(input: {
25
27
  latestEvent: HarnessEvent;
26
- currentState: RunResult["state"];
27
- latestRunId: string;
28
+ currentState: RequestResult["state"];
29
+ latestRequestId: string;
28
30
  entryAgentId: string;
29
31
  latestAgentId?: string;
30
32
  approvalId?: string;
31
33
  pendingActionId?: string;
32
34
  output: string;
33
- }): RunResult;
35
+ }): RequestResult;
36
+ export declare const createFallbackRunResultFromLatestEvent: typeof createFallbackRequestResultFromLatestEvent;
@@ -12,10 +12,10 @@ export function normalizeInvocationEnvelope(options) {
12
12
  invocation,
13
13
  };
14
14
  }
15
- export function isTerminalRunState(state) {
15
+ export function isTerminalRequestState(state) {
16
16
  return state === "completed" || state === "failed";
17
17
  }
18
- export function buildPersistedRunRequest(input, invocation, priority) {
18
+ export function buildPersistedRequestInput(input, invocation, priority) {
19
19
  const envelope = invocation.invocation ?? {
20
20
  ...(invocation.context ? { context: invocation.context } : {}),
21
21
  ...(invocation.state ? { inputs: invocation.state } : {}),
@@ -35,30 +35,32 @@ export function buildPersistedRunRequest(input, invocation, priority) {
35
35
  savedAt: new Date().toISOString(),
36
36
  };
37
37
  }
38
- export function normalizeRunPriority(priority) {
38
+ export function normalizeRequestPriority(priority) {
39
39
  if (!Number.isFinite(priority)) {
40
40
  return 0;
41
41
  }
42
42
  return Math.trunc(priority);
43
43
  }
44
- export function resolveRunListeners(options) {
44
+ export function resolveRequestListeners(options) {
45
45
  const listeners = options.listeners;
46
46
  if (!listeners) {
47
47
  return undefined;
48
48
  }
49
49
  return listeners;
50
50
  }
51
- export function mergeRunResultOutput(result, streamedOutput) {
51
+ export const resolveRunListeners = resolveRequestListeners;
52
+ export function mergeRequestResultOutput(result, streamedOutput) {
52
53
  return {
53
54
  ...result,
54
55
  output: result.output || streamedOutput,
55
56
  finalMessageText: result.finalMessageText ?? result.output ?? streamedOutput,
56
57
  };
57
58
  }
58
- export function createFallbackRunResultFromLatestEvent(input) {
59
+ export const mergeRunResultOutput = mergeRequestResultOutput;
60
+ export function createFallbackRequestResultFromLatestEvent(input) {
59
61
  return {
60
62
  sessionId: input.latestEvent.sessionId,
61
- requestId: input.latestRunId,
63
+ requestId: input.latestRequestId,
62
64
  agentId: input.latestAgentId ?? input.entryAgentId,
63
65
  state: input.currentState,
64
66
  output: input.output,
@@ -66,3 +68,4 @@ export function createFallbackRunResultFromLatestEvent(input) {
66
68
  pendingActionId: input.pendingActionId,
67
69
  };
68
70
  }
71
+ export const createFallbackRunResultFromLatestEvent = createFallbackRequestResultFromLatestEvent;
@@ -1,6 +1,7 @@
1
1
  import type { CompiledAgentBinding, RuntimeSnapshot, RuntimeSurfaceItem } from "../../../contracts/types.js";
2
- export declare function buildRunRuntimeSnapshot(binding: CompiledAgentBinding, options?: {
3
- runId?: string;
2
+ export declare function buildRequestRuntimeSnapshot(binding: CompiledAgentBinding, options?: {
3
+ requestId?: string;
4
+ legacyRequestId?: string;
4
5
  }): RuntimeSnapshot;
5
6
  export declare function consumeRunInspectionUpstreamEvent(input: {
6
7
  event: unknown;
@@ -28,7 +28,7 @@ function readTracingConfig(binding) {
28
28
  asObject(legacyDeepAgentTracing) ??
29
29
  null);
30
30
  }
31
- function buildRuntimeSnapshotTracing(binding, runId) {
31
+ function buildRuntimeSnapshotTracing(binding, requestId) {
32
32
  const tracing = readTracingConfig(binding);
33
33
  const observability = asObject(binding.harnessRuntime.observability);
34
34
  const runtimeTracing = asObject(observability?.tracing);
@@ -41,12 +41,12 @@ function buildRuntimeSnapshotTracing(binding, runId) {
41
41
  }))
42
42
  : [];
43
43
  if (!tracing) {
44
- if (!runtimeTracing || runId === undefined || runtimeTracing.enabled === false) {
44
+ if (!runtimeTracing || requestId === undefined || runtimeTracing.enabled === false) {
45
45
  return undefined;
46
46
  }
47
47
  return {
48
48
  enabled: true,
49
- correlationId: runId,
49
+ correlationId: requestId,
50
50
  metadata: {
51
51
  ...(typeof runtimeTracing.propagation === "string" ? { propagation: runtimeTracing.propagation } : {}),
52
52
  ...(exporters.length > 0 ? { exporters } : {}),
@@ -54,14 +54,14 @@ function buildRuntimeSnapshotTracing(binding, runId) {
54
54
  };
55
55
  }
56
56
  const enabled = tracing.enabled !== false;
57
- if (!enabled || !runId) {
57
+ if (!enabled || !requestId) {
58
58
  return undefined;
59
59
  }
60
60
  const tags = readStringArray(tracing.tags);
61
61
  const metadata = asObject(tracing.metadata);
62
62
  return {
63
63
  enabled: true,
64
- correlationId: runId,
64
+ correlationId: requestId,
65
65
  ...(tags.length > 0 ? { tags } : {}),
66
66
  ...((metadata && Object.keys(metadata).length > 0) || exporters.length > 0 || typeof runtimeTracing?.propagation === "string"
67
67
  ? {
@@ -74,9 +74,9 @@ function buildRuntimeSnapshotTracing(binding, runId) {
74
74
  : {}),
75
75
  };
76
76
  }
77
- export function buildRunRuntimeSnapshot(binding, options) {
77
+ export function buildRequestRuntimeSnapshot(binding, options) {
78
78
  const model = getBindingPrimaryModel(binding);
79
- const tracing = buildRuntimeSnapshotTracing(binding, options?.runId);
79
+ const tracing = buildRuntimeSnapshotTracing(binding, options?.requestId ?? options?.legacyRequestId);
80
80
  const init = typeof model?.init === "object" && model.init ? model.init : {};
81
81
  const baseUrl = typeof init.baseUrl === "string" && init.baseUrl.trim().length > 0
82
82
  ? init.baseUrl.trim()
@@ -1,7 +1,7 @@
1
- import type { ApprovalRecord, RunSummary, RuntimeOperatorOverview, RuntimeHealthSnapshot } from "../../../contracts/types.js";
1
+ import type { ApprovalRecord, RequestSummary, RuntimeOperatorOverview, RuntimeHealthSnapshot } from "../../../contracts/types.js";
2
2
  export declare function projectOperatorOverview(input: {
3
3
  health: RuntimeHealthSnapshot;
4
- runs: RunSummary[];
4
+ requests: RequestSummary[];
5
5
  approvals: ApprovalRecord[];
6
6
  limit?: number;
7
7
  }): RuntimeOperatorOverview;
@@ -1,5 +1,5 @@
1
1
  import { projectQueueDiagnostics } from "./queue-diagnostics.js";
2
- const ACTIVE_RUN_STATES = new Set([
2
+ const ACTIVE_REQUEST_STATES = new Set([
3
3
  "queued",
4
4
  "claimed",
5
5
  "running",
@@ -14,19 +14,19 @@ function sortNewestFirst(items, selectTimestamp) {
14
14
  return rightTs.localeCompare(leftTs);
15
15
  });
16
16
  }
17
- function summarizeStates(runs) {
17
+ function summarizeRequestStates(requests) {
18
18
  const states = {};
19
- for (const run of runs) {
20
- states[run.state] = (states[run.state] ?? 0) + 1;
19
+ for (const request of requests) {
20
+ states[request.state] = (states[request.state] ?? 0) + 1;
21
21
  }
22
22
  return states;
23
23
  }
24
- function collectGovernanceToolPolicies(runs) {
25
- return runs.flatMap((run) => run.runtimeSnapshot?.governance?.bundles ?? [])
24
+ function collectGovernanceToolPolicies(requests) {
25
+ return requests.flatMap((request) => request.runtimeSnapshot?.governance?.bundles ?? [])
26
26
  .flatMap((bundle) => bundle.toolPolicies);
27
27
  }
28
- function projectGovernanceDiagnostics(runs) {
29
- const toolPolicies = collectGovernanceToolPolicies(runs);
28
+ function projectGovernanceDiagnostics(requests) {
29
+ const toolPolicies = collectGovernanceToolPolicies(requests);
30
30
  const highRiskTools = toolPolicies.filter((tool) => tool.risk === "high").length;
31
31
  const approvalRequiredTools = toolPolicies.filter((tool) => tool.requiresApproval).length;
32
32
  const autoApprovedTools = toolPolicies.filter((tool) => tool.decisionMode === "auto-approve").length;
@@ -35,7 +35,7 @@ function projectGovernanceDiagnostics(runs) {
35
35
  const crossTenantTools = toolPolicies.filter((tool) => tool.tenantScope === "cross-tenant").length;
36
36
  const writeAccessMcpTools = toolPolicies.filter((tool) => tool.category === "mcp" && tool.mcpAccess === "read-write").length;
37
37
  return {
38
- runsWithGovernance: runs.filter((run) => (run.runtimeSnapshot?.governance?.bundles?.length ?? 0) > 0).length,
38
+ runsWithGovernance: requests.filter((request) => (request.runtimeSnapshot?.governance?.bundles?.length ?? 0) > 0).length,
39
39
  highRiskTools,
40
40
  approvalRequiredTools,
41
41
  autoApprovedTools,
@@ -53,15 +53,20 @@ function projectGovernanceDiagnostics(runs) {
53
53
  }
54
54
  export function projectOperatorOverview(input) {
55
55
  const limit = typeof input.limit === "number" && Number.isFinite(input.limit) && input.limit > 0 ? Math.floor(input.limit) : 5;
56
- const activeRuns = sortNewestFirst(input.runs.filter((run) => ACTIVE_RUN_STATES.has(run.state)), (run) => run.lastActivityAt ?? run.updatedAt);
56
+ const activeRequests = sortNewestFirst(input.requests.filter((request) => ACTIVE_REQUEST_STATES.has(request.state)), (request) => request.lastActivityAt ?? request.updatedAt);
57
57
  const pendingApprovals = sortNewestFirst(input.approvals.filter((approval) => approval.status === "pending"), (approval) => approval.requestedAt);
58
58
  const queue = projectQueueDiagnostics(input.health, []);
59
- const governance = projectGovernanceDiagnostics(activeRuns);
59
+ const governance = projectGovernanceDiagnostics(activeRequests);
60
+ const requestOverview = {
61
+ total: activeRequests.length,
62
+ states: summarizeRequestStates(activeRequests),
63
+ items: activeRequests.slice(0, limit),
64
+ };
60
65
  return {
61
66
  updatedAt: input.health.updatedAt,
62
67
  summary: `${queue.summary} ` +
63
68
  `pendingApprovals=${pendingApprovals.length} ` +
64
- `activeRuns=${activeRuns.length} ` +
69
+ `activeRequests=${activeRequests.length} ` +
65
70
  `${governance.summary}`,
66
71
  health: input.health,
67
72
  queue,
@@ -69,11 +74,7 @@ export function projectOperatorOverview(input) {
69
74
  total: pendingApprovals.length,
70
75
  items: pendingApprovals.slice(0, limit),
71
76
  },
72
- runs: {
73
- total: activeRuns.length,
74
- states: summarizeStates(activeRuns),
75
- items: activeRuns.slice(0, limit),
76
- },
77
+ requests: requestOverview,
77
78
  governance,
78
79
  };
79
80
  }
@@ -1,14 +1,14 @@
1
1
  export function projectQueueDiagnostics(snapshot, timeline) {
2
2
  const queueEvents = timeline.filter((item) => item.kind === "queue" || item.kind === "recovery");
3
- const summary = `active=${snapshot.stats.activeRunSlots} ` +
4
- `pending=${snapshot.stats.pendingRunSlots} ` +
5
- `stuck=${snapshot.stats.stuckRuns} ` +
3
+ const summary = `active=${snapshot.stats.activeRequestSlots} ` +
4
+ `pending=${snapshot.stats.pendingRequestSlots} ` +
5
+ `stuck=${snapshot.stats.stuckRequests} ` +
6
6
  `workload=${snapshot.checks.workload.status}`;
7
7
  return {
8
8
  status: snapshot.checks.workload.status,
9
- activeRunSlots: snapshot.stats.activeRunSlots,
10
- pendingRunSlots: snapshot.stats.pendingRunSlots,
11
- stuckRuns: snapshot.stats.stuckRuns,
9
+ activeRequestSlots: snapshot.stats.activeRequestSlots,
10
+ pendingRequestSlots: snapshot.stats.pendingRequestSlots,
11
+ stuckRequests: snapshot.stats.stuckRequests,
12
12
  queueEvents,
13
13
  summary,
14
14
  };