@openrouter/sdk 0.3.14 → 0.3.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/esm/funcs/analyticsGetUserActivity.d.ts +1 -1
  2. package/esm/funcs/analyticsGetUserActivity.js +1 -1
  3. package/esm/funcs/apiKeysCreate.d.ts +3 -0
  4. package/esm/funcs/apiKeysCreate.js +3 -0
  5. package/esm/funcs/apiKeysDelete.d.ts +3 -0
  6. package/esm/funcs/apiKeysDelete.js +3 -0
  7. package/esm/funcs/apiKeysGet.d.ts +3 -0
  8. package/esm/funcs/apiKeysGet.js +3 -0
  9. package/esm/funcs/apiKeysList.d.ts +3 -0
  10. package/esm/funcs/apiKeysList.js +3 -0
  11. package/esm/funcs/apiKeysUpdate.d.ts +3 -0
  12. package/esm/funcs/apiKeysUpdate.js +3 -0
  13. package/esm/funcs/call-model.js +9 -6
  14. package/esm/funcs/creditsGetCredits.d.ts +1 -1
  15. package/esm/funcs/creditsGetCredits.js +1 -1
  16. package/esm/funcs/guardrailsBulkAssignKeys.d.ts +18 -0
  17. package/esm/funcs/guardrailsBulkAssignKeys.js +89 -0
  18. package/esm/funcs/guardrailsBulkAssignMembers.d.ts +18 -0
  19. package/esm/funcs/guardrailsBulkAssignMembers.js +89 -0
  20. package/esm/funcs/guardrailsBulkUnassignKeys.d.ts +18 -0
  21. package/esm/funcs/guardrailsBulkUnassignKeys.js +89 -0
  22. package/esm/funcs/guardrailsBulkUnassignMembers.d.ts +18 -0
  23. package/esm/funcs/guardrailsBulkUnassignMembers.js +89 -0
  24. package/esm/funcs/guardrailsCreate.d.ts +18 -0
  25. package/esm/funcs/guardrailsCreate.js +83 -0
  26. package/esm/funcs/guardrailsDelete.d.ts +18 -0
  27. package/esm/funcs/guardrailsDelete.js +88 -0
  28. package/esm/funcs/{parametersGetParameters.d.ts → guardrailsGet.d.ts} +6 -3
  29. package/esm/funcs/guardrailsGet.js +88 -0
  30. package/esm/funcs/guardrailsList.d.ts +18 -0
  31. package/esm/funcs/guardrailsList.js +87 -0
  32. package/esm/funcs/guardrailsListGuardrailKeyAssignments.d.ts +18 -0
  33. package/esm/funcs/guardrailsListGuardrailKeyAssignments.js +93 -0
  34. package/esm/funcs/guardrailsListGuardrailMemberAssignments.d.ts +18 -0
  35. package/esm/funcs/guardrailsListGuardrailMemberAssignments.js +93 -0
  36. package/esm/funcs/guardrailsListKeyAssignments.d.ts +18 -0
  37. package/esm/funcs/guardrailsListKeyAssignments.js +87 -0
  38. package/esm/funcs/guardrailsListMemberAssignments.d.ts +18 -0
  39. package/esm/funcs/guardrailsListMemberAssignments.js +87 -0
  40. package/esm/funcs/guardrailsUpdate.d.ts +18 -0
  41. package/esm/funcs/{parametersGetParameters.js → guardrailsUpdate.js} +24 -32
  42. package/esm/index.d.ts +4 -3
  43. package/esm/index.js +3 -1
  44. package/esm/lib/async-params.d.ts +46 -6
  45. package/esm/lib/async-params.js +10 -2
  46. package/esm/lib/config.d.ts +2 -4
  47. package/esm/lib/config.js +2 -2
  48. package/esm/lib/conversation-state.d.ts +61 -0
  49. package/esm/lib/conversation-state.js +207 -0
  50. package/esm/lib/model-result.d.ts +179 -4
  51. package/esm/lib/model-result.js +719 -191
  52. package/esm/lib/tool-executor.js +37 -13
  53. package/esm/lib/tool-types.d.ts +135 -2
  54. package/esm/lib/tool-types.js +19 -0
  55. package/esm/lib/tool.d.ts +21 -1
  56. package/esm/lib/tool.js +7 -0
  57. package/esm/models/assistantmessage.d.ts +31 -0
  58. package/esm/models/assistantmessage.js +43 -0
  59. package/esm/models/chatmessagecontentitemimage.d.ts +8 -8
  60. package/esm/models/chatmessagecontentitemimage.js +8 -9
  61. package/esm/models/chatresponsechoice.d.ts +0 -2
  62. package/esm/models/chatresponsechoice.js +0 -3
  63. package/esm/models/chatstreamingmessagechunk.d.ts +2 -2
  64. package/esm/models/chatstreamingmessagechunk.js +2 -2
  65. package/esm/models/index.d.ts +1 -1
  66. package/esm/models/index.js +1 -1
  67. package/esm/models/model.d.ts +4 -0
  68. package/esm/models/model.js +2 -0
  69. package/esm/models/operations/bulkassignkeystoguardrail.d.ts +44 -0
  70. package/esm/models/operations/bulkassignkeystoguardrail.js +42 -0
  71. package/esm/models/operations/bulkassignmemberstoguardrail.d.ts +44 -0
  72. package/esm/models/operations/bulkassignmemberstoguardrail.js +42 -0
  73. package/esm/models/operations/bulkunassignkeysfromguardrail.d.ts +44 -0
  74. package/esm/models/operations/bulkunassignkeysfromguardrail.js +42 -0
  75. package/esm/models/operations/bulkunassignmembersfromguardrail.d.ts +44 -0
  76. package/esm/models/operations/bulkunassignmembersfromguardrail.js +42 -0
  77. package/esm/models/operations/createguardrail.d.ts +136 -0
  78. package/esm/models/operations/createguardrail.js +85 -0
  79. package/esm/models/operations/deleteguardrail.d.ts +29 -0
  80. package/esm/models/operations/deleteguardrail.js +21 -0
  81. package/esm/models/operations/getguardrail.d.ts +92 -0
  82. package/esm/models/operations/getguardrail.js +60 -0
  83. package/esm/models/operations/getmodels.d.ts +28 -1
  84. package/esm/models/operations/getmodels.js +22 -1
  85. package/esm/models/operations/index.d.ts +13 -1
  86. package/esm/models/operations/index.js +13 -1
  87. package/esm/models/operations/listguardrailkeyassignments.d.ts +76 -0
  88. package/esm/models/operations/listguardrailkeyassignments.js +51 -0
  89. package/esm/models/operations/listguardrailmemberassignments.d.ts +72 -0
  90. package/esm/models/operations/listguardrailmemberassignments.js +49 -0
  91. package/esm/models/operations/listguardrails.d.ts +98 -0
  92. package/esm/models/operations/listguardrails.js +66 -0
  93. package/esm/models/operations/listkeyassignments.d.ts +71 -0
  94. package/esm/models/operations/listkeyassignments.js +50 -0
  95. package/esm/models/operations/listmemberassignments.d.ts +67 -0
  96. package/esm/models/operations/listmemberassignments.js +48 -0
  97. package/esm/models/operations/updateguardrail.d.ts +151 -0
  98. package/esm/models/operations/updateguardrail.js +97 -0
  99. package/esm/models/outputmodality.d.ts +1 -0
  100. package/esm/models/outputmodality.js +1 -0
  101. package/esm/models/percentilelatencycutoffs.js +1 -1
  102. package/esm/models/percentilestats.js +1 -1
  103. package/esm/models/percentilethroughputcutoffs.js +1 -1
  104. package/esm/models/preferredmaxlatency.js +1 -1
  105. package/esm/models/preferredminthroughput.js +1 -1
  106. package/esm/models/publicendpoint.d.ts +8 -0
  107. package/esm/models/publicendpoint.js +4 -0
  108. package/esm/models/publicpricing.d.ts +4 -0
  109. package/esm/models/publicpricing.js +2 -0
  110. package/esm/models/responseinputvideo.js +1 -1
  111. package/esm/models/responsesoutputmodality.js +1 -1
  112. package/esm/models/schema2.d.ts +92 -0
  113. package/esm/models/schema2.js +109 -0
  114. package/esm/sdk/analytics.d.ts +1 -1
  115. package/esm/sdk/analytics.js +1 -1
  116. package/esm/sdk/apikeys.d.ts +15 -0
  117. package/esm/sdk/apikeys.js +15 -0
  118. package/esm/sdk/credits.d.ts +1 -1
  119. package/esm/sdk/credits.js +1 -1
  120. package/esm/sdk/guardrails.d.ts +96 -0
  121. package/esm/sdk/guardrails.js +139 -0
  122. package/esm/sdk/sdk.d.ts +3 -3
  123. package/esm/sdk/sdk.js +4 -4
  124. package/esm/types/index.d.ts +2 -0
  125. package/esm/types/index.js +1 -0
  126. package/esm/types/models.d.ts +25 -0
  127. package/esm/types/models.js +10 -0
  128. package/jsr.json +1 -1
  129. package/package.json +12 -10
  130. package/scripts/check-types.js +127 -0
  131. package/esm/models/operations/getparameters.d.ts +0 -87
  132. package/esm/models/operations/getparameters.js +0 -73
  133. package/esm/models/schema3.d.ts +0 -51
  134. package/esm/models/schema3.js +0 -62
  135. package/esm/sdk/parameters.d.ts +0 -9
  136. package/esm/sdk/parameters.js +0 -16
