@assemble-dev/sdk 0.0.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.
@@ -0,0 +1,588 @@
1
+ import { ModelAdapter } from '@assemble-dev/providers';
2
+ import { JsonValue } from '@assemble-dev/shared-types/json';
3
+ import { AppError } from '@assemble-dev/shared-utils/errors';
4
+ import { z } from 'zod';
5
+ import { RunMessage, RunState, TokenUsage, PolicyAction, PolicyDecision, RunArtifact, RunStatus } from '@assemble-dev/shared-types/runs';
6
+ import { TraceEvent } from '@assemble-dev/shared-types/trace-events';
7
+ import { RedactionMode } from '@assemble-dev/shared-utils/redaction';
8
+
9
+ type AgentStartHookContext = {
10
+ agentName: string;
11
+ input: JsonValue;
12
+ };
13
+ type AgentCompleteHookContext<TOutput> = {
14
+ agentName: string;
15
+ output: TOutput;
16
+ };
17
+ type AgentErrorHookContext = {
18
+ agentName: string;
19
+ error: AppError;
20
+ };
21
+ type AgentConfig<TOutput = string> = {
22
+ name: string;
23
+ role: string;
24
+ model: ModelAdapter;
25
+ instructions: string;
26
+ allowedToolNames?: string[];
27
+ inputSchema?: z.ZodType<JsonValue>;
28
+ outputSchema?: z.ZodType<TOutput>;
29
+ maxSteps?: number;
30
+ timeoutMs?: number;
31
+ costBudgetUsd?: number;
32
+ fallbackModelName?: string;
33
+ onAgentStart?: (context: AgentStartHookContext) => void;
34
+ onAgentComplete?: (context: AgentCompleteHookContext<TOutput>) => void;
35
+ onAgentError?: (context: AgentErrorHookContext) => void;
36
+ };
37
+ type AgentDefinition<TOutput = string> = Readonly<Omit<AgentConfig<TOutput>, "maxSteps"> & {
38
+ maxSteps: number;
39
+ }>;
40
+ declare function agent<TOutput = string>(config: AgentConfig<TOutput>): AgentDefinition<TOutput>;
41
+
42
+ type MemoryProvider = {
43
+ getMemoryValue(key: string): Promise<JsonValue | null>;
44
+ setMemoryValue(key: string, value: JsonValue): Promise<void>;
45
+ appendMemoryValue(key: string, value: JsonValue): Promise<void>;
46
+ listMemoryKeys(): Promise<string[]>;
47
+ };
48
+
49
+ type ThreadMemoryOptions = {
50
+ provider: MemoryProvider;
51
+ threadKey: string;
52
+ };
53
+ type ThreadMemory = {
54
+ appendThreadMessage(message: RunMessage): Promise<void>;
55
+ listThreadMessages(): Promise<RunMessage[]>;
56
+ };
57
+ declare function createThreadMemory(options: ThreadMemoryOptions): ThreadMemory;
58
+
59
+ type TraceSink = {
60
+ name: string;
61
+ writeTraceEvent(event: TraceEvent): void | Promise<void>;
62
+ flush?(): Promise<void>;
63
+ close?(): void;
64
+ };
65
+
66
+ type TraceSinkFailure = {
67
+ sinkName: string;
68
+ operation: "write" | "flush";
69
+ error: Error;
70
+ };
71
+ type TraceSinkErrorHandler = (failure: TraceSinkFailure) => void;
72
+ type CreateTraceBusInput = {
73
+ runId: string;
74
+ workflowName: string;
75
+ input: JsonValue;
76
+ sinks: TraceSink[];
77
+ now?: () => Date;
78
+ initialRunState?: RunState;
79
+ onSinkError?: TraceSinkErrorHandler;
80
+ };
81
+ type TraceBus = {
82
+ emitTraceEvent(event: TraceEvent): TraceEvent;
83
+ getRunState(): RunState;
84
+ listTraceEvents(): readonly TraceEvent[];
85
+ flushSinks(): Promise<void>;
86
+ closeSinks(): void;
87
+ };
88
+ declare function createTraceBus(busInput: CreateTraceBusInput): TraceBus;
89
+
90
+ type AgentRunResult<TOutput = string> = {
91
+ output: TOutput;
92
+ rawText: string;
93
+ tokenUsage: TokenUsage;
94
+ latencyMs: number;
95
+ agentCallEventId: string;
96
+ };
97
+
98
+ type RunAgentInput<TOutput = string> = {
99
+ definition: AgentDefinition<TOutput>;
100
+ input: JsonValue;
101
+ traceBus: TraceBus;
102
+ parentEventId?: string;
103
+ threadMemory?: ThreadMemory;
104
+ now?: () => Date;
105
+ };
106
+ declare function runAgent<TOutput = string>(runInput: RunAgentInput<TOutput>): Promise<AgentRunResult<TOutput>>;
107
+
108
+ declare const ToolRetryConfigSchema: z.ZodObject<{
109
+ maxAttempts: z.ZodNumber;
110
+ }, z.core.$strip>;
111
+ type ToolRetryConfig = z.infer<typeof ToolRetryConfigSchema>;
112
+ declare const ToolDefinitionOptionsSchema: z.ZodObject<{
113
+ name: z.ZodString;
114
+ description: z.ZodString;
115
+ allowedAgentNames: z.ZodOptional<z.ZodArray<z.ZodString>>;
116
+ requiresApproval: z.ZodOptional<z.ZodBoolean>;
117
+ retry: z.ZodOptional<z.ZodObject<{
118
+ maxAttempts: z.ZodNumber;
119
+ }, z.core.$strip>>;
120
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
121
+ sensitiveFieldNames: z.ZodOptional<z.ZodArray<z.ZodString>>;
122
+ dryRun: z.ZodOptional<z.ZodBoolean>;
123
+ }, z.core.$strip>;
124
+ type ToolDefinitionOptions = z.infer<typeof ToolDefinitionOptionsSchema>;
125
+ type ToolDefinitionConfig<TInput extends JsonValue, TOutput extends JsonValue> = ToolDefinitionOptions & {
126
+ inputSchema: z.ZodType<TInput>;
127
+ outputSchema?: z.ZodType<TOutput>;
128
+ execute: (input: TInput) => Promise<TOutput>;
129
+ };
130
+ type ToolDefinition<TInput extends JsonValue, TOutput extends JsonValue> = {
131
+ readonly name: string;
132
+ readonly description: string;
133
+ readonly inputSchema: z.ZodType<TInput>;
134
+ readonly outputSchema: z.ZodType<TOutput> | null;
135
+ readonly execute: (input: TInput) => Promise<TOutput>;
136
+ readonly allowedAgentNames: string[] | null;
137
+ readonly requiresApproval: boolean;
138
+ readonly retry: ToolRetryConfig;
139
+ readonly timeoutMs: number | null;
140
+ readonly sensitiveFieldNames: string[];
141
+ readonly dryRun: boolean;
142
+ };
143
+ declare function tool<TInput extends JsonValue, TOutput extends JsonValue>(config: ToolDefinitionConfig<TInput, TOutput>): ToolDefinition<TInput, TOutput>;
144
+
145
+ type ToolPolicyContext = {
146
+ toolName: string;
147
+ agentName: string;
148
+ input: JsonValue;
149
+ };
150
+ type ToolPolicyRuleResult = boolean | string;
151
+ type ToolPolicyRule = (context: ToolPolicyContext) => ToolPolicyRuleResult;
152
+ type ToolPolicy = {
153
+ name: string;
154
+ appliesToToolNames?: string[];
155
+ block?: ToolPolicyRule;
156
+ requireApproval?: ToolPolicyRule;
157
+ redact?: ToolPolicyRule;
158
+ logOnly?: ToolPolicyRule;
159
+ };
160
+
161
+ type ToolCallErrorCode = "VALIDATION_FAILED" | "EXECUTION_FAILED";
162
+ type ToolCallError = {
163
+ code: ToolCallErrorCode;
164
+ message: string;
165
+ };
166
+ type ToolCallCompletedOutcome = {
167
+ status: "completed";
168
+ output: JsonValue;
169
+ toolRequestEventId: string;
170
+ latencyMs: number;
171
+ };
172
+ type ToolCallFailedOutcome = {
173
+ status: "failed";
174
+ error: ToolCallError;
175
+ };
176
+ type ToolCallBlockedOutcome = {
177
+ status: "blocked";
178
+ reason: string;
179
+ };
180
+ type ToolCallAwaitingApprovalOutcome = {
181
+ status: "awaiting_approval";
182
+ approvalId: string;
183
+ toolRequestEventId: string;
184
+ };
185
+ type ToolCallOutcome = ToolCallCompletedOutcome | ToolCallFailedOutcome | ToolCallBlockedOutcome | ToolCallAwaitingApprovalOutcome;
186
+
187
+ type GrantedToolApproval = {
188
+ approvalId: string;
189
+ toolRequestEventId: string | null;
190
+ };
191
+ type ExecuteToolCallInput<TInput extends JsonValue, TOutput extends JsonValue> = {
192
+ tool: ToolDefinition<TInput, TOutput>;
193
+ agentName: string;
194
+ input: JsonValue;
195
+ policies?: ToolPolicy[];
196
+ traceBus: TraceBus;
197
+ redactionMode?: RedactionMode;
198
+ parentEventId?: string;
199
+ now?: () => Date;
200
+ mockExecution?: (input: TInput) => JsonValue;
201
+ grantedApproval?: GrantedToolApproval;
202
+ };
203
+ declare function executeToolCall<TInput extends JsonValue, TOutput extends JsonValue>(callInput: ExecuteToolCallInput<TInput, TOutput>): Promise<ToolCallOutcome>;
204
+
205
+ type WorkflowMemoryConfig = {
206
+ provider: MemoryProvider;
207
+ };
208
+ declare function resolveWorkflowMemoryConfig(config?: WorkflowMemoryConfig): WorkflowMemoryConfig;
209
+
210
+ type RunWorkflowOptions = {
211
+ sinks?: TraceSink[];
212
+ runId?: string;
213
+ now?: () => Date;
214
+ runStateDirectory?: string;
215
+ persistRunState?: boolean;
216
+ };
217
+ type WorkflowRunCompletedResult<TOutput extends JsonValue = JsonValue> = {
218
+ status: "completed";
219
+ runId: string;
220
+ output: TOutput;
221
+ state: RunState;
222
+ events: readonly TraceEvent[];
223
+ };
224
+ type WorkflowRunAwaitingApprovalResult = {
225
+ status: "awaiting_approval";
226
+ runId: string;
227
+ approvalId: string;
228
+ state: RunState;
229
+ events: readonly TraceEvent[];
230
+ };
231
+ type WorkflowRunResult<TOutput extends JsonValue = JsonValue> = WorkflowRunCompletedResult<TOutput> | WorkflowRunAwaitingApprovalResult;
232
+ type WorkflowResumeRejectedResult = {
233
+ status: "rejected";
234
+ runId: string;
235
+ state: RunState;
236
+ events: readonly TraceEvent[];
237
+ };
238
+ type WorkflowResumeResult<TOutput extends JsonValue = JsonValue> = WorkflowRunResult<TOutput> | WorkflowResumeRejectedResult;
239
+
240
+ declare const finishWorkflow = "__finish__";
241
+ declare const defaultSupervisorMaxSteps = 10;
242
+ declare const defaultParallelMergedArtifactKey = "parallel:merged";
243
+ type WorkflowRouteContext = {
244
+ state: RunState;
245
+ stepIndex: number;
246
+ lastAgentName: string | null;
247
+ lastOutput: JsonValue | null;
248
+ };
249
+ type WorkflowRouteDecision = {
250
+ agentName: string;
251
+ reason: string;
252
+ };
253
+ type WorkflowRouteTarget = string | WorkflowRouteDecision;
254
+ type WorkflowRouteFunction = (context: WorkflowRouteContext) => Promise<WorkflowRouteTarget> | WorkflowRouteTarget;
255
+ type WorkflowSupervisorStopWhen = (context: WorkflowRouteContext) => boolean;
256
+ declare const PipelineTopologySchema: z.ZodObject<{
257
+ kind: z.ZodLiteral<"pipeline">;
258
+ }, z.core.$strip>;
259
+ type PipelineTopology = z.infer<typeof PipelineTopologySchema>;
260
+ declare const SupervisorTopologySchema: z.ZodObject<{
261
+ kind: z.ZodLiteral<"supervisor">;
262
+ supervisorName: z.ZodString;
263
+ route: z.ZodCustom<WorkflowRouteFunction, WorkflowRouteFunction>;
264
+ maxSteps: z.ZodOptional<z.ZodNumber>;
265
+ stopWhen: z.ZodOptional<z.ZodCustom<WorkflowSupervisorStopWhen, WorkflowSupervisorStopWhen>>;
266
+ }, z.core.$strip>;
267
+ type SupervisorTopology = z.infer<typeof SupervisorTopologySchema>;
268
+ declare const ParallelTopologySchema: z.ZodObject<{
269
+ kind: z.ZodLiteral<"parallel">;
270
+ agentNames: z.ZodOptional<z.ZodArray<z.ZodString>>;
271
+ mergedArtifactKey: z.ZodOptional<z.ZodString>;
272
+ }, z.core.$strip>;
273
+ type ParallelTopology = z.infer<typeof ParallelTopologySchema>;
274
+ declare const WorkflowTopologySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
275
+ kind: z.ZodLiteral<"pipeline">;
276
+ }, z.core.$strip>, z.ZodObject<{
277
+ kind: z.ZodLiteral<"supervisor">;
278
+ supervisorName: z.ZodString;
279
+ route: z.ZodCustom<WorkflowRouteFunction, WorkflowRouteFunction>;
280
+ maxSteps: z.ZodOptional<z.ZodNumber>;
281
+ stopWhen: z.ZodOptional<z.ZodCustom<WorkflowSupervisorStopWhen, WorkflowSupervisorStopWhen>>;
282
+ }, z.core.$strip>, z.ZodObject<{
283
+ kind: z.ZodLiteral<"parallel">;
284
+ agentNames: z.ZodOptional<z.ZodArray<z.ZodString>>;
285
+ mergedArtifactKey: z.ZodOptional<z.ZodString>;
286
+ }, z.core.$strip>], "kind">;
287
+ type WorkflowTopology = z.infer<typeof WorkflowTopologySchema>;
288
+ declare const defaultWorkflowTopology: WorkflowTopology;
289
+
290
+ type WorkflowAgentDefinition = Omit<AgentDefinition<JsonValue>, "onAgentComplete"> & {
291
+ onAgentComplete?(context: AgentCompleteHookContext<JsonValue>): void;
292
+ };
293
+ type WorkflowToolDefinition = Omit<ToolDefinition<JsonValue, JsonValue>, "execute"> & {
294
+ execute(input: JsonValue): Promise<JsonValue>;
295
+ };
296
+ type WorkflowAgentToolBindingContext = {
297
+ state: RunState;
298
+ stepIndex: number;
299
+ agentOutput: JsonValue;
300
+ };
301
+ type WorkflowAgentToolBinding = {
302
+ agentName: string;
303
+ toolName: string;
304
+ buildToolInput(context: WorkflowAgentToolBindingContext): JsonValue;
305
+ };
306
+ type WorkflowStopConditionContext = {
307
+ state: RunState;
308
+ stepIndex: number;
309
+ };
310
+ type WorkflowStopCondition = (context: WorkflowStopConditionContext) => boolean;
311
+ type WorkflowConfig<TInput extends JsonValue, TOutput extends JsonValue> = {
312
+ name: string;
313
+ inputSchema: z.ZodType<TInput>;
314
+ outputSchema?: z.ZodType<TOutput>;
315
+ agents: WorkflowAgentDefinition[];
316
+ tools?: WorkflowToolDefinition[];
317
+ agentToolBindings?: WorkflowAgentToolBinding[];
318
+ topology?: WorkflowTopology;
319
+ policies?: ToolPolicy[];
320
+ memory?: WorkflowMemoryConfig;
321
+ stopCondition?: WorkflowStopCondition;
322
+ continueOnAgentFailure?: boolean;
323
+ };
324
+ type WorkflowDefinition<TInput extends JsonValue, TOutput extends JsonValue> = {
325
+ readonly name: string;
326
+ readonly inputSchema: z.ZodType<TInput>;
327
+ readonly outputSchema: z.ZodType<TOutput> | null;
328
+ readonly agents: readonly WorkflowAgentDefinition[];
329
+ readonly tools: readonly WorkflowToolDefinition[];
330
+ readonly agentToolBindings: readonly WorkflowAgentToolBinding[];
331
+ readonly topology: WorkflowTopology;
332
+ readonly policies: readonly ToolPolicy[];
333
+ readonly memory: WorkflowMemoryConfig | null;
334
+ readonly stopCondition: WorkflowStopCondition | null;
335
+ readonly continueOnAgentFailure: boolean;
336
+ run(input: TInput, options?: RunWorkflowOptions): Promise<WorkflowRunResult<TOutput>>;
337
+ };
338
+ declare function workflow<TInput extends JsonValue, TOutput extends JsonValue = JsonValue>(config: WorkflowConfig<TInput, TOutput>): WorkflowDefinition<TInput, TOutput>;
339
+
340
+ type TeamConfig = {
341
+ name: string;
342
+ description?: string;
343
+ agents: WorkflowAgentDefinition[];
344
+ };
345
+ type TeamDefinition = {
346
+ readonly name: string;
347
+ readonly description: string;
348
+ readonly agents: readonly WorkflowAgentDefinition[];
349
+ readonly agentNames: readonly string[];
350
+ };
351
+ declare function team(config: TeamConfig): TeamDefinition;
352
+
353
+ type BuildPipelineTeamWorkflowConfigInput<TInput extends JsonValue, TOutput extends JsonValue> = {
354
+ team: TeamDefinition;
355
+ name: string;
356
+ inputSchema: z.ZodType<TInput>;
357
+ outputSchema?: z.ZodType<TOutput>;
358
+ };
359
+ declare function buildPipelineTeamWorkflowConfig<TInput extends JsonValue, TOutput extends JsonValue = JsonValue>(input: BuildPipelineTeamWorkflowConfigInput<TInput, TOutput>): WorkflowConfig<TInput, TOutput>;
360
+ type BuildSupervisorTeamWorkflowConfigInput<TInput extends JsonValue, TOutput extends JsonValue> = {
361
+ team: TeamDefinition;
362
+ name: string;
363
+ supervisorName: string;
364
+ route: WorkflowRouteFunction;
365
+ inputSchema: z.ZodType<TInput>;
366
+ outputSchema?: z.ZodType<TOutput>;
367
+ maxSteps?: number;
368
+ };
369
+ declare function buildSupervisorTeamWorkflowConfig<TInput extends JsonValue, TOutput extends JsonValue = JsonValue>(input: BuildSupervisorTeamWorkflowConfigInput<TInput, TOutput>): WorkflowConfig<TInput, TOutput>;
370
+ type BuildReviewPanelWorkflowConfigInput<TInput extends JsonValue> = {
371
+ team: TeamDefinition;
372
+ name: string;
373
+ inputSchema: z.ZodType<TInput>;
374
+ };
375
+ declare function buildReviewPanelWorkflowConfig<TInput extends JsonValue>(input: BuildReviewPanelWorkflowConfigInput<TInput>): WorkflowConfig<TInput, JsonValue>;
376
+
377
+ declare function policy(config: ToolPolicy): ToolPolicy;
378
+
379
+ type EvaluateToolPoliciesInput = {
380
+ policies: ToolPolicy[];
381
+ context: ToolPolicyContext;
382
+ timestamp: string;
383
+ };
384
+ type ToolPolicyEvaluation = {
385
+ action: PolicyAction;
386
+ reason: string;
387
+ policyName: string;
388
+ decisions: PolicyDecision[];
389
+ };
390
+ declare function evaluateToolPolicies(input: EvaluateToolPoliciesInput): ToolPolicyEvaluation;
391
+
392
+ type ArtifactStoreOptions = {
393
+ provider: MemoryProvider;
394
+ runId: string;
395
+ };
396
+ type ArtifactStore = {
397
+ saveRunArtifact(artifact: RunArtifact): Promise<void>;
398
+ getRunArtifact(key: string): Promise<RunArtifact | null>;
399
+ listRunArtifacts(): Promise<RunArtifact[]>;
400
+ };
401
+ declare function createArtifactStore(options: ArtifactStoreOptions): ArtifactStore;
402
+
403
+ type RunWorkflowInput<TInput extends JsonValue, TOutput extends JsonValue> = {
404
+ definition: WorkflowDefinition<TInput, TOutput>;
405
+ input: TInput;
406
+ options?: RunWorkflowOptions;
407
+ };
408
+
409
+ declare function runWorkflow<TInput extends JsonValue, TOutput extends JsonValue>(runInput: RunWorkflowInput<TInput, TOutput>): Promise<WorkflowRunResult<TOutput>>;
410
+
411
+ type ResumeRunDecision = {
412
+ approved: boolean;
413
+ approvedBy: string;
414
+ reason?: string;
415
+ };
416
+ type ResumeRunInput<TInput extends JsonValue, TOutput extends JsonValue> = {
417
+ definition: WorkflowDefinition<TInput, TOutput>;
418
+ runId: string;
419
+ decision: ResumeRunDecision;
420
+ options?: RunWorkflowOptions;
421
+ };
422
+ declare function resumeRun<TInput extends JsonValue, TOutput extends JsonValue>(resumeInput: ResumeRunInput<TInput, TOutput>): Promise<WorkflowResumeResult<TOutput>>;
423
+
424
+ declare const defaultRunStateDirectory: string;
425
+ declare function resolveRunStateFilePath(runId: string, directory?: string): string;
426
+ type LoadRunStateFileInput = {
427
+ runId: string;
428
+ directory?: string;
429
+ };
430
+ declare function loadRunStateFile(input: LoadRunStateFileInput): RunState;
431
+
432
+ declare function createInMemoryMemoryProvider(): MemoryProvider;
433
+
434
+ type JsonFileMemoryProviderOptions = {
435
+ filePath: string;
436
+ };
437
+ declare function createJsonFileMemoryProvider(options: JsonFileMemoryProviderOptions): MemoryProvider;
438
+
439
+ type ConsoleSinkOptions = {
440
+ writeLine?: (line: string) => void;
441
+ useColor?: boolean;
442
+ };
443
+ declare function createConsoleSink(options?: ConsoleSinkOptions): TraceSink;
444
+ declare function formatTraceEventLine(event: TraceEvent, useColor: boolean): string;
445
+
446
+ type JsonlSinkOptions = {
447
+ runId: string;
448
+ directory?: string;
449
+ };
450
+ declare const defaultTraceDirectory: string;
451
+ declare function resolveTraceFilePath(runId: string, directory?: string): string;
452
+ declare function createJsonlSink(options: JsonlSinkOptions): TraceSink;
453
+
454
+ type CreateInitialRunStateInput = {
455
+ runId: string;
456
+ workflowName: string;
457
+ input: JsonValue;
458
+ createdAt: string;
459
+ };
460
+ declare function createInitialRunState(input: CreateInitialRunStateInput): RunState;
461
+ declare function applyTraceEventToRunState(state: RunState, event: TraceEvent): RunState;
462
+
463
+ type PlatformFetchResponse = {
464
+ ok: boolean;
465
+ status: number;
466
+ };
467
+ type PlatformFetchRequest = {
468
+ method: string;
469
+ headers: {
470
+ [headerName: string]: string;
471
+ };
472
+ body: string;
473
+ };
474
+ type PlatformFetchImplementation = (url: string, request: PlatformFetchRequest) => Promise<PlatformFetchResponse>;
475
+ type PlatformUploadStats = {
476
+ uploadedEventCount: number;
477
+ droppedEventCount: number;
478
+ failedBatchCount: number;
479
+ };
480
+ type CreatePlatformTraceSinkOptions = {
481
+ apiKey: string;
482
+ baseUrl?: string;
483
+ runId: string;
484
+ workflowName: string;
485
+ redactionMode?: RedactionMode;
486
+ sensitiveFieldNames?: string[];
487
+ batchSize?: number;
488
+ maxQueueSize?: number;
489
+ fetchImplementation?: PlatformFetchImplementation;
490
+ onUploadError?: (error: Error) => void;
491
+ };
492
+ type PlatformTraceSink = TraceSink & {
493
+ flush(): Promise<void>;
494
+ close(): void;
495
+ getUploadStats(): PlatformUploadStats;
496
+ };
497
+ declare function createPlatformTraceSink(options: CreatePlatformTraceSinkOptions): PlatformTraceSink;
498
+
499
+ declare const PlatformConfigSchema: z.ZodObject<{
500
+ apiKey: z.ZodNullable<z.ZodString>;
501
+ baseUrl: z.ZodString;
502
+ dashboardUrl: z.ZodString;
503
+ }, z.core.$strip>;
504
+ type PlatformConfig = z.infer<typeof PlatformConfigSchema>;
505
+ type ResolvePlatformConfigOptions = {
506
+ apiKey?: string;
507
+ baseUrl?: string;
508
+ dashboardUrl?: string;
509
+ homeDirectory?: string;
510
+ environmentVariables?: Record<string, string | undefined>;
511
+ };
512
+ declare function resolvePlatformConfig(options?: ResolvePlatformConfigOptions): PlatformConfig;
513
+
514
+ type BuildHostedTraceUrlInput = {
515
+ dashboardUrl: string;
516
+ runId: string;
517
+ };
518
+ declare function buildMissingKeyMessage(): string;
519
+ declare function buildHostedTraceUrl(input: BuildHostedTraceUrlInput): string;
520
+
521
+ type ReplayRunOptions = {
522
+ fromStepIndex?: number;
523
+ mockTools?: boolean;
524
+ sinks?: TraceSink[];
525
+ runStateDirectory?: string;
526
+ traceDirectory?: string;
527
+ now?: () => Date;
528
+ replayRunId?: string;
529
+ };
530
+ type ReplayRunInput<TInput extends JsonValue, TOutput extends JsonValue> = {
531
+ definition: WorkflowDefinition<TInput, TOutput>;
532
+ sourceRunId: string;
533
+ options?: ReplayRunOptions;
534
+ };
535
+ type ReplayRunResult = {
536
+ status: "completed" | "awaiting_approval";
537
+ runId: string;
538
+ sourceRunId: string;
539
+ output: JsonValue | null;
540
+ approvalId: string | null;
541
+ state: RunState;
542
+ events: readonly TraceEvent[];
543
+ };
544
+ declare function replayRun<TInput extends JsonValue, TOutput extends JsonValue>(replayInput: ReplayRunInput<TInput, TOutput>): Promise<ReplayRunResult>;
545
+
546
+ declare const maxReplayOutputDiffCount = 50;
547
+ type CompareRunToReplayInput = {
548
+ original: RunState;
549
+ replay: RunState;
550
+ };
551
+ type ReplayOutputDiff = {
552
+ path: string;
553
+ original: JsonValue | null;
554
+ replay: JsonValue | null;
555
+ };
556
+ type ReplayLatencyComparison = {
557
+ originalMs: number | null;
558
+ replayMs: number | null;
559
+ deltaMs: number | null;
560
+ };
561
+ type ReplayTokenUsageComparison = {
562
+ original: TokenUsage | null;
563
+ replay: TokenUsage | null;
564
+ };
565
+ type ReplayRunComparison = {
566
+ statusMatches: boolean;
567
+ originalStatus: RunStatus;
568
+ replayStatus: RunStatus;
569
+ outputMatches: boolean;
570
+ outputDiff: ReplayOutputDiff[];
571
+ latency: ReplayLatencyComparison;
572
+ tokenUsage: ReplayTokenUsageComparison;
573
+ routingMatches: boolean;
574
+ };
575
+ declare function compareRunToReplay(input: CompareRunToReplayInput): ReplayRunComparison;
576
+
577
+ type LoadReplaySourceInput = {
578
+ runId: string;
579
+ runStateDirectory?: string;
580
+ traceDirectory?: string;
581
+ };
582
+ type ReplaySource = {
583
+ state: RunState;
584
+ events: TraceEvent[];
585
+ };
586
+ declare function loadReplaySource(input: LoadReplaySourceInput): ReplaySource;
587
+
588
+ export { type AgentCompleteHookContext, type AgentConfig, type AgentDefinition, type AgentErrorHookContext, type AgentRunResult, type AgentStartHookContext, type ArtifactStore, type BuildPipelineTeamWorkflowConfigInput, type BuildReviewPanelWorkflowConfigInput, type BuildSupervisorTeamWorkflowConfigInput, type CompareRunToReplayInput, type ConsoleSinkOptions, type CreateInitialRunStateInput, type CreatePlatformTraceSinkOptions, type CreateTraceBusInput, type ExecuteToolCallInput, type GrantedToolApproval, type JsonlSinkOptions, type LoadReplaySourceInput, type MemoryProvider, type ParallelTopology, type PipelineTopology, type PlatformConfig, type PlatformFetchImplementation, type PlatformFetchRequest, type PlatformFetchResponse, type PlatformTraceSink, type PlatformUploadStats, type ReplayLatencyComparison, type ReplayOutputDiff, type ReplayRunComparison, type ReplayRunInput, type ReplayRunOptions, type ReplayRunResult, type ReplaySource, type ReplayTokenUsageComparison, type ResolvePlatformConfigOptions, type ResumeRunDecision, type ResumeRunInput, type RunAgentInput, type RunWorkflowInput, type RunWorkflowOptions, type SupervisorTopology, type TeamConfig, type TeamDefinition, type ThreadMemory, type ToolCallAwaitingApprovalOutcome, type ToolCallBlockedOutcome, type ToolCallCompletedOutcome, type ToolCallError, type ToolCallFailedOutcome, type ToolCallOutcome, type ToolDefinition, type ToolDefinitionConfig, type ToolPolicy, type ToolPolicyContext, type ToolPolicyEvaluation, type ToolPolicyRule, type ToolPolicyRuleResult, type ToolRetryConfig, type TraceBus, type TraceSink, type WorkflowAgentDefinition, type WorkflowAgentToolBinding, type WorkflowAgentToolBindingContext, type WorkflowConfig, type WorkflowDefinition, type WorkflowMemoryConfig, type WorkflowResumeRejectedResult, type WorkflowResumeResult, type WorkflowRouteContext, type WorkflowRouteDecision, type WorkflowRouteFunction, type WorkflowRouteTarget, type WorkflowRunAwaitingApprovalResult, type WorkflowRunCompletedResult, type WorkflowRunResult, type WorkflowToolDefinition, type WorkflowTopology, agent, applyTraceEventToRunState, buildHostedTraceUrl, buildMissingKeyMessage, buildPipelineTeamWorkflowConfig, buildReviewPanelWorkflowConfig, buildSupervisorTeamWorkflowConfig, compareRunToReplay, createArtifactStore, createConsoleSink, createInMemoryMemoryProvider, createInitialRunState, createJsonFileMemoryProvider, createJsonlSink, createPlatformTraceSink, createThreadMemory, createTraceBus, defaultParallelMergedArtifactKey, defaultRunStateDirectory, defaultSupervisorMaxSteps, defaultTraceDirectory, defaultWorkflowTopology, evaluateToolPolicies, executeToolCall, finishWorkflow, formatTraceEventLine, loadReplaySource, loadRunStateFile, maxReplayOutputDiffCount, policy, replayRun, resolvePlatformConfig, resolveRunStateFilePath, resolveTraceFilePath, resolveWorkflowMemoryConfig, resumeRun, runAgent, runWorkflow, team, tool, workflow };