@promptbook/remote-server 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/esm/index.es.js CHANGED
@@ -22,7 +22,7 @@ import moment from 'moment';
22
22
  import { lookup, extension } from 'mime-types';
23
23
  import sha256 from 'crypto-js/sha256';
24
24
  import { parse, unparse } from 'papaparse';
25
- import { Agent as Agent$1, setDefaultOpenAIClient, setDefaultOpenAIKey, fileSearchTool, tool, run } from '@openai/agents';
25
+ import { Agent as Agent$1, setDefaultOpenAIClient, setDefaultOpenAIKey, fileSearchTool, tool, run, webSearchTool } from '@openai/agents';
26
26
  import Bottleneck from 'bottleneck';
27
27
  import OpenAI from 'openai';
28
28
 
@@ -40,7 +40,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
40
40
  * @generated
41
41
  * @see https://github.com/webgptorg/promptbook
42
42
  */
43
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-47';
43
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-49';
44
44
  /**
45
45
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
46
46
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -16424,6 +16424,7 @@ class TemplateCommitmentDefinition extends BaseCommitmentDefinition {
16424
16424
  * Supported USE types:
16425
16425
  * - USE BROWSER: Enables the agent to use a web browser tool
16426
16426
  * - USE SEARCH ENGINE (future): Enables search engine access
16427
+ * - USE DEEPSEARCH: Enables deeper research-oriented search access
16427
16428
  * - USE FILE SYSTEM (future): Enables file system operations
16428
16429
  * - USE MCP (future): Enables MCP server connections
16429
16430
  *
@@ -16446,7 +16447,7 @@ class UseCommitmentDefinition extends BaseCommitmentDefinition {
16446
16447
  * Short one-line description of USE commitments.
16447
16448
  */
16448
16449
  get description() {
16449
- return 'Enable the agent to use specific tools or capabilities (BROWSER, SEARCH ENGINE, etc.).';
16450
+ return 'Enable the agent to use specific tools or capabilities (BROWSER, SEARCH ENGINE, DEEPSEARCH, etc.).';
16450
16451
  }
16451
16452
  /**
16452
16453
  * Icon for this commitment.
@@ -16467,6 +16468,7 @@ class UseCommitmentDefinition extends BaseCommitmentDefinition {
16467
16468
 
16468
16469
  - **USE BROWSER** - Enables the agent to use a web browser tool to access and retrieve information from the internet
16469
16470
  - **USE SEARCH ENGINE** (future) - Enables search engine access
16471
+ - **USE DEEPSEARCH** - Enables deeper research-oriented search access
16470
16472
  - **USE FILE SYSTEM** (future) - Enables file system operations
16471
16473
  - **USE MCP** (future) - Enables MCP server connections
16472
16474
 
@@ -16521,7 +16523,7 @@ class UseCommitmentDefinition extends BaseCommitmentDefinition {
16521
16523
  * Checks if this is a known USE type
16522
16524
  */
16523
16525
  isKnownUseType(useType) {
16524
- const knownTypes = ['BROWSER', 'SEARCH ENGINE', 'FILE SYSTEM', 'MCP'];
16526
+ const knownTypes = ['BROWSER', 'SEARCH ENGINE', 'DEEPSEARCH', 'FILE SYSTEM', 'MCP'];
16525
16527
  return knownTypes.includes(useType.toUpperCase());
16526
16528
  }
16527
16529
  }
