@promptbook/node 0.114.0-19 → 0.114.0-20

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.
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Pause lifecycle of `ptbk coder run`.
3
+ */
4
+ export type CoderRunPauseState = 'RUNNING' | 'PAUSING' | 'PAUSED';
5
+ /**
6
+ * Result of toggling the pause hotkey state.
7
+ */
8
+ export type CoderRunPauseToggleResult = 'REQUESTED_PAUSE' | 'CANCELLED_PAUSE' | 'RESUMED';
9
+ /**
10
+ * Result of requesting a timed wait skip.
11
+ */
12
+ export type CoderRunSkipCurrentWaitResult = 'REQUESTED_SKIP' | 'NO_ACTIVE_WAIT';
13
+ /**
14
+ * Result of toggling the dynamic end-after-current-prompt state.
15
+ */
16
+ export type CoderRunEndAfterCurrentPromptToggleResult = 'REQUESTED_END' | 'CANCELLED_END';
17
+ /**
18
+ * Token that identifies one active timed wait which can be skipped by the user.
19
+ */
20
+ export type CoderRunSkippableWaitToken = symbol;
21
+ /**
22
+ * Applies the same three-state toggle used by the `P` hotkey.
23
+ */
24
+ export declare function togglePauseState(): CoderRunPauseToggleResult;
25
+ /**
26
+ * Applies the two-state toggle used by the `X` hotkey.
27
+ */
28
+ export declare function toggleEndAfterCurrentPromptState(): CoderRunEndAfterCurrentPromptToggleResult;
29
+ /**
30
+ * Returns whether the dynamic end-after-current-prompt control is active.
31
+ */
32
+ export declare function getEndAfterCurrentPromptState(): boolean;
33
+ /**
34
+ * Starts one timed wait which can be skipped by the `S` hotkey.
35
+ */
36
+ export declare function beginSkippableWait(): CoderRunSkippableWaitToken;
37
+ /**
38
+ * Finishes one timed wait and clears any skip request that belonged to it.
39
+ */
40
+ export declare function finishSkippableWait(waitToken: CoderRunSkippableWaitToken): void;
41
+ /**
42
+ * Requests that the currently active timed wait ends immediately.
43
+ */
44
+ export declare function requestSkipCurrentWait(): CoderRunSkipCurrentWaitResult;
45
+ /**
46
+ * Returns whether one timed wait should end early.
47
+ */
48
+ export declare function shouldSkipCurrentWait(waitToken: CoderRunSkippableWaitToken): boolean;
49
+ /**
50
+ * Waits for either a timeout or an `S` hotkey skip request.
51
+ */
52
+ export declare function waitForSkippableMilliseconds(waitToken: CoderRunSkippableWaitToken, durationMs: number): Promise<void>;
53
+ /**
54
+ * Restores all shared terminal controls to their default state.
55
+ */
56
+ export declare function resetCoderRunControls(): void;
57
+ /**
58
+ * If the execution is paused, it will wait until it is resumed.
59
+ *
60
+ * @param options.silent - When `true`, suppresses console output (used when the terminal UI handles display).
61
+ * @param options.onPaused - Callback invoked when entering the PAUSED state.
62
+ * @param options.onResumed - Callback invoked when leaving the PAUSED state.
63
+ */
64
+ export declare function checkPause(options?: {
65
+ silent?: boolean;
66
+ onPaused?: () => void;
67
+ onResumed?: () => void;
68
+ }): Promise<void>;
69
+ /**
70
+ * Returns the current pause state for external consumers such as the terminal UI.
71
+ */
72
+ export declare function getPauseState(): CoderRunPauseState;
73
+ /**
74
+ * Returns the label of the next checkpoint where pausing will take effect.
75
+ */
76
+ export declare function getPauseTargetLabel(): string;
77
+ /**
78
+ * Updates the label of the next pause checkpoint.
79
+ */
80
+ export declare function announcePauseTargetLabel(nextPauseTargetLabel: string): void;
81
+ /**
82
+ * Restores the default generic pause target label.
83
+ */
84
+ export declare function resetPauseTargetLabel(): void;
85
+ /**
86
+ * Requests a pause from an external controller (e.g. the Ink UI).
87
+ */
88
+ export declare function requestPause(): void;
89
+ /**
90
+ * Resumes execution from an external controller after a pause.
91
+ */
92
+ export declare function requestResume(): void;
@@ -0,0 +1,15 @@
1
+ import { type WorldTimeDeadlineTick } from './waitUntilWorldTimeDeadline';
2
+ /**
3
+ * Waits until one wall-clock deadline has passed, or until the user skips the wait with the `S` control.
4
+ *
5
+ * This is the single way `ptbk coder` waits for a deadline the user is allowed to cut short, so every
6
+ * wait which shows the `S Skip current waiting` control really reacts to it: the pacing waits between
7
+ * prompts, the cool-down after an error, the harness session-limit waits and the server keep-alive poll.
8
+ *
9
+ * @private internal utility of `ptbk coder` wait handling
10
+ */
11
+ export declare function waitForSkippableWorldTimeDeadline(options: {
12
+ readonly deadlineTimeMs: number;
13
+ readonly pollIntervalMs: number;
14
+ readonly onTick?: WorldTimeDeadlineTick;
15
+ }): Promise<void>;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Supported values of the `--git-changes` option, which decides what happens with a dirty working tree.
3
+ *
4
+ * - `fail` — refuse to start while the working tree has uncommitted changes
5
+ * - `ignore` — start anyway and leave the uncommitted changes where they are
6
+ * - `continue` — resume the single prompt which was left in the middle of its implementation
7
+ *
8
+ * @private internal shared utility of `ptbk coder run`
9
+ */
10
+ export declare const GIT_CHANGES_MODE_VALUES: readonly ["fail", "ignore", "continue"];
11
+ /**
12
+ * Behavior requested for a working tree which has uncommitted changes.
13
+ *
14
+ * @private internal shared utility of `ptbk coder run`
15
+ */
16
+ export type GitChangesMode = (typeof GIT_CHANGES_MODE_VALUES)[number];
17
+ /**
18
+ * Mode applied when `--git-changes` is not used at all.
19
+ *
20
+ * @private internal shared utility of `ptbk coder run`
21
+ */
22
+ export declare const DEFAULT_GIT_CHANGES_MODE: GitChangesMode;
23
+ /**
24
+ * Checks whether a value is a supported `--git-changes` mode.
25
+ *
26
+ * @private internal shared utility of `ptbk coder run`
27
+ */
28
+ export declare function isGitChangesMode(value: string): value is GitChangesMode;
@@ -1,5 +1,6 @@
1
1
  import { Command as Program } from 'commander';
