@promptbook/wizard 0.112.0-47 → 0.112.0-48

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 (43) hide show
  1. package/esm/index.es.js +331 -76
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/src/avatars/AvatarOrImage.d.ts +5 -1
  4. package/esm/src/avatars/avatarInteractionUtils.d.ts +81 -0
  5. package/esm/src/avatars/avatarInteractionUtils.test.d.ts +1 -0
  6. package/esm/src/avatars/avatarPointerTracking.d.ts +17 -0
  7. package/esm/src/avatars/avatarRenderingUtils.d.ts +3 -2
  8. package/esm/src/avatars/avatarRenderingUtils.test.d.ts +1 -0
  9. package/esm/src/avatars/index.d.ts +1 -1
  10. package/esm/src/avatars/types/AvatarVisualDefinition.d.ts +35 -0
  11. package/esm/src/avatars/visuals/octopusAvatarVisualShared.d.ts +34 -0
  12. package/esm/src/avatars/visuals/octopusAvatarVisualShared.test.d.ts +1 -0
  13. package/esm/src/book-components/Chat/Chat/TeamToolCallModalContent.test.d.ts +2 -0
  14. package/esm/src/commitments/USE/USE.d.ts +1 -0
  15. package/esm/src/commitments/USE/aggregateUseCommitmentSystemMessages.d.ts +1 -1
  16. package/esm/src/commitments/USE_DEEPSEARCH/USE_DEEPSEARCH.d.ts +47 -0
  17. package/esm/src/commitments/USE_DEEPSEARCH/USE_DEEPSEARCH.test.d.ts +1 -0
  18. package/esm/src/commitments/_common/createSerpSearchToolFunction.d.ts +12 -0
  19. package/esm/src/commitments/index.d.ts +2 -1
  20. package/esm/src/llm-providers/openai/OpenAiAgentKitExecutionTools.test.d.ts +1 -0
  21. package/esm/src/version.d.ts +1 -1
  22. package/package.json +2 -2
  23. package/umd/index.umd.js +330 -75
  24. package/umd/index.umd.js.map +1 -1
  25. package/umd/src/avatars/AvatarOrImage.d.ts +5 -1
  26. package/umd/src/avatars/avatarInteractionUtils.d.ts +81 -0
  27. package/umd/src/avatars/avatarInteractionUtils.test.d.ts +1 -0
  28. package/umd/src/avatars/avatarPointerTracking.d.ts +17 -0
  29. package/umd/src/avatars/avatarRenderingUtils.d.ts +3 -2
  30. package/umd/src/avatars/avatarRenderingUtils.test.d.ts +1 -0
  31. package/umd/src/avatars/index.d.ts +1 -1
  32. package/umd/src/avatars/types/AvatarVisualDefinition.d.ts +35 -0
  33. package/umd/src/avatars/visuals/octopusAvatarVisualShared.d.ts +34 -0
  34. package/umd/src/avatars/visuals/octopusAvatarVisualShared.test.d.ts +1 -0
  35. package/umd/src/book-components/Chat/Chat/TeamToolCallModalContent.test.d.ts +2 -0
  36. package/umd/src/commitments/USE/USE.d.ts +1 -0
  37. package/umd/src/commitments/USE/aggregateUseCommitmentSystemMessages.d.ts +1 -1
  38. package/umd/src/commitments/USE_DEEPSEARCH/USE_DEEPSEARCH.d.ts +47 -0
  39. package/umd/src/commitments/USE_DEEPSEARCH/USE_DEEPSEARCH.test.d.ts +1 -0
  40. package/umd/src/commitments/_common/createSerpSearchToolFunction.d.ts +12 -0
  41. package/umd/src/commitments/index.d.ts +2 -1
  42. package/umd/src/llm-providers/openai/OpenAiAgentKitExecutionTools.test.d.ts +1 -0
  43. package/umd/src/version.d.ts +1 -1
package/esm/index.es.js CHANGED
@@ -21,7 +21,7 @@ import { Subject, BehaviorSubject } from 'rxjs';
21
21
  import moment from 'moment';
22
22
  import { lookup, extension } from 'mime-types';
23
23
  import { parse, unparse } from 'papaparse';