@@ -16534,6 +16536,7 @@ class UseCommitmentDefinition extends BaseCommitmentDefinition {
16534
16536
  */
16535
16537
  const AGGREGATED_USE_COMMITMENT_TYPES = [
16536
16538
  'USE BROWSER',
16539
+ 'USE DEEPSEARCH',
16537
16540
  'USE SEARCH ENGINE',
16538
16541
  'USE TIME',
16539
16542
  ];
@@ -16613,6 +16616,15 @@ function createAggregatedUseCommitmentSystemMessage(type, additionalInstructions
16613
16616
  - Do not tell the user you cannot search for information, YOU CAN.
16614
16617
  ${block(formatOptionalInstructionBlock('Search instructions', combinedAdditionalInstructions))}
16615
16618
  `);
16619
+ case 'USE DEEPSEARCH':
16620
+ return spaceTrim$1((block) => `
16621
+ Tool:
16622
+ - You have access to DeepSearch via the tool "deep_search".
16623
+ - Use it for broader research tasks that need multi-step investigation, comparison, or synthesis across multiple sources.
16624
+ - Prefer it over quick search when the user asks for a well-grounded brief, report, or deeper investigation.
16625
+ - Do not pretend you cannot research current information when this tool is available.
16626
+ ${block(formatOptionalInstructionBlock('DeepSearch instructions', combinedAdditionalInstructions))}
16627
+ `);
16616
16628
  }
16617
16629
  }
16618
16630
  /**
@@ -18162,6 +18174,207 @@ function addConfiguredCalendarIfMissing(configuredCalendars, calendarReference)
18162
18174
  }
18163
18175
  // Note: [💞] Ignore a discrepancy between file name and entity name
18164
18176
 
18177
+ /**
18178
+ * A search engine implementation that uses the SerpApi to fetch Google search results.
18179
+ *
18180
+ * @private <- TODO: !!!! Export via some package
18181
+ */
18182
+ class SerpSearchEngine {
18183
+ get title() {
18184
+ return 'SerpApi Search Engine';
18185
+ }
18186
+ get description() {
18187
+ return 'Search engine that uses SerpApi to fetch Google search results';
18188
+ }
18189
+ checkConfiguration() {
18190
+ if (!process.env.SERP_API_KEY) {
18191
+ throw new Error('SERP_API_KEY is not configured');
18192
+ }
18193
+ }
18194
+ async search(query, options = {}) {
18195
+ const apiKey = process.env.SERP_API_KEY;
18196
+ if (!apiKey) {
18197
+ throw new Error('SERP_API_KEY is not configured');
18198
+ }
18199
+ const url = new URL('https://serpapi.com/search');
18200
+ url.searchParams.set('api_key', apiKey);
18201
+ url.searchParams.set('engine', 'google');
18202
+ url.searchParams.set('q', query);
18203
+ for (const [key, value] of Object.entries(options)) {
18204
+ url.searchParams.set(key, String(value));
18205
+ }
18206
+ const response = await fetch(url.toString());
18207
+ if (!response.ok) {
18208
+ const body = await response.text();
18209
+ throw new Error(`SerpApi failed with status ${response.status}: ${response.statusText}\n${body}`);
18210
+ }
18211
+ const data = (await response.json());
18212
+ return (data.organic_results || []).map((item) => ({
18213
+ title: item.title,
18214
+ url: item.link,
18215
+ snippet: item.snippet || '',
18216
+ }));
18217
+ }
18218
+ }
18219
+
18220
+ /**
18221
+ * Creates one SERP-backed tool function used as a local fallback for search-like commitments.
18222
+ *
18223
+ * @param toolName - Technical tool name used for validation messages.
18224
+ * @param resultLabel - Human-readable label used in formatted results.
18225
+ * @returns Async tool function compatible with commitment tool registration.
18226
+ *
18227
+ * @private internal helper for search-like commitments
18228
+ */
18229
+ function createSerpSearchToolFunction(toolName, resultLabel) {
18230
+ return async (rawArgs) => {
18231
+ const { query, ...searchOptions } = rawArgs;
18232
+ if (typeof query !== 'string' || !query.trim()) {
18233
+ throw new Error(`${toolName} query is required`);
18234
+ }
18235
+ const searchEngine = new SerpSearchEngine();
18236
+ const results = await searchEngine.search(query, searchOptions);
18237
+ return spaceTrim$1((block) => `
18238
+ ${resultLabel} results for "${query}"${Object.keys(searchOptions).length === 0
18239
+ ? ''
18240
+ : ` with options ${JSON.stringify(searchOptions)}`}:
18241
+
18242
+ ${block(results
18243
+ .map((result) => spaceTrim$1(`
18244
+ - **${result.title}**
18245
+ ${result.url}
18246
+ ${result.snippet}
18247
+ `))
18248
+ .join('\n\n'))}
18249
+ `);
18250
+ };
18251
+ }
18252
+
18253
+ /**
18254
+ * USE DEEPSEARCH commitment definition
18255
+ *
18256
+ * The `USE DEEPSEARCH` commitment indicates that the agent should use a deeper research-oriented
18257
+ * search workflow instead of lightweight web search when it needs fresh information from the internet.
18258
+ *
18259
+ * The content following `USE DEEPSEARCH` is an arbitrary text that the agent should know
18260
+ * (e.g. search scope or research instructions).
18261
+ *
18262
+ * Example usage in agent source:
18263
+ *
18264
+ * ```book
18265
+ * USE DEEPSEARCH
18266
+ * USE DEEPSEARCH Compare official vendor documentation with independent benchmarks.
18267
+ * ```
18268
+ *
18269
+ * @private [🪔] Maybe export the commitments through some package
18270
+ */
18271
+ class UseDeepSearchCommitmentDefinition extends BaseCommitmentDefinition {
18272
+ constructor() {
18273
+ super('USE DEEPSEARCH');
18274
+ }
18275
+ get requiresContent() {
18276
+ return false;
18277
+ }
18278
+ /**
18279
+ * Short one-line description of USE DEEPSEARCH.
18280
+ */
18281
+ get description() {
18282
+ return 'Enable the agent to use DeepSearch for more thorough internet research.';
18283
+ }
18284
+ /**
18285
+ * Icon for this commitment.
18286
+ */
18287
+ get icon() {
18288
+ return '🔬';
18289
+ }
18290
+ /**
18291
+ * Markdown documentation for USE DEEPSEARCH commitment.
18292
+ */
18293
+ get documentation() {
18294
+ return spaceTrim$1(`
18295
+ # USE DEEPSEARCH
18296
+
18297
+ Enables the agent to use DeepSearch for broader, more thorough internet research than lightweight web search.
18298
+
18299
+ ## Key aspects
18300
+
18301
+ - The content following \`USE DEEPSEARCH\` is arbitrary guidance for the research workflow.
18302
+ - In Agents Server, the OpenAI Agents SDK runtime uses a nested deep-research agent for this tool.
18303
+ - Use this for investigations, comparisons, market scans, or other tasks that benefit from deeper synthesis.
18304
+ - Prefer regular \`USE SEARCH ENGINE\` when a quick factual lookup is enough.
18305
+
18306
+ ## Examples
18307
+
18308
+ \`\`\`book
18309
+ Due Diligence Researcher
18310
+
18311
+ GOAL Investigate vendors thoroughly before making recommendations.
18312
+ USE DEEPSEARCH Compare official sources with credible third-party analysis.
18313
+ RULE Cite the strongest supporting sources in the final answer.
18314
+ \`\`\`
18315
+
18316
+ \`\`\`book
18317
+ Market Analyst
18318
+
18319
+ GOAL Build concise but well-grounded research briefs.
18320
+ USE DEEPSEARCH Focus on recent public information and competing viewpoints.
18321
+ CLOSED
18322
+ \`\`\`
18323
+ `);
18324
+ }
18325
+ applyToAgentModelRequirements(requirements, content) {
18326
+ const existingTools = requirements.tools || [];
18327
+ const updatedTools = existingTools.some((tool) => tool.name === 'deep_search')
18328
+ ? existingTools
18329
+ : [
18330
+ ...existingTools,
18331
+ {
18332
+ name: 'deep_search',
18333
+ description: spaceTrim$1(`
18334
+ Research the internet deeply and synthesize a grounded answer.
18335
+ Use this tool for broader investigations, comparisons, and requests that need more than a quick search.
18336
+ `),
18337
+ parameters: {
18338
+ type: 'object',
18339
+ properties: {
18340
+ query: {
18341
+ type: 'string',
18342
+ description: 'The research question or investigation request.',
18343
+ },
18344
+ },
18345
+ required: ['query'],
18346
+ additionalProperties: false,
18347
+ },
18348
+ },
18349
+ ];
18350
+ return appendAggregatedUseCommitmentPlaceholder({
18351
+ ...requirements,
18352
+ tools: updatedTools,
18353
+ _metadata: {
18354
+ ...requirements._metadata,
18355
+ useDeepSearch: content || true,
18356
+ },
18357
+ }, this.type);
18358
+ }
18359
+ /**
18360
+ * Gets human-readable titles for tool functions provided by this commitment.
18361
+ */
18362
+ getToolTitles() {
18363
+ return {
18364
+ deep_search: 'DeepSearch',
18365
+ };
18366
+ }
18367
+ /**
18368
+ * Gets the local fallback implementation for the `deep_search` tool.
18369
+ */
18370
+ getToolFunctions() {
18371
+ return {
18372
+ deep_search: createSerpSearchToolFunction('deep_search', 'DeepSearch'),
18373
+ };
18374
+ }
18375
+ }
18376
+ // Note: [💞] Ignore a discrepancy between file name and entity name
18377
+
18165
18378
  /**
18166
18379
  * Lightweight email token matcher used for `USE EMAIL` first-line parsing.
18167
18380
  *
@@ -20549,49 +20762,6 @@ function addConfiguredProjectIfMissing(configuredProjects, repositoryReference)
20549
20762
  }
20550
20763
  // Note: [💞] Ignore a discrepancy between file name and entity name
20551
20764
 
20552
- /**
20553
- * A search engine implementation that uses the SerpApi to fetch Google search results.
20554
- *
20555
- * @private <- TODO: !!!! Export via some package
20556
- */
20557
- class SerpSearchEngine {
20558
- get title() {
20559
- return 'SerpApi Search Engine';
20560
- }
20561
- get description() {
20562
- return 'Search engine that uses SerpApi to fetch Google search results';
20563
- }
20564
- checkConfiguration() {
20565
- if (!process.env.SERP_API_KEY) {
20566
- throw new Error('SERP_API_KEY is not configured');
20567
- }
20568
- }
20569
- async search(query, options = {}) {
20570
- const apiKey = process.env.SERP_API_KEY;
20571
- if (!apiKey) {
20572
- throw new Error('SERP_API_KEY is not configured');
20573
- }
20574
- const url = new URL('https://serpapi.com/search');
20575
- url.searchParams.set('api_key', apiKey);
20576
- url.searchParams.set('engine', 'google');
20577
- url.searchParams.set('q', query);
20578
- for (const [key, value] of Object.entries(options)) {
20579
- url.searchParams.set(key, String(value));
20580
- }
20581
- const response = await fetch(url.toString());
20582
- if (!response.ok) {
20583
- const body = await response.text();
20584
- throw new Error(`SerpApi failed with status ${response.status}: ${response.statusText}\n${body}`);
20585
- }
20586
- const data = (await response.json());
20587
- return (data.organic_results || []).map((item) => ({
20588
- title: item.title,
20589
- url: item.link,
20590
- snippet: item.snippet || '',
20591
- }));
20592
- }
20593
- }
20594
-
20595
20765
  /**
20596
20766
  * USE SEARCH ENGINE commitment definition
20597
20767
  *
@@ -20735,26 +20905,7 @@ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
20735
20905
  */
