@promptbook/node 0.110.0-4 → 0.110.0-7

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 (23) hide show
  1. package/esm/index.es.js +1226 -412
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/openai.index.d.ts +8 -4
  4. package/esm/typings/src/_packages/types.index.d.ts +4 -2
  5. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +0 -3
  6. package/esm/typings/src/execution/LlmExecutionTools.d.ts +2 -1
  7. package/esm/typings/src/llm-providers/agent/Agent.d.ts +1 -1
  8. package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +5 -1
  9. package/esm/typings/src/llm-providers/agent/AgentOptions.d.ts +4 -3
  10. package/esm/typings/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +7 -5
  11. package/esm/typings/src/llm-providers/agent/RemoteAgent.d.ts +2 -1
  12. package/esm/typings/src/llm-providers/openai/OpenAiAgentKitExecutionTools.d.ts +111 -0
  13. package/esm/typings/src/llm-providers/openai/OpenAiAgentKitExecutionToolsOptions.d.ts +15 -0
  14. package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +3 -3
  15. package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionToolsOptions.d.ts +2 -3
  16. package/esm/typings/src/llm-providers/openai/OpenAiVectorStoreHandler.d.ts +135 -0
  17. package/esm/typings/src/llm-providers/openai/utils/mapToolsToOpenAi.d.ts +1 -1
  18. package/esm/typings/src/version.d.ts +1 -1
  19. package/package.json +7 -3
  20. package/umd/index.umd.js +1229 -416
  21. package/umd/index.umd.js.map +1 -1
  22. package/esm/typings/src/llm-providers/openai/OpenAiAgentExecutionTools.d.ts +0 -43
  23. package/esm/typings/src/llm-providers/openai/createOpenAiAgentExecutionTools.d.ts +0 -11
@@ -1,10 +1,10 @@
1
1
  import { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION } from '../version';
2
- import { createOpenAiAgentExecutionTools } from '../llm-providers/openai/createOpenAiAgentExecutionTools';
3
2
  import { createOpenAiAssistantExecutionTools } from '../llm-providers/openai/createOpenAiAssistantExecutionTools';
4
3
  import { createOpenAiCompatibleExecutionTools } from '../llm-providers/openai/createOpenAiCompatibleExecutionTools';
5
4
  import { createOpenAiExecutionTools } from '../llm-providers/openai/createOpenAiExecutionTools';
6
5
  import { OPENAI_MODELS } from '../llm-providers/openai/openai-models';
7
- import { OpenAiAgentExecutionTools } from '../llm-providers/openai/OpenAiAgentExecutionTools';
6
+ import { OpenAiAgentKitExecutionTools } from '../llm-providers/openai/OpenAiAgentKitExecutionTools';
7
+ import type { OpenAiAgentKitExecutionToolsOptions } from '../llm-providers/openai/OpenAiAgentKitExecutionToolsOptions';
8
8
  import { OpenAiAssistantExecutionTools } from '../llm-providers/openai/OpenAiAssistantExecutionTools';
9
9
  import type { OpenAiAssistantExecutionToolsOptions } from '../llm-providers/openai/OpenAiAssistantExecutionToolsOptions';
10
10
  import { OpenAiCompatibleExecutionTools } from '../llm-providers/openai/OpenAiCompatibleExecutionTools';
@@ -13,16 +13,18 @@ import type { OpenAiCompatibleExecutionToolsNonProxiedOptions } from '../llm-pro
13
13
  import type { OpenAiCompatibleExecutionToolsProxiedOptions } from '../llm-providers/openai/OpenAiCompatibleExecutionToolsOptions';
14
14
  import { OpenAiExecutionTools } from '../llm-providers/openai/OpenAiExecutionTools';
15
15
  import type { OpenAiExecutionToolsOptions } from '../llm-providers/openai/OpenAiExecutionToolsOptions';
16
+ import type { OpenAiVectorStoreHandlerOptions } from '../llm-providers/openai/OpenAiVectorStoreHandler';
17
+ import { OpenAiVectorStoreHandler } from '../llm-providers/openai/OpenAiVectorStoreHandler';
16
18
  import { _OpenAiRegistration } from '../llm-providers/openai/register-constructor';
17
19
  import { _OpenAiAssistantRegistration } from '../llm-providers/openai/register-constructor';
18
20
  import { _OpenAiCompatibleRegistration } from '../llm-providers/openai/register-constructor';
