@promptbook/browser 0.112.0-47 → 0.112.0-49

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 (51) 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/avatarAnimationScheduler.d.ts +16 -0
  5. package/esm/src/avatars/avatarInteractionUtils.d.ts +81 -0
  6. package/esm/src/avatars/avatarInteractionUtils.test.d.ts +1 -0
  7. package/esm/src/avatars/avatarPointerTracking.d.ts +33 -0
  8. package/esm/src/avatars/avatarRenderingUtils.d.ts +3 -2
  9. package/esm/src/avatars/avatarRenderingUtils.test.d.ts +1 -0
  10. package/esm/src/avatars/avatarVisibilityTracking.d.ts +17 -0
  11. package/esm/src/avatars/index.d.ts +1 -1
  12. package/esm/src/avatars/renderAvatarVisual.d.ts +29 -1
  13. package/esm/src/avatars/types/AvatarVisualDefinition.d.ts +35 -0
  14. package/esm/src/avatars/visuals/octopusAvatarVisualShared.d.ts +34 -0
  15. package/esm/src/avatars/visuals/octopusAvatarVisualShared.test.d.ts +1 -0
  16. package/esm/src/book-components/Chat/Chat/ChatProps.d.ts +3 -3
  17. package/esm/src/book-components/Chat/Chat/TeamToolCallModalContent.test.d.ts +2 -0
  18. package/esm/src/commitments/USE/USE.d.ts +1 -0
  19. package/esm/src/commitments/USE/aggregateUseCommitmentSystemMessages.d.ts +1 -1
  20. package/esm/src/commitments/USE_DEEPSEARCH/USE_DEEPSEARCH.d.ts +47 -0
  21. package/esm/src/commitments/USE_DEEPSEARCH/USE_DEEPSEARCH.test.d.ts +1 -0
  22. package/esm/src/commitments/_common/createSerpSearchToolFunction.d.ts +12 -0
  23. package/esm/src/commitments/index.d.ts +2 -1
  24. package/esm/src/llm-providers/openai/OpenAiAgentKitExecutionTools.test.d.ts +1 -0
  25. package/esm/src/version.d.ts +1 -1
  26. package/package.json +2 -2
  27. package/umd/index.umd.js +330 -75
  28. package/umd/index.umd.js.map +1 -1
  29. package/umd/src/avatars/AvatarOrImage.d.ts +5 -1
  30. package/umd/src/avatars/avatarAnimationScheduler.d.ts +16 -0
  31. package/umd/src/avatars/avatarInteractionUtils.d.ts +81 -0
  32. package/umd/src/avatars/avatarInteractionUtils.test.d.ts +1 -0
  33. package/umd/src/avatars/avatarPointerTracking.d.ts +33 -0
  34. package/umd/src/avatars/avatarRenderingUtils.d.ts +3 -2
  35. package/umd/src/avatars/avatarRenderingUtils.test.d.ts +1 -0
  36. package/umd/src/avatars/avatarVisibilityTracking.d.ts +17 -0
  37. package/umd/src/avatars/index.d.ts +1 -1
  38. package/umd/src/avatars/renderAvatarVisual.d.ts +29 -1
  39. package/umd/src/avatars/types/AvatarVisualDefinition.d.ts +35 -0
  40. package/umd/src/avatars/visuals/octopusAvatarVisualShared.d.ts +34 -0
  41. package/umd/src/avatars/visuals/octopusAvatarVisualShared.test.d.ts +1 -0
  42. package/umd/src/book-components/Chat/Chat/ChatProps.d.ts +3 -3
  43. package/umd/src/book-components/Chat/Chat/TeamToolCallModalContent.test.d.ts +2 -0
  44. package/umd/src/commitments/USE/USE.d.ts +1 -0
  45. package/umd/src/commitments/USE/aggregateUseCommitmentSystemMessages.d.ts +1 -1
  46. package/umd/src/commitments/USE_DEEPSEARCH/USE_DEEPSEARCH.d.ts +47 -0
  47. package/umd/src/commitments/USE_DEEPSEARCH/USE_DEEPSEARCH.test.d.ts +1 -0
  48. package/umd/src/commitments/_common/createSerpSearchToolFunction.d.ts +12 -0
  49. package/umd/src/commitments/index.d.ts +2 -1
  50. package/umd/src/llm-providers/openai/OpenAiAgentKitExecutionTools.test.d.ts +1 -0
  51. package/umd/src/version.d.ts +1 -1
