@promptbook/core 0.114.0-2 → 0.114.0-3
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.
- package/esm/index.es.js +57 -10
- package/esm/index.es.js.map +1 -1
- package/esm/src/book-components/Chat/utils/$provideServerDomWindow.d.ts +11 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/createAgentsServerRuntimeEnvironment.d.ts +7 -0
- package/esm/src/cli/cli-commands/coder/ping.d.ts +2 -5
- package/esm/src/cli/cli-commands/coder.d.ts +1 -1
- package/esm/src/cli/cli-commands/common/coderGitSyncCliOptions.d.ts +34 -0
- package/esm/src/cli/cli-commands/common/coderGitSyncCliOptions.test.d.ts +1 -0
- package/esm/src/cli/common/loadPromptsModule.d.ts +16 -0
- package/esm/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +1 -1
- package/esm/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +1 -1
- package/esm/src/llm-providers/openai/OpenAiAgentKitExecutionTools.d.ts +1 -1
- package/esm/src/llm-providers/openai/OpenAiAgentKitExecutionToolsToolBuilder.d.ts +1 -1
- package/esm/src/llm-providers/openai/OpenAiAssistantExecutionToolsStreamRunner.d.ts +1 -1
- package/esm/src/llm-providers/openai/OpenAiAssistantExecutionToolsToolRunner.d.ts +1 -1
- package/esm/src/llm-providers/openai/OpenAiCompatibleNonChatPromptCaller.d.ts +1 -1
- package/esm/src/llm-providers/openai/OpenAiCompatibleRequestManager.d.ts +1 -1
- package/esm/src/llm-providers/openai/utils/callOpenAiCompatibleChatModel.d.ts +1 -1
- package/esm/src/llm-providers/openai/utils/loadOpenAiAgentsModule.d.ts +203 -0
- package/esm/src/llm-providers/openai/utils/uploadFilesToOpenAi.d.ts +1 -1
- package/esm/src/utils/misc/createLazyModuleLoader.d.ts +14 -0
- package/esm/src/version.d.ts +1 -1
- package/package.json +5 -1
- package/umd/index.umd.js +67 -19
- package/umd/index.umd.js.map +1 -1
- package/umd/src/book-components/Chat/utils/$provideServerDomWindow.d.ts +11 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/createAgentsServerRuntimeEnvironment.d.ts +7 -0
- package/umd/src/cli/cli-commands/coder/ping.d.ts +2 -5
- package/umd/src/cli/cli-commands/coder.d.ts +1 -1
- package/umd/src/cli/cli-commands/common/coderGitSyncCliOptions.d.ts +34 -0
- package/umd/src/cli/cli-commands/common/coderGitSyncCliOptions.test.d.ts +1 -0
- package/umd/src/cli/common/loadPromptsModule.d.ts +16 -0
- package/umd/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +1 -1
- package/umd/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +1 -1
- package/umd/src/llm-providers/openai/OpenAiAgentKitExecutionTools.d.ts +1 -1
- package/umd/src/llm-providers/openai/OpenAiAgentKitExecutionToolsToolBuilder.d.ts +1 -1
- package/umd/src/llm-providers/openai/OpenAiAssistantExecutionToolsStreamRunner.d.ts +1 -1
- package/umd/src/llm-providers/openai/OpenAiAssistantExecutionToolsToolRunner.d.ts +1 -1
- package/umd/src/llm-providers/openai/OpenAiCompatibleNonChatPromptCaller.d.ts +1 -1
- package/umd/src/llm-providers/openai/OpenAiCompatibleRequestManager.d.ts +1 -1
- package/umd/src/llm-providers/openai/utils/callOpenAiCompatibleChatModel.d.ts +1 -1
- package/umd/src/llm-providers/openai/utils/loadOpenAiAgentsModule.d.ts +203 -0
- package/umd/src/llm-providers/openai/utils/uploadFilesToOpenAi.d.ts +1 -1
- package/umd/src/utils/misc/createLazyModuleLoader.d.ts +14 -0
- package/umd/src/version.d.ts +1 -1
package/umd/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('crypto-js'), require('crypto-js/enc-hex'), require('rxjs'), require('waitasecond'), require('crypto-js/sha256'), require('path'), require('mime-types'), require('papaparse'), require('moment'), require('crypto'), require('colors'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'crypto-js', 'crypto-js/enc-hex', 'rxjs', 'waitasecond', 'crypto-js/sha256', 'path', 'mime-types', 'papaparse', 'moment', 'crypto', 'colors', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-core"] = {}, global.spacetrim, global.CryptoJS, global.hexEncoder, global.rxjs, global.waitasecond, global.sha256, global.path, global.mimeTypes, global.papaparse, global.moment, global.crypto, global.colors, global.
|
|
5
|
-
})(this, (function (exports, spacetrim, CryptoJS, hexEncoder, rxjs, waitasecond, sha256, path, mimeTypes, papaparse, moment, crypto, colors,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('crypto-js'), require('crypto-js/enc-hex'), require('rxjs'), require('waitasecond'), require('crypto-js/sha256'), require('path'), require('mime-types'), require('papaparse'), require('moment'), require('crypto'), require('colors'), require('bottleneck')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'crypto-js', 'crypto-js/enc-hex', 'rxjs', 'waitasecond', 'crypto-js/sha256', 'path', 'mime-types', 'papaparse', 'moment', 'crypto', 'colors', 'bottleneck'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-core"] = {}, global.spacetrim, global.CryptoJS, global.hexEncoder, global.rxjs, global.waitasecond, global.sha256, global.path, global.mimeTypes, global.papaparse, global.moment, global.crypto, global.colors, global.Bottleneck));
|
|
5
|
+
})(this, (function (exports, spacetrim, CryptoJS, hexEncoder, rxjs, waitasecond, sha256, path, mimeTypes, papaparse, moment, crypto, colors, Bottleneck) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
|
|
14
14
|
var colors__default = /*#__PURE__*/_interopDefaultLegacy(colors);
|
|
15
15
|
var Bottleneck__default = /*#__PURE__*/_interopDefaultLegacy(Bottleneck);
|
|
16
|
-
var OpenAI__default = /*#__PURE__*/_interopDefaultLegacy(OpenAI);
|
|
17
16
|
|
|
18
17
|
// ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
|
|
19
18
|
/**
|
|
@@ -29,7 +28,7 @@
|
|
|
29
28
|
* @generated
|
|
30
29
|
* @see https://github.com/webgptorg/promptbook
|
|
31
30
|
*/
|
|
32
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.114.0-
|
|
31
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.114.0-3';
|
|
33
32
|
/**
|
|
34
33
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
35
34
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -38427,6 +38426,41 @@
|
|
|
38427
38426
|
`;
|
|
38428
38427
|
}
|
|
38429
38428
|
|
|
38429
|
+
/**
|
|
38430
|
+
* Creates a loader which imports one module on the first call and reuses the very same module afterwards
|
|
38431
|
+
*
|
|
38432
|
+
* Note: [🐌] Heavy third-party dependencies are imported lazily to keep the startup of the Promptbook CLI fast.
|
|
38433
|
+
* A statically imported dependency is loaded every single time the bundle is loaded, even when the running
|
|
38434
|
+
* command never touches it. A lazily imported dependency is loaded only when the feature is really used.
|
|
38435
|
+
*
|
|
38436
|
+
* @example
|
|
38437
|
+
* const loadJsdomModule = createLazyModuleLoader(() => import('jsdom'));
|
|
38438
|
+
* const { JSDOM } = await loadJsdomModule();
|
|
38439
|
+
*
|
|
38440
|
+
* @private internal utility of Promptbook
|
|
38441
|
+
*/
|
|
38442
|
+
function createLazyModuleLoader(importModule) {
|
|
38443
|
+
let importedModulePromise = null;
|
|
38444
|
+
return function loadModule() {
|
|
38445
|
+
if (importedModulePromise === null) {
|
|
38446
|
+
importedModulePromise = importModule();
|
|
38447
|
+
}
|
|
38448
|
+
return importedModulePromise;
|
|
38449
|
+
};
|
|
38450
|
+
}
|
|
38451
|
+
// Note: [🐌] Do not convert the lazy `import(...)` calls back to static `import` statements, it would bring back the
|
|
38452
|
+
// slow startup of the `ptbk` CLI utility
|
|
38453
|
+
|
|
38454
|
+
/**
|
|
38455
|
+
* Loads the OpenAI AgentKit SDK (`@openai/agents`) on demand
|
|
38456
|
+
*
|
|
38457
|
+
* Note: [🐌] The AgentKit SDK is one of the heaviest dependencies of Promptbook, loading it eagerly would slow down
|
|
38458
|
+
* every single run of the `ptbk` CLI utility even when no AgentKit agent is used
|
|
38459
|
+
*
|
|
38460
|
+
* @private internal utility of `@promptbook/openai`
|
|
38461
|
+
*/
|
|
38462
|
+
const loadOpenAiAgentsModule = createLazyModuleLoader(() => import('@openai/agents'));
|
|
38463
|
+
|
|
38430
38464
|
/**
|
|
38431
38465
|
* Constant for default model used for nested DeepSearch tool invocations.
|
|
38432
38466
|
*/
|
|
@@ -38480,11 +38514,12 @@
|
|
|
38480
38514
|
/**
|
|
38481
38515
|
* Builds the tool list for AgentKit, including hosted file search when applicable.
|
|
38482
38516
|
*/
|
|
38483
|
-
buildAgentKitTools(options) {
|
|
38517
|
+
async buildAgentKitTools(options) {
|
|
38484
38518
|
const { tools, vectorStoreId } = options;
|
|
38519
|
+
const { fileSearchTool, tool: agentKitTool } = await loadOpenAiAgentsModule();
|
|
38485
38520
|
const agentKitTools = [];
|
|
38486
38521
|
if (vectorStoreId) {
|
|
38487
|
-
agentKitTools.push(
|
|
38522
|
+
agentKitTools.push(fileSearchTool(vectorStoreId));
|
|
38488
38523
|
}
|
|
38489
38524
|
if (!tools || tools.length === 0) {
|
|
38490
38525
|
return agentKitTools;
|
|
@@ -38492,11 +38527,11 @@
|
|
|
38492
38527
|
let scriptTools = null;
|
|
38493
38528
|
for (const toolDefinition of tools) {
|
|
38494
38529
|
if (this.isDeepSearchToolDefinition(toolDefinition)) {
|
|
38495
|
-
agentKitTools.push(this.createDeepSearchAgentKitTool(toolDefinition));
|
|
38530
|
+
agentKitTools.push(await this.createDeepSearchAgentKitTool(toolDefinition));
|
|
38496
38531
|
continue;
|
|
38497
38532
|
}
|
|
38498
38533
|
scriptTools !== null && scriptTools !== void 0 ? scriptTools : (scriptTools = this.resolveScriptTools());
|
|
38499
|
-
agentKitTools.push(
|
|
38534
|
+
agentKitTools.push(agentKitTool({
|
|
38500
38535
|
name: toolDefinition.name,
|
|
38501
38536
|
description: toolDefinition.description,
|
|
38502
38537
|
parameters: this.normalizeAgentKitToolParameters(toolDefinition.parameters),
|
|
@@ -38703,12 +38738,13 @@
|
|
|
38703
38738
|
/**
|
|
38704
38739
|
* Creates the native Agent SDK tool used for `USE DEEPSEARCH`.
|
|
38705
38740
|
*/
|
|
38706
|
-
createDeepSearchAgentKitTool(toolDefinition) {
|
|
38707
|
-
const
|
|
38741
|
+
async createDeepSearchAgentKitTool(toolDefinition) {
|
|
38742
|
+
const { Agent: AgentFromKit, webSearchTool } = await loadOpenAiAgentsModule();
|
|
38743
|
+
const deepSearchAgent = new AgentFromKit({
|
|
38708
38744
|
name: 'DeepSearch',
|
|
38709
38745
|
model: DEFAULT_DEEP_SEARCH_MODEL_NAME,
|
|
38710
38746
|
instructions: this.createDeepSearchAgentInstructions(toolDefinition.description),
|
|
38711
|
-
tools: [
|
|
38747
|
+
tools: [webSearchTool({ searchContextSize: 'high' })],
|
|
38712
38748
|
});
|
|
38713
38749
|
return deepSearchAgent.asTool({
|
|
38714
38750
|
toolName: toolDefinition.name,
|
|
@@ -40030,6 +40066,14 @@
|
|
|
40030
40066
|
}
|
|
40031
40067
|
}
|
|
40032
40068
|
|
|
40069
|
+
/**
|
|
40070
|
+
* Loads the OpenAI SDK (`openai`) on demand
|
|
40071
|
+
*
|
|
40072
|
+
* Note: [🐌] Loaded lazily to keep the startup of the `ptbk` CLI utility fast
|
|
40073
|
+
*
|
|
40074
|
+
* @private internal utility of `OpenAiCompatibleRequestManager`
|
|
40075
|
+
*/
|
|
40076
|
+
const loadOpenAiModule = createLazyModuleLoader(() => import('openai'));
|
|
40033
40077
|
/**
|
|
40034
40078
|
* Manages OpenAI-compatible client creation plus shared retry and rate-limit behavior.
|
|
40035
40079
|
*
|
|
@@ -40056,7 +40100,8 @@
|
|
|
40056
40100
|
timeout: API_REQUEST_TIMEOUT,
|
|
40057
40101
|
maxRetries: CONNECTION_RETRIES_LIMIT,
|
|
40058
40102
|
};
|
|
40059
|
-
|
|
40103
|
+
const { default: OpenAI } = await loadOpenAiModule();
|
|
40104
|
+
this.client = new OpenAI(enhancedOptions);
|
|
40060
40105
|
}
|
|
40061
40106
|
return this.client;
|
|
40062
40107
|
}
|
|
@@ -42203,8 +42248,9 @@
|
|
|
42203
42248
|
vectorStoreId,
|
|
42204
42249
|
});
|
|
42205
42250
|
}
|
|
42206
|
-
const
|
|
42207
|
-
const
|
|
42251
|
+
const { Agent: AgentFromKit } = await loadOpenAiAgentsModule();
|
|
42252
|
+
const agentKitTools = await this.buildAgentKitTools({ tools, vectorStoreId });
|
|
42253
|
+
const openAiAgentKitAgent = new AgentFromKit({
|
|
42208
42254
|
name,
|
|
42209
42255
|
model: this.agentKitModelName,
|
|
42210
42256
|
instructions: instructions || 'You are a helpful assistant.',
|
|
@@ -42249,7 +42295,8 @@
|
|
|
42249
42295
|
agentName: agentForRun.name,
|
|
42250
42296
|
input: inputItems,
|
|
42251
42297
|
};
|
|
42252
|
-
const
|
|
42298
|
+
const { run } = await loadOpenAiAgentsModule();
|
|
42299
|
+
const streamResult = await run(agentForRun, inputItems, {
|
|
42253
42300
|
stream: true,
|
|
42254
42301
|
maxTurns: 200,
|
|
42255
42302
|
context: {
|
|
@@ -42391,11 +42438,12 @@
|
|
|
42391
42438
|
* Ensures the AgentKit SDK is wired to the OpenAI client and API key.
|
|
42392
42439
|
*/
|
|
42393
42440
|
async ensureAgentKitDefaults() {
|
|
42441
|
+
const { setDefaultOpenAIClient, setDefaultOpenAIKey } = await loadOpenAiAgentsModule();
|
|
42394
42442
|
const client = await this.getClient();
|
|
42395
|
-
|
|
42443
|
+
setDefaultOpenAIClient(client);
|
|
42396
42444
|
const apiKey = this.agentKitOptions.apiKey;
|
|
42397
42445
|
if (apiKey && typeof apiKey === 'string') {
|
|
42398
|
-
|
|
42446
|
+
setDefaultOpenAIKey(apiKey);
|
|
42399
42447
|
}
|
|
42400
42448
|
}
|
|
42401
42449
|
/**
|