19
21
  export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
20
- export { createOpenAiAgentExecutionTools };
21
22
  export { createOpenAiAssistantExecutionTools };
22
23
  export { createOpenAiCompatibleExecutionTools };
23
24
  export { createOpenAiExecutionTools };
24
25
  export { OPENAI_MODELS };
25
- export { OpenAiAgentExecutionTools };
26
+ export { OpenAiAgentKitExecutionTools };
27
+ export type { OpenAiAgentKitExecutionToolsOptions };
26
28
  export { OpenAiAssistantExecutionTools };
27
29
  export type { OpenAiAssistantExecutionToolsOptions };
28
30
  export { OpenAiCompatibleExecutionTools };
@@ -31,6 +33,8 @@ export type { OpenAiCompatibleExecutionToolsNonProxiedOptions };
31
33
  export type { OpenAiCompatibleExecutionToolsProxiedOptions };
32
34
  export { OpenAiExecutionTools };
33
35
  export type { OpenAiExecutionToolsOptions };
36
+ export type { OpenAiVectorStoreHandlerOptions };
37
+ export { OpenAiVectorStoreHandler };
34
38
  export { _OpenAiRegistration };
35
39
  export { _OpenAiAssistantRegistration };
36
40
  export { _OpenAiCompatibleRegistration };
@@ -138,12 +138,13 @@ import type { AzureOpenAiExecutionToolsOptions } from '../llm-providers/azure-op
138
138
  import type { DeepseekExecutionToolsOptions } from '../llm-providers/deepseek/DeepseekExecutionToolsOptions';
139
139
  import type { GoogleExecutionToolsOptions } from '../llm-providers/google/GoogleExecutionToolsOptions';
140
140
  import type { OllamaExecutionToolsOptions } from '../llm-providers/ollama/OllamaExecutionToolsOptions';
141
- import type { OpenAiAgentExecutionToolsOptions } from '../llm-providers/openai/OpenAiAgentExecutionTools';
141
+ import type { OpenAiAgentKitExecutionToolsOptions } from '../llm-providers/openai/OpenAiAgentKitExecutionToolsOptions';
142
142
  import type { OpenAiAssistantExecutionToolsOptions } from '../llm-providers/openai/OpenAiAssistantExecutionToolsOptions';
143
143
  import type { OpenAiCompatibleExecutionToolsOptions } from '../llm-providers/openai/OpenAiCompatibleExecutionToolsOptions';
144
144
  import type { OpenAiCompatibleExecutionToolsNonProxiedOptions } from '../llm-providers/openai/OpenAiCompatibleExecutionToolsOptions';
145
145
  import type { OpenAiCompatibleExecutionToolsProxiedOptions } from '../llm-providers/openai/OpenAiCompatibleExecutionToolsOptions';
146
146
  import type { OpenAiExecutionToolsOptions } from '../llm-providers/openai/OpenAiExecutionToolsOptions';
147
+ import type { OpenAiVectorStoreHandlerOptions } from '../llm-providers/openai/OpenAiVectorStoreHandler';
147
148
  import type { VercelExecutionToolsOptions } from '../llm-providers/vercel/VercelExecutionToolsOptions';
148
149
  import type { VercelProvider } from '../llm-providers/vercel/VercelProvider';
149
150
  import type { IsPipelineImplementingInterfaceOptions } from '../pipeline/PipelineInterface/isPipelineImplementingInterface';
@@ -540,12 +541,13 @@ export type { AzureOpenAiExecutionToolsOptions };
540
541
  export type { DeepseekExecutionToolsOptions };
541
542
  export type { GoogleExecutionToolsOptions };
542
543
  export type { OllamaExecutionToolsOptions };
543
- export type { OpenAiAgentExecutionToolsOptions };
544
+ export type { OpenAiAgentKitExecutionToolsOptions };
544
545
  export type { OpenAiAssistantExecutionToolsOptions };
545
546
  export type { OpenAiCompatibleExecutionToolsOptions };
546
547
  export type { OpenAiCompatibleExecutionToolsNonProxiedOptions };
547
548
  export type { OpenAiCompatibleExecutionToolsProxiedOptions };
548
549
  export type { OpenAiExecutionToolsOptions };
550
+ export type { OpenAiVectorStoreHandlerOptions };
549
551
  export type { VercelExecutionToolsOptions };
