@promptbook/browser 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 +57 -10
- 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 +67 -19
- 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
|
@@ -546,26 +546,27 @@ ptbk coder verify
|
|
|
546
546
|
| ------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | ------ | ---- | ----- | ------------------------------------------------------------------------ |
|
|
547
547
|
| `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/`. |
|
|
548
548
|
| `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. |
|
|
549
|
-
| `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.
|
|
549
|
+
| `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. |
|
|
550
550
|
| `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. |
|
|
551
551
|
| `ptbk coder verify` | Walks through completed prompts, archives truly finished work, and adds follow-up repair prompts for unfinished results. |
|
|
552
552
|
|
|
553
553
|
#### Most useful `ptbk coder run` flags
|
|
554
554
|
|
|
555
|
-
| Flag | Purpose
|
|
556
|
-
| -------------------------- |
|
|
557
|
-
| `--harness <name>` | Selects the coding harness.
|
|
558
|
-
| `--model <model>` | Chooses the runner model; required for `openai-codex` and `gemini`, optional for `github-copilot`.
|
|
559
|
-
| `--context <text-or-file>` | Appends extra instructions inline or from a file like `AGENTS.md`.
|
|
560
|
-
| `--test <command>` | Runs a verification command after each prompt attempt and feeds failing output back for retries.
|
|
561
|
-
| `--
|
|
562
|
-
| `--
|
|
563
|
-
| `--
|
|
564
|
-
| `--
|
|
565
|
-
| `--
|
|
566
|
-
| `--
|
|
567
|
-
| `--
|
|
568
|
-
| `--auto-
|
|
555
|
+
| Flag | Purpose |
|
|
556
|
+
| -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
557
|
+
| `--harness <name>` | Selects the coding harness. |
|
|
558
|
+
| `--model <model>` | Chooses the runner model; required for `openai-codex` and `gemini`, optional for `github-copilot`. |
|
|
559
|
+
| `--context <text-or-file>` | Appends extra instructions inline or from a file like `AGENTS.md`. |
|
|
560
|
+
| `--test <command>` | Runs a verification command after each prompt attempt and feeds failing output back for retries. |
|
|
561
|
+
| `--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`. |
|
|
562
|
+
| `--thinking-level <level>` | Sets reasoning effort for supported runners. |
|
|
563
|
+
| `--no-auto` | Waits for user confirmation before each prompt instead of running automatically through the queue. |
|
|
564
|
+
| `--ignore-git-changes` | Disables the clean-working-tree guard. |
|
|
565
|
+
| `--priority <n>` | Runs only prompts at or above the given priority. |
|
|
566
|
+
| `--dry-run` | Prints which prompts are ready instead of executing them. |
|
|
567
|
+
| `--allow-credits` | Lets OpenAI Codex spend credits when required. |
|
|
568
|
+
| `--auto-push` | Pushes each successful coding-agent commit to the configured remote. |
|
|
569
|
+
| `--auto-migrate` | Runs testing-server database migrations after each successful prompt. |
|
|
569
570
|
|
|
570
571
|
#### Typical usage pattern
|
|
571
572
|
|
package/esm/index.es.js
CHANGED
|
@@ -10,10 +10,8 @@ import { lookup, extension } from 'mime-types';
|
|
|
10
10
|
import { forTime } from 'waitasecond';
|
|
11
11
|
import sha256 from 'crypto-js/sha256';
|
|
12
12
|
import papaparse from 'papaparse';
|
|
13
|
-
import { fileSearchTool, tool, Agent as Agent$1, webSearchTool, run, setDefaultOpenAIClient, setDefaultOpenAIKey } from '@openai/agents';
|
|
14
13
|
import colors from 'colors';
|
|
15
14
|
import Bottleneck from 'bottleneck';
|
|
16
|
-
import OpenAI from 'openai';
|
|
17
15
|
|
|
18
16
|
// ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
|
|
19
17
|
/**
|
|
@@ -29,7 +27,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
29
27
|
* @generated
|
|
30
28
|
* @see https://github.com/webgptorg/promptbook
|
|
31
29
|
*/
|
|
32
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.114.0-
|
|
30
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.114.0-3';
|
|
33
31
|
/**
|
|
34
32
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
35
33
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -31158,6 +31156,41 @@ function buildToolInvocationScript(options) {
|
|
|
31158
31156
|
`;
|
|
31159
31157
|
}
|
|
31160
31158
|
|
|
31159
|
+
/**
|
|
31160
|
+
* Creates a loader which imports one module on the first call and reuses the very same module afterwards
|
|
31161
|
+
*
|
|
31162
|
+
* Note: [🐌] Heavy third-party dependencies are imported lazily to keep the startup of the Promptbook CLI fast.
|
|
31163
|
+
* A statically imported dependency is loaded every single time the bundle is loaded, even when the running
|
|
31164
|
+
* command never touches it. A lazily imported dependency is loaded only when the feature is really used.
|
|
31165
|
+
*
|
|
31166
|
+
* @example
|
|
31167
|
+
* const loadJsdomModule = createLazyModuleLoader(() => import('jsdom'));
|
|
31168
|
+
* const { JSDOM } = await loadJsdomModule();
|
|
31169
|
+
*
|
|
31170
|
+
* @private internal utility of Promptbook
|
|
31171
|
+
*/
|
|
31172
|
+
function createLazyModuleLoader(importModule) {
|
|
31173
|
+
let importedModulePromise = null;
|
|
31174
|
+
return function loadModule() {
|
|
31175
|
+
if (importedModulePromise === null) {
|
|
31176
|
+
importedModulePromise = importModule();
|
|
31177
|
+
}
|
|
31178
|
+
return importedModulePromise;
|
|
31179
|
+
};
|
|
31180
|
+
}
|
|
31181
|
+
// Note: [🐌] Do not convert the lazy `import(...)` calls back to static `import` statements, it would bring back the
|
|
31182
|
+
// slow startup of the `ptbk` CLI utility
|
|
31183
|
+
|
|
31184
|
+
/**
|
|
31185
|
+
* Loads the OpenAI AgentKit SDK (`@openai/agents`) on demand
|
|
31186
|
+
*
|
|
31187
|
+
* Note: [🐌] The AgentKit SDK is one of the heaviest dependencies of Promptbook, loading it eagerly would slow down
|
|
31188
|
+
* every single run of the `ptbk` CLI utility even when no AgentKit agent is used
|
|
31189
|
+
*
|
|
31190
|
+
* @private internal utility of `@promptbook/openai`
|
|
31191
|
+
*/
|
|
31192
|
+
const loadOpenAiAgentsModule = createLazyModuleLoader(() => import('@openai/agents'));
|
|
31193
|
+
|
|
31161
31194
|
/**
|
|
31162
31195
|
* Constant for default model used for nested DeepSearch tool invocations.
|
|
31163
31196
|
*/
|
|
@@ -31211,8 +31244,9 @@ class OpenAiAgentKitExecutionToolsToolBuilder {
|
|
|
31211
31244
|
/**
|
|
31212
31245
|
* Builds the tool list for AgentKit, including hosted file search when applicable.
|
|
31213
31246
|
*/
|
|
31214
|
-
buildAgentKitTools(options) {
|
|
31247
|
+
async buildAgentKitTools(options) {
|
|
31215
31248
|
const { tools, vectorStoreId } = options;
|
|
31249
|
+
const { fileSearchTool, tool: agentKitTool } = await loadOpenAiAgentsModule();
|
|
31216
31250
|
const agentKitTools = [];
|
|
31217
31251
|
if (vectorStoreId) {
|
|
31218
31252
|
agentKitTools.push(fileSearchTool(vectorStoreId));
|
|
@@ -31223,11 +31257,11 @@ class OpenAiAgentKitExecutionToolsToolBuilder {
|
|
|
31223
31257
|
let scriptTools = null;
|
|
31224
31258
|
for (const toolDefinition of tools) {
|
|
31225
31259
|
if (this.isDeepSearchToolDefinition(toolDefinition)) {
|
|
31226
|
-
agentKitTools.push(this.createDeepSearchAgentKitTool(toolDefinition));
|
|
31260
|
+
agentKitTools.push(await this.createDeepSearchAgentKitTool(toolDefinition));
|
|
31227
31261
|
continue;
|
|
31228
31262
|
}
|
|
31229
31263
|
scriptTools !== null && scriptTools !== void 0 ? scriptTools : (scriptTools = this.resolveScriptTools());
|
|
31230
|
-
agentKitTools.push(
|
|
31264
|
+
agentKitTools.push(agentKitTool({
|
|
31231
31265
|
name: toolDefinition.name,
|
|
31232
31266
|
description: toolDefinition.description,
|
|
31233
31267
|
parameters: this.normalizeAgentKitToolParameters(toolDefinition.parameters),
|
|
@@ -31434,8 +31468,9 @@ class OpenAiAgentKitExecutionToolsToolBuilder {
|
|
|
31434
31468
|
/**
|
|
31435
31469
|
* Creates the native Agent SDK tool used for `USE DEEPSEARCH`.
|
|
31436
31470
|
*/
|
|
31437
|
-
createDeepSearchAgentKitTool(toolDefinition) {
|
|
31438
|
-
const
|
|
31471
|
+
async createDeepSearchAgentKitTool(toolDefinition) {
|
|
31472
|
+
const { Agent: AgentFromKit, webSearchTool } = await loadOpenAiAgentsModule();
|
|
31473
|
+
const deepSearchAgent = new AgentFromKit({
|
|
31439
31474
|
name: 'DeepSearch',
|
|
31440
31475
|
model: DEFAULT_DEEP_SEARCH_MODEL_NAME,
|
|
31441
31476
|
instructions: this.createDeepSearchAgentInstructions(toolDefinition.description),
|
|
@@ -32761,6 +32796,14 @@ class OpenAiCompatibleNonChatPromptCaller {
|
|
|
32761
32796
|
}
|
|
32762
32797
|
}
|
|
32763
32798
|
|
|
32799
|
+
/**
|
|
32800
|
+
* Loads the OpenAI SDK (`openai`) on demand
|
|
32801
|
+
*
|
|
32802
|
+
* Note: [🐌] Loaded lazily to keep the startup of the `ptbk` CLI utility fast
|
|
32803
|
+
*
|
|
32804
|
+
* @private internal utility of `OpenAiCompatibleRequestManager`
|
|
32805
|
+
*/
|
|
32806
|
+
const loadOpenAiModule = createLazyModuleLoader(() => import('openai'));
|
|
32764
32807
|
/**
|
|
32765
32808
|
* Manages OpenAI-compatible client creation plus shared retry and rate-limit behavior.
|
|
32766
32809
|
*
|
|
@@ -32787,6 +32830,7 @@ class OpenAiCompatibleRequestManager {
|
|
|
32787
32830
|
timeout: API_REQUEST_TIMEOUT,
|
|
32788
32831
|
maxRetries: CONNECTION_RETRIES_LIMIT,
|
|
32789
32832
|
};
|
|
32833
|
+
const { default: OpenAI } = await loadOpenAiModule();
|
|
32790
32834
|
this.client = new OpenAI(enhancedOptions);
|
|
32791
32835
|
}
|
|
32792
32836
|
return this.client;
|
|
@@ -34934,8 +34978,9 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
34934
34978
|
vectorStoreId,
|
|
34935
34979
|
});
|
|
34936
34980
|
}
|
|
34937
|
-
const
|
|
34938
|
-
const
|
|
34981
|
+
const { Agent: AgentFromKit } = await loadOpenAiAgentsModule();
|
|
34982
|
+
const agentKitTools = await this.buildAgentKitTools({ tools, vectorStoreId });
|
|
34983
|
+
const openAiAgentKitAgent = new AgentFromKit({
|
|
34939
34984
|
name,
|
|
34940
34985
|
model: this.agentKitModelName,
|
|
34941
34986
|
instructions: instructions || 'You are a helpful assistant.',
|
|
@@ -34980,6 +35025,7 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
34980
35025
|
agentName: agentForRun.name,
|
|
34981
35026
|
input: inputItems,
|
|
34982
35027
|
};
|
|
35028
|
+
const { run } = await loadOpenAiAgentsModule();
|
|
34983
35029
|
const streamResult = await run(agentForRun, inputItems, {
|
|
34984
35030
|
stream: true,
|
|
34985
35031
|
maxTurns: 200,
|
|
@@ -35122,6 +35168,7 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
35122
35168
|
* Ensures the AgentKit SDK is wired to the OpenAI client and API key.
|
|
35123
35169
|
*/
|
|
35124
35170
|
async ensureAgentKitDefaults() {
|
|
35171
|
+
const { setDefaultOpenAIClient, setDefaultOpenAIKey } = await loadOpenAiAgentsModule();
|
|
35125
35172
|
const client = await this.getClient();
|
|
35126
35173
|
setDefaultOpenAIClient(client);
|
|
35127
35174
|
const apiKey = this.agentKitOptions.apiKey;
|