@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.
Files changed (27) hide show
  1. package/apps/agents-server/src/app/agents/[agentName]/api/user-chats/[chatId]/stream/route.ts +85 -56
  2. package/apps/agents-server/src/app/agents/[agentName]/chat/useAgentChatHistorySyncEffects.ts +7 -13
  3. package/apps/agents-server/src/database/migrations/2026-06-1300-user-chat-active-read-indexes.sql +7 -0
  4. package/apps/agents-server/src/utils/agentRouting/resolveAgentRouteTarget.ts +38 -0
  5. package/apps/agents-server/src/utils/userChat/createImmediateUserChatAnswerModelRequirements.ts +15 -12
  6. package/apps/agents-server/src/utils/userChat/createUserChatDetailPayload.ts +33 -18
  7. package/apps/agents-server/src/utils/userChat/hasPotentiallyPendingAssistantMessages.ts +26 -0
  8. package/apps/agents-server/src/utils/userChat/runImmediateUserChatAnswer.ts +1 -1
  9. package/esm/index.es.js +60 -24
  10. package/esm/index.es.js.map +1 -1
  11. package/esm/scripts/run-codex-prompts/common/runGoScript/printLiveScriptChunk.d.ts +4 -0
  12. package/esm/src/cli/cli-commands/agent/agentCliOptions.d.ts +10 -1
  13. package/esm/src/version.d.ts +1 -1
  14. package/package.json +1 -1
  15. package/src/book-3.0/LiteAgent.ts +15 -10
  16. package/src/cli/cli-commands/agent/agentCliOptions.ts +33 -4
  17. package/src/cli/cli-commands/agent/chat.ts +2 -2
  18. package/src/cli/cli-commands/agent/exec.ts +2 -2
  19. package/src/cli/cli-commands/agent.ts +0 -1
  20. package/src/other/templates/getTemplatesPipelineCollection.ts +767 -853
  21. package/src/version.ts +2 -2
  22. package/src/versions.txt +1 -0
  23. package/umd/index.umd.js +60 -24
  24. package/umd/index.umd.js.map +1 -1
  25. package/umd/scripts/run-codex-prompts/common/runGoScript/printLiveScriptChunk.d.ts +4 -0
  26. package/umd/src/cli/cli-commands/agent/agentCliOptions.d.ts +10 -1
  27. package/umd/src/version.d.ts +1 -1
package/src/version.ts CHANGED
@@ -16,11 +16,11 @@ export const BOOK_LANGUAGE_VERSION: string_semantic_version = '2.0.0';
16
16
  * @generated
17
17
  * @see https://github.com/webgptorg/promptbook
18
18
  */
19
- export const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version = '0.112.0-113';
19
+ export const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version = '0.112.0-114';
20
20
 
21
21
  /**
22
22
  * Represents the version string of the Promptbook engine.
23
- * It follows semantic versioning (e.g., `0.112.0-112`).
23
+ * It follows semantic versioning (e.g., `0.112.0-113`).
24
24
  *
25
25
  * @generated
26
26
  */
package/src/versions.txt CHANGED
@@ -1147,3 +1147,4 @@
1147
1147
  0.112.0-111
1148
1148
  0.112.0-112
1149
1149
  0.112.0-113
1150
+ 0.112.0-114
package/umd/index.umd.js CHANGED
@@ -60,7 +60,7 @@
60
60
  * @generated
61
61
  * @see https://github.com/webgptorg/promptbook
62
62
  */
63
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-113';
63
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-114';
64
64
  /**
65
65
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
66
66
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1910,10 +1910,13 @@
1910
1910
  *
1911
1911
  * @private internal utility of `ptbk agent`
1912
1912
  */
