@promptbook/cli 0.114.0-13 → 0.114.0-14

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/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.114.0-13';
19
+ export const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version = '0.114.0-14';
20
20
 
21
21
  /**
22
22
  * Represents the version string of the Promptbook engine.
23
- * It follows semantic versioning (e.g., `0.114.0-12`).
23
+ * It follows semantic versioning (e.g., `0.114.0-13`).
24
24
  *
25
25
  * @generated
26
26
  */
package/src/versions.txt CHANGED
@@ -1189,3 +1189,4 @@
1189
1189
  0.114.0-10
1190
1190
  0.114.0-12
1191
1191
  0.114.0-13
1192
+ 0.114.0-14
package/umd/index.umd.js CHANGED
@@ -58,7 +58,7 @@
58
58
  * @generated
59
59
  * @see https://github.com/webgptorg/promptbook
60
60
  */
61
- const PROMPTBOOK_ENGINE_VERSION = '0.114.0-13';
61
+ const PROMPTBOOK_ENGINE_VERSION = '0.114.0-14';
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
@@ -42457,6 +42457,52 @@
42457
42457
  // Note: [🟡] Code for CLI command [init](src/cli/cli-commands/coder/init.ts) should never be published outside of `@promptbook/cli`
42458
42458
  // Note: [💞] Ignore a discrepancy between file name and entity name
42459
42459
 