package/umd/index.umd.js CHANGED
@@ -27,7 +27,7 @@
27
27
  * @generated
28
28
  * @see https://github.com/webgptorg/promptbook
29
29
  */
30
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-47';
30
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-49';
31
31
  /**
32
32
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
33
33
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -10720,6 +10720,7 @@
10720
10720
  * Supported USE types:
10721
10721
  * - USE BROWSER: Enables the agent to use a web browser tool
10722
10722
  * - USE SEARCH ENGINE (future): Enables search engine access
10723
+ * - USE DEEPSEARCH: Enables deeper research-oriented search access
10723
10724
  * - USE FILE SYSTEM (future): Enables file system operations
10724
10725
  * - USE MCP (future): Enables MCP server connections
10725
10726
  *
@@ -10742,7 +10743,7 @@
10742
10743
  * Short one-line description of USE commitments.
10743
10744
  */
10744
10745
  get description() {
10745
- return 'Enable the agent to use specific tools or capabilities (BROWSER, SEARCH ENGINE, etc.).';
10746
+ return 'Enable the agent to use specific tools or capabilities (BROWSER, SEARCH ENGINE, DEEPSEARCH, etc.).';
10746
10747
  }
10747
10748
  /**
10748
10749
  * Icon for this commitment.
@@ -10763,6 +10764,7 @@
10763
10764
 
10764
10765
  - **USE BROWSER** - Enables the agent to use a web browser tool to access and retrieve information from the internet
10765
10766
  - **USE SEARCH ENGINE** (future) - Enables search engine access
10767
+ - **USE DEEPSEARCH** - Enables deeper research-oriented search access
10766
10768
  - **USE FILE SYSTEM** (future) - Enables file system operations
10767
10769
  - **USE MCP** (future) - Enables MCP server connections
10768
10770
 
@@ -10817,7 +10819,7 @@
10817
10819
  * Checks if this is a known USE type
10818
10820
  */
10819
10821
  isKnownUseType(useType) {
10820
- const knownTypes = ['BROWSER', 'SEARCH ENGINE', 'FILE SYSTEM', 'MCP'];
10822
+ const knownTypes = ['BROWSER', 'SEARCH ENGINE', 'DEEPSEARCH', 'FILE SYSTEM', 'MCP'];
10821
10823
  return knownTypes.includes(useType.toUpperCase());
10822
10824
  }
10823
10825
  }
@@ -10830,6 +10832,7 @@
10830
10832
  */
10831
10833
  const AGGREGATED_USE_COMMITMENT_TYPES = [
10832
10834
  'USE BROWSER',
10835
+ 'USE DEEPSEARCH',
10833
10836
  'USE SEARCH ENGINE',
10834
10837
  'USE TIME',
10835
10838
  ];
@@ -10909,6 +10912,15 @@
10909
10912
  - Do not tell the user you cannot search for information, YOU CAN.
10910
10913
  ${block(formatOptionalInstructionBlock('Search instructions', combinedAdditionalInstructions))}