24
- import { Agent as Agent$1, setDefaultOpenAIClient, setDefaultOpenAIKey, fileSearchTool, tool, run } from '@openai/agents';
24
+ import { Agent as Agent$1, setDefaultOpenAIClient, setDefaultOpenAIKey, fileSearchTool, tool, run, webSearchTool } from '@openai/agents';
25
25
  import OpenAI from 'openai';
26
26
 
27
27
  // ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
@@ -38,7 +38,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
38
38
  * @generated
39
39
  * @see https://github.com/webgptorg/promptbook
40
40
  */
41
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-47';
41
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-48';
42
42
  /**
43
43
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
44
44
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -23825,6 +23825,7 @@ class TemplateCommitmentDefinition extends BaseCommitmentDefinition {
23825
23825
  * Supported USE types:
23826
23826
  * - USE BROWSER: Enables the agent to use a web browser tool
23827
23827
  * - USE SEARCH ENGINE (future): Enables search engine access
23828
+ * - USE DEEPSEARCH: Enables deeper research-oriented search access
23828
23829
  * - USE FILE SYSTEM (future): Enables file system operations
23829
23830
  * - USE MCP (future): Enables MCP server connections
23830
23831
  *
@@ -23847,7 +23848,7 @@ class UseCommitmentDefinition extends BaseCommitmentDefinition {
23847
23848
  * Short one-line description of USE commitments.
23848
23849
  */
23849
23850
  get description() {
23850
- return 'Enable the agent to use specific tools or capabilities (BROWSER, SEARCH ENGINE, etc.).';
23851
+ return 'Enable the agent to use specific tools or capabilities (BROWSER, SEARCH ENGINE, DEEPSEARCH, etc.).';
23851
23852
  }
23852
23853
  /**
23853
23854
  * Icon for this commitment.
@@ -23868,6 +23869,7 @@ class UseCommitmentDefinition extends BaseCommitmentDefinition {
23868
23869
 
23869
23870
  - **USE BROWSER** - Enables the agent to use a web browser tool to access and retrieve information from the internet
23870
23871
  - **USE SEARCH ENGINE** (future) - Enables search engine access
23872
+ - **USE DEEPSEARCH** - Enables deeper research-oriented search access
23871
23873
  - **USE FILE SYSTEM** (future) - Enables file system operations
23872
23874
  - **USE MCP** (future) - Enables MCP server connections
23873
23875
 
@@ -23922,7 +23924,7 @@ class UseCommitmentDefinition extends BaseCommitmentDefinition {
23922
23924
  * Checks if this is a known USE type
23923
23925
  */
23924
23926
  isKnownUseType(useType) {
23925
- const knownTypes = ['BROWSER', 'SEARCH ENGINE', 'FILE SYSTEM', 'MCP'];
23927
+ const knownTypes = ['BROWSER', 'SEARCH ENGINE', 'DEEPSEARCH', 'FILE SYSTEM', 'MCP'];
23926
23928
  return knownTypes.includes(useType.toUpperCase());
23927
23929
  }
23928
23930
  }
