@openrouter/sdk 0.3.14 → 0.3.15

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 (129) 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 +175 -2
  51. package/esm/lib/model-result.js +678 -181
  52. package/esm/lib/tool-types.d.ts +108 -0
  53. package/esm/lib/tool-types.js +13 -0
  54. package/esm/lib/tool.d.ts +21 -1
  55. package/esm/lib/tool.js +7 -0
  56. package/esm/models/assistantmessage.d.ts +31 -0
  57. package/esm/models/assistantmessage.js +43 -0
  58. package/esm/models/chatmessagecontentitemimage.d.ts +8 -8
  59. package/esm/models/chatmessagecontentitemimage.js +8 -9
  60. package/esm/models/chatresponsechoice.d.ts +0 -2
  61. package/esm/models/chatresponsechoice.js +0 -3
  62. package/esm/models/chatstreamingmessagechunk.d.ts +2 -2
  63. package/esm/models/chatstreamingmessagechunk.js +2 -2
  64. package/esm/models/index.d.ts +1 -1
  65. package/esm/models/index.js +1 -1
  66. package/esm/models/model.d.ts +4 -0
  67. package/esm/models/model.js +2 -0
  68. package/esm/models/operations/bulkassignkeystoguardrail.d.ts +44 -0
  69. package/esm/models/operations/bulkassignkeystoguardrail.js +42 -0
  70. package/esm/models/operations/bulkassignmemberstoguardrail.d.ts +44 -0
  71. package/esm/models/operations/bulkassignmemberstoguardrail.js +42 -0
  72. package/esm/models/operations/bulkunassignkeysfromguardrail.d.ts +44 -0
  73. package/esm/models/operations/bulkunassignkeysfromguardrail.js +42 -0
  74. package/esm/models/operations/bulkunassignmembersfromguardrail.d.ts +44 -0
  75. package/esm/models/operations/bulkunassignmembersfromguardrail.js +42 -0
  76. package/esm/models/operations/createguardrail.d.ts +136 -0
  77. package/esm/models/operations/createguardrail.js +85 -0
  78. package/esm/models/operations/deleteguardrail.d.ts +29 -0
  79. package/esm/models/operations/deleteguardrail.js +21 -0
  80. package/esm/models/operations/getguardrail.d.ts +92 -0
  81. package/esm/models/operations/getguardrail.js +60 -0
  82. package/esm/models/operations/getmodels.d.ts +28 -1
  83. package/esm/models/operations/getmodels.js +22 -1
  84. package/esm/models/operations/index.d.ts +13 -1
  85. package/esm/models/operations/index.js +13 -1
  86. package/esm/models/operations/listguardrailkeyassignments.d.ts +76 -0
  87. package/esm/models/operations/listguardrailkeyassignments.js +51 -0
  88. package/esm/models/operations/listguardrailmemberassignments.d.ts +72 -0
  89. package/esm/models/operations/listguardrailmemberassignments.js +49 -0
  90. package/esm/models/operations/listguardrails.d.ts +98 -0
  91. package/esm/models/operations/listguardrails.js +66 -0
  92. package/esm/models/operations/listkeyassignments.d.ts +71 -0
  93. package/esm/models/operations/listkeyassignments.js +50 -0
  94. package/esm/models/operations/listmemberassignments.d.ts +67 -0
  95. package/esm/models/operations/listmemberassignments.js +48 -0
  96. package/esm/models/operations/updateguardrail.d.ts +151 -0
  97. package/esm/models/operations/updateguardrail.js +97 -0
  98. package/esm/models/percentilelatencycutoffs.js +1 -1
  99. package/esm/models/percentilestats.js +1 -1
  100. package/esm/models/percentilethroughputcutoffs.js +1 -1
  101. package/esm/models/preferredmaxlatency.js +1 -1
  102. package/esm/models/preferredminthroughput.js +1 -1
  103. package/esm/models/responseinputvideo.js +1 -1
  104. package/esm/models/responsesoutputmodality.js +1 -1
  105. package/esm/models/schema2.d.ts +92 -0
  106. package/esm/models/schema2.js +109 -0
  107. package/esm/sdk/analytics.d.ts +1 -1
  108. package/esm/sdk/analytics.js +1 -1
  109. package/esm/sdk/apikeys.d.ts +15 -0
  110. package/esm/sdk/apikeys.js +15 -0
  111. package/esm/sdk/credits.d.ts +1 -1
  112. package/esm/sdk/credits.js +1 -1
  113. package/esm/sdk/guardrails.d.ts +96 -0
  114. package/esm/sdk/guardrails.js +139 -0
  115. package/esm/sdk/sdk.d.ts +3 -3
  116. package/esm/sdk/sdk.js +4 -4
  117. package/esm/types/index.d.ts +2 -0
  118. package/esm/types/index.js +1 -0
  119. package/esm/types/models.d.ts +25 -0
  120. package/esm/types/models.js +10 -0
  121. package/jsr.json +1 -1
  122. package/package.json +12 -10
  123. package/scripts/check-types.js +127 -0
  124. package/esm/models/operations/getparameters.d.ts +0 -87
  125. package/esm/models/operations/getparameters.js +0 -73
  126. package/esm/models/schema3.d.ts +0 -51
  127. package/esm/models/schema3.js +0 -62
  128. package/esm/sdk/parameters.d.ts +0 -9
  129. 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, 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,6 +47,12 @@ 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).
