@promptbook/openai 0.114.0-1 → 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/README.md +16 -15
- package/esm/index.es.js +66 -11
- package/esm/index.es.js.map +1 -1
- package/esm/src/book-2.0/book-language-documentation/BookLanguageManualDictionary.d.ts +1 -15
- package/esm/src/book-2.0/book-language-documentation/getBookLanguageManualCommitmentGroups.d.ts +1 -1
- package/esm/src/book-2.0/book-language-documentation/renderCommitmentCatalogSection.d.ts +0 -4
- package/esm/src/book-components/Chat/utils/$provideServerDomWindow.d.ts +11 -0
- package/esm/src/book-components/Chat/utils/renderMarkdown.d.ts +7 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/createAgentsServerRuntimeEnvironment.d.ts +7 -0
- package/esm/src/cli/cli-commands/coder/agentCodingFile.d.ts +2 -3
- package/esm/src/cli/cli-commands/coder/ping.d.ts +10 -0
- package/esm/src/cli/cli-commands/coder/ping.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/coder.d.ts +1 -0
- 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 +6 -2
- package/umd/index.umd.js +77 -20
- package/umd/index.umd.js.map +1 -1
- package/umd/src/book-2.0/book-language-documentation/BookLanguageManualDictionary.d.ts +1 -15
- package/umd/src/book-2.0/book-language-documentation/getBookLanguageManualCommitmentGroups.d.ts +1 -1
- package/umd/src/book-2.0/book-language-documentation/renderCommitmentCatalogSection.d.ts +0 -4
- package/umd/src/book-components/Chat/utils/$provideServerDomWindow.d.ts +11 -0
- package/umd/src/book-components/Chat/utils/renderMarkdown.d.ts +7 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/createAgentsServerRuntimeEnvironment.d.ts +7 -0
- package/umd/src/cli/cli-commands/coder/agentCodingFile.d.ts +2 -3
- package/umd/src/cli/cli-commands/coder/ping.d.ts +10 -0
- package/umd/src/cli/cli-commands/coder/ping.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/coder.d.ts +1 -0
- 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/README.md
CHANGED
|
@@ -820,26 +820,27 @@ ptbk coder verify
|
|
|
820
820
|
| ------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | ------ | ---- | ----- | ------------------------------------------------------------------------ |
|
|
821
821
|
| `ptbk coder init` | Creates `prompts/`, `prompts/done/`, the project-generic template files materialized in `prompts/templates/` (currently `common.md`), and a starter `AGENTS.md`; ensures `.env` contains `CODING_AGENT_GIT_NAME`, `CODING_AGENT_GIT_EMAIL`, and `CODING_AGENT_GIT_SIGNING_KEY`; adds helper coder scripts to `package.json`; ensures `.gitignore` contains `/.promptbook`; and configures `.vscode/settings.json` to save pasted prompt images into `prompts/screenshots/`. |
|
|
822
822
|
| `ptbk coder generate-boilerplates` | Creates new prompt markdown files with fresh emoji tags so you can quickly fill in coding tasks; `--template` accepts either a built-in alias or a markdown file path relative to the project root. |
|
|
823
|
-
| `ptbk coder run` | Picks the next ready prompt, appends optional context, runs it through the selected coding agent, can optionally verify each attempt with a shell test command and feed failing output back for retries, then marks success or failure, commits the result, and pushes only when `--auto-push` is enabled.
|
|
823
|
+
| `ptbk coder run` | Picks the next ready prompt, can run tests before coding to stop or repair pre-existing failures, appends optional context, runs it through the selected coding agent, can optionally verify each attempt with a shell test command and feed failing output back for retries, then marks success or failure, commits the result, and pushes only when `--auto-push` is enabled. |
|
|
824
824
|
| `ptbk coder find-refactor-candidates` | Scans the repository for oversized or overpacked files and writes prompt files for likely refactors; `--level <xlow | low | medium | high | xhigh | extreme>` ranges from a very benevolent scan to a very aggressive sweep. |
|
|
825
825
|
| `ptbk coder verify` | Walks through completed prompts, archives truly finished work, and adds follow-up repair prompts for unfinished results. |
|
|
826
826
|
|
|
827
827
|
#### Most useful `ptbk coder run` flags
|
|
828
828
|
|
|
829
|
-
| Flag | Purpose
|
|
830
|
-
| -------------------------- |
|
|
831
|
-
| `--harness <name>` | Selects the coding harness.
|
|
832
|
-
| `--model <model>` | Chooses the runner model; required for `openai-codex` and `gemini`, optional for `github-copilot`.
|
|
833
|
-
| `--context <text-or-file>` | Appends extra instructions inline or from a file like `AGENTS.md`.
|
|
834
|
-
| `--test <command>` | Runs a verification command after each prompt attempt and feeds failing output back for retries.
|
|
835
|
-
| `--
|
|
836
|
-
| `--
|
|
837
|
-
| `--
|
|
838
|
-
| `--
|
|
839
|
-
| `--
|
|
840
|
-
| `--
|
|
841
|
-
| `--
|
|
842
|
-
| `--auto-
|
|
829
|
+
| Flag | Purpose |
|
|
830
|
+
| -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
831
|
+
| `--harness <name>` | Selects the coding harness. |
|
|
832
|
+
| `--model <model>` | Chooses the runner model; required for `openai-codex` and `gemini`, optional for `github-copilot`. |
|
|
833
|
+
| `--context <text-or-file>` | Appends extra instructions inline or from a file like `AGENTS.md`. |
|
|
834
|
+
| `--test <command>` | Runs a verification command after each prompt attempt and feeds failing output back for retries. |
|
|
835
|
+
| `--test-before <mode>` | Runs tests before coding: `no` (default), `yes-and-fail` (stop with results), or `yes-and-fix` (create one repair prompt first); defaults to `npm test` when enabled without `--test`. |
|
|
836
|
+
| `--thinking-level <level>` | Sets reasoning effort for supported runners. |
|
|
837
|
+
| `--no-auto` | Waits for user confirmation before each prompt instead of running automatically through the queue. |
|
|
838
|
+
| `--ignore-git-changes` | Disables the clean-working-tree guard. |
|
|
839
|
+
| `--priority <n>` | Runs only prompts at or above the given priority. |
|
|
840
|
+
| `--dry-run` | Prints which prompts are ready instead of executing them. |
|
|
841
|
+
| `--allow-credits` | Lets OpenAI Codex spend credits when required. |
|
|
842
|
+
| `--auto-push` | Pushes each successful coding-agent commit to the configured remote. |
|
|
843
|
+
| `--auto-migrate` | Runs testing-server database migrations after each successful prompt. |
|
|
843
844
|
|
|
844
845
|
#### Typical usage pattern
|
|
845
846
|
|
package/esm/index.es.js
CHANGED
|
@@ -2,9 +2,6 @@ import { spaceTrim as spaceTrim$1 } from 'spacetrim';
|
|
|
2
2
|
import CryptoJS from 'crypto-js';
|
|
3
3
|
import colors from 'colors';
|
|
4
4
|
import Bottleneck from 'bottleneck';
|
|
5
|
-
import OpenAI from 'openai';
|
|
6
|
-
import { io } from 'socket.io-client';
|
|
7
|
-
import { fileSearchTool, tool, Agent, webSearchTool, run, setDefaultOpenAIClient, setDefaultOpenAIKey } from '@openai/agents';
|
|
8
5
|
|
|
9
6
|
// ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
|
|
10
7
|
/**
|
|
@@ -20,7 +17,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
20
17
|
* @generated
|
|
21
18
|
* @see https://github.com/webgptorg/promptbook
|
|
22
19
|
*/
|
|
23
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.114.0-
|
|
20
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.114.0-3';
|
|
24
21
|
/**
|
|
25
22
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
26
23
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -4820,6 +4817,39 @@ class OpenAiCompatibleNonChatPromptCaller {
|
|
|
4820
4817
|
}
|
|
4821
4818
|
}
|
|
4822
4819
|
|
|
4820
|
+
/**
|
|
4821
|
+
* Creates a loader which imports one module on the first call and reuses the very same module afterwards
|
|
4822
|
+
*
|
|
4823
|
+
* Note: [🐌] Heavy third-party dependencies are imported lazily to keep the startup of the Promptbook CLI fast.
|
|
4824
|
+
* A statically imported dependency is loaded every single time the bundle is loaded, even when the running
|
|
4825
|
+
* command never touches it. A lazily imported dependency is loaded only when the feature is really used.
|
|
4826
|
+
*
|
|
4827
|
+
* @example
|
|
4828
|
+
* const loadJsdomModule = createLazyModuleLoader(() => import('jsdom'));
|
|
4829
|
+
* const { JSDOM } = await loadJsdomModule();
|
|
4830
|
+
*
|
|
4831
|
+
* @private internal utility of Promptbook
|
|
4832
|
+
*/
|
|
4833
|
+
function createLazyModuleLoader(importModule) {
|
|
4834
|
+
let importedModulePromise = null;
|
|
4835
|
+
return function loadModule() {
|
|
4836
|
+
if (importedModulePromise === null) {
|
|
4837
|
+
importedModulePromise = importModule();
|
|
4838
|
+
}
|
|
4839
|
+
return importedModulePromise;
|
|
4840
|
+
};
|
|
4841
|
+
}
|
|
4842
|
+
// Note: [🐌] Do not convert the lazy `import(...)` calls back to static `import` statements, it would bring back the
|
|
4843
|
+
// slow startup of the `ptbk` CLI utility
|
|
4844
|
+
|
|
4845
|
+
/**
|
|
4846
|
+
* Loads the OpenAI SDK (`openai`) on demand
|
|
4847
|
+
*
|
|
4848
|
+
* Note: [🐌] Loaded lazily to keep the startup of the `ptbk` CLI utility fast
|
|
4849
|
+
*
|
|
4850
|
+
* @private internal utility of `OpenAiCompatibleRequestManager`
|
|
4851
|
+
*/
|
|
4852
|
+
const loadOpenAiModule = createLazyModuleLoader(() => import('openai'));
|
|
4823
4853
|
/**
|
|
4824
4854
|
* Manages OpenAI-compatible client creation plus shared retry and rate-limit behavior.
|
|
4825
4855
|
*
|
|
@@ -4846,6 +4876,7 @@ class OpenAiCompatibleRequestManager {
|
|
|
4846
4876
|
timeout: API_REQUEST_TIMEOUT,
|
|
4847
4877
|
maxRetries: CONNECTION_RETRIES_LIMIT,
|
|
4848
4878
|
};
|
|
4879
|
+
const { default: OpenAI } = await loadOpenAiModule();
|
|
4849
4880
|
this.client = new OpenAI(enhancedOptions);
|
|
4850
4881
|
}
|
|
4851
4882
|
return this.client;
|
|
@@ -7445,6 +7476,14 @@ function isValidUrl(url) {
|
|
|
7445
7476
|
}
|
|
7446
7477
|
}
|
|
7447
7478
|
|
|
7479
|
+
/**
|
|
7480
|
+
* Loads the Socket.io client (`socket.io-client`) on demand
|
|
7481
|
+
*
|
|
7482
|
+
* Note: [🐌] Loaded lazily to keep the startup of the `ptbk` CLI utility fast
|
|
7483
|
+
*
|
|
7484
|
+
* @private internal utility of `createRemoteClient`
|
|
7485
|
+
*/
|
|
7486
|
+
const loadSocketIoClientModule = createLazyModuleLoader(() => import('socket.io-client'));
|
|
7448
7487
|
/**
|
|
7449
7488
|
* Creates a connection to the remote proxy server.
|
|
7450
7489
|
*
|
|
@@ -7473,6 +7512,7 @@ async function createRemoteClient(options) {
|
|
|
7473
7512
|
|
|
7474
7513
|
`));
|
|
7475
7514
|
}
|
|
7515
|
+
const { io } = await loadSocketIoClientModule();
|
|
7476
7516
|
return new Promise((resolve, reject) => {
|
|
7477
7517
|
const socket = io(remoteServerUrl, {
|
|
7478
7518
|
retries: CONNECTION_RETRIES_LIMIT,
|
|
@@ -8126,6 +8166,16 @@ class OpenAiAgentKitExecutionToolsOutputTypeMapper {
|
|
|
8126
8166
|
}
|
|
8127
8167
|
}
|
|
8128
8168
|
|
|
8169
|
+
/**
|
|
8170
|
+
* Loads the OpenAI AgentKit SDK (`@openai/agents`) on demand
|
|
8171
|
+
*
|
|
8172
|
+
* Note: [🐌] The AgentKit SDK is one of the heaviest dependencies of Promptbook, loading it eagerly would slow down
|
|
8173
|
+
* every single run of the `ptbk` CLI utility even when no AgentKit agent is used
|
|
8174
|
+
*
|
|
8175
|
+
* @private internal utility of `@promptbook/openai`
|
|
8176
|
+
*/
|
|
8177
|
+
const loadOpenAiAgentsModule = createLazyModuleLoader(() => import('@openai/agents'));
|
|
8178
|
+
|
|
8129
8179
|
/**
|
|
8130
8180
|
* Constant for default model used for nested DeepSearch tool invocations.
|
|
8131
8181
|
*/
|
|
@@ -8179,8 +8229,9 @@ class OpenAiAgentKitExecutionToolsToolBuilder {
|
|
|
8179
8229
|
/**
|
|
8180
8230
|
* Builds the tool list for AgentKit, including hosted file search when applicable.
|
|
8181
8231
|
*/
|
|
8182
|
-
buildAgentKitTools(options) {
|
|
8232
|
+
async buildAgentKitTools(options) {
|
|
8183
8233
|
const { tools, vectorStoreId } = options;
|
|
8234
|
+
const { fileSearchTool, tool: agentKitTool } = await loadOpenAiAgentsModule();
|
|
8184
8235
|
const agentKitTools = [];
|
|
8185
8236
|
if (vectorStoreId) {
|
|
8186
8237
|
agentKitTools.push(fileSearchTool(vectorStoreId));
|
|
@@ -8191,11 +8242,11 @@ class OpenAiAgentKitExecutionToolsToolBuilder {
|
|
|
8191
8242
|
let scriptTools = null;
|
|
8192
8243
|
for (const toolDefinition of tools) {
|
|
8193
8244
|
if (this.isDeepSearchToolDefinition(toolDefinition)) {
|
|
8194
|
-
agentKitTools.push(this.createDeepSearchAgentKitTool(toolDefinition));
|
|
8245
|
+
agentKitTools.push(await this.createDeepSearchAgentKitTool(toolDefinition));
|
|
8195
8246
|
continue;
|
|
8196
8247
|
}
|
|
8197
8248
|
scriptTools !== null && scriptTools !== void 0 ? scriptTools : (scriptTools = this.resolveScriptTools());
|
|
8198
|
-
agentKitTools.push(
|
|
8249
|
+
agentKitTools.push(agentKitTool({
|
|
8199
8250
|
name: toolDefinition.name,
|
|
8200
8251
|
description: toolDefinition.description,
|
|
8201
8252
|
parameters: this.normalizeAgentKitToolParameters(toolDefinition.parameters),
|
|
@@ -8402,8 +8453,9 @@ class OpenAiAgentKitExecutionToolsToolBuilder {
|
|
|
8402
8453
|
/**
|
|
8403
8454
|
* Creates the native Agent SDK tool used for `USE DEEPSEARCH`.
|
|
8404
8455
|
*/
|
|
8405
|
-
createDeepSearchAgentKitTool(toolDefinition) {
|
|
8406
|
-
const
|
|
8456
|
+
async createDeepSearchAgentKitTool(toolDefinition) {
|
|
8457
|
+
const { Agent: AgentFromKit, webSearchTool } = await loadOpenAiAgentsModule();
|
|
8458
|
+
const deepSearchAgent = new AgentFromKit({
|
|
8407
8459
|
name: 'DeepSearch',
|
|
8408
8460
|
model: DEFAULT_DEEP_SEARCH_MODEL_NAME,
|
|
8409
8461
|
instructions: this.createDeepSearchAgentInstructions(toolDefinition.description),
|
|
@@ -8616,8 +8668,9 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
8616
8668
|
vectorStoreId,
|
|
8617
8669
|
});
|
|
8618
8670
|
}
|
|
8619
|
-
const
|
|
8620
|
-
const
|
|
8671
|
+
const { Agent: AgentFromKit } = await loadOpenAiAgentsModule();
|
|
8672
|
+
const agentKitTools = await this.buildAgentKitTools({ tools, vectorStoreId });
|
|
8673
|
+
const openAiAgentKitAgent = new AgentFromKit({
|
|
8621
8674
|
name,
|
|
8622
8675
|
model: this.agentKitModelName,
|
|
8623
8676
|
instructions: instructions || 'You are a helpful assistant.',
|
|
@@ -8662,6 +8715,7 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
8662
8715
|
agentName: agentForRun.name,
|
|
8663
8716
|
input: inputItems,
|
|
8664
8717
|
};
|
|
8718
|
+
const { run } = await loadOpenAiAgentsModule();
|
|
8665
8719
|
const streamResult = await run(agentForRun, inputItems, {
|
|
8666
8720
|
stream: true,
|
|
8667
8721
|
maxTurns: 200,
|
|
@@ -8804,6 +8858,7 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
8804
8858
|
* Ensures the AgentKit SDK is wired to the OpenAI client and API key.
|
|
8805
8859
|
*/
|
|
8806
8860
|
async ensureAgentKitDefaults() {
|
|
8861
|
+
const { setDefaultOpenAIClient, setDefaultOpenAIKey } = await loadOpenAiAgentsModule();
|
|
8807
8862
|
const client = await this.getClient();
|
|
8808
8863
|
setDefaultOpenAIClient(client);
|
|
8809
8864
|
const apiKey = this.agentKitOptions.apiKey;
|