@@ -23935,6 +23937,7 @@ class UseCommitmentDefinition extends BaseCommitmentDefinition {
23935
23937
  */
23936
23938
  const AGGREGATED_USE_COMMITMENT_TYPES = [
23937
23939
  'USE BROWSER',
23940
+ 'USE DEEPSEARCH',
23938
23941
  'USE SEARCH ENGINE',
23939
23942
  'USE TIME',
23940
23943
  ];
@@ -24014,6 +24017,15 @@ function createAggregatedUseCommitmentSystemMessage(type, additionalInstructions
24014
24017
  - Do not tell the user you cannot search for information, YOU CAN.
24015
24018
  ${block(formatOptionalInstructionBlock('Search instructions', combinedAdditionalInstructions))}
24016
24019
  `);
24020
+ case 'USE DEEPSEARCH':
24021
+ return spaceTrim$1((block) => `
24022
+ Tool:
24023
+ - You have access to DeepSearch via the tool "deep_search".
24024
+ - Use it for broader research tasks that need multi-step investigation, comparison, or synthesis across multiple sources.
24025
+ - Prefer it over quick search when the user asks for a well-grounded brief, report, or deeper investigation.
24026
+ - Do not pretend you cannot research current information when this tool is available.
24027
+ ${block(formatOptionalInstructionBlock('DeepSearch instructions', combinedAdditionalInstructions))}
24028
+ `);
24017
24029
  }
24018
24030
  }
24019
24031
  /**
@@ -25563,6 +25575,207 @@ function addConfiguredCalendarIfMissing(configuredCalendars, calendarReference)
25563
25575
  }
25564
25576
  // Note: [💞] Ignore a discrepancy between file name and entity name
25565
25577
 
25578
+ /**
25579
+ * A search engine implementation that uses the SerpApi to fetch Google search results.
25580
+ *
25581
+ * @private <- TODO: !!!! Export via some package
25582
+ */
25583
+ class SerpSearchEngine {
25584
+ get title() {
25585
+ return 'SerpApi Search Engine';
25586
+ }
25587
+ get description() {
25588
+ return 'Search engine that uses SerpApi to fetch Google search results';
25589
+ }
25590
+ checkConfiguration() {
25591
+ if (!process.env.SERP_API_KEY) {
25592
+ throw new Error('SERP_API_KEY is not configured');
25593
+ }
25594
+ }
25595
+ async search(query, options = {}) {
25596
+ const apiKey = process.env.SERP_API_KEY;
25597
+ if (!apiKey) {
25598
+ throw new Error('SERP_API_KEY is not configured');
25599
+ }
25600
+ const url = new URL('https://serpapi.com/search');
25601
+ url.searchParams.set('api_key', apiKey);
25602
+ url.searchParams.set('engine', 'google');
25603
+ url.searchParams.set('q', query);
25604
+ for (const [key, value] of Object.entries(options)) {
25605
+ url.searchParams.set(key, String(value));
25606
+ }
25607
+ const response = await fetch(url.toString());
25608
+ if (!response.ok) {
25609
+ const body = await response.text();
25610
+ throw new Error(`SerpApi failed with status ${response.status}: ${response.statusText}\n${body}`);
25611
+ }
25612
+ const data = (await response.json());
25613
+ return (data.organic_results || []).map((item) => ({
25614
+ title: item.title,
25615
+ url: item.link,
25616
+ snippet: item.snippet || '',
25617
+ }));
25618
+ }
25619
+ }
25620
+
25621
+ /**
25622
+ * Creates one SERP-backed tool function used as a local fallback for search-like commitments.
25623
+ *
25624
+ * @param toolName - Technical tool name used for validation messages.
25625
+ * @param resultLabel - Human-readable label used in formatted results.
25626
+ * @returns Async tool function compatible with commitment tool registration.
25627
+ *
25628
+ * @private internal helper for search-like commitments
25629
+ */
25630
+ function createSerpSearchToolFunction(toolName, resultLabel) {
25631
+ return async (rawArgs) => {
25632
+ const { query, ...searchOptions } = rawArgs;
25633
+ if (typeof query !== 'string' || !query.trim()) {
25634
+ throw new Error(`${toolName} query is required`);
25635
+ }
25636
+ const searchEngine = new SerpSearchEngine();
25637
+ const results = await searchEngine.search(query, searchOptions);
25638
+ return spaceTrim$1((block) => `
25639
+ ${resultLabel} results for "${query}"${Object.keys(searchOptions).length === 0
25640
+ ? ''
25641
+ : ` with options ${JSON.stringify(searchOptions)}`}:
25642
+
25643
+ ${block(results
25644
+ .map((result) => spaceTrim$1(`
25645
+ - **${result.title}**
25646
+ ${result.url}
25647
+ ${result.snippet}
25648
+ `))
25649
+ .join('\n\n'))}
25650
+ `);
25651
+ };
25652
+ }
25653
+
25654
+ /**
25655
+ * USE DEEPSEARCH commitment definition
25656
+ *
25657
+ * The `USE DEEPSEARCH` commitment indicates that the agent should use a deeper research-oriented
25658
+ * search workflow instead of lightweight web search when it needs fresh information from the internet.
25659
+ *
25660
+ * The content following `USE DEEPSEARCH` is an arbitrary text that the agent should know
25661
+ * (e.g. search scope or research instructions).
25662
+ *
25663
+ * Example usage in agent source:
25664
+ *
25665
+ * ```book
25666
+ * USE DEEPSEARCH
25667
+ * USE DEEPSEARCH Compare official vendor documentation with independent benchmarks.
25668
+ * ```
25669
+ *
25670
+ * @private [🪔] Maybe export the commitments through some package
25671
+ */
25672
+ class UseDeepSearchCommitmentDefinition extends BaseCommitmentDefinition {
25673
+ constructor() {
25674
+ super('USE DEEPSEARCH');
25675
+ }
25676
+ get requiresContent() {
25677
+ return false;
25678
+ }
25679
+ /**
25680
+ * Short one-line description of USE DEEPSEARCH.
25681
+ */
25682
+ get description() {
25683
+ return 'Enable the agent to use DeepSearch for more thorough internet research.';
25684
+ }
25685
+ /**
25686
+ * Icon for this commitment.
25687
+ */
25688
+ get icon() {
25689
+ return '🔬';
25690
+ }
25691
+ /**
25692
+ * Markdown documentation for USE DEEPSEARCH commitment.
25693
+ */
25694
+ get documentation() {
25695
+ return spaceTrim$1(`
25696
+ # USE DEEPSEARCH
25697
+
25698
+ Enables the agent to use DeepSearch for broader, more thorough internet research than lightweight web search.
25699
+
25700
+ ## Key aspects
25701
+
25702
+ - The content following \`USE DEEPSEARCH\` is arbitrary guidance for the research workflow.
25703
+ - In Agents Server, the OpenAI Agents SDK runtime uses a nested deep-research agent for this tool.
25704
+ - Use this for investigations, comparisons, market scans, or other tasks that benefit from deeper synthesis.
25705
+ - Prefer regular \`USE SEARCH ENGINE\` when a quick factual lookup is enough.
25706
+
25707
+ ## Examples
25708
+
25709
+ \`\`\`book
25710
+ Due Diligence Researcher
25711
+
25712
+ GOAL Investigate vendors thoroughly before making recommendations.
25713
+ USE DEEPSEARCH Compare official sources with credible third-party analysis.
25714
+ RULE Cite the strongest supporting sources in the final answer.
25715
+ \`\`\`
25716
+
25717
+ \`\`\`book
25718
+ Market Analyst
25719
+
25720
+ GOAL Build concise but well-grounded research briefs.
25721
+ USE DEEPSEARCH Focus on recent public information and competing viewpoints.
25722
+ CLOSED
25723
+ \`\`\`
25724
+ `);
25725
+ }
25726
+ applyToAgentModelRequirements(requirements, content) {
25727
+ const existingTools = requirements.tools || [];
25728
+ const updatedTools = existingTools.some((tool) => tool.name === 'deep_search')
25729
+ ? existingTools
25730
+ : [
25731
+ ...existingTools,
25732
+ {
25733
+ name: 'deep_search',
25734
+ description: spaceTrim$1(`
25735
+ Research the internet deeply and synthesize a grounded answer.
25736
+ Use this tool for broader investigations, comparisons, and requests that need more than a quick search.
25737
+ `),
25738
+ parameters: {
25739
+ type: 'object',
25740
+ properties: {
25741
+ query: {
25742
+ type: 'string',
25743
+ description: 'The research question or investigation request.',
25744
+ },
25745
+ },
25746
+ required: ['query'],
25747
+ additionalProperties: false,
25748
+ },
25749
+ },
25750
+ ];
25751
+ return appendAggregatedUseCommitmentPlaceholder({
25752
+ ...requirements,
25753
+ tools: updatedTools,
25754
+ _metadata: {
25755
+ ...requirements._metadata,
25756
+ useDeepSearch: content || true,
25757
+ },
25758
+ }, this.type);
25759
+ }
25760
+ /**
25761
+ * Gets human-readable titles for tool functions provided by this commitment.
25762
+ */
25763
+ getToolTitles() {
25764
+ return {
25765
+ deep_search: 'DeepSearch',
25766
+ };
25767
+ }
25768
+ /**
25769
+ * Gets the local fallback implementation for the `deep_search` tool.
25770
+ */
25771
+ getToolFunctions() {
25772
+ return {
25773
+ deep_search: createSerpSearchToolFunction('deep_search', 'DeepSearch'),
25774
+ };
25775
+ }
25776
+ }
25777
+ // Note: [💞] Ignore a discrepancy between file name and entity name
25778
+
25566
25779
  /**
25567
25780
  * Lightweight email token matcher used for `USE EMAIL` first-line parsing.
25568
25781
  *
@@ -27950,49 +28163,6 @@ function addConfiguredProjectIfMissing(configuredProjects, repositoryReference)
27950
28163
  }
27951
28164
  // Note: [💞] Ignore a discrepancy between file name and entity name
27952
28165
 
27953
- /**
27954
- * A search engine implementation that uses the SerpApi to fetch Google search results.
27955
- *
27956
- * @private <- TODO: !!!! Export via some package
27957
- */
27958
- class SerpSearchEngine {
27959
- get title() {
27960
- return 'SerpApi Search Engine';
27961
- }
27962
- get description() {
27963
- return 'Search engine that uses SerpApi to fetch Google search results';
27964
- }
27965
- checkConfiguration() {
27966
- if (!process.env.SERP_API_KEY) {
27967
- throw new Error('SERP_API_KEY is not configured');
27968
- }
27969
- }
27970
- async search(query, options = {}) {
27971
- const apiKey = process.env.SERP_API_KEY;
27972
- if (!apiKey) {
27973
- throw new Error('SERP_API_KEY is not configured');
27974
- }
27975
- const url = new URL('https://serpapi.com/search');
27976
- url.searchParams.set('api_key', apiKey);
27977
- url.searchParams.set('engine', 'google');
27978
- url.searchParams.set('q', query);
27979
- for (const [key, value] of Object.entries(options)) {
27980
- url.searchParams.set(key, String(value));
27981
- }
27982
- const response = await fetch(url.toString());
27983
- if (!response.ok) {
27984
- const body = await response.text();
27985
- throw new Error(`SerpApi failed with status ${response.status}: ${response.statusText}\n${body}`);
27986
- }
27987
- const data = (await response.json());
27988
- return (data.organic_results || []).map((item) => ({
27989
- title: item.title,
27990
- url: item.link,
27991
- snippet: item.snippet || '',
27992
- }));
27993
- }
27994
- }
27995
-
27996
28166
  /**
27997
28167
  * USE SEARCH ENGINE commitment definition
27998
28168
  *
@@ -28136,26 +28306,7 @@ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
28136
28306
  */
