@dogpile/sdk 0.3.0 → 0.3.1
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/CHANGELOG.md +9 -0
- package/dist/browser/index.js +784 -562
- package/dist/browser/index.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/runtime/broadcast.d.ts.map +1 -1
- package/dist/runtime/broadcast.js +1 -13
- package/dist/runtime/broadcast.js.map +1 -1
- package/dist/runtime/coordinator.d.ts.map +1 -1
- package/dist/runtime/coordinator.js +1 -13
- package/dist/runtime/coordinator.js.map +1 -1
- package/dist/runtime/ids.d.ts +19 -0
- package/dist/runtime/ids.d.ts.map +1 -0
- package/dist/runtime/ids.js +36 -0
- package/dist/runtime/ids.js.map +1 -0
- package/dist/runtime/logger.d.ts +61 -0
- package/dist/runtime/logger.d.ts.map +1 -0
- package/dist/runtime/logger.js +114 -0
- package/dist/runtime/logger.js.map +1 -0
- package/dist/runtime/retry.d.ts +99 -0
- package/dist/runtime/retry.d.ts.map +1 -0
- package/dist/runtime/retry.js +181 -0
- package/dist/runtime/retry.js.map +1 -0
- package/dist/runtime/sequential.d.ts.map +1 -1
- package/dist/runtime/sequential.js +1 -10
- package/dist/runtime/sequential.js.map +1 -1
- package/dist/runtime/shared.d.ts.map +1 -1
- package/dist/runtime/shared.js +1 -13
- package/dist/runtime/shared.js.map +1 -1
- package/dist/runtime/tools/built-in.d.ts +99 -0
- package/dist/runtime/tools/built-in.d.ts.map +1 -0
- package/dist/runtime/tools/built-in.js +577 -0
- package/dist/runtime/tools/built-in.js.map +1 -0
- package/dist/runtime/tools/vercel-ai.d.ts +67 -0
- package/dist/runtime/tools/vercel-ai.d.ts.map +1 -0
- package/dist/runtime/tools/vercel-ai.js +148 -0
- package/dist/runtime/tools/vercel-ai.js.map +1 -0
- package/dist/runtime/tools.d.ts +5 -268
- package/dist/runtime/tools.d.ts.map +1 -1
- package/dist/runtime/tools.js +7 -770
- package/dist/runtime/tools.js.map +1 -1
- package/dist/types/benchmark.d.ts +276 -0
- package/dist/types/benchmark.d.ts.map +1 -0
- package/dist/types/benchmark.js +2 -0
- package/dist/types/benchmark.js.map +1 -0
- package/dist/types/events.d.ts +495 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/events.js +2 -0
- package/dist/types/events.js.map +1 -0
- package/dist/types/replay.d.ts +169 -0
- package/dist/types/replay.d.ts.map +1 -0
- package/dist/types/replay.js +2 -0
- package/dist/types/replay.js.map +1 -0
- package/dist/types.d.ts +6 -935
- package/dist/types.d.ts.map +1 -1
- package/package.json +27 -1
- package/src/index.ts +4 -0
- package/src/runtime/broadcast.ts +1 -16
- package/src/runtime/coordinator.ts +1 -16
- package/src/runtime/ids.ts +41 -0
- package/src/runtime/logger.ts +152 -0
- package/src/runtime/retry.ts +270 -0
- package/src/runtime/sequential.ts +1 -12
- package/src/runtime/shared.ts +1 -16
- package/src/runtime/tools/built-in.ts +875 -0
- package/src/runtime/tools/vercel-ai.ts +269 -0
- package/src/runtime/tools.ts +60 -1255
- package/src/types/benchmark.ts +300 -0
- package/src/types/events.ts +544 -0
- package/src/types/replay.ts +201 -0
- package/src/types.ts +104 -994
|
@@ -0,0 +1,495 @@
|
|
|
1
|
+
import type { BudgetStopReason, CostSummary, JsonObject, ModelRequest, ModelResponse, NormalizedQualityScore, RunEvaluation, RuntimeToolIdentity, RuntimeToolResult, TerminationStopRecord } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Event emitted when a protocol assigns or records an agent role.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* This event normally appears near the beginning of a run and establishes the
|
|
7
|
+
* `agentId`/`role` pair that later turn and transcript records refer to. A
|
|
8
|
+
* renderer can use it to build the participant roster before model output
|
|
9
|
+
* starts streaming.
|
|
10
|
+
*
|
|
11
|
+
* Payload shape:
|
|
12
|
+
*
|
|
13
|
+
* - `type`: always `role-assignment`.
|
|
14
|
+
* - `runId`: stable id shared by every event and trace object for the run.
|
|
15
|
+
* - `at`: ISO-8601 timestamp for when the assignment was emitted.
|
|
16
|
+
* - `agentId`: stable agent id used in events, trace, and transcript entries.
|
|
17
|
+
* - `role`: model-visible role or perspective assigned to that agent.
|
|
18
|
+
*/
|
|
19
|
+
export interface RoleAssignmentEvent {
|
|
20
|
+
/** Discriminant for event rendering and exhaustive switches. */
|
|
21
|
+
readonly type: "role-assignment";
|
|
22
|
+
/** Stable run id shared by all events in one workflow. */
|
|
23
|
+
readonly runId: string;
|
|
24
|
+
/** ISO-8601 event timestamp. */
|
|
25
|
+
readonly at: string;
|
|
26
|
+
/** Agent receiving the role assignment. */
|
|
27
|
+
readonly agentId: string;
|
|
28
|
+
/** Role assigned to the agent. */
|
|
29
|
+
readonly role: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Event emitted when Dogpile is about to ask the configured model provider for
|
|
33
|
+
* one protocol-managed response.
|
|
34
|
+
*
|
|
35
|
+
* @remarks
|
|
36
|
+
* This event is the request-side model activity counterpart to
|
|
37
|
+
* {@link ModelResponseEvent}. Protocol implementations may omit it when they
|
|
38
|
+
* only expose completed turns, but adapters and researcher harnesses can emit
|
|
39
|
+
* it to make provider calls visible in the same streaming event log as agent
|
|
40
|
+
* turns and final output.
|
|
41
|
+
*/
|
|
42
|
+
export interface ModelRequestEvent {
|
|
43
|
+
/** Discriminant for event rendering and exhaustive switches. */
|
|
44
|
+
readonly type: "model-request";
|
|
45
|
+
/** Stable run id shared by all events in one workflow. */
|
|
46
|
+
readonly runId: string;
|
|
47
|
+
/** ISO-8601 event timestamp. */
|
|
48
|
+
readonly at: string;
|
|
49
|
+
/** Stable provider call id within the run. */
|
|
50
|
+
readonly callId: string;
|
|
51
|
+
/** Configured model provider id receiving the request. */
|
|
52
|
+
readonly providerId: string;
|
|
53
|
+
/** Agent requesting the model call. */
|
|
54
|
+
readonly agentId: string;
|
|
55
|
+
/** Agent role for the active model call. */
|
|
56
|
+
readonly role: string;
|
|
57
|
+
/** Provider-neutral request handed to the model adapter. */
|
|
58
|
+
readonly request: ModelRequest;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Event emitted after the configured model provider returns one response.
|
|
62
|
+
*
|
|
63
|
+
* @remarks
|
|
64
|
+
* This event records provider-level model activity without forcing callers to
|
|
65
|
+
* infer it from the higher-level {@link TurnEvent}. The response is the same
|
|
66
|
+
* provider-neutral shape captured in replay traces, so it remains portable and
|
|
67
|
+
* JSON-serializable across Node LTS, Bun, and browser ESM runtimes.
|
|
68
|
+
*/
|
|
69
|
+
export interface ModelResponseEvent {
|
|
70
|
+
/** Discriminant for event rendering and exhaustive switches. */
|
|
71
|
+
readonly type: "model-response";
|
|
72
|
+
/** Stable run id shared by all events in one workflow. */
|
|
73
|
+
readonly runId: string;
|
|
74
|
+
/** ISO-8601 event timestamp. */
|
|
75
|
+
readonly at: string;
|
|
76
|
+
/** Stable provider call id within the run. */
|
|
77
|
+
readonly callId: string;
|
|
78
|
+
/** Configured model provider id that produced the response. */
|
|
79
|
+
readonly providerId: string;
|
|
80
|
+
/** Agent that requested the model call. */
|
|
81
|
+
readonly agentId: string;
|
|
82
|
+
/** Agent role for the completed model call. */
|
|
83
|
+
readonly role: string;
|
|
84
|
+
/** Provider-neutral response returned by the model adapter. */
|
|
85
|
+
readonly response: ModelResponse;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Event emitted while a model turn is still generating text.
|
|
89
|
+
*
|
|
90
|
+
* @remarks
|
|
91
|
+
* `model-output-chunk` lets streaming callers render provider output before
|
|
92
|
+
* the protocol has enough information to commit the completed `agent-turn`
|
|
93
|
+
* transcript entry. It is emitted only when the configured model provider
|
|
94
|
+
* implements {@link ConfiguredModelProvider.stream}; non-streaming providers
|
|
95
|
+
* continue to produce the existing role/turn/final event sequence.
|
|
96
|
+
*
|
|
97
|
+
* Payload shape:
|
|
98
|
+
*
|
|
99
|
+
* - `type`: always `model-output-chunk`.
|
|
100
|
+
* - `runId`: stable id shared by every event and trace object for the run.
|
|
101
|
+
* - `at`: ISO-8601 timestamp for when the chunk was observed.
|
|
102
|
+
* - `agentId` and `role`: identify the active generating agent.
|
|
103
|
+
* - `input`: prompt text visible to that agent for this turn.
|
|
104
|
+
* - `chunkIndex`: zero-based chunk index within this model turn.
|
|
105
|
+
* - `text`: text delta from the provider.
|
|
106
|
+
* - `output`: accumulated output for this turn after applying the chunk.
|
|
107
|
+
*/
|
|
108
|
+
export interface ModelOutputChunkEvent {
|
|
109
|
+
/** Discriminant for event rendering and exhaustive switches. */
|
|
110
|
+
readonly type: "model-output-chunk";
|
|
111
|
+
/** Stable run id shared by all events in one workflow. */
|
|
112
|
+
readonly runId: string;
|
|
113
|
+
/** ISO-8601 event timestamp. */
|
|
114
|
+
readonly at: string;
|
|
115
|
+
/** Agent currently producing output. */
|
|
116
|
+
readonly agentId: string;
|
|
117
|
+
/** Agent role for the active turn. */
|
|
118
|
+
readonly role: string;
|
|
119
|
+
/** Prompt/input visible to the agent for this turn. */
|
|
120
|
+
readonly input: string;
|
|
121
|
+
/** Zero-based chunk index within the active model turn. */
|
|
122
|
+
readonly chunkIndex: number;
|
|
123
|
+
/** Text delta produced by the model provider. */
|
|
124
|
+
readonly text: string;
|
|
125
|
+
/** Accumulated output for this turn after applying this chunk. */
|
|
126
|
+
readonly output: string;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Event emitted when a runtime tool is invoked by protocol or model policy.
|
|
130
|
+
*
|
|
131
|
+
* @remarks
|
|
132
|
+
* Tools are caller-owned escape hatches. This request-side event keeps tool
|
|
133
|
+
* invocation observable without making Dogpile core depend on Node-only
|
|
134
|
+
* capabilities, a storage layer, or a provider-specific function-call shape.
|
|
135
|
+
*/
|
|
136
|
+
export interface ToolCallEvent {
|
|
137
|
+
/** Discriminant for event rendering and exhaustive switches. */
|
|
138
|
+
readonly type: "tool-call";
|
|
139
|
+
/** Stable run id shared by all events in one workflow. */
|
|
140
|
+
readonly runId: string;
|
|
141
|
+
/** ISO-8601 event timestamp. */
|
|
142
|
+
readonly at: string;
|
|
143
|
+
/** Stable tool call id within the run. */
|
|
144
|
+
readonly toolCallId: string;
|
|
145
|
+
/** Tool identity selected for execution. */
|
|
146
|
+
readonly tool: RuntimeToolIdentity;
|
|
147
|
+
/** JSON-serializable tool input. */
|
|
148
|
+
readonly input: JsonObject;
|
|
149
|
+
/** Agent that requested the tool, when agent-scoped. */
|
|
150
|
+
readonly agentId?: string;
|
|
151
|
+
/** Agent role that requested the tool, when available. */
|
|
152
|
+
readonly role?: string;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Event emitted after a runtime tool returns a normalized result.
|
|
156
|
+
*
|
|
157
|
+
* @remarks
|
|
158
|
+
* Tool failures are data at the public boundary. The result payload uses the
|
|
159
|
+
* same discriminated union as runtime tool adapters, allowing log consumers to
|
|
160
|
+
* render successful outputs and normalized errors exhaustively.
|
|
161
|
+
*/
|
|
162
|
+
export interface ToolResultEvent {
|
|
163
|
+
/** Discriminant for event rendering and exhaustive switches. */
|
|
164
|
+
readonly type: "tool-result";
|
|
165
|
+
/** Stable run id shared by all events in one workflow. */
|
|
166
|
+
readonly runId: string;
|
|
167
|
+
/** ISO-8601 event timestamp. */
|
|
168
|
+
readonly at: string;
|
|
169
|
+
/** Stable tool call id within the run. */
|
|
170
|
+
readonly toolCallId: string;
|
|
171
|
+
/** Tool identity that produced the result. */
|
|
172
|
+
readonly tool: RuntimeToolIdentity;
|
|
173
|
+
/** Normalized JSON-serializable tool result. */
|
|
174
|
+
readonly result: RuntimeToolResult;
|
|
175
|
+
/** Agent that requested the tool, when agent-scoped. */
|
|
176
|
+
readonly agentId?: string;
|
|
177
|
+
/** Agent role that requested the tool, when available. */
|
|
178
|
+
readonly role?: string;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Provider-normalized participation decision parsed from paper-style agent output.
|
|
182
|
+
*
|
|
183
|
+
* @remarks
|
|
184
|
+
* Dogpile preserves the raw model text on transcript entries and events. When
|
|
185
|
+
* a model emits the labeled fields `role_selected`, `participation`,
|
|
186
|
+
* `rationale`, and `contribution`, protocols also attach this structured
|
|
187
|
+
* metadata so reproduction harnesses can distinguish contribution from
|
|
188
|
+
* voluntary abstention without reparsing raw text.
|
|
189
|
+
*/
|
|
190
|
+
export interface AgentDecision {
|
|
191
|
+
/** Task-specific role selected by the agent for this turn. */
|
|
192
|
+
readonly selectedRole: string;
|
|
193
|
+
/** Whether the agent contributed or voluntarily abstained. */
|
|
194
|
+
readonly participation: AgentParticipation;
|
|
195
|
+
/** Agent-provided rationale for the selected role and participation choice. */
|
|
196
|
+
readonly rationale: string;
|
|
197
|
+
/** Agent-provided contribution text, or abstention explanation. */
|
|
198
|
+
readonly contribution: string;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Agent participation state for a paper-style turn decision.
|
|
202
|
+
*/
|
|
203
|
+
export type AgentParticipation = "contribute" | "abstain";
|
|
204
|
+
/**
|
|
205
|
+
* Event emitted after one agent contributes a model turn.
|
|
206
|
+
*
|
|
207
|
+
* @remarks
|
|
208
|
+
* `agent-turn` is the primary streaming payload for sequential, coordinator,
|
|
209
|
+
* shared-state, and broadcast executions. It captures the exact prompt/input
|
|
210
|
+
* Dogpile supplied to the agent, the text returned by the model provider, and
|
|
211
|
+
* the cumulative cost after applying that response.
|
|
212
|
+
*
|
|
213
|
+
* The corresponding durable transcript record contains the same
|
|
214
|
+
* `agentId`/`role`/`input`/`output` contribution without event timing or cost
|
|
215
|
+
* fields. Use this event for live progress UIs and the transcript for replay
|
|
216
|
+
* or downstream application logic.
|
|
217
|
+
*
|
|
218
|
+
* Payload shape:
|
|
219
|
+
*
|
|
220
|
+
* - `type`: always `agent-turn`.
|
|
221
|
+
* - `runId`: stable id shared by every event and trace object for the run.
|
|
222
|
+
* - `at`: ISO-8601 timestamp for when the turn completed.
|
|
223
|
+
* - `agentId` and `role`: identify the contributing agent.
|
|
224
|
+
* - `input`: prompt text visible to that agent for this turn.
|
|
225
|
+
* - `output`: generated model text produced by the agent.
|
|
226
|
+
* - `cost`: cumulative token and spend accounting after this turn.
|
|
227
|
+
*/
|
|
228
|
+
export interface TurnEvent {
|
|
229
|
+
/** Discriminant for event rendering and exhaustive switches. */
|
|
230
|
+
readonly type: "agent-turn";
|
|
231
|
+
/** Stable run id shared by all events in one workflow. */
|
|
232
|
+
readonly runId: string;
|
|
233
|
+
/** ISO-8601 event timestamp. */
|
|
234
|
+
readonly at: string;
|
|
235
|
+
/** Agent that produced this turn. */
|
|
236
|
+
readonly agentId: string;
|
|
237
|
+
/** Agent role for this turn. */
|
|
238
|
+
readonly role: string;
|
|
239
|
+
/** Prompt/input visible to the agent for this turn. */
|
|
240
|
+
readonly input: string;
|
|
241
|
+
/** Model output produced by the agent. */
|
|
242
|
+
readonly output: string;
|
|
243
|
+
/** Optional structured role/participation decision parsed from model output. */
|
|
244
|
+
readonly decision?: AgentDecision;
|
|
245
|
+
/** Cumulative cost after this turn. */
|
|
246
|
+
readonly cost: CostSummary;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* One independent contribution captured by a broadcast round event.
|
|
250
|
+
*
|
|
251
|
+
* @remarks
|
|
252
|
+
* Broadcast protocols collect one contribution per participating agent before
|
|
253
|
+
* synthesis. The contribution payload is intentionally smaller than
|
|
254
|
+
* {@link TurnEvent}: it is a round-level summary of model outputs, while the
|
|
255
|
+
* complete prompt/output pair for each agent is still available as individual
|
|
256
|
+
* `agent-turn` events and {@link TranscriptEntry} records.
|
|
257
|
+
*
|
|
258
|
+
* Payload shape:
|
|
259
|
+
*
|
|
260
|
+
* - `agentId`: stable id of the contributing agent.
|
|
261
|
+
* - `role`: model-visible role or perspective used for that contribution.
|
|
262
|
+
* - `output`: generated text contributed independently for the round.
|
|
263
|
+
*/
|
|
264
|
+
export interface BroadcastContribution {
|
|
265
|
+
/** Agent that produced the broadcast contribution. */
|
|
266
|
+
readonly agentId: string;
|
|
267
|
+
/** Agent role for the contribution. */
|
|
268
|
+
readonly role: string;
|
|
269
|
+
/** Independent model output produced for the shared mission. */
|
|
270
|
+
readonly output: string;
|
|
271
|
+
/** Optional structured role/participation decision parsed from model output. */
|
|
272
|
+
readonly decision?: AgentDecision;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Event emitted after agents broadcast independent contributions for a round.
|
|
276
|
+
*
|
|
277
|
+
* @remarks
|
|
278
|
+
* A `broadcast` event marks the coordination moment where independently
|
|
279
|
+
* generated agent outputs are gathered for a shared round. It does not replace
|
|
280
|
+
* per-agent `agent-turn` events; instead, it groups their outputs by round so
|
|
281
|
+
* observers can render the broadcast barrier and replay the paper protocol's
|
|
282
|
+
* independent-contribution step.
|
|
283
|
+
*
|
|
284
|
+
* Payload shape:
|
|
285
|
+
*
|
|
286
|
+
* - `type`: always `broadcast`.
|
|
287
|
+
* - `runId`: stable id shared by every event and trace object for the run.
|
|
288
|
+
* - `at`: ISO-8601 timestamp for when the round finished.
|
|
289
|
+
* - `round`: one-based broadcast round number.
|
|
290
|
+
* - `contributions`: independent outputs collected for this round.
|
|
291
|
+
* - `cost`: cumulative token and spend accounting after the round.
|
|
292
|
+
*/
|
|
293
|
+
export interface BroadcastEvent {
|
|
294
|
+
/** Discriminant for event rendering and exhaustive switches. */
|
|
295
|
+
readonly type: "broadcast";
|
|
296
|
+
/** Stable run id shared by all events in one workflow. */
|
|
297
|
+
readonly runId: string;
|
|
298
|
+
/** ISO-8601 event timestamp. */
|
|
299
|
+
readonly at: string;
|
|
300
|
+
/** One-based broadcast round number. */
|
|
301
|
+
readonly round: number;
|
|
302
|
+
/** Independent contributions collected in this broadcast round. */
|
|
303
|
+
readonly contributions: readonly BroadcastContribution[];
|
|
304
|
+
/** Cumulative cost after this broadcast round. */
|
|
305
|
+
readonly cost: CostSummary;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Event emitted when a workflow halts because a configured budget cap fired.
|
|
309
|
+
*
|
|
310
|
+
* @remarks
|
|
311
|
+
* `budget-stop` records the normalized cap class that stopped execution before
|
|
312
|
+
* the final event closes the run. The detail object is JSON-serializable so
|
|
313
|
+
* callers can persist or replay the exact cap, observed value, and limit.
|
|
314
|
+
*/
|
|
315
|
+
export interface BudgetStopEvent {
|
|
316
|
+
/** Discriminant for event rendering and exhaustive switches. */
|
|
317
|
+
readonly type: "budget-stop";
|
|
318
|
+
/** Stable run id shared by all events in one workflow. */
|
|
319
|
+
readonly runId: string;
|
|
320
|
+
/** ISO-8601 event timestamp. */
|
|
321
|
+
readonly at: string;
|
|
322
|
+
/** Normalized machine-readable budget stop reason. */
|
|
323
|
+
readonly reason: BudgetStopReason;
|
|
324
|
+
/** Total cost at the stop point. */
|
|
325
|
+
readonly cost: CostSummary;
|
|
326
|
+
/** Completed model-turn iterations at the stop point. */
|
|
327
|
+
readonly iteration: number;
|
|
328
|
+
/** Elapsed runtime in milliseconds at the stop point. */
|
|
329
|
+
readonly elapsedMs: number;
|
|
330
|
+
/** Serializable cap diagnostics. */
|
|
331
|
+
readonly detail: JsonObject;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Link from a terminal event to the completed trace transcript.
|
|
335
|
+
*
|
|
336
|
+
* @remarks
|
|
337
|
+
* Final events are emitted before callers await {@link StreamHandle.result},
|
|
338
|
+
* so this compact link tells streaming UIs exactly which transcript artifact
|
|
339
|
+
* the terminal output closes over without duplicating every transcript entry
|
|
340
|
+
* inside the event log.
|
|
341
|
+
*/
|
|
342
|
+
export interface TranscriptLink {
|
|
343
|
+
/** Discriminant for future transcript link variants. */
|
|
344
|
+
readonly kind: "trace-transcript";
|
|
345
|
+
/** Number of transcript entries included in the completed trace. */
|
|
346
|
+
readonly entryCount: number;
|
|
347
|
+
/** Zero-based index of the last transcript entry, or `null` for empty runs. */
|
|
348
|
+
readonly lastEntryIndex: number | null;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Event emitted when a workflow produces its final output.
|
|
352
|
+
*
|
|
353
|
+
* @remarks
|
|
354
|
+
* `final` is the terminal streaming event for a successful run. Its `output`
|
|
355
|
+
* value matches {@link RunResult.output}, and its `cost` value matches the
|
|
356
|
+
* final aggregate cost returned on the result. Its `transcript` link points to
|
|
357
|
+
* the completed {@link Trace.transcript} entries that produced the terminal
|
|
358
|
+
* output.
|
|
359
|
+
*
|
|
360
|
+
* Payload shape:
|
|
361
|
+
*
|
|
362
|
+
* - `type`: always `final`.
|
|
363
|
+
* - `runId`: stable id shared by every event and trace object for the run.
|
|
364
|
+
* - `at`: ISO-8601 timestamp for when final synthesis completed.
|
|
365
|
+
* - `output`: final synthesized answer returned to the caller.
|
|
366
|
+
* - `cost`: total token and spend accounting for the run.
|
|
367
|
+
* - `transcript`: compact link to the completed trace transcript.
|
|
368
|
+
*/
|
|
369
|
+
export interface FinalEvent {
|
|
370
|
+
/** Discriminant for event rendering and exhaustive switches. */
|
|
371
|
+
readonly type: "final";
|
|
372
|
+
/** Stable run id shared by all events in one workflow. */
|
|
373
|
+
readonly runId: string;
|
|
374
|
+
/** ISO-8601 event timestamp. */
|
|
375
|
+
readonly at: string;
|
|
376
|
+
/** Final synthesized answer returned as `RunResult.output`. */
|
|
377
|
+
readonly output: string;
|
|
378
|
+
/** Total cost at completion. */
|
|
379
|
+
readonly cost: CostSummary;
|
|
380
|
+
/** Link to the completed trace transcript. */
|
|
381
|
+
readonly transcript: TranscriptLink;
|
|
382
|
+
/** Optional normalized quality score supplied by a caller-owned evaluator. */
|
|
383
|
+
readonly quality?: NormalizedQualityScore;
|
|
384
|
+
/** Optional serializable evaluation payload supplied by a caller-owned evaluator. */
|
|
385
|
+
readonly evaluation?: RunEvaluation;
|
|
386
|
+
/** Termination condition that stopped the run, when the run ended by policy. */
|
|
387
|
+
readonly termination?: TerminationStopRecord;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Successful coordination event emitted by Dogpile and persisted in traces.
|
|
391
|
+
*
|
|
392
|
+
* @remarks
|
|
393
|
+
* `RunEvent` is the discriminated union stored in {@link Trace.events} and
|
|
394
|
+
* used by low-level protocol emit callbacks. Switch on `type` to handle each
|
|
395
|
+
* coordination moment exhaustively:
|
|
396
|
+
*
|
|
397
|
+
* - `role-assignment`: participant/role roster was established.
|
|
398
|
+
* - `model-request`: one provider-neutral model request was started.
|
|
399
|
+
* - `model-response`: one provider-neutral model response completed.
|
|
400
|
+
* - `model-output-chunk`: one streaming model text delta arrived.
|
|
401
|
+
* - `tool-call`: one runtime tool invocation was started.
|
|
402
|
+
* - `tool-result`: one runtime tool invocation completed.
|
|
403
|
+
* - `agent-turn`: one agent completed a prompt/response turn.
|
|
404
|
+
* - `broadcast`: a broadcast round gathered independent contributions.
|
|
405
|
+
* - `budget-stop`: a configured budget cap halted further model turns.
|
|
406
|
+
* - `final`: the run completed and produced the final output.
|
|
407
|
+
*
|
|
408
|
+
* Every variant is JSON-serializable and includes `runId` plus an ISO-8601
|
|
409
|
+
* `at` timestamp so callers can persist, render, or replay the event log
|
|
410
|
+
* without SDK-owned storage.
|
|
411
|
+
*
|
|
412
|
+
* @example
|
|
413
|
+
* ```ts
|
|
414
|
+
* for await (const event of Dogpile.stream(options)) {
|
|
415
|
+
* switch (event.type) {
|
|
416
|
+
* case "agent-turn":
|
|
417
|
+
* console.log(event.agentId, event.output);
|
|
418
|
+
* break;
|
|
419
|
+
* case "final":
|
|
420
|
+
* console.log(event.output);
|
|
421
|
+
* break;
|
|
422
|
+
* }
|
|
423
|
+
* }
|
|
424
|
+
* ```
|
|
425
|
+
*/
|
|
426
|
+
export type RunEvent = RoleAssignmentEvent | ModelRequestEvent | ModelResponseEvent | ModelOutputChunkEvent | ToolCallEvent | ToolResultEvent | TurnEvent | BroadcastEvent | BudgetStopEvent | FinalEvent;
|
|
427
|
+
/**
|
|
428
|
+
* Model activity events yielded by `stream()` and persisted in traces when a
|
|
429
|
+
* protocol exposes provider-call boundaries.
|
|
430
|
+
*/
|
|
431
|
+
export type ModelActivityEvent = ModelRequestEvent | ModelResponseEvent | ModelOutputChunkEvent;
|
|
432
|
+
/**
|
|
433
|
+
* Tool activity events yielded by `stream()` and persisted in traces when a
|
|
434
|
+
* protocol or caller-owned adapter invokes runtime tools.
|
|
435
|
+
*/
|
|
436
|
+
export type ToolActivityEvent = ToolCallEvent | ToolResultEvent;
|
|
437
|
+
/**
|
|
438
|
+
* Lifecycle event yielded by `stream()`.
|
|
439
|
+
*
|
|
440
|
+
* These events describe workflow coordination state rather than model text.
|
|
441
|
+
* Role assignment establishes the participant roster, while `budget-stop`
|
|
442
|
+
* records a lifecycle halt before the terminal completion event.
|
|
443
|
+
*/
|
|
444
|
+
export type StreamLifecycleEvent = RoleAssignmentEvent | BudgetStopEvent;
|
|
445
|
+
/**
|
|
446
|
+
* Output event yielded by `stream()`.
|
|
447
|
+
*
|
|
448
|
+
* These events carry generated agent output or grouped round output while a
|
|
449
|
+
* workflow is still running.
|
|
450
|
+
*/
|
|
451
|
+
export type StreamOutputEvent = ModelActivityEvent | ToolActivityEvent | TurnEvent | BroadcastEvent;
|
|
452
|
+
/**
|
|
453
|
+
* Error event yielded by `stream()` when execution rejects.
|
|
454
|
+
*
|
|
455
|
+
* @remarks
|
|
456
|
+
* Stream errors are emitted before {@link StreamHandle.result} rejects so UIs
|
|
457
|
+
* and log collectors can record a terminal failure without wrapping the result
|
|
458
|
+
* promise. The error payload is JSON-serializable and intentionally omits
|
|
459
|
+
* runtime-specific values such as `Error.stack`.
|
|
460
|
+
*/
|
|
461
|
+
export interface StreamErrorEvent {
|
|
462
|
+
/** Discriminant for stream event handling. */
|
|
463
|
+
readonly type: "error";
|
|
464
|
+
/** Stable run id when known; empty when failure happened before protocol startup. */
|
|
465
|
+
readonly runId: string;
|
|
466
|
+
/** ISO-8601 event timestamp. */
|
|
467
|
+
readonly at: string;
|
|
468
|
+
/** Error name when available. */
|
|
469
|
+
readonly name: string;
|
|
470
|
+
/** Human-readable error message. */
|
|
471
|
+
readonly message: string;
|
|
472
|
+
/** Optional serializable diagnostics supplied by the SDK. */
|
|
473
|
+
readonly detail?: JsonObject;
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Completion event yielded by `stream()` after successful execution.
|
|
477
|
+
*/
|
|
478
|
+
export type StreamCompletionEvent = FinalEvent;
|
|
479
|
+
/**
|
|
480
|
+
* Public streaming event union returned by `stream()`.
|
|
481
|
+
*
|
|
482
|
+
* @remarks
|
|
483
|
+
* The union is grouped into lifecycle, output, error, and completion families:
|
|
484
|
+
*
|
|
485
|
+
* - lifecycle: {@link StreamLifecycleEvent}
|
|
486
|
+
* - output: {@link StreamOutputEvent}
|
|
487
|
+
* - error: {@link StreamErrorEvent}
|
|
488
|
+
* - completion: {@link StreamCompletionEvent}
|
|
489
|
+
*
|
|
490
|
+
* Successful stream events are also persisted as {@link RunEvent} values in the
|
|
491
|
+
* completed trace. `error` is stream-only because a failed run has no completed
|
|
492
|
+
* {@link RunResult} trace to return.
|
|
493
|
+
*/
|
|
494
|
+
export type StreamEvent = StreamLifecycleEvent | StreamOutputEvent | StreamErrorEvent | StreamCompletionEvent;
|
|
495
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACX,UAAU,EAIV,YAAY,EACZ,aAAa,EACb,sBAAsB,EAEtB,aAAa,EACb,mBAAmB,EAEnB,iBAAiB,EACjB,qBAAqB,EACtB,MAAM,aAAa,CAAC;AAGrB;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,mBAAmB;IAClC,gEAAgE;IAChE,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IACjC,0DAA0D;IAC1D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,gCAAgC;IA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M,MAAM,kBAAkB,GAAG,iBAAiB,GAAG,kBAAkB,GAAG,qBAAqB,CAAC;AAEhG;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG,eAAe,CAAC;AAEhE;;;;;;GAMG;AACH,MAAM,MAAM,oBAAoB,GAAG,mBAAmB,GAAG,eAAe,CAAC;AAEzE;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,kBAAkB,GAAG,iBAAiB,GAAG,SAAS,GAAG,cAAc,CAAC;AAEpG;;;;;;;;GAQG;AACH,MAAM,WAAW,gBAAgB;IAC/B,8CAA8C;IAC9C,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,qFAAqF;IACrF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,gCAAgC;IAChC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,iCAAiC;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oCAAoC;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,6DAA6D;IAC7D,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,UAAU,CAAC;AAE/C;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,WAAW,GAAG,oBAAoB,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import type { AgentSpec, Budget, BudgetStopReason, CostSummary, ModelRequest, ModelResponse, Protocol, ProtocolConfig, RunEvent, RuntimeToolIdentity, TerminationCondition, Tier, TranscriptLink } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Version tag for the replay trace artifact schema.
|
|
4
|
+
*/
|
|
5
|
+
export type ReplayTraceSchemaVersion = "1.0";
|
|
6
|
+
/**
|
|
7
|
+
* Serializable seed metadata recorded with replay traces.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* Most providers do not expose deterministic seed control. Dogpile still
|
|
11
|
+
* records an explicit empty seed artifact so replay consumers can distinguish
|
|
12
|
+
* "no seed supplied" from a missing trace field.
|
|
13
|
+
*/
|
|
14
|
+
export interface ReplayTraceSeed {
|
|
15
|
+
/** Seed artifact discriminant. */
|
|
16
|
+
readonly kind: "replay-trace-seed";
|
|
17
|
+
/** Seed source visible to replay tooling. */
|
|
18
|
+
readonly source: "caller" | "none";
|
|
19
|
+
/** Caller-supplied seed value, or `null` when no seed was supplied. */
|
|
20
|
+
readonly value: string | number | null;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Normalized run inputs persisted inside the replay trace artifact.
|
|
24
|
+
*/
|
|
25
|
+
export interface ReplayTraceRunInputs {
|
|
26
|
+
/** Run input artifact discriminant. */
|
|
27
|
+
readonly kind: "replay-trace-run-inputs";
|
|
28
|
+
/** Mission or intent supplied by the caller. */
|
|
29
|
+
readonly intent: string;
|
|
30
|
+
/** Exact normalized protocol config used for execution. */
|
|
31
|
+
readonly protocol: ProtocolConfig;
|
|
32
|
+
/** Selected cost/quality tier. */
|
|
33
|
+
readonly tier: Tier;
|
|
34
|
+
/** Configured model provider id. */
|
|
35
|
+
readonly modelProviderId: string;
|
|
36
|
+
/** Concrete agent roster visible to the protocol. */
|
|
37
|
+
readonly agents: readonly AgentSpec[];
|
|
38
|
+
/** Temperature supplied to provider requests. */
|
|
39
|
+
readonly temperature: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Budget and stop-policy artifact persisted inside replay traces.
|
|
43
|
+
*/
|
|
44
|
+
export interface ReplayTraceBudget {
|
|
45
|
+
/** Budget artifact discriminant. */
|
|
46
|
+
readonly kind: "replay-trace-budget";
|
|
47
|
+
/** Selected cost/quality tier. */
|
|
48
|
+
readonly tier: Tier;
|
|
49
|
+
/** Optional hard caps supplied by the caller. */
|
|
50
|
+
readonly caps?: Omit<Budget, "tier">;
|
|
51
|
+
/** Optional composable termination policy used by the protocol. */
|
|
52
|
+
readonly termination?: TerminationCondition;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Budget state snapshot derived from a cost-bearing trace event.
|
|
56
|
+
*
|
|
57
|
+
* @remarks
|
|
58
|
+
* Replay consumers can inspect this artifact without walking the full event
|
|
59
|
+
* log. Entries are emitted for model-turn accounting changes, coordination
|
|
60
|
+
* barriers that expose cumulative cost, budget stops, and final completion.
|
|
61
|
+
*/
|
|
62
|
+
export interface ReplayTraceBudgetStateChange {
|
|
63
|
+
/** Budget state artifact discriminant. */
|
|
64
|
+
readonly kind: "replay-trace-budget-state-change";
|
|
65
|
+
/** Zero-based event index that exposed this budget state. */
|
|
66
|
+
readonly eventIndex: number;
|
|
67
|
+
/** Source event type for the budget state. */
|
|
68
|
+
readonly eventType: "agent-turn" | "broadcast" | "budget-stop" | "final";
|
|
69
|
+
/** ISO-8601 timestamp from the source event. */
|
|
70
|
+
readonly at: string;
|
|
71
|
+
/** Cumulative cost visible at this point in the run. */
|
|
72
|
+
readonly cost: CostSummary;
|
|
73
|
+
/** Completed model-turn iteration count when known. */
|
|
74
|
+
readonly iteration?: number;
|
|
75
|
+
/** Elapsed runtime in milliseconds when known. */
|
|
76
|
+
readonly elapsedMs?: number;
|
|
77
|
+
/** Budget stop reason when this state records a halt. */
|
|
78
|
+
readonly budgetReason?: BudgetStopReason;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Provider-neutral protocol decision kinds recorded for replay.
|
|
82
|
+
*/
|
|
83
|
+
export type ReplayTraceProtocolDecisionType = "assign-role" | "select-agent-turn" | "start-model-call" | "complete-model-call" | "observe-model-output" | "start-tool-call" | "complete-tool-call" | "collect-broadcast-round" | "stop-for-budget" | "finalize-output";
|
|
84
|
+
/**
|
|
85
|
+
* Protocol-level decision appended during execution.
|
|
86
|
+
*/
|
|
87
|
+
export interface ReplayTraceProtocolDecision {
|
|
88
|
+
/** Decision artifact discriminant. */
|
|
89
|
+
readonly kind: "replay-trace-protocol-decision";
|
|
90
|
+
/** Zero-based event index that produced this decision. */
|
|
91
|
+
readonly eventIndex: number;
|
|
92
|
+
/** Event type that records the decision. */
|
|
93
|
+
readonly eventType: RunEvent["type"];
|
|
94
|
+
/** Coordination protocol that made the decision. */
|
|
95
|
+
readonly protocol: Protocol;
|
|
96
|
+
/** Provider-neutral decision kind for replay tooling. */
|
|
97
|
+
readonly decision: ReplayTraceProtocolDecisionType;
|
|
98
|
+
/** ISO-8601 timestamp from the source event. */
|
|
99
|
+
readonly at: string;
|
|
100
|
+
/** Agent involved in the decision, when agent-scoped. */
|
|
101
|
+
readonly agentId?: string;
|
|
102
|
+
/** Role involved in the decision, when agent-scoped. */
|
|
103
|
+
readonly role?: string;
|
|
104
|
+
/** Provider call involved in the decision, when model-scoped. */
|
|
105
|
+
readonly callId?: string;
|
|
106
|
+
/** Provider involved in the decision, when model-scoped. */
|
|
107
|
+
readonly providerId?: string;
|
|
108
|
+
/** Tool call involved in the decision, when tool-scoped. */
|
|
109
|
+
readonly toolCallId?: string;
|
|
110
|
+
/** Tool identity involved in the decision, when tool-scoped. */
|
|
111
|
+
readonly tool?: RuntimeToolIdentity;
|
|
112
|
+
/** One-based protocol turn for turn-scoped decisions. */
|
|
113
|
+
readonly turn?: number;
|
|
114
|
+
/** Coordinator phase for coordinator protocol turn decisions. */
|
|
115
|
+
readonly phase?: "plan" | "worker" | "final-synthesis";
|
|
116
|
+
/** One-based broadcast round for grouped broadcast decisions. */
|
|
117
|
+
readonly round?: number;
|
|
118
|
+
/** Number of transcript entries visible after this decision. */
|
|
119
|
+
readonly transcriptEntryCount?: number;
|
|
120
|
+
/** Number of contributions collected at a broadcast barrier. */
|
|
121
|
+
readonly contributionCount?: number;
|
|
122
|
+
/** Prompt/input associated with turn decisions. */
|
|
123
|
+
readonly input?: string;
|
|
124
|
+
/** Output associated with turn or final decisions. */
|
|
125
|
+
readonly output?: string;
|
|
126
|
+
/** Cumulative cost visible at this decision point. */
|
|
127
|
+
readonly cost?: CostSummary;
|
|
128
|
+
/** Normalized budget stop reason for budget-stop decisions. */
|
|
129
|
+
readonly budgetReason?: BudgetStopReason;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Provider call metadata and response captured for replay inspection.
|
|
133
|
+
*/
|
|
134
|
+
export interface ReplayTraceProviderCall {
|
|
135
|
+
/** Provider call artifact discriminant. */
|
|
136
|
+
readonly kind: "replay-trace-provider-call";
|
|
137
|
+
/** Stable call id within the run. */
|
|
138
|
+
readonly callId: string;
|
|
139
|
+
/** Configured model provider id. */
|
|
140
|
+
readonly providerId: string;
|
|
141
|
+
/** ISO-8601 timestamp before the provider call started. */
|
|
142
|
+
readonly startedAt: string;
|
|
143
|
+
/** ISO-8601 timestamp after the provider call completed. */
|
|
144
|
+
readonly completedAt: string;
|
|
145
|
+
/** Agent that requested this provider call. */
|
|
146
|
+
readonly agentId: string;
|
|
147
|
+
/** Role that requested this provider call. */
|
|
148
|
+
readonly role: string;
|
|
149
|
+
/** Request handed to the configured model provider. */
|
|
150
|
+
readonly request: ModelRequest;
|
|
151
|
+
/** Response returned by the configured model provider. */
|
|
152
|
+
readonly response: ModelResponse;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Final output artifact persisted inside replay traces.
|
|
156
|
+
*/
|
|
157
|
+
export interface ReplayTraceFinalOutput {
|
|
158
|
+
/** Final output artifact discriminant. */
|
|
159
|
+
readonly kind: "replay-trace-final-output";
|
|
160
|
+
/** Final synthesized output returned by the run. */
|
|
161
|
+
readonly output: string;
|
|
162
|
+
/** Total cost at completion. */
|
|
163
|
+
readonly cost: CostSummary;
|
|
164
|
+
/** ISO-8601 completion timestamp from the terminal event. */
|
|
165
|
+
readonly completedAt: string;
|
|
166
|
+
/** Link to the completed transcript artifact. */
|
|
167
|
+
readonly transcript: TranscriptLink;
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=replay.d.ts.map
|