@promptbook/core 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 +1 -1
  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
@@ -10,7 +10,7 @@ import { lookup, extension } from 'mime-types';
10
10
  import { parse, unparse } from 'papaparse';
11
11
  import moment from 'moment';
12
12
  import colors from 'colors';
13
- import { Agent as Agent$1, setDefaultOpenAIClient, setDefaultOpenAIKey, fileSearchTool, tool, run } from '@openai/agents';
13
+ import { Agent as Agent$1, setDefaultOpenAIClient, setDefaultOpenAIKey, fileSearchTool, tool, run, webSearchTool } from '@openai/agents';
14
14
  import Bottleneck from 'bottleneck';
15
15
  import OpenAI from 'openai';
16
16
 
@@ -28,7 +28,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
28
28
  * @generated
29
29
  * @see https://github.com/webgptorg/promptbook
30
30
  */
31
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-47';
31
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-48';
32
32
  /**
33
33
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
34
34
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -15651,6 +15651,7 @@ class TemplateCommitmentDefinition extends BaseCommitmentDefinition {
15651
15651
  * Supported USE types:
15652
15652
  * - USE BROWSER: Enables the agent to use a web browser tool
15653
15653
  * - USE SEARCH ENGINE (future): Enables search engine access
15654
+ * - USE DEEPSEARCH: Enables deeper research-oriented search access
15654
15655
  * - USE FILE SYSTEM (future): Enables file system operations
15655
15656
  * - USE MCP (future): Enables MCP server connections
15656
15657
  *
@@ -15673,7 +15674,7 @@ class UseCommitmentDefinition extends BaseCommitmentDefinition {
15673
15674
  * Short one-line description of USE commitments.
15674
15675
  */
15675
15676
  get description() {
15676
- return 'Enable the agent to use specific tools or capabilities (BROWSER, SEARCH ENGINE, etc.).';
15677
+ return 'Enable the agent to use specific tools or capabilities (BROWSER, SEARCH ENGINE, DEEPSEARCH, etc.).';
15677
15678
  }
15678
15679
  /**
15679
15680
  * Icon for this commitment.
@@ -15694,6 +15695,7 @@ class UseCommitmentDefinition extends BaseCommitmentDefinition {
15694
15695
 
15695
15696
  - **USE BROWSER** - Enables the agent to use a web browser tool to access and retrieve information from the internet
15696
15697
  - **USE SEARCH ENGINE** (future) - Enables search engine access
15698
+ - **USE DEEPSEARCH** - Enables deeper research-oriented search access
15697
15699
  - **USE FILE SYSTEM** (future) - Enables file system operations
15698
15700
  - **USE MCP** (future) - Enables MCP server connections
15699
15701
 
@@ -15748,7 +15750,7 @@ class UseCommitmentDefinition extends BaseCommitmentDefinition {
15748
15750
  * Checks if this is a known USE type
15749
15751
  */
15750
15752
  isKnownUseType(useType) {
15751
- const knownTypes = ['BROWSER', 'SEARCH ENGINE', 'FILE SYSTEM', 'MCP'];
15753
+ const knownTypes = ['BROWSER', 'SEARCH ENGINE', 'DEEPSEARCH', 'FILE SYSTEM', 'MCP'];
15752
15754
  return knownTypes.includes(useType.toUpperCase());
15753
15755
  }
15754
15756
  }