10911
10914
  `);
10915
+ case 'USE DEEPSEARCH':
10916
+ return spacetrim.spaceTrim((block) => `
10917
+ Tool:
10918
+ - You have access to DeepSearch via the tool "deep_search".
10919
+ - Use it for broader research tasks that need multi-step investigation, comparison, or synthesis across multiple sources.
10920
+ - Prefer it over quick search when the user asks for a well-grounded brief, report, or deeper investigation.
10921
+ - Do not pretend you cannot research current information when this tool is available.
10922
+ ${block(formatOptionalInstructionBlock('DeepSearch instructions', combinedAdditionalInstructions))}
10923
+ `);
10912
10924
  }
10913
10925
  }
10914
10926
  /**
@@ -12458,6 +12470,207 @@
12458
12470
  }
12459
12471
  // Note: [💞] Ignore a discrepancy between file name and entity name
12460
12472
 
12473
+ /**
12474
+ * A search engine implementation that uses the SerpApi to fetch Google search results.
12475
+ *
12476
+ * @private <- TODO: !!!! Export via some package
12477
+ */
12478
+ class SerpSearchEngine {
12479
+ get title() {
12480
+ return 'SerpApi Search Engine';
12481
+ }
12482
+ get description() {
12483
+ return 'Search engine that uses SerpApi to fetch Google search results';
12484
+ }
12485
+ checkConfiguration() {
12486
+ if (!process.env.SERP_API_KEY) {
12487
+ throw new Error('SERP_API_KEY is not configured');
12488
+ }
12489
+ }
12490
+ async search(query, options = {}) {
12491
+ const apiKey = process.env.SERP_API_KEY;
12492
+ if (!apiKey) {
12493
+ throw new Error('SERP_API_KEY is not configured');
12494
+ }
12495
+ const url = new URL('https://serpapi.com/search');
12496
+ url.searchParams.set('api_key', apiKey);
12497
+ url.searchParams.set('engine', 'google');
12498
+ url.searchParams.set('q', query);
12499
+ for (const [key, value] of Object.entries(options)) {
12500
+ url.searchParams.set(key, String(value));
12501
+ }
12502
+ const response = await fetch(url.toString());
12503
+ if (!response.ok) {
12504
+ const body = await response.text();
12505
+ throw new Error(`SerpApi failed with status ${response.status}: ${response.statusText}\n${body}`);
12506
+ }
12507
+ const data = (await response.json());
12508
+ return (data.organic_results || []).map((item) => ({
12509
+ title: item.title,
12510
+ url: item.link,
12511
+ snippet: item.snippet || '',
12512
+ }));
12513
+ }
12514
+ }
12515
+
12516
+ /**
12517
+ * Creates one SERP-backed tool function used as a local fallback for search-like commitments.
12518
+ *
12519
+ * @param toolName - Technical tool name used for validation messages.
12520
+ * @param resultLabel - Human-readable label used in formatted results.
12521
+ * @returns Async tool function compatible with commitment tool registration.
12522
+ *
12523
+ * @private internal helper for search-like commitments
12524
+ */
12525
+ function createSerpSearchToolFunction(toolName, resultLabel) {
12526
+ return async (rawArgs) => {
12527
+ const { query, ...searchOptions } = rawArgs;
12528
+ if (typeof query !== 'string' || !query.trim()) {
12529
+ throw new Error(`${toolName} query is required`);
12530
+ }
12531
+ const searchEngine = new SerpSearchEngine();
12532
+ const results = await searchEngine.search(query, searchOptions);
12533
+ return spacetrim.spaceTrim((block) => `
12534
+ ${resultLabel} results for "${query}"${Object.keys(searchOptions).length === 0
12535
+ ? ''
12536
+ : ` with options ${JSON.stringify(searchOptions)}`}:
12537
+
12538
+ ${block(results
12539
+ .map((result) => spacetrim.spaceTrim(`
12540
+ - **${result.title}**
12541
+ ${result.url}
12542
+ ${result.snippet}
12543
+ `))
12544
+ .join('\n\n'))}
12545
+ `);
12546
+ };
12547
+ }
12548
+
12549
+ /**
12550
+ * USE DEEPSEARCH commitment definition
12551
+ *
12552
+ * The `USE DEEPSEARCH` commitment indicates that the agent should use a deeper research-oriented
12553
+ * search workflow instead of lightweight web search when it needs fresh information from the internet.
12554
+ *
12555
+ * The content following `USE DEEPSEARCH` is an arbitrary text that the agent should know
12556
+ * (e.g. search scope or research instructions).
12557
+ *
12558
+ * Example usage in agent source:
12559
+ *
12560
+ * ```book
12561
+ * USE DEEPSEARCH
12562
+ * USE DEEPSEARCH Compare official vendor documentation with independent benchmarks.
12563
+ * ```
12564
+ *
12565
+ * @private [🪔] Maybe export the commitments through some package
12566
+ */
12567
+ class UseDeepSearchCommitmentDefinition extends BaseCommitmentDefinition {
12568
+ constructor() {
12569
+ super('USE DEEPSEARCH');
12570
+ }
12571
+ get requiresContent() {
12572
+ return false;
12573
+ }
12574
+ /**
12575
+ * Short one-line description of USE DEEPSEARCH.
12576
+ */
12577
+ get description() {
12578
+ return 'Enable the agent to use DeepSearch for more thorough internet research.';
12579
+ }
12580
+ /**
12581
+ * Icon for this commitment.
12582
+ */
12583
+ get icon() {
12584
+ return '🔬';
12585
+ }
12586
+ /**
12587
+ * Markdown documentation for USE DEEPSEARCH commitment.
12588
+ */
12589
+ get documentation() {
12590
+ return spacetrim.spaceTrim(`
12591
+ # USE DEEPSEARCH
12592
+
12593
+ Enables the agent to use DeepSearch for broader, more thorough internet research than lightweight web search.
12594
+
12595
+ ## Key aspects
12596
+
12597
+ - The content following \`USE DEEPSEARCH\` is arbitrary guidance for the research workflow.
12598
+ - In Agents Server, the OpenAI Agents SDK runtime uses a nested deep-research agent for this tool.
12599
+ - Use this for investigations, comparisons, market scans, or other tasks that benefit from deeper synthesis.
12600
+ - Prefer regular \`USE SEARCH ENGINE\` when a quick factual lookup is enough.
12601
+
12602
+ ## Examples
12603
+
12604
+ \`\`\`book
12605
+ Due Diligence Researcher
12606
+
12607
+ GOAL Investigate vendors thoroughly before making recommendations.
12608
+ USE DEEPSEARCH Compare official sources with credible third-party analysis.
12609
+ RULE Cite the strongest supporting sources in the final answer.
12610
+ \`\`\`
12611
+
12612
+ \`\`\`book
12613
+ Market Analyst
12614
+
12615
+ GOAL Build concise but well-grounded research briefs.
12616
+ USE DEEPSEARCH Focus on recent public information and competing viewpoints.
12617
+ CLOSED
12618
+ \`\`\`
12619
+ `);
12620
+ }
12621
+ applyToAgentModelRequirements(requirements, content) {
12622
+ const existingTools = requirements.tools || [];
12623
+ const updatedTools = existingTools.some((tool) => tool.name === 'deep_search')
12624
+ ? existingTools
12625
+ : [
12626
+ ...existingTools,
12627
+ {
12628
+ name: 'deep_search',
12629
+ description: spacetrim.spaceTrim(`
12630
+ Research the internet deeply and synthesize a grounded answer.
12631
+ Use this tool for broader investigations, comparisons, and requests that need more than a quick search.
12632
+ `),
12633
+ parameters: {
12634
+ type: 'object',
12635
+ properties: {
12636
+ query: {
12637
+ type: 'string',
12638
+ description: 'The research question or investigation request.',
12639
+ },
12640
+ },
12641
+ required: ['query'],
12642
+ additionalProperties: false,
12643
+ },
12644
+ },
12645
+ ];
12646
+ return appendAggregatedUseCommitmentPlaceholder({
12647
+ ...requirements,
12648
+ tools: updatedTools,
12649
+ _metadata: {
12650
+ ...requirements._metadata,
12651
+ useDeepSearch: content || true,
12652
+ },
12653
+ }, this.type);
12654
+ }
12655
+ /**
12656
+ * Gets human-readable titles for tool functions provided by this commitment.
12657
+ */
12658
+ getToolTitles() {
12659
+ return {
12660
+ deep_search: 'DeepSearch',
12661
+ };
12662
+ }
12663
+ /**
12664
+ * Gets the local fallback implementation for the `deep_search` tool.
12665
+ */
12666
+ getToolFunctions() {
12667
+ return {
12668
+ deep_search: createSerpSearchToolFunction('deep_search', 'DeepSearch'),
12669
+ };
12670
+ }
12671
+ }
12672
+ // Note: [💞] Ignore a discrepancy between file name and entity name
12673
+
12461
12674
  /**
12462
12675
  * Lightweight email token matcher used for `USE EMAIL` first-line parsing.
12463
12676
  *
@@ -14864,49 +15077,6 @@
14864
15077
  }
14865
15078
  // Note: [💞] Ignore a discrepancy between file name and entity name
14866
15079
 
14867
- /**
14868
- * A search engine implementation that uses the SerpApi to fetch Google search results.
14869
- *
14870
- * @private <- TODO: !!!! Export via some package
14871
- */
14872
- class SerpSearchEngine {
14873
- get title() {
14874
- return 'SerpApi Search Engine';
14875
- }
14876
- get description() {
14877
- return 'Search engine that uses SerpApi to fetch Google search results';
14878
- }
14879
- checkConfiguration() {
14880
- if (!process.env.SERP_API_KEY) {
14881
- throw new Error('SERP_API_KEY is not configured');
14882
- }
14883
- }
14884
- async search(query, options = {}) {
14885
- const apiKey = process.env.SERP_API_KEY;
14886
- if (!apiKey) {
14887
- throw new Error('SERP_API_KEY is not configured');
14888
- }
14889
- const url = new URL('https://serpapi.com/search');
14890
- url.searchParams.set('api_key', apiKey);
14891
- url.searchParams.set('engine', 'google');
14892
- url.searchParams.set('q', query);
14893
- for (const [key, value] of Object.entries(options)) {
14894
- url.searchParams.set(key, String(value));
14895
- }
14896
- const response = await fetch(url.toString());
14897
- if (!response.ok) {
14898
- const body = await response.text();
14899
- throw new Error(`SerpApi failed with status ${response.status}: ${response.statusText}\n${body}`);
14900
- }
14901
- const data = (await response.json());
14902
- return (data.organic_results || []).map((item) => ({
14903
- title: item.title,
14904
- url: item.link,
14905
- snippet: item.snippet || '',
14906
- }));
14907
- }
14908
- }
14909
-
14910
15080
  /**
14911
15081
  * USE SEARCH ENGINE commitment definition
14912
15082
  *
@@ -15050,26 +15220,7 @@
15050
15220
  */
