@promptbook/cli 0.112.0-70 → 0.112.0-71

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/esm/index.es.js CHANGED
@@ -57,7 +57,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
57
57
  * @generated
58
58
  * @see https://github.com/webgptorg/promptbook
59
59
  */
60
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-70';
60
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-71';
61
61
  /**
62
62
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
63
63
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -52843,6 +52843,17 @@ function sanitizeGithubTokenInError(token, error) {
52843
52843
  return new Error(rawMessage.split(token).join('***').split(encodedToken).join('***'));
52844
52844
  }
52845
52845
 
52846
+ /**
52847
+ * Returns true when one periodic background task should run now.
52848
+ */
52849
+ function shouldRunPeriodicTask(options) {
52850
+ const { lastRunTimestamp, intervalMs } = options;
52851
+ if (lastRunTimestamp === undefined) {
52852
+ return true;
52853
+ }
52854
+ return Date.now() - lastRunTimestamp >= intervalMs;
52855
+ }
52856
+
52846
52857
  /**
52847
52858
  * Git commands used to list changed and untracked files in the working tree.
52848
52859
  */
@@ -56464,6 +56475,10 @@ const MULTI_AGENT_QUEUE_POLL_INTERVAL_MS = 2000;
56464
56475
  * Delay between GitHub owner synchronization rounds while the multi-agent runner stays active.
56465
56476
  */
56466
56477
  const MULTI_AGENT_GITHUB_SYNC_INTERVAL_MS = 30000;
56478
+ /**
56479
+ * Delay between GitHub owner synchronization rounds while no local repositories exist yet.
56480
+ */
56481
+ const MULTI_AGENT_EMPTY_DIRECTORY_GITHUB_SYNC_INTERVAL_MS = MULTI_AGENT_QUEUE_POLL_INTERVAL_MS;
56467
56482
  /**
56468
56483
  * Watches all direct child agent repositories from the current directory in one shared session.
56469
56484
  */
@@ -56474,6 +56489,7 @@ async function runMultipleAgentMessages(options, controls = {}) {
56474
56489
  const shouldContinue = controls.shouldContinue || (() => just(true));
56475
56490
  const uiHandle = await initializeMultipleAgentRunUi(options);
56476
56491
  let githubSynchronizationTimestamp;
56492
+ let lastObservedProjectCount = 0;
56477
56493
  if (!uiHandle) {
56478
56494
  console.info(colors.green('Watching direct child agent repositories for queued messages.'));
56479
56495
  }
@@ -56482,8 +56498,10 @@ async function runMultipleAgentMessages(options, controls = {}) {
56482
56498
  rootPath,
56483
56499
  uiHandle,
56484
56500
  lastSynchronizationTimestamp: githubSynchronizationTimestamp,
56501
+ lastObservedProjectCount,
56485
56502
  });
56486
56503
  const projectSummaries = await loadLocalAgentRunnerProjectSummaries(rootPath);
56504
+ lastObservedProjectCount = projectSummaries.length;
56487
56505
  const nextQueuedProject = projectSummaries.find((projectSummary) => projectSummary.queuedMessageCount > 0);
56488
56506
  if (!nextQueuedProject) {
56489
56507
  updateMultipleAgentRunUiForWatching(uiHandle, options, rootPath, projectSummaries);
@@ -56522,9 +56540,14 @@ async function initializeMultipleAgentRunUi(options) {
56522
56540
  */
56523
56541
  async function synchronizeGithubAgentRunnerRepositoriesIfNeeded(options) {
56524
56542
  var _a;
56525
- const { rootPath, uiHandle, lastSynchronizationTimestamp } = options;
56526
- if (lastSynchronizationTimestamp !== undefined &&
56527
- Date.now() - lastSynchronizationTimestamp < MULTI_AGENT_GITHUB_SYNC_INTERVAL_MS) {
56543
+ const { rootPath, uiHandle, lastSynchronizationTimestamp, lastObservedProjectCount } = options;
56544
+ const synchronizationIntervalMs = lastObservedProjectCount === 0
56545
+ ? MULTI_AGENT_EMPTY_DIRECTORY_GITHUB_SYNC_INTERVAL_MS
56546
+ : MULTI_AGENT_GITHUB_SYNC_INTERVAL_MS;
56547
+ if (!shouldRunPeriodicTask({
56548
+ lastRunTimestamp: lastSynchronizationTimestamp,
56549
+ intervalMs: synchronizationIntervalMs,
56550
+ })) {
56528
56551
  return lastSynchronizationTimestamp;
56529
56552
  }
56530
56553
  if (uiHandle) {
@@ -56695,10 +56718,13 @@ async function waitForQueuedAgentMessage(options) {
56695
56718
  * Decides whether the empty queue has been idle long enough for another auto-pull.
56696
56719
  */
56697
56720
  function shouldAutoPullWhileIdle(options, autoPullTimestamp) {
56698
- if (!options.autoPull || autoPullTimestamp === undefined) {
56721
+ if (!options.autoPull) {
56699
56722
  return false;
56700
56723
  }
56701
- return Date.now() - autoPullTimestamp >= AGENT_IDLE_AUTO_PULL_INTERVAL_MS;
56724
+ return shouldRunPeriodicTask({
56725
+ lastRunTimestamp: autoPullTimestamp,
56726
+ intervalMs: AGENT_IDLE_AUTO_PULL_INTERVAL_MS,
56727
+ });
56702
56728
  }
56703
56729
  /**
56704
56730
  * Waits for the given number of milliseconds.