550
552
  export type { VercelProvider };
551
553
  export type { IsPipelineImplementingInterfaceOptions };
@@ -36,7 +36,6 @@ export type AgentsDatabaseSchema = {
36
36
  promptbookEngineVersion: string;
37
37
  usage: Json | null;
38
38
  preparedModelRequirements: Json | null;
39
- preparedExternals: Json | null;
40
39
  folderId: number | null;
41
40
  sortOrder: number;
42
41
  deletedAt: string | null;
@@ -54,7 +53,6 @@ export type AgentsDatabaseSchema = {
54
53
  promptbookEngineVersion: string;
55
54
  usage?: Json | null;
56
55
  preparedModelRequirements?: Json | null;
57
- preparedExternals?: Json | null;
58
56
  folderId?: number | null;
59
57
  sortOrder?: number;
60
58
  deletedAt?: string | null;
@@ -72,7 +70,6 @@ export type AgentsDatabaseSchema = {
72
70
  promptbookEngineVersion?: string;
73
71
  usage?: Json | null;
74
72
  preparedModelRequirements?: Json | null;
75
- preparedExternals?: Json | null;
76
73
  folderId?: number | null;
77
74
  sortOrder?: number;
78
75
  deletedAt?: string | null;
@@ -13,7 +13,8 @@ import type { ChatPromptResult, CompletionPromptResult, EmbeddingPromptResult, I
13
13
  * - `Agent` - which represents an AI Agent with its source, memories, actions, etc. Agent is a higher-level abstraction which is internally using:
14
14
  * - `LlmExecutionTools` - which wraps one or more LLM models and provides an interface to execute them
15
15
  * - `AgentLlmExecutionTools` - which is a specific implementation of `LlmExecutionTools` that wraps another LlmExecutionTools and applies agent-specific system prompts and requirements
16
- * - `OpenAiAssistantExecutionTools` - which is a specific implementation of `LlmExecutionTools` for OpenAI models with assistant capabilities, recommended for usage in `Agent` or `AgentLlmExecutionTools`
16
+ * - `OpenAiAssistantExecutionTools` - (Deprecated) which is a specific implementation of `LlmExecutionTools` for OpenAI models with assistant capabilities
17
+ * - `OpenAiAgentKitExecutionTools` - which is a specific implementation of `LlmExecutionTools` backed by OpenAI AgentKit
17
18
  * - `RemoteAgent` - which is an `Agent` that connects to a Promptbook Agents Server
18
19
  *
19
20
  * @see https://github.com/webgptorg/promptbook#llm-execution-tools
@@ -14,8 +14,8 @@ import type { AgentOptions } from './AgentOptions';
14
14
  * - `Agent` - which represents an AI Agent with its source, memories, actions, etc. Agent is a higher-level abstraction which is internally using:
15
15
  * - `LlmExecutionTools` - which wraps one or more LLM models and provides an interface to execute them
16
16
  * - `AgentLlmExecutionTools` - which is a specific implementation of `LlmExecutionTools` that wraps another LlmExecutionTools and applies agent-specific system prompts and requirements
17
- * - `OpenAiAgentExecutionTools` - which is a specific implementation of `LlmExecutionTools` for OpenAI models with agent capabilities (using Responses API), recommended for usage in `Agent` or `AgentLlmExecutionTools`
18
17
  * - `OpenAiAssistantExecutionTools` - (Deprecated) which is a specific implementation of `LlmExecutionTools` for OpenAI models with assistant capabilities
18
+ * - `OpenAiAgentKitExecutionTools` - which is a specific implementation of `LlmExecutionTools` backed by OpenAI AgentKit
19
19
  * - `RemoteAgent` - which is an `Agent` that connects to a Promptbook Agents Server
20
20
  *
21
21
  * @public exported from `@promptbook/core`
@@ -16,14 +16,18 @@ import type { CreateAgentLlmExecutionToolsOptions } from './CreateAgentLlmExecut
16
16
  * - `Agent` - which represents an AI Agent with its source, memories, actions, etc. Agent is a higher-level abstraction which is internally using:
17
17
  * - `LlmExecutionTools` - which wraps one or more LLM models and provides an interface to execute them
18
18
  * - `AgentLlmExecutionTools` - which is a specific implementation of `LlmExecutionTools` that wraps another LlmExecutionTools and applies agent-specific system prompts and requirements
19
- * - `OpenAiAgentExecutionTools` - which is a specific implementation of `LlmExecutionTools` for OpenAI models with agent capabilities (using Responses API), recommended for usage in `Agent` or `AgentLlmExecutionTools`
20
19
  * - `OpenAiAssistantExecutionTools` - (Deprecated) which is a specific implementation of `LlmExecutionTools` for OpenAI models with assistant capabilities
20
+ * - `OpenAiAgentKitExecutionTools` - which is a specific implementation of `LlmExecutionTools` backed by OpenAI AgentKit
21
21
  * - `RemoteAgent` - which is an `Agent` that connects to a Promptbook Agents Server
22
22
  *
23
23
  * @public exported from `@promptbook/core`
24
24
  */
25
25
  export declare class AgentLlmExecutionTools implements LlmExecutionTools {
26
26
  protected readonly options: CreateAgentLlmExecutionToolsOptions;
27
+ /**
28
+ * Cached AgentKit agents to avoid rebuilding identical instances.
29
+ */
30
+ private static agentKitAgentCache;
27
31
  /**
28
32
  * Cache of OpenAI assistants to avoid creating duplicates
29
33
  */
@@ -14,10 +14,11 @@ export type AgentOptions = CommonToolsOptions & {
14
14
  */
15
15
  executionTools: ExecutionTools;
16
16
  /**
17
- * How to manage OpenAI assistant preparation when using OpenAiAssistantExecutionTools.
17
+ * How to manage OpenAI assistant/AgentKit preparation when using OpenAiAssistantExecutionTools
18
+ * or OpenAiAgentKitExecutionTools.
18
19
  *
19
- * Use `external` when an external cache manager already created the assistant and
20
- * the agent should use it as-is.
20
+ * Use `external` when an external cache manager already created the assistant/AgentKit agent
21
+ * and the agent should use it as-is.
21
22
  *
22
23
  * @default internal
23
24
  */
@@ -1,7 +1,8 @@
1
1
  import type { string_book } from '../../book-2.0/agent-source/string_book';
2
2
  import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
3
3
  import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
4
- import { OpenAiAssistantExecutionTools } from '../openai/OpenAiAssistantExecutionTools';
4
+ import type { OpenAiAgentKitExecutionTools } from '../openai/OpenAiAgentKitExecutionTools';
5
+ import type { OpenAiAssistantExecutionTools } from '../openai/OpenAiAssistantExecutionTools';
5
6
  /**
6
7
  * Options for creating AgentLlmExecutionTools
7
8
  */
@@ -9,12 +10,13 @@ export type CreateAgentLlmExecutionToolsOptions = CommonToolsOptions & {
9
10
  /**
10
11
  * The underlying LLM execution tools to wrap
11
12
  */
12
- llmTools: LlmExecutionTools | OpenAiAssistantExecutionTools;
13
+ llmTools: LlmExecutionTools | OpenAiAssistantExecutionTools | OpenAiAgentKitExecutionTools;
13
14
  /**
14
- * How to manage OpenAI assistant preparation when using OpenAiAssistantExecutionTools.
15
+ * How to manage OpenAI assistant/AgentKit preparation when using OpenAiAssistantExecutionTools
16
+ * or OpenAiAgentKitExecutionTools.
15
17
  *
16
- * Use `external` when an external cache manager already created the assistant and
17
- * the agent should use it as-is.
18
+ * Use `external` when an external cache manager already created the assistant/AgentKit agent
19
+ * and the agent should use it as-is.
18
20
  *
19
21
  * @default internal
20
22
  */
@@ -10,7 +10,8 @@ import type { RemoteAgentOptions } from './RemoteAgentOptions';
10
10
  * - `Agent` - which represents an AI Agent with its source, memories, actions, etc. Agent is a higher-level abstraction which is internally using:
11
11
  * - `LlmExecutionTools` - which wraps one or more LLM models and provides an interface to execute them
12
12
  * - `AgentLlmExecutionTools` - which is a specific implementation of `LlmExecutionTools` that wraps another LlmExecutionTools and applies agent-specific system prompts and requirements
13
- * - `OpenAiAssistantExecutionTools` - which is a specific implementation of `LlmExecutionTools` for OpenAI models with assistant capabilities, recommended for usage in `Agent` or `AgentLlmExecutionTools`
13
+ * - `OpenAiAssistantExecutionTools` - (Deprecated) which is a specific implementation of `LlmExecutionTools` for OpenAI models with assistant capabilities
14
+ * - `OpenAiAgentKitExecutionTools` - which is a specific implementation of `LlmExecutionTools` backed by OpenAI AgentKit
14
15
  * - `RemoteAgent` - which is an `Agent` that connects to a Promptbook Agents Server
15
16
  *
16
17
  * @public exported from `@promptbook/core`
@@ -0,0 +1,111 @@
1
+ import { Agent as AgentFromKit } from '@openai/agents';
2
+ import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
3
+ import type { ChatPromptResult } from '../../execution/PromptResult';
4
+ import type { ModelRequirements } from '../../types/ModelRequirements';
5
+ import type { Prompt } from '../../types/Prompt';
6
+ import type { string_markdown, string_markdown_text, string_title } from '../../types/typeAliases';
7
+ import type { OpenAiAgentKitExecutionToolsOptions } from './OpenAiAgentKitExecutionToolsOptions';
8
+ import { OpenAiVectorStoreHandler } from './OpenAiVectorStoreHandler';
9
+ /**
10
+ * Alias for OpenAI AgentKit agent to avoid naming confusion with Promptbook agents.
11
+ */
12
+ type OpenAiAgentKitAgent = AgentFromKit;
13
+ /**
14
+ * Prepared AgentKit agent details.
15
+ */
16
+ type OpenAiAgentKitPreparedAgent = {
17
+ readonly agent: OpenAiAgentKitAgent;
18
+ readonly vectorStoreId?: string;
19
+ };
20
+ /**
21
+ * Execution tools for OpenAI AgentKit (Agents SDK).
22
+ *
23
+ * @public exported from `@promptbook/openai`
24
+ */
25
+ export declare class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler implements LlmExecutionTools {
26
+ private preparedAgentKitAgent;
27
+ private readonly agentKitModelName;
28
+ /**
29
+ * Creates OpenAI AgentKit execution tools.
30
+ */
31
+ constructor(options: OpenAiAgentKitExecutionToolsOptions);
32
+ get title(): string_title & string_markdown_text;
33
+ get description(): string_markdown;
34
+ /**
35
+ * Calls OpenAI AgentKit with a chat prompt (non-streaming).
36
+ */
37
+ callChatModel(prompt: Prompt): Promise<ChatPromptResult>;
38
+ /**
39
+ * Calls OpenAI AgentKit with a chat prompt (streaming).
40
+ */
41
+ callChatModelStream(prompt: Prompt, onProgress: (chunk: ChatPromptResult) => void): Promise<ChatPromptResult>;
42
+ /**
43
+ * Returns a prepared AgentKit agent when the server wants to manage caching externally.
44
+ */
45
+ getPreparedAgentKitAgent(): OpenAiAgentKitPreparedAgent | null;
46
+ /**
47
+ * Stores a prepared AgentKit agent for later reuse by external cache managers.
48
+ */
49
+ setPreparedAgentKitAgent(preparedAgent: OpenAiAgentKitPreparedAgent): void;
50
+ /**
51
+ * Creates a new tools instance bound to a prepared AgentKit agent.
52
+ */
53
+ getPreparedAgentTools(preparedAgent: OpenAiAgentKitPreparedAgent): OpenAiAgentKitExecutionTools;
54
+ /**
55
+ * Prepares an AgentKit agent with optional knowledge sources and tool definitions.
56
+ */
57
+ prepareAgentKitAgent(options: {
58
+ readonly name: string_title;
59
+ readonly instructions: string_markdown;
60
+ readonly knowledgeSources?: ReadonlyArray<string>;
61
+ readonly tools?: ModelRequirements['tools'];
62
+ readonly vectorStoreId?: string;
63
+ readonly storeAsPrepared?: boolean;
64
+ }): Promise<OpenAiAgentKitPreparedAgent>;
65
+ /**
66
+ * Ensures the AgentKit SDK is wired to the OpenAI client and API key.
67
+ */
68
+ private ensureAgentKitDefaults;
69
+ /**
70
+ * Builds the tool list for AgentKit, including hosted file search when applicable.
71
+ */
72
+ private buildAgentKitTools;
73
+ /**
74
+ * Resolves the configured script tools for tool execution.
75
+ */
76
+ private resolveScriptTools;
77
+ /**
78
+ * Runs a prepared AgentKit agent and streams results back to the caller.
79
+ */
80
+ callChatModelStreamWithPreparedAgent(options: {
81
+ readonly openAiAgentKitAgent: OpenAiAgentKitAgent;
82
+ readonly prompt: Prompt;
83
+ readonly rawPromptContent?: string;
84
+ readonly onProgress: (chunk: ChatPromptResult) => void;
85
+ }): Promise<ChatPromptResult>;
86
+ /**
87
+ * Builds AgentKit input items from the prompt and optional thread.
88
+ */
89
+ private buildAgentKitInputItems;
90
+ /**
91
+ * Builds the user message content for AgentKit runs, including file inputs when provided.
92
+ */
93
+ private buildAgentKitUserContent;
94
+ /**
95
+ * Normalizes AgentKit tool outputs into a string for Promptbook tool call results.
96
+ */
97
+ private formatAgentKitToolOutput;
98
+ /**
99
+ * Returns AgentKit-specific options.
100
+ */
101
+ private get agentKitOptions();
102
+ /**
103
+ * Discriminant for type guards.
104
+ */
105
+ protected get discriminant(): string;
106
+ /**
107
+ * Type guard to check if given `LlmExecutionTools` are instanceof `OpenAiAgentKitExecutionTools`.
108
+ */
109
+ static isOpenAiAgentKitExecutionTools(llmExecutionTools: LlmExecutionTools): llmExecutionTools is OpenAiAgentKitExecutionTools;
110
+ }
111
+ export {};
@@ -0,0 +1,15 @@
1
+ import type { string_model_name } from '../../types/typeAliases';
2
+ import type { OpenAiVectorStoreHandlerOptions } from './OpenAiVectorStoreHandler';
3
+ /**
4
+ * Options for `OpenAiAgentKitExecutionTools`.
5
+ *
6
+ * @public exported from `@promptbook/openai`
7
+ */
8
+ export type OpenAiAgentKitExecutionToolsOptions = OpenAiVectorStoreHandlerOptions & {
9
+ /**
10
+ * Base model name used for AgentKit agents.
11
+ *
12
+ * @default gpt-5.2
13
+ */
14
+ readonly agentKitModelName?: string_model_name;
15
+ };
@@ -4,7 +4,7 @@ import type { ModelRequirements } from '../../types/ModelRequirements';
4
4
  import type { Prompt } from '../../types/Prompt';
5
5
  import type { string_markdown, string_markdown_text, string_title, string_token } from '../../types/typeAliases';
6
6
  import type { OpenAiAssistantExecutionToolsOptions } from './OpenAiAssistantExecutionToolsOptions';
7
- import { OpenAiExecutionTools } from './OpenAiExecutionTools';
7
+ import { OpenAiVectorStoreHandler } from './OpenAiVectorStoreHandler';
8
8
  /**
9
9
  * Execution Tools for calling OpenAI API Assistants
10
10
  *
@@ -17,10 +17,10 @@ import { OpenAiExecutionTools } from './OpenAiExecutionTools';
17
17
  * - `OpenAiAssistantExecutionTools` - which is a specific implementation of `LlmExecutionTools` for OpenAI models with assistant capabilities, recommended for usage in `Agent` or `AgentLlmExecutionTools`
18
18
  * - `RemoteAgent` - which is an `Agent` that connects to a Promptbook Agents Server
19
19
  *
20
+ * @deprecated Use `OpenAiAgentKitExecutionTools` instead.
20
21
  * @public exported from `@promptbook/openai`
21
- * @deprecated Use `OpenAiAgentExecutionTools` instead which uses the new OpenAI Responses API
22
22
  */
23
- export declare class OpenAiAssistantExecutionTools extends OpenAiExecutionTools implements LlmExecutionTools {
23
+ export declare class OpenAiAssistantExecutionTools extends OpenAiVectorStoreHandler implements LlmExecutionTools {
24
24
  readonly assistantId: string_token;
25
25
  private readonly isCreatingNewAssistantsAllowed;
26
26
  /**
@@ -1,12 +1,11 @@
1
- import type { ClientOptions } from 'openai';
2
1
  import type { string_token } from '../../types/typeAliases';
3
- import type { OpenAiCompatibleExecutionToolsOptions } from './OpenAiCompatibleExecutionToolsOptions';
2
+ import type { OpenAiVectorStoreHandlerOptions } from './OpenAiVectorStoreHandler';
4
3
  /**
5
4
  * Options for `createOpenAiAssistantExecutionTools` and `OpenAiAssistantExecutionTools`
6
5
  *
7
6
  * @public exported from `@promptbook/openai`
8
7
  */
9
- export type OpenAiAssistantExecutionToolsOptions = OpenAiCompatibleExecutionToolsOptions & ClientOptions & {
8
+ export type OpenAiAssistantExecutionToolsOptions = OpenAiVectorStoreHandlerOptions & {
10
9
  /**
11
10
  * Whether creating new assistants is allowed
12
11
  *
@@ -0,0 +1,135 @@
1
+ import type { ClientOptions } from 'openai';
2
+ import OpenAI from 'openai';
3
+ import { TODO_any } from '../../_packages/types.index';
4
+ import type { string_title } from '../../types/typeAliases';
5
+ import type { OpenAiCompatibleExecutionToolsOptions } from './OpenAiCompatibleExecutionToolsOptions';
6
+ import { OpenAiExecutionTools } from './OpenAiExecutionTools';
7
+ /**
8
+ * Metadata for uploaded knowledge source files used for vector store diagnostics.
9
+ */
10
+ type KnowledgeSourceUploadMetadata = {
11
+ readonly fileId: string;
12
+ readonly filename: string;
13
+ readonly sizeBytes?: number;
14
+ };
15
+ /**
16
+ * Shared options for OpenAI vector store handling.
17
+ *
18
+ * @public exported from `@promptbook/openai`
19
+ */
20
+ export type OpenAiVectorStoreHandlerOptions = OpenAiCompatibleExecutionToolsOptions & ClientOptions & {
21
+ /**
22
+ * Per-knowledge-source download timeout in milliseconds when preparing vector stores.
23
+ *
24
+ * @default 30000
25
+ */
26
+ readonly knowledgeSourceDownloadTimeoutMs?: number;
27
+ /**
28
+ * Max concurrency for uploading knowledge source files to the vector store.
29
+ *
30
+ * @default 5
31
+ */
32
+ readonly knowledgeSourceUploadMaxConcurrency?: number;
33
+ /**
34
+ * Poll interval in milliseconds when waiting for vector store file batch processing.
35
+ *
36
+ * @default 5000
37
+ */
38
+ readonly knowledgeSourceUploadPollIntervalMs?: number;
39
+ /**
40
+ * Overall timeout in milliseconds for vector store file batch processing.
41
+ *
42
+ * @default 900000
43
+ */
44
+ readonly knowledgeSourceUploadTimeoutMs?: number;
45
+ /**
46
+ * Whether we should continue even if vector store ingestion stalls.
47
+ *
48
+ * @default true
49
+ */
50
+ readonly shouldContinueOnVectorStoreStall?: boolean;
51
+ };
52
+ /**
53
+ * Base class for OpenAI execution tools that need hosted vector stores.
54
+ *
55
+ * @public exported from `@promptbook/openai`
56
+ */
57
+ export declare abstract class OpenAiVectorStoreHandler extends OpenAiExecutionTools {
58
+ /**
59
+ * Returns the per-knowledge-source download timeout in milliseconds.
60
+ */
61
+ protected getKnowledgeSourceDownloadTimeoutMs(): number;
62
+ /**
63
+ * Returns the max concurrency for knowledge source uploads.
64
+ */
65
+ protected getKnowledgeSourceUploadMaxConcurrency(): number;
66
+ /**
67
+ * Returns the polling interval in milliseconds for vector store uploads.
68
+ */
69
+ protected getKnowledgeSourceUploadPollIntervalMs(): number;
70
+ /**
71
+ * Returns the overall upload timeout in milliseconds for vector store uploads.
72
+ */
73
+ protected getKnowledgeSourceUploadTimeoutMs(): number;
74
+ /**
75
+ * Returns true if we should continue even if vector store ingestion stalls.
76
+ */
77
+ protected shouldContinueOnVectorStoreStall(): boolean;
78
+ /**
79
+ * Returns vector-store-specific options with extended settings.
80
+ */
81
+ protected get vectorStoreOptions(): OpenAiVectorStoreHandlerOptions;
82
+ /**
83
+ * Returns the OpenAI vector stores API surface, supporting stable and beta SDKs.
84
+ */
85
+ protected getVectorStoresApi(client: OpenAI): TODO_any;
86
+ /**
87
+ * Downloads a knowledge source URL into a File for vector store upload.
88
+ */
89
+ protected downloadKnowledgeSourceFile(options: {
90
+ readonly source: string;
91
+ readonly timeoutMs: number;
92
+ readonly logLabel: string;
93
+ }): Promise<{
94
+ readonly file: File;
95
+ readonly sizeBytes: number;
96
+ readonly filename: string;
97
+ readonly elapsedMs: number;
98
+ } | null>;
99
+ /**
100
+ * Logs vector store file batch diagnostics to help trace ingestion stalls or failures.
101
+ */
102
+ protected logVectorStoreFileBatchDiagnostics(options: {
103
+ readonly client: OpenAI;
104
+ readonly vectorStoreId: string;
105
+ readonly batchId: string;
106
+ readonly uploadedFiles: ReadonlyArray<KnowledgeSourceUploadMetadata>;
107
+ readonly logLabel: string;
108
+ readonly reason: 'stalled' | 'timeout' | 'failed';
109
+ }): Promise<void>;
110
+ /**
111
+ * Uploads knowledge source files to the vector store and polls until processing completes.
112
+ */
113
+ protected uploadKnowledgeSourceFilesToVectorStore(options: {
114
+ readonly client: OpenAI;
115
+ readonly vectorStoreId: string;
116
+ readonly files: ReadonlyArray<File>;
117
+ readonly totalBytes: number;
118
+ readonly logLabel: string;
119
+ }): Promise<TODO_any | null>;
120
+ /**
121
+ * Creates a vector store and uploads knowledge sources, returning its ID.
122
+ */
123
+ protected createVectorStoreWithKnowledgeSources(options: {
124
+ readonly client: OpenAI;
125
+ readonly name: string_title;
126
+ readonly knowledgeSources: ReadonlyArray<string>;
127
+ readonly logLabel: string;
128
+ }): Promise<{
129
+ readonly vectorStoreId: string;
130
+ readonly uploadedFileCount: number;
131
+ readonly skippedCount: number;
132
+ readonly totalBytes: number;
133
+ }>;
134
+ }
135
+ export {};
@@ -5,4 +5,4 @@ import type { LlmToolDefinition } from '../../../types/LlmToolDefinition';
5
5
  *
6
6
  * @private
7
7
  */
8
- export declare function mapToolsToOpenAi(tools: ReadonlyArray<LlmToolDefinition>): Array<OpenAI.Chat.Completions.ChatCompletionTool>;
8
+ export declare function mapToolsToOpenAi(tools: ReadonlyArray<LlmToolDefinition>): Array<OpenAI.Chat.Completions.ChatCompletionTool & OpenAI.Beta.AssistantTool>;
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
15
15
  export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
16
16
  /**
17
17
  * Represents the version string of the Promptbook engine.
18
- * It follows semantic versioning (e.g., `0.110.0-2`).
18
+ * It follows semantic versioning (e.g., `0.110.0-6`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/node",
3
- "version": "0.110.0-4",
3
+ "version": "0.110.0-7",
4
4
  "description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -89,14 +89,18 @@
89
89
  "node": ">=18.18.0",
90
90
  "npm": ">=8.0.0"
91
91
  },
92
+ "overrides": {
93
+ "zod": "$zod"
94
+ },
92
95
  "main": "./umd/index.umd.js",
93
96
  "module": "./esm/index.es.js",
94
97
  "typings": "./esm/typings/src/_packages/node.index.d.ts",
95
98
  "peerDependencies": {
96
- "@promptbook/core": "0.110.0-4"
99
+ "@promptbook/core": "0.110.0-7"
97
100
  },
98
101
  "dependencies": {
99
102
  "@mozilla/readability": "0.6.0",
103
+ "@openai/agents": "0.4.5",
100
104
  "bottleneck": "2.19.5",
101
105
  "colors": "1.4.0",
102
106
  "crypto": "1.0.1",
@@ -105,7 +109,7 @@
105
109
  "jsdom": "25.0.1",
106
110
  "jszip": "3.10.1",
107
111
  "moment": "2.30.1",
108
- "openai": "4.63.0",
112
+ "openai": "6.18.0",
109
113
  "papaparse": "5.4.1",
110
114
  "rxjs": "7.8.2",
111
115
  "showdown": "2.1.0",