@promptbook/node 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 +98 -18
- package/esm/index.es.js.map +1 -1
- package/esm/scripts/run-codex-prompts/common/runGoScript/scriptExecutionLog.d.ts +7 -0
- package/esm/scripts/run-codex-prompts/main/resolvePromptRunner.d.ts +8 -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 +117 -34
- package/umd/index.umd.js.map +1 -1
- package/umd/scripts/run-codex-prompts/common/runGoScript/scriptExecutionLog.d.ts +7 -0
- package/umd/scripts/run-codex-prompts/main/resolvePromptRunner.d.ts +8 -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('fs/promises'), require('spacetrim'), require('colors'), require('child_process'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'path', 'fs/promises', 'spacetrim', 'colors', 'child_process', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-node"] = {}, global.path, global.promises, global._spaceTrim, global.colors, global.child_process, global.
|
|
5
|
-
})(this, (function (exports, path, promises, _spaceTrim, colors, child_process,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('path'), require('fs/promises'), require('spacetrim'), require('colors'), require('child_process'), require('url'), require('crypto-js'), require('crypto-js/enc-hex'), require('showdown'), require('waitasecond'), require('dotenv'), require('crypto-js/sha256'), require('rxjs'), require('crypto'), require('moment'), require('mime-types'), require('papaparse'), require('bottleneck')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'path', 'fs/promises', 'spacetrim', 'colors', 'child_process', 'url', 'crypto-js', 'crypto-js/enc-hex', 'showdown', 'waitasecond', 'dotenv', 'crypto-js/sha256', 'rxjs', 'crypto', 'moment', 'mime-types', 'papaparse', 'bottleneck'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-node"] = {}, global.path, global.promises, global._spaceTrim, global.colors, global.child_process, global.url, global.CryptoJS, global.hexEncoder, global.showdown, global.waitasecond, global.dotenv, global.sha256, global.rxjs, null, global.moment, global.mimeTypes, global.papaparse, global.Bottleneck));
|
|
5
|
+
})(this, (function (exports, path, promises, _spaceTrim, colors, child_process, url, CryptoJS, hexEncoder, showdown, waitasecond, dotenv, sha256, rxjs, crypto, moment, mimeTypes, papaparse, Bottleneck) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -29,13 +29,11 @@
|
|
|
29
29
|
var CryptoJS__default = /*#__PURE__*/_interopDefaultLegacy(CryptoJS);
|
|
30
30
|
var hexEncoder__default = /*#__PURE__*/_interopDefaultLegacy(hexEncoder);
|
|
31
31
|
var showdown__default = /*#__PURE__*/_interopDefaultLegacy(showdown);
|
|
32
|
-
var JSZip__default = /*#__PURE__*/_interopDefaultLegacy(JSZip);
|
|
33
32
|
var dotenv__namespace = /*#__PURE__*/_interopNamespace(dotenv);
|
|
34
33
|
var sha256__default = /*#__PURE__*/_interopDefaultLegacy(sha256);
|
|
35
34
|
var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
|
|
36
35
|
var papaparse__default = /*#__PURE__*/_interopDefaultLegacy(papaparse);
|
|
37
36
|
var Bottleneck__default = /*#__PURE__*/_interopDefaultLegacy(Bottleneck);
|
|
38
|
-
var OpenAI__default = /*#__PURE__*/_interopDefaultLegacy(OpenAI);
|
|
39
37
|
|
|
40
38
|
// ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
|
|
41
39
|
/**
|
|
@@ -51,7 +49,7 @@
|
|
|
51
49
|
* @generated
|
|
52
50
|
* @see https://github.com/webgptorg/promptbook
|
|
53
51
|
*/
|
|
54
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.114.0-
|
|
52
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.114.0-3';
|
|
55
53
|
/**
|
|
56
54
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
57
55
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -2951,6 +2949,13 @@
|
|
|
2951
2949
|
* Environment variable read by the shell wrapper to tee live output into the temporary runtime log file.
|
|
2952
2950
|
*/
|
|
2953
2951
|
const PTBK_CODER_LOG_FILE_ENV_NAME = 'PTBK_CODER_LOG_FILE';
|
|
2952
|
+
/**
|
|
2953
|
+
* Log line which separates the raw script input from the raw script output of one execution section.
|
|
2954
|
+
*
|
|
2955
|
+
* Readers of a runtime log split on this marker to look only at what the harness really produced,
|
|
2956
|
+
* without the generated script and the prompt it embeds.
|
|
2957
|
+
*/
|
|
2958
|
+
const SCRIPT_EXECUTION_LOG_RAW_OUTPUT_MARKER = '--- raw output ---';
|
|
2954
2959
|
/**
|
|
2955
2960
|
* Small bash wrapper that preserves stdout/stderr streams while teeing both into the runtime log file.
|
|
2956
2961
|
*/
|
|
@@ -2986,7 +2991,7 @@
|
|
|
2986
2991
|
--- raw input ---
|
|
2987
2992
|
${block(normalizedInput)}
|
|
2988
2993
|
|
|
2989
|
-
|
|
2994
|
+
${SCRIPT_EXECUTION_LOG_RAW_OUTPUT_MARKER}
|
|
2990
2995
|
`);
|
|
2991
2996
|
await promises.appendFile(logPath, `${logSection}\n`, 'utf-8');
|
|
2992
2997
|
}
|
|
@@ -32918,6 +32923,41 @@
|
|
|
32918
32923
|
`;
|
|
32919
32924
|
}
|
|
32920
32925
|
|
|
32926
|
+
/**
|
|
32927
|
+
* Creates a loader which imports one module on the first call and reuses the very same module afterwards
|
|
32928
|
+
*
|
|
32929
|
+
* Note: [🐌] Heavy third-party dependencies are imported lazily to keep the startup of the Promptbook CLI fast.
|
|
32930
|
+
* A statically imported dependency is loaded every single time the bundle is loaded, even when the running
|
|
32931
|
+
* command never touches it. A lazily imported dependency is loaded only when the feature is really used.
|
|
32932
|
+
*
|
|
32933
|
+
* @example
|
|
32934
|
+
* const loadJsdomModule = createLazyModuleLoader(() => import('jsdom'));
|
|
32935
|
+
* const { JSDOM } = await loadJsdomModule();
|
|
32936
|
+
*
|
|
32937
|
+
* @private internal utility of Promptbook
|
|
32938
|
+
*/
|
|
32939
|
+
function createLazyModuleLoader(importModule) {
|
|
32940
|
+
let importedModulePromise = null;
|
|
32941
|
+
return function loadModule() {
|
|
32942
|
+
if (importedModulePromise === null) {
|
|
32943
|
+
importedModulePromise = importModule();
|
|
32944
|
+
}
|
|
32945
|
+
return importedModulePromise;
|
|
32946
|
+
};
|
|
32947
|
+
}
|
|
32948
|
+
// Note: [🐌] Do not convert the lazy `import(...)` calls back to static `import` statements, it would bring back the
|
|
32949
|
+
// slow startup of the `ptbk` CLI utility
|
|
32950
|
+
|
|
32951
|
+
/**
|
|
32952
|
+
* Loads the OpenAI AgentKit SDK (`@openai/agents`) on demand
|
|
32953
|
+
*
|
|
32954
|
+
* Note: [🐌] The AgentKit SDK is one of the heaviest dependencies of Promptbook, loading it eagerly would slow down
|
|
32955
|
+
* every single run of the `ptbk` CLI utility even when no AgentKit agent is used
|
|
32956
|
+
*
|
|
32957
|
+
* @private internal utility of `@promptbook/openai`
|
|
32958
|
+
*/
|
|
32959
|
+
const loadOpenAiAgentsModule = createLazyModuleLoader(() => import('@openai/agents'));
|
|
32960
|
+
|
|
32921
32961
|
/**
|
|
32922
32962
|
* Constant for default model used for nested DeepSearch tool invocations.
|
|
32923
32963
|
*/
|
|
@@ -32971,11 +33011,12 @@
|
|
|
32971
33011
|
/**
|
|
32972
33012
|
* Builds the tool list for AgentKit, including hosted file search when applicable.
|
|
32973
33013
|
*/
|
|
32974
|
-
buildAgentKitTools(options) {
|
|
33014
|
+
async buildAgentKitTools(options) {
|
|
32975
33015
|
const { tools, vectorStoreId } = options;
|
|
33016
|
+
const { fileSearchTool, tool: agentKitTool } = await loadOpenAiAgentsModule();
|
|
32976
33017
|
const agentKitTools = [];
|
|
32977
33018
|
if (vectorStoreId) {
|
|
32978
|
-
agentKitTools.push(
|
|
33019
|
+
agentKitTools.push(fileSearchTool(vectorStoreId));
|
|
32979
33020
|
}
|
|
32980
33021
|
if (!tools || tools.length === 0) {
|
|
32981
33022
|
return agentKitTools;
|
|
@@ -32983,11 +33024,11 @@
|
|
|
32983
33024
|
let scriptTools = null;
|
|
32984
33025
|
for (const toolDefinition of tools) {
|
|
32985
33026
|
if (this.isDeepSearchToolDefinition(toolDefinition)) {
|
|
32986
|
-
agentKitTools.push(this.createDeepSearchAgentKitTool(toolDefinition));
|
|
33027
|
+
agentKitTools.push(await this.createDeepSearchAgentKitTool(toolDefinition));
|
|
32987
33028
|
continue;
|
|
32988
33029
|
}
|
|
32989
33030
|
scriptTools !== null && scriptTools !== void 0 ? scriptTools : (scriptTools = this.resolveScriptTools());
|
|
32990
|
-
agentKitTools.push(
|
|
33031
|
+
agentKitTools.push(agentKitTool({
|
|
32991
33032
|
name: toolDefinition.name,
|
|
32992
33033
|
description: toolDefinition.description,
|
|
32993
33034
|
parameters: this.normalizeAgentKitToolParameters(toolDefinition.parameters),
|
|
@@ -33194,12 +33235,13 @@
|
|
|
33194
33235
|
/**
|
|
33195
33236
|
* Creates the native Agent SDK tool used for `USE DEEPSEARCH`.
|
|
33196
33237
|
*/
|
|
33197
|
-
createDeepSearchAgentKitTool(toolDefinition) {
|
|
33198
|
-
const
|
|
33238
|
+
async createDeepSearchAgentKitTool(toolDefinition) {
|
|
33239
|
+
const { Agent: AgentFromKit, webSearchTool } = await loadOpenAiAgentsModule();
|
|
33240
|
+
const deepSearchAgent = new AgentFromKit({
|
|
33199
33241
|
name: 'DeepSearch',
|
|
33200
33242
|
model: DEFAULT_DEEP_SEARCH_MODEL_NAME,
|
|
33201
33243
|
instructions: this.createDeepSearchAgentInstructions(toolDefinition.description),
|
|
33202
|
-
tools: [
|
|
33244
|
+
tools: [webSearchTool({ searchContextSize: 'high' })],
|
|
33203
33245
|
});
|
|
33204
33246
|
return deepSearchAgent.asTool({
|
|
33205
33247
|
toolName: toolDefinition.name,
|
|
@@ -33763,6 +33805,14 @@
|
|
|
33763
33805
|
}
|
|
33764
33806
|
}
|
|
33765
33807
|
|
|
33808
|
+
/**
|
|
33809
|
+
* Loads the OpenAI SDK (`openai`) on demand
|
|
33810
|
+
*
|
|
33811
|
+
* Note: [🐌] Loaded lazily to keep the startup of the `ptbk` CLI utility fast
|
|
33812
|
+
*
|
|
33813
|
+
* @private internal utility of `OpenAiCompatibleRequestManager`
|
|
33814
|
+
*/
|
|
33815
|
+
const loadOpenAiModule = createLazyModuleLoader(() => import('openai'));
|
|
33766
33816
|
/**
|
|
33767
33817
|
* Manages OpenAI-compatible client creation plus shared retry and rate-limit behavior.
|
|
33768
33818
|
*
|
|
@@ -33789,7 +33839,8 @@
|
|
|
33789
33839
|
timeout: API_REQUEST_TIMEOUT,
|
|
33790
33840
|
maxRetries: CONNECTION_RETRIES_LIMIT,
|
|
33791
33841
|
};
|
|
33792
|
-
|
|
33842
|
+
const { default: OpenAI } = await loadOpenAiModule();
|
|
33843
|
+
this.client = new OpenAI(enhancedOptions);
|
|
33793
33844
|
}
|
|
33794
33845
|
return this.client;
|
|
33795
33846
|
}
|
|
@@ -36135,7 +36186,23 @@
|
|
|
36135
36186
|
});
|
|
36136
36187
|
}
|
|
36137
36188
|
|
|
36138
|
-
|
|
36189
|
+
/**
|
|
36190
|
+
* Loads `jsdom` on demand
|
|
36191
|
+
*
|
|
36192
|
+
* Note: [🐌] `jsdom` is by far the heaviest dependency of Promptbook, loading it eagerly would slow down every single
|
|
36193
|
+
* run of the `ptbk` CLI utility even when no website is scraped
|
|
36194
|
+
*
|
|
36195
|
+
* @private internal utility of `WebsiteScraper`
|
|
36196
|
+
*/
|
|
36197
|
+
const loadJsdomModule = createLazyModuleLoader(() => import('jsdom'));
|
|
36198
|
+
/**
|
|
36199
|
+
* Loads `@mozilla/readability` on demand
|
|
36200
|
+
*
|
|
36201
|
+
* Note: [🐌] Loaded lazily to keep the startup of the `ptbk` CLI utility fast
|
|
36202
|
+
*
|
|
36203
|
+
* @private internal utility of `WebsiteScraper`
|
|
36204
|
+
*/
|
|
36205
|
+
const loadReadabilityModule = createLazyModuleLoader(() => import('@mozilla/readability'));
|
|
36139
36206
|
/**
|
|
36140
36207
|
* Scraper for websites
|
|
36141
36208
|
*
|
|
@@ -36171,14 +36238,15 @@
|
|
|
36171
36238
|
if (this.tools.fs === undefined) {
|
|
36172
36239
|
throw new EnvironmentMismatchError('Can not scrape websites without filesystem tools');
|
|
36173
36240
|
}
|
|
36174
|
-
const
|
|
36241
|
+
const [{ JSDOM }, { Readability }] = await Promise.all([loadJsdomModule(), loadReadabilityModule()]);
|
|
36242
|
+
const jsdom = new JSDOM(await source.asText(), {
|
|
36175
36243
|
url: source.url,
|
|
36176
36244
|
});
|
|
36177
|
-
const reader = new
|
|
36245
|
+
const reader = new Readability(jsdom.window.document);
|
|
36178
36246
|
const article = reader.parse();
|
|
36179
36247
|
// console.log(article);
|
|
36180
36248
|
// await forTime(10000);
|
|
36181
|
-
let html = (article === null || article === void 0 ? void 0 : article.content) || (article === null || article === void 0 ? void 0 : article.textContent) || jsdom
|
|
36249
|
+
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;
|
|
36182
36250
|
// Note: Unwrap html such as it is convertable by `markdownConverter`
|
|
36183
36251
|
for (let i = 0; i < 2; i++) {
|
|
36184
36252
|
html = html.replace(/<div\s*(?:id="readability-page-\d+"\s+class="page")?>(.*)<\/div>/is, '$1');
|
|
@@ -36211,7 +36279,7 @@
|
|
|
36211
36279
|
throw error;
|
|
36212
36280
|
}
|
|
36213
36281
|
}
|
|
36214
|
-
const markdown = this.showdownConverter.makeMarkdown(html, jsdom
|
|
36282
|
+
const markdown = this.showdownConverter.makeMarkdown(html, jsdom.window.document);
|
|
36215
36283
|
return { ...cacheFilehandler, markdown };
|
|
36216
36284
|
}
|
|
36217
36285
|
/**
|
|
@@ -39434,7 +39502,8 @@
|
|
|
39434
39502
|
}
|
|
39435
39503
|
const preparedAgent = await this.prepareAgent();
|
|
39436
39504
|
(_a = preparedAgent.toolBuilder) === null || _a === void 0 ? void 0 : _a.clearRunState();
|
|
39437
|
-
const
|
|
39505
|
+
const { run } = await loadOpenAiAgentsModule();
|
|
39506
|
+
const result = await run(preparedAgent.agent, createLiteAgentPromptText(normalizedMessage, options.context, preparedAgent.modelRequirements.promptSuffix), options.signal ? { signal: options.signal } : undefined);
|
|
39438
39507
|
return formatLiteAgentOutput(result.finalOutput);
|
|
39439
39508
|
}
|
|
39440
39509
|
/**
|
|
@@ -39473,9 +39542,10 @@
|
|
|
39473
39542
|
userId: this.options.userId,
|
|
39474
39543
|
});
|
|
39475
39544
|
const client = await runtime.getClient();
|
|
39476
|
-
|
|
39545
|
+
const { Agent: AgentFromKit, fileSearchTool, setDefaultOpenAIClient, setDefaultOpenAIKey, } = await loadOpenAiAgentsModule();
|
|
39546
|
+
setDefaultOpenAIClient(client);
|
|
39477
39547
|
if (this.options.apiKey) {
|
|
39478
|
-
|
|
39548
|
+
setDefaultOpenAIKey(this.options.apiKey);
|
|
39479
39549
|
}
|
|
39480
39550
|
const toolBuilder = modelRequirements.tools && modelRequirements.tools.length > 0
|
|
39481
39551
|
? new OpenAiAgentKitExecutionToolsToolBuilder({
|
|
@@ -39493,19 +39563,19 @@
|
|
|
39493
39563
|
agentKitModelName: resolvedModelName,
|
|
39494
39564
|
})
|
|
39495
39565
|
: null;
|
|
39496
|
-
const agentTools = (toolBuilder === null || toolBuilder === void 0 ? void 0 : toolBuilder.buildAgentKitTools({
|
|
39566
|
+
const agentTools = (await (toolBuilder === null || toolBuilder === void 0 ? void 0 : toolBuilder.buildAgentKitTools({
|
|
39497
39567
|
tools: modelRequirements.tools ? [...modelRequirements.tools] : undefined,
|
|
39498
|
-
})) || [];
|
|
39568
|
+
}))) || [];
|
|
39499
39569
|
const normalizedKnowledgeSources = await normalizeLiteAgentKnowledgeSources(modelRequirements.knowledgeSources || [], resolvedSource.sourceDirectoryPath);
|
|
39500
39570
|
if (normalizedKnowledgeSources.length > 0) {
|
|
39501
39571
|
const vectorStore = await runtime.createHostedKnowledgeVectorStore({
|
|
39502
39572
|
knowledgeSources: normalizedKnowledgeSources,
|
|
39503
39573
|
name: resolvedSource.agentName,
|
|
39504
39574
|
});
|
|
39505
|
-
agentTools.unshift(
|
|
39575
|
+
agentTools.unshift(fileSearchTool(vectorStore.vectorStoreId));
|
|
39506
39576
|
}
|
|
39507
39577
|
return {
|
|
39508
|
-
agent: new
|
|
39578
|
+
agent: new AgentFromKit({
|
|
39509
39579
|
name: resolvedSource.agentName,
|
|
39510
39580
|
model: resolvedModelName,
|
|
39511
39581
|
instructions: modelRequirements.systemMessage || 'You are a helpful assistant.',
|
|
@@ -39714,6 +39784,15 @@
|
|
|
39714
39784
|
}
|
|
39715
39785
|
}
|
|
39716
39786
|
|
|
39787
|
+
/**
|
|
39788
|
+
* Loads the ZIP archive library (`jszip`) on demand
|
|
39789
|
+
*
|
|
39790
|
+
* Note: [🐌] Loaded lazily to keep the startup of the `ptbk` CLI utility fast
|
|
39791
|
+
*
|
|
39792
|
+
* @private internal utility of `loadArchive` and `saveArchive`
|
|
39793
|
+
*/
|
|
39794
|
+
const loadJsZipModule = createLazyModuleLoader(() => import('jszip'));
|
|
39795
|
+
|
|
39717
39796
|
/**
|
|
39718
39797
|
* Loads the books from the archive file with `.bookc` extension
|
|
39719
39798
|
*
|
|
@@ -39728,7 +39807,8 @@
|
|
|
39728
39807
|
throw new UnexpectedError(`Archive file must have '.bookc' extension`);
|
|
39729
39808
|
}
|
|
39730
39809
|
const data = await fs.readFile(filePath);
|
|
39731
|
-
const
|
|
39810
|
+
const { default: JSZip } = await loadJsZipModule();
|
|
39811
|
+
const archive = await JSZip.loadAsync(data);
|
|
39732
39812
|
const indexFile = archive.file('index.book.json');
|
|
39733
39813
|
if (!indexFile) {
|
|
39734
39814
|
throw new UnexpectedError(`Archive does not contain 'index.book.json' file`);
|
|
@@ -46100,8 +46180,9 @@
|
|
|
46100
46180
|
vectorStoreId,
|
|
46101
46181
|
});
|
|
46102
46182
|
}
|
|
46103
|
-
const
|
|
46104
|
-
const
|
|
46183
|
+
const { Agent: AgentFromKit } = await loadOpenAiAgentsModule();
|
|
46184
|
+
const agentKitTools = await this.buildAgentKitTools({ tools, vectorStoreId });
|
|
46185
|
+
const openAiAgentKitAgent = new AgentFromKit({
|
|
46105
46186
|
name,
|
|
46106
46187
|
model: this.agentKitModelName,
|
|
46107
46188
|
instructions: instructions || 'You are a helpful assistant.',
|
|
@@ -46146,7 +46227,8 @@
|
|
|
46146
46227
|
agentName: agentForRun.name,
|
|
46147
46228
|
input: inputItems,
|
|
46148
46229
|
};
|
|
46149
|
-
const
|
|
46230
|
+
const { run } = await loadOpenAiAgentsModule();
|
|
46231
|
+
const streamResult = await run(agentForRun, inputItems, {
|
|
46150
46232
|
stream: true,
|
|
46151
46233
|
maxTurns: 200,
|
|
46152
46234
|
context: {
|
|
@@ -46288,11 +46370,12 @@
|
|
|
46288
46370
|
* Ensures the AgentKit SDK is wired to the OpenAI client and API key.
|
|
46289
46371
|
*/
|
|
46290
46372
|
async ensureAgentKitDefaults() {
|
|
46373
|
+
const { setDefaultOpenAIClient, setDefaultOpenAIKey } = await loadOpenAiAgentsModule();
|
|
46291
46374
|
const client = await this.getClient();
|
|
46292
|
-
|
|
46375
|
+
setDefaultOpenAIClient(client);
|
|
46293
46376
|
const apiKey = this.agentKitOptions.apiKey;
|
|
46294
46377
|
if (apiKey && typeof apiKey === 'string') {
|
|
46295
|
-
|
|
46378
|
+
setDefaultOpenAIKey(apiKey);
|
|
46296
46379
|
}
|
|
46297
46380
|
}
|
|
46298
46381
|
/**
|