@runtypelabs/sdk 1.17.1 → 1.18.0

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 CHANGED
@@ -98,7 +98,7 @@ const summary = await runtype
98
98
  { streamResponse: true },
99
99
  {
100
100
  onStepStart: (event) => console.log('Starting:', event.name),
101
- onStepChunk: (chunk) => process.stdout.write(chunk),
101
+ onStepDelta: (text) => process.stdout.write(text),
102
102
  onStepComplete: (result, event) => console.log('Done:', event.name),
103
103
  onFlowComplete: (event) => console.log('Complete!'),
104
104
  }
@@ -184,7 +184,7 @@ const allResults = await flowResult.getAllResults()
184
184
  interface StreamCallbacks {
185
185
  onFlowStart?: (event: FlowStartEvent) => void
186
186
  onStepStart?: (event: StepStartEvent) => void
187
- onStepChunk?: (chunk: string, event: StepChunkEvent) => void
187
+ onStepDelta?: (text: string, event: StepDeltaEvent) => void
188
188
  onStepComplete?: (result: any, event: StepCompleteEvent) => void
189
189
  onFlowComplete?: (event: FlowCompleteEvent) => void
190
190
  onError?: (error: Error) => void
package/dist/index.cjs CHANGED
@@ -189,13 +189,9 @@ function handleEvent(event, callbacks, results, summary) {
189
189
  case "step_start":
190
190
  callbacks.onStepStart?.(event);
191
191
  break;
192
- case "step_delta": {
193
- const chunkText = event.chunk || event.text || "";
194
- const deltaEvent = event;
195
- callbacks.onStepDelta?.(chunkText, deltaEvent);
196
- callbacks.onStepChunk?.(chunkText, deltaEvent);
192
+ case "step_delta":
193
+ callbacks.onStepDelta?.(event.text, event);
197
194
  break;
198
- }
199
195
  case "step_complete":
200
196
  results.set(event.name, event.result);
201
197
  callbacks.onStepComplete?.(event.result, event);
@@ -253,10 +249,6 @@ async function* streamEvents(response) {
253
249
  for (const eventStr of events) {
254
250
  try {
255
251
  const event = JSON.parse(eventStr);
256
- if (event.type === "step_delta" && "text" in event && !("chunk" in event)) {
257
- ;
258
- event.chunk = event.text;
259
- }
260
252
  yield event;
261
253
  } catch {
262
254
  }
@@ -266,10 +258,6 @@ async function* streamEvents(response) {
266
258
  if (finalEvent) {
267
259
  try {
268
260
  const event = JSON.parse(finalEvent);
269
- if (event.type === "step_delta" && "text" in event && !("chunk" in event)) {
270
- ;
271
- event.chunk = event.text;
272
- }
273
261
  yield event;
274
262
  } catch {
275
263
  }
@@ -379,7 +367,7 @@ var FlowResult = class {
379
367
  * ```typescript
380
368
  * const summary = await result.stream({
381
369
  * onStepStart: (event) => console.log('Starting:', event.name),
382
- * onStepChunk: (chunk) => process.stdout.write(chunk),
370
+ * onStepDelta: (text) => process.stdout.write(text),
383
371
  * onStepComplete: (result, event) => console.log('Done:', event.name),
384
372
  * onFlowComplete: (event) => console.log('Flow complete!'),
385
373
  * })
@@ -983,7 +971,7 @@ var RuntypeFlowBuilder = class {
983
971
  ...callbacks,
984
972
  onFlowStart: (event) => callbacks?.onFlowStart?.(event),
985
973
  onStepStart: (event) => callbacks?.onStepStart?.(event),
986
- onStepChunk: (chunk, event) => callbacks?.onStepChunk?.(chunk, event),
974
+ onStepDelta: (text, event) => callbacks?.onStepDelta?.(text, event),
987
975
  onStepComplete: (result, event) => callbacks?.onStepComplete?.(result, event),
988
976
  onFlowComplete: (event) => callbacks?.onFlowComplete?.(event),
989
977
  onError: (error) => callbacks?.onError?.(error)
@@ -1013,11 +1001,9 @@ var RuntypeFlowBuilder = class {
1013
1001
  case "step_start":
1014
1002
  wrappedCallbacks.onStepStart?.(event);
1015
1003
  break;
1016
- case "step_delta": {
1017
- const chunkText = awaitEvent.chunk || awaitEvent.text || "";
1018
- wrappedCallbacks.onStepChunk?.(chunkText, event);
1004
+ case "step_delta":
1005
+ wrappedCallbacks.onStepDelta?.(event.text, event);
1019
1006
  break;
1020
- }
1021
1007
  case "step_complete": {
1022
1008
  accumulatedSummary.results?.set(event.name, event.result);
1023
1009
  wrappedCallbacks.onStepComplete?.(event.result, event);
@@ -1467,7 +1453,7 @@ var PromptRunner = class {
1467
1453
  *
1468
1454
  * // Process with callbacks
1469
1455
  * await result.stream({
1470
- * onStepChunk: (chunk) => process.stdout.write(chunk),
1456
+ * onStepDelta: (text) => process.stdout.write(text),
1471
1457
  * onFlowComplete: () => console.log('Done!'),
1472
1458
  * })
1473
1459
  * ```
@@ -4376,6 +4362,15 @@ function dispatchAgentEvent(event, callbacks) {
4376
4362
  case "agent_tool_complete":
4377
4363
  callbacks.onToolComplete?.(typedData);
4378
4364
  break;
4365
+ case "agent_media":
4366
+ callbacks.onMedia?.(typedData);
4367
+ break;
4368
+ case "agent_approval_start":
4369
+ callbacks.onApprovalStart?.(typedData);
4370
+ break;
4371
+ case "agent_approval_complete":
4372
+ callbacks.onApprovalComplete?.(typedData);
4373
+ break;
4379
4374
  case "agent_iteration_complete":
4380
4375
  callbacks.onIterationComplete?.(typedData);
4381
4376
  break;
@@ -7671,7 +7666,7 @@ var ClientFlowBuilder = class extends FlowBuilder {
7671
7666
  };
7672
7667
  function isStreamCallbacks(obj) {
7673
7668
  if (!obj || typeof obj !== "object") return false;
7674
- return "onFlowStart" in obj || "onStepStart" in obj || "onStepDelta" in obj || "onStepChunk" in obj || "onStepComplete" in obj || "onFlowComplete" in obj || "onError" in obj;
7669
+ return "onFlowStart" in obj || "onStepStart" in obj || "onStepDelta" in obj || "onStepComplete" in obj || "onFlowComplete" in obj || "onError" in obj;
7675
7670
  }
7676
7671
  function createExternalTool(config) {
7677
7672
  return {
@@ -7786,7 +7781,7 @@ var RuntypeClient2 = class {
7786
7781
  ...callbacks,
7787
7782
  onFlowStart: (event) => callbacks?.onFlowStart?.(event),
7788
7783
  onStepStart: (event) => callbacks?.onStepStart?.(event),
7789
- onStepChunk: (chunk, event) => callbacks?.onStepChunk?.(chunk, event),
7784
+ onStepDelta: (text, event) => callbacks?.onStepDelta?.(text, event),
7790
7785
  onStepComplete: (result, event) => callbacks?.onStepComplete?.(result, event),
7791
7786
  onFlowComplete: (event) => callbacks?.onFlowComplete?.(event),
7792
7787
  onError: (error) => callbacks?.onError?.(error)
@@ -7821,12 +7816,9 @@ var RuntypeClient2 = class {
7821
7816
  case "step_start":
7822
7817
  wrappedCallbacks.onStepStart?.(event);
7823
7818
  break;
7824
- case "step_delta": {
7825
- const deltaEvent = event;
7826
- const chunkText = deltaEvent.chunk || deltaEvent.text || "";
7827
- wrappedCallbacks.onStepChunk?.(chunkText, deltaEvent);
7819
+ case "step_delta":
7820
+ wrappedCallbacks.onStepDelta?.(event.text, event);
7828
7821
  break;
7829
- }
7830
7822
  case "step_complete": {
7831
7823
  summary.results?.set(event.name, event.result);
7832
7824
  wrappedCallbacks.onStepComplete?.(event.result, event);
package/dist/index.d.cts CHANGED
@@ -428,7 +428,7 @@ interface BuiltInTool {
428
428
  id: string;
429
429
  name: string;
430
430
  description: string;
431
- category: 'image_generation' | 'web_search' | 'web_scraping' | 'code_execution' | 'file_operations' | 'data_analysis' | 'knowledge_retrieval' | 'text_to_speech' | 'voice_processing' | 'third_party_api' | 'artifact' | 'data_management' | 'commerce';
431
+ category: 'image_generation' | 'web_search' | 'web_scraping' | 'code_execution' | 'file_operations' | 'data_analysis' | 'knowledge_retrieval' | 'text_to_speech' | 'voice_processing' | 'third_party_api' | 'artifact' | 'data_management' | 'commerce' | 'browser';
432
432
  providers: string[];
433
433
  parametersSchema: JSONSchema;
434
434
  defaultConfig?: JsonObject;
@@ -1278,11 +1278,10 @@ interface StepStartEvent {
1278
1278
  interface StepDeltaEvent {
1279
1279
  type: 'step_delta';
1280
1280
  id: string;
1281
- chunk: string;
1282
1281
  index: number;
1282
+ /** Streaming text fragment. */
1283
+ text: string;
1283
1284
  }
1284
- /** @deprecated Use StepDeltaEvent instead */
1285
- type StepChunkEvent = StepDeltaEvent;
1286
1285
  interface StepCompleteEvent {
1287
1286
  type: 'step_complete';
1288
1287
  id: string;
@@ -1329,13 +1328,8 @@ interface StreamCallbacks {
1329
1328
  onFlowStart?: (event: FlowStartEvent) => void;
1330
1329
  /** Called when a step starts executing */
1331
1330
  onStepStart?: (event: StepStartEvent) => void;
1332
- /** Called for each chunk of streaming output from a step */
1333
- onStepDelta?: (chunk: string, event: StepDeltaEvent) => void;
1334
- /**
1335
- * @deprecated Use onStepDelta instead
1336
- * Called for each chunk of streaming output from a step
1337
- */
1338
- onStepChunk?: (chunk: string, event: StepDeltaEvent) => void;
1331
+ /** Called for each text fragment of streaming output from a step */
1332
+ onStepDelta?: (text: string, event: StepDeltaEvent) => void;
1339
1333
  /** Called when a step completes */
1340
1334
  onStepComplete?: (result: any, event: StepCompleteEvent) => void;
1341
1335
  /** Called when the entire flow completes */
@@ -1735,7 +1729,7 @@ declare function createExternalTool(config: {
1735
1729
  *
1736
1730
  * // Option 1: Process with callbacks
1737
1731
  * const summary = await result.stream({
1738
- * onStepChunk: (chunk) => process.stdout.write(chunk),
1732
+ * onStepDelta: (text) => process.stdout.write(text),
1739
1733
  * })
1740
1734
  *
1741
1735
  * // Option 2: Just get a specific step's result
@@ -1771,7 +1765,7 @@ declare class FlowResult {
1771
1765
  * ```typescript
1772
1766
  * const summary = await result.stream({
1773
1767
  * onStepStart: (event) => console.log('Starting:', event.name),
1774
- * onStepChunk: (chunk) => process.stdout.write(chunk),
1768
+ * onStepDelta: (text) => process.stdout.write(text),
1775
1769
  * onStepComplete: (result, event) => console.log('Done:', event.name),
1776
1770
  * onFlowComplete: (event) => console.log('Flow complete!'),
1777
1771
  * })
@@ -2232,7 +2226,7 @@ declare class RuntypeFlowBuilder {
2232
2226
  *
2233
2227
  * // Process with callbacks
2234
2228
  * await result.stream({
2235
- * onStepChunk: (chunk) => process.stdout.write(chunk),
2229
+ * onStepDelta: (text) => process.stdout.write(text),
2236
2230
  * onFlowComplete: () => console.log('Done!'),
2237
2231
  * })
2238
2232
  *
@@ -2769,7 +2763,7 @@ declare class PromptRunner {
2769
2763
  *
2770
2764
  * // Process with callbacks
2771
2765
  * await result.stream({
2772
- * onStepChunk: (chunk) => process.stdout.write(chunk),
2766
+ * onStepDelta: (text) => process.stdout.write(text),
2773
2767
  * onFlowComplete: () => console.log('Done!'),
2774
2768
  * })
2775
2769
  * ```
@@ -4116,7 +4110,7 @@ declare class ClientTokensEndpoint {
4116
4110
  /**
4117
4111
  * Agent event types for streaming
4118
4112
  */
4119
- type AgentEventType = 'agent_start' | 'agent_iteration_start' | 'agent_turn_start' | 'agent_turn_delta' | 'agent_turn_complete' | 'agent_tool_start' | 'agent_tool_delta' | 'agent_tool_input_delta' | 'agent_tool_input_complete' | 'agent_tool_complete' | 'agent_iteration_complete' | 'agent_reflection' | 'agent_complete' | 'agent_error' | 'agent_ping' | 'agent_await';
4113
+ type AgentEventType = 'agent_start' | 'agent_iteration_start' | 'agent_turn_start' | 'agent_turn_delta' | 'agent_turn_complete' | 'agent_tool_start' | 'agent_tool_delta' | 'agent_tool_input_delta' | 'agent_tool_input_complete' | 'agent_tool_complete' | 'agent_media' | 'agent_approval_start' | 'agent_approval_complete' | 'agent_iteration_complete' | 'agent_reflection' | 'agent_complete' | 'agent_error' | 'agent_ping' | 'agent_await';
4120
4114
  /**
4121
4115
  * Base agent event with common fields
4122
4116
  */
@@ -4247,6 +4241,59 @@ interface AgentToolCompleteEvent extends BaseAgentEvent {
4247
4241
  result?: unknown;
4248
4242
  executionTime?: number;
4249
4243
  }
4244
+ interface AgentMediaEvent extends BaseAgentEvent {
4245
+ type: 'agent_media';
4246
+ iteration: number;
4247
+ toolCallId: string;
4248
+ toolName: string;
4249
+ media: Array<{
4250
+ type: 'media';
4251
+ data: string;
4252
+ mediaType: string;
4253
+ annotations?: {
4254
+ audience?: ('user' | 'assistant')[];
4255
+ };
4256
+ } | {
4257
+ type: 'image-url';
4258
+ url: string;
4259
+ mediaType?: string;
4260
+ annotations?: {
4261
+ audience?: ('user' | 'assistant')[];
4262
+ };
4263
+ } | {
4264
+ type: 'file-url';
4265
+ url: string;
4266
+ mediaType: string;
4267
+ annotations?: {
4268
+ audience?: ('user' | 'assistant')[];
4269
+ };
4270
+ }>;
4271
+ }
4272
+ /**
4273
+ * Agent approval start event — execution paused waiting for user approval.
4274
+ */
4275
+ interface AgentApprovalStartEvent extends BaseAgentEvent {
4276
+ type: 'agent_approval_start';
4277
+ approvalId: string;
4278
+ iteration?: number;
4279
+ toolCallId: string;
4280
+ toolName: string;
4281
+ toolType: string;
4282
+ description: string;
4283
+ parameters?: Record<string, unknown>;
4284
+ timeout: number;
4285
+ startedAt: string;
4286
+ }
4287
+ /**
4288
+ * Agent approval complete event — user or system resolved the approval.
4289
+ */
4290
+ interface AgentApprovalCompleteEvent extends BaseAgentEvent {
4291
+ type: 'agent_approval_complete';
4292
+ approvalId: string;
4293
+ decision: 'approved' | 'denied' | 'timeout';
4294
+ completedAt: string;
4295
+ resolvedBy: 'user' | 'system';
4296
+ }
4250
4297
  /**
4251
4298
  * Agent iteration complete event
4252
4299
  */
@@ -4312,7 +4359,7 @@ interface AgentPingEvent extends BaseAgentEvent {
4312
4359
  timestamp: string;
4313
4360
  }
4314
4361
  /**
4315
- * Agent await event (execution awaiting local tool result from client).
4362
+ * API-emitted agent await event for local tools that must execute on the client.
4316
4363
  */
4317
4364
  interface AgentPausedEvent extends BaseAgentEvent {
4318
4365
  type: 'agent_await';
@@ -4349,7 +4396,7 @@ interface LocalToolExecutionCompleteEvent {
4349
4396
  /**
4350
4397
  * Union of all agent event types
4351
4398
  */
4352
- type AgentEvent = AgentStartEvent | AgentIterationStartEvent | AgentTurnStartEvent | AgentTurnDeltaEvent | AgentTurnCompleteEvent | AgentToolStartEvent | AgentToolDeltaEvent | AgentToolInputDeltaEvent | AgentToolInputCompleteEvent | AgentToolCompleteEvent | AgentIterationCompleteEvent | AgentReflectionEvent | AgentCompleteEvent | AgentErrorEvent | AgentPingEvent | AgentPausedEvent;
4399
+ type AgentEvent = AgentStartEvent | AgentIterationStartEvent | AgentTurnStartEvent | AgentTurnDeltaEvent | AgentTurnCompleteEvent | AgentToolStartEvent | AgentToolDeltaEvent | AgentToolInputDeltaEvent | AgentToolInputCompleteEvent | AgentToolCompleteEvent | AgentMediaEvent | AgentApprovalStartEvent | AgentApprovalCompleteEvent | AgentIterationCompleteEvent | AgentReflectionEvent | AgentCompleteEvent | AgentErrorEvent | AgentPingEvent | AgentPausedEvent;
4353
4400
  /**
4354
4401
  * Parsed SSE event with event type and data
4355
4402
  */
@@ -4371,6 +4418,9 @@ interface AgentStreamCallbacks {
4371
4418
  onToolInputDelta?: (event: AgentToolInputDeltaEvent) => void;
4372
4419
  onToolInputComplete?: (event: AgentToolInputCompleteEvent) => void;
4373
4420
  onToolComplete?: (event: AgentToolCompleteEvent) => void;
4421
+ onMedia?: (event: AgentMediaEvent) => void;
4422
+ onApprovalStart?: (event: AgentApprovalStartEvent) => void;
4423
+ onApprovalComplete?: (event: AgentApprovalCompleteEvent) => void;
4374
4424
  onIterationComplete?: (event: AgentIterationCompleteEvent) => void;
4375
4425
  onReflection?: (event: AgentReflectionEvent) => void;
4376
4426
  onAgentComplete?: (event: AgentCompleteEvent) => void;
@@ -5656,4 +5706,4 @@ declare function getLikelySupportingCandidatePaths(bestCandidatePath: string | u
5656
5706
  declare function getDefaultPlanPath(taskName: string): string;
5657
5707
  declare function sanitizeTaskSlug(taskName: string): string;
5658
5708
 
5659
- export { type Agent, type AgentCompleteEvent, type AgentErrorEvent, type AgentEvent, type AgentEventType, type AgentExecuteRequest, type AgentExecuteResponse, type AgentIterationCompleteEvent, type AgentIterationStartEvent, type AgentMessage, type AgentPausedEvent, type AgentPingEvent, type AgentReflectionEvent, type AgentRuntimeToolDefinition, type AgentStartEvent, type AgentStreamCallbacks, type AgentSubagentConfig, type AgentToolCompleteEvent, type AgentToolDeltaEvent, type AgentToolInputCompleteEvent, type AgentToolInputDeltaEvent, type AgentToolStartEvent, type AgentTurnCompleteEvent, type AgentTurnDeltaEvent, type AgentTurnStartEvent, AgentsEndpoint, AnalyticsEndpoint, type ApiClient, type ApiKey, ApiKeysEndpoint, type ApiResponse, type ApplyGeneratedProposalOptions, type ApplyGeneratedProposalResult, type AttachRuntimeToolsOptions, type BaseAgentEvent, BatchBuilder, type BatchClient, type BatchListParams, type BatchOptions, type BatchRequest, type BatchResult, type BatchScheduleConfig, type BatchStatus, BatchesNamespace, type BuiltInTool, type BulkEditCondition, type BulkEditRequest, type BulkEditResponse, type BulkEditResult, ChatEndpoint, ClientBatchBuilder, type ClientConfig, type ClientConversation, ClientEvalBuilder, ClientFlowBuilder, type ClientToken, type ClientTokenConfig, type ClientTokenEnvironment, type ClientTokenVersionPin, ClientTokensEndpoint, type ClientWidgetTheme, type ConditionalStepConfig$1 as ConditionalStepConfig, type ContextErrorHandling, type ContextFallback, ContextTemplatesEndpoint, type CreateApiKeyRequest, type CreateClientTokenRequest, type CreateClientTokenResponse, type CreateFlowRequest, type CreateModelConfigRequest, type CreatePromptData, type CreatePromptRequest, type CreateProviderKeyRequest, type CreateRecordRequest, type CreateToolRequest, type CustomMCPServer, type CustomMCPServerAuth, type CustomToolConfig, type DeployCfSandboxRequest, type DeployCfSandboxResponse, type DeploySandboxRequest, type DeploySandboxResponse, type DispatchClient, DispatchEndpoint, type DispatchEnvironment, type DispatchOptions$1 as DispatchOptions, type DispatchRequest, type ErrorHandlingMode, EvalBuilder, type EvalClient, EvalEndpoint, type EvalListParams, type EvalOptions, type EvalRecord, type EvalRequest, type EvalResult, type EvalRunConfig, EvalRunner, type EvalStatus, EvalsNamespace, type ExecuteToolRequest, type ExecuteToolResponse, type ExternalToolConfig, type FallbackFailEvent, type FallbackStartEvent, type FallbackSuccessEvent, type FallbacksExhaustedEvent, type FallbacksInitiatedEvent, type FetchGitHubStepConfig$1 as FetchGitHubStepConfig, type FetchUrlStepConfig$1 as FetchUrlStepConfig, type FileContentPart, type Flow, type FlowAttachment, FlowBuilder, type FlowCompleteEvent, type FlowConfig$1 as FlowConfig, type FlowErrorEvent, type FlowFallback, type FlowPausedEvent, FlowResult, type FlowStartEvent, type FlowStep, FlowStepsEndpoint, type FlowSummary, type FlowToolConfig, FlowsEndpoint, FlowsNamespace, type GenerateEmbeddingStepConfig$1 as GenerateEmbeddingStepConfig, type GeneratedRuntimeToolGateDecision, type GeneratedRuntimeToolGateOptions, type ImageContentPart, type JSONSchema, type JsonArray, type JsonObject, type JsonPrimitive, type JsonValue, type ListConversationsResponse, type ListParams, type LocalToolConfig, type LocalToolDefinition, type LocalToolExecutionCompleteEvent, type LocalToolExecutionLoopSnapshotSlice, type LocalToolExecutionStartEvent, type Message$1 as Message, type MessageContent, type Metadata, type ModelConfig, ModelConfigsEndpoint, type ModelFallback, type ModelOverride, type ModelUsageDetail, type ModelUsageQueryParams, type ModelUsageResponse, type ModelUsageSummary, type ModelUsageTimeSeries, type PaginationResponse, type Prompt$1 as Prompt, type PromptErrorHandling, type PromptFallback, type PromptListParams, type PromptRunOptions, PromptRunner, type PromptStepConfig$1 as PromptStepConfig, PromptsEndpoint, PromptsNamespace, type ProviderApiKey, type ReasoningConfig, type ReasoningValue, type RecordConfig$1 as RecordConfig, type RecordListParams, RecordsEndpoint, type RetrieveRecordStepConfig$1 as RetrieveRecordStepConfig, type RetryFallback, type RunTaskContextBudgetBreakdown, type RunTaskContextCompactionEvent, type RunTaskContextCompactionStrategy, type RunTaskContextNoticeEvent, type RunTaskContinuation, type RunTaskOnContextCompaction, type RunTaskOnContextNotice, type RunTaskOnSession, type RunTaskOptions, type RunTaskResult, type RunTaskResumeState, type RunTaskSessionSummary, type RunTaskState, type RunTaskStateSlice, type RunTaskStatus, type RunTaskToolTraceSlice, type RuntimeCustomToolConfig, type RuntimeExternalToolConfig, type RuntimeFlowToolConfig, type RuntimeLocalToolConfig, type RuntimeSubagentToolConfig, type RuntimeTool, type RuntimeToolConfig, Runtype, RuntypeApiError, RuntypeClient, type ConditionalStepConfig as RuntypeConditionalStepConfig, type RuntypeConfig, type FetchGitHubStepConfig as RuntypeFetchGitHubStepConfig, type FetchUrlStepConfig as RuntypeFetchUrlStepConfig, RuntypeFlowBuilder, type FlowConfig as RuntypeFlowConfig, type GenerateEmbeddingStepConfig as RuntypeGenerateEmbeddingStepConfig, type Message as RuntypeMessage, type ModelOverride$1 as RuntypeModelOverride, type Prompt as RuntypePrompt, type PromptStepConfig as RuntypePromptStepConfig, type RuntypeRecord, type RecordConfig as RuntypeRecordConfig, type RetrieveRecordStepConfig as RuntypeRetrieveRecordStepConfig, type SearchStepConfig as RuntypeSearchStepConfig, type SendEmailStepConfig as RuntypeSendEmailStepConfig, type SendEventStepConfig as RuntypeSendEventStepConfig, type SendStreamStepConfig as RuntypeSendStreamStepConfig, type SendTextStepConfig as RuntypeSendTextStepConfig, type SetVariableStepConfig as RuntypeSetVariableStepConfig, type TransformDataStepConfig as RuntypeTransformDataStepConfig, type UpsertFlowConfig as RuntypeUpsertFlowConfig, type UpsertRecordStepConfig as RuntypeUpsertRecordStepConfig, type VectorSearchStepConfig as RuntypeVectorSearchStepConfig, type WaitUntilStepConfig as RuntypeWaitUntilStepConfig, type SearchStepConfig$1 as SearchStepConfig, type SendEmailStepConfig$1 as SendEmailStepConfig, type SendEventStepConfig$1 as SendEventStepConfig, type SendStreamStepConfig$1 as SendStreamStepConfig, type SendTextStepConfig$1 as SendTextStepConfig, type SetVariableStepConfig$1 as SetVariableStepConfig, type StepChunkEvent, type StepCompleteEvent, type StepDeltaEvent, type StepFallback, type StepStartEvent, type StepWaitingLocalEvent, type StreamCallbacks, type StreamEvent, type SubagentToolConfig, type TextContentPart, type Tool, type ToolConfig, type ToolExecution, type ToolsConfig, ToolsEndpoint, type TransformDataStepConfig$1 as TransformDataStepConfig, type UpdateClientTokenRequest, type UpdatePromptData, type UpdateProviderKeyRequest, type UpdateToolRequest, type UpsertFlowConfig$1 as UpsertFlowConfig, type UpsertOptions$2 as UpsertOptions, type UpsertRecordStepConfig$1 as UpsertRecordStepConfig, type UserProfile, UsersEndpoint, type VectorSearchStepConfig$1 as VectorSearchStepConfig, type WaitUntilStepConfig$1 as WaitUntilStepConfig, type WorkflowContext, type WorkflowDefinition, type WorkflowPhase, applyGeneratedRuntimeToolProposalToDispatchRequest, attachRuntimeToolsToDispatchRequest, buildGeneratedRuntimeToolGateOutput, createClient, createExternalTool, defaultWorkflow, deployWorkflow, evaluateGeneratedRuntimeToolProposal, gameWorkflow, getDefaultPlanPath, getLikelySupportingCandidatePaths, isDiscoveryToolName, isMarathonArtifactPath, isPreservationSensitiveTask, normalizeCandidatePath, parseFinalBuffer, parseSSEChunk, processStream, sanitizeTaskSlug, streamEvents };
5709
+ export { type Agent, type AgentApprovalCompleteEvent, type AgentApprovalStartEvent, type AgentCompleteEvent, type AgentErrorEvent, type AgentEvent, type AgentEventType, type AgentExecuteRequest, type AgentExecuteResponse, type AgentIterationCompleteEvent, type AgentIterationStartEvent, type AgentMediaEvent, type AgentMessage, type AgentPausedEvent, type AgentPingEvent, type AgentReflectionEvent, type AgentRuntimeToolDefinition, type AgentStartEvent, type AgentStreamCallbacks, type AgentSubagentConfig, type AgentToolCompleteEvent, type AgentToolDeltaEvent, type AgentToolInputCompleteEvent, type AgentToolInputDeltaEvent, type AgentToolStartEvent, type AgentTurnCompleteEvent, type AgentTurnDeltaEvent, type AgentTurnStartEvent, AgentsEndpoint, AnalyticsEndpoint, type ApiClient, type ApiKey, ApiKeysEndpoint, type ApiResponse, type ApplyGeneratedProposalOptions, type ApplyGeneratedProposalResult, type AttachRuntimeToolsOptions, type BaseAgentEvent, BatchBuilder, type BatchClient, type BatchListParams, type BatchOptions, type BatchRequest, type BatchResult, type BatchScheduleConfig, type BatchStatus, BatchesNamespace, type BuiltInTool, type BulkEditCondition, type BulkEditRequest, type BulkEditResponse, type BulkEditResult, ChatEndpoint, ClientBatchBuilder, type ClientConfig, type ClientConversation, ClientEvalBuilder, ClientFlowBuilder, type ClientToken, type ClientTokenConfig, type ClientTokenEnvironment, type ClientTokenVersionPin, ClientTokensEndpoint, type ClientWidgetTheme, type ConditionalStepConfig$1 as ConditionalStepConfig, type ContextErrorHandling, type ContextFallback, ContextTemplatesEndpoint, type CreateApiKeyRequest, type CreateClientTokenRequest, type CreateClientTokenResponse, type CreateFlowRequest, type CreateModelConfigRequest, type CreatePromptData, type CreatePromptRequest, type CreateProviderKeyRequest, type CreateRecordRequest, type CreateToolRequest, type CustomMCPServer, type CustomMCPServerAuth, type CustomToolConfig, type DeployCfSandboxRequest, type DeployCfSandboxResponse, type DeploySandboxRequest, type DeploySandboxResponse, type DispatchClient, DispatchEndpoint, type DispatchEnvironment, type DispatchOptions$1 as DispatchOptions, type DispatchRequest, type ErrorHandlingMode, EvalBuilder, type EvalClient, EvalEndpoint, type EvalListParams, type EvalOptions, type EvalRecord, type EvalRequest, type EvalResult, type EvalRunConfig, EvalRunner, type EvalStatus, EvalsNamespace, type ExecuteToolRequest, type ExecuteToolResponse, type ExternalToolConfig, type FallbackFailEvent, type FallbackStartEvent, type FallbackSuccessEvent, type FallbacksExhaustedEvent, type FallbacksInitiatedEvent, type FetchGitHubStepConfig$1 as FetchGitHubStepConfig, type FetchUrlStepConfig$1 as FetchUrlStepConfig, type FileContentPart, type Flow, type FlowAttachment, FlowBuilder, type FlowCompleteEvent, type FlowConfig$1 as FlowConfig, type FlowErrorEvent, type FlowFallback, type FlowPausedEvent, FlowResult, type FlowStartEvent, type FlowStep, FlowStepsEndpoint, type FlowSummary, type FlowToolConfig, FlowsEndpoint, FlowsNamespace, type GenerateEmbeddingStepConfig$1 as GenerateEmbeddingStepConfig, type GeneratedRuntimeToolGateDecision, type GeneratedRuntimeToolGateOptions, type ImageContentPart, type JSONSchema, type JsonArray, type JsonObject, type JsonPrimitive, type JsonValue, type ListConversationsResponse, type ListParams, type LocalToolConfig, type LocalToolDefinition, type LocalToolExecutionCompleteEvent, type LocalToolExecutionLoopSnapshotSlice, type LocalToolExecutionStartEvent, type Message$1 as Message, type MessageContent, type Metadata, type ModelConfig, ModelConfigsEndpoint, type ModelFallback, type ModelOverride, type ModelUsageDetail, type ModelUsageQueryParams, type ModelUsageResponse, type ModelUsageSummary, type ModelUsageTimeSeries, type PaginationResponse, type Prompt$1 as Prompt, type PromptErrorHandling, type PromptFallback, type PromptListParams, type PromptRunOptions, PromptRunner, type PromptStepConfig$1 as PromptStepConfig, PromptsEndpoint, PromptsNamespace, type ProviderApiKey, type ReasoningConfig, type ReasoningValue, type RecordConfig$1 as RecordConfig, type RecordListParams, RecordsEndpoint, type RetrieveRecordStepConfig$1 as RetrieveRecordStepConfig, type RetryFallback, type RunTaskContextBudgetBreakdown, type RunTaskContextCompactionEvent, type RunTaskContextCompactionStrategy, type RunTaskContextNoticeEvent, type RunTaskContinuation, type RunTaskOnContextCompaction, type RunTaskOnContextNotice, type RunTaskOnSession, type RunTaskOptions, type RunTaskResult, type RunTaskResumeState, type RunTaskSessionSummary, type RunTaskState, type RunTaskStateSlice, type RunTaskStatus, type RunTaskToolTraceSlice, type RuntimeCustomToolConfig, type RuntimeExternalToolConfig, type RuntimeFlowToolConfig, type RuntimeLocalToolConfig, type RuntimeSubagentToolConfig, type RuntimeTool, type RuntimeToolConfig, Runtype, RuntypeApiError, RuntypeClient, type ConditionalStepConfig as RuntypeConditionalStepConfig, type RuntypeConfig, type FetchGitHubStepConfig as RuntypeFetchGitHubStepConfig, type FetchUrlStepConfig as RuntypeFetchUrlStepConfig, RuntypeFlowBuilder, type FlowConfig as RuntypeFlowConfig, type GenerateEmbeddingStepConfig as RuntypeGenerateEmbeddingStepConfig, type Message as RuntypeMessage, type ModelOverride$1 as RuntypeModelOverride, type Prompt as RuntypePrompt, type PromptStepConfig as RuntypePromptStepConfig, type RuntypeRecord, type RecordConfig as RuntypeRecordConfig, type RetrieveRecordStepConfig as RuntypeRetrieveRecordStepConfig, type SearchStepConfig as RuntypeSearchStepConfig, type SendEmailStepConfig as RuntypeSendEmailStepConfig, type SendEventStepConfig as RuntypeSendEventStepConfig, type SendStreamStepConfig as RuntypeSendStreamStepConfig, type SendTextStepConfig as RuntypeSendTextStepConfig, type SetVariableStepConfig as RuntypeSetVariableStepConfig, type TransformDataStepConfig as RuntypeTransformDataStepConfig, type UpsertFlowConfig as RuntypeUpsertFlowConfig, type UpsertRecordStepConfig as RuntypeUpsertRecordStepConfig, type VectorSearchStepConfig as RuntypeVectorSearchStepConfig, type WaitUntilStepConfig as RuntypeWaitUntilStepConfig, type SearchStepConfig$1 as SearchStepConfig, type SendEmailStepConfig$1 as SendEmailStepConfig, type SendEventStepConfig$1 as SendEventStepConfig, type SendStreamStepConfig$1 as SendStreamStepConfig, type SendTextStepConfig$1 as SendTextStepConfig, type SetVariableStepConfig$1 as SetVariableStepConfig, type StepCompleteEvent, type StepDeltaEvent, type StepFallback, type StepStartEvent, type StepWaitingLocalEvent, type StreamCallbacks, type StreamEvent, type SubagentToolConfig, type TextContentPart, type Tool, type ToolConfig, type ToolExecution, type ToolsConfig, ToolsEndpoint, type TransformDataStepConfig$1 as TransformDataStepConfig, type UpdateClientTokenRequest, type UpdatePromptData, type UpdateProviderKeyRequest, type UpdateToolRequest, type UpsertFlowConfig$1 as UpsertFlowConfig, type UpsertOptions$2 as UpsertOptions, type UpsertRecordStepConfig$1 as UpsertRecordStepConfig, type UserProfile, UsersEndpoint, type VectorSearchStepConfig$1 as VectorSearchStepConfig, type WaitUntilStepConfig$1 as WaitUntilStepConfig, type WorkflowContext, type WorkflowDefinition, type WorkflowPhase, applyGeneratedRuntimeToolProposalToDispatchRequest, attachRuntimeToolsToDispatchRequest, buildGeneratedRuntimeToolGateOutput, createClient, createExternalTool, defaultWorkflow, deployWorkflow, evaluateGeneratedRuntimeToolProposal, gameWorkflow, getDefaultPlanPath, getLikelySupportingCandidatePaths, isDiscoveryToolName, isMarathonArtifactPath, isPreservationSensitiveTask, normalizeCandidatePath, parseFinalBuffer, parseSSEChunk, processStream, sanitizeTaskSlug, streamEvents };
package/dist/index.d.ts CHANGED
@@ -428,7 +428,7 @@ interface BuiltInTool {
428
428
  id: string;
429
429
  name: string;
430
430
  description: string;
431
- category: 'image_generation' | 'web_search' | 'web_scraping' | 'code_execution' | 'file_operations' | 'data_analysis' | 'knowledge_retrieval' | 'text_to_speech' | 'voice_processing' | 'third_party_api' | 'artifact' | 'data_management' | 'commerce';
431
+ category: 'image_generation' | 'web_search' | 'web_scraping' | 'code_execution' | 'file_operations' | 'data_analysis' | 'knowledge_retrieval' | 'text_to_speech' | 'voice_processing' | 'third_party_api' | 'artifact' | 'data_management' | 'commerce' | 'browser';
432
432
  providers: string[];
433
433
  parametersSchema: JSONSchema;
434
434
  defaultConfig?: JsonObject;
@@ -1278,11 +1278,10 @@ interface StepStartEvent {
1278
1278
  interface StepDeltaEvent {
1279
1279
  type: 'step_delta';
1280
1280
  id: string;
1281
- chunk: string;
1282
1281
  index: number;
1282
+ /** Streaming text fragment. */
1283
+ text: string;
1283
1284
  }
1284
- /** @deprecated Use StepDeltaEvent instead */
1285
- type StepChunkEvent = StepDeltaEvent;
1286
1285
  interface StepCompleteEvent {
1287
1286
  type: 'step_complete';
1288
1287
  id: string;
@@ -1329,13 +1328,8 @@ interface StreamCallbacks {
1329
1328
  onFlowStart?: (event: FlowStartEvent) => void;
1330
1329
  /** Called when a step starts executing */
1331
1330
  onStepStart?: (event: StepStartEvent) => void;
1332
- /** Called for each chunk of streaming output from a step */
1333
- onStepDelta?: (chunk: string, event: StepDeltaEvent) => void;
1334
- /**
1335
- * @deprecated Use onStepDelta instead
1336
- * Called for each chunk of streaming output from a step
1337
- */
1338
- onStepChunk?: (chunk: string, event: StepDeltaEvent) => void;
1331
+ /** Called for each text fragment of streaming output from a step */
1332
+ onStepDelta?: (text: string, event: StepDeltaEvent) => void;
1339
1333
  /** Called when a step completes */
1340
1334
  onStepComplete?: (result: any, event: StepCompleteEvent) => void;
1341
1335
  /** Called when the entire flow completes */
@@ -1735,7 +1729,7 @@ declare function createExternalTool(config: {
1735
1729
  *
1736
1730
  * // Option 1: Process with callbacks
1737
1731
  * const summary = await result.stream({
1738
- * onStepChunk: (chunk) => process.stdout.write(chunk),
1732
+ * onStepDelta: (text) => process.stdout.write(text),
1739
1733
  * })
1740
1734
  *
1741
1735
  * // Option 2: Just get a specific step's result
@@ -1771,7 +1765,7 @@ declare class FlowResult {
1771
1765
  * ```typescript
1772
1766
  * const summary = await result.stream({
1773
1767
  * onStepStart: (event) => console.log('Starting:', event.name),
1774
- * onStepChunk: (chunk) => process.stdout.write(chunk),
1768
+ * onStepDelta: (text) => process.stdout.write(text),
1775
1769
  * onStepComplete: (result, event) => console.log('Done:', event.name),
1776
1770
  * onFlowComplete: (event) => console.log('Flow complete!'),
1777
1771
  * })
@@ -2232,7 +2226,7 @@ declare class RuntypeFlowBuilder {
2232
2226
  *
2233
2227
  * // Process with callbacks
2234
2228
  * await result.stream({
2235
- * onStepChunk: (chunk) => process.stdout.write(chunk),
2229
+ * onStepDelta: (text) => process.stdout.write(text),
2236
2230
  * onFlowComplete: () => console.log('Done!'),
2237
2231
  * })
2238
2232
  *
@@ -2769,7 +2763,7 @@ declare class PromptRunner {
2769
2763
  *
2770
2764
  * // Process with callbacks
2771
2765
  * await result.stream({
2772
- * onStepChunk: (chunk) => process.stdout.write(chunk),
2766
+ * onStepDelta: (text) => process.stdout.write(text),
2773
2767
  * onFlowComplete: () => console.log('Done!'),
2774
2768
  * })
2775
2769
  * ```
@@ -4116,7 +4110,7 @@ declare class ClientTokensEndpoint {
4116
4110
  /**
4117
4111
  * Agent event types for streaming
4118
4112
  */
4119
- type AgentEventType = 'agent_start' | 'agent_iteration_start' | 'agent_turn_start' | 'agent_turn_delta' | 'agent_turn_complete' | 'agent_tool_start' | 'agent_tool_delta' | 'agent_tool_input_delta' | 'agent_tool_input_complete' | 'agent_tool_complete' | 'agent_iteration_complete' | 'agent_reflection' | 'agent_complete' | 'agent_error' | 'agent_ping' | 'agent_await';
4113
+ type AgentEventType = 'agent_start' | 'agent_iteration_start' | 'agent_turn_start' | 'agent_turn_delta' | 'agent_turn_complete' | 'agent_tool_start' | 'agent_tool_delta' | 'agent_tool_input_delta' | 'agent_tool_input_complete' | 'agent_tool_complete' | 'agent_media' | 'agent_approval_start' | 'agent_approval_complete' | 'agent_iteration_complete' | 'agent_reflection' | 'agent_complete' | 'agent_error' | 'agent_ping' | 'agent_await';
4120
4114
  /**
4121
4115
  * Base agent event with common fields
4122
4116
  */
@@ -4247,6 +4241,59 @@ interface AgentToolCompleteEvent extends BaseAgentEvent {
4247
4241
  result?: unknown;
4248
4242
  executionTime?: number;
4249
4243
  }
4244
+ interface AgentMediaEvent extends BaseAgentEvent {
4245
+ type: 'agent_media';
4246
+ iteration: number;
4247
+ toolCallId: string;
4248
+ toolName: string;
4249
+ media: Array<{
4250
+ type: 'media';
4251
+ data: string;
4252
+ mediaType: string;
4253
+ annotations?: {
4254
+ audience?: ('user' | 'assistant')[];
4255
+ };
4256
+ } | {
4257
+ type: 'image-url';
4258
+ url: string;
4259
+ mediaType?: string;
4260
+ annotations?: {
4261
+ audience?: ('user' | 'assistant')[];
4262
+ };
4263
+ } | {
4264
+ type: 'file-url';
4265
+ url: string;
4266
+ mediaType: string;
4267
+ annotations?: {
4268
+ audience?: ('user' | 'assistant')[];
4269
+ };
4270
+ }>;
4271
+ }
4272
+ /**
4273
+ * Agent approval start event — execution paused waiting for user approval.
4274
+ */
4275
+ interface AgentApprovalStartEvent extends BaseAgentEvent {
4276
+ type: 'agent_approval_start';
4277
+ approvalId: string;
4278
+ iteration?: number;
4279
+ toolCallId: string;
4280
+ toolName: string;
4281
+ toolType: string;
4282
+ description: string;
4283
+ parameters?: Record<string, unknown>;
4284
+ timeout: number;
4285
+ startedAt: string;
4286
+ }
4287
+ /**
4288
+ * Agent approval complete event — user or system resolved the approval.
4289
+ */
4290
+ interface AgentApprovalCompleteEvent extends BaseAgentEvent {
4291
+ type: 'agent_approval_complete';
4292
+ approvalId: string;
4293
+ decision: 'approved' | 'denied' | 'timeout';
4294
+ completedAt: string;
4295
+ resolvedBy: 'user' | 'system';
4296
+ }
4250
4297
  /**
4251
4298
  * Agent iteration complete event
4252
4299
  */
@@ -4312,7 +4359,7 @@ interface AgentPingEvent extends BaseAgentEvent {
4312
4359
  timestamp: string;
4313
4360
  }
4314
4361
  /**
4315
- * Agent await event (execution awaiting local tool result from client).
4362
+ * API-emitted agent await event for local tools that must execute on the client.
4316
4363
  */
4317
4364
  interface AgentPausedEvent extends BaseAgentEvent {
4318
4365
  type: 'agent_await';
@@ -4349,7 +4396,7 @@ interface LocalToolExecutionCompleteEvent {
4349
4396
  /**
4350
4397
  * Union of all agent event types
4351
4398
  */
4352
- type AgentEvent = AgentStartEvent | AgentIterationStartEvent | AgentTurnStartEvent | AgentTurnDeltaEvent | AgentTurnCompleteEvent | AgentToolStartEvent | AgentToolDeltaEvent | AgentToolInputDeltaEvent | AgentToolInputCompleteEvent | AgentToolCompleteEvent | AgentIterationCompleteEvent | AgentReflectionEvent | AgentCompleteEvent | AgentErrorEvent | AgentPingEvent | AgentPausedEvent;
4399
+ type AgentEvent = AgentStartEvent | AgentIterationStartEvent | AgentTurnStartEvent | AgentTurnDeltaEvent | AgentTurnCompleteEvent | AgentToolStartEvent | AgentToolDeltaEvent | AgentToolInputDeltaEvent | AgentToolInputCompleteEvent | AgentToolCompleteEvent | AgentMediaEvent | AgentApprovalStartEvent | AgentApprovalCompleteEvent | AgentIterationCompleteEvent | AgentReflectionEvent | AgentCompleteEvent | AgentErrorEvent | AgentPingEvent | AgentPausedEvent;
4353
4400
  /**
4354
4401
  * Parsed SSE event with event type and data
4355
4402
  */
@@ -4371,6 +4418,9 @@ interface AgentStreamCallbacks {
4371
4418
  onToolInputDelta?: (event: AgentToolInputDeltaEvent) => void;
4372
4419
  onToolInputComplete?: (event: AgentToolInputCompleteEvent) => void;
4373
4420
  onToolComplete?: (event: AgentToolCompleteEvent) => void;
4421
+ onMedia?: (event: AgentMediaEvent) => void;
4422
+ onApprovalStart?: (event: AgentApprovalStartEvent) => void;
4423
+ onApprovalComplete?: (event: AgentApprovalCompleteEvent) => void;
4374
4424
  onIterationComplete?: (event: AgentIterationCompleteEvent) => void;
4375
4425
  onReflection?: (event: AgentReflectionEvent) => void;
4376
4426
  onAgentComplete?: (event: AgentCompleteEvent) => void;
@@ -5656,4 +5706,4 @@ declare function getLikelySupportingCandidatePaths(bestCandidatePath: string | u
5656
5706
  declare function getDefaultPlanPath(taskName: string): string;
5657
5707
  declare function sanitizeTaskSlug(taskName: string): string;
5658
5708
 
5659
- export { type Agent, type AgentCompleteEvent, type AgentErrorEvent, type AgentEvent, type AgentEventType, type AgentExecuteRequest, type AgentExecuteResponse, type AgentIterationCompleteEvent, type AgentIterationStartEvent, type AgentMessage, type AgentPausedEvent, type AgentPingEvent, type AgentReflectionEvent, type AgentRuntimeToolDefinition, type AgentStartEvent, type AgentStreamCallbacks, type AgentSubagentConfig, type AgentToolCompleteEvent, type AgentToolDeltaEvent, type AgentToolInputCompleteEvent, type AgentToolInputDeltaEvent, type AgentToolStartEvent, type AgentTurnCompleteEvent, type AgentTurnDeltaEvent, type AgentTurnStartEvent, AgentsEndpoint, AnalyticsEndpoint, type ApiClient, type ApiKey, ApiKeysEndpoint, type ApiResponse, type ApplyGeneratedProposalOptions, type ApplyGeneratedProposalResult, type AttachRuntimeToolsOptions, type BaseAgentEvent, BatchBuilder, type BatchClient, type BatchListParams, type BatchOptions, type BatchRequest, type BatchResult, type BatchScheduleConfig, type BatchStatus, BatchesNamespace, type BuiltInTool, type BulkEditCondition, type BulkEditRequest, type BulkEditResponse, type BulkEditResult, ChatEndpoint, ClientBatchBuilder, type ClientConfig, type ClientConversation, ClientEvalBuilder, ClientFlowBuilder, type ClientToken, type ClientTokenConfig, type ClientTokenEnvironment, type ClientTokenVersionPin, ClientTokensEndpoint, type ClientWidgetTheme, type ConditionalStepConfig$1 as ConditionalStepConfig, type ContextErrorHandling, type ContextFallback, ContextTemplatesEndpoint, type CreateApiKeyRequest, type CreateClientTokenRequest, type CreateClientTokenResponse, type CreateFlowRequest, type CreateModelConfigRequest, type CreatePromptData, type CreatePromptRequest, type CreateProviderKeyRequest, type CreateRecordRequest, type CreateToolRequest, type CustomMCPServer, type CustomMCPServerAuth, type CustomToolConfig, type DeployCfSandboxRequest, type DeployCfSandboxResponse, type DeploySandboxRequest, type DeploySandboxResponse, type DispatchClient, DispatchEndpoint, type DispatchEnvironment, type DispatchOptions$1 as DispatchOptions, type DispatchRequest, type ErrorHandlingMode, EvalBuilder, type EvalClient, EvalEndpoint, type EvalListParams, type EvalOptions, type EvalRecord, type EvalRequest, type EvalResult, type EvalRunConfig, EvalRunner, type EvalStatus, EvalsNamespace, type ExecuteToolRequest, type ExecuteToolResponse, type ExternalToolConfig, type FallbackFailEvent, type FallbackStartEvent, type FallbackSuccessEvent, type FallbacksExhaustedEvent, type FallbacksInitiatedEvent, type FetchGitHubStepConfig$1 as FetchGitHubStepConfig, type FetchUrlStepConfig$1 as FetchUrlStepConfig, type FileContentPart, type Flow, type FlowAttachment, FlowBuilder, type FlowCompleteEvent, type FlowConfig$1 as FlowConfig, type FlowErrorEvent, type FlowFallback, type FlowPausedEvent, FlowResult, type FlowStartEvent, type FlowStep, FlowStepsEndpoint, type FlowSummary, type FlowToolConfig, FlowsEndpoint, FlowsNamespace, type GenerateEmbeddingStepConfig$1 as GenerateEmbeddingStepConfig, type GeneratedRuntimeToolGateDecision, type GeneratedRuntimeToolGateOptions, type ImageContentPart, type JSONSchema, type JsonArray, type JsonObject, type JsonPrimitive, type JsonValue, type ListConversationsResponse, type ListParams, type LocalToolConfig, type LocalToolDefinition, type LocalToolExecutionCompleteEvent, type LocalToolExecutionLoopSnapshotSlice, type LocalToolExecutionStartEvent, type Message$1 as Message, type MessageContent, type Metadata, type ModelConfig, ModelConfigsEndpoint, type ModelFallback, type ModelOverride, type ModelUsageDetail, type ModelUsageQueryParams, type ModelUsageResponse, type ModelUsageSummary, type ModelUsageTimeSeries, type PaginationResponse, type Prompt$1 as Prompt, type PromptErrorHandling, type PromptFallback, type PromptListParams, type PromptRunOptions, PromptRunner, type PromptStepConfig$1 as PromptStepConfig, PromptsEndpoint, PromptsNamespace, type ProviderApiKey, type ReasoningConfig, type ReasoningValue, type RecordConfig$1 as RecordConfig, type RecordListParams, RecordsEndpoint, type RetrieveRecordStepConfig$1 as RetrieveRecordStepConfig, type RetryFallback, type RunTaskContextBudgetBreakdown, type RunTaskContextCompactionEvent, type RunTaskContextCompactionStrategy, type RunTaskContextNoticeEvent, type RunTaskContinuation, type RunTaskOnContextCompaction, type RunTaskOnContextNotice, type RunTaskOnSession, type RunTaskOptions, type RunTaskResult, type RunTaskResumeState, type RunTaskSessionSummary, type RunTaskState, type RunTaskStateSlice, type RunTaskStatus, type RunTaskToolTraceSlice, type RuntimeCustomToolConfig, type RuntimeExternalToolConfig, type RuntimeFlowToolConfig, type RuntimeLocalToolConfig, type RuntimeSubagentToolConfig, type RuntimeTool, type RuntimeToolConfig, Runtype, RuntypeApiError, RuntypeClient, type ConditionalStepConfig as RuntypeConditionalStepConfig, type RuntypeConfig, type FetchGitHubStepConfig as RuntypeFetchGitHubStepConfig, type FetchUrlStepConfig as RuntypeFetchUrlStepConfig, RuntypeFlowBuilder, type FlowConfig as RuntypeFlowConfig, type GenerateEmbeddingStepConfig as RuntypeGenerateEmbeddingStepConfig, type Message as RuntypeMessage, type ModelOverride$1 as RuntypeModelOverride, type Prompt as RuntypePrompt, type PromptStepConfig as RuntypePromptStepConfig, type RuntypeRecord, type RecordConfig as RuntypeRecordConfig, type RetrieveRecordStepConfig as RuntypeRetrieveRecordStepConfig, type SearchStepConfig as RuntypeSearchStepConfig, type SendEmailStepConfig as RuntypeSendEmailStepConfig, type SendEventStepConfig as RuntypeSendEventStepConfig, type SendStreamStepConfig as RuntypeSendStreamStepConfig, type SendTextStepConfig as RuntypeSendTextStepConfig, type SetVariableStepConfig as RuntypeSetVariableStepConfig, type TransformDataStepConfig as RuntypeTransformDataStepConfig, type UpsertFlowConfig as RuntypeUpsertFlowConfig, type UpsertRecordStepConfig as RuntypeUpsertRecordStepConfig, type VectorSearchStepConfig as RuntypeVectorSearchStepConfig, type WaitUntilStepConfig as RuntypeWaitUntilStepConfig, type SearchStepConfig$1 as SearchStepConfig, type SendEmailStepConfig$1 as SendEmailStepConfig, type SendEventStepConfig$1 as SendEventStepConfig, type SendStreamStepConfig$1 as SendStreamStepConfig, type SendTextStepConfig$1 as SendTextStepConfig, type SetVariableStepConfig$1 as SetVariableStepConfig, type StepChunkEvent, type StepCompleteEvent, type StepDeltaEvent, type StepFallback, type StepStartEvent, type StepWaitingLocalEvent, type StreamCallbacks, type StreamEvent, type SubagentToolConfig, type TextContentPart, type Tool, type ToolConfig, type ToolExecution, type ToolsConfig, ToolsEndpoint, type TransformDataStepConfig$1 as TransformDataStepConfig, type UpdateClientTokenRequest, type UpdatePromptData, type UpdateProviderKeyRequest, type UpdateToolRequest, type UpsertFlowConfig$1 as UpsertFlowConfig, type UpsertOptions$2 as UpsertOptions, type UpsertRecordStepConfig$1 as UpsertRecordStepConfig, type UserProfile, UsersEndpoint, type VectorSearchStepConfig$1 as VectorSearchStepConfig, type WaitUntilStepConfig$1 as WaitUntilStepConfig, type WorkflowContext, type WorkflowDefinition, type WorkflowPhase, applyGeneratedRuntimeToolProposalToDispatchRequest, attachRuntimeToolsToDispatchRequest, buildGeneratedRuntimeToolGateOutput, createClient, createExternalTool, defaultWorkflow, deployWorkflow, evaluateGeneratedRuntimeToolProposal, gameWorkflow, getDefaultPlanPath, getLikelySupportingCandidatePaths, isDiscoveryToolName, isMarathonArtifactPath, isPreservationSensitiveTask, normalizeCandidatePath, parseFinalBuffer, parseSSEChunk, processStream, sanitizeTaskSlug, streamEvents };
5709
+ export { type Agent, type AgentApprovalCompleteEvent, type AgentApprovalStartEvent, type AgentCompleteEvent, type AgentErrorEvent, type AgentEvent, type AgentEventType, type AgentExecuteRequest, type AgentExecuteResponse, type AgentIterationCompleteEvent, type AgentIterationStartEvent, type AgentMediaEvent, type AgentMessage, type AgentPausedEvent, type AgentPingEvent, type AgentReflectionEvent, type AgentRuntimeToolDefinition, type AgentStartEvent, type AgentStreamCallbacks, type AgentSubagentConfig, type AgentToolCompleteEvent, type AgentToolDeltaEvent, type AgentToolInputCompleteEvent, type AgentToolInputDeltaEvent, type AgentToolStartEvent, type AgentTurnCompleteEvent, type AgentTurnDeltaEvent, type AgentTurnStartEvent, AgentsEndpoint, AnalyticsEndpoint, type ApiClient, type ApiKey, ApiKeysEndpoint, type ApiResponse, type ApplyGeneratedProposalOptions, type ApplyGeneratedProposalResult, type AttachRuntimeToolsOptions, type BaseAgentEvent, BatchBuilder, type BatchClient, type BatchListParams, type BatchOptions, type BatchRequest, type BatchResult, type BatchScheduleConfig, type BatchStatus, BatchesNamespace, type BuiltInTool, type BulkEditCondition, type BulkEditRequest, type BulkEditResponse, type BulkEditResult, ChatEndpoint, ClientBatchBuilder, type ClientConfig, type ClientConversation, ClientEvalBuilder, ClientFlowBuilder, type ClientToken, type ClientTokenConfig, type ClientTokenEnvironment, type ClientTokenVersionPin, ClientTokensEndpoint, type ClientWidgetTheme, type ConditionalStepConfig$1 as ConditionalStepConfig, type ContextErrorHandling, type ContextFallback, ContextTemplatesEndpoint, type CreateApiKeyRequest, type CreateClientTokenRequest, type CreateClientTokenResponse, type CreateFlowRequest, type CreateModelConfigRequest, type CreatePromptData, type CreatePromptRequest, type CreateProviderKeyRequest, type CreateRecordRequest, type CreateToolRequest, type CustomMCPServer, type CustomMCPServerAuth, type CustomToolConfig, type DeployCfSandboxRequest, type DeployCfSandboxResponse, type DeploySandboxRequest, type DeploySandboxResponse, type DispatchClient, DispatchEndpoint, type DispatchEnvironment, type DispatchOptions$1 as DispatchOptions, type DispatchRequest, type ErrorHandlingMode, EvalBuilder, type EvalClient, EvalEndpoint, type EvalListParams, type EvalOptions, type EvalRecord, type EvalRequest, type EvalResult, type EvalRunConfig, EvalRunner, type EvalStatus, EvalsNamespace, type ExecuteToolRequest, type ExecuteToolResponse, type ExternalToolConfig, type FallbackFailEvent, type FallbackStartEvent, type FallbackSuccessEvent, type FallbacksExhaustedEvent, type FallbacksInitiatedEvent, type FetchGitHubStepConfig$1 as FetchGitHubStepConfig, type FetchUrlStepConfig$1 as FetchUrlStepConfig, type FileContentPart, type Flow, type FlowAttachment, FlowBuilder, type FlowCompleteEvent, type FlowConfig$1 as FlowConfig, type FlowErrorEvent, type FlowFallback, type FlowPausedEvent, FlowResult, type FlowStartEvent, type FlowStep, FlowStepsEndpoint, type FlowSummary, type FlowToolConfig, FlowsEndpoint, FlowsNamespace, type GenerateEmbeddingStepConfig$1 as GenerateEmbeddingStepConfig, type GeneratedRuntimeToolGateDecision, type GeneratedRuntimeToolGateOptions, type ImageContentPart, type JSONSchema, type JsonArray, type JsonObject, type JsonPrimitive, type JsonValue, type ListConversationsResponse, type ListParams, type LocalToolConfig, type LocalToolDefinition, type LocalToolExecutionCompleteEvent, type LocalToolExecutionLoopSnapshotSlice, type LocalToolExecutionStartEvent, type Message$1 as Message, type MessageContent, type Metadata, type ModelConfig, ModelConfigsEndpoint, type ModelFallback, type ModelOverride, type ModelUsageDetail, type ModelUsageQueryParams, type ModelUsageResponse, type ModelUsageSummary, type ModelUsageTimeSeries, type PaginationResponse, type Prompt$1 as Prompt, type PromptErrorHandling, type PromptFallback, type PromptListParams, type PromptRunOptions, PromptRunner, type PromptStepConfig$1 as PromptStepConfig, PromptsEndpoint, PromptsNamespace, type ProviderApiKey, type ReasoningConfig, type ReasoningValue, type RecordConfig$1 as RecordConfig, type RecordListParams, RecordsEndpoint, type RetrieveRecordStepConfig$1 as RetrieveRecordStepConfig, type RetryFallback, type RunTaskContextBudgetBreakdown, type RunTaskContextCompactionEvent, type RunTaskContextCompactionStrategy, type RunTaskContextNoticeEvent, type RunTaskContinuation, type RunTaskOnContextCompaction, type RunTaskOnContextNotice, type RunTaskOnSession, type RunTaskOptions, type RunTaskResult, type RunTaskResumeState, type RunTaskSessionSummary, type RunTaskState, type RunTaskStateSlice, type RunTaskStatus, type RunTaskToolTraceSlice, type RuntimeCustomToolConfig, type RuntimeExternalToolConfig, type RuntimeFlowToolConfig, type RuntimeLocalToolConfig, type RuntimeSubagentToolConfig, type RuntimeTool, type RuntimeToolConfig, Runtype, RuntypeApiError, RuntypeClient, type ConditionalStepConfig as RuntypeConditionalStepConfig, type RuntypeConfig, type FetchGitHubStepConfig as RuntypeFetchGitHubStepConfig, type FetchUrlStepConfig as RuntypeFetchUrlStepConfig, RuntypeFlowBuilder, type FlowConfig as RuntypeFlowConfig, type GenerateEmbeddingStepConfig as RuntypeGenerateEmbeddingStepConfig, type Message as RuntypeMessage, type ModelOverride$1 as RuntypeModelOverride, type Prompt as RuntypePrompt, type PromptStepConfig as RuntypePromptStepConfig, type RuntypeRecord, type RecordConfig as RuntypeRecordConfig, type RetrieveRecordStepConfig as RuntypeRetrieveRecordStepConfig, type SearchStepConfig as RuntypeSearchStepConfig, type SendEmailStepConfig as RuntypeSendEmailStepConfig, type SendEventStepConfig as RuntypeSendEventStepConfig, type SendStreamStepConfig as RuntypeSendStreamStepConfig, type SendTextStepConfig as RuntypeSendTextStepConfig, type SetVariableStepConfig as RuntypeSetVariableStepConfig, type TransformDataStepConfig as RuntypeTransformDataStepConfig, type UpsertFlowConfig as RuntypeUpsertFlowConfig, type UpsertRecordStepConfig as RuntypeUpsertRecordStepConfig, type VectorSearchStepConfig as RuntypeVectorSearchStepConfig, type WaitUntilStepConfig as RuntypeWaitUntilStepConfig, type SearchStepConfig$1 as SearchStepConfig, type SendEmailStepConfig$1 as SendEmailStepConfig, type SendEventStepConfig$1 as SendEventStepConfig, type SendStreamStepConfig$1 as SendStreamStepConfig, type SendTextStepConfig$1 as SendTextStepConfig, type SetVariableStepConfig$1 as SetVariableStepConfig, type StepCompleteEvent, type StepDeltaEvent, type StepFallback, type StepStartEvent, type StepWaitingLocalEvent, type StreamCallbacks, type StreamEvent, type SubagentToolConfig, type TextContentPart, type Tool, type ToolConfig, type ToolExecution, type ToolsConfig, ToolsEndpoint, type TransformDataStepConfig$1 as TransformDataStepConfig, type UpdateClientTokenRequest, type UpdatePromptData, type UpdateProviderKeyRequest, type UpdateToolRequest, type UpsertFlowConfig$1 as UpsertFlowConfig, type UpsertOptions$2 as UpsertOptions, type UpsertRecordStepConfig$1 as UpsertRecordStepConfig, type UserProfile, UsersEndpoint, type VectorSearchStepConfig$1 as VectorSearchStepConfig, type WaitUntilStepConfig$1 as WaitUntilStepConfig, type WorkflowContext, type WorkflowDefinition, type WorkflowPhase, applyGeneratedRuntimeToolProposalToDispatchRequest, attachRuntimeToolsToDispatchRequest, buildGeneratedRuntimeToolGateOutput, createClient, createExternalTool, defaultWorkflow, deployWorkflow, evaluateGeneratedRuntimeToolProposal, gameWorkflow, getDefaultPlanPath, getLikelySupportingCandidatePaths, isDiscoveryToolName, isMarathonArtifactPath, isPreservationSensitiveTask, normalizeCandidatePath, parseFinalBuffer, parseSSEChunk, processStream, sanitizeTaskSlug, streamEvents };
package/dist/index.mjs CHANGED
@@ -177,13 +177,9 @@ function handleEvent(event, callbacks, results, summary) {
177
177
  case "step_start":
178
178
  callbacks.onStepStart?.(event);
179
179
  break;
180
- case "step_delta": {
181
- const chunkText = event.chunk || event.text || "";
182
- const deltaEvent = event;
183
- callbacks.onStepDelta?.(chunkText, deltaEvent);
184
- callbacks.onStepChunk?.(chunkText, deltaEvent);
180
+ case "step_delta":
181
+ callbacks.onStepDelta?.(event.text, event);
185
182
  break;
186
- }
187
183
  case "step_complete":
188
184
  results.set(event.name, event.result);
189
185
  callbacks.onStepComplete?.(event.result, event);
@@ -241,10 +237,6 @@ async function* streamEvents(response) {
241
237
  for (const eventStr of events) {
242
238
  try {
243
239
  const event = JSON.parse(eventStr);
244
- if (event.type === "step_delta" && "text" in event && !("chunk" in event)) {
245
- ;
246
- event.chunk = event.text;
247
- }
248
240
  yield event;
249
241
  } catch {
250
242
  }
@@ -254,10 +246,6 @@ async function* streamEvents(response) {
254
246
  if (finalEvent) {
255
247
  try {
256
248
  const event = JSON.parse(finalEvent);
257
- if (event.type === "step_delta" && "text" in event && !("chunk" in event)) {
258
- ;
259
- event.chunk = event.text;
260
- }
261
249
  yield event;
262
250
  } catch {
263
251
  }
@@ -309,7 +297,7 @@ var FlowResult = class {
309
297
  * ```typescript
310
298
  * const summary = await result.stream({
311
299
  * onStepStart: (event) => console.log('Starting:', event.name),
312
- * onStepChunk: (chunk) => process.stdout.write(chunk),
300
+ * onStepDelta: (text) => process.stdout.write(text),
313
301
  * onStepComplete: (result, event) => console.log('Done:', event.name),
314
302
  * onFlowComplete: (event) => console.log('Flow complete!'),
315
303
  * })
@@ -913,7 +901,7 @@ var RuntypeFlowBuilder = class {
913
901
  ...callbacks,
914
902
  onFlowStart: (event) => callbacks?.onFlowStart?.(event),
915
903
  onStepStart: (event) => callbacks?.onStepStart?.(event),
916
- onStepChunk: (chunk, event) => callbacks?.onStepChunk?.(chunk, event),
904
+ onStepDelta: (text, event) => callbacks?.onStepDelta?.(text, event),
917
905
  onStepComplete: (result, event) => callbacks?.onStepComplete?.(result, event),
918
906
  onFlowComplete: (event) => callbacks?.onFlowComplete?.(event),
919
907
  onError: (error) => callbacks?.onError?.(error)
@@ -943,11 +931,9 @@ var RuntypeFlowBuilder = class {
943
931
  case "step_start":
944
932
  wrappedCallbacks.onStepStart?.(event);
945
933
  break;
946
- case "step_delta": {
947
- const chunkText = awaitEvent.chunk || awaitEvent.text || "";
948
- wrappedCallbacks.onStepChunk?.(chunkText, event);
934
+ case "step_delta":
935
+ wrappedCallbacks.onStepDelta?.(event.text, event);
949
936
  break;
950
- }
951
937
  case "step_complete": {
952
938
  accumulatedSummary.results?.set(event.name, event.result);
953
939
  wrappedCallbacks.onStepComplete?.(event.result, event);
@@ -1397,7 +1383,7 @@ var PromptRunner = class {
1397
1383
  *
1398
1384
  * // Process with callbacks
1399
1385
  * await result.stream({
1400
- * onStepChunk: (chunk) => process.stdout.write(chunk),
1386
+ * onStepDelta: (text) => process.stdout.write(text),
1401
1387
  * onFlowComplete: () => console.log('Done!'),
1402
1388
  * })
1403
1389
  * ```
@@ -4306,6 +4292,15 @@ function dispatchAgentEvent(event, callbacks) {
4306
4292
  case "agent_tool_complete":
4307
4293
  callbacks.onToolComplete?.(typedData);
4308
4294
  break;
4295
+ case "agent_media":
4296
+ callbacks.onMedia?.(typedData);
4297
+ break;
4298
+ case "agent_approval_start":
4299
+ callbacks.onApprovalStart?.(typedData);
4300
+ break;
4301
+ case "agent_approval_complete":
4302
+ callbacks.onApprovalComplete?.(typedData);
4303
+ break;
4309
4304
  case "agent_iteration_complete":
4310
4305
  callbacks.onIterationComplete?.(typedData);
4311
4306
  break;
@@ -7601,7 +7596,7 @@ var ClientFlowBuilder = class extends FlowBuilder {
7601
7596
  };
7602
7597
  function isStreamCallbacks(obj) {
7603
7598
  if (!obj || typeof obj !== "object") return false;
7604
- return "onFlowStart" in obj || "onStepStart" in obj || "onStepDelta" in obj || "onStepChunk" in obj || "onStepComplete" in obj || "onFlowComplete" in obj || "onError" in obj;
7599
+ return "onFlowStart" in obj || "onStepStart" in obj || "onStepDelta" in obj || "onStepComplete" in obj || "onFlowComplete" in obj || "onError" in obj;
7605
7600
  }
7606
7601
  function createExternalTool(config) {
7607
7602
  return {
@@ -7716,7 +7711,7 @@ var RuntypeClient2 = class {
7716
7711
  ...callbacks,
7717
7712
  onFlowStart: (event) => callbacks?.onFlowStart?.(event),
7718
7713
  onStepStart: (event) => callbacks?.onStepStart?.(event),
7719
- onStepChunk: (chunk, event) => callbacks?.onStepChunk?.(chunk, event),
7714
+ onStepDelta: (text, event) => callbacks?.onStepDelta?.(text, event),
7720
7715
  onStepComplete: (result, event) => callbacks?.onStepComplete?.(result, event),
7721
7716
  onFlowComplete: (event) => callbacks?.onFlowComplete?.(event),
7722
7717
  onError: (error) => callbacks?.onError?.(error)
@@ -7751,12 +7746,9 @@ var RuntypeClient2 = class {
7751
7746
  case "step_start":
7752
7747
  wrappedCallbacks.onStepStart?.(event);
7753
7748
  break;
7754
- case "step_delta": {
7755
- const deltaEvent = event;
7756
- const chunkText = deltaEvent.chunk || deltaEvent.text || "";
7757
- wrappedCallbacks.onStepChunk?.(chunkText, deltaEvent);
7749
+ case "step_delta":
7750
+ wrappedCallbacks.onStepDelta?.(event.text, event);
7758
7751
  break;
7759
- }
7760
7752
  case "step_complete": {
7761
7753
  summary.results?.set(event.name, event.result);
7762
7754
  wrappedCallbacks.onStepComplete?.(event.result, event);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runtypelabs/sdk",
3
- "version": "1.17.1",
3
+ "version": "1.18.0",
4
4
  "type": "module",
5
5
  "description": "TypeScript SDK for the Runtype API with fluent methods. Use it to quickly realize AI products, agents, and workflows.",
6
6
  "main": "dist/index.cjs",