@@ -0,0 +1,207 @@
1
+ import { normalizeInputToArray } from './turn-context.js';
2
+ /**
3
+ * Type guard to verify an object is a valid UnsentToolResult
4
+ */
5
+ function isValidUnsentToolResult(obj) {
6
+ if (typeof obj !== 'object' || obj === null)
7
+ return false;
8
+ const candidate = obj;
9
+ return (typeof candidate['callId'] === 'string' &&
10
+ typeof candidate['name'] === 'string' &&
11
+ 'output' in candidate);
12
+ }
13
+ /**
14
+ * Type guard to verify an object is a valid ParsedToolCall
15
+ */
16
+ function isValidParsedToolCall(obj) {
17
+ if (typeof obj !== 'object' || obj === null)
18
+ return false;
19
+ const candidate = obj;
20
+ return (typeof candidate['id'] === 'string' &&
21
+ typeof candidate['name'] === 'string' &&
22
+ 'arguments' in candidate);
23
+ }
24
+ /**
25
+ * Generate a unique ID for a conversation
26
+ * Uses crypto.randomUUID if available, falls back to timestamp + random
27
+ */
28
+ export function generateConversationId() {
29
+ if (typeof crypto !== 'undefined' && crypto.randomUUID) {
30
+ return `conv_${crypto.randomUUID()}`;
31
+ }
32
+ // Fallback for environments without crypto.randomUUID
33
+ return `conv_${Date.now()}_${Math.random().toString(36).substring(2, 15)}`;
34
+ }
35
+ /**
36
+ * Create an initial conversation state
37
+ * @param id - Optional custom ID, generates one if not provided
38
+ */
39
+ export function createInitialState(id) {
40
+ const now = Date.now();
41
+ return {
42
+ id: id ?? generateConversationId(),
43
+ messages: [],
44
+ status: 'in_progress',
45
+ createdAt: now,
46
+ updatedAt: now,
47
+ };
48
+ }
49
+ /**
50
+ * Update a conversation state with new values
51
+ * Automatically updates the updatedAt timestamp
52
+ */
53
+ export function updateState(state, updates) {
54
+ return {
55
+ ...state,
56
+ ...updates,
57
+ updatedAt: Date.now(),
58
+ };
59
+ }
60
+ /**
61
+ * Append new items to the message history
62
+ */
63
+ export function appendToMessages(current, newItems) {
64
+ const currentArray = normalizeInputToArray(current);
65
+ return [...currentArray, ...newItems];
66
+ }
67
+ /**
68
+ * Check if a tool call requires approval
69
+ * @param toolCall - The tool call to check
70
+ * @param tools - Available tools
71
+ * @param context - Turn context for the approval check
72
+ * @param callLevelCheck - Optional call-level approval function (overrides tool-level), can be async
73
+ */
74
+ export async function toolRequiresApproval(toolCall, tools, context, callLevelCheck) {
75
+ // Call-level check takes precedence
76
+ if (callLevelCheck) {
77
+ return callLevelCheck(toolCall, context);
78
+ }
79
+ // Fall back to tool-level setting
80
+ const tool = tools.find(t => t.function.name === toolCall.name);
81
+ if (!tool)
82
+ return false;
83
+ const requireApproval = tool.function.requireApproval;
84
+ // If it's a function, call it with the tool's arguments and context
85
+ if (typeof requireApproval === 'function') {
86
+ return requireApproval(toolCall.arguments, context);
87
+ }
88
+ // Otherwise treat as boolean
89
+ return requireApproval ?? false;
90
+ }
91
+ /**
92
+ * Partition tool calls into those requiring approval and those that can auto-execute
93
+ * @param toolCalls - Tool calls to partition
94
+ * @param tools - Available tools
95
+ * @param context - Turn context for the approval check
96
+ * @param callLevelCheck - Optional call-level approval function (overrides tool-level), can be async
97
+ */
98
+ export async function partitionToolCalls(toolCalls, tools, context, callLevelCheck) {
99
+ const requiresApproval = [];
100
+ const autoExecute = [];
101
+ for (const tc of toolCalls) {
102
+ if (await toolRequiresApproval(tc, tools, context, callLevelCheck)) {
103
+ requiresApproval.push(tc);
104
+ }
105
+ else {
106
+ autoExecute.push(tc);
107
+ }
108
+ }
109
+ return { requiresApproval, autoExecute };
110
+ }
111
+ /**
112
+ * Create an unsent tool result from a successful execution
113
+ */
114
+ export function createUnsentResult(callId, name, output) {
115
+ const result = { callId, name, output };
116
+ if (!isValidUnsentToolResult(result)) {
117
+ throw new Error('Invalid UnsentToolResult structure');
118
+ }
119
+ return result;
120
+ }
121
+ /**
122
+ * Create an unsent tool result from a rejection
123
+ */
124
+ export function createRejectedResult(callId, name, reason) {
125
+ const result = {
126
+ callId,
127
+ name,
128
+ output: null,
129
+ error: reason ?? 'Tool call rejected by user',
130
+ };
131
+ if (!isValidUnsentToolResult(result)) {
132
+ throw new Error('Invalid UnsentToolResult structure');
133
+ }
134
+ return result;
135
+ }
136
+ /**
137
+ * Convert unsent tool results to API format for sending to the model
138
+ */
139
+ export function unsentResultsToAPIFormat(results) {
140
+ return results.map(r => ({
141
+ type: 'function_call_output',
142
+ id: `output_${r.callId}`,
143
+ callId: r.callId,
144
+ output: r.error
145
+ ? JSON.stringify({ error: r.error })
146
+ : JSON.stringify(r.output),
147
+ }));
148
+ }
149
+ /**
150
+ * Extract text content from a response
151
+ */
152
+ export function extractTextFromResponse(response) {
153
+ if (!response.output) {
154
+ return '';
155
+ }
156
+ const outputs = Array.isArray(response.output) ? response.output : [response.output];
157
+ const textParts = [];
158
+ for (const item of outputs) {
159
+ if (item.type === 'message' && item.content) {
160
+ for (const content of item.content) {
161
+ if (content.type === 'output_text' && content.text) {
162
+ textParts.push(content.text);
163
+ }
164
+ }
165
+ }
166
+ }
167
+ return textParts.join('');
168
+ }
169
+ /**
170
+ * Extract tool calls from a response
171
+ */
172
+ export function extractToolCallsFromResponse(response) {
173
+ if (!response.output) {
174
+ return [];
175
+ }
176
+ const outputs = Array.isArray(response.output) ? response.output : [response.output];
177
+ const toolCalls = [];
178
+ for (const item of outputs) {
179
+ if (item.type === 'function_call') {
180
+ let parsedArguments;
181
+ if (typeof item.arguments === 'string') {
182
+ try {
183
+ parsedArguments = JSON.parse(item.arguments);
184
+ }
185
+ catch (error) {
186
+ // Log warning and skip malformed tool call, similar to stream-transformers.ts
187
+ console.warn(`Failed to parse arguments for tool call "${item.name}": ${error instanceof Error ? error.message : String(error)}`);
188
+ continue;
189
+ }
190
+ }
191
+ else {
192
+ parsedArguments = item.arguments;
193
+ }
194
+ const toolCall = {
195
+ id: item.callId ?? item.id ?? '',
196
+ name: item.name ?? '',
197
+ arguments: parsedArguments,
198
+ };
199
+ if (!isValidParsedToolCall(toolCall)) {
200
+ throw new Error(`Invalid tool call structure for tool: ${item.name}`);
201
+ }
202
+ toolCalls.push(toolCall);
203
+ }
204
+ }
205
+ return toolCalls;
206
+ }
207
+ //# sourceMappingURL=conversation-state.js.map
@@ -2,13 +2,21 @@ import type { OpenRouterCore } from '../core.js';
2
2
  import type * as models from '../models/index.js';
