@promptbook/remote-server 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 +75 -13
- 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 +2 -2
- package/umd/index.umd.js +89 -24
- 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('path'), require('child_process'), require('colors'), require('spacetrim'), require('waitasecond'), require('http'), require('express'), require('socket.io'), require('fs/promises'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'path', 'child_process', 'colors', 'spacetrim', 'waitasecond', 'http', 'express', 'socket.io', 'fs/promises', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-remote-server"] = {}, global.path, global.child_process, global.colors, global._spaceTrim, global.waitasecond, global.http, global.express, global.socket_io, global.promises, global.
|
|
5
|
-
})(this, (function (exports, path, child_process, colors, _spaceTrim, waitasecond, http, express, socket_io, promises,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('path'), require('child_process'), require('colors'), require('spacetrim'), require('waitasecond'), require('http'), require('express'), require('socket.io'), require('fs/promises'), require('crypto-js'), require('crypto-js/enc-hex'), require('showdown'), require('express-openapi-validator'), require('swagger-ui-express'), require('react'), require('react-dom/server'), require('rxjs'), require('crypto'), require('moment'), require('mime-types'), require('crypto-js/sha256'), require('papaparse'), require('bottleneck')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'path', 'child_process', 'colors', 'spacetrim', 'waitasecond', 'http', 'express', 'socket.io', 'fs/promises', 'crypto-js', 'crypto-js/enc-hex', 'showdown', 'express-openapi-validator', 'swagger-ui-express', 'react', 'react-dom/server', 'rxjs', 'crypto', 'moment', 'mime-types', 'crypto-js/sha256', 'papaparse', 'bottleneck'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-remote-server"] = {}, global.path, global.child_process, global.colors, global._spaceTrim, global.waitasecond, global.http, global.express, global.socket_io, global.promises, global.CryptoJS, global.hexEncoder, global.showdown, global.OpenApiValidator, global.swaggerUi, global.react, global.server, global.rxjs, null, global.moment, global.mimeTypes, global.sha256, global.papaparse, global.Bottleneck));
|
|
5
|
+
})(this, (function (exports, path, child_process, colors, _spaceTrim, waitasecond, http, express, socket_io, promises, CryptoJS, hexEncoder, showdown, OpenApiValidator, swaggerUi, react, server, rxjs, crypto, moment, mimeTypes, sha256, papaparse, Bottleneck) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -37,7 +37,6 @@
|
|
|
37
37
|
var sha256__default = /*#__PURE__*/_interopDefaultLegacy(sha256);
|
|
38
38
|
var papaparse__default = /*#__PURE__*/_interopDefaultLegacy(papaparse);
|
|
39
39
|
var Bottleneck__default = /*#__PURE__*/_interopDefaultLegacy(Bottleneck);
|
|
40
|
-
var OpenAI__default = /*#__PURE__*/_interopDefaultLegacy(OpenAI);
|
|
41
40
|
|
|
42
41
|
// ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
|
|
43
42
|
/**
|
|
@@ -53,7 +52,7 @@
|
|
|
53
52
|
* @generated
|
|
54
53
|
* @see https://github.com/webgptorg/promptbook
|
|
55
54
|
*/
|
|
56
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.114.0-
|
|
55
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.114.0-3';
|
|
57
56
|
/**
|
|
58
57
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
59
58
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -9405,6 +9404,31 @@
|
|
|
9405
9404
|
// Note: [🟢] Code for Node scraper registration helper [$provideScrapersForNode](src/scrapers/_common/register/$provideScrapersForNode.ts) should never be published into packages that could be imported into browser environment
|
|
9406
9405
|
// TODO: [🏓] Unite `xxxForServer` and `xxxForNode` naming
|
|
9407
9406
|
|
|
9407
|
+
/**
|
|
9408
|
+
* Creates a loader which imports one module on the first call and reuses the very same module afterwards
|
|
9409
|
+
*
|
|
9410
|
+
* Note: [🐌] Heavy third-party dependencies are imported lazily to keep the startup of the Promptbook CLI fast.
|
|
9411
|
+
* A statically imported dependency is loaded every single time the bundle is loaded, even when the running
|
|
9412
|
+
* command never touches it. A lazily imported dependency is loaded only when the feature is really used.
|
|
9413
|
+
*
|
|
9414
|
+
* @example
|
|
9415
|
+
* const loadJsdomModule = createLazyModuleLoader(() => import('jsdom'));
|
|
9416
|
+
* const { JSDOM } = await loadJsdomModule();
|
|
9417
|
+
*
|
|
9418
|
+
* @private internal utility of Promptbook
|
|
9419
|
+
*/
|
|
9420
|
+
function createLazyModuleLoader(importModule) {
|
|
9421
|
+
let importedModulePromise = null;
|
|
9422
|
+
return function loadModule() {
|
|
9423
|
+
if (importedModulePromise === null) {
|
|
9424
|
+
importedModulePromise = importModule();
|
|
9425
|
+
}
|
|
9426
|
+
return importedModulePromise;
|
|
9427
|
+
};
|
|
9428
|
+
}
|
|
9429
|
+
// Note: [🐌] Do not convert the lazy `import(...)` calls back to static `import` statements, it would bring back the
|
|
9430
|
+
// slow startup of the `ptbk` CLI utility
|
|
9431
|
+
|
|
9408
9432
|
/**
|
|
9409
9433
|
* Metadata of the scraper
|
|
9410
9434
|
*
|
|
@@ -9689,7 +9713,23 @@
|
|
|
9689
9713
|
});
|
|
9690
9714
|
}
|
|
9691
9715
|
|
|
9692
|
-
|
|
9716
|
+
/**
|
|
9717
|
+
* Loads `jsdom` on demand
|
|
9718
|
+
*
|
|
9719
|
+
* Note: [🐌] `jsdom` is by far the heaviest dependency of Promptbook, loading it eagerly would slow down every single
|
|
9720
|
+
* run of the `ptbk` CLI utility even when no website is scraped
|
|
9721
|
+
*
|
|
9722
|
+
* @private internal utility of `WebsiteScraper`
|
|
9723
|
+
*/
|
|
9724
|
+
const loadJsdomModule = createLazyModuleLoader(() => import('jsdom'));
|
|
9725
|
+
/**
|
|
9726
|
+
* Loads `@mozilla/readability` on demand
|
|
9727
|
+
*
|
|
9728
|
+
* Note: [🐌] Loaded lazily to keep the startup of the `ptbk` CLI utility fast
|
|
9729
|
+
*
|
|
9730
|
+
* @private internal utility of `WebsiteScraper`
|
|
9731
|
+
*/
|
|
9732
|
+
const loadReadabilityModule = createLazyModuleLoader(() => import('@mozilla/readability'));
|
|
9693
9733
|
/**
|
|
9694
9734
|
* Scraper for websites
|
|
9695
9735
|
*
|
|
@@ -9725,14 +9765,15 @@
|
|
|
9725
9765
|
if (this.tools.fs === undefined) {
|
|
9726
9766
|
throw new EnvironmentMismatchError('Can not scrape websites without filesystem tools');
|
|
9727
9767
|
}
|
|
9728
|
-
const
|
|
9768
|
+
const [{ JSDOM }, { Readability }] = await Promise.all([loadJsdomModule(), loadReadabilityModule()]);
|
|
9769
|
+
const jsdom = new JSDOM(await source.asText(), {
|
|
9729
9770
|
url: source.url,
|
|
9730
9771
|
});
|
|
9731
|
-
const reader = new
|
|
9772
|
+
const reader = new Readability(jsdom.window.document);
|
|
9732
9773
|
const article = reader.parse();
|
|
9733
9774
|
// console.log(article);
|
|
9734
9775
|
// await forTime(10000);
|
|
9735
|
-
let html = (article === null || article === void 0 ? void 0 : article.content) || (article === null || article === void 0 ? void 0 : article.textContent) || jsdom
|
|
9776
|
+
let html = (article === null || article === void 0 ? void 0 : article.content) || (article === null || article === void 0 ? void 0 : article.textContent) || jsdom.window.document.body.innerHTML;
|
|
9736
9777
|
// Note: Unwrap html such as it is convertable by `markdownConverter`
|
|
9737
9778
|
for (let i = 0; i < 2; i++) {
|
|
9738
9779
|
html = html.replace(/<div\s*(?:id="readability-page-\d+"\s+class="page")?>(.*)<\/div>/is, '$1');
|
|
@@ -9765,7 +9806,7 @@
|
|
|
9765
9806
|
throw error;
|
|
9766
9807
|
}
|
|
9767
9808
|
}
|
|
9768
|
-
const markdown = this.showdownConverter.makeMarkdown(html, jsdom
|
|
9809
|
+
const markdown = this.showdownConverter.makeMarkdown(html, jsdom.window.document);
|
|
9769
9810
|
return { ...cacheFilehandler, markdown };
|
|
9770
9811
|
}
|
|
9771
9812
|
/**
|
|
@@ -35847,6 +35888,16 @@
|
|
|
35847
35888
|
`;
|
|
35848
35889
|
}
|
|
35849
35890
|
|
|
35891
|
+
/**
|
|
35892
|
+
* Loads the OpenAI AgentKit SDK (`@openai/agents`) on demand
|
|
35893
|
+
*
|
|
35894
|
+
* Note: [🐌] The AgentKit SDK is one of the heaviest dependencies of Promptbook, loading it eagerly would slow down
|
|
35895
|
+
* every single run of the `ptbk` CLI utility even when no AgentKit agent is used
|
|
35896
|
+
*
|
|
35897
|
+
* @private internal utility of `@promptbook/openai`
|
|
35898
|
+
*/
|
|
35899
|
+
const loadOpenAiAgentsModule = createLazyModuleLoader(() => import('@openai/agents'));
|
|
35900
|
+
|
|
35850
35901
|
/**
|
|
35851
35902
|
* Constant for default model used for nested DeepSearch tool invocations.
|
|
35852
35903
|
*/
|
|
@@ -35900,11 +35951,12 @@
|
|
|
35900
35951
|
/**
|
|
35901
35952
|
* Builds the tool list for AgentKit, including hosted file search when applicable.
|
|
35902
35953
|
*/
|
|
35903
|
-
buildAgentKitTools(options) {
|
|
35954
|
+
async buildAgentKitTools(options) {
|
|
35904
35955
|
const { tools, vectorStoreId } = options;
|
|
35956
|
+
const { fileSearchTool, tool: agentKitTool } = await loadOpenAiAgentsModule();
|
|
35905
35957
|
const agentKitTools = [];
|
|
35906
35958
|
if (vectorStoreId) {
|
|
35907
|
-
agentKitTools.push(
|
|
35959
|
+
agentKitTools.push(fileSearchTool(vectorStoreId));
|
|
35908
35960
|
}
|
|
35909
35961
|
if (!tools || tools.length === 0) {
|
|
35910
35962
|
return agentKitTools;
|
|
@@ -35912,11 +35964,11 @@
|
|
|
35912
35964
|
let scriptTools = null;
|
|
35913
35965
|
for (const toolDefinition of tools) {
|
|
35914
35966
|
if (this.isDeepSearchToolDefinition(toolDefinition)) {
|
|
35915
|
-
agentKitTools.push(this.createDeepSearchAgentKitTool(toolDefinition));
|
|
35967
|
+
agentKitTools.push(await this.createDeepSearchAgentKitTool(toolDefinition));
|
|
35916
35968
|
continue;
|
|
35917
35969
|
}
|
|
35918
35970
|
scriptTools !== null && scriptTools !== void 0 ? scriptTools : (scriptTools = this.resolveScriptTools());
|
|
35919
|
-
agentKitTools.push(
|
|
35971
|
+
agentKitTools.push(agentKitTool({
|
|
35920
35972
|
name: toolDefinition.name,
|
|
35921
35973
|
description: toolDefinition.description,
|
|
35922
35974
|
parameters: this.normalizeAgentKitToolParameters(toolDefinition.parameters),
|
|
@@ -36123,12 +36175,13 @@
|
|
|
36123
36175
|
/**
|
|
36124
36176
|
* Creates the native Agent SDK tool used for `USE DEEPSEARCH`.
|
|
36125
36177
|
*/
|
|
36126
|
-
createDeepSearchAgentKitTool(toolDefinition) {
|
|
36127
|
-
const
|
|
36178
|
+
async createDeepSearchAgentKitTool(toolDefinition) {
|
|
36179
|
+
const { Agent: AgentFromKit, webSearchTool } = await loadOpenAiAgentsModule();
|
|
36180
|
+
const deepSearchAgent = new AgentFromKit({
|
|
36128
36181
|
name: 'DeepSearch',
|
|
36129
36182
|
model: DEFAULT_DEEP_SEARCH_MODEL_NAME,
|
|
36130
36183
|
instructions: this.createDeepSearchAgentInstructions(toolDefinition.description),
|
|
36131
|
-
tools: [
|
|
36184
|
+
tools: [webSearchTool({ searchContextSize: 'high' })],
|
|
36132
36185
|
});
|
|
36133
36186
|
return deepSearchAgent.asTool({
|
|
36134
36187
|
toolName: toolDefinition.name,
|
|
@@ -37450,6 +37503,14 @@
|
|
|
37450
37503
|
}
|
|
37451
37504
|
}
|
|
37452
37505
|
|
|
37506
|
+
/**
|
|
37507
|
+
* Loads the OpenAI SDK (`openai`) on demand
|
|
37508
|
+
*
|
|
37509
|
+
* Note: [🐌] Loaded lazily to keep the startup of the `ptbk` CLI utility fast
|
|
37510
|
+
*
|
|
37511
|
+
* @private internal utility of `OpenAiCompatibleRequestManager`
|
|
37512
|
+
*/
|
|
37513
|
+
const loadOpenAiModule = createLazyModuleLoader(() => import('openai'));
|
|
37453
37514
|
/**
|
|
37454
37515
|
* Manages OpenAI-compatible client creation plus shared retry and rate-limit behavior.
|
|
37455
37516
|
*
|
|
@@ -37476,7 +37537,8 @@
|
|
|
37476
37537
|
timeout: API_REQUEST_TIMEOUT,
|
|
37477
37538
|
maxRetries: CONNECTION_RETRIES_LIMIT,
|
|
37478
37539
|
};
|
|
37479
|
-
|
|
37540
|
+
const { default: OpenAI } = await loadOpenAiModule();
|
|
37541
|
+
this.client = new OpenAI(enhancedOptions);
|
|
37480
37542
|
}
|
|
37481
37543
|
return this.client;
|
|
37482
37544
|
}
|
|
@@ -39623,8 +39685,9 @@
|
|
|
39623
39685
|
vectorStoreId,
|
|
39624
39686
|
});
|
|
39625
39687
|
}
|
|
39626
|
-
const
|
|
39627
|
-
const
|
|
39688
|
+
const { Agent: AgentFromKit } = await loadOpenAiAgentsModule();
|
|
39689
|
+
const agentKitTools = await this.buildAgentKitTools({ tools, vectorStoreId });
|
|
39690
|
+
const openAiAgentKitAgent = new AgentFromKit({
|
|
39628
39691
|
name,
|
|
39629
39692
|
model: this.agentKitModelName,
|
|
39630
39693
|
instructions: instructions || 'You are a helpful assistant.',
|
|
@@ -39669,7 +39732,8 @@
|
|
|
39669
39732
|
agentName: agentForRun.name,
|
|
39670
39733
|
input: inputItems,
|
|
39671
39734
|
};
|
|
39672
|
-
const
|
|
39735
|
+
const { run } = await loadOpenAiAgentsModule();
|
|
39736
|
+
const streamResult = await run(agentForRun, inputItems, {
|
|
39673
39737
|
stream: true,
|
|
39674
39738
|
maxTurns: 200,
|
|
39675
39739
|
context: {
|
|
@@ -39811,11 +39875,12 @@
|
|
|
39811
39875
|
* Ensures the AgentKit SDK is wired to the OpenAI client and API key.
|
|
39812
39876
|
*/
|
|
39813
39877
|
async ensureAgentKitDefaults() {
|
|
39878
|
+
const { setDefaultOpenAIClient, setDefaultOpenAIKey } = await loadOpenAiAgentsModule();
|
|
39814
39879
|
const client = await this.getClient();
|
|
39815
|
-
|
|
39880
|
+
setDefaultOpenAIClient(client);
|
|
39816
39881
|
const apiKey = this.agentKitOptions.apiKey;
|
|
39817
39882
|
if (apiKey && typeof apiKey === 'string') {
|
|
39818
|
-
|
|
39883
|
+
setDefaultOpenAIKey(apiKey);
|
|
39819
39884
|
}
|
|
39820
39885
|
}
|
|
39821
39886
|
/**
|