1913
- function normalizeAgentCommandRunnerOptions(cliOptions) {
1914
- return normalizePromptRunnerSelectionCliOptions(cliOptions, {
1915
- isAgentRequired: true,
1916
- });
1913
+ function normalizeAgentCommandRunnerOptions(cliOptions, command) {
1914
+ return {
1915
+ ...normalizePromptRunnerSelectionCliOptions(cliOptions, {
1916
+ isAgentRequired: true,
1917
+ }),
1918
+ isVerbose: resolveCommandVerboseOption(command),
1919
+ };
1917
1920
  }
1918
1921
  // Note: [🟡] Code for CLI command options [agent](src/cli/cli-commands/agent/agentCliOptions.ts) should never be published outside of `@promptbook/cli`
1919
1922
  // Note: [💞] Ignore a discrepancy between file name and exported helper names
@@ -1943,6 +1946,16 @@
1943
1946
  }
1944
1947
  return message;
1945
1948
  }
1949
+ /**
1950
+ * Resolves the inherited `--verbose` flag from the current Commander command chain.
1951
+ *
1952
+ * @private internal utility of `ptbk agent`
1953
+ */
1954
+ function resolveCommandVerboseOption(command) {
1955
+ var _a;
1956
+ const globalOptions = command.optsWithGlobals();
1957
+ return (_a = globalOptions.verbose) !== null && _a !== void 0 ? _a : false;
1958
+ }
1946
1959
 
1947
1960
  /**
1948
1961
  * Initializes `agent chat` command for Promptbook CLI utilities.
@@ -1962,9 +1975,9 @@
1962
1975
  addPromptRunnerSelectionOptions(command);
1963
1976
  addPromptRunnerRuntimeOptions(command);
1964
1977
  command.option('--context <context-or-file>', 'Append extra context either inline or from a file path');
1965
- command.action(handleActionErrors(async (cliOptions) => {
1978
+ command.action(handleActionErrors(async (cliOptions, commandProgram) => {
1966
1979
  const options = cliOptions;
1967
- const runnerOptions = normalizeAgentCommandRunnerOptions(options);
1980
+ const runnerOptions = normalizeAgentCommandRunnerOptions(options, commandProgram);
1968
1981
  const { runAgentChat } = await Promise.resolve().then(function () { return runAgentChat$1; });
1969
1982
  await runAgentChat({
1970
1983
  agentPath: resolveRequiredAgentPath(options),
@@ -1996,9 +2009,9 @@
1996
2009
  addPromptRunnerSelectionOptions(command);
1997
2010
  addPromptRunnerRuntimeOptions(command);
1998
2011
  command.option('--context <context-or-file>', 'Append extra context either inline or from a file path');
1999
- command.action(handleActionErrors(async (cliOptions) => {
2012
+ command.action(handleActionErrors(async (cliOptions, commandProgram) => {
2000
2013
  const options = cliOptions;
2001
- const runnerOptions = normalizeAgentCommandRunnerOptions(options);
2014
+ const runnerOptions = normalizeAgentCommandRunnerOptions(options, commandProgram);
2002
2015
  const { runAgentExec } = await Promise.resolve().then(function () { return runAgentExec$1; });
2003
2016
  await runAgentExec({
2004
2017
  agentPath: resolveRequiredAgentPath(options),
@@ -26937,13 +26950,31 @@
26937
26950
  return scriptPath.toLowerCase().endsWith('.test.sh') ? 'test shell' : 'runner shell';
26938
26951
  }
26939
26952
 
26953
+ /**
26954
+ * Prints one live shell output chunk to the terminal when console mirroring is enabled.
26955
+ */
26956
+ function printLiveScriptChunk(chunk, source, shouldPrintLiveOutput) {
26957
+ if (!shouldPrintLiveOutput) {
26958
+ return;
26959
+ }
26960
+ if (source === 'stderr') {
26961
+ if (chunk.trim()) {
26962
+ console.warn(chunk);
26963
+ }
26964
+ return;
26965
+ }
26966
+ console.info(chunk);
26967
+ }
26968
+
26940
26969
  /**
26941
26970
  * Runs one temporary bash script, optionally mirroring its raw input/output into a live runtime log file.
26942
26971
  */
