@promptbook/cli 0.112.0-117 → 0.112.0-118
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/apps/agents-server/src/app/agents/[agentName]/chat/AgentChatSidebarDefault.tsx +5 -6
- package/apps/agents-server/src/utils/externalChatRunner/processExternalUserChatJob.ts +17 -7
- package/apps/agents-server/src/utils/localChatRunner/processLocalUserChatJob.ts +17 -7
- package/apps/agents-server/src/utils/userChat/createImmediateUserChatAnswerModelRequirements.ts +11 -0
- package/apps/agents-server/src/utils/userChat/listUserChats.ts +5 -7
- package/esm/index.es.js +417 -64
- package/esm/index.es.js.map +1 -1
- package/esm/scripts/run-codex-prompts/common/parseDuration.d.ts +19 -0
- package/esm/src/_packages/node.index.d.ts +10 -0
- package/esm/src/book-3.0/BookNodeAgentSource.d.ts +1 -1
- package/esm/src/book-3.0/CliAgent.d.ts +7 -2
- package/esm/src/book-3.0/cliAgentEnv.d.ts +33 -0
- package/esm/src/cli/cli-commands/common/promptRunnerCliOptions.d.ts +2 -18
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/_packages/node.index.ts +10 -0
- package/src/avatars/avatarAnimationScheduler.ts +33 -2
- package/src/avatars/visuals/fractalAvatarVisual.ts +5 -4
- package/src/avatars/visuals/minecraft2AvatarVisual.ts +16 -11
- package/src/avatars/visuals/minecraftAvatarVisual.ts +21 -7
- package/src/avatars/visuals/octopus3d2AvatarVisual.ts +69 -17
- package/src/avatars/visuals/octopus3d3AvatarVisual.ts +81 -18
- package/src/avatars/visuals/octopus3dAvatarVisual.ts +69 -17
- package/src/book-3.0/Book.ts +3 -1
- package/src/book-3.0/BookNodeAgentSource.ts +2 -2
- package/src/book-3.0/CliAgent.ts +84 -6
- package/src/book-3.0/cliAgentEnv.ts +46 -0
- package/src/cli/cli-commands/coder/run.ts +28 -3
- package/src/cli/cli-commands/common/promptRunnerCliOptions.ts +9 -29
- package/src/other/templates/getTemplatesPipelineCollection.ts +713 -735
- package/src/version.ts +2 -2
- package/src/versions.txt +1 -0
- package/umd/index.umd.js +417 -64
- package/umd/index.umd.js.map +1 -1
- package/umd/scripts/run-codex-prompts/common/parseDuration.d.ts +19 -0
- package/umd/src/_packages/node.index.d.ts +10 -0
- package/umd/src/book-3.0/BookNodeAgentSource.d.ts +1 -1
- package/umd/src/book-3.0/CliAgent.d.ts +7 -2
- package/umd/src/book-3.0/cliAgentEnv.d.ts +33 -0
- package/umd/src/cli/cli-commands/common/promptRunnerCliOptions.d.ts +2 -18
- package/umd/src/version.d.ts +1 -1
|
@@ -55,6 +55,53 @@ const LIGHT_DIRECTION: Point3D = normalizeVector3({
|
|
|
55
55
|
z: 0.94,
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Per-avatar stable state derived once from the seeded random factory and reused across frames.
|
|
60
|
+
*
|
|
61
|
+
* @private helper of `octopus3dAvatarVisual`
|
|
62
|
+
*/
|
|
63
|
+
type Octopus3dStableState = {
|
|
64
|
+
readonly morphologyProfile: Octopus3MorphologyProfile;
|
|
65
|
+
readonly animationPhase: number;
|
|
66
|
+
readonly leftEyePhaseOffset: number;
|
|
67
|
+
readonly rightEyePhaseOffset: number;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Cache keyed by the `createRandom` factory reference (stable per mounted `<Avatar/>`).
|
|
72
|
+
*
|
|
73
|
+
* @private helper of `octopus3dAvatarVisual`
|
|
74
|
+
*/
|
|
75
|
+
const octopus3dStableStateCache = new WeakMap<(salt: string) => () => number, Octopus3dStableState>();
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Returns the stable per-avatar state, computing it on first access and caching for subsequent frames.
|
|
79
|
+
*
|
|
80
|
+
* @private helper of `octopus3dAvatarVisual`
|
|
81
|
+
*/
|
|
82
|
+
function getOctopus3dStableState(createRandom: (salt: string) => () => number): Octopus3dStableState {
|
|
83
|
+
const cached = octopus3dStableStateCache.get(createRandom);
|
|
84
|
+
|
|
85
|
+
if (cached !== undefined) {
|
|
86
|
+
return cached;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const animationRandom = createRandom('octopus3d-animation-profile');
|
|
90
|
+
const eyeRandom = createRandom('octopus3d-eye-profile');
|
|
91
|
+
const leftEyePhaseOffset = eyeRandom() * 0.6;
|
|
92
|
+
const rightEyePhaseOffset = eyeRandom() * 0.6;
|
|
93
|
+
const state: Octopus3dStableState = {
|
|
94
|
+
morphologyProfile: createOctopus3MorphologyProfile(createRandom),
|
|
95
|
+
animationPhase: animationRandom() * Math.PI * 2,
|
|
96
|
+
leftEyePhaseOffset,
|
|
97
|
+
rightEyePhaseOffset,
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
octopus3dStableStateCache.set(createRandom, state);
|
|
101
|
+
|
|
102
|
+
return state;
|
|
103
|
+
}
|
|
104
|
+
|
|
58
105
|
/**
|
|
59
106
|
* Proper 3D Octopus visual built from projected organic meshes and tentacles.
|
|
60
107
|
*
|
|
@@ -67,10 +114,8 @@ export const octopus3dAvatarVisual: AvatarVisualDefinition = {
|
|
|
67
114
|
isAnimated: true,
|
|
68
115
|
supportsPointerTracking: true,
|
|
69
116
|
render({ context, size, palette, createRandom, timeMs, interaction }) {
|
|
70
|
-
const morphologyProfile =
|
|
71
|
-
|
|
72
|
-
const eyeRandom = createRandom('octopus3d-eye-profile');
|
|
73
|
-
const animationPhase = animationRandom() * Math.PI * 2;
|
|
117
|
+
const { morphologyProfile, animationPhase, leftEyePhaseOffset, rightEyePhaseOffset } =
|
|
118
|
+
getOctopus3dStableState(createRandom);
|
|
74
119
|
const sceneCenterX = size * 0.5;
|
|
75
120
|
const sceneCenterY = size * 0.56;
|
|
76
121
|
const bob = Math.sin(timeMs / 920 + animationPhase) * size * 0.014;
|
|
@@ -201,7 +246,7 @@ export const octopus3dAvatarVisual: AvatarVisualDefinition = {
|
|
|
201
246
|
size,
|
|
202
247
|
palette,
|
|
203
248
|
timeMs,
|
|
204
|
-
animationPhase +
|
|
249
|
+
animationPhase + leftEyePhaseOffset,
|
|
205
250
|
interaction,
|
|
206
251
|
morphologyProfile.face.eyeStyle,
|
|
207
252
|
);
|
|
@@ -228,7 +273,7 @@ export const octopus3dAvatarVisual: AvatarVisualDefinition = {
|
|
|
228
273
|
size,
|
|
229
274
|
palette,
|
|
230
275
|
timeMs,
|
|
231
|
-
animationPhase + 0.7 +
|
|
276
|
+
animationPhase + 0.7 + rightEyePhaseOffset,
|
|
232
277
|
interaction,
|
|
233
278
|
morphologyProfile.face.eyeStyle,
|
|
234
279
|
);
|
|
@@ -334,6 +379,9 @@ function drawOctopus3dAtmosphere(
|
|
|
334
379
|
/**
|
|
335
380
|
* Draws the soft ground shadow below the octopus.
|
|
336
381
|
*
|
|
382
|
+
* Uses a scaled radial gradient instead of `context.filter = 'blur()'` to approximate the
|
|
383
|
+
* blurry ellipse without triggering a costly software rasterization pass on every frame.
|
|
384
|
+
*
|
|
337
385
|
* @private helper of `octopus3dAvatarVisual`
|
|
338
386
|
*/
|
|
339
387
|
function drawOctopus3dShadow(
|
|
@@ -346,19 +394,23 @@ function drawOctopus3dShadow(
|
|
|
346
394
|
},
|
|
347
395
|
timeMs: number,
|
|
348
396
|
): void {
|
|
397
|
+
const cx = size * 0.5 + interaction.gazeX * size * 0.04;
|
|
398
|
+
const cy = size * 0.87 + Math.sin(timeMs / 920) * size * 0.008;
|
|
399
|
+
const rx = size * (0.18 + interaction.intensity * 0.02);
|
|
400
|
+
const ry = size * 0.06;
|
|
401
|
+
|
|
349
402
|
context.save();
|
|
350
|
-
context.
|
|
351
|
-
context.
|
|
403
|
+
context.translate(cx, cy);
|
|
404
|
+
context.scale(1, ry / rx);
|
|
405
|
+
const blurRadius = rx * 1.4;
|
|
406
|
+
const shadowGradient = context.createRadialGradient(0, 0, 0, 0, 0, blurRadius);
|
|
407
|
+
shadowGradient.addColorStop(0, `${palette.shadow}7a`);
|
|
408
|
+
shadowGradient.addColorStop(0.45, `${palette.shadow}44`);
|
|
409
|
+
shadowGradient.addColorStop(0.8, `${palette.shadow}1a`);
|
|
410
|
+
shadowGradient.addColorStop(1, `${palette.shadow}00`);
|
|
411
|
+
context.fillStyle = shadowGradient;
|
|
352
412
|
context.beginPath();
|
|
353
|
-
context.
|
|
354
|
-
size * 0.5 + interaction.gazeX * size * 0.04,
|
|
355
|
-
size * 0.87 + Math.sin(timeMs / 920) * size * 0.008,
|
|
356
|
-
size * (0.18 + interaction.intensity * 0.02),
|
|
357
|
-
size * 0.06,
|
|
358
|
-
0,
|
|
359
|
-
0,
|
|
360
|
-
Math.PI * 2,
|
|
361
|
-
);
|
|
413
|
+
context.arc(0, 0, blurRadius, 0, Math.PI * 2);
|
|
362
414
|
context.fill();
|
|
363
415
|
context.restore();
|
|
364
416
|
}
|
package/src/book-3.0/Book.ts
CHANGED
|
@@ -215,7 +215,9 @@ function parseBookMessageHeader(line: string): Pick<BookMessageBlock, 'marker' |
|
|
|
215
215
|
* @private internal utility of `Book`
|
|
216
216
|
*/
|
|
217
217
|
function parseCommitmentHeader(line: string): Commitment | null {
|
|
218
|
-
|
|
218
|
+
// Require at least 2 characters in the first keyword word to avoid treating common
|
|
219
|
+
// single-letter words (e.g. "V" in Czech, "I" or "A" in English) as commitment headers.
|
|
220
|
+
const match = /^([A-Z][A-Z0-9]+(?: [A-Z0-9]+)*)(?:\s+(.*))?$/u.exec(line);
|
|
219
221
|
if (!match) {
|
|
220
222
|
return null;
|
|
221
223
|
}
|
|
@@ -23,7 +23,7 @@ export type BookNodeAgentSource = Book | string_book;
|
|
|
23
23
|
*/
|
|
24
24
|
export type BookNodeAgentSourceOptions = {
|
|
25
25
|
readonly agentPath?: string;
|
|
26
|
-
readonly book?: BookNodeAgentSource;
|
|
26
|
+
readonly book?: string | BookNodeAgentSource;
|
|
27
27
|
readonly currentWorkingDirectory?: string;
|
|
28
28
|
};
|
|
29
29
|
|
|
@@ -92,7 +92,7 @@ export async function resolveBookNodeAgentSource(
|
|
|
92
92
|
*
|
|
93
93
|
* @private internal utility of `resolveBookNodeAgentSource`
|
|
94
94
|
*/
|
|
95
|
-
function normalizeBookNodeAgentSource(book: BookNodeAgentSource): string_book {
|
|
95
|
+
function normalizeBookNodeAgentSource(book: string | BookNodeAgentSource): string_book {
|
|
96
96
|
if (book instanceof Book) {
|
|
97
97
|
return book.stringify();
|
|
98
98
|
}
|
package/src/book-3.0/CliAgent.ts
CHANGED
|
@@ -3,22 +3,30 @@ import { dirname } from 'path';
|
|
|
3
3
|
import { executeAgentChatTurn } from '../../scripts/run-agent-chat/executeAgentChatTurn';
|
|
4
4
|
import { NotAllowed } from '../errors/NotAllowed';
|
|
5
5
|
import { resolvePromptbookTemporaryPath } from '../utils/filesystem/promptbookTemporaryPath';
|
|
6
|
+
import { spaceTrim } from '../utils/organization/spaceTrim';
|
|
6
7
|
import type { BookNodeAgentSourceOptions, ResolvedBookNodeAgentSource } from './BookNodeAgentSource';
|
|
7
8
|
import { resolveBookNodeAgentSource } from './BookNodeAgentSource';
|
|
9
|
+
import {
|
|
10
|
+
CLI_AGENT_HARNESS_NAMES,
|
|
11
|
+
CLI_AGENT_THINKING_LEVEL_VALUES,
|
|
12
|
+
PTBK_HARNESS_ENV,
|
|
13
|
+
PTBK_MODEL_ENV,
|
|
14
|
+
PTBK_THINKING_LEVEL_ENV,
|
|
15
|
+
} from './cliAgentEnv';
|
|
8
16
|
|
|
9
17
|
/**
|
|
10
18
|
* CLI harness names supported by `ptbk agent exec`.
|
|
11
19
|
*
|
|
12
20
|
* @public exported from `@promptbook/node`
|
|
13
21
|
*/
|
|
14
|
-
export type CliAgentHarness =
|
|
22
|
+
export type CliAgentHarness = (typeof CLI_AGENT_HARNESS_NAMES)[number];
|
|
15
23
|
|
|
16
24
|
/**
|
|
17
25
|
* Thinking levels supported by CLI coding harnesses.
|
|
18
26
|
*
|
|
19
27
|
* @public exported from `@promptbook/node`
|
|
20
28
|
*/
|
|
21
|
-
export type CliAgentThinkingLevel =
|
|
29
|
+
export type CliAgentThinkingLevel = (typeof CLI_AGENT_THINKING_LEVEL_VALUES)[number];
|
|
22
30
|
|
|
23
31
|
/**
|
|
24
32
|
* Per-run CLI options exposed by `CliAgent`.
|
|
@@ -31,6 +39,7 @@ export type CliAgentRunOptions = {
|
|
|
31
39
|
readonly allowCredits?: boolean;
|
|
32
40
|
readonly context?: string;
|
|
33
41
|
readonly harness?: CliAgentHarness;
|
|
42
|
+
readonly isVerbose?: boolean;
|
|
34
43
|
readonly model?: string;
|
|
35
44
|
readonly noUi?: boolean;
|
|
36
45
|
readonly thinkingLevel?: CliAgentThinkingLevel;
|
|
@@ -56,6 +65,9 @@ const DEFAULT_CLI_AGENT_IS_NO_UI = true;
|
|
|
56
65
|
* It uses the same harnesses and execution path as `ptbk agent exec`, running the runner
|
|
57
66
|
* in-process instead of spawning a separate CLI process.
|
|
58
67
|
*
|
|
68
|
+
* When no `harness` is provided in the constructor or per-run options, `CliAgent` falls back
|
|
69
|
+
* to the `PTBK_HARNESS` environment variable, mirroring `ptbk agent exec` behavior.
|
|
70
|
+
*
|
|
59
71
|
* @public exported from `@promptbook/node`
|
|
60
72
|
*/
|
|
61
73
|
export class CliAgent {
|
|
@@ -81,15 +93,30 @@ export class CliAgent {
|
|
|
81
93
|
const agentPath = await this.resolveExecutableAgentPath(resolvedSource);
|
|
82
94
|
const mergedOptions = mergeCliAgentRunOptions(this.options, options);
|
|
83
95
|
|
|
96
|
+
const harness = mergedOptions.harness ?? resolveCliAgentHarnessFromEnv();
|
|
97
|
+
|
|
98
|
+
if (!harness) {
|
|
99
|
+
throw new NotAllowed(
|
|
100
|
+
spaceTrim(`
|
|
101
|
+
No harness specified for \`CliAgent\`. Pass \`harness\` in the constructor options or per-run options,
|
|
102
|
+
or set the \`${PTBK_HARNESS_ENV}\` environment variable.
|
|
103
|
+
|
|
104
|
+
Available harnesses: ${CLI_AGENT_HARNESS_NAMES.join(', ')}
|
|
105
|
+
|
|
106
|
+
Example: \`PTBK_HARNESS=claude-code\`
|
|
107
|
+
`),
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
84
111
|
const result = await executeAgentChatTurn({
|
|
85
112
|
agentPath,
|
|
86
113
|
messages: [{ sender: 'USER', content: normalizedMessage }],
|
|
87
|
-
agentName:
|
|
88
|
-
model: mergedOptions.model,
|
|
114
|
+
agentName: harness,
|
|
115
|
+
model: mergedOptions.model ?? process.env[PTBK_MODEL_ENV],
|
|
89
116
|
noUi: mergedOptions.noUi ?? DEFAULT_CLI_AGENT_IS_NO_UI,
|
|
90
|
-
thinkingLevel: mergedOptions.thinkingLevel,
|
|
117
|
+
thinkingLevel: mergedOptions.thinkingLevel ?? resolveCliAgentThinkingLevelFromEnv(),
|
|
91
118
|
allowCredits: mergedOptions.allowCredits ?? false,
|
|
92
|
-
isVerbose: false,
|
|
119
|
+
isVerbose: mergedOptions.isVerbose ?? false,
|
|
93
120
|
context: mergedOptions.context,
|
|
94
121
|
currentWorkingDirectory: resolvedSource.currentWorkingDirectory,
|
|
95
122
|
});
|
|
@@ -128,12 +155,63 @@ function mergeCliAgentRunOptions(defaults: CliAgentRunOptions, overrides: CliAge
|
|
|
128
155
|
allowCredits: overrides.allowCredits ?? defaults.allowCredits,
|
|
129
156
|
context: overrides.context ?? defaults.context,
|
|
130
157
|
harness: overrides.harness ?? defaults.harness,
|
|
158
|
+
isVerbose: overrides.isVerbose ?? defaults.isVerbose,
|
|
131
159
|
model: overrides.model ?? defaults.model,
|
|
132
160
|
noUi: overrides.noUi ?? defaults.noUi,
|
|
133
161
|
thinkingLevel: overrides.thinkingLevel ?? defaults.thinkingLevel,
|
|
134
162
|
};
|
|
135
163
|
}
|
|
136
164
|
|
|
165
|
+
/**
|
|
166
|
+
* Reads and validates the harness name from the `PTBK_HARNESS` environment variable.
|
|
167
|
+
*
|
|
168
|
+
* @private internal utility of `CliAgent`
|
|
169
|
+
*/
|
|
170
|
+
function resolveCliAgentHarnessFromEnv(): CliAgentHarness | undefined {
|
|
171
|
+
const envValue = process.env[PTBK_HARNESS_ENV];
|
|
172
|
+
|
|
173
|
+
if (!envValue) {
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (!(CLI_AGENT_HARNESS_NAMES as ReadonlyArray<string>).includes(envValue)) {
|
|
178
|
+
throw new NotAllowed(
|
|
179
|
+
spaceTrim(`
|
|
180
|
+
Invalid value for \`${PTBK_HARNESS_ENV}\` environment variable: \`${envValue}\`
|
|
181
|
+
|
|
182
|
+
Must be one of: ${CLI_AGENT_HARNESS_NAMES.join(', ')}
|
|
183
|
+
`),
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return envValue as CliAgentHarness;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Reads and validates the thinking level from the `PTBK_THINKING_LEVEL` environment variable.
|
|
192
|
+
*
|
|
193
|
+
* @private internal utility of `CliAgent`
|
|
194
|
+
*/
|
|
195
|
+
function resolveCliAgentThinkingLevelFromEnv(): CliAgentThinkingLevel | undefined {
|
|
196
|
+
const envValue = process.env[PTBK_THINKING_LEVEL_ENV];
|
|
197
|
+
|
|
198
|
+
if (!envValue) {
|
|
199
|
+
return undefined;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (!(CLI_AGENT_THINKING_LEVEL_VALUES as ReadonlyArray<string>).includes(envValue)) {
|
|
203
|
+
throw new NotAllowed(
|
|
204
|
+
spaceTrim(`
|
|
205
|
+
Invalid value for \`${PTBK_THINKING_LEVEL_ENV}\` environment variable: \`${envValue}\`
|
|
206
|
+
|
|
207
|
+
Must be one of: ${CLI_AGENT_THINKING_LEVEL_VALUES.join(', ')}
|
|
208
|
+
`),
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return envValue as CliAgentThinkingLevel;
|
|
213
|
+
}
|
|
214
|
+
|
|
137
215
|
/**
|
|
138
216
|
* Creates the stable temporary path used when `CliAgent` is initialized from in-memory Book source.
|
|
139
217
|
*
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* All CLI harness names supported by `CliAgent` and `ptbk agent exec`.
|
|
5
|
+
*
|
|
6
|
+
* @public exported from `@promptbook/node`
|
|
7
|
+
*/
|
|
8
|
+
export const CLI_AGENT_HARNESS_NAMES = [
|
|
9
|
+
'openai-codex',
|
|
10
|
+
'github-copilot',
|
|
11
|
+
'cline',
|
|
12
|
+
'claude-code',
|
|
13
|
+
'opencode',
|
|
14
|
+
'gemini',
|
|
15
|
+
] as const;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* All supported thinking-level values for CLI coding-agent runners.
|
|
19
|
+
*
|
|
20
|
+
* @public exported from `@promptbook/node`
|
|
21
|
+
*/
|
|
22
|
+
export const CLI_AGENT_THINKING_LEVEL_VALUES = ['low', 'medium', 'high', 'xhigh'] as const;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Environment variable used as the default runner identifier when `--harness` is omitted or not set in `CliAgent`.
|
|
26
|
+
*
|
|
27
|
+
* Set this to one of the harness names (`openai-codex`, `github-copilot`, `cline`, `claude-code`, `opencode`, `gemini`)
|
|
28
|
+
* so that `CliAgent` and `ptbk agent exec` can run without an explicit `harness` option.
|
|
29
|
+
*
|
|
30
|
+
* @public exported from `@promptbook/node`
|
|
31
|
+
*/
|
|
32
|
+
export const PTBK_HARNESS_ENV = 'PTBK_HARNESS';
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Environment variable used as the default runner model when `--model` is omitted or not set in `CliAgent`.
|
|
36
|
+
*
|
|
37
|
+
* @public exported from `@promptbook/node`
|
|
38
|
+
*/
|
|
39
|
+
export const PTBK_MODEL_ENV = 'PTBK_MODEL';
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Environment variable used as the default thinking level when `--thinking-level` is omitted or not set in `CliAgent`.
|
|
43
|
+
*
|
|
44
|
+
* @public exported from `@promptbook/node`
|
|
45
|
+
*/
|
|
46
|
+
export const PTBK_THINKING_LEVEL_ENV = 'PTBK_THINKING_LEVEL';
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
normalizePromptRunnerCliOptions,
|
|
12
12
|
PROMPT_RUNNER_DESCRIPTION,
|
|
13
13
|
} from '../common/promptRunnerCliOptions';
|
|
14
|
+
import { parseDuration } from '../../../../scripts/run-codex-prompts/common/parseDuration';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Initializes `coder run` command for Promptbook CLI utilities
|
|
@@ -57,7 +58,17 @@ export function $initializeCoderRunCommand(program: Program): $side_effect {
|
|
|
57
58
|
);
|
|
58
59
|
addPromptRunnerExecutionOptions(command);
|
|
59
60
|
command.option('--priority <minimum-priority>', 'Filter prompts by minimum priority level', parseIntOption, 0);
|
|
60
|
-
command.option(
|
|
61
|
+
command.option(
|
|
62
|
+
'--wait [duration]',
|
|
63
|
+
spaceTrim(`
|
|
64
|
+
Wait between prompt rounds.
|
|
65
|
+
Without a value (default): waits for user confirmation before each prompt (interactive mode).
|
|
66
|
+
With a duration like 1h, 30m, 5s: waits that long between prompts to avoid hitting rate limits of the harness.
|
|
67
|
+
`),
|
|
68
|
+
true,
|
|
69
|
+
);
|
|
70
|
+
// Note: --no-wait disables the default interactive wait-for-user behaviour
|
|
71
|
+
command.option('--no-wait', 'Skip all waiting between prompts and run non-interactively');
|
|
61
72
|
command.option(
|
|
62
73
|
'--auto-migrate',
|
|
63
74
|
'Run testing-server database migrations automatically after each successfully processed prompt',
|
|
@@ -76,7 +87,7 @@ export function $initializeCoderRunCommand(program: Program): $side_effect {
|
|
|
76
87
|
readonly test?: string | string[];
|
|
77
88
|
readonly preserveLogs: boolean;
|
|
78
89
|
readonly priority: number;
|
|
79
|
-
readonly wait: boolean;
|
|
90
|
+
readonly wait: boolean | string;
|
|
80
91
|
readonly autoMigrate: boolean;
|
|
81
92
|
readonly allowDestructiveAutoMigrate: boolean;
|
|
82
93
|
} & PromptRunnerCliOptions;
|
|
@@ -86,10 +97,24 @@ export function $initializeCoderRunCommand(program: Program): $side_effect {
|
|
|
86
97
|
isAgentRequired: !dryRun,
|
|
87
98
|
});
|
|
88
99
|
|
|
100
|
+
// [1] Parse the --wait option:
|
|
101
|
+
// true (default or --wait without value): wait for user confirmation
|
|
102
|
+
// false (--no-wait): no waiting at all
|
|
103
|
+
// string (--wait 1h): wait that long between prompt rounds
|
|
104
|
+
let waitForUser = false;
|
|
105
|
+
let waitBetweenPrompts = 0;
|
|
106
|
+
|
|
107
|
+
if (wait === true) {
|
|
108
|
+
waitForUser = true;
|
|
109
|
+
} else if (typeof wait === 'string' && wait !== '') {
|
|
110
|
+
waitBetweenPrompts = parseDuration(wait);
|
|
111
|
+
}
|
|
112
|
+
|
|
89
113
|
// Convert commander options to RunOptions format
|
|
90
114
|
const runOptions = {
|
|
91
115
|
dryRun,
|
|
92
|
-
waitForUser
|
|
116
|
+
waitForUser,
|
|
117
|
+
waitBetweenPrompts,
|
|
93
118
|
noCommit: runnerOptions.noCommit,
|
|
94
119
|
ignoreGitChanges: runnerOptions.ignoreGitChanges,
|
|
95
120
|
agentName: runnerOptions.agentName,
|
|
@@ -6,41 +6,21 @@ import {
|
|
|
6
6
|
import { spaceTrim } from 'spacetrim';
|
|
7
7
|
import type { ThinkingLevel } from '../coder/ThinkingLevel';
|
|
8
8
|
import { THINKING_LEVEL_VALUES } from '../coder/ThinkingLevel';
|
|
9
|
+
import {
|
|
10
|
+
CLI_AGENT_HARNESS_NAMES,
|
|
11
|
+
PTBK_HARNESS_ENV,
|
|
12
|
+
PTBK_MODEL_ENV,
|
|
13
|
+
PTBK_THINKING_LEVEL_ENV,
|
|
14
|
+
} from '../../../book-3.0/cliAgentEnv';
|
|
9
15
|
|
|
10
|
-
|
|
11
|
-
* Runner identifiers supported by Promptbook CLI agent orchestration commands.
|
|
12
|
-
*
|
|
13
|
-
* @private internal utility of `promptbookCli`
|
|
14
|
-
*/
|
|
15
|
-
export const PROMPT_RUNNER_HARNESS_NAMES = [
|
|
16
|
-
'openai-codex',
|
|
17
|
-
'github-copilot',
|
|
18
|
-
'cline',
|
|
19
|
-
'claude-code',
|
|
20
|
-
'opencode',
|
|
21
|
-
'gemini',
|
|
22
|
-
] as const;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Environment variable used as the default runner identifier when `--harness` is omitted.
|
|
26
|
-
*
|
|
27
|
-
* @private internal utility of `promptbookCli`
|
|
28
|
-
*/
|
|
29
|
-
export const PTBK_HARNESS_ENV = 'PTBK_HARNESS';
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Environment variable used as the default runner model when `--model` is omitted.
|
|
33
|
-
*
|
|
34
|
-
* @private internal utility of `promptbookCli`
|
|
35
|
-
*/
|
|
36
|
-
export const PTBK_MODEL_ENV = 'PTBK_MODEL';
|
|
16
|
+
export { PTBK_HARNESS_ENV, PTBK_MODEL_ENV, PTBK_THINKING_LEVEL_ENV };
|
|
37
17
|
|
|
38
18
|
/**
|
|
39
|
-
*
|
|
19
|
+
* Runner identifiers supported by Promptbook CLI agent orchestration commands.
|
|
40
20
|
*
|
|
41
21
|
* @private internal utility of `promptbookCli`
|
|
42
22
|
*/
|
|
43
|
-
export const
|
|
23
|
+
export const PROMPT_RUNNER_HARNESS_NAMES = CLI_AGENT_HARNESS_NAMES;
|
|
44
24
|
|
|
45
25
|
/**
|
|
46
26
|
* Runner identifier supported by Promptbook CLI agent orchestration commands.
|