2
2
  import { PTBK_HARNESS_ENV, PTBK_MODEL_ENV, PTBK_THINKING_LEVEL_ENV } from '../../../book-3.0/cliAgentEnv';
3
+ import type { GitChangesMode } from '../coder/GitChangesMode';
3
4
  import type { ThinkingLevel } from '../coder/ThinkingLevel';
4
5
  export { PTBK_HARNESS_ENV, PTBK_MODEL_ENV, PTBK_THINKING_LEVEL_ENV };
5
6
  /**
@@ -25,7 +26,7 @@ export type PromptRunnerCliOptions = {
25
26
  readonly ui: boolean;
26
27
  readonly thinkingLevel?: ThinkingLevel;
27
28
  readonly commit: boolean;
28
- readonly ignoreGitChanges: boolean;
29
+ readonly gitChanges: GitChangesMode;
29
30
  readonly allowCredits: boolean;
30
31
  readonly normalizeLineEndings: boolean;
31
32
  readonly autoPush: boolean;
@@ -48,7 +49,7 @@ export type NormalizedPromptRunnerCliOptions = {
48
49
  readonly noUi: boolean;
49
50
  readonly thinkingLevel?: ThinkingLevel;
50
51
  readonly noCommit: boolean;
51
- readonly ignoreGitChanges: boolean;
52
+ readonly gitChanges: GitChangesMode;
52
53
  readonly allowCredits: boolean;
53
54
  readonly normalizeLineEndings: boolean;
54
55
  readonly autoPush: boolean;
@@ -78,6 +79,12 @@ export declare const PROMPT_RUNNER_HARNESS_OPTION_DESCRIPTION = "Select runner:
78
79
  * @private internal utility of `promptbookCli`
79
80
  */
80
81
  export declare const PROMPT_RUNNER_MODEL_OPTION_DESCRIPTION: string;