@@ -48,13 +61,156 @@ export declare class ModelResult<TTools extends readonly Tool[]> {
48
61
  private ensureBroadcaster;
49
62
  /**
50
63
  * Type guard to check if a value is a non-streaming response
64
+ * Only requires 'output' field and absence of 'toReadableStream' method
51
65
  */
52
66
  private isNonStreamingResponse;
67
+ /**
68
+ * Get initial response from stream or cached final response.
69
+ * Consumes the stream to completion if needed to extract the response.
70
+ *
71
+ * @returns The complete non-streaming response
72
+ * @throws Error if neither stream nor response has been initialized
73
+ */
74
+ private getInitialResponse;
75
+ /**
76
+ * Save response output to state.
77
+ * Appends the response output to the message history and records the response ID.
78
+ *
79
+ * @param response - The API response to save
80
+ */
81
+ private saveResponseToState;
82
+ /**
83
+ * Mark state as complete.
84
+ * Sets the conversation status to 'complete' indicating no further tool execution is needed.
85
+ */
86
+ private markStateComplete;
87
+ /**
88
+ * Save tool results to state.
89
+ * Appends tool execution results to the message history for multi-turn context.
90
+ *
91
+ * @param toolResults - The tool execution results to save
92
+ */
93
+ private saveToolResultsToState;
94
+ /**
95
+ * Check if execution should be interrupted by external signal.
96
+ * Polls the state accessor for interruption flags set by external processes.
97
+ *
98
+ * @param currentResponse - The current response to save as partial state
99
+ * @returns True if interrupted and caller should exit, false to continue
100
+ */
101
+ private checkForInterruption;
102
+ /**
103
+ * Check if stop conditions are met.
104
+ * Returns true if execution should stop.
105
+ *
106
+ * @remarks
107
+ * Default: stepCountIs(DEFAULT_MAX_STEPS) if no stopWhen is specified.
108
+ * This evaluates stop conditions against the complete step history.
109
+ */
110
+ private shouldStopExecution;
111
+ /**
112
+ * Check if any tool calls have execute functions.
113
+ * Used to determine if automatic tool execution should be attempted.
114
+ *
115
+ * @param toolCalls - The tool calls to check
116
+ * @returns True if at least one tool call has an executable function
117
+ */
118
+ private hasExecutableToolCalls;
119
+ /**
120
+ * Execute tools that can auto-execute (don't require approval).
121
+ * Processes tool calls that are approved for automatic execution.
122
+ *
123
+ * @param toolCalls - The tool calls to execute
124
+ * @param turnContext - The current turn context
125
+ * @returns Array of unsent tool results for later submission
126
+ */
127
+ private executeAutoApproveTools;
128
+ /**
129
+ * Check for tools requiring approval and handle accordingly.
130
+ * Partitions tool calls into those needing approval and those that can auto-execute.
131
+ *
132
+ * @param toolCalls - The tool calls to check
133
+ * @param currentRound - The current execution round (1-indexed)
134
+ * @param currentResponse - The current response to save if pausing
135
+ * @returns True if execution should pause for approval, false to continue
136
+ * @throws Error if approval is required but no state accessor is configured
137
+ */
138
+ private handleApprovalCheck;
139
+ /**
140
+ * Execute all tools in a single round.
141
+ * Runs each tool call sequentially and collects results for API submission.
142
+ *
143
+ * @param toolCalls - The tool calls to execute
144
+ * @param turnContext - The current turn context
145
+ * @returns Array of function call outputs formatted for the API
146
+ */
147
+ private executeToolRound;
148
+ /**
149
+ * Resolve async functions for the current turn.
150
+ * Updates the resolved request with turn-specific parameter values.
151
+ *
152
+ * @param turnContext - The turn context for parameter resolution
153
+ */
154
+ private resolveAsyncFunctionsForTurn;
155
+ /**
156
+ * Apply nextTurnParams from executed tools.
157
+ * Allows tools to modify request parameters for subsequent turns.
158
+ *
159
+ * @param toolCalls - The tool calls that were just executed
160
+ */
161
+ private applyNextTurnParams;
162
+ /**
163
+ * Make a follow-up API request with tool results.
164
+ * Continues the conversation after tool execution.
165
+ *
166
+ * @param currentResponse - The response that contained tool calls
167
+ * @param toolResults - The results from executing those tools
168
+ * @returns The new response from the API
169
+ */
170
+ private makeFollowupRequest;
171
+ /**
172
+ * Validate the final response has required fields.
173
+ *
174
+ * @param response - The response to validate
175
+ * @throws Error if response is missing required fields or has invalid output
176
+ */
177
+ private validateFinalResponse;
178
+ /**
179
+ * Resolve async functions in the request for a given turn context.
180
+ * Extracts non-function fields and resolves any async parameter functions.
181
+ *
182
+ * @param context - The turn context for parameter resolution
183
+ * @returns The resolved request without async functions
184
+ */
185
+ private resolveRequestForContext;
186
+ /**
187
+ * Safely persist state with error handling.
188
+ * Wraps state save operations to ensure failures are properly reported.
189
+ *
190
+ * @param updates - Optional partial state updates to apply before saving
191
+ * @throws Error if state persistence fails
192
+ */
193
+ private saveStateSafely;
194
+ /**
195
+ * Remove optional properties from state when they should be cleared.
196
+ * Uses delete to properly remove optional properties rather than setting undefined.
197
+ *
198
+ * @param props - Array of property names to remove from current state
199
+ */
200
+ private clearOptionalStateProperties;
53
201
  /**
54
202
  * Initialize the stream if not already started
55
203
  * This is idempotent - multiple calls will return the same promise
56
204
  */
57
205
  private initStream;
206
+ /**
207
+ * Process approval/rejection decisions and resume execution
208
+ */
209
+ private processApprovalDecisions;
210
+ /**
211
+ * Continue execution with unsent tool results
212
+ */
213
+ private continueWithUnsentResults;
58
214
  /**
59
215
  * Execute tools automatically if they are provided and have execute functions
60
216
  * This is idempotent - multiple calls will return the same promise
@@ -121,5 +277,22 @@ export declare class ModelResult<TTools extends readonly Tool[]> {
121
277
  * Cancel the underlying stream and all consumers
122
278
  */
123
279
  cancel(): Promise<void>;
280
+ /**
281
+ * Check if the conversation requires human approval to continue.
282
+ * Returns true if there are pending tool calls awaiting approval.
283
+ */
284
+ requiresApproval(): Promise<boolean>;
285
+ /**
286
+ * Get the pending tool calls that require approval.
287
+ * Returns empty array if no approvals needed.
288
+ */
289
+ getPendingToolCalls(): Promise<ParsedToolCall<TTools[number]>[]>;
290
+ /**
291
+ * Get the current conversation state.
292
+ * Useful for inspection, debugging, or custom persistence.
293
+ * Note: This returns the raw ConversationState for inspection only.
294
+ * To resume a conversation, use the StateAccessor pattern.
295
+ */
296
+ getState(): Promise<ConversationState<TTools>>;
124
297
  }
125
298
  //# sourceMappingURL=model-result.d.ts.map