42460
+ /**
42461
+ * Default wait duration applied before retrying a prompt round after an error (10 minutes).
42462
+ *
42463
+ * @private internal constant of `ptbk coder` wait handling
42464
+ */
42465
+ const DEFAULT_WAIT_AFTER_ERROR_MS$1 = 10 * 60 * 1000;
42466
+ /**
42467
+ * Parses an optional Commander duration string and returns the resolved milliseconds.
42468
+ *
42469
+ * Returns `defaultMs` when the flag was not provided or was provided without a non-empty value.
42470
+ *
42471
+ * @private internal utility of `ptbk coder` wait handling
42472
+ */
42473
+ function parseOptionalWaitDuration(value, defaultMs) {
42474
+ if (typeof value !== 'string' || value === '') {
42475
+ return defaultMs;
42476
+ }
42477
+ return parseDuration(value);
42478
+ }
42479
+ /**
42480
+ * Parses an optional Commander period duration string and returns the resolved milliseconds.
42481
+ *
42482
+ * Returns `undefined` when the flag was not provided or was provided without a non-empty value,
42483
+ * which means the command runs only once instead of repeating itself.
42484
+ *
42485
+ * @throws {NotAllowed} When the duration is not a positive one, because a non-positive period
42486
+ * would repeat the command without ever pausing between two rounds
42487
+ *
42488
+ * @private internal utility of `ptbk coder` wait handling
42489
+ */
42490
+ function parseOptionalPeriodDuration(optionName, value) {
42491
+ if (typeof value !== 'string' || value === '') {
42492
+ return undefined;
42493
+ }
42494
+ const periodMs = parseDuration(value);
42495
+ if (periodMs <= 0) {
42496
+ throw new NotAllowed(_spaceTrim.spaceTrim(`
42497
+ Invalid value for \`${optionName}\`: \`${value}\`.
42498
+
42499
+ Use a **positive** duration like \`5h\`, \`30m\` or \`1h30m\`.
42500
+ `));
42501
+ }
42502
+ return periodMs;
42503
+ }
42504
+ // Note: [💞] Ignore a discrepancy between file name and entity name
42505
+
42460
42506
  /**
42461
42507
  * Initializes `coder ping` command for Promptbook CLI utilities
42462
42508
  *
@@ -42475,6 +42521,7 @@
42475
42521
  - Verifies that the selected harness, model, thinking level and authentication really work
42476
42522
  - Reports the answer of the harness, the response time and the reported usage
42477
42523
  - Starts the hourly/weekly quota window before you need it, so it is already refreshing when you do
42524
+ - Optional --period keeps the quota window refreshing by pinging once per period until stopped
42478
42525
  - Leaves the project exactly as it was — nothing is read, written, changed or committed
42479
42526
  - Checks that the selected harness is installed globally and up to date unless --no-harness-update is used
42480
42527
  - Use --no-ui to stream the raw harness output instead of only the compact result
@@ -42482,21 +42529,34 @@
42482
42529
  addPromptRunnerSelectionOptions(command);
42483
42530
  addHarnessUpdateOption(command);
42484
42531
  addPromptRunnerRuntimeOptions(command);
42532
+ command.option('--period <duration>', _spaceTrim.spaceTrim(`
42533
+ Keep pinging once per period instead of pinging only once.
42534
+ Accepts durations like 5h, 30m, 1h30m and repeats until it is stopped with CTRL+C.
42535
+ `));
42485
42536
  command.action(handleActionErrors(async (cliOptions) => {
42537
+ const { period: periodValue } = cliOptions;
42486
42538
  const runnerOptions = normalizePromptRunnerSelectionCliOptions(cliOptions, { isAgentRequired: true });
42487
42539
  const { isHarnessUpdateCheckEnabled } = normalizeHarnessUpdateCliOptions(cliOptions);
42540
+ // Note: The period is validated before the harness installation check, so a mistyped duration fails fast
42541
+ const periodMs = parseOptionalPeriodDuration('--period', periodValue);
42488
42542
  await $ensureHarnessInstallations([runnerOptions.agentName], isHarnessUpdateCheckEnabled);
42489
- // Note: Import the ping dynamically to avoid loading heavy dependencies until needed
42490
- const { pingCoderHarness } = await Promise.resolve().then(function () { return pingCoderHarness$1; });
42491
- const { printCoderPingResult } = await Promise.resolve().then(function () { return printCoderPingResult$1; });
42492
- const result = await pingCoderHarness({
42543
+ const pingOptions = {
42493
42544
  agentName: runnerOptions.agentName,
42494
42545
  model: runnerOptions.model,
42495
42546
  thinkingLevel: runnerOptions.thinkingLevel,
42496
42547
  allowCredits: runnerOptions.allowCredits,
42497
42548
  shouldPrintLiveOutput: runnerOptions.noUi,
42498
- });
42499
- printCoderPingResult(result);
42549
+ };
42550
+ // Note: Import the ping dynamically to avoid loading heavy dependencies until needed
42551
+ if (periodMs !== undefined) {
42552
+ const { pingCoderHarnessPeriodically } = await Promise.resolve().then(function () { return pingCoderHarnessPeriodically$1; });
42553
+ // Note: This never returns - it keeps pinging until the user stops the process
42554
+ await pingCoderHarnessPeriodically({ ...pingOptions, periodMs });
42555
+ return;
42556
+ }
42557
+ const { pingCoderHarness } = await Promise.resolve().then(function () { return pingCoderHarness$1; });
42558
+ const { printCoderPingResult } = await Promise.resolve().then(function () { return printCoderPingResult$1; });
42559
+ printCoderPingResult(await pingCoderHarness(pingOptions));
42500
42560
  }));
42501
42561
  }
42502
42562
  // Note: [🟡] Code for CLI command [ping](src/cli/cli-commands/coder/ping.ts) should never be published outside of `@promptbook/cli`
@@ -42933,27 +42993,6 @@
42933
42993
  return TEST_BEFORE_MODE_VALUES.includes(value);
42934
42994
  }
42935
42995
 
42936
- /**
42937
- * Default wait duration applied before retrying a prompt round after an error (10 minutes).
42938
- *
42939
- * @private internal constant of `ptbk coder` wait handling
42940
- */
42941
- const DEFAULT_WAIT_AFTER_ERROR_MS$1 = 10 * 60 * 1000;
42942
- /**
42943
- * Parses an optional Commander duration string and returns the resolved milliseconds.
42944
- *
42945
- * Returns `defaultMs` when the flag was not provided or was provided without a non-empty value.
42946
- *
42947
- * @private internal utility of `ptbk coder` wait handling
42948
- */
42949
- function parseOptionalWaitDuration(value, defaultMs) {
42950
- if (typeof value !== 'string' || value === '') {
42951
- return defaultMs;
42952
- }
42953
- return parseDuration(value);
42954
- }
42955
- // Note: [💞] Ignore a discrepancy between file name and entity name
42956
-
42957
42996
  /**
42958
42997
  * Initializes `coder run` command for Promptbook CLI utilities
42959
42998
  *
@@ -72692,6 +72731,23 @@
72692
72731
  findUnwrittenPrompts: findUnwrittenPrompts
72693
72732
  });
72694
72733
 
72734
+ /**
72735
+ * Formats one unknown error-like value into its readable message without the stack trace.
72736
+ *
72737
+ * Use this instead of `formatUnknownErrorDetails` whenever the text is shown to the user, for example
72738
+ * inside a branded error, where the stack of the wrapped error would only bury the actual cause.
72739
+ */
72740
+ function formatUnknownErrorMessage(error) {
72741
+ if (error instanceof Error) {
72742
+ return error.message;
72743
+ }
72744
+ if (typeof error === 'string') {
72745
+ return error;
72746
+ }
72747
+ const serializedError = JSON.stringify(error, null, 2);
72748
+ return serializedError !== null && serializedError !== void 0 ? serializedError : String(error);
72749
+ }
72750
+
72695
72751
  /**
72696
72752
  * Builds a normalized temporary shell script path for prompt runners.
72697
72753
  */