3
3
  import type { CallModelInput } from './async-params.js';
4
4
  import type { RequestOptions } from './sdks.js';
5
- import type { ResponseStreamEvent, InferToolEventsUnion, ParsedToolCall, StopWhen, Tool, ToolStreamEvent } from './tool-types.js';
5
+ import type { ConversationState, ResponseStreamEvent, InferToolEventsUnion, InferToolOutputsUnion, ParsedToolCall, StateAccessor, StopWhen, Tool, ToolStreamEvent, TurnContext } from './tool-types.js';
6
6
  export interface GetResponseOptions<TTools extends readonly Tool[]> {
7
7
  request: CallModelInput<TTools>;
8
8
  client: OpenRouterCore;
9
9
  options?: RequestOptions;
10
10
  tools?: TTools;
11
11
  stopWhen?: StopWhen<TTools>;
12
+ state?: StateAccessor<TTools>;
13
+ /**
14
+ * Call-level approval check - overrides tool-level requireApproval setting
15
+ * Receives the tool call and turn context, can be sync or async
16
+ */
17
+ requireApproval?: (toolCall: ParsedToolCall<TTools[number]>, context: TurnContext) => boolean | Promise<boolean>;
18
+ approveToolCalls?: string[];
19
+ rejectToolCalls?: string[];
12
20
  }