15051
15221
  getToolFunctions() {
15052
15222
  return {
15053
- async web_search(args) {
15054
- console.log('!!!! [Tool] web_search called', { args });
15055
- const { query, ...options } = args;
15056
- if (!query) {
15057
- throw new Error('Search query is required');
15058
- }
15059
- const searchEngine = new SerpSearchEngine();
15060
- const results = await searchEngine.search(query, options);
15061
- return spacetrim.spaceTrim((block) => `
15062
- Search results for "${query}"${Object.keys(options).length === 0 ? '' : ` with options ${JSON.stringify(options)}`}:
15063
-
15064
- ${block(results
15065
- .map((result) => spacetrim.spaceTrim(`
15066
- - **${result.title}**
15067
- ${result.url}
15068
- ${result.snippet}
15069
- `))
15070
- .join('\n\n'))}
15071
- `);
15072
- },
15223
+ web_search: createSerpSearchToolFunction('web_search', 'Search'),
15073
15224
  };
15074
15225
  }
15075
15226
  }
@@ -16715,6 +16866,7 @@
16715
16866
  new ClosedCommitmentDefinition(),
16716
16867
  new TeamCommitmentDefinition(),
16717
16868
  new UseBrowserCommitmentDefinition(),
16869
+ new UseDeepSearchCommitmentDefinition(),
16718
16870
  new UseSearchEngineCommitmentDefinition(),
