@botbotgo/agent-harness 0.0.475 → 0.0.476
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1234
- package/README.zh.md +3 -1191
- package/dist/acp.js +1 -1
- package/dist/api.js +1 -404
- package/dist/benchmark/checkpoint-resume-cost-benchmark.js +1 -55
- package/dist/benchmark/deepagent-local-model-benchmark.js +2 -35
- package/dist/benchmark/upstream-runtime-ab-benchmark.js +1 -179
- package/dist/cli/chat-interactive.js +25 -244
- package/dist/cli/chat-rendering.js +6 -100
- package/dist/cli/chat-stream.js +23 -512
- package/dist/cli/chat-ui.js +21 -199
- package/dist/cli/chat-workspace.js +2 -210
- package/dist/cli/main.js +21 -428
- package/dist/cli/managed-service-commands.js +9 -63
- package/dist/cli/managed-service.js +2 -137
- package/dist/cli/options-init-chat.js +1 -108
- package/dist/cli/options-runtime.js +1 -158
- package/dist/cli/options-serve.js +1 -282
- package/dist/cli/options.js +2 -19
- package/dist/cli/process-guards.js +1 -139
- package/dist/cli/request-tree.js +7 -296
- package/dist/cli/runtime-commands.js +12 -258
- package/dist/cli/runtime-output.js +16 -155
- package/dist/cli/server-commands.js +16 -270
- package/dist/cli/workspace.js +1 -67
- package/dist/cli.js +1 -7
- package/dist/client/acp.js +1 -1
- package/dist/client/in-process.js +1 -67
- package/dist/client/index.js +1 -2
- package/dist/client/types.js +0 -1
- package/dist/client.js +1 -1
- package/dist/contracts/core.js +1 -1
- package/dist/contracts/runtime-evaluation.js +0 -1
- package/dist/contracts/runtime-memory.js +0 -1
- package/dist/contracts/runtime-observability.js +0 -1
- package/dist/contracts/runtime-requests.js +0 -1
- package/dist/contracts/runtime-scheduling.js +0 -1
- package/dist/contracts/runtime.js +1 -27
- package/dist/contracts/types.js +1 -3
- package/dist/contracts/workspace.js +0 -1
- package/dist/flow/build-flow-graph.js +1 -50
- package/dist/flow/export-mermaid.js +2 -464
- package/dist/flow/export-sequence-mermaid.js +2 -325
- package/dist/flow/flow-graph-normalization.js +1 -214
- package/dist/flow/flow-graph-runtime.js +1 -107
- package/dist/flow/flow-graph-upstream.js +1 -494
- package/dist/flow/index.js +1 -3
- package/dist/flow/types.js +0 -1
- package/dist/index.js +1 -5
- package/dist/init-project.js +1 -1
- package/dist/knowledge/config.js +1 -32
- package/dist/knowledge/contracts.js +0 -1
- package/dist/knowledge/index.js +1 -2
- package/dist/knowledge/module.js +12 -909
- package/dist/knowledge/procedural/config.js +1 -125
- package/dist/knowledge/procedural/index.js +1 -2
- package/dist/knowledge/procedural/manager.js +9 -345
- package/dist/mcp.js +1 -2
- package/dist/package-version.d.ts +1 -1
- package/dist/package-version.js +1 -2
- package/dist/persistence/file-store.js +3 -758
- package/dist/persistence/sqlite-request-context-store.js +5 -54
- package/dist/persistence/sqlite-request-queue-store.js +10 -108
- package/dist/persistence/sqlite-runtime.js +1 -86
- package/dist/persistence/sqlite-store.js +62 -810
- package/dist/persistence/types.js +0 -1
- package/dist/projections/presentation.js +37 -206
- package/dist/projections/request-events.js +2 -502
- package/dist/projections/upstream-events.js +1 -201
- package/dist/protocol/a2a/http-discovery.js +1 -178
- package/dist/protocol/a2a/http-rpc.js +6 -622
- package/dist/protocol/a2a/http.js +1 -138
- package/dist/protocol/a2a/task-state.js +3 -317
- package/dist/protocol/acp/client.js +8 -294
- package/dist/protocol/acp/harness-client.js +1 -218
- package/dist/protocol/acp/http.js +5 -130
- package/dist/protocol/acp/server.js +1 -310
- package/dist/protocol/acp/stdio.js +2 -69
- package/dist/protocol/ag-ui/http.js +3 -378
- package/dist/protocol/mcp/server.js +1 -428
- package/dist/resource/backend/workspace-scoped-backend.js +1 -319
- package/dist/resource/isolation.js +1 -237
- package/dist/resource/mcp/tool-support.js +3 -296
- package/dist/resource/mcp-tool-support.js +1 -2
- package/dist/resource/providers/resource-provider.js +1 -215
- package/dist/resource/resource-impl.js +1 -3
- package/dist/resource/resource-types.js +0 -1
- package/dist/resource/resource.js +1 -1
- package/dist/resource/sources.js +1 -247
- package/dist/resource/tools/function-tool-resolver.js +2 -272
- package/dist/runtime/adapter/compat/deepagent-compat.js +1 -29
- package/dist/runtime/adapter/compat/openai-compatible.js +1 -55
- package/dist/runtime/adapter/direct-builtin-utility.js +2 -90
- package/dist/runtime/adapter/flow/execution-context.js +1 -71
- package/dist/runtime/adapter/flow/invocation-flow.js +8 -425
- package/dist/runtime/adapter/flow/invoke-runtime.js +1 -20
- package/dist/runtime/adapter/flow/stream-runtime.js +11 -1395
- package/dist/runtime/adapter/invocation-result.js +2 -473
- package/dist/runtime/adapter/local-tool-invocation.js +6 -638
- package/dist/runtime/adapter/middleware/context-hygiene.js +1 -83
- package/dist/runtime/adapter/middleware-assembly.js +5 -477
- package/dist/runtime/adapter/model/invocation-request.js +3 -183
- package/dist/runtime/adapter/model/message-assembly.js +1 -28
- package/dist/runtime/adapter/model/model-providers.js +23 -1115
- package/dist/runtime/adapter/model/prompted-json-tool-call-capture.js +1 -40
- package/dist/runtime/adapter/model/prompted-json-tool-policy.js +1 -22
- package/dist/runtime/adapter/resilience.js +1 -104
- package/dist/runtime/adapter/runtime-adapter-support.js +3 -141
- package/dist/runtime/adapter/runtime-shell.js +5 -166
- package/dist/runtime/adapter/stream-event-projection.js +2 -622
- package/dist/runtime/adapter/stream-text-consumption.js +1 -18
- package/dist/runtime/adapter/terminal-status.js +2 -67
- package/dist/runtime/adapter/tool/builtin-middleware-tools.js +6 -627
- package/dist/runtime/adapter/tool/declared-middleware.js +1 -154
- package/dist/runtime/adapter/tool/interrupt-policy.js +1 -34
- package/dist/runtime/adapter/tool/provider-tool.js +1 -25
- package/dist/runtime/adapter/tool/resolved-tool.js +1 -225
- package/dist/runtime/adapter/tool/tool-arguments.js +3 -486
- package/dist/runtime/adapter/tool/tool-hitl.js +1 -346
- package/dist/runtime/adapter/tool/tool-name-mapping.js +1 -128
- package/dist/runtime/adapter/tool/tool-output-artifacts.js +2 -88
- package/dist/runtime/adapter/tool/tool-replay.js +1 -37
- package/dist/runtime/adapter/tool-resolution.js +1 -86
- package/dist/runtime/adapter/upstream-configurable-keys.js +1 -2
- package/dist/runtime/agent-runtime-adapter.js +60 -2338
- package/dist/runtime/agent-runtime-assembly.js +7 -249
- package/dist/runtime/env/runtime-env.js +1 -62
- package/dist/runtime/harness/background-runtime.js +1 -8
- package/dist/runtime/harness/bindings.js +1 -58
- package/dist/runtime/harness/events/event-bus.js +1 -16
- package/dist/runtime/harness/events/event-sink.js +1 -61
- package/dist/runtime/harness/events/events.js +1 -80
- package/dist/runtime/harness/events/listener-runtime.js +1 -13
- package/dist/runtime/harness/events/runtime-event-operations.js +1 -9
- package/dist/runtime/harness/events/streaming.js +1 -100
- package/dist/runtime/harness/events/timeline.js +1 -52
- package/dist/runtime/harness/public-shapes.js +1 -186
- package/dist/runtime/harness/run/artifact-paths.js +1 -15
- package/dist/runtime/harness/run/governance.js +1 -295
- package/dist/runtime/harness/run/helpers.js +1 -71
- package/dist/runtime/harness/run/inspection.js +1 -409
- package/dist/runtime/harness/run/operator-overview.js +1 -80
- package/dist/runtime/harness/run/queue-diagnostics.js +1 -15
- package/dist/runtime/harness/run/recovery.js +1 -162
- package/dist/runtime/harness/run/resources.js +1 -60
- package/dist/runtime/harness/run/resume.js +1 -56
- package/dist/runtime/harness/run/routing.js +1 -48
- package/dist/runtime/harness/run/run-lifecycle.js +1 -66
- package/dist/runtime/harness/run/run-operations.js +1 -217
- package/dist/runtime/harness/run/run-queue.js +1 -43
- package/dist/runtime/harness/run/run-slot-acquisition.js +1 -157
- package/dist/runtime/harness/run/session-records.js +1 -97
- package/dist/runtime/harness/run/start-run.js +1 -120
- package/dist/runtime/harness/run/startup-runtime.js +1 -69
- package/dist/runtime/harness/run/stream-run.js +8 -1418
- package/dist/runtime/harness/run/surface-semantics.js +1 -79
- package/dist/runtime/harness/runtime-defaults.js +1 -39
- package/dist/runtime/harness/system/boundary-analysis.js +1 -234
- package/dist/runtime/harness/system/health-monitor.js +1 -258
- package/dist/runtime/harness/system/inventory.js +1 -129
- package/dist/runtime/harness/system/mem0-ingestion-sync.js +5 -345
- package/dist/runtime/harness/system/policy-engine.js +1 -175
- package/dist/runtime/harness/system/runtime-memory-candidates.js +4 -110
- package/dist/runtime/harness/system/runtime-memory-consolidation.js +1 -51
- package/dist/runtime/harness/system/runtime-memory-manager.js +10 -693
- package/dist/runtime/harness/system/runtime-memory-policy.js +1 -155
- package/dist/runtime/harness/system/runtime-memory-records.js +11 -577
- package/dist/runtime/harness/system/runtime-memory-sync.js +5 -206
- package/dist/runtime/harness/system/session-memory-sync.js +3 -113
- package/dist/runtime/harness/system/skill-requirements.js +1 -112
- package/dist/runtime/harness/system/store.js +9 -365
- package/dist/runtime/harness/tool-gateway/index.js +1 -2
- package/dist/runtime/harness/tool-gateway/policy.js +1 -45
- package/dist/runtime/harness/tool-gateway/validation.js +1 -176
- package/dist/runtime/harness/tool-schema.js +1 -3
- package/dist/runtime/harness.js +3 -1490
- package/dist/runtime/index.js +1 -3
- package/dist/runtime/layout/runtime-layout.js +1 -31
- package/dist/runtime/maintenance/checkpoint-maintenance.js +2 -178
- package/dist/runtime/maintenance/file-checkpoint-saver.js +1 -106
- package/dist/runtime/maintenance/runtime-record-maintenance.js +2 -169
- package/dist/runtime/maintenance/sqlite-checkpoint-saver.js +4 -289
- package/dist/runtime/parsing/output-content.js +10 -550
- package/dist/runtime/parsing/output-parsing.js +1 -4
- package/dist/runtime/parsing/output-recovery.js +3 -213
- package/dist/runtime/parsing/output-tool-args.js +7 -663
- package/dist/runtime/parsing/stream-event-parsing.js +3 -362
- package/dist/runtime/prompts/runtime-prompts.js +4 -73
- package/dist/runtime/scheduling/system-schedule-manager.js +11 -532
- package/dist/runtime/skills/skill-metadata.js +1 -197
- package/dist/runtime/startup-tracing.js +2 -37
- package/dist/runtime/support/compiled-binding.js +1 -290
- package/dist/runtime/support/embedding-models.js +1 -118
- package/dist/runtime/support/harness-support.js +5 -137
- package/dist/runtime/support/llamaindex.js +1 -108
- package/dist/runtime/support/runtime-adapter-options.js +1 -29
- package/dist/runtime/support/runtime-factories.js +1 -51
- package/dist/runtime/support/vector-stores.js +9 -270
- package/dist/scaffold/init-project.js +54 -233
- package/dist/tooling/extensions.js +1 -311
- package/dist/tooling/module-loader.js +1 -55
- package/dist/tools.js +1 -176
- package/dist/utils/agent-display.js +1 -18
- package/dist/utils/bundled-text.js +4 -39
- package/dist/utils/compiled-binding.js +1 -33
- package/dist/utils/fs.js +2 -45
- package/dist/utils/id.js +1 -9
- package/dist/utils/message-content.js +1 -30
- package/dist/utils/object.js +1 -6
- package/dist/workspace/agent-binding-compiler.js +3 -613
- package/dist/workspace/compile.js +1 -472
- package/dist/workspace/framework-contract-validation.js +2 -322
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/object-loader-paths.js +1 -71
- package/dist/workspace/object-loader-readers.js +1 -187
- package/dist/workspace/object-loader.js +1 -754
- package/dist/workspace/resource-compilers.js +1 -374
- package/dist/workspace/support/agent-capabilities.js +1 -37
- package/dist/workspace/support/agent-execution-config.js +1 -44
- package/dist/workspace/support/discovery.js +1 -147
- package/dist/workspace/support/source-collectors.js +1 -30
- package/dist/workspace/support/source-protocols.js +2 -192
- package/dist/workspace/support/workspace-ref-utils.js +1 -362
- package/dist/workspace/tool-hydration.js +1 -280
- package/dist/workspace/validate.js +1 -99
- package/dist/workspace/yaml-object-reader.js +1 -285
- package/package.json +7 -3
|
@@ -1,502 +1,2 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const DATA_EVENT_PREVIEW_CHARS = 2_000;
|
|
4
|
-
const TRUNCATION_SENTINEL = "\n...[truncated]";
|
|
5
|
-
function createEmptyPlanSummary() {
|
|
6
|
-
return {
|
|
7
|
-
total: 0,
|
|
8
|
-
pending: 0,
|
|
9
|
-
inProgress: 0,
|
|
10
|
-
completed: 0,
|
|
11
|
-
failed: 0,
|
|
12
|
-
cancelled: 0,
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
function resolveTodoKey(content, id, index) {
|
|
16
|
-
if (typeof id === "string" && id.length > 0) {
|
|
17
|
-
return id;
|
|
18
|
-
}
|
|
19
|
-
return `${index}:${content}`;
|
|
20
|
-
}
|
|
21
|
-
function resolveActiveTodoKey(items) {
|
|
22
|
-
const active = items.find((item) => item.status === "in_progress");
|
|
23
|
-
return active?.key;
|
|
24
|
-
}
|
|
25
|
-
function countStructuredTodoIds(items) {
|
|
26
|
-
return items.filter((item) => typeof item.id === "string" && item.id.length > 0).length;
|
|
27
|
-
}
|
|
28
|
-
function shouldReplacePlanItems(currentItems, nextItems) {
|
|
29
|
-
if (currentItems.length === 0) {
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
if (nextItems.length === 0) {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
const currentStructuredIds = countStructuredTodoIds(currentItems);
|
|
36
|
-
const nextStructuredIds = countStructuredTodoIds(nextItems);
|
|
37
|
-
if (currentStructuredIds > 0
|
|
38
|
-
&& nextStructuredIds === 0
|
|
39
|
-
&& nextItems.length < currentItems.length) {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
return true;
|
|
43
|
-
}
|
|
44
|
-
function cloneSteps(steps) {
|
|
45
|
-
return steps.map((step) => ({
|
|
46
|
-
...step,
|
|
47
|
-
...(step.detail ? { detail: { ...step.detail } } : {}),
|
|
48
|
-
}));
|
|
49
|
-
}
|
|
50
|
-
function buildPlanItems(snapshot, planItems) {
|
|
51
|
-
const previousSteps = new Map(snapshot.plan.items.map((item) => [item.key, cloneSteps(item.events)]));
|
|
52
|
-
return planItems.map((item, index) => {
|
|
53
|
-
const key = resolveTodoKey(item.content, item.id, index);
|
|
54
|
-
return {
|
|
55
|
-
...item,
|
|
56
|
-
key,
|
|
57
|
-
events: previousSteps.get(key) ?? [],
|
|
58
|
-
};
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
function buildStepEventKey(input) {
|
|
62
|
-
return `${input.kind}:${input.id}`;
|
|
63
|
-
}
|
|
64
|
-
function truncateText(value, maxChars) {
|
|
65
|
-
if (value.length <= maxChars) {
|
|
66
|
-
return value;
|
|
67
|
-
}
|
|
68
|
-
const sliceLength = Math.max(0, maxChars - TRUNCATION_SENTINEL.length);
|
|
69
|
-
return `${value.slice(0, sliceLength)}${TRUNCATION_SENTINEL}`;
|
|
70
|
-
}
|
|
71
|
-
function appendSnapshotOutput(current, delta) {
|
|
72
|
-
if (!delta || current.length >= MAX_SNAPSHOT_OUTPUT_CHARS || current.endsWith(TRUNCATION_SENTINEL)) {
|
|
73
|
-
return current;
|
|
74
|
-
}
|
|
75
|
-
const remaining = MAX_SNAPSHOT_OUTPUT_CHARS - current.length;
|
|
76
|
-
if (delta.length <= remaining) {
|
|
77
|
-
return current + delta;
|
|
78
|
-
}
|
|
79
|
-
return `${current}${truncateText(delta, remaining)}`;
|
|
80
|
-
}
|
|
81
|
-
function summarizeLargeDataEventOutput(output) {
|
|
82
|
-
if (typeof output === "string") {
|
|
83
|
-
if (output.length <= MAX_DATA_EVENT_INLINE_CHARS) {
|
|
84
|
-
return output;
|
|
85
|
-
}
|
|
86
|
-
return {
|
|
87
|
-
truncated: true,
|
|
88
|
-
originalSizeChars: output.length,
|
|
89
|
-
preview: truncateText(output, DATA_EVENT_PREVIEW_CHARS),
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
if (typeof output === "number" || typeof output === "boolean" || output === null || output === undefined) {
|
|
93
|
-
return output;
|
|
94
|
-
}
|
|
95
|
-
let serialized;
|
|
96
|
-
try {
|
|
97
|
-
serialized = JSON.stringify(output, null, 2);
|
|
98
|
-
}
|
|
99
|
-
catch {
|
|
100
|
-
serialized = String(output);
|
|
101
|
-
}
|
|
102
|
-
if (serialized.length <= MAX_DATA_EVENT_INLINE_CHARS) {
|
|
103
|
-
return output;
|
|
104
|
-
}
|
|
105
|
-
return {
|
|
106
|
-
truncated: true,
|
|
107
|
-
originalSizeChars: serialized.length,
|
|
108
|
-
preview: truncateText(serialized, DATA_EVENT_PREVIEW_CHARS),
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
function applyPlanState(snapshot, planState) {
|
|
112
|
-
if (!shouldReplacePlanItems(snapshot.plan.items, planState.items)) {
|
|
113
|
-
return {
|
|
114
|
-
...snapshot,
|
|
115
|
-
sessionId: planState.sessionId,
|
|
116
|
-
requestId: planState.requestId,
|
|
117
|
-
updatedAt: planState.updatedAt,
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
const items = buildPlanItems(snapshot, planState.items);
|
|
121
|
-
return {
|
|
122
|
-
...snapshot,
|
|
123
|
-
sessionId: planState.sessionId,
|
|
124
|
-
requestId: planState.requestId,
|
|
125
|
-
updatedAt: planState.updatedAt,
|
|
126
|
-
plan: {
|
|
127
|
-
version: planState.version,
|
|
128
|
-
updatedAt: planState.updatedAt,
|
|
129
|
-
summary: planState.summary,
|
|
130
|
-
items,
|
|
131
|
-
},
|
|
132
|
-
activeTodoKey: resolveActiveTodoKey(items),
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
function appendStep(steps, nextStep, timestamp) {
|
|
136
|
-
return [
|
|
137
|
-
...steps,
|
|
138
|
-
{
|
|
139
|
-
...nextStep,
|
|
140
|
-
...(timestamp ? { occurredAt: nextStep.occurredAt ?? timestamp } : {}),
|
|
141
|
-
},
|
|
142
|
-
];
|
|
143
|
-
}
|
|
144
|
-
function applySurfaceItem(snapshot, surfaceItem, timestamp) {
|
|
145
|
-
const nextStep = {
|
|
146
|
-
id: surfaceItem.id,
|
|
147
|
-
kind: surfaceItem.kind,
|
|
148
|
-
name: surfaceItem.name,
|
|
149
|
-
action: surfaceItem.action,
|
|
150
|
-
status: surfaceItem.status,
|
|
151
|
-
...(surfaceItem.agentId ? { agentId: surfaceItem.agentId } : {}),
|
|
152
|
-
...(surfaceItem.agentName ? { agentName: surfaceItem.agentName } : {}),
|
|
153
|
-
...(surfaceItem.ownerAgentId ? { ownerAgentId: surfaceItem.ownerAgentId } : {}),
|
|
154
|
-
...(surfaceItem.ownerAgentName ? { ownerAgentName: surfaceItem.ownerAgentName } : {}),
|
|
155
|
-
...(surfaceItem.sourceEventId ? { sourceEventId: surfaceItem.sourceEventId } : {}),
|
|
156
|
-
...(surfaceItem.detail ? { detail: surfaceItem.detail } : {}),
|
|
157
|
-
};
|
|
158
|
-
const targetTodoKey = snapshot.activeTodoKey;
|
|
159
|
-
if (!targetTodoKey) {
|
|
160
|
-
const activeEventKey = buildStepEventKey(nextStep);
|
|
161
|
-
return {
|
|
162
|
-
...snapshot,
|
|
163
|
-
updatedAt: timestamp,
|
|
164
|
-
events: appendStep(snapshot.events, nextStep, timestamp),
|
|
165
|
-
activeEventId: surfaceItem.status === "started" ? activeEventKey : snapshot.activeEventId,
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
const activeEventKey = buildStepEventKey(nextStep);
|
|
169
|
-
return {
|
|
170
|
-
...snapshot,
|
|
171
|
-
updatedAt: timestamp,
|
|
172
|
-
plan: {
|
|
173
|
-
...snapshot.plan,
|
|
174
|
-
items: snapshot.plan.items.map((item) => item.key === targetTodoKey
|
|
175
|
-
? {
|
|
176
|
-
...item,
|
|
177
|
-
events: appendStep(item.events, nextStep, timestamp),
|
|
178
|
-
}
|
|
179
|
-
: item),
|
|
180
|
-
},
|
|
181
|
-
activeEventId: surfaceItem.status === "started" ? activeEventKey : snapshot.activeEventId,
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
function applyToolResult(snapshot, item, timestamp) {
|
|
185
|
-
const summary = typeof item.output === "object" && item.output !== null
|
|
186
|
-
? item.output.summary
|
|
187
|
-
: undefined;
|
|
188
|
-
const hasStructuredSummary = typeof summary === "object"
|
|
189
|
-
&& summary !== null
|
|
190
|
-
&& Array.isArray(summary.items)
|
|
191
|
-
&& typeof summary.summary === "object"
|
|
192
|
-
&& summary.summary !== null;
|
|
193
|
-
if (hasStructuredSummary) {
|
|
194
|
-
const typedSummary = summary;
|
|
195
|
-
if (!shouldReplacePlanItems(snapshot.plan.items, typedSummary.items)) {
|
|
196
|
-
return {
|
|
197
|
-
...snapshot,
|
|
198
|
-
sessionId: item.sessionId,
|
|
199
|
-
requestId: item.requestId,
|
|
200
|
-
agentId: item.agentId,
|
|
201
|
-
updatedAt: timestamp,
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
const items = buildPlanItems(snapshot, typedSummary.items);
|
|
205
|
-
return {
|
|
206
|
-
...snapshot,
|
|
207
|
-
sessionId: item.sessionId,
|
|
208
|
-
requestId: item.requestId,
|
|
209
|
-
agentId: item.agentId,
|
|
210
|
-
updatedAt: timestamp,
|
|
211
|
-
plan: {
|
|
212
|
-
version: snapshot.plan.version + 1,
|
|
213
|
-
updatedAt: timestamp,
|
|
214
|
-
summary: typedSummary.summary,
|
|
215
|
-
items,
|
|
216
|
-
},
|
|
217
|
-
activeTodoKey: resolveActiveTodoKey(items),
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
return {
|
|
221
|
-
...snapshot,
|
|
222
|
-
sessionId: item.sessionId,
|
|
223
|
-
requestId: item.requestId,
|
|
224
|
-
agentId: item.agentId,
|
|
225
|
-
updatedAt: timestamp,
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
function applyLifecycleEvent(snapshot, event) {
|
|
229
|
-
const next = {
|
|
230
|
-
...snapshot,
|
|
231
|
-
sessionId: event.sessionId,
|
|
232
|
-
requestId: event.requestId,
|
|
233
|
-
updatedAt: event.timestamp,
|
|
234
|
-
};
|
|
235
|
-
if (event.eventType === "request.created") {
|
|
236
|
-
return {
|
|
237
|
-
...next,
|
|
238
|
-
state: "running",
|
|
239
|
-
...(typeof event.payload.selectedAgentId === "string" ? { agentId: event.payload.selectedAgentId } : {}),
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
if (event.eventType === "request.state.changed") {
|
|
243
|
-
return {
|
|
244
|
-
...next,
|
|
245
|
-
state: typeof event.payload.state === "string" ? event.payload.state : next.state,
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
if (event.eventType === "request.resumed") {
|
|
249
|
-
return {
|
|
250
|
-
...next,
|
|
251
|
-
state: typeof event.payload.state === "string" ? event.payload.state : "resuming",
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
if (event.eventType === "approval.requested") {
|
|
255
|
-
const approval = {
|
|
256
|
-
...(typeof event.payload.approvalId === "string" ? { approvalId: event.payload.approvalId } : {}),
|
|
257
|
-
...(typeof event.payload.pendingActionId === "string" ? { pendingActionId: event.payload.pendingActionId } : {}),
|
|
258
|
-
...(typeof event.payload.toolName === "string" ? { toolName: event.payload.toolName } : {}),
|
|
259
|
-
status: "pending",
|
|
260
|
-
...(Array.isArray(event.payload.allowedDecisions) ? { allowedDecisions: event.payload.allowedDecisions } : {}),
|
|
261
|
-
};
|
|
262
|
-
return {
|
|
263
|
-
...next,
|
|
264
|
-
state: "waiting_for_approval",
|
|
265
|
-
approval,
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
if (event.eventType === "approval.resolved") {
|
|
269
|
-
const decision = typeof event.payload.decision === "string" ? event.payload.decision : undefined;
|
|
270
|
-
const approvalStatus = decision === "approve" ? "approved"
|
|
271
|
-
: decision === "edit" ? "edited"
|
|
272
|
-
: decision === "reject" ? "rejected"
|
|
273
|
-
: snapshot.approval?.status;
|
|
274
|
-
return {
|
|
275
|
-
...next,
|
|
276
|
-
approval: {
|
|
277
|
-
...(snapshot.approval ?? {}),
|
|
278
|
-
...(typeof event.payload.approvalId === "string" ? { approvalId: event.payload.approvalId } : {}),
|
|
279
|
-
...(typeof event.payload.pendingActionId === "string" ? { pendingActionId: event.payload.pendingActionId } : {}),
|
|
280
|
-
...(typeof event.payload.toolName === "string" ? { toolName: event.payload.toolName } : {}),
|
|
281
|
-
...(approvalStatus ? { status: approvalStatus } : {}),
|
|
282
|
-
},
|
|
283
|
-
};
|
|
284
|
-
}
|
|
285
|
-
return next;
|
|
286
|
-
}
|
|
287
|
-
export function createInitialRequestEventSnapshot() {
|
|
288
|
-
const now = new Date().toISOString();
|
|
289
|
-
return {
|
|
290
|
-
sessionId: "",
|
|
291
|
-
requestId: "",
|
|
292
|
-
updatedAt: now,
|
|
293
|
-
state: "running",
|
|
294
|
-
plan: {
|
|
295
|
-
version: 0,
|
|
296
|
-
updatedAt: now,
|
|
297
|
-
summary: createEmptyPlanSummary(),
|
|
298
|
-
items: [],
|
|
299
|
-
},
|
|
300
|
-
output: "",
|
|
301
|
-
events: [],
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
export function applyRequestStreamItemToSnapshot(snapshot, item) {
|
|
305
|
-
const now = new Date().toISOString();
|
|
306
|
-
switch (item.type) {
|
|
307
|
-
case "event":
|
|
308
|
-
return applyLifecycleEvent(snapshot, item.event);
|
|
309
|
-
case "content":
|
|
310
|
-
return {
|
|
311
|
-
...snapshot,
|
|
312
|
-
sessionId: item.sessionId,
|
|
313
|
-
requestId: item.requestId,
|
|
314
|
-
updatedAt: now,
|
|
315
|
-
agentId: item.agentId,
|
|
316
|
-
output: appendSnapshotOutput(snapshot.output, item.content),
|
|
317
|
-
};
|
|
318
|
-
case "commentary":
|
|
319
|
-
return {
|
|
320
|
-
...snapshot,
|
|
321
|
-
sessionId: item.sessionId,
|
|
322
|
-
requestId: item.requestId,
|
|
323
|
-
updatedAt: now,
|
|
324
|
-
agentId: item.agentId,
|
|
325
|
-
};
|
|
326
|
-
case "content-blocks":
|
|
327
|
-
return {
|
|
328
|
-
...snapshot,
|
|
329
|
-
sessionId: item.sessionId,
|
|
330
|
-
requestId: item.requestId,
|
|
331
|
-
updatedAt: now,
|
|
332
|
-
agentId: item.agentId,
|
|
333
|
-
contentBlocks: item.contentBlocks,
|
|
334
|
-
};
|
|
335
|
-
case "tool-result":
|
|
336
|
-
return applyToolResult({
|
|
337
|
-
...snapshot,
|
|
338
|
-
sessionId: item.sessionId,
|
|
339
|
-
requestId: item.requestId,
|
|
340
|
-
agentId: item.agentId,
|
|
341
|
-
}, item, now);
|
|
342
|
-
case "plan-state":
|
|
343
|
-
return applyPlanState({
|
|
344
|
-
...snapshot,
|
|
345
|
-
agentId: item.agentId,
|
|
346
|
-
}, item.planState);
|
|
347
|
-
case "upstream-event":
|
|
348
|
-
return item.surfaceItem
|
|
349
|
-
? applySurfaceItem({
|
|
350
|
-
...snapshot,
|
|
351
|
-
sessionId: item.sessionId,
|
|
352
|
-
requestId: item.requestId,
|
|
353
|
-
}, item.surfaceItem, now)
|
|
354
|
-
: {
|
|
355
|
-
...snapshot,
|
|
356
|
-
sessionId: item.sessionId,
|
|
357
|
-
requestId: item.requestId,
|
|
358
|
-
updatedAt: now,
|
|
359
|
-
};
|
|
360
|
-
case "profile-step":
|
|
361
|
-
const activeEventKey = buildStepEventKey(item.step);
|
|
362
|
-
return {
|
|
363
|
-
...snapshot,
|
|
364
|
-
sessionId: item.sessionId,
|
|
365
|
-
requestId: item.requestId,
|
|
366
|
-
updatedAt: now,
|
|
367
|
-
events: appendStep(snapshot.events, item.step, now),
|
|
368
|
-
activeEventId: item.step.status === "started"
|
|
369
|
-
? activeEventKey
|
|
370
|
-
: snapshot.activeEventId,
|
|
371
|
-
};
|
|
372
|
-
case "result":
|
|
373
|
-
return {
|
|
374
|
-
...snapshot,
|
|
375
|
-
sessionId: item.result.sessionId,
|
|
376
|
-
requestId: item.result.requestId,
|
|
377
|
-
updatedAt: now,
|
|
378
|
-
state: item.result.state,
|
|
379
|
-
agentId: item.result.agentId ?? snapshot.agentId,
|
|
380
|
-
output: item.result.output ? truncateText(item.result.output, MAX_SNAPSHOT_OUTPUT_CHARS) : snapshot.output,
|
|
381
|
-
...(item.result.contentBlocks ? { contentBlocks: item.result.contentBlocks } : {}),
|
|
382
|
-
...(item.result.structuredResponse !== undefined ? { structuredResponse: item.result.structuredResponse } : {}),
|
|
383
|
-
...(item.result.interruptContent !== undefined ? { interruptContent: item.result.interruptContent } : {}),
|
|
384
|
-
...(item.result.approvalId || item.result.pendingActionId
|
|
385
|
-
? {
|
|
386
|
-
approval: {
|
|
387
|
-
...(snapshot.approval ?? {}),
|
|
388
|
-
...(item.result.approvalId ? { approvalId: item.result.approvalId } : {}),
|
|
389
|
-
...(item.result.pendingActionId ? { pendingActionId: item.result.pendingActionId } : {}),
|
|
390
|
-
},
|
|
391
|
-
}
|
|
392
|
-
: {}),
|
|
393
|
-
};
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
function createSurfaceExecutionStep(surfaceItem) {
|
|
397
|
-
return {
|
|
398
|
-
id: surfaceItem.id,
|
|
399
|
-
kind: surfaceItem.kind,
|
|
400
|
-
name: surfaceItem.name,
|
|
401
|
-
action: surfaceItem.action,
|
|
402
|
-
status: surfaceItem.status,
|
|
403
|
-
...(surfaceItem.agentId ? { agentId: surfaceItem.agentId } : {}),
|
|
404
|
-
...(surfaceItem.agentName ? { agentName: surfaceItem.agentName } : {}),
|
|
405
|
-
...(surfaceItem.ownerAgentId ? { ownerAgentId: surfaceItem.ownerAgentId } : {}),
|
|
406
|
-
...(surfaceItem.ownerAgentName ? { ownerAgentName: surfaceItem.ownerAgentName } : {}),
|
|
407
|
-
...(surfaceItem.sourceEventId ? { sourceEventId: surfaceItem.sourceEventId } : {}),
|
|
408
|
-
...(surfaceItem.detail ? { detail: surfaceItem.detail } : {}),
|
|
409
|
-
};
|
|
410
|
-
}
|
|
411
|
-
export function toRequestDataEvents(item) {
|
|
412
|
-
switch (item.type) {
|
|
413
|
-
case "commentary":
|
|
414
|
-
return [{
|
|
415
|
-
type: "progress.commentary",
|
|
416
|
-
sessionId: item.sessionId,
|
|
417
|
-
requestId: item.requestId,
|
|
418
|
-
agentId: item.agentId,
|
|
419
|
-
text: item.content,
|
|
420
|
-
}];
|
|
421
|
-
case "content":
|
|
422
|
-
return [{
|
|
423
|
-
type: "output.text.delta",
|
|
424
|
-
sessionId: item.sessionId,
|
|
425
|
-
requestId: item.requestId,
|
|
426
|
-
agentId: item.agentId,
|
|
427
|
-
text: item.content,
|
|
428
|
-
}];
|
|
429
|
-
case "content-blocks":
|
|
430
|
-
return [{
|
|
431
|
-
type: "output.content-blocks",
|
|
432
|
-
sessionId: item.sessionId,
|
|
433
|
-
requestId: item.requestId,
|
|
434
|
-
agentId: item.agentId,
|
|
435
|
-
contentBlocks: item.contentBlocks,
|
|
436
|
-
}];
|
|
437
|
-
case "tool-result":
|
|
438
|
-
return [{
|
|
439
|
-
type: "tool.result",
|
|
440
|
-
sessionId: item.sessionId,
|
|
441
|
-
requestId: item.requestId,
|
|
442
|
-
agentId: item.agentId,
|
|
443
|
-
toolName: item.toolName,
|
|
444
|
-
output: summarizeLargeDataEventOutput(item.output),
|
|
445
|
-
...(item.isError !== undefined ? { isError: item.isError } : {}),
|
|
446
|
-
}];
|
|
447
|
-
case "plan-state":
|
|
448
|
-
return [
|
|
449
|
-
{
|
|
450
|
-
type: "plan.state",
|
|
451
|
-
sessionId: item.sessionId,
|
|
452
|
-
requestId: item.requestId,
|
|
453
|
-
agentId: item.agentId,
|
|
454
|
-
planState: item.planState,
|
|
455
|
-
},
|
|
456
|
-
...item.planState.items.map((planItem, index) => ({
|
|
457
|
-
type: "plan.step",
|
|
458
|
-
sessionId: item.sessionId,
|
|
459
|
-
requestId: item.requestId,
|
|
460
|
-
agentId: item.agentId,
|
|
461
|
-
planStateVersion: item.planState.version,
|
|
462
|
-
index,
|
|
463
|
-
item: planItem,
|
|
464
|
-
})),
|
|
465
|
-
];
|
|
466
|
-
case "upstream-event":
|
|
467
|
-
return [
|
|
468
|
-
...(item.surfaceItem
|
|
469
|
-
? [{
|
|
470
|
-
type: "execution.step",
|
|
471
|
-
sessionId: item.sessionId,
|
|
472
|
-
requestId: item.requestId,
|
|
473
|
-
step: createSurfaceExecutionStep(item.surfaceItem),
|
|
474
|
-
}]
|
|
475
|
-
: []),
|
|
476
|
-
{
|
|
477
|
-
type: "debug.upstream",
|
|
478
|
-
sessionId: item.sessionId,
|
|
479
|
-
requestId: item.requestId,
|
|
480
|
-
...(item.surfaceItem ? { surfaceItem: item.surfaceItem } : {}),
|
|
481
|
-
event: item.event,
|
|
482
|
-
},
|
|
483
|
-
];
|
|
484
|
-
case "profile-step":
|
|
485
|
-
return [{
|
|
486
|
-
type: "execution.step",
|
|
487
|
-
sessionId: item.sessionId,
|
|
488
|
-
requestId: item.requestId,
|
|
489
|
-
step: item.step,
|
|
490
|
-
}, {
|
|
491
|
-
type: "debug.profile",
|
|
492
|
-
sessionId: item.sessionId,
|
|
493
|
-
requestId: item.requestId,
|
|
494
|
-
step: item.step,
|
|
495
|
-
}];
|
|
496
|
-
default:
|
|
497
|
-
return [];
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
export function toRequestDataEvent(item) {
|
|
501
|
-
return toRequestDataEvents(item)[0] ?? null;
|
|
502
|
-
}
|
|
1
|
+
const R=4096,k=12e3,P=2e3,u=`
|
|
2
|
+
...[truncated]`;function y(){return{total:0,pending:0,inProgress:0,completed:0,failed:0,cancelled:0}}function A(t,e,n){return typeof e=="string"&&e.length>0?e:`${n}:${t}`}function I(t){return t.find(n=>n.status==="in_progress")?.key}function c(t){return t.filter(e=>typeof e.id=="string"&&e.id.length>0).length}function i(t,e){if(t.length===0)return!0;if(e.length===0)return!1;const n=c(t),s=c(e);return!(n>0&&s===0&&e.length<t.length)}function v(t){return t.map(e=>({...e,...e.detail?{detail:{...e.detail}}:{}}))}function g(t,e){const n=new Map(t.plan.items.map(s=>[s.key,v(s.events)]));return e.map((s,r)=>{const o=A(s.content,s.id,r);return{...s,key:o,events:n.get(o)??[]}})}function l(t){return`${t.kind}:${t.id}`}function a(t,e){if(t.length<=e)return t;const n=Math.max(0,e-u.length);return`${t.slice(0,n)}${u}`}function q(t,e){if(!e||t.length>=4096||t.endsWith(u))return t;const n=4096-t.length;return e.length<=n?t+e:`${t}${a(e,n)}`}function f(t){if(typeof t=="string")return t.length<=12e3?t:{truncated:!0,originalSizeChars:t.length,preview:a(t,2e3)};if(typeof t=="number"||typeof t=="boolean"||t===null||t===void 0)return t;let e;try{e=JSON.stringify(t,null,2)}catch{e=String(t)}return e.length<=12e3?t:{truncated:!0,originalSizeChars:e.length,preview:a(e,2e3)}}function E(t,e){if(!i(t.plan.items,e.items))return{...t,sessionId:e.sessionId,requestId:e.requestId,updatedAt:e.updatedAt};const n=g(t,e.items);return{...t,sessionId:e.sessionId,requestId:e.requestId,updatedAt:e.updatedAt,plan:{version:e.version,updatedAt:e.updatedAt,summary:e.summary,items:n},activeTodoKey:I(n)}}function p(t,e,n){return[...t,{...e,...n?{occurredAt:e.occurredAt??n}:{}}]}function S(t,e,n){const s={id:e.id,kind:e.kind,name:e.name,action:e.action,status:e.status,...e.agentId?{agentId:e.agentId}:{},...e.agentName?{agentName:e.agentName}:{},...e.ownerAgentId?{ownerAgentId:e.ownerAgentId}:{},...e.ownerAgentName?{ownerAgentName:e.ownerAgentName}:{},...e.sourceEventId?{sourceEventId:e.sourceEventId}:{},...e.detail?{detail:e.detail}:{}},r=t.activeTodoKey;if(!r){const d=l(s);return{...t,updatedAt:n,events:p(t.events,s,n),activeEventId:e.status==="started"?d:t.activeEventId}}const o=l(s);return{...t,updatedAt:n,plan:{...t.plan,items:t.plan.items.map(d=>d.key===r?{...d,events:p(d.events,s,n)}:d)},activeEventId:e.status==="started"?o:t.activeEventId}}function T(t,e,n){const s=typeof e.output=="object"&&e.output!==null?e.output.summary:void 0;if(typeof s=="object"&&s!==null&&Array.isArray(s.items)&&typeof s.summary=="object"&&s.summary!==null){const o=s;if(!i(t.plan.items,o.items))return{...t,sessionId:e.sessionId,requestId:e.requestId,agentId:e.agentId,updatedAt:n};const d=g(t,o.items);return{...t,sessionId:e.sessionId,requestId:e.requestId,agentId:e.agentId,updatedAt:n,plan:{version:t.plan.version+1,updatedAt:n,summary:o.summary,items:d},activeTodoKey:I(d)}}return{...t,sessionId:e.sessionId,requestId:e.requestId,agentId:e.agentId,updatedAt:n}}function N(t,e){const n={...t,sessionId:e.sessionId,requestId:e.requestId,updatedAt:e.timestamp};if(e.eventType==="request.created")return{...n,state:"running",...typeof e.payload.selectedAgentId=="string"?{agentId:e.payload.selectedAgentId}:{}};if(e.eventType==="request.state.changed")return{...n,state:typeof e.payload.state=="string"?e.payload.state:n.state};if(e.eventType==="request.resumed")return{...n,state:typeof e.payload.state=="string"?e.payload.state:"resuming"};if(e.eventType==="approval.requested"){const s={...typeof e.payload.approvalId=="string"?{approvalId:e.payload.approvalId}:{},...typeof e.payload.pendingActionId=="string"?{pendingActionId:e.payload.pendingActionId}:{},...typeof e.payload.toolName=="string"?{toolName:e.payload.toolName}:{},status:"pending",...Array.isArray(e.payload.allowedDecisions)?{allowedDecisions:e.payload.allowedDecisions}:{}};return{...n,state:"waiting_for_approval",approval:s}}if(e.eventType==="approval.resolved"){const s=typeof e.payload.decision=="string"?e.payload.decision:void 0,r=s==="approve"?"approved":s==="edit"?"edited":s==="reject"?"rejected":t.approval?.status;return{...n,approval:{...t.approval??{},...typeof e.payload.approvalId=="string"?{approvalId:e.payload.approvalId}:{},...typeof e.payload.pendingActionId=="string"?{pendingActionId:e.payload.pendingActionId}:{},...typeof e.payload.toolName=="string"?{toolName:e.payload.toolName}:{},...r?{status:r}:{}}}}return n}function C(){const t=new Date().toISOString();return{sessionId:"",requestId:"",updatedAt:t,state:"running",plan:{version:0,updatedAt:t,summary:y(),items:[]},output:"",events:[]}}function D(t,e){const n=new Date().toISOString();switch(e.type){case"event":return N(t,e.event);case"content":return{...t,sessionId:e.sessionId,requestId:e.requestId,updatedAt:n,agentId:e.agentId,output:q(t.output,e.content)};case"commentary":return{...t,sessionId:e.sessionId,requestId:e.requestId,updatedAt:n,agentId:e.agentId};case"content-blocks":return{...t,sessionId:e.sessionId,requestId:e.requestId,updatedAt:n,agentId:e.agentId,contentBlocks:e.contentBlocks};case"tool-result":return T({...t,sessionId:e.sessionId,requestId:e.requestId,agentId:e.agentId},e,n);case"plan-state":return E({...t,agentId:e.agentId},e.planState);case"upstream-event":return e.surfaceItem?S({...t,sessionId:e.sessionId,requestId:e.requestId},e.surfaceItem,n):{...t,sessionId:e.sessionId,requestId:e.requestId,updatedAt:n};case"profile-step":const s=l(e.step);return{...t,sessionId:e.sessionId,requestId:e.requestId,updatedAt:n,events:p(t.events,e.step,n),activeEventId:e.step.status==="started"?s:t.activeEventId};case"result":return{...t,sessionId:e.result.sessionId,requestId:e.result.requestId,updatedAt:n,state:e.result.state,agentId:e.result.agentId??t.agentId,output:e.result.output?a(e.result.output,4096):t.output,...e.result.contentBlocks?{contentBlocks:e.result.contentBlocks}:{},...e.result.structuredResponse!==void 0?{structuredResponse:e.result.structuredResponse}:{},...e.result.interruptContent!==void 0?{interruptContent:e.result.interruptContent}:{},...e.result.approvalId||e.result.pendingActionId?{approval:{...t.approval??{},...e.result.approvalId?{approvalId:e.result.approvalId}:{},...e.result.pendingActionId?{pendingActionId:e.result.pendingActionId}:{}}}:{}}}}function _(t){return{id:t.id,kind:t.kind,name:t.name,action:t.action,status:t.status,...t.agentId?{agentId:t.agentId}:{},...t.agentName?{agentName:t.agentName}:{},...t.ownerAgentId?{ownerAgentId:t.ownerAgentId}:{},...t.ownerAgentName?{ownerAgentName:t.ownerAgentName}:{},...t.sourceEventId?{sourceEventId:t.sourceEventId}:{},...t.detail?{detail:t.detail}:{}}}function w(t){switch(t.type){case"commentary":return[{type:"progress.commentary",sessionId:t.sessionId,requestId:t.requestId,agentId:t.agentId,text:t.content}];case"content":return[{type:"output.text.delta",sessionId:t.sessionId,requestId:t.requestId,agentId:t.agentId,text:t.content}];case"content-blocks":return[{type:"output.content-blocks",sessionId:t.sessionId,requestId:t.requestId,agentId:t.agentId,contentBlocks:t.contentBlocks}];case"tool-result":return[{type:"tool.result",sessionId:t.sessionId,requestId:t.requestId,agentId:t.agentId,toolName:t.toolName,output:f(t.output),...t.isError!==void 0?{isError:t.isError}:{}}];case"plan-state":return[{type:"plan.state",sessionId:t.sessionId,requestId:t.requestId,agentId:t.agentId,planState:t.planState},...t.planState.items.map((e,n)=>({type:"plan.step",sessionId:t.sessionId,requestId:t.requestId,agentId:t.agentId,planStateVersion:t.planState.version,index:n,item:e}))];case"upstream-event":return[...t.surfaceItem?[{type:"execution.step",sessionId:t.sessionId,requestId:t.requestId,step:_(t.surfaceItem)}]:[],{type:"debug.upstream",sessionId:t.sessionId,requestId:t.requestId,...t.surfaceItem?{surfaceItem:t.surfaceItem}:{},event:t.event}];case"profile-step":return[{type:"execution.step",sessionId:t.sessionId,requestId:t.requestId,step:t.step},{type:"debug.profile",sessionId:t.sessionId,requestId:t.requestId,step:t.step}];default:return[]}}function H(t){return w(t)[0]??null}export{D as applyRequestStreamItemToSnapshot,C as createInitialRequestEventSnapshot,H as toRequestDataEvent,w as toRequestDataEvents};
|