28137
28307
  getToolFunctions() {
28138
28308
  return {
28139
- async web_search(args) {
28140
- console.log('!!!! [Tool] web_search called', { args });
28141
- const { query, ...options } = args;
28142
- if (!query) {
28143
- throw new Error('Search query is required');
28144
- }
28145
- const searchEngine = new SerpSearchEngine();
28146
- const results = await searchEngine.search(query, options);
28147
- return spaceTrim$1((block) => `
28148
- Search results for "${query}"${Object.keys(options).length === 0 ? '' : ` with options ${JSON.stringify(options)}`}:
28149
-
28150
- ${block(results
28151
- .map((result) => spaceTrim$1(`
28152
- - **${result.title}**
28153
- ${result.url}
28154
- ${result.snippet}
28155
- `))
28156
- .join('\n\n'))}
28157
- `);
28158
- },
28309
+ web_search: createSerpSearchToolFunction('web_search', 'Search'),
28159
28310
  };
28160
28311
  }
28161
28312
  }
@@ -29754,6 +29905,7 @@ const COMMITMENT_REGISTRY = [
29754
29905
  new ClosedCommitmentDefinition(),
29755
29906
  new TeamCommitmentDefinition(),
29756
29907
  new UseBrowserCommitmentDefinition(),
29908
+ new UseDeepSearchCommitmentDefinition(),
29757
29909
  new UseSearchEngineCommitmentDefinition(),
29758
29910
  new UseSpawnCommitmentDefinition(),
29759
29911
  new UseTimeoutCommitmentDefinition(),
@@ -30932,6 +31084,11 @@ const SIMPLE_CAPABILITY_BY_COMMITMENT_TYPE = {
30932
31084
  label: 'Internet',
30933
31085
  iconName: 'Search',
30934
31086
  },
31087
+ 'USE DEEPSEARCH': {
31088
+ type: 'search-engine',
31089
+ label: 'DeepSearch',
31090
+ iconName: 'Search',
31091
+ },
30935
31092
  'USE TIME': {
30936
31093
  type: 'time',
30937
31094
  label: 'Time',
@@ -39177,6 +39334,14 @@ function promptbookifyAiText(text) {
39177
39334
  * Constant for default agent kit model name.
39178
39335
  */
39179
39336
  const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5.4-mini';
39337
+ /**
39338
+ * Default model used for nested DeepSearch tool invocations.
39339
+ */
39340
+ const DEFAULT_DEEP_SEARCH_MODEL_NAME = 'o4-mini-deep-research';
39341
+ /**
39342
+ * Tool name used by the Book commitment-backed DeepSearch capability.
39343
+ */
39344
+ const DEEP_SEARCH_TOOL_NAME = 'deep_search';
39180
39345
  /**
39181
39346
  * Creates one structured log entry for streamed tool-call updates.
39182
39347
  *
@@ -39219,6 +39384,98 @@ function resolveFinalToolCallState(options) {
39219
39384
  }
39220
39385
  return 'COMPLETE';
39221
39386
  }
39387
+ /**
39388
+ * Returns true when one tool definition represents the dedicated DeepSearch capability.
39389
+ *
39390
+ * @param toolDefinition - Tool definition from compiled model requirements.
39391
+ * @returns `true` when the tool should be backed by a nested deep-research agent.
39392
+ *
39393
+ * @private helper of `OpenAiAgentKitExecutionTools`
39394
+ */
39395
+ function isDeepSearchToolDefinition(toolDefinition) {
39396
+ return toolDefinition.name === DEEP_SEARCH_TOOL_NAME;
39397
+ }
39398
+ /**
39399
+ * Normalizes Promptbook JSON-schema tool parameters for AgentKit function tools.
39400
+ *
39401
+ * @param parameters - Promptbook tool parameters.
39402
+ * @returns AgentKit-compatible JSON schema or `undefined`.
39403
+ *
39404
+ * @private helper of `OpenAiAgentKitExecutionTools`
39405
+ */
39406
+ function normalizeAgentKitToolParameters(parameters) {
39407
+ var _a, _b;
39408
+ if (!parameters) {
39409
+ return undefined;
39410
+ }
39411
+ return {
39412
+ ...parameters,
39413
+ additionalProperties: (_a = parameters.additionalProperties) !== null && _a !== void 0 ? _a : false,
39414
+ required: (_b = parameters.required) !== null && _b !== void 0 ? _b : [],
39415
+ };
39416
+ }
39417
+ /**
39418
+ * Creates instructions for the nested DeepSearch specialist agent.
39419
+ *
39420
+ * @param toolDescription - Model-facing description from the original tool definition.
39421
+ * @returns System instructions for the nested deep-research agent.
39422
+ *
39423
+ * @private helper of `OpenAiAgentKitExecutionTools`
39424
+ */
39425
+ function createDeepSearchAgentInstructions(toolDescription) {
39426
+ const normalizedDescription = toolDescription.trim();
39427
+ return spaceTrim$1((block) => `
39428
+ You are a DeepSearch specialist working as a tool for another agent.
39429
+ Perform thorough, source-grounded public-web research based on the provided request.
39430
+ Use web search to gather current information, compare relevant viewpoints, and synthesize a concise research brief.
39431
+ Do not ask follow-up questions. If the request is not specific enough, state the assumptions you had to make.
39432
+ Include citations in the research brief whenever sources were used.
39433
+ ${block(normalizedDescription ? `Tool guidance:\n${normalizedDescription}` : '')}
39434
+ `);
39435
+ }
39436
+ /**
39437
+ * Builds the nested DeepSearch prompt from structured tool arguments.
39438
+ *
39439
+ * @param rawInput - Parsed function-tool arguments provided by the outer agent.
39440
+ * @returns Prompt text passed to the nested deep-research agent.
39441
+ *
39442
+ * @private helper of `OpenAiAgentKitExecutionTools`
39443
+ */
39444
+ function buildDeepSearchToolInput(rawInput) {
39445
+ const input = rawInput && typeof rawInput === 'object' ? rawInput : {};
39446
+ const query = typeof input.query === 'string' ? input.query.trim() : '';
39447
+ const additionalHints = Object.entries(input)
39448
+ .filter(([key, value]) => key !== 'query' && value !== undefined && value !== null && String(value).trim() !== '')
39449
+ .map(([key, value]) => `- ${key}: ${typeof value === 'string' ? value : JSON.stringify(value)}`);
39450
+ return spaceTrim$1((block) => `
39451
+ Research request:
39452
+ ${query || JSON.stringify(input)}
39453
+ ${block(additionalHints.length > 0 ? `Execution hints:\n${additionalHints.join('\n')}` : '')}
39454
+ `);
39455
+ }
39456
+ /**
39457
+ * Creates the native Agent SDK tool used for `USE DEEPSEARCH`.
39458
+ *
39459
+ * @param toolDefinition - Promptbook tool definition for `deep_search`.
39460
+ * @returns AgentKit tool backed by a nested deep-research agent.
39461
+ *
39462
+ * @private helper of `OpenAiAgentKitExecutionTools`
39463
+ */
39464
+ function createDeepSearchAgentKitTool(toolDefinition) {
39465
+ const deepSearchAgent = new Agent$1({
39466
+ name: 'DeepSearch',
39467
+ model: DEFAULT_DEEP_SEARCH_MODEL_NAME,
39468
+ instructions: createDeepSearchAgentInstructions(toolDefinition.description),
39469
+ tools: [webSearchTool({ searchContextSize: 'high' })],
39470
+ });
39471
+ return deepSearchAgent.asTool({
39472
+ toolName: toolDefinition.name,
39473
+ toolDescription: toolDefinition.description,
39474
+ parameters: normalizeAgentKitToolParameters(toolDefinition.parameters),
39475
+ inputBuilder: ({ params }) => buildDeepSearchToolInput(params),
39476
+ customOutputExtractor: (result) => { var _a; return typeof result.finalOutput === 'string' ? result.finalOutput : JSON.stringify((_a = result.finalOutput) !== null && _a !== void 0 ? _a : ''); },
39477
+ });
39478
+ }
39222
39479
  /**
39223
39480
  * Constant for default JSON schema name.
39224
39481
  */
@@ -39559,25 +39816,23 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
39559
39816
  * Builds the tool list for AgentKit, including hosted file search when applicable.
39560
39817
  */
39561
39818
  buildAgentKitTools(options) {
39562
- var _a;
39563
39819
  const { tools, vectorStoreId } = options;
39564
39820
  const agentKitTools = [];
39565
39821
  if (vectorStoreId) {
39566
39822
  agentKitTools.push(fileSearchTool(vectorStoreId));
39567
39823
  }
39568
39824
  if (tools && tools.length > 0) {
39569
- const scriptTools = this.resolveScriptTools();
39825
+ let scriptTools = null;
39570
39826
  for (const toolDefinition of tools) {
39827
+ if (isDeepSearchToolDefinition(toolDefinition)) {
39828
+ agentKitTools.push(createDeepSearchAgentKitTool(toolDefinition));
39829
+ continue;
39830
+ }
39831
+ scriptTools !== null && scriptTools !== void 0 ? scriptTools : (scriptTools = this.resolveScriptTools());
39571
39832
  agentKitTools.push(tool({
39572
39833
  name: toolDefinition.name,
39573
39834
  description: toolDefinition.description,
39574
- parameters: toolDefinition.parameters
39575
- ? {
39576
- ...toolDefinition.parameters,
39577
- additionalProperties: false,
39578
- required: (_a = toolDefinition.parameters.required) !== null && _a !== void 0 ? _a : [],
39579
- }
39580
- : undefined,
39835
+ parameters: normalizeAgentKitToolParameters(toolDefinition.parameters),
39581
39836
  strict: false,
39582
39837
  execute: async (input, runContext, details) => {
39583
39838
  var _a, _b, _c, _d;