20736
20906
  getToolFunctions() {
20737
20907
  return {
20738
- async web_search(args) {
20739
- console.log('!!!! [Tool] web_search called', { args });
20740
- const { query, ...options } = args;
20741
- if (!query) {
20742
- throw new Error('Search query is required');
20743
- }
20744
- const searchEngine = new SerpSearchEngine();
20745
- const results = await searchEngine.search(query, options);
20746
- return spaceTrim$1((block) => `
20747
- Search results for "${query}"${Object.keys(options).length === 0 ? '' : ` with options ${JSON.stringify(options)}`}:
20748
-
20749
- ${block(results
20750
- .map((result) => spaceTrim$1(`
20751
- - **${result.title}**
20752
- ${result.url}
20753
- ${result.snippet}
20754
- `))
20755
- .join('\n\n'))}
20756
- `);
20757
- },
20908
+ web_search: createSerpSearchToolFunction('web_search', 'Search'),
20758
20909
  };
20759
20910
  }
20760
20911
  }
@@ -22400,6 +22551,7 @@ const COMMITMENT_REGISTRY = [
22400
22551
  new ClosedCommitmentDefinition(),
22401
22552
  new TeamCommitmentDefinition(),
22402
22553
  new UseBrowserCommitmentDefinition(),
22554
+ new UseDeepSearchCommitmentDefinition(),
22403
22555
  new UseSearchEngineCommitmentDefinition(),
22404
22556
  new UseSpawnCommitmentDefinition(),
22405
22557
  new UseTimeoutCommitmentDefinition(),
@@ -25134,6 +25286,11 @@ const SIMPLE_CAPABILITY_BY_COMMITMENT_TYPE = {
25134
25286
  label: 'Internet',
25135
25287
  iconName: 'Search',
25136
25288
  },
25289
+ 'USE DEEPSEARCH': {
25290
+ type: 'search-engine',
25291
+ label: 'DeepSearch',
25292
+ iconName: 'Search',
25293
+ },
25137
25294
  'USE TIME': {
25138
25295
  type: 'time',
25139
25296
  label: 'Time',
@@ -30379,6 +30536,14 @@ class OpenAiVectorStoreHandler extends OpenAiExecutionTools {
30379
30536
  * Constant for default agent kit model name.
30380
30537
  */
30381
30538
  const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5.4-mini';
30539
+ /**
30540
+ * Default model used for nested DeepSearch tool invocations.
30541
+ */
30542
+ const DEFAULT_DEEP_SEARCH_MODEL_NAME = 'o4-mini-deep-research';
30543
+ /**
30544
+ * Tool name used by the Book commitment-backed DeepSearch capability.
30545
+ */
30546
+ const DEEP_SEARCH_TOOL_NAME = 'deep_search';
30382
30547
  /**
30383
30548
  * Creates one structured log entry for streamed tool-call updates.
30384
30549
  *
@@ -30421,6 +30586,98 @@ function resolveFinalToolCallState$1(options) {
30421
30586
  }
30422
30587
  return 'COMPLETE';
30423
30588
  }
30589
+ /**
30590
+ * Returns true when one tool definition represents the dedicated DeepSearch capability.
30591
+ *
30592
+ * @param toolDefinition - Tool definition from compiled model requirements.
30593
+ * @returns `true` when the tool should be backed by a nested deep-research agent.
30594
+ *
30595
+ * @private helper of `OpenAiAgentKitExecutionTools`
30596
+ */
30597
+ function isDeepSearchToolDefinition(toolDefinition) {
30598
+ return toolDefinition.name === DEEP_SEARCH_TOOL_NAME;
30599
+ }
30600
+ /**
30601
+ * Normalizes Promptbook JSON-schema tool parameters for AgentKit function tools.
30602
+ *
30603
+ * @param parameters - Promptbook tool parameters.
30604
+ * @returns AgentKit-compatible JSON schema or `undefined`.
30605
+ *
30606
+ * @private helper of `OpenAiAgentKitExecutionTools`
30607
+ */
30608
+ function normalizeAgentKitToolParameters(parameters) {
30609
+ var _a, _b;
30610
+ if (!parameters) {
30611
+ return undefined;
30612
+ }
30613
+ return {
30614
+ ...parameters,
30615
+ additionalProperties: (_a = parameters.additionalProperties) !== null && _a !== void 0 ? _a : false,
30616
+ required: (_b = parameters.required) !== null && _b !== void 0 ? _b : [],
30617
+ };
30618
+ }
30619
+ /**
30620
+ * Creates instructions for the nested DeepSearch specialist agent.
30621
+ *
30622
+ * @param toolDescription - Model-facing description from the original tool definition.
30623
+ * @returns System instructions for the nested deep-research agent.
30624
+ *
30625
+ * @private helper of `OpenAiAgentKitExecutionTools`
30626
+ */
30627
+ function createDeepSearchAgentInstructions(toolDescription) {
30628
+ const normalizedDescription = toolDescription.trim();
30629
+ return spaceTrim$1((block) => `
30630
+ You are a DeepSearch specialist working as a tool for another agent.
30631
+ Perform thorough, source-grounded public-web research based on the provided request.
30632
+ Use web search to gather current information, compare relevant viewpoints, and synthesize a concise research brief.
30633
+ Do not ask follow-up questions. If the request is not specific enough, state the assumptions you had to make.
30634
+ Include citations in the research brief whenever sources were used.
30635
+ ${block(normalizedDescription ? `Tool guidance:\n${normalizedDescription}` : '')}
30636
+ `);
30637
+ }
30638
+ /**
30639
+ * Builds the nested DeepSearch prompt from structured tool arguments.
30640
+ *
30641
+ * @param rawInput - Parsed function-tool arguments provided by the outer agent.
30642
+ * @returns Prompt text passed to the nested deep-research agent.
30643
+ *
30644
+ * @private helper of `OpenAiAgentKitExecutionTools`
30645
+ */
30646
+ function buildDeepSearchToolInput(rawInput) {
30647
+ const input = rawInput && typeof rawInput === 'object' ? rawInput : {};
30648
+ const query = typeof input.query === 'string' ? input.query.trim() : '';
30649
+ const additionalHints = Object.entries(input)
30650
+ .filter(([key, value]) => key !== 'query' && value !== undefined && value !== null && String(value).trim() !== '')
30651
+ .map(([key, value]) => `- ${key}: ${typeof value === 'string' ? value : JSON.stringify(value)}`);
30652
+ return spaceTrim$1((block) => `
30653
+ Research request:
30654
+ ${query || JSON.stringify(input)}
30655
+ ${block(additionalHints.length > 0 ? `Execution hints:\n${additionalHints.join('\n')}` : '')}
30656
+ `);
30657
+ }
30658
+ /**
30659
+ * Creates the native Agent SDK tool used for `USE DEEPSEARCH`.
30660
+ *
30661
+ * @param toolDefinition - Promptbook tool definition for `deep_search`.
30662
+ * @returns AgentKit tool backed by a nested deep-research agent.
30663
+ *
30664
+ * @private helper of `OpenAiAgentKitExecutionTools`
30665
+ */
30666
+ function createDeepSearchAgentKitTool(toolDefinition) {
30667
+ const deepSearchAgent = new Agent$1({
30668
+ name: 'DeepSearch',
30669
+ model: DEFAULT_DEEP_SEARCH_MODEL_NAME,
30670
+ instructions: createDeepSearchAgentInstructions(toolDefinition.description),
30671
+ tools: [webSearchTool({ searchContextSize: 'high' })],
30672
+ });
30673
+ return deepSearchAgent.asTool({
30674
+ toolName: toolDefinition.name,
30675
+ toolDescription: toolDefinition.description,
30676
+ parameters: normalizeAgentKitToolParameters(toolDefinition.parameters),
30677
+ inputBuilder: ({ params }) => buildDeepSearchToolInput(params),
30678
+ customOutputExtractor: (result) => { var _a; return typeof result.finalOutput === 'string' ? result.finalOutput : JSON.stringify((_a = result.finalOutput) !== null && _a !== void 0 ? _a : ''); },
30679
+ });
30680
+ }
30424
30681
  /**
30425
30682
  * Constant for default JSON schema name.
30426
30683
  */
@@ -30761,25 +31018,23 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
30761
31018
  * Builds the tool list for AgentKit, including hosted file search when applicable.
30762
31019
  */
30763
31020
  buildAgentKitTools(options) {
30764
- var _a;
30765
31021
  const { tools, vectorStoreId } = options;
30766
31022
  const agentKitTools = [];
30767
31023
  if (vectorStoreId) {
30768
31024
  agentKitTools.push(fileSearchTool(vectorStoreId));
30769
31025
  }
30770
31026
  if (tools && tools.length > 0) {
30771
- const scriptTools = this.resolveScriptTools();
31027
+ let scriptTools = null;
30772
31028
  for (const toolDefinition of tools) {
31029
+ if (isDeepSearchToolDefinition(toolDefinition)) {
31030
+ agentKitTools.push(createDeepSearchAgentKitTool(toolDefinition));
31031
+ continue;
31032
+ }
31033
+ scriptTools !== null && scriptTools !== void 0 ? scriptTools : (scriptTools = this.resolveScriptTools());
30773
31034
  agentKitTools.push(tool({
30774
31035
  name: toolDefinition.name,
30775
31036
  description: toolDefinition.description,
30776
- parameters: toolDefinition.parameters
30777
- ? {
30778
- ...toolDefinition.parameters,
30779
- additionalProperties: false,
30780
- required: (_a = toolDefinition.parameters.required) !== null && _a !== void 0 ? _a : [],
30781
- }
30782
- : undefined,
31037
+ parameters: normalizeAgentKitToolParameters(toolDefinition.parameters),
30783
31038
  strict: false,
30784
31039
  execute: async (input, runContext, details) => {
30785
31040
  var _a, _b, _c, _d;