16719
16871
  new UseSpawnCommitmentDefinition(),
16720
16872
  new UseTimeoutCommitmentDefinition(),
@@ -17608,6 +17760,11 @@
17608
17760
  label: 'Internet',
17609
17761
  iconName: 'Search',
17610
17762
  },
17763
+ 'USE DEEPSEARCH': {
17764
+ type: 'search-engine',
17765
+ label: 'DeepSearch',
17766
+ iconName: 'Search',
17767
+ },
17611
17768
  'USE TIME': {
17612
17769
  type: 'time',
17613
17770
  label: 'Time',
@@ -27616,6 +27773,14 @@
27616
27773
  * Constant for default agent kit model name.
27617
27774
  */
27618
27775
  const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5.4-mini';
27776
+ /**
27777
+ * Default model used for nested DeepSearch tool invocations.
27778
+ */
27779
+ const DEFAULT_DEEP_SEARCH_MODEL_NAME = 'o4-mini-deep-research';
27780
+ /**
27781
+ * Tool name used by the Book commitment-backed DeepSearch capability.
27782
+ */
27783
+ const DEEP_SEARCH_TOOL_NAME = 'deep_search';
27619
27784
  /**
27620
27785
  * Creates one structured log entry for streamed tool-call updates.
27621
27786
  *
@@ -27658,6 +27823,98 @@
27658
27823
  }
27659
27824
  return 'COMPLETE';
27660
27825
  }
27826
+ /**
27827
+ * Returns true when one tool definition represents the dedicated DeepSearch capability.
27828
+ *
27829
+ * @param toolDefinition - Tool definition from compiled model requirements.
27830
+ * @returns `true` when the tool should be backed by a nested deep-research agent.
27831
+ *
27832
+ * @private helper of `OpenAiAgentKitExecutionTools`
27833
+ */
27834
+ function isDeepSearchToolDefinition(toolDefinition) {
27835
+ return toolDefinition.name === DEEP_SEARCH_TOOL_NAME;
27836
+ }
27837
+ /**
27838
+ * Normalizes Promptbook JSON-schema tool parameters for AgentKit function tools.
27839
+ *
27840
+ * @param parameters - Promptbook tool parameters.
27841
+ * @returns AgentKit-compatible JSON schema or `undefined`.
27842
+ *
27843
+ * @private helper of `OpenAiAgentKitExecutionTools`
27844
+ */
27845
+ function normalizeAgentKitToolParameters(parameters) {
27846
+ var _a, _b;
27847
+ if (!parameters) {
27848
+ return undefined;
27849
+ }
27850
+ return {
27851
+ ...parameters,
27852
+ additionalProperties: (_a = parameters.additionalProperties) !== null && _a !== void 0 ? _a : false,
27853
+ required: (_b = parameters.required) !== null && _b !== void 0 ? _b : [],
27854
+ };
27855
+ }
27856
+ /**
27857
+ * Creates instructions for the nested DeepSearch specialist agent.
27858
+ *
27859
+ * @param toolDescription - Model-facing description from the original tool definition.
27860
+ * @returns System instructions for the nested deep-research agent.
27861
+ *
27862
+ * @private helper of `OpenAiAgentKitExecutionTools`
27863
+ */
27864
+ function createDeepSearchAgentInstructions(toolDescription) {
27865
+ const normalizedDescription = toolDescription.trim();
27866
+ return spacetrim.spaceTrim((block) => `
27867
+ You are a DeepSearch specialist working as a tool for another agent.
27868
+ Perform thorough, source-grounded public-web research based on the provided request.
27869
+ Use web search to gather current information, compare relevant viewpoints, and synthesize a concise research brief.
27870
+ Do not ask follow-up questions. If the request is not specific enough, state the assumptions you had to make.
27871
+ Include citations in the research brief whenever sources were used.
27872
+ ${block(normalizedDescription ? `Tool guidance:\n${normalizedDescription}` : '')}
27873
+ `);
27874
+ }
27875
+ /**
27876
+ * Builds the nested DeepSearch prompt from structured tool arguments.
27877
+ *
27878
+ * @param rawInput - Parsed function-tool arguments provided by the outer agent.
27879
+ * @returns Prompt text passed to the nested deep-research agent.
27880
+ *
27881
+ * @private helper of `OpenAiAgentKitExecutionTools`
27882
+ */
27883
+ function buildDeepSearchToolInput(rawInput) {
27884
+ const input = rawInput && typeof rawInput === 'object' ? rawInput : {};
27885
+ const query = typeof input.query === 'string' ? input.query.trim() : '';
27886
+ const additionalHints = Object.entries(input)
27887
+ .filter(([key, value]) => key !== 'query' && value !== undefined && value !== null && String(value).trim() !== '')
27888
+ .map(([key, value]) => `- ${key}: ${typeof value === 'string' ? value : JSON.stringify(value)}`);
27889
+ return spacetrim.spaceTrim((block) => `
27890
+ Research request:
27891
+ ${query || JSON.stringify(input)}
27892
+ ${block(additionalHints.length > 0 ? `Execution hints:\n${additionalHints.join('\n')}` : '')}
27893
+ `);
27894
+ }
27895
+ /**
27896
+ * Creates the native Agent SDK tool used for `USE DEEPSEARCH`.
27897
+ *
27898
+ * @param toolDefinition - Promptbook tool definition for `deep_search`.
27899
+ * @returns AgentKit tool backed by a nested deep-research agent.
27900
+ *
27901
+ * @private helper of `OpenAiAgentKitExecutionTools`
27902
+ */
27903
+ function createDeepSearchAgentKitTool(toolDefinition) {
27904
+ const deepSearchAgent = new agents.Agent({
27905
+ name: 'DeepSearch',
27906
+ model: DEFAULT_DEEP_SEARCH_MODEL_NAME,
27907
+ instructions: createDeepSearchAgentInstructions(toolDefinition.description),
27908
+ tools: [agents.webSearchTool({ searchContextSize: 'high' })],
27909
+ });
27910
+ return deepSearchAgent.asTool({
27911
+ toolName: toolDefinition.name,
27912
+ toolDescription: toolDefinition.description,
27913
+ parameters: normalizeAgentKitToolParameters(toolDefinition.parameters),
27914
+ inputBuilder: ({ params }) => buildDeepSearchToolInput(params),
27915
+ customOutputExtractor: (result) => { var _a; return typeof result.finalOutput === 'string' ? result.finalOutput : JSON.stringify((_a = result.finalOutput) !== null && _a !== void 0 ? _a : ''); },
27916
+ });
27917
+ }
27661
27918
  /**
27662
27919
  * Constant for default JSON schema name.
27663
27920
  */
@@ -27998,25 +28255,23 @@
27998
28255
  * Builds the tool list for AgentKit, including hosted file search when applicable.
27999
28256
  */
28000
28257
  buildAgentKitTools(options) {
28001
- var _a;
28002
28258
  const { tools, vectorStoreId } = options;
28003
28259
  const agentKitTools = [];
28004
28260
  if (vectorStoreId) {
28005
28261
  agentKitTools.push(agents.fileSearchTool(vectorStoreId));
28006
28262
  }
28007
28263
  if (tools && tools.length > 0) {
28008
- const scriptTools = this.resolveScriptTools();
28264
+ let scriptTools = null;
28009
28265
  for (const toolDefinition of tools) {
28266
+ if (isDeepSearchToolDefinition(toolDefinition)) {
28267
+ agentKitTools.push(createDeepSearchAgentKitTool(toolDefinition));
28268
+ continue;
28269
+ }
28270
+ scriptTools !== null && scriptTools !== void 0 ? scriptTools : (scriptTools = this.resolveScriptTools());
28010
28271
  agentKitTools.push(agents.tool({
28011
28272
  name: toolDefinition.name,
28012
28273
  description: toolDefinition.description,
28013
- parameters: toolDefinition.parameters
28014
- ? {
28015
- ...toolDefinition.parameters,
28016
- additionalProperties: false,
28017
- required: (_a = toolDefinition.parameters.required) !== null && _a !== void 0 ? _a : [],
28018
- }
28019
- : undefined,
28274
+ parameters: normalizeAgentKitToolParameters(toolDefinition.parameters),
28020
28275
  strict: false,
28021
28276
  execute: async (input, runContext, details) => {
28022
28277
  var _a, _b, _c, _d;