@dudko.dev/agent 0.0.54 → 0.0.56

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/dist/index.d.cts CHANGED
@@ -220,10 +220,29 @@ interface ISearchOptions {
220
220
  signal?: AbortSignal;
221
221
  }
222
222
  /**
223
- * A search engine of the host's own: any function that answers a query with results. What it
224
- * returns is treated like a built-in adapter's answer - cleaned, capped and filtered.
223
+ * What a search engine function may answer in place of a bare list, when the search ran through a
224
+ * model - a provider's server-side search tool, one model call: the results, what the call spent,
225
+ * the model's own answer and a line on what the results are. Every field is checked as the rest of
226
+ * an engine's answer is (`searchEngineAnswer`).
225
227
  */
226
- type SearchEngine = (query: string, options: ISearchOptions) => Promise<ISearchResult[]>;
228
+ interface ISearchEngineAnswer {
229
+ results: ISearchResult[];
230
+ /**
231
+ * The model tokens the search spent, as its API reported them: charged to the run like the
232
+ * google provider's (a `usage` event of phase 'search', in every total and against the limits).
233
+ */
234
+ usage?: ISearchUsage;
235
+ /** The model's answer from its sources: the model sees it, cut, when no result has a snippet. */
236
+ summary?: string;
237
+ /** One line on what the results are - whose search, what the snippets are - for the model. */
238
+ note?: string;
239
+ }
240
+ /**
241
+ * A search engine of the host's own: any function that answers a query with results - a bare
242
+ * list, or an `ISearchEngineAnswer` with what the search spent. What it returns is treated like a
243
+ * built-in adapter's answer - cleaned, capped and filtered.
244
+ */
245
+ type SearchEngine = (query: string, options: ISearchOptions) => Promise<ISearchResult[] | ISearchEngineAnswer>;
227
246
  /**
228
247
  * The built-in provider. One: Google Search through the Gemini API's grounding (`google_search`),
229
248
  * which needs a Gemini (Google AI Studio) key and nothing else. Any other search API is the
@@ -240,6 +259,8 @@ declare const SEARCH_API_BASE_URL: Record<SearchProvider, string>;
240
259
  declare const SEARCH_GOOGLE_DEFAULT_MODEL = "gemini-2.5-flash-lite";
241
260
  /** The most of the grounding model's answer a model sees as `summary`. */
242
261
  declare const SEARCH_MAX_SUMMARY_CHARS = 1000;
262
+ /** The most of a result list's `note` (what the results are) a model sees. */
263
+ declare const SEARCH_MAX_NOTE_CHARS = 300;
243
264
  /** Said in every result of the google provider: what its URLs and its text are. */
244
265
  declare const SEARCH_GOOGLE_NOTE: string;
245
266
  /** One HTTP call to a search API. The key, if any, is in `headers` only - never in the URL. */
@@ -275,6 +296,8 @@ interface ISearchAnswer {
275
296
  summary?: unknown;
276
297
  /** Absent when the API reported none. */
277
298
  usage?: ISearchUsage;
299
+ /** What the results are (the google provider's `SEARCH_GOOGLE_NOTE`, an engine's own line). */
300
+ note?: string;
278
301
  }
279
302
  /**
280
303
  * The request for one query, per the Gemini API's public documentation:
@@ -292,6 +315,18 @@ declare const buildSearchRequest: (input: ISearchRequestInput) => ISearchRequest
292
315
  * what makes them safe to show.
293
316
  */
294
317
  declare const parseSearchResponse: (provider: SearchProvider, json: unknown) => ISearchAnswer;
318
+ /**
319
+ * What a search spent, as an engine reported it: whole non-negative token counts (anything else
320
+ * is 0), the total their sum, reasoning never more than the output. Undefined when it spent none.
321
+ */
322
+ declare const searchUsageOf: (raw: unknown) => ISearchUsage | undefined;
323
+ /**
324
+ * An engine's answer as the tool reads it. A bare list is the results and nothing else (no usage,
325
+ * no summary, no note); an `ISearchEngineAnswer` gives its `results` and - checked - its usage
326
+ * (`searchUsageOf`), its summary (a string; cleaned and cut when it is shown) and its note (cleaned
327
+ * and cut here). Anything else is no results. Still raw until `sanitizeSearchResults`.
328
+ */
329
+ declare const searchEngineAnswer: (raw: unknown) => ISearchAnswer;
295
330
  /**
296
331
  * What a failed call says to the model: the provider, the model, the status, the API's own error
297
332
  * code word and what it usually means. Never the error's text: that is third-party text, and may
@@ -319,18 +354,19 @@ declare const sanitizeSearchResults: (raw: unknown, options?: {
319
354
  interface ISearchToolResult {
320
355
  query: string;
321
356
  results: ISearchResult[];
322
- /** The google provider, when no source came with a snippet: the grounding model's answer, cut. */
357
+ /** When no source came with a snippet: the grounding (or engine's) model's answer, cut. */
323
358
  summary?: string;
324
- /** The google provider: what its URLs and its text are. */
359
+ /** What the URLs and the text are: the google provider's note, or an engine's own line. */
325
360
  note?: string;
326
361
  filtered?: number;
327
362
  truncated?: true;
328
363
  untrusted: true;
329
364
  }
330
365
  /**
331
- * The tool's result, from the cleaned list and - for the google provider - the parsed answer.
332
- * The model's `summary` is attached only when there are sources, none of them carries a snippet
333
- * and none was filtered out: a summary cannot be cut to the sources that remain.
366
+ * The tool's result, from the cleaned list and the parsed answer (the google provider's, or an
367
+ * engine's `searchEngineAnswer`). The model's `summary` is attached only when there are sources,
368
+ * none of them carries a snippet and none was filtered out: a summary cannot be cut to the sources
369
+ * that remain. The answer's `note` goes with every result list, cleaned and cut.
334
370
  */
335
371
  declare const searchToolResult: (query: string, clean: ISanitizedSearch, answer?: ISearchAnswer) => ISearchToolResult;
336
372
 
@@ -1010,6 +1046,141 @@ declare const adoptSubagentEvent: <E extends {
1010
1046
  type: string;
1011
1047
  }>(event: E, parentId: string) => E;
1012
1048
 