@@ -72929,6 +72985,60 @@
72929
72985
  printCoderPingResult: printCoderPingResult
72930
72986
  });
72931
72987
 
72988
+ /**
72989
+ * How often the countdown to the next periodic ping is reported to the console (30 minutes).
72990
+ *
72991
+ * A period like `5h` is meant to be left running unattended, so the countdown is deliberately
72992
+ * coarse — it is a sign of life, not a progress bar.
72993
+ */
72994
+ const CODER_PING_COUNTDOWN_UPDATE_INTERVAL_MS = 30 * 60 * 1000;
72995
+ /**
72996
+ * Pings the selected harness and model once per period until the process is stopped.
72997
+ *
72998
+ * This keeps the quota window of the harness refreshing without any real work, so the window is
72999
+ * always open by the time you need it. The loop never ends on its own — it is stopped with `CTRL+C`
73000
+ * or by killing the process — therefore a failing ping is reported and the next period is started
73001
+ * instead of tearing the whole loop down.
73002
+ */
73003
+ async function pingCoderHarnessPeriodically(options) {
73004
+ const { periodMs, ...pingOptions } = options;
73005
+ console.info(colors__default["default"].gray(`🏓 Pinging every ${formatDurationMs(periodMs)} until stopped with CTRL+C`));
73006
+ // Note: The loop is intentionally endless - only `CTRL+C` or killing the process ends it
73007
+ for (;;) {
73008
+ const nextPingTimeMs = Date.now() + periodMs;
73009
+ await reportOneCoderPing(pingOptions);
73010
+ await waitUntilNextCoderPing(nextPingTimeMs);
73011
+ }
73012
+ }
73013
+ /**
73014
+ * Sends and reports one ping of the endless loop, keeping the loop alive when the harness fails.
73015
+ */
73016
+ async function reportOneCoderPing(options) {
73017
+ try {
73018
+ printCoderPingResult(await pingCoderHarness(options));
73019
+ }
73020
+ catch (error) {
73021
+ console.error(colors__default["default"].red(`🏓 Ping failed: ${formatUnknownErrorMessage(error)}`));
73022
+ }
73023
+ }
73024
+ /**
73025
+ * Waits until the wall-clock time of the next ping, reporting how much of the period is left.
73026
+ */
73027
+ async function waitUntilNextCoderPing(nextPingTimeMs) {
73028
+ await waitUntilWorldTimeDeadline({
73029
+ deadlineTimeMs: nextPingTimeMs,
73030
+ pollIntervalMs: CODER_PING_COUNTDOWN_UPDATE_INTERVAL_MS,
73031
+ onTick(remainingDurationMs) {
73032
+ console.info(colors__default["default"].gray(` Next ping in ${formatDurationMs(remainingDurationMs)}`));
73033
+ },
73034
+ });
73035
+ }
73036
+
73037
+ var pingCoderHarnessPeriodically$1 = /*#__PURE__*/Object.freeze({
73038
+ __proto__: null,
73039
+ pingCoderHarnessPeriodically: pingCoderHarnessPeriodically
73040
+ });
73041
+
72932
73042
  /**
72933
73043
  * Default wait duration applied before retrying a failed prompt round.
72934
73044
  */
@@ -75762,23 +75872,6 @@
75762
75872
  return getPromptbookTemporaryPath(CODER_ISOLATION_WORKTREES_DIRECTORY_NAME, taskName);
75763
75873
  }
75764
75874
 
75765
- /**
75766
- * Formats one unknown error-like value into its readable message without the stack trace.
75767
- *
75768
- * Use this instead of `formatUnknownErrorDetails` whenever the text is shown to the user, for example
75769
- * inside a branded error, where the stack of the wrapped error would only bury the actual cause.
75770
- */
75771
- function formatUnknownErrorMessage(error) {
75772
- if (error instanceof Error) {
75773
- return error.message;
75774
- }
75775
- if (typeof error === 'string') {
75776
- return error;
75777
- }
75778
- const serializedError = JSON.stringify(error, null, 2);
75779
- return serializedError !== null && serializedError !== void 0 ? serializedError : String(error);
75780
- }
75781
-
75782
75875
  /**
75783
75876
  * Git configuration key which lets Git read, write and delete files whose absolute path is longer than
75784
75877
  * the Windows `MAX_PATH` limit of 260 characters.