82
+ /**
83
+ * Commander description for the `--git-changes` option.
84
+ *
85
+ * @private internal utility of `promptbookCli`
86
+ */
87
+ export declare const GIT_CHANGES_OPTION_DESCRIPTION: string;
81
88
  /**
82
89
  * Registers runner selection flags on a command.
83
90
  *
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
15
15
  export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
16
16
  /**
17
17
  * Represents the version string of the Promptbook engine.
18
- * It follows semantic versioning (e.g., `0.114.0-18`).
18
+ * It follows semantic versioning (e.g., `0.114.0-19`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/node",
3
- "version": "0.114.0-19",
3
+ "version": "0.114.0-20",
4
4
  "description": "Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -97,7 +97,7 @@
97
97
  "types": "./esm/src/_packages/node.index.d.ts",
98
98
  "typings": "./esm/src/_packages/node.index.d.ts",
99
99
  "peerDependencies": {
100
- "@promptbook/core": "0.114.0-19"
100
+ "@promptbook/core": "0.114.0-20"
101
101
  },
102
102
  "dependencies": {
103
103
  "@openai/agents": "0.4.15",
package/umd/index.umd.js CHANGED
@@ -47,7 +47,7 @@
47
47
  * @generated
48
48
  * @see https://github.com/webgptorg/promptbook
49
49
  */
50
- const PROMPTBOOK_ENGINE_VERSION = '0.114.0-19';
50
+ const PROMPTBOOK_ENGINE_VERSION = '0.114.0-20';
51
51
  /**
52
52
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
53
53
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -3259,6 +3259,97 @@
3259
3259
  });
3260
3260
  }
3261
3261
 
3262
+ /**
3263
+ * Token of the currently active timed wait, if the runner is inside one.
3264
+ */
3265
+ let activeSkippableWaitToken;
3266
+ /**
3267
+ * Whether the user requested the active timed wait to end immediately.
3268
+ */
3269
+ let isSkipCurrentWaitRequested = false;
3270
+ /**
3271
+ * Promise resolvers waiting for the active timed wait to be skipped.
3272
+ */
3273
+ const SKIP_CURRENT_WAIT_RESOLVERS = new Map();
3274
+ /**
3275
+ * Starts one timed wait which can be skipped by the `S` hotkey.
3276
+ */
3277
+ function beginSkippableWait() {
3278
+ const waitToken = Symbol('coder-run-skippable-wait');
3279
+ activeSkippableWaitToken = waitToken;
3280
+ isSkipCurrentWaitRequested = false;
3281
+ SKIP_CURRENT_WAIT_RESOLVERS.clear();
3282
+ return waitToken;
3283
+ }
3284
+ /**
3285
+ * Finishes one timed wait and clears any skip request that belonged to it.
3286
+ */
3287
+ function finishSkippableWait(waitToken) {
3288
+ if (activeSkippableWaitToken !== waitToken) {
3289
+ return;
3290
+ }
3291
+ activeSkippableWaitToken = undefined;
3292
+ isSkipCurrentWaitRequested = false;
3293
+ resolveSkipCurrentWaitResolvers(waitToken);
3294
+ SKIP_CURRENT_WAIT_RESOLVERS.delete(waitToken);
3295
+ }
3296
+ /**
3297
+ * Returns whether one timed wait should end early.
3298
+ */
3299
+ function shouldSkipCurrentWait(waitToken) {
3300
+ return activeSkippableWaitToken === waitToken && isSkipCurrentWaitRequested;
3301
+ }
3302
+ /**
3303
+ * Waits for either a timeout or an `S` hotkey skip request.
3304
+ */
3305
+ async function waitForSkippableMilliseconds(waitToken, durationMs) {
3306
+ if (durationMs <= 0 || shouldSkipCurrentWait(waitToken)) {
3307
+ return;
3308
+ }
3309
+ await new Promise((resolve) => {
3310
+ let timeout = setTimeout(resolveWait, durationMs);
3311
+ const resolver = () => resolveWait();
3312
+ const resolvers = getSkipCurrentWaitResolvers(waitToken);
3313
+ resolvers.add(resolver);
3314
+ function resolveWait() {
3315
+ if (timeout !== undefined) {
3316
+ clearTimeout(timeout);
3317
+ timeout = undefined;
3318
+ }
3319
+ resolvers.delete(resolver);
3320
+ if (resolvers.size === 0) {
3321
+ SKIP_CURRENT_WAIT_RESOLVERS.delete(waitToken);
3322
+ }
3323
+ resolve();
3324
+ }
3325
+ });
3326
+ }
3327
+ /**
3328
+ * Gets or creates the resolver set for one timed wait.
3329
+ */
3330
+ function getSkipCurrentWaitResolvers(waitToken) {
3331
+ const existingResolvers = SKIP_CURRENT_WAIT_RESOLVERS.get(waitToken);
3332
+ if (existingResolvers !== undefined) {
3333
+ return existingResolvers;
3334
+ }
3335
+ const resolvers = new Set();
3336
+ SKIP_CURRENT_WAIT_RESOLVERS.set(waitToken, resolvers);
3337
+ return resolvers;
3338
+ }
3339
+ /**
3340
+ * Resolves all pending skip waiters for one timed wait.
3341
+ */
3342
+ function resolveSkipCurrentWaitResolvers(waitToken) {
3343
+ const resolvers = SKIP_CURRENT_WAIT_RESOLVERS.get(waitToken);
3344
+ if (resolvers === undefined) {
3345
+ return;
3346
+ }
3347
+ for (const resolver of resolvers) {
3348
+ resolver();
3349
+ }
3350
+ resolvers.clear();
3351
+ }
3352
+
3262
3353
  /**
3263
3354
  * Minimum timer duration used to avoid a zero-millisecond polling loop.
3264
3355
  */
