@promptbook/cli 0.112.0-113 → 0.112.0-114
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/apps/agents-server/src/app/agents/[agentName]/api/user-chats/[chatId]/stream/route.ts +85 -56
- package/apps/agents-server/src/app/agents/[agentName]/chat/useAgentChatHistorySyncEffects.ts +7 -13
- package/apps/agents-server/src/database/migrations/2026-06-1300-user-chat-active-read-indexes.sql +7 -0
- package/apps/agents-server/src/utils/agentRouting/resolveAgentRouteTarget.ts +38 -0
- package/apps/agents-server/src/utils/userChat/createImmediateUserChatAnswerModelRequirements.ts +15 -12
- package/apps/agents-server/src/utils/userChat/createUserChatDetailPayload.ts +33 -18
- package/apps/agents-server/src/utils/userChat/hasPotentiallyPendingAssistantMessages.ts +26 -0
- package/apps/agents-server/src/utils/userChat/runImmediateUserChatAnswer.ts +1 -1
- package/esm/index.es.js +60 -24
- package/esm/index.es.js.map +1 -1
- package/esm/scripts/run-codex-prompts/common/runGoScript/printLiveScriptChunk.d.ts +4 -0
- package/esm/src/cli/cli-commands/agent/agentCliOptions.d.ts +10 -1
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/book-3.0/LiteAgent.ts +15 -10
- package/src/cli/cli-commands/agent/agentCliOptions.ts +33 -4
- package/src/cli/cli-commands/agent/chat.ts +2 -2
- package/src/cli/cli-commands/agent/exec.ts +2 -2
- package/src/cli/cli-commands/agent.ts +0 -1
- package/src/other/templates/getTemplatesPipelineCollection.ts +767 -853
- package/src/version.ts +2 -2
- package/src/versions.txt +1 -0
- package/umd/index.umd.js +60 -24
- package/umd/index.umd.js.map +1 -1
- package/umd/scripts/run-codex-prompts/common/runGoScript/printLiveScriptChunk.d.ts +4 -0
- package/umd/src/cli/cli-commands/agent/agentCliOptions.d.ts +10 -1
- package/umd/src/version.d.ts +1 -1
package/esm/index.es.js
CHANGED
|
@@ -58,7 +58,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
58
58
|
* @generated
|
|
59
59
|
* @see https://github.com/webgptorg/promptbook
|
|
60
60
|
*/
|
|
61
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
61
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-114';
|
|
62
62
|
/**
|
|
63
63
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
64
64
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -1908,10 +1908,13 @@ class NotAllowed extends Error {
|
|
|
1908
1908
|
*
|
|
1909
1909
|
* @private internal utility of `ptbk agent`
|
|
1910
1910
|
*/
|
|
1911
|
-
function normalizeAgentCommandRunnerOptions(cliOptions) {
|
|
1912
|
-
return
|
|
1913
|
-
|
|
1914
|
-
|
|
1911
|
+
function normalizeAgentCommandRunnerOptions(cliOptions, command) {
|
|
1912
|
+
return {
|
|
1913
|
+
...normalizePromptRunnerSelectionCliOptions(cliOptions, {
|
|
1914
|
+
isAgentRequired: true,
|
|
1915
|
+
}),
|
|
1916
|
+
isVerbose: resolveCommandVerboseOption(command),
|
|
1917
|
+
};
|
|
1915
1918
|
}
|
|
1916
1919
|
// Note: [🟡] Code for CLI command options [agent](src/cli/cli-commands/agent/agentCliOptions.ts) should never be published outside of `@promptbook/cli`
|
|
1917
1920
|
// Note: [💞] Ignore a discrepancy between file name and exported helper names
|
|
@@ -1941,6 +1944,16 @@ function resolveRequiredAgentMessage(cliOptions) {
|
|
|
1941
1944
|
}
|
|
1942
1945
|
return message;
|
|
1943
1946
|
}
|
|
1947
|
+
/**
|
|
1948
|
+
* Resolves the inherited `--verbose` flag from the current Commander command chain.
|
|
1949
|
+
*
|
|
1950
|
+
* @private internal utility of `ptbk agent`
|
|
1951
|
+
*/
|
|
1952
|
+
function resolveCommandVerboseOption(command) {
|
|
1953
|
+
var _a;
|
|
1954
|
+
const globalOptions = command.optsWithGlobals();
|
|
1955
|
+
return (_a = globalOptions.verbose) !== null && _a !== void 0 ? _a : false;
|
|
1956
|
+
}
|
|
1944
1957
|
|
|
1945
1958
|
/**
|
|
1946
1959
|
* Initializes `agent chat` command for Promptbook CLI utilities.
|
|
@@ -1960,9 +1973,9 @@ function $initializeAgentChatCommand(program) {
|
|
|
1960
1973
|
addPromptRunnerSelectionOptions(command);
|
|
1961
1974
|
addPromptRunnerRuntimeOptions(command);
|
|
1962
1975
|
command.option('--context <context-or-file>', 'Append extra context either inline or from a file path');
|
|
1963
|
-
command.action(handleActionErrors(async (cliOptions) => {
|
|
1976
|
+
command.action(handleActionErrors(async (cliOptions, commandProgram) => {
|
|
1964
1977
|
const options = cliOptions;
|
|
1965
|
-
const runnerOptions = normalizeAgentCommandRunnerOptions(options);
|
|
1978
|
+
const runnerOptions = normalizeAgentCommandRunnerOptions(options, commandProgram);
|
|
1966
1979
|
const { runAgentChat } = await Promise.resolve().then(function () { return runAgentChat$1; });
|
|
1967
1980
|
await runAgentChat({
|
|
1968
1981
|
agentPath: resolveRequiredAgentPath(options),
|
|
@@ -1994,9 +2007,9 @@ function $initializeAgentExecCommand(program) {
|
|
|
1994
2007
|
addPromptRunnerSelectionOptions(command);
|
|
1995
2008
|
addPromptRunnerRuntimeOptions(command);
|
|
1996
2009
|
command.option('--context <context-or-file>', 'Append extra context either inline or from a file path');
|
|
1997
|
-
command.action(handleActionErrors(async (cliOptions) => {
|
|
2010
|
+
command.action(handleActionErrors(async (cliOptions, commandProgram) => {
|
|
1998
2011
|
const options = cliOptions;
|
|
1999
|
-
const runnerOptions = normalizeAgentCommandRunnerOptions(options);
|
|
2012
|
+
const runnerOptions = normalizeAgentCommandRunnerOptions(options, commandProgram);
|
|
2000
2013
|
const { runAgentExec } = await Promise.resolve().then(function () { return runAgentExec$1; });
|
|
2001
2014
|
await runAgentExec({
|
|
2002
2015
|
agentPath: resolveRequiredAgentPath(options),
|
|
@@ -26935,13 +26948,31 @@ function describeTempScriptKind(scriptPath) {
|
|
|
26935
26948
|
return scriptPath.toLowerCase().endsWith('.test.sh') ? 'test shell' : 'runner shell';
|
|
26936
26949
|
}
|
|
26937
26950
|
|
|
26951
|
+
/**
|
|
26952
|
+
* Prints one live shell output chunk to the terminal when console mirroring is enabled.
|
|
26953
|
+
*/
|
|
26954
|
+
function printLiveScriptChunk(chunk, source, shouldPrintLiveOutput) {
|
|
26955
|
+
if (!shouldPrintLiveOutput) {
|
|
26956
|
+
return;
|
|
26957
|
+
}
|
|
26958
|
+
if (source === 'stderr') {
|
|
26959
|
+
if (chunk.trim()) {
|
|
26960
|
+
console.warn(chunk);
|
|
26961
|
+
}
|
|
26962
|
+
return;
|
|
26963
|
+
}
|
|
26964
|
+
console.info(chunk);
|
|
26965
|
+
}
|
|
26966
|
+
|
|
26938
26967
|
/**
|
|
26939
26968
|
* Runs one temporary bash script, optionally mirroring its raw input/output into a live runtime log file.
|
|
26940
26969
|
*/
|
|
26941
26970
|
async function runBashScriptWithOutput(options) {
|
|
26971
|
+
var _a;
|
|
26942
26972
|
await appendScriptExecutionLogStart(options);
|
|
26943
26973
|
const bashExecution = buildLoggedBashExecution(options.scriptPath, options.logPath);
|
|
26944
26974
|
const scriptPathPosix = toPosixPath(options.scriptPath);
|
|
26975
|
+
const shouldPrintLiveOutput = (_a = options.shouldPrintLiveOutput) !== null && _a !== void 0 ? _a : true;
|
|
26945
26976
|
return await new Promise((resolve, reject) => {
|
|
26946
26977
|
const commandProcess = spawn('bash', bashExecution.args, {
|
|
26947
26978
|
env: bashExecution.env ? { ...process.env, ...bashExecution.env } : process.env,
|
|
@@ -26985,14 +27016,12 @@ async function runBashScriptWithOutput(options) {
|
|
|
26985
27016
|
commandProcess.stdout.on('data', (stdout) => {
|
|
26986
27017
|
const chunk = stdout.toString();
|
|
26987
27018
|
output += chunk;
|
|
26988
|
-
|
|
27019
|
+
printLiveScriptChunk(chunk, 'stdout', shouldPrintLiveOutput);
|
|
26989
27020
|
});
|
|
26990
27021
|
commandProcess.stderr.on('data', (stderr) => {
|
|
26991
27022
|
const chunk = stderr.toString();
|
|
26992
27023
|
output += chunk;
|
|
26993
|
-
|
|
26994
|
-
console.warn(chunk);
|
|
26995
|
-
}
|
|
27024
|
+
printLiveScriptChunk(chunk, 'stderr', shouldPrintLiveOutput);
|
|
26996
27025
|
});
|
|
26997
27026
|
/**
|
|
26998
27027
|
* Handles process exit and resolves or rejects accordingly.
|
|
@@ -27212,6 +27241,7 @@ class ClaudeCodeRunner {
|
|
|
27212
27241
|
scriptPath: options.scriptPath,
|
|
27213
27242
|
scriptContent,
|
|
27214
27243
|
logPath: options.logPath,
|
|
27244
|
+
shouldPrintLiveOutput: options.shouldPrintLiveOutput,
|
|
27215
27245
|
preserveArtifactsOnSuccess: options.preserveArtifactsOnSuccess,
|
|
27216
27246
|
});
|
|
27217
27247
|
const usage = parseClaudeCodeJsonOutput(output);
|
|
@@ -27276,6 +27306,7 @@ class ClineRunner {
|
|
|
27276
27306
|
scriptPath: options.scriptPath,
|
|
27277
27307
|
scriptContent,
|
|
27278
27308
|
logPath: options.logPath,
|
|
27309
|
+
shouldPrintLiveOutput: options.shouldPrintLiveOutput,
|
|
27279
27310
|
preserveArtifactsOnSuccess: options.preserveArtifactsOnSuccess,
|
|
27280
27311
|
});
|
|
27281
27312
|
return { usage: UNCERTAIN_USAGE };
|
|
@@ -27419,6 +27450,7 @@ class GeminiRunner {
|
|
|
27419
27450
|
scriptPath: options.scriptPath,
|
|
27420
27451
|
scriptContent,
|
|
27421
27452
|
logPath: options.logPath,
|
|
27453
|
+
shouldPrintLiveOutput: options.shouldPrintLiveOutput,
|
|
27422
27454
|
preserveArtifactsOnSuccess: options.preserveArtifactsOnSuccess,
|
|
27423
27455
|
});
|
|
27424
27456
|
const usage = parseGeminiUsageFromOutput(output, options.prompt, this.options.model);
|
|
@@ -27486,6 +27518,7 @@ class GitHubCopilotRunner {
|
|
|
27486
27518
|
scriptPath: options.scriptPath,
|
|
27487
27519
|
scriptContent,
|
|
27488
27520
|
logPath: options.logPath,
|
|
27521
|
+
shouldPrintLiveOutput: options.shouldPrintLiveOutput,
|
|
27489
27522
|
preserveArtifactsOnSuccess: options.preserveArtifactsOnSuccess,
|
|
27490
27523
|
});
|
|
27491
27524
|
}
|
|
@@ -27559,8 +27592,10 @@ function buildCommandFailureMessage(scriptPathPosix, code, fullOutput) {
|
|
|
27559
27592
|
* Returns the captured output.
|
|
27560
27593
|
*/
|
|
27561
27594
|
async function runScriptUntilMarkerIdle(options) {
|
|
27595
|
+
var _a;
|
|
27562
27596
|
const { scriptPath, completionLineMatcher, idleTimeoutMs } = options;
|
|
27563
27597
|
const scriptPathPosix = toPosixPath(scriptPath);
|
|
27598
|
+
const shouldPrintLiveOutput = (_a = options.shouldPrintLiveOutput) !== null && _a !== void 0 ? _a : true;
|
|
27564
27599
|
await appendScriptExecutionLogStart(options);
|
|
27565
27600
|
const bashExecution = buildLoggedBashExecution(scriptPath, options.logPath);
|
|
27566
27601
|
return await new Promise((resolve, reject) => {
|
|
@@ -27644,14 +27679,7 @@ async function runScriptUntilMarkerIdle(options) {
|
|
|
27644
27679
|
const handleChunk = (chunk, source) => {
|
|
27645
27680
|
var _a, _b;
|
|
27646
27681
|
fullOutput += chunk;
|
|
27647
|
-
|
|
27648
|
-
if (chunk.trim()) {
|
|
27649
|
-
console.warn(chunk);
|
|
27650
|
-
}
|
|
27651
|
-
}
|
|
27652
|
-
else {
|
|
27653
|
-
console.info(chunk);
|
|
27654
|
-
}
|
|
27682
|
+
printLiveScriptChunk(chunk, source, shouldPrintLiveOutput);
|
|
27655
27683
|
if (source === 'stdout') {
|
|
27656
27684
|
stdoutBuffer += chunk;
|
|
27657
27685
|
const lines = stdoutBuffer.split(/\r?\n/);
|
|
@@ -27711,6 +27739,7 @@ async function $runGoScriptUntilMarkerIdle(options) {
|
|
|
27711
27739
|
completionLineMatcher: options.completionLineMatcher,
|
|
27712
27740
|
idleTimeoutMs: options.idleTimeoutMs,
|
|
27713
27741
|
logPath: options.logPath,
|
|
27742
|
+
shouldPrintLiveOutput: options.shouldPrintLiveOutput,
|
|
27714
27743
|
});
|
|
27715
27744
|
});
|
|
27716
27745
|
}
|
|
@@ -28117,7 +28146,7 @@ class OpenAiCodexRunner {
|
|
|
28117
28146
|
* Runs the Codex prompt in a temporary script and waits for completion output.
|
|
28118
28147
|
*/
|
|
28119
28148
|
async runPrompt(options) {
|
|
28120
|
-
var _a;
|
|
28149
|
+
var _a, _b;
|
|
28121
28150
|
const scriptContent = buildCodexScript({
|
|
28122
28151
|
prompt: options.prompt,
|
|
28123
28152
|
projectPath: options.projectPath,
|
|
@@ -28143,6 +28172,7 @@ class OpenAiCodexRunner {
|
|
|
28143
28172
|
completionLineMatcher: CODEX_COMPLETION_LINE,
|
|
28144
28173
|
idleTimeoutMs: CODEX_COMPLETION_IDLE_MS,
|
|
28145
28174
|
logPath: options.logPath,
|
|
28175
|
+
shouldPrintLiveOutput: options.shouldPrintLiveOutput,
|
|
28146
28176
|
preserveArtifactsOnSuccess: options.preserveArtifactsOnSuccess,
|
|
28147
28177
|
});
|
|
28148
28178
|
this.rateLimitBackoff.reset();
|
|
@@ -28161,7 +28191,9 @@ class OpenAiCodexRunner {
|
|
|
28161
28191
|
const retryAt = new Date(Date.now() + delayMs).toISOString();
|
|
28162
28192
|
const retryIndex = this.rateLimitBackoff.retryCount;
|
|
28163
28193
|
const summary = extractFailureSummary(details);
|
|
28164
|
-
|
|
28194
|
+
if ((_b = options.shouldPrintLiveOutput) !== null && _b !== void 0 ? _b : true) {
|
|
28195
|
+
console.warn(colors.yellow(`[codex] Rate limit/quota detected (${summary}). Retry #${retryIndex} in ${formatDelay(delayMs)} at ${retryAt}.`));
|
|
28196
|
+
}
|
|
28165
28197
|
await waitForRetryDelay(delayMs, options);
|
|
28166
28198
|
}
|
|
28167
28199
|
}
|
|
@@ -28296,6 +28328,7 @@ class OpencodeRunner {
|
|
|
28296
28328
|
scriptPath: options.scriptPath,
|
|
28297
28329
|
scriptContent,
|
|
28298
28330
|
logPath: options.logPath,
|
|
28331
|
+
shouldPrintLiveOutput: options.shouldPrintLiveOutput,
|
|
28299
28332
|
preserveArtifactsOnSuccess: options.preserveArtifactsOnSuccess,
|
|
28300
28333
|
});
|
|
28301
28334
|
}
|
|
@@ -62656,6 +62689,7 @@ async function executeAgentChatTurn(options) {
|
|
|
62656
62689
|
scriptPath,
|
|
62657
62690
|
projectPath: workspacePath,
|
|
62658
62691
|
logPath,
|
|
62692
|
+
shouldPrintLiveOutput: options.isVerbose,
|
|
62659
62693
|
preserveArtifactsOnSuccess: false,
|
|
62660
62694
|
});
|
|
62661
62695
|
}, { preserveArtifactsOnSuccess: false });
|
|
@@ -62822,7 +62856,9 @@ async function runAgentChat(options) {
|
|
|
62822
62856
|
agentPath: options.agentPath,
|
|
62823
62857
|
});
|
|
62824
62858
|
const messages = [];
|
|
62825
|
-
|
|
62859
|
+
if (options.isVerbose) {
|
|
62860
|
+
console.info(colors.gray('Type "exit" or "quit" to end the chat.'));
|
|
62861
|
+
}
|
|
62826
62862
|
while (true) {
|
|
62827
62863
|
const response = await prompts({
|
|
62828
62864
|
type: 'text',
|