13
21
  /**
14
22
  * A wrapper around a streaming response that provides multiple consumption patterns.
@@ -31,7 +39,6 @@ export interface GetResponseOptions<TTools extends readonly Tool[]> {
31
39
  */
32
40
  export declare class ModelResult<TTools extends readonly Tool[]> {
33
41
  private reusableStream;
34
- private streamPromise;
35
42
  private textPromise;
36
43
  private options;
37
44
  private initPromise;
@@ -40,21 +47,172 @@ export declare class ModelResult<TTools extends readonly Tool[]> {
40
47
  private toolEventBroadcaster;
41
48
  private allToolExecutionRounds;
42
49
  private resolvedRequest;
50
+ private stateAccessor;
51
+ private currentState;
52
+ private requireApprovalFn;
53
+ private approvedToolCalls;
54
+ private rejectedToolCalls;
55
+ private isResumingFromApproval;
43
56
  constructor(options: GetResponseOptions<TTools>);
44
57
  /**
45
58
  * Get or create the tool event broadcaster (lazy initialization).
46
59
  * Ensures only one broadcaster exists for the lifetime of this ModelResult.
60
+ * Broadcasts both preliminary results and final tool results.
47
61
  */
48
62
  private ensureBroadcaster;
49
63
  /**
50
64
  * Type guard to check if a value is a non-streaming response
65
+ * Only requires 'output' field and absence of 'toReadableStream' method
51
66
  */
52
67
  private isNonStreamingResponse;
68
+ /**
69
+ * Get initial response from stream or cached final response.
70
+ * Consumes the stream to completion if needed to extract the response.
71
+ *
72
+ * @returns The complete non-streaming response
73
+ * @throws Error if neither stream nor response has been initialized
74
+ */
75
+ private getInitialResponse;
76
+ /**
77
+ * Save response output to state.
78
+ * Appends the response output to the message history and records the response ID.
79
+ *
80
+ * @param response - The API response to save
81
+ */
82
+ private saveResponseToState;
83
+ /**
84
+ * Mark state as complete.
85
+ * Sets the conversation status to 'complete' indicating no further tool execution is needed.
86
+ */
87
+ private markStateComplete;
88
+ /**
89
+ * Save tool results to state.
90
+ * Appends tool execution results to the message history for multi-turn context.
91
+ *
92
+ * @param toolResults - The tool execution results to save
93
+ */
94
+ private saveToolResultsToState;
95
+ /**
96
+ * Check if execution should be interrupted by external signal.
97
+ * Polls the state accessor for interruption flags set by external processes.
98
+ *
99
+ * @param currentResponse - The current response to save as partial state
100
+ * @returns True if interrupted and caller should exit, false to continue
101
+ */
102
+ private checkForInterruption;
103
+ /**
104
+ * Check if stop conditions are met.
105
+ * Returns true if execution should stop.
106
+ *
107
+ * @remarks
108
+ * Default: stepCountIs(DEFAULT_MAX_STEPS) if no stopWhen is specified.
109
+ * This evaluates stop conditions against the complete step history.
110
+ */
111
+ private shouldStopExecution;
112
+ /**
113
+ * Check if any tool calls have execute functions.
114
+ * Used to determine if automatic tool execution should be attempted.
115
+ *
116
+ * @param toolCalls - The tool calls to check
117
+ * @returns True if at least one tool call has an executable function
118
+ */
119
+ private hasExecutableToolCalls;
120
+ /**
121
+ * Execute tools that can auto-execute (don't require approval).
122
+ * Processes tool calls that are approved for automatic execution.
123
+ *
124
+ * @param toolCalls - The tool calls to execute
125
+ * @param turnContext - The current turn context
126
+ * @returns Array of unsent tool results for later submission
127
+ */
128
+ private executeAutoApproveTools;
129
+ /**
130
+ * Check for tools requiring approval and handle accordingly.
131
+ * Partitions tool calls into those needing approval and those that can auto-execute.
132
+ *
133
+ * @param toolCalls - The tool calls to check
134
+ * @param currentRound - The current execution round (1-indexed)
135
+ * @param currentResponse - The current response to save if pausing
136
+ * @returns True if execution should pause for approval, false to continue
137
+ * @throws Error if approval is required but no state accessor is configured
138
+ */
139
+ private handleApprovalCheck;
140
+ /**
141
+ * Execute all tools in a single round.
142
+ * Runs each tool call sequentially and collects results for API submission.
143
+ * Emits tool.result events after each tool execution completes.
144
+ *
145
+ * @param toolCalls - The tool calls to execute
146
+ * @param turnContext - The current turn context
147
+ * @returns Array of function call outputs formatted for the API
148
+ */
149
+ private executeToolRound;
150
+ /**
151
+ * Resolve async functions for the current turn.
152
+ * Updates the resolved request with turn-specific parameter values.
153
+ *
154
+ * @param turnContext - The turn context for parameter resolution
155
+ */
156
+ private resolveAsyncFunctionsForTurn;
157
+ /**
158
+ * Apply nextTurnParams from executed tools.
159
+ * Allows tools to modify request parameters for subsequent turns.
160
+ *
161
+ * @param toolCalls - The tool calls that were just executed
162
+ */
163
+ private applyNextTurnParams;
164
+ /**
165
+ * Make a follow-up API request with tool results.
166
+ * Continues the conversation after tool execution.
167
+ *
168
+ * @param currentResponse - The response that contained tool calls
169
+ * @param toolResults - The results from executing those tools
170
+ * @returns The new response from the API
171
+ */
172
+ private makeFollowupRequest;
173
+ /**
174
+ * Validate the final response has required fields.
175
+ *
176
+ * @param response - The response to validate
177
+ * @throws Error if response is missing required fields or has invalid output
178
+ */
179
+ private validateFinalResponse;
180
+ /**
181
+ * Resolve async functions in the request for a given turn context.
182
+ * Extracts non-function fields and resolves any async parameter functions.
183
+ *
184
+ * @param context - The turn context for parameter resolution
185
+ * @returns The resolved request without async functions
186
+ */
187
+ private resolveRequestForContext;
188
+ /**
189
+ * Safely persist state with error handling.
190
+ * Wraps state save operations to ensure failures are properly reported.
191
+ *
192
+ * @param updates - Optional partial state updates to apply before saving
193
+ * @throws Error if state persistence fails
194
+ */
195
+ private saveStateSafely;
196
+ /**
197
+ * Remove optional properties from state when they should be cleared.
198
+ * Uses delete to properly remove optional properties rather than setting undefined.
199
+ *
200
+ * @param props - Array of property names to remove from current state
201
+ */
202
+ private clearOptionalStateProperties;
53
203
  /**
54
204
  * Initialize the stream if not already started
55
205
  * This is idempotent - multiple calls will return the same promise
56
206
  */
57
207
  private initStream;
208
+ /**
209
+ * Process approval/rejection decisions and resume execution
210
+ */
211
+ private processApprovalDecisions;
212
+ /**
213
+ * Continue execution with unsent tool results
214
+ */
215
+ private continueWithUnsentResults;
58
216
  /**
59
217
  * Execute tools automatically if they are provided and have execute functions
60
218
  * This is idempotent - multiple calls will return the same promise
@@ -78,9 +236,9 @@ export declare class ModelResult<TTools extends readonly Tool[]> {
78
236
  /**
79
237
  * Stream all response events as they arrive.
80
238
  * Multiple consumers can iterate over this stream concurrently.
81
- * Preliminary tool results are streamed in REAL-TIME as generator tools yield.
239
+ * Preliminary tool results and tool results are streamed in REAL-TIME as generator tools yield.
82
240
  */
83
- getFullResponsesStream(): AsyncIterableIterator<ResponseStreamEvent<InferToolEventsUnion<TTools>>>;
241
+ getFullResponsesStream(): AsyncIterableIterator<ResponseStreamEvent<InferToolEventsUnion<TTools>, InferToolOutputsUnion<TTools>>>;
84
242
  /**
85
243
  * Stream only text deltas as they arrive.
86
244
  * This filters the full event stream to only yield text content.
@@ -121,5 +279,22 @@ export declare class ModelResult<TTools extends readonly Tool[]> {
121
279
  * Cancel the underlying stream and all consumers
122
280
  */
123
281
  cancel(): Promise<void>;
282
+ /**
283
+ * Check if the conversation requires human approval to continue.
284
+ * Returns true if there are pending tool calls awaiting approval.
285
+ */
286
+ requiresApproval(): Promise<boolean>;
287
+ /**
288
+ * Get the pending tool calls that require approval.
289
+ * Returns empty array if no approvals needed.
290
+ */
291
+ getPendingToolCalls(): Promise<ParsedToolCall<TTools[number]>[]>;
292
+ /**
293
+ * Get the current conversation state.
294
+ * Useful for inspection, debugging, or custom persistence.
295
+ * Note: This returns the raw ConversationState for inspection only.
296
+ * To resume a conversation, use the StateAccessor pattern.
297
+ */
298
+ getState(): Promise<ConversationState<TTools>>;
124
299
  }
125
300
  //# sourceMappingURL=model-result.d.ts.map