26943
26972
  async function runBashScriptWithOutput(options) {
26973
+ var _a;
26944
26974
  await appendScriptExecutionLogStart(options);
26945
26975
  const bashExecution = buildLoggedBashExecution(options.scriptPath, options.logPath);
26946
26976
  const scriptPathPosix = toPosixPath(options.scriptPath);
26977
+ const shouldPrintLiveOutput = (_a = options.shouldPrintLiveOutput) !== null && _a !== void 0 ? _a : true;
26947
26978
  return await new Promise((resolve, reject) => {
26948
26979
  const commandProcess = child_process.spawn('bash', bashExecution.args, {
26949
26980
  env: bashExecution.env ? { ...process.env, ...bashExecution.env } : process.env,
@@ -26987,14 +27018,12 @@
26987
27018
  commandProcess.stdout.on('data', (stdout) => {
26988
27019
  const chunk = stdout.toString();
26989
27020
  output += chunk;
26990
- console.info(chunk);
27021
+ printLiveScriptChunk(chunk, 'stdout', shouldPrintLiveOutput);
26991
27022
  });
26992
27023
  commandProcess.stderr.on('data', (stderr) => {
26993
27024
  const chunk = stderr.toString();
26994
27025
  output += chunk;
26995
- if (chunk.trim()) {
26996
- console.warn(chunk);
26997
- }
27026
+ printLiveScriptChunk(chunk, 'stderr', shouldPrintLiveOutput);
26998
27027
  });
26999
27028
  /**
27000
27029
  * Handles process exit and resolves or rejects accordingly.
@@ -27214,6 +27243,7 @@
27214
27243
  scriptPath: options.scriptPath,
27215
27244
  scriptContent,
27216
27245
  logPath: options.logPath,
27246
+ shouldPrintLiveOutput: options.shouldPrintLiveOutput,
27217
27247
  preserveArtifactsOnSuccess: options.preserveArtifactsOnSuccess,
27218
27248
  });
27219
27249
  const usage = parseClaudeCodeJsonOutput(output);
@@ -27278,6 +27308,7 @@
27278
27308
  scriptPath: options.scriptPath,
27279
27309
  scriptContent,
27280
27310
  logPath: options.logPath,
27311
+ shouldPrintLiveOutput: options.shouldPrintLiveOutput,
27281
27312
  preserveArtifactsOnSuccess: options.preserveArtifactsOnSuccess,
27282
27313
  });
27283
27314
  return { usage: UNCERTAIN_USAGE };
@@ -27421,6 +27452,7 @@
27421
27452
  scriptPath: options.scriptPath,
27422
27453
  scriptContent,
27423
27454
  logPath: options.logPath,
27455
+ shouldPrintLiveOutput: options.shouldPrintLiveOutput,
27424
27456
  preserveArtifactsOnSuccess: options.preserveArtifactsOnSuccess,
27425
27457
  });
27426
27458
  const usage = parseGeminiUsageFromOutput(output, options.prompt, this.options.model);
@@ -27488,6 +27520,7 @@
27488
27520
  scriptPath: options.scriptPath,
27489
27521
  scriptContent,
27490
27522
  logPath: options.logPath,
27523
+ shouldPrintLiveOutput: options.shouldPrintLiveOutput,
27491
27524
  preserveArtifactsOnSuccess: options.preserveArtifactsOnSuccess,
27492
27525
  });
27493
27526
  }
@@ -27561,8 +27594,10 @@
27561
27594
  * Returns the captured output.
27562
27595
  */
27563
27596
  async function runScriptUntilMarkerIdle(options) {
27597
+ var _a;
27564
27598
  const { scriptPath, completionLineMatcher, idleTimeoutMs } = options;
27565
27599
  const scriptPathPosix = toPosixPath(scriptPath);
27600
+ const shouldPrintLiveOutput = (_a = options.shouldPrintLiveOutput) !== null && _a !== void 0 ? _a : true;
27566
27601
  await appendScriptExecutionLogStart(options);
27567
27602
  const bashExecution = buildLoggedBashExecution(scriptPath, options.logPath);
27568
27603
  return await new Promise((resolve, reject) => {
@@ -27646,14 +27681,7 @@
27646
27681
  const handleChunk = (chunk, source) => {
27647
27682
  var _a, _b;
27648
27683
  fullOutput += chunk;
27649
- if (source === 'stderr') {
27650
- if (chunk.trim()) {
27651
- console.warn(chunk);
27652
- }
27653
- }
27654
- else {
27655
- console.info(chunk);
27656
- }
27684
+ printLiveScriptChunk(chunk, source, shouldPrintLiveOutput);
27657
27685
  if (source === 'stdout') {
27658
27686
  stdoutBuffer += chunk;
27659
27687
  const lines = stdoutBuffer.split(/\r?\n/);
@@ -27713,6 +27741,7 @@
27713
27741
  completionLineMatcher: options.completionLineMatcher,
27714
27742
  idleTimeoutMs: options.idleTimeoutMs,
27715
27743
  logPath: options.logPath,
27744
+ shouldPrintLiveOutput: options.shouldPrintLiveOutput,
27716
27745
  });
27717
27746
  });
27718
27747
  }
@@ -28119,7 +28148,7 @@
28119
28148
  * Runs the Codex prompt in a temporary script and waits for completion output.
28120
28149
  */
28121
28150
  async runPrompt(options) {
28122
- var _a;
28151
+ var _a, _b;
28123
28152
  const scriptContent = buildCodexScript({
28124
28153
  prompt: options.prompt,
28125
28154
  projectPath: options.projectPath,
@@ -28145,6 +28174,7 @@
28145
28174
  completionLineMatcher: CODEX_COMPLETION_LINE,
28146
28175
  idleTimeoutMs: CODEX_COMPLETION_IDLE_MS,
28147
28176
  logPath: options.logPath,
28177
+ shouldPrintLiveOutput: options.shouldPrintLiveOutput,
28148
28178
  preserveArtifactsOnSuccess: options.preserveArtifactsOnSuccess,
28149
28179
  });
28150
28180
  this.rateLimitBackoff.reset();
@@ -28163,7 +28193,9 @@
28163
28193
  const retryAt = new Date(Date.now() + delayMs).toISOString();
28164
28194
  const retryIndex = this.rateLimitBackoff.retryCount;
28165
28195
  const summary = extractFailureSummary(details);
28166
- console.warn(colors__default["default"].yellow(`[codex] Rate limit/quota detected (${summary}). Retry #${retryIndex} in ${formatDelay(delayMs)} at ${retryAt}.`));
28196
+ if ((_b = options.shouldPrintLiveOutput) !== null && _b !== void 0 ? _b : true) {
28197
+ console.warn(colors__default["default"].yellow(`[codex] Rate limit/quota detected (${summary}). Retry #${retryIndex} in ${formatDelay(delayMs)} at ${retryAt}.`));
28198
+ }
28167
28199
  await waitForRetryDelay(delayMs, options);
28168
28200
  }
28169
28201
  }
@@ -28298,6 +28330,7 @@
28298
28330
  scriptPath: options.scriptPath,
28299
28331
  scriptContent,
28300
28332
  logPath: options.logPath,
28333
+ shouldPrintLiveOutput: options.shouldPrintLiveOutput,
28301
28334
  preserveArtifactsOnSuccess: options.preserveArtifactsOnSuccess,
28302
28335
  });
28303
28336
  }
@@ -62658,6 +62691,7 @@
62658
62691
  scriptPath,
62659
62692
  projectPath: workspacePath,
62660
62693
  logPath,
62694
+ shouldPrintLiveOutput: options.isVerbose,
62661
62695
  preserveArtifactsOnSuccess: false,
62662
62696
  });
62663
62697
  }, { preserveArtifactsOnSuccess: false });
@@ -62824,7 +62858,9 @@
62824
62858
  agentPath: options.agentPath,
62825
62859
  });
62826
62860
  const messages = [];
62827
- console.info(colors__default["default"].gray('Type "exit" or "quit" to end the chat.'));
62861
+ if (options.isVerbose) {
62862
+ console.info(colors__default["default"].gray('Type "exit" or "quit" to end the chat.'));
62863
+ }
62828
62864
  while (true) {
62829
62865
  const response = await prompts__default["default"]({
62830
62866
  type: 'text',