@@ -15761,6 +15763,7 @@ class UseCommitmentDefinition extends BaseCommitmentDefinition {
15761
15763
  */
15762
15764
  const AGGREGATED_USE_COMMITMENT_TYPES = [
15763
15765
  'USE BROWSER',
15766
+ 'USE DEEPSEARCH',
15764
15767
  'USE SEARCH ENGINE',
15765
15768
  'USE TIME',
15766
15769
  ];
@@ -15840,6 +15843,15 @@ function createAggregatedUseCommitmentSystemMessage(type, additionalInstructions
15840
15843
  - Do not tell the user you cannot search for information, YOU CAN.
15841
15844
  ${block(formatOptionalInstructionBlock('Search instructions', combinedAdditionalInstructions))}
15842
15845
  `);
15846
+ case 'USE DEEPSEARCH':
15847
+ return spaceTrim$1((block) => `
15848
+ Tool:
15849
+ - You have access to DeepSearch via the tool "deep_search".
15850
+ - Use it for broader research tasks that need multi-step investigation, comparison, or synthesis across multiple sources.
15851
+ - Prefer it over quick search when the user asks for a well-grounded brief, report, or deeper investigation.
15852
+ - Do not pretend you cannot research current information when this tool is available.
15853
+ ${block(formatOptionalInstructionBlock('DeepSearch instructions', combinedAdditionalInstructions))}
15854
+ `);
15843
15855
  }
15844
15856
  }
15845
15857
  /**
@@ -17389,6 +17401,207 @@ function addConfiguredCalendarIfMissing(configuredCalendars, calendarReference)
17389
17401
  }
17390
17402
  // Note: [💞] Ignore a discrepancy between file name and entity name
17391
17403
 
17404
+ /**
17405
+ * A search engine implementation that uses the SerpApi to fetch Google search results.
17406
+ *
17407
+ * @private <- TODO: !!!! Export via some package
17408
+ */
17409
+ class SerpSearchEngine {
17410
+ get title() {
17411
+ return 'SerpApi Search Engine';
17412
+ }
17413
+ get description() {
17414
+ return 'Search engine that uses SerpApi to fetch Google search results';
17415
+ }
17416
+ checkConfiguration() {
17417
+ if (!process.env.SERP_API_KEY) {
17418
+ throw new Error('SERP_API_KEY is not configured');
17419
+ }
17420
+ }
17421
+ async search(query, options = {}) {
17422
+ const apiKey = process.env.SERP_API_KEY;
17423
+ if (!apiKey) {
17424
+ throw new Error('SERP_API_KEY is not configured');
17425
+ }
17426
+ const url = new URL('https://serpapi.com/search');
17427
+ url.searchParams.set('api_key', apiKey);
17428
+ url.searchParams.set('engine', 'google');
17429
+ url.searchParams.set('q', query);
17430
+ for (const [key, value] of Object.entries(options)) {
17431
+ url.searchParams.set(key, String(value));
17432
+ }
17433
+ const response = await fetch(url.toString());
17434
+ if (!response.ok) {
17435
+ const body = await response.text();
17436
+ throw new Error(`SerpApi failed with status ${response.status}: ${response.statusText}\n${body}`);
17437
+ }
17438
+ const data = (await response.json());
17439
+ return (data.organic_results || []).map((item) => ({
17440
+ title: item.title,
17441
+ url: item.link,
17442
+ snippet: item.snippet || '',
17443
+ }));
17444
+ }
17445
+ }
17446
+
17447
+ /**
17448
+ * Creates one SERP-backed tool function used as a local fallback for search-like commitments.
17449
+ *
17450
+ * @param toolName - Technical tool name used for validation messages.
17451
+ * @param resultLabel - Human-readable label used in formatted results.
17452
+ * @returns Async tool function compatible with commitment tool registration.
17453
+ *
17454
+ * @private internal helper for search-like commitments
17455
+ */
17456
+ function createSerpSearchToolFunction(toolName, resultLabel) {
17457
+ return async (rawArgs) => {
17458
+ const { query, ...searchOptions } = rawArgs;
17459
+ if (typeof query !== 'string' || !query.trim()) {
17460
+ throw new Error(`${toolName} query is required`);
17461
+ }
17462
+ const searchEngine = new SerpSearchEngine();
17463
+ const results = await searchEngine.search(query, searchOptions);
17464
+ return spaceTrim$1((block) => `
17465
+ ${resultLabel} results for "${query}"${Object.keys(searchOptions).length === 0
17466
+ ? ''
17467
+ : ` with options ${JSON.stringify(searchOptions)}`}:
17468
+
17469
+ ${block(results
17470
+ .map((result) => spaceTrim$1(`
17471
+ - **${result.title}**
17472
+ ${result.url}
17473
+ ${result.snippet}
17474
+ `))
17475
+ .join('\n\n'))}
17476
+ `);
17477
+ };
17478
+ }
17479
+
17480
+ /**
17481
+ * USE DEEPSEARCH commitment definition
17482
+ *
17483
+ * The `USE DEEPSEARCH` commitment indicates that the agent should use a deeper research-oriented
17484
+ * search workflow instead of lightweight web search when it needs fresh information from the internet.
17485
+ *
17486
+ * The content following `USE DEEPSEARCH` is an arbitrary text that the agent should know
17487
+ * (e.g. search scope or research instructions).
17488
+ *
17489
+ * Example usage in agent source:
17490
+ *
17491
+ * ```book
17492
+ * USE DEEPSEARCH
17493
+ * USE DEEPSEARCH Compare official vendor documentation with independent benchmarks.
17494
+ * ```
17495
+ *
17496
+ * @private [🪔] Maybe export the commitments through some package
17497
+ */
17498
+ class UseDeepSearchCommitmentDefinition extends BaseCommitmentDefinition {
17499
+ constructor() {
17500
+ super('USE DEEPSEARCH');
17501
+ }
17502
+ get requiresContent() {
17503
+ return false;
17504
+ }
17505
+ /**
17506
+ * Short one-line description of USE DEEPSEARCH.
17507
+ */
17508
+ get description() {
17509
+ return 'Enable the agent to use DeepSearch for more thorough internet research.';
17510
+ }
17511
+ /**
17512
+ * Icon for this commitment.
17513
+ */
17514
+ get icon() {
17515
+ return '🔬';
17516
+ }
17517
+ /**
17518
+ * Markdown documentation for USE DEEPSEARCH commitment.
17519
+ */
17520
+ get documentation() {
17521
+ return spaceTrim$1(`
17522
+ # USE DEEPSEARCH
17523
+
17524
+ Enables the agent to use DeepSearch for broader, more thorough internet research than lightweight web search.
17525
+
17526
+ ## Key aspects
17527
+
17528
+ - The content following \`USE DEEPSEARCH\` is arbitrary guidance for the research workflow.
17529
+ - In Agents Server, the OpenAI Agents SDK runtime uses a nested deep-research agent for this tool.
17530
+ - Use this for investigations, comparisons, market scans, or other tasks that benefit from deeper synthesis.
17531
+ - Prefer regular \`USE SEARCH ENGINE\` when a quick factual lookup is enough.
17532
+
17533
+ ## Examples
17534
+
17535
+ \`\`\`book
17536
+ Due Diligence Researcher
17537
+
17538
+ GOAL Investigate vendors thoroughly before making recommendations.
17539
+ USE DEEPSEARCH Compare official sources with credible third-party analysis.
17540
+ RULE Cite the strongest supporting sources in the final answer.
17541
+ \`\`\`
17542
+
17543
+ \`\`\`book
17544
+ Market Analyst
17545
+
17546
+ GOAL Build concise but well-grounded research briefs.
17547
+ USE DEEPSEARCH Focus on recent public information and competing viewpoints.
17548
+ CLOSED
17549
+ \`\`\`
17550
+ `);
17551
+ }
17552
+ applyToAgentModelRequirements(requirements, content) {
17553
+ const existingTools = requirements.tools || [];
17554
+ const updatedTools = existingTools.some((tool) => tool.name === 'deep_search')
17555
+ ? existingTools
17556
+ : [
17557
+ ...existingTools,
17558
+ {
17559
+ name: 'deep_search',
17560
+ description: spaceTrim$1(`
17561
+ Research the internet deeply and synthesize a grounded answer.
17562
+ Use this tool for broader investigations, comparisons, and requests that need more than a quick search.
17563
+ `),
17564
+ parameters: {
17565
+ type: 'object',
17566
+ properties: {
17567
+ query: {
17568
+ type: 'string',
17569
+ description: 'The research question or investigation request.',
17570
+ },
17571
+ },
17572
+ required: ['query'],
17573
+ additionalProperties: false,
17574
+ },
17575
+ },
17576
+ ];
17577
+ return appendAggregatedUseCommitmentPlaceholder({
17578
+ ...requirements,
17579
+ tools: updatedTools,
17580
+ _metadata: {
17581
+ ...requirements._metadata,
17582
+ useDeepSearch: content || true,
17583
+ },
17584
+ }, this.type);
17585
+ }
17586
+ /**
17587
+ * Gets human-readable titles for tool functions provided by this commitment.
17588
+ */
17589
+ getToolTitles() {
17590
+ return {
17591
+ deep_search: 'DeepSearch',
17592
+ };
17593
+ }
17594
+ /**
17595
+ * Gets the local fallback implementation for the `deep_search` tool.
17596
+ */
17597
+ getToolFunctions() {
17598
+ return {
17599
+ deep_search: createSerpSearchToolFunction('deep_search', 'DeepSearch'),
17600
+ };
17601
+ }
17602
+ }
17603
+ // Note: [💞] Ignore a discrepancy between file name and entity name
17604
+
17392
17605
  /**
17393
17606
  * Lightweight email token matcher used for `USE EMAIL` first-line parsing.
17394
17607
  *
@@ -19776,49 +19989,6 @@ function addConfiguredProjectIfMissing(configuredProjects, repositoryReference)
19776
19989
  }
19777
19990
  // Note: [💞] Ignore a discrepancy between file name and entity name
19778
19991
 
19779
- /**
19780
- * A search engine implementation that uses the SerpApi to fetch Google search results.
19781
- *
19782
- * @private <- TODO: !!!! Export via some package
19783
- */
19784
- class SerpSearchEngine {
19785
- get title() {
19786
- return 'SerpApi Search Engine';
19787
- }
19788
- get description() {
19789
- return 'Search engine that uses SerpApi to fetch Google search results';
19790
- }
19791
- checkConfiguration() {
19792
- if (!process.env.SERP_API_KEY) {
19793
- throw new Error('SERP_API_KEY is not configured');
19794
- }
19795
- }
19796
- async search(query, options = {}) {
19797
- const apiKey = process.env.SERP_API_KEY;
19798
- if (!apiKey) {
19799
- throw new Error('SERP_API_KEY is not configured');
19800
- }
19801
- const url = new URL('https://serpapi.com/search');
19802
- url.searchParams.set('api_key', apiKey);
19803
- url.searchParams.set('engine', 'google');
19804
- url.searchParams.set('q', query);
19805
- for (const [key, value] of Object.entries(options)) {
19806
- url.searchParams.set(key, String(value));
19807
- }
19808
- const response = await fetch(url.toString());
19809
- if (!response.ok) {
19810
- const body = await response.text();
19811
- throw new Error(`SerpApi failed with status ${response.status}: ${response.statusText}\n${body}`);
19812
- }
19813
- const data = (await response.json());
19814
- return (data.organic_results || []).map((item) => ({
19815
- title: item.title,
19816
- url: item.link,
19817
- snippet: item.snippet || '',
19818
- }));
19819
- }
19820
- }
19821
-
19822
19992
  /**
19823
19993
  * USE SEARCH ENGINE commitment definition
19824
19994
  *
@@ -19962,26 +20132,7 @@ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
19962
20132
  */