1049
+ declare const ASK_USER_TOOL = "ask_user";
1050
+ /** How long one question waits for the person, by default: a human is reading it. */
1051
+ declare const ASK_USER_TIMEOUT_MS = 300000;
1052
+ /**
1053
+ * The longest wait a timer holds (2^31 - 1 ms, about 24.8 days). `setTimeout` fires a longer one -
1054
+ * Infinity included - after about 1 ms, so a `timeoutMs` past it is taken as no limit at all.
1055
+ */
1056
+ declare const ASK_USER_TIMEOUT_MAX_MS = 2147483647;
1057
+ /** The most questions one run may ask, by default (its helpers' and subagents' included). */
1058
+ declare const ASK_USER_MAX_PER_RUN = 3;
1059
+ /** A question offers at least this many options... */
1060
+ declare const ASK_USER_MIN_OPTIONS = 2;
1061
+ /** ...and at most this many. */
1062
+ declare const ASK_USER_MAX_OPTIONS = 6;
1063
+ /** The longest question, in characters (after cleaning). */
1064
+ declare const ASK_USER_QUESTION_MAX_CHARS = 500;
1065
+ /** The longest option label. */
1066
+ declare const ASK_USER_LABEL_MAX_CHARS = 80;
1067
+ /** The longest option description. */
1068
+ declare const ASK_USER_DESCRIPTION_MAX_CHARS = 200;
1069
+ /** The most of a person's own words (`{ other }`) the model is given; the rest is cut. */
1070
+ declare const ASK_USER_OTHER_MAX_CHARS = 2000;
1071
+ /** One option of a question, as the person is shown it. Both strings are the MODEL's, cleaned. */
1072
+ interface AskUserOption {
1073
+ label: string;
1074
+ description?: string;
1075
+ }
1076
+ /** A question as checked and cleaned: what a host shows and an event carries. */
1077
+ interface AskUserQuestion {
1078
+ question: string;
1079
+ options: AskUserOption[];
1080
+ /** The person may pick several options. */
1081
+ multiple: boolean;
1082
+ /** The person may answer in their own words instead of picking. */
1083
+ allowOther: boolean;
1084
+ }
1085
+ /** What the host's `onQuestion` is given. Every string in it is the model's text, cleaned. */
1086
+ interface AskUserRequest<TStep = unknown> extends AskUserQuestion {
1087
+ /** Unique per question; the same id is in the two events. */
1088
+ id: string;
1089
+ /** The plan step whose tool call asks. */
1090
+ step?: TStep;
1091
+ runId?: string;
1092
+ /** Set when a helper or a subagent of the run asks, not the run itself: its id and depth. */
1093
+ subagent?: {
1094
+ id: string;
1095
+ depth: number;
1096
+ };
1097
+ }
1098
+ /**
1099
+ * The person's answer: the labels they picked (exactly as offered; one unless `multiple`), their
1100
+ * own words (only when `allowOther`), or that they would rather not answer.
1101
+ */
1102
+ type AskUserAnswer = {
1103
+ choice: string[];
1104
+ } | {
1105
+ other: string;
1106
+ } | {
1107
+ declined: true;
1108
+ };
1109
+ interface AskUserContext {
1110
+ /**
1111
+ * Aborted when the question ends WITHOUT the host's answer: no answer within `timeoutMs`
1112
+ * (`signal.reason` is an Error named 'TimeoutError'), the run was stopped, or the handler
1113
+ * failed. Take the prompt down then: an answer given later is ignored. Never aborted once the
1114
+ * host has answered.
1115
+ */
1116
+ signal: AbortSignal;
1117
+ }
1118
+ /** How a question ended. `automatic`: nobody decided (a time limit, a stop, a failed handler). */
1119
+ type AskUserAction = 'choice' | 'other' | 'declined' | 'timeout' | 'stopped';
1120
+ /** Why a question was closed as `declined` without the person deciding. */
1121
+ type AskUserReason = 'handler-error' | 'invalid-answer' | 'cannot-park';
1122
+ /** The two events of a question. Neither ever carries the person's own words. */
1123
+ type AskUserEvent<TStep = unknown> = {
1124
+ type: 'user.question-asked';
1125
+ id: string;
1126
+ question: string;
1127
+ options: AskUserOption[];
1128
+ multiple: boolean;
1129
+ allowOther: boolean;
1130
+ step?: TStep;
1131
+ subagent?: {
1132
+ id: string;
1133
+ depth: number;
1134
+ };
1135
+ } | {
1136
+ type: 'user.question-answered';
1137
+ id: string;
1138
+ action: AskUserAction;
1139
+ /** true when nobody decided: a time limit, a stop, a failed handler, an unusable answer. */
1140
+ automatic: boolean;
1141
+ /** Action 'choice': the labels picked. Never the text of an `other` answer. */
1142
+ choice?: string[];
1143
+ /** Action 'declined' with `automatic`: why. */
1144
+ reason?: AskUserReason;
1145
+ };
1146
+ /** A bad `ask_user` input: the tool call fails with this message, which says what to fix. */
1147
+ declare class AskUserInputError extends Error {
1148
+ constructor(message: string);
1149
+ toJSON(): string;
1150
+ }
1151
+ /** The model's text as a person may be shown it: a string, invisible characters removed, trimmed. */
1152
+ declare const cleanAskUserText: (raw: unknown, oneLine?: boolean) => string;
1153
+ /**
1154
+ * Check and clean the model's `ask_user` arguments: 2-6 options, no two labels alike (letter case
1155
+ * and spaces aside), each label 1-80 characters, a description at most 200, a question of 1-500 -
1156
+ * all measured after cleaning. An option may be given as a bare string (its label). Throws
1157
+ * {@link AskUserInputError} with what to fix.
1158
+ */
1159
+ declare const checkAskUserInput: (raw: unknown) => AskUserQuestion;
1160
+ /** An answer as checked: what the model is told. */
1161
+ type AskUserCheckedAnswer = {
1162
+ kind: 'choice';
1163
+ choice: string[];
1164
+ } | {
1165
+ kind: 'other';
1166
+ text: string;
1167
+ } | {
1168
+ kind: 'declined';
1169
+ };
1170
+ /**
1171
+ * Check the host's answer against the question: exactly one of `choice` (labels that were
1172
+ * offered, no repeats, one unless `multiple`), `other` (a non-empty text, only when `allowOther`;
1173
+ * cleaned and cut at {@link ASK_USER_OTHER_MAX_CHARS}) or `declined: true`. Anything else is not
1174
+ * an answer.
1175
+ */
1176
+ declare const checkAskUserAnswer: (q: AskUserQuestion, raw: unknown) => {
1177
+ ok: true;
1178
+ value: AskUserCheckedAnswer;
1179
+ } | {
1180
+ ok: false;
1181
+ reason: string;
1182
+ };
1183
+
1013
1184
  type ProviderType = 'openai' | 'anthropic' | 'openai-compatible' | 'google' | 'xai' | 'azure' | 'amazon-bedrock' | 'google-vertex' | 'deepseek' | 'gateway' | 'cloudflare';
1014
1185
  type AgentModel = Exclude<LanguageModel, string>;
1015
1186
  type LogLevel = 'none' | 'error' | 'warn' | 'info' | 'debug';
