@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/esm/index.es.js +138 -45
- package/esm/index.es.js.map +1 -1
- package/esm/scripts/run-codex-prompts/ping/pingCoderHarnessPeriodically.d.ts +22 -0
- package/esm/src/cli/cli-commands/coder/waitOptions.d.ts +12 -0
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/cli/cli-commands/coder/ping.ts +35 -9
- package/src/cli/cli-commands/coder/waitOptions.ts +33 -0
- package/src/other/templates/getTemplatesPipelineCollection.ts +830 -742
- package/src/version.ts +2 -2
- package/src/versions.txt +1 -0
- package/umd/index.umd.js +138 -45
- package/umd/index.umd.js.map +1 -1
- package/umd/scripts/run-codex-prompts/ping/pingCoderHarnessPeriodically.d.ts +22 -0
- package/umd/src/cli/cli-commands/coder/waitOptions.d.ts +12 -0
- package/umd/src/version.d.ts +1 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PingCoderHarnessOptions } from './pingCoderHarness';
|
|
2
|
+
/**
|
|
3
|
+
* Options for the endless `ptbk coder ping --period <duration>` loop.
|
|
4
|
+
*/
|
|
5
|
+
export type PingCoderHarnessPeriodicallyOptions = PingCoderHarnessOptions & {
|
|
6
|
+
/**
|
|
7
|
+
* How long one ping period lasts, in milliseconds.
|
|
8
|
+
*
|
|
9
|
+
* The period is measured from the start of one ping to the start of the next one, so the pings
|
|
10
|
+
* really happen once per period instead of once per period plus the duration of the ping itself.
|
|
11
|
+
*/
|
|
12
|
+
readonly periodMs: number;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Pings the selected harness and model once per period until the process is stopped.
|
|
16
|
+
*
|
|
17
|
+
* This keeps the quota window of the harness refreshing without any real work, so the window is
|
|
18
|
+
* always open by the time you need it. The loop never ends on its own — it is stopped with `CTRL+C`
|
|
19
|
+
* or by killing the process — therefore a failing ping is reported and the next period is started
|
|
20
|
+
* instead of tearing the whole loop down.
|
|
21
|
+
*/
|
|
22
|
+
export declare function pingCoderHarnessPeriodically(options: PingCoderHarnessPeriodicallyOptions): Promise<never>;
|
|
@@ -12,3 +12,15 @@ export declare const DEFAULT_WAIT_AFTER_ERROR_MS: number;
|
|
|
12
12
|
* @private internal utility of `ptbk coder` wait handling
|
|
13
13
|
*/
|
|
14
14
|
export declare function parseOptionalWaitDuration(value: string | undefined, defaultMs: number): number;
|
|
15
|
+
/**
|
|
16
|
+
* Parses an optional Commander period duration string and returns the resolved milliseconds.
|
|
17
|
+
*
|
|
18
|
+
* Returns `undefined` when the flag was not provided or was provided without a non-empty value,
|
|
19
|
+
* which means the command runs only once instead of repeating itself.
|
|
20
|
+
*
|
|
21
|
+
* @throws {NotAllowed} When the duration is not a positive one, because a non-positive period
|
|
22
|
+
* would repeat the command without ever pausing between two rounds
|
|
23
|
+
*
|
|
24
|
+
* @private internal utility of `ptbk coder` wait handling
|
|
25
|
+
*/
|
|
26
|
+
export declare function parseOptionalPeriodDuration(optionName: string, value: string | undefined): number | undefined;
|
package/esm/src/version.d.ts
CHANGED
|
@@ -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
|
+
* It follows semantic versioning (e.g., `0.114.0-13`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
normalizePromptRunnerSelectionCliOptions,
|
|
18
18
|
PROMPT_RUNNER_DESCRIPTION,
|
|
19
19
|
} from '../common/promptRunnerCliOptions';
|
|
20
|
+
import { parseOptionalPeriodDuration } from './waitOptions';
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* Initializes `coder ping` command for Promptbook CLI utilities
|
|
@@ -37,6 +38,7 @@ export function $initializeCoderPingCommand(program: Program): $side_effect {
|
|
|
37
38
|
- Verifies that the selected harness, model, thinking level and authentication really work
|
|
38
39
|
- Reports the answer of the harness, the response time and the reported usage
|
|
39
40
|
- Starts the hourly/weekly quota window before you need it, so it is already refreshing when you do
|
|
41
|
+
- Optional --period keeps the quota window refreshing by pinging once per period until stopped
|
|
40
42
|
- Leaves the project exactly as it was — nothing is read, written, changed or committed
|
|
41
43
|
- Checks that the selected harness is installed globally and up to date unless --no-harness-update is used
|
|
42
44
|
- Use --no-ui to stream the raw harness output instead of only the compact result
|
|
@@ -46,9 +48,20 @@ export function $initializeCoderPingCommand(program: Program): $side_effect {
|
|
|
46
48
|
addPromptRunnerSelectionOptions(command);
|
|
47
49
|
addHarnessUpdateOption(command);
|
|
48
50
|
addPromptRunnerRuntimeOptions(command);
|
|
51
|
+
command.option(
|
|
52
|
+
'--period <duration>',
|
|
53
|
+
spaceTrim(`
|
|
54
|
+
Keep pinging once per period instead of pinging only once.
|
|
55
|
+
Accepts durations like 5h, 30m, 1h30m and repeats until it is stopped with CTRL+C.
|
|
56
|
+
`),
|
|
57
|
+
);
|
|
49
58
|
|
|
50
59
|
command.action(
|
|
51
60
|
handleActionErrors(async (cliOptions) => {
|
|
61
|
+
const { period: periodValue } = cliOptions as {
|
|
62
|
+
readonly period?: string;
|
|
63
|
+
} & PromptRunnerSelectionCliOptions;
|
|
64
|
+
|
|
52
65
|
const runnerOptions = normalizePromptRunnerSelectionCliOptions(
|
|
53
66
|
cliOptions as PromptRunnerSelectionCliOptions,
|
|
54
67
|
{ isAgentRequired: true },
|
|
@@ -57,23 +70,36 @@ export function $initializeCoderPingCommand(program: Program): $side_effect {
|
|
|
57
70
|
cliOptions as HarnessUpdateCliOptions,
|
|
58
71
|
);
|
|
59
72
|
|
|
60
|
-
|
|
73
|
+
// Note: The period is validated before the harness installation check, so a mistyped duration fails fast
|
|
74
|
+
const periodMs = parseOptionalPeriodDuration('--period', periodValue);
|
|
61
75
|
|
|
62
|
-
|
|
63
|
-
const { pingCoderHarness } = await import('../../../../scripts/run-codex-prompts/ping/pingCoderHarness');
|
|
64
|
-
const { printCoderPingResult } = await import(
|
|
65
|
-
'../../../../scripts/run-codex-prompts/ping/printCoderPingResult'
|
|
66
|
-
);
|
|
76
|
+
await $ensureHarnessInstallations([runnerOptions.agentName], isHarnessUpdateCheckEnabled);
|
|
67
77
|
|
|
68
|
-
const
|
|
78
|
+
const pingOptions = {
|
|
69
79
|
agentName: runnerOptions.agentName,
|
|
70
80
|
model: runnerOptions.model,
|
|
71
81
|
thinkingLevel: runnerOptions.thinkingLevel,
|
|
72
82
|
allowCredits: runnerOptions.allowCredits,
|
|
73
83
|
shouldPrintLiveOutput: runnerOptions.noUi,
|
|
74
|
-
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// Note: Import the ping dynamically to avoid loading heavy dependencies until needed
|
|
87
|
+
if (periodMs !== undefined) {
|
|
88
|
+
const { pingCoderHarnessPeriodically } = await import(
|
|
89
|
+
'../../../../scripts/run-codex-prompts/ping/pingCoderHarnessPeriodically'
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
// Note: This never returns - it keeps pinging until the user stops the process
|
|
93
|
+
await pingCoderHarnessPeriodically({ ...pingOptions, periodMs });
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const { pingCoderHarness } = await import('../../../../scripts/run-codex-prompts/ping/pingCoderHarness');
|
|
98
|
+
const { printCoderPingResult } = await import(
|
|
99
|
+
'../../../../scripts/run-codex-prompts/ping/printCoderPingResult'
|
|
100
|
+
);
|
|
75
101
|
|
|
76
|
-
printCoderPingResult(
|
|
102
|
+
printCoderPingResult(await pingCoderHarness(pingOptions));
|
|
77
103
|
}),
|
|
78
104
|
);
|
|
79
105
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { spaceTrim } from 'spacetrim';
|
|
1
2
|
import { parseDuration } from '../../../../scripts/run-codex-prompts/common/parseDuration';
|
|
3
|
+
import { NotAllowed } from '../../../errors/NotAllowed';
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* Default wait duration applied before retrying a prompt round after an error (10 minutes).
|
|
@@ -21,4 +23,35 @@ export function parseOptionalWaitDuration(value: string | undefined, defaultMs:
|
|
|
21
23
|
return parseDuration(value);
|
|
22
24
|
}
|
|
23
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Parses an optional Commander period duration string and returns the resolved milliseconds.
|
|
28
|
+
*
|
|
29
|
+
* Returns `undefined` when the flag was not provided or was provided without a non-empty value,
|
|
30
|
+
* which means the command runs only once instead of repeating itself.
|
|
31
|
+
*
|
|
32
|
+
* @throws {NotAllowed} When the duration is not a positive one, because a non-positive period
|
|
33
|
+
* would repeat the command without ever pausing between two rounds
|
|
34
|
+
*
|
|
35
|
+
* @private internal utility of `ptbk coder` wait handling
|
|
36
|
+
*/
|
|
37
|
+
export function parseOptionalPeriodDuration(optionName: string, value: string | undefined): number | undefined {
|
|
38
|
+
if (typeof value !== 'string' || value === '') {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const periodMs = parseDuration(value);
|
|
43
|
+
|
|
44
|
+
if (periodMs <= 0) {
|
|
45
|
+
throw new NotAllowed(
|
|
46
|
+
spaceTrim(`
|
|
47
|
+
Invalid value for \`${optionName}\`: \`${value}\`.
|
|
48
|
+
|
|
49
|
+
Use a **positive** duration like \`5h\`, \`30m\` or \`1h30m\`.
|
|
50
|
+
`),
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return periodMs;
|
|
55
|
+
}
|
|
56
|
+
|
|
24
57
|
// Note: [💞] Ignore a discrepancy between file name and entity name
|