19963
20133
  getToolFunctions() {
19964
20134
  return {
19965
- async web_search(args) {
19966
- console.log('!!!! [Tool] web_search called', { args });
19967
- const { query, ...options } = args;
19968
- if (!query) {
19969
- throw new Error('Search query is required');
19970
- }
19971
- const searchEngine = new SerpSearchEngine();
19972
- const results = await searchEngine.search(query, options);
19973
- return spaceTrim$1((block) => `
19974
- Search results for "${query}"${Object.keys(options).length === 0 ? '' : ` with options ${JSON.stringify(options)}`}:
19975
-
19976
- ${block(results
19977
- .map((result) => spaceTrim$1(`
19978
- - **${result.title}**
19979
- ${result.url}
19980
- ${result.snippet}
19981
- `))
19982
- .join('\n\n'))}
19983
- `);
19984
- },
20135
+ web_search: createSerpSearchToolFunction('web_search', 'Search'),
19985
20136
  };
19986
20137
  }
19987
20138
  }
@@ -21627,6 +21778,7 @@ const COMMITMENT_REGISTRY = [
21627
21778
  new ClosedCommitmentDefinition(),
21628
21779
  new TeamCommitmentDefinition(),
21629
21780
  new UseBrowserCommitmentDefinition(),
21781
+ new UseDeepSearchCommitmentDefinition(),
21630
21782
  new UseSearchEngineCommitmentDefinition(),
21631
21783
  new UseSpawnCommitmentDefinition(),
21632
21784
  new UseTimeoutCommitmentDefinition(),
@@ -22796,6 +22948,11 @@ const SIMPLE_CAPABILITY_BY_COMMITMENT_TYPE = {
22796
22948
  label: 'Internet',
22797
22949
  iconName: 'Search',
22798
22950
  },
22951
+ 'USE DEEPSEARCH': {
22952
+ type: 'search-engine',
22953
+ label: 'DeepSearch',
22954
+ iconName: 'Search',
22955
+ },
22799
22956
  'USE TIME': {
22800
22957
  type: 'time',
22801
22958
  label: 'Time',
@@ -32845,6 +33002,14 @@ class OpenAiVectorStoreHandler extends OpenAiExecutionTools {
32845
33002
  * Constant for default agent kit model name.
32846
33003
  */
32847
33004
  const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5.4-mini';
33005
+ /**
33006
+ * Default model used for nested DeepSearch tool invocations.
33007
+ */
33008
+ const DEFAULT_DEEP_SEARCH_MODEL_NAME = 'o4-mini-deep-research';
33009
+ /**
33010
+ * Tool name used by the Book commitment-backed DeepSearch capability.
33011
+ */
33012
+ const DEEP_SEARCH_TOOL_NAME = 'deep_search';
32848
33013
  /**
32849
33014
  * Creates one structured log entry for streamed tool-call updates.
32850
33015
  *
@@ -32887,6 +33052,98 @@ function resolveFinalToolCallState$1(options) {
32887
33052
  }
32888
33053
  return 'COMPLETE';
32889
33054
  }
33055
+ /**
33056
+ * Returns true when one tool definition represents the dedicated DeepSearch capability.
33057
+ *
33058
+ * @param toolDefinition - Tool definition from compiled model requirements.
33059
+ * @returns `true` when the tool should be backed by a nested deep-research agent.
33060
+ *
33061
+ * @private helper of `OpenAiAgentKitExecutionTools`
33062
+ */
33063
+ function isDeepSearchToolDefinition(toolDefinition) {
33064
+ return toolDefinition.name === DEEP_SEARCH_TOOL_NAME;
33065
+ }
33066
+ /**
33067
+ * Normalizes Promptbook JSON-schema tool parameters for AgentKit function tools.
33068
+ *
33069
+ * @param parameters - Promptbook tool parameters.
33070
+ * @returns AgentKit-compatible JSON schema or `undefined`.
33071
+ *
33072
+ * @private helper of `OpenAiAgentKitExecutionTools`
33073
+ */
33074
+ function normalizeAgentKitToolParameters(parameters) {
33075
+ var _a, _b;
33076
+ if (!parameters) {
33077
+ return undefined;
33078
+ }
33079
+ return {
33080
+ ...parameters,
33081
+ additionalProperties: (_a = parameters.additionalProperties) !== null && _a !== void 0 ? _a : false,
33082
+ required: (_b = parameters.required) !== null && _b !== void 0 ? _b : [],
33083
+ };
33084
+ }
33085
+ /**
33086
+ * Creates instructions for the nested DeepSearch specialist agent.
33087
+ *
33088
+ * @param toolDescription - Model-facing description from the original tool definition.
33089
+ * @returns System instructions for the nested deep-research agent.
33090
+ *
33091
+ * @private helper of `OpenAiAgentKitExecutionTools`
33092
+ */
33093
+ function createDeepSearchAgentInstructions(toolDescription) {
33094
+ const normalizedDescription = toolDescription.trim();
33095
+ return spaceTrim$1((block) => `
33096
+ You are a DeepSearch specialist working as a tool for another agent.
33097
+ Perform thorough, source-grounded public-web research based on the provided request.
33098
+ Use web search to gather current information, compare relevant viewpoints, and synthesize a concise research brief.
33099
+ Do not ask follow-up questions. If the request is not specific enough, state the assumptions you had to make.
33100
+ Include citations in the research brief whenever sources were used.
33101
+ ${block(normalizedDescription ? `Tool guidance:\n${normalizedDescription}` : '')}
33102
+ `);
33103
+ }
33104
+ /**
33105
+ * Builds the nested DeepSearch prompt from structured tool arguments.
33106
+ *
33107
+ * @param rawInput - Parsed function-tool arguments provided by the outer agent.
33108
+ * @returns Prompt text passed to the nested deep-research agent.
33109
+ *
33110
+ * @private helper of `OpenAiAgentKitExecutionTools`
33111
+ */
33112
+ function buildDeepSearchToolInput(rawInput) {
33113
+ const input = rawInput && typeof rawInput === 'object' ? rawInput : {};
33114
+ const query = typeof input.query === 'string' ? input.query.trim() : '';
33115
+ const additionalHints = Object.entries(input)
33116
+ .filter(([key, value]) => key !== 'query' && value !== undefined && value !== null && String(value).trim() !== '')
33117
+ .map(([key, value]) => `- ${key}: ${typeof value === 'string' ? value : JSON.stringify(value)}`);
33118
+ return spaceTrim$1((block) => `
33119
+ Research request:
33120
+ ${query || JSON.stringify(input)}
33121
+ ${block(additionalHints.length > 0 ? `Execution hints:\n${additionalHints.join('\n')}` : '')}
33122
+ `);
33123
+ }
33124
+ /**
33125
+ * Creates the native Agent SDK tool used for `USE DEEPSEARCH`.
33126
+ *
33127
+ * @param toolDefinition - Promptbook tool definition for `deep_search`.
33128
+ * @returns AgentKit tool backed by a nested deep-research agent.
33129
+ *
33130
+ * @private helper of `OpenAiAgentKitExecutionTools`
33131
+ */
33132
+ function createDeepSearchAgentKitTool(toolDefinition) {
33133
+ const deepSearchAgent = new Agent$1({
33134
+ name: 'DeepSearch',
33135
+ model: DEFAULT_DEEP_SEARCH_MODEL_NAME,
33136
+ instructions: createDeepSearchAgentInstructions(toolDefinition.description),
33137
+ tools: [webSearchTool({ searchContextSize: 'high' })],
33138
+ });
33139
+ return deepSearchAgent.asTool({
33140
+ toolName: toolDefinition.name,
33141
+ toolDescription: toolDefinition.description,
33142
+ parameters: normalizeAgentKitToolParameters(toolDefinition.parameters),
33143
+ inputBuilder: ({ params }) => buildDeepSearchToolInput(params),
33144
+ customOutputExtractor: (result) => { var _a; return typeof result.finalOutput === 'string' ? result.finalOutput : JSON.stringify((_a = result.finalOutput) !== null && _a !== void 0 ? _a : ''); },
33145
+ });
33146
+ }
32890
33147
  /**
32891
33148
  * Constant for default JSON schema name.
32892
33149
  */
@@ -33227,25 +33484,23 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
33227
33484
  * Builds the tool list for AgentKit, including hosted file search when applicable.
33228
33485
  */
33229
33486
  buildAgentKitTools(options) {
33230
- var _a;
33231
33487
  const { tools, vectorStoreId } = options;
33232
33488
  const agentKitTools = [];
33233
33489
  if (vectorStoreId) {
33234
33490
  agentKitTools.push(fileSearchTool(vectorStoreId));
33235
33491
  }
33236
33492
  if (tools && tools.length > 0) {
33237
- const scriptTools = this.resolveScriptTools();
33493
+ let scriptTools = null;
33238
33494
  for (const toolDefinition of tools) {
33495
+ if (isDeepSearchToolDefinition(toolDefinition)) {
33496
+ agentKitTools.push(createDeepSearchAgentKitTool(toolDefinition));
33497
+ continue;
33498
+ }
33499
+ scriptTools !== null && scriptTools !== void 0 ? scriptTools : (scriptTools = this.resolveScriptTools());
33239
33500
  agentKitTools.push(tool({
33240
33501
  name: toolDefinition.name,
33241
33502
  description: toolDefinition.description,
33242
- parameters: toolDefinition.parameters
33243
- ? {
33244
- ...toolDefinition.parameters,
33245
- additionalProperties: false,
33246
- required: (_a = toolDefinition.parameters.required) !== null && _a !== void 0 ? _a : [],
33247
- }
33248
- : undefined,
33503
+ parameters: normalizeAgentKitToolParameters(toolDefinition.parameters),
33249
33504
  strict: false,
33250
33505
  execute: async (input, runContext, details) => {
33251
33506
  var _a, _b, _c, _d;