@@ -1128,6 +1299,16 @@ type ToolApprovalAnswer = boolean | {
1128
1299
  type ToolApprovalDecision = ToolApprovalAnswer | {
1129
1300
  park: true;
1130
1301
  };
1302
+ type IAskUserRequest = AskUserRequest<IPlanStep>;
1303
+ type AskUserDecision = AskUserAnswer | {
1304
+ park: true;
1305
+ };
1306
+ type AskUserHandler = (request: IAskUserRequest, ctx: AskUserContext) => AskUserDecision | Promise<AskUserDecision>;
1307
+ interface IAskUserConfig {
1308
+ onQuestion?: AskUserHandler;
1309
+ timeoutMs?: number;
1310
+ maxPerRun?: number;
1311
+ }
1131
1312
  interface IToolApprovalConfig {
1132
1313
  mode?: ToolApprovalMode;
1133
1314
  rules?: Record<string, ToolPermission>;
@@ -1211,6 +1392,7 @@ interface IAgentConfig {
1211
1392
  compaction?: ICompactionConfig;
1212
1393
  skills?: ISkill[];
1213
1394
  toolApproval?: IToolApprovalConfig;
1395
+ askUser?: boolean | IAskUserConfig;
1214
1396
  toolSearchThreshold?: number;
1215
1397
  mcpConnectTimeoutMs?: number;
1216
1398
  onElicitation?: McpElicitationHandler;
@@ -1404,7 +1586,7 @@ type AgentEventBody = {
1404
1586
  reason?: string;
1405
1587
  automatic: boolean;
1406
1588
  parked?: true;
1407
- } | {
1589
+ } | AskUserEvent<IPlanStep> | {
1408
1590
  type: 'mcp.elicitation-requested';
1409
1591
  id: string;
1410
1592
  server: string;
@@ -1607,6 +1789,7 @@ interface IRunSnapshot {
1607
1789
  }[];
1608
1790
  escalations?: number;
1609
1791
  subagentsSpawned?: number;
1792
+ questionsAsked?: number;
1610
1793
  attempt?: number;
1611
1794
  leaseOwner?: string;
1612
1795
  parked?: IParkedRun;
@@ -2705,5 +2888,5 @@ declare const REMOTE_SUBAGENT_LIMITS: {
2705
2888
  */
2706
2889
  declare const createSubagentTool: (opts: ISubagentToolOptions) => Tool;
2707
2890
 
2708
- export { DEFAULT_COMPACTION_THRESHOLD_RATIO, DEFAULT_DECISION_CONFIDENCE_THRESHOLD, DEFAULT_DECISION_TIMEOUT_MS, DirSkillStore, ENTERPRISE_MANAGED_AUTHORIZATION_EXTENSION, EgressError, EnterpriseOAuthError, FORGET_SKILL_TOOL, FileOAuthStore, GENERATE_IMAGE_TOOL, GENERATE_SPEECH_TOOL, JOURNAL_LIMITS, JournalError, MCP_ELICITATION_MAX_PER_RUN, MCP_ELICITATION_MAX_PER_TOOL_CALL, MCP_ELICITATION_TIMEOUT_MS, MCP_INSTRUCTIONS_MAX_CHARS_PER_SERVER, MCP_INSTRUCTIONS_MAX_CHARS_TOTAL, MCP_MODERN_PROTOCOL_VERSION, MCP_SKILLS_EXTENSION, MCP_SKILLS_MAX_PER_SERVER, MCP_SKILLS_MAX_TOTAL, MCP_SKILL_BODY_MAX_CHARS, MCP_SKILL_CONSENTS, MCP_SKILL_CONSENT_DEFAULT, MCP_SKILL_DESCRIPTION_MAX_CHARS, MCP_SKILL_DIRECTORY_ENTRIES_MAX, MCP_SKILL_FILE_MAX_CHARS, MCP_SKILL_MAX_RESOURCES, MCP_SKILL_MAX_TOTAL_BYTES, MCP_SKILL_SNAPSHOTS_MAX_BYTES, MCP_SKILL_SNAPSHOT_MAX_DEPTH, MCP_SKILL_SNAPSHOT_MAX_DIRECTORIES, MCP_SKILL_URI_MAX_CHARS, MEDIA_AUDIO_TYPES, MEDIA_DEFAULT_MAX_CALLS, MEDIA_FOLDER, MEDIA_IMAGE_TYPES, MEDIA_MAX_ATTACHED_AUDIO, MEDIA_MAX_AUDIO_INPUT_BYTES, MEDIA_MAX_IMAGE_BYTES, MEDIA_MAX_PROMPT_CHARS, MEDIA_MAX_SPEECH_BYTES, MEDIA_MAX_SPEECH_CHARS, MEDIA_MAX_TRANSCRIPT_CHARS, MEDIA_TIMEOUT_MS, MediaBudgetError, MediaError, MemoryOAuthStore, MemorySkillStore, ModelCallRefusedError, NodeEnterpriseOAuthProvider, NodeOAuthProvider, PipelineDefinition, PipelineEvent, PipelineNode, PipelineNodeRunner, PipelineResult, REMOTE_SUBAGENT_LIMITS, REPLAY_NOTE, RUN_JS_TOOL, RUN_LEASE_DEFAULT_TTL_MS, RunLeaseError, SAVE_SKILL_TOOL, SEARCH_API_BASE_URL, SEARCH_DEFAULT_MAX_RESULTS, SEARCH_GOOGLE_DEFAULT_MODEL, SEARCH_GOOGLE_NOTE, SEARCH_MAX_QUERY_CHARS, SEARCH_MAX_RESULTS, SEARCH_MAX_SNIPPET_CHARS, SEARCH_MAX_SUMMARY_CHARS, SEARCH_MAX_TITLE_CHARS, SEARCH_MAX_TOTAL_CHARS, SEARCH_MAX_URL_CHARS, SEARCH_PROVIDERS, SPAWN_INPUT_SCHEMA, SPAWN_SUBAGENT_TOOL, SUBAGENT_DEFAULTS, SUBAGENT_MAX_DEPTH_LIMIT, SUMMARY_PREFIX, SandboxUnavailableError, SubagentSpawnError, TOOL_APPROVAL_TIMEOUT_MS, TRANSCRIBE_AUDIO_TOOL, ToolBudgetError, ToolDeniedError, WEB_FETCH_TOOL, WEB_SEARCH_TOOL, acceptMedia, addUsage, adoptSubagentEvent, askDecisionModel, beginMcpOAuth, buildInstructions, buildMediaModelFromStage, buildSearchRequest, checkAuthorizationResponseIssuer, checkEgressUrl, checkLimits, checkRedirect, classifyAddress, compactHistory, createAgent, createEgressTools, createEnterpriseOAuthProvider, createLearning, createMedia, createNodeOAuthProvider, createPipeline, createRunControl, createSafeFetch, createSandboxTool, createSandboxTools, createSearchTools, createSubagentTool, createToolResultClearer, createWebFetchTool, createWebSearchTool, decideToolPermission, decisionModelFromAiSdk, deferResult, defineSkill, estimateTokens, findSecret, finishMcpOAuth, getCurrentRunId, getCurrentRunSandbox, hostMatches, htmlToText, isAuthError, isCodeExecutionTool, isDeferredResult, isModelCallRefused, isReadOnlyTool, isReplayedToolOutput, loadSkillsFromDir, markCodeExecution, markReadOnly, matchToolRule, mcpSkillEntryRefusal, mcpSkillPreamble, mcpSkillUriRefusal, mediaUsageOf, mergeProviderOptions, nodeResolver, normalizeMcpElicitationSchema, normalizeSkillName, normalizeUsage, parseSearchResponse, parseSkillMarkdown, pickPipelineRoute, redactHeaders, renderMcpInstructions, resolveCompaction, resolveDynamicSubagents, resolveEgressPolicy, resolveLimits, resolvePromptCaching, resolveSandboxLimits, resolveThinking, sanitizeSearchResults, searchEgressPolicy, searchStatusMessage, searchToolResult, searchTools, sniffMediaType, truncateToolModelOutput, validateMcpElicitationContent, withRollingBreakpoint, withToolOutputLimit, wrapTranscript };
2709
- export type { AgentEvent, AgentModel, AgentStage, BudgetKind, DecisionFallbackReason, DecisionPoint, EgressErrorCode, EnterpriseAssertionAlgorithm, EnterpriseAssertionAudience, EnterpriseAssertionType, EnterpriseOAuthHop, EnterpriseOAuthLog, EnterprisePrivateKey, EscalationReason, EventHandler, IAgent, IAgentConfig, IAgentRunOptions, IAgentRunResult, IAgentStageOverride, IAiSdkDecisionOptions, IClearedInfo, ICloseOptions, ICompactHistoryOptions, ICompactHistoryResult, ICompactOptions, ICompactResult, ICompactionConfig, IConversationTurn, IDecisionAnswer, IDecisionCallOptions, IDecisionConfig, IDecisionEvent, IDecisionModel, IDecisionOption, IDecisionOutcome, IDecisionQuestion, IDeferredResult, IDynamicSubagentsConfig, IEgressPolicy, IEnterpriseIdpOptions, IEnterpriseOAuthProviderOptions, IEscalationConfig, IJournalAnswerEntry, IJournalEntry, IJournalModelEntry, IJournalPendingEntry, IJournalToolEntry, ILearning, ILearningConfig, ILimitBreach, ILocalSubagentToolOptions, IMcpHttpServerConfig, IMcpServerConfig, IMcpSkillOrigin, IMcpStdioServerConfig, IMedia, IMediaConfig, IMediaFile, IMediaModelSpec, IMediaUsage, IModelCall, INodeOAuthProviderOptions, IOAuthRequestOptions, IOAuthStore, IParkedRun, IPersistence, IPlan, IPlanStep, IRemoteSubagentContext, IRemoteSubagentResult, IRemoteSubagentTask, IRemoteSubagentToolOptions, IResolvedAddress, IResolvedDynamicSubagents, IResolvedThinking, IRunFile, IRunJournal, IRunLease, IRunLeaseOptions, IRunSnapshot, ISandboxConfig, ISandboxError, ISandboxLimits, ISandboxResult, ISanitizedSearch, ISaveSkillInput, ISearchAnswer, ISearchConfig, ISearchOptions, ISearchRequest, ISearchResult, ISearchToolResult, ISearchToolsOptions, ISearchUsage, ISharedLimits, ISkill, ISkillOrigin, ISkillStore, IStepEscalation, IStepResult, IStepStartInfo, ISubagentProfile, ISubagentToolOptions, ISubagentsConfig, IThinkingConfig, ITokenLimits, IToolApprovalConfig, IToolApprovalContext, IToolApprovalRequest, IToolCatalogEntry, IToolDecision, IToolDecisionInput, IToolResultClearing, ITranscription, IUsage, IWebSearchOptions, LogLevel, McpElicitationContent, McpElicitationContext, McpElicitationFieldSchema, McpElicitationHandler, McpElicitationOptions, McpElicitationReason, McpElicitationRequest, McpElicitationResult, McpElicitationSchema, McpOAuthRegistration, McpOAuthRegistrationKind, McpProtocolMode, McpServerInstructions, McpServerProtocol, McpSkillConsent, McpSkillConsentView, McpSkillsOptions, McpSkillsSetting, MediaImageModel, MediaKind, MediaModelKind, MediaSpeechModel, MediaTranscriptionModel, ModelCallStage, ModelTier, NodeResolverOptions, ParkAnswer, ParkedItem, Pipeline, PipelineModelConfig, PipelineOptions, PipelineRouteOptions, PipelineRouteResult, PipelineRunOptions, PromptCachingSetting, ProviderType, RemoteSubagentDispatch, ReplanCause, ReplanTrigger, RunControl, RunLeaseLostReason, SafeFetch, SearchEngine, SearchFreshness, SearchProvider, SkillDirectoryListing, StepComplexity, SubagentDefaultTools, SubagentInfo, SubagentIsolation, ThinkingLevel, ThinkingSetting, TierReason, TokenLimitKind, ToolApprovalAnswer, ToolApprovalDecision, ToolApprovalMode, ToolPermission, ToolResultAnswer, ToolSelectionStrategy, UsagePhase };
2891
+ export { ASK_USER_DESCRIPTION_MAX_CHARS, ASK_USER_LABEL_MAX_CHARS, ASK_USER_MAX_OPTIONS, ASK_USER_MAX_PER_RUN, ASK_USER_MIN_OPTIONS, ASK_USER_OTHER_MAX_CHARS, ASK_USER_QUESTION_MAX_CHARS, ASK_USER_TIMEOUT_MAX_MS, ASK_USER_TIMEOUT_MS, ASK_USER_TOOL, AskUserInputError, DEFAULT_COMPACTION_THRESHOLD_RATIO, DEFAULT_DECISION_CONFIDENCE_THRESHOLD, DEFAULT_DECISION_TIMEOUT_MS, DirSkillStore, ENTERPRISE_MANAGED_AUTHORIZATION_EXTENSION, EgressError, EnterpriseOAuthError, FORGET_SKILL_TOOL, FileOAuthStore, GENERATE_IMAGE_TOOL, GENERATE_SPEECH_TOOL, JOURNAL_LIMITS, JournalError, MCP_ELICITATION_MAX_PER_RUN, MCP_ELICITATION_MAX_PER_TOOL_CALL, MCP_ELICITATION_TIMEOUT_MS, MCP_INSTRUCTIONS_MAX_CHARS_PER_SERVER, MCP_INSTRUCTIONS_MAX_CHARS_TOTAL, MCP_MODERN_PROTOCOL_VERSION, MCP_SKILLS_EXTENSION, MCP_SKILLS_MAX_PER_SERVER, MCP_SKILLS_MAX_TOTAL, MCP_SKILL_BODY_MAX_CHARS, MCP_SKILL_CONSENTS, MCP_SKILL_CONSENT_DEFAULT, MCP_SKILL_DESCRIPTION_MAX_CHARS, MCP_SKILL_DIRECTORY_ENTRIES_MAX, MCP_SKILL_FILE_MAX_CHARS, MCP_SKILL_MAX_RESOURCES, MCP_SKILL_MAX_TOTAL_BYTES, MCP_SKILL_SNAPSHOTS_MAX_BYTES, MCP_SKILL_SNAPSHOT_MAX_DEPTH, MCP_SKILL_SNAPSHOT_MAX_DIRECTORIES, MCP_SKILL_URI_MAX_CHARS, MEDIA_AUDIO_TYPES, MEDIA_DEFAULT_MAX_CALLS, MEDIA_FOLDER, MEDIA_IMAGE_TYPES, MEDIA_MAX_ATTACHED_AUDIO, MEDIA_MAX_AUDIO_INPUT_BYTES, MEDIA_MAX_IMAGE_BYTES, MEDIA_MAX_PROMPT_CHARS, MEDIA_MAX_SPEECH_BYTES, MEDIA_MAX_SPEECH_CHARS, MEDIA_MAX_TRANSCRIPT_CHARS, MEDIA_TIMEOUT_MS, MediaBudgetError, MediaError, MemoryOAuthStore, MemorySkillStore, ModelCallRefusedError, NodeEnterpriseOAuthProvider, NodeOAuthProvider, PipelineDefinition, PipelineEvent, PipelineNode, PipelineNodeRunner, PipelineResult, REMOTE_SUBAGENT_LIMITS, REPLAY_NOTE, RUN_JS_TOOL, RUN_LEASE_DEFAULT_TTL_MS, RunLeaseError, SAVE_SKILL_TOOL, SEARCH_API_BASE_URL, SEARCH_DEFAULT_MAX_RESULTS, SEARCH_GOOGLE_DEFAULT_MODEL, SEARCH_GOOGLE_NOTE, SEARCH_MAX_NOTE_CHARS, SEARCH_MAX_QUERY_CHARS, SEARCH_MAX_RESULTS, SEARCH_MAX_SNIPPET_CHARS, SEARCH_MAX_SUMMARY_CHARS, SEARCH_MAX_TITLE_CHARS, SEARCH_MAX_TOTAL_CHARS, SEARCH_MAX_URL_CHARS, SEARCH_PROVIDERS, SPAWN_INPUT_SCHEMA, SPAWN_SUBAGENT_TOOL, SUBAGENT_DEFAULTS, SUBAGENT_MAX_DEPTH_LIMIT, SUMMARY_PREFIX, SandboxUnavailableError, SubagentSpawnError, TOOL_APPROVAL_TIMEOUT_MS, TRANSCRIBE_AUDIO_TOOL, ToolBudgetError, ToolDeniedError, WEB_FETCH_TOOL, WEB_SEARCH_TOOL, acceptMedia, addUsage, adoptSubagentEvent, askDecisionModel, beginMcpOAuth, buildInstructions, buildMediaModelFromStage, buildSearchRequest, checkAskUserAnswer, checkAskUserInput, checkAuthorizationResponseIssuer, checkEgressUrl, checkLimits, checkRedirect, classifyAddress, cleanAskUserText, compactHistory, createAgent, createEgressTools, createEnterpriseOAuthProvider, createLearning, createMedia, createNodeOAuthProvider, createPipeline, createRunControl, createSafeFetch, createSandboxTool, createSandboxTools, createSearchTools, createSubagentTool, createToolResultClearer, createWebFetchTool, createWebSearchTool, decideToolPermission, decisionModelFromAiSdk, deferResult, defineSkill, estimateTokens, findSecret, finishMcpOAuth, getCurrentRunId, getCurrentRunSandbox, hostMatches, htmlToText, isAuthError, isCodeExecutionTool, isDeferredResult, isModelCallRefused, isReadOnlyTool, isReplayedToolOutput, loadSkillsFromDir, markCodeExecution, markReadOnly, matchToolRule, mcpSkillEntryRefusal, mcpSkillPreamble, mcpSkillUriRefusal, mediaUsageOf, mergeProviderOptions, nodeResolver, normalizeMcpElicitationSchema, normalizeSkillName, normalizeUsage, parseSearchResponse, parseSkillMarkdown, pickPipelineRoute, redactHeaders, renderMcpInstructions, resolveCompaction, resolveDynamicSubagents, resolveEgressPolicy, resolveLimits, resolvePromptCaching, resolveSandboxLimits, resolveThinking, sanitizeSearchResults, searchEgressPolicy, searchEngineAnswer, searchStatusMessage, searchToolResult, searchTools, searchUsageOf, sniffMediaType, truncateToolModelOutput, validateMcpElicitationContent, withRollingBreakpoint, withToolOutputLimit, wrapTranscript };
2892
+ export type { AgentEvent, AgentModel, AgentStage, AskUserAction, AskUserAnswer, AskUserCheckedAnswer, AskUserContext, AskUserDecision, AskUserHandler, AskUserOption, AskUserQuestion, AskUserReason, BudgetKind, DecisionFallbackReason, DecisionPoint, EgressErrorCode, EnterpriseAssertionAlgorithm, EnterpriseAssertionAudience, EnterpriseAssertionType, EnterpriseOAuthHop, EnterpriseOAuthLog, EnterprisePrivateKey, EscalationReason, EventHandler, IAgent, IAgentConfig, IAgentRunOptions, IAgentRunResult, IAgentStageOverride, IAiSdkDecisionOptions, IAskUserConfig, IAskUserRequest, IClearedInfo, ICloseOptions, ICompactHistoryOptions, ICompactHistoryResult, ICompactOptions, ICompactResult, ICompactionConfig, IConversationTurn, IDecisionAnswer, IDecisionCallOptions, IDecisionConfig, IDecisionEvent, IDecisionModel, IDecisionOption, IDecisionOutcome, IDecisionQuestion, IDeferredResult, IDynamicSubagentsConfig, IEgressPolicy, IEnterpriseIdpOptions, IEnterpriseOAuthProviderOptions, IEscalationConfig, IJournalAnswerEntry, IJournalEntry, IJournalModelEntry, IJournalPendingEntry, IJournalToolEntry, ILearning, ILearningConfig, ILimitBreach, ILocalSubagentToolOptions, IMcpHttpServerConfig, IMcpServerConfig, IMcpSkillOrigin, IMcpStdioServerConfig, IMedia, IMediaConfig, IMediaFile, IMediaModelSpec, IMediaUsage, IModelCall, INodeOAuthProviderOptions, IOAuthRequestOptions, IOAuthStore, IParkedRun, IPersistence, IPlan, IPlanStep, IRemoteSubagentContext, IRemoteSubagentResult, IRemoteSubagentTask, IRemoteSubagentToolOptions, IResolvedAddress, IResolvedDynamicSubagents, IResolvedThinking, IRunFile, IRunJournal, IRunLease, IRunLeaseOptions, IRunSnapshot, ISandboxConfig, ISandboxError, ISandboxLimits, ISandboxResult, ISanitizedSearch, ISaveSkillInput, ISearchAnswer, ISearchConfig, ISearchEngineAnswer, ISearchOptions, ISearchRequest, ISearchResult, ISearchToolResult, ISearchToolsOptions, ISearchUsage, ISharedLimits, ISkill, ISkillOrigin, ISkillStore, IStepEscalation, IStepResult, IStepStartInfo, ISubagentProfile, ISubagentToolOptions, ISubagentsConfig, IThinkingConfig, ITokenLimits, IToolApprovalConfig, IToolApprovalContext, IToolApprovalRequest, IToolCatalogEntry, IToolDecision, IToolDecisionInput, IToolResultClearing, ITranscription, IUsage, IWebSearchOptions, LogLevel, McpElicitationContent, McpElicitationContext, McpElicitationFieldSchema, McpElicitationHandler, McpElicitationOptions, McpElicitationReason, McpElicitationRequest, McpElicitationResult, McpElicitationSchema, McpOAuthRegistration, McpOAuthRegistrationKind, McpProtocolMode, McpServerInstructions, McpServerProtocol, McpSkillConsent, McpSkillConsentView, McpSkillsOptions, McpSkillsSetting, MediaImageModel, MediaKind, MediaModelKind, MediaSpeechModel, MediaTranscriptionModel, ModelCallStage, ModelTier, NodeResolverOptions, ParkAnswer, ParkedItem, Pipeline, PipelineModelConfig, PipelineOptions, PipelineRouteOptions, PipelineRouteResult, PipelineRunOptions, PromptCachingSetting, ProviderType, RemoteSubagentDispatch, ReplanCause, ReplanTrigger, RunControl, RunLeaseLostReason, SafeFetch, SearchEngine, SearchFreshness, SearchProvider, SkillDirectoryListing, StepComplexity, SubagentDefaultTools, SubagentInfo, SubagentIsolation, ThinkingLevel, ThinkingSetting, TierReason, TokenLimitKind, ToolApprovalAnswer, ToolApprovalDecision, ToolApprovalMode, ToolPermission, ToolResultAnswer, ToolSelectionStrategy, UsagePhase };
package/dist/index.d.ts CHANGED
@@ -220,10 +220,29 @@ interface ISearchOptions {
220
220
  signal?: AbortSignal;
221
221
  }
222
222
  /**
223
- * A search engine of the host's own: any function that answers a query with results. What it
224
- * returns is treated like a built-in adapter's answer - cleaned, capped and filtered.
223
+ * What a search engine function may answer in place of a bare list, when the search ran through a
224
+ * model - a provider's server-side search tool, one model call: the results, what the call spent,
225
+ * the model's own answer and a line on what the results are. Every field is checked as the rest of
226
+ * an engine's answer is (`searchEngineAnswer`).
225
227
  */
226
- type SearchEngine = (query: string, options: ISearchOptions) => Promise<ISearchResult[]>;
228
+ interface ISearchEngineAnswer {
229
+ results: ISearchResult[];
230
+ /**
231
+ * The model tokens the search spent, as its API reported them: charged to the run like the
232
+ * google provider's (a `usage` event of phase 'search', in every total and against the limits).
233
+ */
234
+ usage?: ISearchUsage;
235
+ /** The model's answer from its sources: the model sees it, cut, when no result has a snippet. */
236
+ summary?: string;
237
+ /** One line on what the results are - whose search, what the snippets are - for the model. */
238
+ note?: string;
239
+ }
240
+ /**
241
+ * A search engine of the host's own: any function that answers a query with results - a bare
242
+ * list, or an `ISearchEngineAnswer` with what the search spent. What it returns is treated like a
243
+ * built-in adapter's answer - cleaned, capped and filtered.
244
+ */
245
+ type SearchEngine = (query: string, options: ISearchOptions) => Promise<ISearchResult[] | ISearchEngineAnswer>;
227
246
  /**
228
247
  * The built-in provider. One: Google Search through the Gemini API's grounding (`google_search`),
229
248
  * which needs a Gemini (Google AI Studio) key and nothing else. Any other search API is the
@@ -240,6 +259,8 @@ declare const SEARCH_API_BASE_URL: Record<SearchProvider, string>;
240
259
  declare const SEARCH_GOOGLE_DEFAULT_MODEL = "gemini-2.5-flash-lite";
241
260
  /** The most of the grounding model's answer a model sees as `summary`. */
242
261
  declare const SEARCH_MAX_SUMMARY_CHARS = 1000;
262
+ /** The most of a result list's `note` (what the results are) a model sees. */
263
+ declare const SEARCH_MAX_NOTE_CHARS = 300;
243
264
  /** Said in every result of the google provider: what its URLs and its text are. */
244
265
  declare const SEARCH_GOOGLE_NOTE: string;
245
266
  /** One HTTP call to a search API. The key, if any, is in `headers` only - never in the URL. */
@@ -275,6 +296,8 @@ interface ISearchAnswer {
275
296
  summary?: unknown;
276
297
  /** Absent when the API reported none. */
277
298
  usage?: ISearchUsage;
299
+ /** What the results are (the google provider's `SEARCH_GOOGLE_NOTE`, an engine's own line). */
300
+ note?: string;
278
301
  }
279
302
  /**
280
303
  * The request for one query, per the Gemini API's public documentation:
@@ -292,6 +315,18 @@ declare const buildSearchRequest: (input: ISearchRequestInput) => ISearchRequest
292
315
  * what makes them safe to show.
293
316
  */
294
317
  declare const parseSearchResponse: (provider: SearchProvider, json: unknown) => ISearchAnswer;
318
+ /**
319
+ * What a search spent, as an engine reported it: whole non-negative token counts (anything else
320
+ * is 0), the total their sum, reasoning never more than the output. Undefined when it spent none.
321
+ */
322
+ declare const searchUsageOf: (raw: unknown) => ISearchUsage | undefined;
323
+ /**
324
+ * An engine's answer as the tool reads it. A bare list is the results and nothing else (no usage,
325
+ * no summary, no note); an `ISearchEngineAnswer` gives its `results` and - checked - its usage
326
+ * (`searchUsageOf`), its summary (a string; cleaned and cut when it is shown) and its note (cleaned
327
+ * and cut here). Anything else is no results. Still raw until `sanitizeSearchResults`.
328
+ */
329
+ declare const searchEngineAnswer: (raw: unknown) => ISearchAnswer;
295
330
  /**
296
331
  * What a failed call says to the model: the provider, the model, the status, the API's own error
297
332
  * code word and what it usually means. Never the error's text: that is third-party text, and may
@@ -319,18 +354,19 @@ declare const sanitizeSearchResults: (raw: unknown, options?: {
319
354
  interface ISearchToolResult {
320
355
  query: string;
321
356
  results: ISearchResult[];
322
- /** The google provider, when no source came with a snippet: the grounding model's answer, cut. */
357
+ /** When no source came with a snippet: the grounding (or engine's) model's answer, cut. */
323
358
  summary?: string;
324
- /** The google provider: what its URLs and its text are. */
359
+ /** What the URLs and the text are: the google provider's note, or an engine's own line. */
325
360
  note?: string;
326
361
  filtered?: number;
327
362
  truncated?: true;
328
363
  untrusted: true;
329
364
  }
330
365
  /**
331
- * The tool's result, from the cleaned list and - for the google provider - the parsed answer.
332
- * The model's `summary` is attached only when there are sources, none of them carries a snippet
333
- * and none was filtered out: a summary cannot be cut to the sources that remain.
366
+ * The tool's result, from the cleaned list and the parsed answer (the google provider's, or an
367
+ * engine's `searchEngineAnswer`). The model's `summary` is attached only when there are sources,
368
+ * none of them carries a snippet and none was filtered out: a summary cannot be cut to the sources
369
+ * that remain. The answer's `note` goes with every result list, cleaned and cut.
334
370
  */
335
371
  declare const searchToolResult: (query: string, clean: ISanitizedSearch, answer?: ISearchAnswer) => ISearchToolResult;
336
372
 
@@ -1010,6 +1046,141 @@ declare const adoptSubagentEvent: <E extends {
1010
1046
  type: string;
1011
1047
  }>(event: E, parentId: string) => E;
1012
1048
 
1049
+ declare const ASK_USER_TOOL = "ask_user";
1050
+ /** How long one question waits for the person, by default: a human is reading it. */
1051
+ declare const ASK_USER_TIMEOUT_MS = 300000;
1052
+ /**
1053
+ * The longest wait a timer holds (2^31 - 1 ms, about 24.8 days). `setTimeout` fires a longer one -
1054
+ * Infinity included - after about 1 ms, so a `timeoutMs` past it is taken as no limit at all.
1055
+ */
1056
+ declare const ASK_USER_TIMEOUT_MAX_MS = 2147483647;
1057
+ /** The most questions one run may ask, by default (its helpers' and subagents' included). */
1058
+ declare const ASK_USER_MAX_PER_RUN = 3;
1059
+ /** A question offers at least this many options... */
1060
+ declare const ASK_USER_MIN_OPTIONS = 2;
1061
+ /** ...and at most this many. */
1062
+ declare const ASK_USER_MAX_OPTIONS = 6;
1063
+ /** The longest question, in characters (after cleaning). */
1064
+ declare const ASK_USER_QUESTION_MAX_CHARS = 500;
1065
+ /** The longest option label. */
1066
+ declare const ASK_USER_LABEL_MAX_CHARS = 80;
1067
+ /** The longest option description. */
1068
+ declare const ASK_USER_DESCRIPTION_MAX_CHARS = 200;
1069
+ /** The most of a person's own words (`{ other }`) the model is given; the rest is cut. */
1070
+ declare const ASK_USER_OTHER_MAX_CHARS = 2000;
1071
+ /** One option of a question, as the person is shown it. Both strings are the MODEL's, cleaned. */
1072
+ interface AskUserOption {
1073
+ label: string;
1074
+ description?: string;
1075
+ }
1076
+ /** A question as checked and cleaned: what a host shows and an event carries. */
1077
+ interface AskUserQuestion {
1078
+ question: string;
1079
+ options: AskUserOption[];
1080
+ /** The person may pick several options. */
1081
+ multiple: boolean;
1082
+ /** The person may answer in their own words instead of picking. */
1083
+ allowOther: boolean;
1084
+ }
1085
+ /** What the host's `onQuestion` is given. Every string in it is the model's text, cleaned. */
1086
+ interface AskUserRequest<TStep = unknown> extends AskUserQuestion {
1087
+ /** Unique per question; the same id is in the two events. */
1088
+ id: string;
1089
+ /** The plan step whose tool call asks. */
1090
+ step?: TStep;
1091
+ runId?: string;
1092
+ /** Set when a helper or a subagent of the run asks, not the run itself: its id and depth. */
1093
+ subagent?: {
1094
+ id: string;
1095
+ depth: number;
1096
+ };
1097
+ }
1098
+ /**
1099
+ * The person's answer: the labels they picked (exactly as offered; one unless `multiple`), their
1100
+ * own words (only when `allowOther`), or that they would rather not answer.
1101
+ */
1102
+ type AskUserAnswer = {
1103
+ choice: string[];
1104
+ } | {
1105
+ other: string;
1106
+ } | {
1107
+ declined: true;
1108
+ };
1109
+ interface AskUserContext {
1110
+ /**
1111
+ * Aborted when the question ends WITHOUT the host's answer: no answer within `timeoutMs`
1112
+ * (`signal.reason` is an Error named 'TimeoutError'), the run was stopped, or the handler
1113
+ * failed. Take the prompt down then: an answer given later is ignored. Never aborted once the
1114
+ * host has answered.
1115
+ */
1116
+ signal: AbortSignal;
1117
+ }
1118
+ /** How a question ended. `automatic`: nobody decided (a time limit, a stop, a failed handler). */
1119
+ type AskUserAction = 'choice' | 'other' | 'declined' | 'timeout' | 'stopped';
1120
+ /** Why a question was closed as `declined` without the person deciding. */
1121
+ type AskUserReason = 'handler-error' | 'invalid-answer' | 'cannot-park';
1122
+ /** The two events of a question. Neither ever carries the person's own words. */
1123
+ type AskUserEvent<TStep = unknown> = {
1124
+ type: 'user.question-asked';
1125
+ id: string;
1126
+ question: string;
1127
+ options: AskUserOption[];
1128
+ multiple: boolean;
1129
+ allowOther: boolean;
1130
+ step?: TStep;
1131
+ subagent?: {
1132
+ id: string;
1133
+ depth: number;
1134
+ };
1135
+ } | {
1136
+ type: 'user.question-answered';
1137
+ id: string;
1138
+ action: AskUserAction;
1139
+ /** true when nobody decided: a time limit, a stop, a failed handler, an unusable answer. */
1140
+ automatic: boolean;
1141
+ /** Action 'choice': the labels picked. Never the text of an `other` answer. */
1142
+ choice?: string[];
1143
+ /** Action 'declined' with `automatic`: why. */
1144
+ reason?: AskUserReason;
1145
+ };
1146
+ /** A bad `ask_user` input: the tool call fails with this message, which says what to fix. */
1147
+ declare class AskUserInputError extends Error {
1148
+ constructor(message: string);
1149
+ toJSON(): string;
1150
+ }
1151
+ /** The model's text as a person may be shown it: a string, invisible characters removed, trimmed. */
1152
+ declare const cleanAskUserText: (raw: unknown, oneLine?: boolean) => string;
1153
+ /**
1154
+ * Check and clean the model's `ask_user` arguments: 2-6 options, no two labels alike (letter case
1155
+ * and spaces aside), each label 1-80 characters, a description at most 200, a question of 1-500 -
1156
+ * all measured after cleaning. An option may be given as a bare string (its label). Throws
1157
+ * {@link AskUserInputError} with what to fix.
1158
+ */
1159
+ declare const checkAskUserInput: (raw: unknown) => AskUserQuestion;
1160
+ /** An answer as checked: what the model is told. */
1161
+ type AskUserCheckedAnswer = {
1162
+ kind: 'choice';
1163
+ choice: string[];
1164
+ } | {
1165
+ kind: 'other';
1166
+ text: string;
1167
+ } | {
1168
+ kind: 'declined';
1169
+ };
1170
+ /**
1171
+ * Check the host's answer against the question: exactly one of `choice` (labels that were
1172
+ * offered, no repeats, one unless `multiple`), `other` (a non-empty text, only when `allowOther`;
1173
+ * cleaned and cut at {@link ASK_USER_OTHER_MAX_CHARS}) or `declined: true`. Anything else is not
1174
+ * an answer.
1175
+ */
1176
+ declare const checkAskUserAnswer: (q: AskUserQuestion, raw: unknown) => {
1177
+ ok: true;
1178
+ value: AskUserCheckedAnswer;
1179
+ } | {
1180
+ ok: false;
1181
+ reason: string;
1182
+ };
1183
+
1013
1184
  type ProviderType = 'openai' | 'anthropic' | 'openai-compatible' | 'google' | 'xai' | 'azure' | 'amazon-bedrock' | 'google-vertex' | 'deepseek' | 'gateway' | 'cloudflare';
1014
1185
  type AgentModel = Exclude<LanguageModel, string>;
1015
1186
  type LogLevel = 'none' | 'error' | 'warn' | 'info' | 'debug';
@@ -1128,6 +1299,16 @@ type ToolApprovalAnswer = boolean | {
1128
1299
  type ToolApprovalDecision = ToolApprovalAnswer | {
1129
1300
  park: true;
1130
1301
  };
1302
+ type IAskUserRequest = AskUserRequest<IPlanStep>;
1303
+ type AskUserDecision = AskUserAnswer | {
1304
+ park: true;
1305
+ };
1306
+ type AskUserHandler = (request: IAskUserRequest, ctx: AskUserContext) => AskUserDecision | Promise<AskUserDecision>;
1307
+ interface IAskUserConfig {
1308
+ onQuestion?: AskUserHandler;
1309
+ timeoutMs?: number;
1310
+ maxPerRun?: number;
1311
+ }
1131
1312
  interface IToolApprovalConfig {
1132
1313
  mode?: ToolApprovalMode;
1133
1314
  rules?: Record<string, ToolPermission>;
@@ -1211,6 +1392,7 @@ interface IAgentConfig {
1211
1392
  compaction?: ICompactionConfig;
1212
1393
  skills?: ISkill[];
1213
1394
  toolApproval?: IToolApprovalConfig;
1395
+ askUser?: boolean | IAskUserConfig;
1214
1396
  toolSearchThreshold?: number;
1215
1397
  mcpConnectTimeoutMs?: number;
1216
1398
  onElicitation?: McpElicitationHandler;
@@ -1404,7 +1586,7 @@ type AgentEventBody = {
1404
1586
  reason?: string;
1405
1587
  automatic: boolean;
1406
1588
  parked?: true;
1407
- } | {
1589
+ } | AskUserEvent<IPlanStep> | {
1408
1590
  type: 'mcp.elicitation-requested';
1409
1591
  id: string;
1410
1592
  server: string;
@@ -1607,6 +1789,7 @@ interface IRunSnapshot {
1607
1789
  }[];
1608
1790
  escalations?: number;
1609
1791
  subagentsSpawned?: number;
1792
+ questionsAsked?: number;
1610
1793
  attempt?: number;
1611
1794
  leaseOwner?: string;
1612
1795
  parked?: IParkedRun;
@@ -2705,5 +2888,5 @@ declare const REMOTE_SUBAGENT_LIMITS: {
2705
2888
  */
2706
2889
  declare const createSubagentTool: (opts: ISubagentToolOptions) => Tool;
2707
2890
 
2708
- export { DEFAULT_COMPACTION_THRESHOLD_RATIO, DEFAULT_DECISION_CONFIDENCE_THRESHOLD, DEFAULT_DECISION_TIMEOUT_MS, DirSkillStore, ENTERPRISE_MANAGED_AUTHORIZATION_EXTENSION, EgressError, EnterpriseOAuthError, FORGET_SKILL_TOOL, FileOAuthStore, GENERATE_IMAGE_TOOL, GENERATE_SPEECH_TOOL, JOURNAL_LIMITS, JournalError, MCP_ELICITATION_MAX_PER_RUN, MCP_ELICITATION_MAX_PER_TOOL_CALL, MCP_ELICITATION_TIMEOUT_MS, MCP_INSTRUCTIONS_MAX_CHARS_PER_SERVER, MCP_INSTRUCTIONS_MAX_CHARS_TOTAL, MCP_MODERN_PROTOCOL_VERSION, MCP_SKILLS_EXTENSION, MCP_SKILLS_MAX_PER_SERVER, MCP_SKILLS_MAX_TOTAL, MCP_SKILL_BODY_MAX_CHARS, MCP_SKILL_CONSENTS, MCP_SKILL_CONSENT_DEFAULT, MCP_SKILL_DESCRIPTION_MAX_CHARS, MCP_SKILL_DIRECTORY_ENTRIES_MAX, MCP_SKILL_FILE_MAX_CHARS, MCP_SKILL_MAX_RESOURCES, MCP_SKILL_MAX_TOTAL_BYTES, MCP_SKILL_SNAPSHOTS_MAX_BYTES, MCP_SKILL_SNAPSHOT_MAX_DEPTH, MCP_SKILL_SNAPSHOT_MAX_DIRECTORIES, MCP_SKILL_URI_MAX_CHARS, MEDIA_AUDIO_TYPES, MEDIA_DEFAULT_MAX_CALLS, MEDIA_FOLDER, MEDIA_IMAGE_TYPES, MEDIA_MAX_ATTACHED_AUDIO, MEDIA_MAX_AUDIO_INPUT_BYTES, MEDIA_MAX_IMAGE_BYTES, MEDIA_MAX_PROMPT_CHARS, MEDIA_MAX_SPEECH_BYTES, MEDIA_MAX_SPEECH_CHARS, MEDIA_MAX_TRANSCRIPT_CHARS, MEDIA_TIMEOUT_MS, MediaBudgetError, MediaError, MemoryOAuthStore, MemorySkillStore, ModelCallRefusedError, NodeEnterpriseOAuthProvider, NodeOAuthProvider, PipelineDefinition, PipelineEvent, PipelineNode, PipelineNodeRunner, PipelineResult, REMOTE_SUBAGENT_LIMITS, REPLAY_NOTE, RUN_JS_TOOL, RUN_LEASE_DEFAULT_TTL_MS, RunLeaseError, SAVE_SKILL_TOOL, SEARCH_API_BASE_URL, SEARCH_DEFAULT_MAX_RESULTS, SEARCH_GOOGLE_DEFAULT_MODEL, SEARCH_GOOGLE_NOTE, SEARCH_MAX_QUERY_CHARS, SEARCH_MAX_RESULTS, SEARCH_MAX_SNIPPET_CHARS, SEARCH_MAX_SUMMARY_CHARS, SEARCH_MAX_TITLE_CHARS, SEARCH_MAX_TOTAL_CHARS, SEARCH_MAX_URL_CHARS, SEARCH_PROVIDERS, SPAWN_INPUT_SCHEMA, SPAWN_SUBAGENT_TOOL, SUBAGENT_DEFAULTS, SUBAGENT_MAX_DEPTH_LIMIT, SUMMARY_PREFIX, SandboxUnavailableError, SubagentSpawnError, TOOL_APPROVAL_TIMEOUT_MS, TRANSCRIBE_AUDIO_TOOL, ToolBudgetError, ToolDeniedError, WEB_FETCH_TOOL, WEB_SEARCH_TOOL, acceptMedia, addUsage, adoptSubagentEvent, askDecisionModel, beginMcpOAuth, buildInstructions, buildMediaModelFromStage, buildSearchRequest, checkAuthorizationResponseIssuer, checkEgressUrl, checkLimits, checkRedirect, classifyAddress, compactHistory, createAgent, createEgressTools, createEnterpriseOAuthProvider, createLearning, createMedia, createNodeOAuthProvider, createPipeline, createRunControl, createSafeFetch, createSandboxTool, createSandboxTools, createSearchTools, createSubagentTool, createToolResultClearer, createWebFetchTool, createWebSearchTool, decideToolPermission, decisionModelFromAiSdk, deferResult, defineSkill, estimateTokens, findSecret, finishMcpOAuth, getCurrentRunId, getCurrentRunSandbox, hostMatches, htmlToText, isAuthError, isCodeExecutionTool, isDeferredResult, isModelCallRefused, isReadOnlyTool, isReplayedToolOutput, loadSkillsFromDir, markCodeExecution, markReadOnly, matchToolRule, mcpSkillEntryRefusal, mcpSkillPreamble, mcpSkillUriRefusal, mediaUsageOf, mergeProviderOptions, nodeResolver, normalizeMcpElicitationSchema, normalizeSkillName, normalizeUsage, parseSearchResponse, parseSkillMarkdown, pickPipelineRoute, redactHeaders, renderMcpInstructions, resolveCompaction, resolveDynamicSubagents, resolveEgressPolicy, resolveLimits, resolvePromptCaching, resolveSandboxLimits, resolveThinking, sanitizeSearchResults, searchEgressPolicy, searchStatusMessage, searchToolResult, searchTools, sniffMediaType, truncateToolModelOutput, validateMcpElicitationContent, withRollingBreakpoint, withToolOutputLimit, wrapTranscript };
2709
- export type { AgentEvent, AgentModel, AgentStage, BudgetKind, DecisionFallbackReason, DecisionPoint, EgressErrorCode, EnterpriseAssertionAlgorithm, EnterpriseAssertionAudience, EnterpriseAssertionType, EnterpriseOAuthHop, EnterpriseOAuthLog, EnterprisePrivateKey, EscalationReason, EventHandler, IAgent, IAgentConfig, IAgentRunOptions, IAgentRunResult, IAgentStageOverride, IAiSdkDecisionOptions, IClearedInfo, ICloseOptions, ICompactHistoryOptions, ICompactHistoryResult, ICompactOptions, ICompactResult, ICompactionConfig, IConversationTurn, IDecisionAnswer, IDecisionCallOptions, IDecisionConfig, IDecisionEvent, IDecisionModel, IDecisionOption, IDecisionOutcome, IDecisionQuestion, IDeferredResult, IDynamicSubagentsConfig, IEgressPolicy, IEnterpriseIdpOptions, IEnterpriseOAuthProviderOptions, IEscalationConfig, IJournalAnswerEntry, IJournalEntry, IJournalModelEntry, IJournalPendingEntry, IJournalToolEntry, ILearning, ILearningConfig, ILimitBreach, ILocalSubagentToolOptions, IMcpHttpServerConfig, IMcpServerConfig, IMcpSkillOrigin, IMcpStdioServerConfig, IMedia, IMediaConfig, IMediaFile, IMediaModelSpec, IMediaUsage, IModelCall, INodeOAuthProviderOptions, IOAuthRequestOptions, IOAuthStore, IParkedRun, IPersistence, IPlan, IPlanStep, IRemoteSubagentContext, IRemoteSubagentResult, IRemoteSubagentTask, IRemoteSubagentToolOptions, IResolvedAddress, IResolvedDynamicSubagents, IResolvedThinking, IRunFile, IRunJournal, IRunLease, IRunLeaseOptions, IRunSnapshot, ISandboxConfig, ISandboxError, ISandboxLimits, ISandboxResult, ISanitizedSearch, ISaveSkillInput, ISearchAnswer, ISearchConfig, ISearchOptions, ISearchRequest, ISearchResult, ISearchToolResult, ISearchToolsOptions, ISearchUsage, ISharedLimits, ISkill, ISkillOrigin, ISkillStore, IStepEscalation, IStepResult, IStepStartInfo, ISubagentProfile, ISubagentToolOptions, ISubagentsConfig, IThinkingConfig, ITokenLimits, IToolApprovalConfig, IToolApprovalContext, IToolApprovalRequest, IToolCatalogEntry, IToolDecision, IToolDecisionInput, IToolResultClearing, ITranscription, IUsage, IWebSearchOptions, LogLevel, McpElicitationContent, McpElicitationContext, McpElicitationFieldSchema, McpElicitationHandler, McpElicitationOptions, McpElicitationReason, McpElicitationRequest, McpElicitationResult, McpElicitationSchema, McpOAuthRegistration, McpOAuthRegistrationKind, McpProtocolMode, McpServerInstructions, McpServerProtocol, McpSkillConsent, McpSkillConsentView, McpSkillsOptions, McpSkillsSetting, MediaImageModel, MediaKind, MediaModelKind, MediaSpeechModel, MediaTranscriptionModel, ModelCallStage, ModelTier, NodeResolverOptions, ParkAnswer, ParkedItem, Pipeline, PipelineModelConfig, PipelineOptions, PipelineRouteOptions, PipelineRouteResult, PipelineRunOptions, PromptCachingSetting, ProviderType, RemoteSubagentDispatch, ReplanCause, ReplanTrigger, RunControl, RunLeaseLostReason, SafeFetch, SearchEngine, SearchFreshness, SearchProvider, SkillDirectoryListing, StepComplexity, SubagentDefaultTools, SubagentInfo, SubagentIsolation, ThinkingLevel, ThinkingSetting, TierReason, TokenLimitKind, ToolApprovalAnswer, ToolApprovalDecision, ToolApprovalMode, ToolPermission, ToolResultAnswer, ToolSelectionStrategy, UsagePhase };
2891
+ export { ASK_USER_DESCRIPTION_MAX_CHARS, ASK_USER_LABEL_MAX_CHARS, ASK_USER_MAX_OPTIONS, ASK_USER_MAX_PER_RUN, ASK_USER_MIN_OPTIONS, ASK_USER_OTHER_MAX_CHARS, ASK_USER_QUESTION_MAX_CHARS, ASK_USER_TIMEOUT_MAX_MS, ASK_USER_TIMEOUT_MS, ASK_USER_TOOL, AskUserInputError, DEFAULT_COMPACTION_THRESHOLD_RATIO, DEFAULT_DECISION_CONFIDENCE_THRESHOLD, DEFAULT_DECISION_TIMEOUT_MS, DirSkillStore, ENTERPRISE_MANAGED_AUTHORIZATION_EXTENSION, EgressError, EnterpriseOAuthError, FORGET_SKILL_TOOL, FileOAuthStore, GENERATE_IMAGE_TOOL, GENERATE_SPEECH_TOOL, JOURNAL_LIMITS, JournalError, MCP_ELICITATION_MAX_PER_RUN, MCP_ELICITATION_MAX_PER_TOOL_CALL, MCP_ELICITATION_TIMEOUT_MS, MCP_INSTRUCTIONS_MAX_CHARS_PER_SERVER, MCP_INSTRUCTIONS_MAX_CHARS_TOTAL, MCP_MODERN_PROTOCOL_VERSION, MCP_SKILLS_EXTENSION, MCP_SKILLS_MAX_PER_SERVER, MCP_SKILLS_MAX_TOTAL, MCP_SKILL_BODY_MAX_CHARS, MCP_SKILL_CONSENTS, MCP_SKILL_CONSENT_DEFAULT, MCP_SKILL_DESCRIPTION_MAX_CHARS, MCP_SKILL_DIRECTORY_ENTRIES_MAX, MCP_SKILL_FILE_MAX_CHARS, MCP_SKILL_MAX_RESOURCES, MCP_SKILL_MAX_TOTAL_BYTES, MCP_SKILL_SNAPSHOTS_MAX_BYTES, MCP_SKILL_SNAPSHOT_MAX_DEPTH, MCP_SKILL_SNAPSHOT_MAX_DIRECTORIES, MCP_SKILL_URI_MAX_CHARS, MEDIA_AUDIO_TYPES, MEDIA_DEFAULT_MAX_CALLS, MEDIA_FOLDER, MEDIA_IMAGE_TYPES, MEDIA_MAX_ATTACHED_AUDIO, MEDIA_MAX_AUDIO_INPUT_BYTES, MEDIA_MAX_IMAGE_BYTES, MEDIA_MAX_PROMPT_CHARS, MEDIA_MAX_SPEECH_BYTES, MEDIA_MAX_SPEECH_CHARS, MEDIA_MAX_TRANSCRIPT_CHARS, MEDIA_TIMEOUT_MS, MediaBudgetError, MediaError, MemoryOAuthStore, MemorySkillStore, ModelCallRefusedError, NodeEnterpriseOAuthProvider, NodeOAuthProvider, PipelineDefinition, PipelineEvent, PipelineNode, PipelineNodeRunner, PipelineResult, REMOTE_SUBAGENT_LIMITS, REPLAY_NOTE, RUN_JS_TOOL, RUN_LEASE_DEFAULT_TTL_MS, RunLeaseError, SAVE_SKILL_TOOL, SEARCH_API_BASE_URL, SEARCH_DEFAULT_MAX_RESULTS, SEARCH_GOOGLE_DEFAULT_MODEL, SEARCH_GOOGLE_NOTE, SEARCH_MAX_NOTE_CHARS, SEARCH_MAX_QUERY_CHARS, SEARCH_MAX_RESULTS, SEARCH_MAX_SNIPPET_CHARS, SEARCH_MAX_SUMMARY_CHARS, SEARCH_MAX_TITLE_CHARS, SEARCH_MAX_TOTAL_CHARS, SEARCH_MAX_URL_CHARS, SEARCH_PROVIDERS, SPAWN_INPUT_SCHEMA, SPAWN_SUBAGENT_TOOL, SUBAGENT_DEFAULTS, SUBAGENT_MAX_DEPTH_LIMIT, SUMMARY_PREFIX, SandboxUnavailableError, SubagentSpawnError, TOOL_APPROVAL_TIMEOUT_MS, TRANSCRIBE_AUDIO_TOOL, ToolBudgetError, ToolDeniedError, WEB_FETCH_TOOL, WEB_SEARCH_TOOL, acceptMedia, addUsage, adoptSubagentEvent, askDecisionModel, beginMcpOAuth, buildInstructions, buildMediaModelFromStage, buildSearchRequest, checkAskUserAnswer, checkAskUserInput, checkAuthorizationResponseIssuer, checkEgressUrl, checkLimits, checkRedirect, classifyAddress, cleanAskUserText, compactHistory, createAgent, createEgressTools, createEnterpriseOAuthProvider, createLearning, createMedia, createNodeOAuthProvider, createPipeline, createRunControl, createSafeFetch, createSandboxTool, createSandboxTools, createSearchTools, createSubagentTool, createToolResultClearer, createWebFetchTool, createWebSearchTool, decideToolPermission, decisionModelFromAiSdk, deferResult, defineSkill, estimateTokens, findSecret, finishMcpOAuth, getCurrentRunId, getCurrentRunSandbox, hostMatches, htmlToText, isAuthError, isCodeExecutionTool, isDeferredResult, isModelCallRefused, isReadOnlyTool, isReplayedToolOutput, loadSkillsFromDir, markCodeExecution, markReadOnly, matchToolRule, mcpSkillEntryRefusal, mcpSkillPreamble, mcpSkillUriRefusal, mediaUsageOf, mergeProviderOptions, nodeResolver, normalizeMcpElicitationSchema, normalizeSkillName, normalizeUsage, parseSearchResponse, parseSkillMarkdown, pickPipelineRoute, redactHeaders, renderMcpInstructions, resolveCompaction, resolveDynamicSubagents, resolveEgressPolicy, resolveLimits, resolvePromptCaching, resolveSandboxLimits, resolveThinking, sanitizeSearchResults, searchEgressPolicy, searchEngineAnswer, searchStatusMessage, searchToolResult, searchTools, searchUsageOf, sniffMediaType, truncateToolModelOutput, validateMcpElicitationContent, withRollingBreakpoint, withToolOutputLimit, wrapTranscript };
2892
+ export type { AgentEvent, AgentModel, AgentStage, AskUserAction, AskUserAnswer, AskUserCheckedAnswer, AskUserContext, AskUserDecision, AskUserHandler, AskUserOption, AskUserQuestion, AskUserReason, BudgetKind, DecisionFallbackReason, DecisionPoint, EgressErrorCode, EnterpriseAssertionAlgorithm, EnterpriseAssertionAudience, EnterpriseAssertionType, EnterpriseOAuthHop, EnterpriseOAuthLog, EnterprisePrivateKey, EscalationReason, EventHandler, IAgent, IAgentConfig, IAgentRunOptions, IAgentRunResult, IAgentStageOverride, IAiSdkDecisionOptions, IAskUserConfig, IAskUserRequest, IClearedInfo, ICloseOptions, ICompactHistoryOptions, ICompactHistoryResult, ICompactOptions, ICompactResult, ICompactionConfig, IConversationTurn, IDecisionAnswer, IDecisionCallOptions, IDecisionConfig, IDecisionEvent, IDecisionModel, IDecisionOption, IDecisionOutcome, IDecisionQuestion, IDeferredResult, IDynamicSubagentsConfig, IEgressPolicy, IEnterpriseIdpOptions, IEnterpriseOAuthProviderOptions, IEscalationConfig, IJournalAnswerEntry, IJournalEntry, IJournalModelEntry, IJournalPendingEntry, IJournalToolEntry, ILearning, ILearningConfig, ILimitBreach, ILocalSubagentToolOptions, IMcpHttpServerConfig, IMcpServerConfig, IMcpSkillOrigin, IMcpStdioServerConfig, IMedia, IMediaConfig, IMediaFile, IMediaModelSpec, IMediaUsage, IModelCall, INodeOAuthProviderOptions, IOAuthRequestOptions, IOAuthStore, IParkedRun, IPersistence, IPlan, IPlanStep, IRemoteSubagentContext, IRemoteSubagentResult, IRemoteSubagentTask, IRemoteSubagentToolOptions, IResolvedAddress, IResolvedDynamicSubagents, IResolvedThinking, IRunFile, IRunJournal, IRunLease, IRunLeaseOptions, IRunSnapshot, ISandboxConfig, ISandboxError, ISandboxLimits, ISandboxResult, ISanitizedSearch, ISaveSkillInput, ISearchAnswer, ISearchConfig, ISearchEngineAnswer, ISearchOptions, ISearchRequest, ISearchResult, ISearchToolResult, ISearchToolsOptions, ISearchUsage, ISharedLimits, ISkill, ISkillOrigin, ISkillStore, IStepEscalation, IStepResult, IStepStartInfo, ISubagentProfile, ISubagentToolOptions, ISubagentsConfig, IThinkingConfig, ITokenLimits, IToolApprovalConfig, IToolApprovalContext, IToolApprovalRequest, IToolCatalogEntry, IToolDecision, IToolDecisionInput, IToolResultClearing, ITranscription, IUsage, IWebSearchOptions, LogLevel, McpElicitationContent, McpElicitationContext, McpElicitationFieldSchema, McpElicitationHandler, McpElicitationOptions, McpElicitationReason, McpElicitationRequest, McpElicitationResult, McpElicitationSchema, McpOAuthRegistration, McpOAuthRegistrationKind, McpProtocolMode, McpServerInstructions, McpServerProtocol, McpSkillConsent, McpSkillConsentView, McpSkillsOptions, McpSkillsSetting, MediaImageModel, MediaKind, MediaModelKind, MediaSpeechModel, MediaTranscriptionModel, ModelCallStage, ModelTier, NodeResolverOptions, ParkAnswer, ParkedItem, Pipeline, PipelineModelConfig, PipelineOptions, PipelineRouteOptions, PipelineRouteResult, PipelineRunOptions, PromptCachingSetting, ProviderType, RemoteSubagentDispatch, ReplanCause, ReplanTrigger, RunControl, RunLeaseLostReason, SafeFetch, SearchEngine, SearchFreshness, SearchProvider, SkillDirectoryListing, StepComplexity, SubagentDefaultTools, SubagentInfo, SubagentIsolation, ThinkingLevel, ThinkingSetting, TierReason, TokenLimitKind, ToolApprovalAnswer, ToolApprovalDecision, ToolApprovalMode, ToolPermission, ToolResultAnswer, ToolSelectionStrategy, UsagePhase };