@@ -3308,6 +3399,32 @@
3308
3399
  await new Promise((resolve) => setTimeout(resolve, durationMs));
3309
3400
  }
3310
3401
 
3402
+ /**
3403
+ * Waits until one wall-clock deadline has passed, or until the user skips the wait with the `S` control.
3404
+ *
3405
+ * This is the single way `ptbk coder` waits for a deadline the user is allowed to cut short, so every
3406
+ * wait which shows the `S Skip current waiting` control really reacts to it: the pacing waits between
3407
+ * prompts, the cool-down after an error, the harness session-limit waits and the server keep-alive poll.
3408
+ *
3409
+ * @private internal utility of `ptbk coder` wait handling
3410
+ */
3411
+ async function waitForSkippableWorldTimeDeadline(options) {
3412
+ const { deadlineTimeMs, pollIntervalMs, onTick } = options;
3413
+ const waitToken = beginSkippableWait();
3414
+ try {
3415
+ await waitUntilWorldTimeDeadline({
3416
+ deadlineTimeMs,
3417
+ pollIntervalMs,
3418
+ onTick,
3419
+ shouldStopWaiting: () => shouldSkipCurrentWait(waitToken),
3420
+ waitForMilliseconds: (waitDurationMs) => waitForSkippableMilliseconds(waitToken, waitDurationMs),
3421
+ });
3422
+ }
3423
+ finally {
3424
+ finishSkippableWait(waitToken);
3425
+ }
3426
+ }
3427
+
3311
3428
  /**
3312
3429
  * Base delimiter used for passing large prompts through stdin.
3313
3430
  */
@@ -3715,6 +3832,10 @@
3715
3832
  }
3716
3833
  /**
3717
3834
  * Waits until the Claude Code session can be resumed, keeping terminal status clear.
3835
+ *
3836
+ * The wait runs in the `waiting` phase, where the terminal UI offers `S Skip current waiting`, so it is
3837
+ * a skippable wait: pressing `S` resumes the session with `--resume` immediately instead of sitting out
3838
+ * the reset window.
3718
3839
  */
3719
3840
  async function waitForClaudeCodeSessionLimitReset(sessionLimit, resurrectionCount, options) {
3720
3841
  var _a, _b;
@@ -3725,7 +3846,7 @@
3725
3846
  if ((_a = options.shouldPrintLiveOutput) !== null && _a !== void 0 ? _a : true) {
3726
3847
  console.warn(colors__default["default"].yellow(`[claude-code] Session limit detected for ${sessionLimit.sessionId}. Resurrection #${resurrectionCount} will resume with --resume after ${formatDurationMs(delayMs)}. ${resetSummary}`));
3727
3848
  }
3728
- await waitUntilWorldTimeDeadline({
3849
+ await waitForSkippableWorldTimeDeadline({
3729
3850
  deadlineTimeMs: resetDeadlineTimeMs,
3730
3851
  pollIntervalMs: CLAUDE_CODE_SESSION_RESURRECTION_POLL_MS,
3731
3852
  onTick: async (remainingDelayMs) => {
@@ -29561,7 +29682,7 @@
29561
29682
  waitBetweenPrompts: 0,
29562
29683
  waitAfterError: 0,
29563
29684
  noCommit: true,
29564
- ignoreGitChanges: true,
29685
+ gitChanges: 'ignore',
29565
29686
  normalizeLineEndings: false,
29566
29687
  allowCredits: options.allowCredits,
29567
29688
  isVerbose: options.isVerbose,