@promptbook/cli 0.112.0-112 → 0.112.0-114

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.
Files changed (94) hide show
  1. package/README.md +7 -7
  2. package/apps/agents-server/README.md +1 -1
  3. package/apps/agents-server/next.config.ts +20 -1
  4. package/apps/agents-server/src/app/agents/[agentName]/api/user-chats/[chatId]/stream/route.ts +85 -56
  5. package/apps/agents-server/src/app/agents/[agentName]/chat/useAgentChatHistorySyncEffects.ts +7 -13
  6. package/apps/agents-server/src/app/api/admin/code-runners/route.ts +1 -1
  7. package/apps/agents-server/src/app/api/internal/user-chat-jobs/run/route.ts +1 -1
  8. package/apps/agents-server/src/database/migrations/2026-06-1300-user-chat-active-read-indexes.sql +7 -0
  9. package/apps/agents-server/src/instrumentation-client.ts +28 -0
  10. package/apps/agents-server/src/instrumentation.ts +16 -0
  11. package/apps/agents-server/src/sentry.edge.config.ts +18 -0
  12. package/apps/agents-server/src/sentry.server.config.ts +19 -0
  13. package/apps/agents-server/src/utils/agentRouting/resolveAgentRouteTarget.ts +38 -0
  14. package/apps/agents-server/src/utils/codeRunnerConfiguration.ts +1 -1
  15. package/apps/agents-server/src/utils/errorReporting/agentsServerSentryContext.ts +203 -0
  16. package/apps/agents-server/src/utils/errorReporting/registerServerErrorSentryLogging.ts +59 -9
  17. package/apps/agents-server/src/utils/errorReporting/sendApplicationErrorReportToSentry.ts +39 -3
  18. package/apps/agents-server/src/utils/errorReporting/sentrySdkConfig.ts +237 -0
  19. package/apps/agents-server/src/utils/errorReporting/sentryStore.ts +10 -0
  20. package/apps/agents-server/src/utils/externalChatRunner/createExternalAgentRepositoryFiles.ts +2 -2
  21. package/apps/agents-server/src/utils/userChat/createImmediateUserChatAnswerModelRequirements.ts +15 -12
  22. package/apps/agents-server/src/utils/userChat/createUserChatDetailPayload.ts +33 -18
  23. package/apps/agents-server/src/utils/userChat/hasPotentiallyPendingAssistantMessages.ts +26 -0
  24. package/apps/agents-server/src/utils/userChat/runImmediateUserChatAnswer.ts +1 -1
  25. package/apps/agents-server/src/utils/userChat/triggerUserChatJobWorker.ts +54 -19
  26. package/apps/agents-server/src/utils/vpsConfiguration.ts +1 -1
  27. package/esm/index.es.js +9285 -8807
  28. package/esm/index.es.js.map +1 -1
  29. package/esm/scripts/run-agent-chat/executeAgentChatTurn.d.ts +28 -0
  30. package/esm/scripts/run-agent-chat/runAgentChat.d.ts +5 -0
  31. package/esm/scripts/run-agent-chat/runAgentExec.d.ts +11 -0
  32. package/esm/scripts/run-agent-messages/messages/createAgentRunnerSystemMessage.d.ts +10 -0
  33. package/esm/scripts/run-codex-prompts/common/resolveInlineOrFileText.d.ts +14 -0
  34. package/esm/scripts/run-codex-prompts/common/runGoScript/printLiveScriptChunk.d.ts +4 -0
  35. package/esm/src/_packages/node.index.d.ts +20 -0
  36. package/esm/src/_packages/types.index.d.ts +16 -0
  37. package/esm/src/book-3.0/BookNodeAgentSource.d.ts +38 -0
  38. package/esm/src/book-3.0/CliAgent.d.ts +68 -0
  39. package/esm/src/book-3.0/LiteAgent.d.ts +68 -0
  40. package/esm/src/book-components/BookEditor/BookEditorAboutPromptbookInformation.d.ts +12 -0
  41. package/esm/src/cli/cli-commands/agent/agentCliOptions.d.ts +38 -0
  42. package/esm/src/cli/cli-commands/agent/chat.d.ts +10 -0
  43. package/esm/src/cli/cli-commands/agent/exec.d.ts +10 -0
  44. package/esm/src/cli/cli-commands/agent/run.test.d.ts +1 -0
  45. package/esm/src/cli/cli-commands/agent.d.ts +14 -0
  46. package/esm/src/cli/cli-commands/agents-server/startAgentsServer.d.ts +3 -4
  47. package/esm/src/cli/cli-commands/common/promptRunnerCliOptions.d.ts +9 -9
  48. package/esm/src/version.d.ts +1 -1
  49. package/package.json +2 -1
  50. package/src/_packages/node.index.ts +20 -0
  51. package/src/_packages/types.index.ts +16 -0
  52. package/src/book-3.0/BookNodeAgentSource.ts +135 -0
  53. package/src/book-3.0/CliAgent.ts +236 -0
  54. package/src/book-3.0/LiteAgent.ts +468 -0
  55. package/src/book-components/BookEditor/BookEditor.module.css +61 -0
  56. package/src/book-components/BookEditor/BookEditorAboutPromptbookInformation.tsx +74 -0
  57. package/src/book-components/BookEditor/BookEditorActionbar.tsx +3 -3
  58. package/src/cli/cli-commands/agent/agentCliOptions.ts +92 -0
  59. package/src/cli/cli-commands/agent/chat.ts +54 -0
  60. package/src/cli/cli-commands/agent/exec.ts +60 -0
  61. package/src/cli/cli-commands/agent.ts +44 -0
  62. package/src/cli/cli-commands/agents-server/startAgentsServer.ts +3 -19
  63. package/src/cli/cli-commands/coder/getDefaultCoderPackageJsonScripts.ts +1 -1
  64. package/src/cli/cli-commands/common/promptRunnerCliOptions.ts +27 -23
  65. package/src/cli/promptbookCli.ts +2 -0
  66. package/src/other/templates/getTemplatesPipelineCollection.ts +747 -771
  67. package/src/version.ts +2 -2
  68. package/src/versions.txt +2 -0
  69. package/umd/index.umd.js +9285 -8807
  70. package/umd/index.umd.js.map +1 -1
  71. package/umd/scripts/run-agent-chat/executeAgentChatTurn.d.ts +28 -0
  72. package/umd/scripts/run-agent-chat/runAgentChat.d.ts +5 -0
  73. package/umd/scripts/run-agent-chat/runAgentExec.d.ts +11 -0
  74. package/umd/scripts/run-agent-messages/messages/createAgentRunnerSystemMessage.d.ts +10 -0
  75. package/umd/scripts/run-codex-prompts/common/resolveInlineOrFileText.d.ts +14 -0
  76. package/umd/scripts/run-codex-prompts/common/runGoScript/printLiveScriptChunk.d.ts +4 -0
  77. package/umd/src/_packages/node.index.d.ts +20 -0
  78. package/umd/src/_packages/types.index.d.ts +16 -0
  79. package/umd/src/book-3.0/BookNodeAgentSource.d.ts +38 -0
  80. package/umd/src/book-3.0/CliAgent.d.ts +68 -0
  81. package/umd/src/book-3.0/CliAgent.test.d.ts +1 -0
  82. package/umd/src/book-3.0/LiteAgent.d.ts +68 -0
  83. package/umd/src/book-3.0/LiteAgent.test.d.ts +1 -0
  84. package/umd/src/book-components/BookEditor/BookEditorAboutPromptbookInformation.d.ts +12 -0
  85. package/umd/src/cli/cli-commands/agent/agentCliOptions.d.ts +38 -0
  86. package/umd/src/cli/cli-commands/agent/chat.d.ts +10 -0
  87. package/umd/src/cli/cli-commands/agent/exec.d.ts +10 -0
  88. package/umd/src/cli/cli-commands/agent/run.test.d.ts +1 -0
  89. package/umd/src/cli/cli-commands/agent.d.ts +14 -0
  90. package/umd/src/cli/cli-commands/agents-server/startAgentsServer.d.ts +3 -4
  91. package/umd/src/cli/cli-commands/common/promptRunnerCliOptions.d.ts +9 -9
  92. package/umd/src/version.d.ts +1 -1
  93. /package/esm/src/{cli/cli-commands/agents-server/startAgentsServer.test.d.ts → book-3.0/CliAgent.test.d.ts} +0 -0
  94. /package/{umd/src/cli/cli-commands/agents-server/startAgentsServer.test.d.ts → esm/src/book-3.0/LiteAgent.test.d.ts} +0 -0
@@ -0,0 +1,92 @@
1
+ import type {
2
+ Command as Program /* <- Note: [🔸] Using Program because Command is misleading name */,
3
+ } from 'commander';
4
+ import { NotAllowed } from '../../../errors/NotAllowed';
5
+ import type {
6
+ NormalizedPromptRunnerSelectionCliOptions,
7
+ PromptRunnerSelectionCliOptions,
8
+ } from '../common/promptRunnerCliOptions';
9
+ import { normalizePromptRunnerSelectionCliOptions } from '../common/promptRunnerCliOptions';
10
+
11
+ /**
12
+ * Commander option bag shared by `ptbk agent` subcommands.
13
+ *
14
+ * @private internal utility of `ptbk agent`
15
+ */
16
+ export type AgentCommandCliOptions = PromptRunnerSelectionCliOptions & {
17
+ readonly agent?: string;
18
+ readonly context?: string;
19
+ readonly message?: string;
20
+ };
21
+
22
+ /**
23
+ * Normalized shared options used by local `ptbk agent` subcommands.
24
+ *
25
+ * @private internal utility of `ptbk agent`
26
+ */
27
+ export type NormalizedAgentCommandRunnerOptions = NormalizedPromptRunnerSelectionCliOptions & {
28
+ readonly isVerbose: boolean;
29
+ };
30
+
31
+ /**
32
+ * Normalizes shared runner flags for local agent subcommands.
33
+ *
34
+ * @private internal utility of `ptbk agent`
35
+ */
36
+ export function normalizeAgentCommandRunnerOptions(
37
+ cliOptions: AgentCommandCliOptions,
38
+ command: Program,
39
+ ): NormalizedAgentCommandRunnerOptions {
40
+ return {
41
+ ...normalizePromptRunnerSelectionCliOptions(cliOptions, {
42
+ isAgentRequired: true,
43
+ }),
44
+ isVerbose: resolveCommandVerboseOption(command),
45
+ };
46
+ }
47
+
48
+ // Note: [🟡] Code for CLI command options [agent](src/cli/cli-commands/agent/agentCliOptions.ts) should never be published outside of `@promptbook/cli`
49
+ // Note: [💞] Ignore a discrepancy between file name and exported helper names
50
+
51
+ /**
52
+ * Returns the required agent book path from Commander options.
53
+ *
54
+ * @private internal utility of `ptbk agent`
55
+ */
56
+ export function resolveRequiredAgentPath(cliOptions: AgentCommandCliOptions): string {
57
+ const agentPath = cliOptions.agent?.trim();
58
+
59
+ if (!agentPath) {
60
+ throw new NotAllowed('Pass an agent book path in `--agent`.');
61
+ }
62
+
63
+ return agentPath;
64
+ }
65
+
66
+ /**
67
+ * Returns the required single-turn user message from Commander options.
68
+ *
69
+ * @private internal utility of `ptbk agent`
70
+ */
71
+ export function resolveRequiredAgentMessage(cliOptions: AgentCommandCliOptions): string {
72
+ const message = cliOptions.message?.trim();
73
+
74
+ if (!message) {
75
+ throw new NotAllowed('Pass a non-empty user message in `--message`.');
76
+ }
77
+
78
+ return message;
79
+ }
80
+
81
+ /**
82
+ * Resolves the inherited `--verbose` flag from the current Commander command chain.
83
+ *
84
+ * @private internal utility of `ptbk agent`
85
+ */
86
+ function resolveCommandVerboseOption(command: Program): boolean {
87
+ const globalOptions = command.optsWithGlobals() as {
88
+ readonly verbose?: boolean;
89
+ };
90
+
91
+ return globalOptions.verbose ?? false;
92
+ }
@@ -0,0 +1,54 @@
1
+ import type {
2
+ Command as Program /* <- Note: [🔸] Using Program because Command is misleading name */,
3
+ } from 'commander';
4
+ import { spaceTrim } from 'spacetrim';
5
+ import type { $side_effect } from '../../../utils/organization/$side_effect';
6
+ import { handleActionErrors } from '../common/handleActionErrors';
7
+ import {
8
+ addPromptRunnerRuntimeOptions,
9
+ addPromptRunnerSelectionOptions,
10
+ PROMPT_RUNNER_DESCRIPTION,
11
+ } from '../common/promptRunnerCliOptions';
12
+ import type { AgentCommandCliOptions } from './agentCliOptions';
13
+ import { normalizeAgentCommandRunnerOptions, resolveRequiredAgentPath } from './agentCliOptions';
14
+
15
+ /**
16
+ * Initializes `agent chat` command for Promptbook CLI utilities.
17
+ *
18
+ * Note: `$` is used to indicate that this function is not a pure function - it registers a command in the CLI.
19
+ *
20
+ * @private internal function of `promptbookCli`
21
+ */
22
+ export function $initializeAgentChatCommand(program: Program): $side_effect {
23
+ const command = program.command('chat');
24
+ command.description(
25
+ spaceTrim(`
26
+ Run an interactive CLI chat with one Promptbook agent book
27
+
28
+ ${PROMPT_RUNNER_DESCRIPTION}
29
+ `),
30
+ );
31
+
32
+ command.requiredOption('--agent <agent-book-path>', 'Path to the agent .book file');
33
+ addPromptRunnerSelectionOptions(command);
34
+ addPromptRunnerRuntimeOptions(command);
35
+ command.option('--context <context-or-file>', 'Append extra context either inline or from a file path');
36
+
37
+ command.action(
38
+ handleActionErrors(async (cliOptions, commandProgram) => {
39
+ const options = cliOptions as AgentCommandCliOptions;
40
+ const runnerOptions = normalizeAgentCommandRunnerOptions(options, commandProgram as Program);
41
+ const { runAgentChat } = await import('../../../../scripts/run-agent-chat/runAgentChat');
42
+
43
+ await runAgentChat({
44
+ agentPath: resolveRequiredAgentPath(options),
45
+ context: options.context,
46
+ currentWorkingDirectory: process.cwd(),
47
+ ...runnerOptions,
48
+ });
49
+ }),
50
+ );
51
+ }
52
+
53
+ // Note: [🟡] Code for CLI command [agent chat](src/cli/cli-commands/agent/chat.ts) should never be published outside of `@promptbook/cli`
54
+ // Note: [💞] Ignore a discrepancy between file name and entity name
@@ -0,0 +1,60 @@
1
+ import type {
2
+ Command as Program /* <- Note: [🔸] Using Program because Command is misleading name */,
3
+ } from 'commander';
4
+ import { spaceTrim } from 'spacetrim';
5
+ import type { $side_effect } from '../../../utils/organization/$side_effect';
6
+ import { handleActionErrors } from '../common/handleActionErrors';
7
+ import {
8
+ addPromptRunnerRuntimeOptions,
9
+ addPromptRunnerSelectionOptions,
10
+ PROMPT_RUNNER_DESCRIPTION,
11
+ } from '../common/promptRunnerCliOptions';
12
+ import type { AgentCommandCliOptions } from './agentCliOptions';
13
+ import {
14
+ normalizeAgentCommandRunnerOptions,
15
+ resolveRequiredAgentMessage,
16
+ resolveRequiredAgentPath,
17
+ } from './agentCliOptions';
18
+
19
+ /**
20
+ * Initializes `agent exec` command for Promptbook CLI utilities.
21
+ *
22
+ * Note: `$` is used to indicate that this function is not a pure function - it registers a command in the CLI.
23
+ *
24
+ * @private internal function of `promptbookCli`
25
+ */
26
+ export function $initializeAgentExecCommand(program: Program): $side_effect {
27
+ const command = program.command('exec');
28
+ command.description(
29
+ spaceTrim(`
30
+ Run one non-interactive message with a Promptbook agent book and print the answer
31
+
32
+ ${PROMPT_RUNNER_DESCRIPTION}
33
+ `),
34
+ );
35
+
36
+ command.requiredOption('--agent <agent-book-path>', 'Path to the agent .book file');
37
+ command.requiredOption('--message <message>', 'User message to send to the agent');
38
+ addPromptRunnerSelectionOptions(command);
39
+ addPromptRunnerRuntimeOptions(command);
40
+ command.option('--context <context-or-file>', 'Append extra context either inline or from a file path');
41
+
42
+ command.action(
43
+ handleActionErrors(async (cliOptions, commandProgram) => {
44
+ const options = cliOptions as AgentCommandCliOptions;
45
+ const runnerOptions = normalizeAgentCommandRunnerOptions(options, commandProgram as Program);
46
+ const { runAgentExec } = await import('../../../../scripts/run-agent-chat/runAgentExec');
47
+
48
+ await runAgentExec({
49
+ agentPath: resolveRequiredAgentPath(options),
50
+ context: options.context,
51
+ message: resolveRequiredAgentMessage(options),
52
+ currentWorkingDirectory: process.cwd(),
53
+ ...runnerOptions,
54
+ });
55
+ }),
56
+ );
57
+ }
58
+
59
+ // Note: [🟡] Code for CLI command [agent exec](src/cli/cli-commands/agent/exec.ts) should never be published outside of `@promptbook/cli`
60
+ // Note: [💞] Ignore a discrepancy between file name and entity name
@@ -0,0 +1,44 @@
1
+ import colors from 'colors';
2
+ import type {
3
+ Command as Program /* <- Note: [🔸] Using Program because Command is misleading name */,
4
+ } from 'commander';
5
+ import { spaceTrim } from 'spacetrim';
6
+ import type { $side_effect } from '../../utils/organization/$side_effect';
7
+ import { $initializeAgentChatCommand } from './agent/chat';
8
+ import { $initializeAgentExecCommand } from './agent/exec';
9
+
10
+ /**
11
+ * Initializes `agent` command with subcommands for Promptbook CLI utilities.
12
+ *
13
+ * The agent command runs one `.book` source directly through a selected CLI harness:
14
+ * - chat: Run an interactive terminal chat session
15
+ * - exec: Send one message and print the response
16
+ *
17
+ * Note: `$` is used to indicate that this function is not a pure function - it registers a command in the CLI.
18
+ *
19
+ * @private internal function of `promptbookCli`
20
+ */
21
+ export function $initializeAgentCommand(program: Program): $side_effect {
22
+ const agentCommand = program.command('agent');
23
+ agentCommand.description(
24
+ spaceTrim(`
25
+ Run a Promptbook agent book directly in the terminal
26
+
27
+ Subcommands:
28
+ - chat: Run an interactive terminal chat session
29
+ - exec: Send one message and print the response
30
+ `),
31
+ );
32
+
33
+ $initializeAgentChatCommand(agentCommand);
34
+ $initializeAgentExecCommand(agentCommand);
35
+
36
+ agentCommand.action(() => {
37
+ console.info(colors.yellow('Please specify a subcommand.'));
38
+ console.info('');
39
+ agentCommand.help();
40
+ });
41
+ }
42
+
43
+ // Note: [🟡] Code for CLI command [agent](src/cli/cli-commands/agent.ts) should never be published outside of `@promptbook/cli`
44
+ // Note: [💞] Ignore a discrepancy between file name and entity name
@@ -6,7 +6,7 @@ import { join } from 'path';
6
6
  import * as dotenv from 'dotenv';
7
7
  import { spaceTrim } from 'spacetrim';
8
8
  import type { ThinkingLevel } from '../coder/ThinkingLevel';
9
- import type { PromptRunnerAgentName } from '../common/promptRunnerCliOptions';
9
+ import type { PromptRunnerHarnessName } from '../common/promptRunnerCliOptions';
10
10
  import { NotAllowed } from '../../../errors/NotAllowed';
11
11
  import type { number_port } from '../../../types/number_positive';
12
12
  import { resolvePromptbookTemporaryPath } from '../../../utils/filesystem/promptbookTemporaryPath';
@@ -107,13 +107,6 @@ const PTBK_AGENTS_SERVER_SQLITE_PATH_ENV = 'PTBK_AGENTS_SERVER_SQLITE_PATH';
107
107
  */
108
108
  const PTBK_HOSTNAME_ENV = 'PTBK_HOSTNAME';
109
109
 
110
- /**
111
- * Explicit installed `.env` file passed by standalone VPS pm2/runtime launchers.
112
- *
113
- * @private internal constant of `ptbk agents-server`
114
- */
115
- const PTBK_AGENTS_SERVER_ENV_FILE_ENV = 'PTBK_AGENTS_SERVER_ENV_FILE';
116
-
117
110
  /**
118
111
  * Entropy size for the local-only token shared by the CLI pump and the Next app.
119
112
  *
@@ -135,7 +128,7 @@ export type AgentsServerNextRuntimeMode = 'start' | 'dev';
135
128
  */
136
129
  export type StartAgentsServerOptions = {
137
130
  readonly port: number_port;
138
- readonly agentName: PromptRunnerAgentName;
131
+ readonly agentName: PromptRunnerHarnessName;
139
132
  readonly model?: string;
140
133
  readonly noUi: boolean;
141
134
  readonly thinkingLevel?: ThinkingLevel;
@@ -362,20 +355,11 @@ async function prepareAgentsServerDevelopmentRuntime(
362
355
  }
363
356
 
364
357
  /**
365
- * Loads Agents Server runtime environment from the installed `.env` file when explicitly configured and falls back
366
- * to the launch-directory `.env`.
358
+ * Loads launch-directory `.env` values without overriding explicit process environment.
367
359
  *
368
360
  * @private internal utility of `ptbk agents-server`
369
361
  */
370
362
  export function loadAgentsServerProjectEnvironment(launchWorkingDirectory: string): void {
371
- const explicitEnvFilePath = process.env[PTBK_AGENTS_SERVER_ENV_FILE_ENV]?.trim();
372
- if (explicitEnvFilePath) {
373
- const explicitLoadResult = dotenv.config({ path: explicitEnvFilePath, override: true });
374
- if (!explicitLoadResult.error) {
375
- return;
376
- }
377
- }
378
-
379
363
  dotenv.config({ path: join(launchWorkingDirectory, AGENTS_SERVER_PROJECT_ENV_FILE_NAME) });
380
364
  }
381
365
 
@@ -4,7 +4,7 @@
4
4
  const DEFAULT_CODER_PACKAGE_JSON_SCRIPTS = {
5
5
  'coder:generate-boilerplates': 'ptbk coder generate-boilerplates --template ./prompts/templates/common.md',
6
6
  'coder:run':
7
- 'ptbk coder run --agent github-copilot --model gpt-5.4 --thinking-level xhigh --context AGENTS.md --no-wait',
7
+ 'ptbk coder run --harness github-copilot --model gpt-5.4 --thinking-level xhigh --context AGENTS.md --no-wait',
8
8
  'coder:find-refactor-candidates': 'ptbk coder find-refactor-candidates',
9
9
  'coder:verify': 'ptbk coder verify',
10
10
  } as const satisfies Readonly<Record<string, string>>;
@@ -12,7 +12,7 @@ import { THINKING_LEVEL_VALUES } from '../coder/ThinkingLevel';
12
12
  *
13
13
  * @private internal utility of `promptbookCli`
14
14
  */
15
- export const PROMPT_RUNNER_AGENT_NAMES = [
15
+ export const PROMPT_RUNNER_HARNESS_NAMES = [
16
16
  'openai-codex',
17
17
  'github-copilot',
18
18
  'cline',
@@ -22,11 +22,11 @@ export const PROMPT_RUNNER_AGENT_NAMES = [
22
22
  ] as const;
23
23
 
24
24
  /**
25
- * Environment variable used as the default runner identifier when `--agent` is omitted.
25
+ * Environment variable used as the default runner identifier when `--harness` is omitted.
26
26
  *
27
27
  * @private internal utility of `promptbookCli`
28
28
  */
29
- export const PTBK_AGENT_ENV = 'PTBK_AGENT';
29
+ export const PTBK_HARNESS_ENV = 'PTBK_HARNESS';
30
30
 
31
31
  /**
32
32
  * Environment variable used as the default runner model when `--model` is omitted.
@@ -47,7 +47,7 @@ export const PTBK_THINKING_LEVEL_ENV = 'PTBK_THINKING_LEVEL';
47
47
  *
48
48
  * @private internal utility of `promptbookCli`
49
49
  */
50
- export type PromptRunnerAgentName = (typeof PROMPT_RUNNER_AGENT_NAMES)[number];
50
+ export type PromptRunnerHarnessName = (typeof PROMPT_RUNNER_HARNESS_NAMES)[number];
51
51
 
52
52
  /**
53
53
  * Commander option bag for shared runner flags.
@@ -55,7 +55,7 @@ export type PromptRunnerAgentName = (typeof PROMPT_RUNNER_AGENT_NAMES)[number];
55
55
  * @private internal utility of `promptbookCli`
56
56
  */
57
57
  export type PromptRunnerCliOptions = {
58
- readonly agent?: string;
58
+ readonly harness?: string;
59
59
  readonly model?: string;
60
60
  readonly ui: boolean;
61
61
  readonly thinkingLevel?: ThinkingLevel;
@@ -74,7 +74,7 @@ export type PromptRunnerCliOptions = {
74
74
  */
75
75
  export type PromptRunnerSelectionCliOptions = Pick<
76
76
  PromptRunnerCliOptions,
77
- 'agent' | 'model' | 'ui' | 'thinkingLevel' | 'allowCredits'
77
+ 'harness' | 'model' | 'ui' | 'thinkingLevel' | 'allowCredits'
78
78
  >;
79
79
 
80
80
  /**
@@ -83,7 +83,7 @@ export type PromptRunnerSelectionCliOptions = Pick<
83
83
  * @private internal utility of `promptbookCli`
84
84
  */
85
85
  export type NormalizedPromptRunnerCliOptions = {
86
- readonly agentName?: PromptRunnerAgentName;
86
+ readonly agentName?: PromptRunnerHarnessName;
87
87
  readonly model?: string;
88
88
  readonly noUi: boolean;
89
89
  readonly thinkingLevel?: ThinkingLevel;
@@ -121,11 +121,11 @@ export const PROMPT_RUNNER_DESCRIPTION = spaceTrim(`
121
121
  `);
122
122
 
123
123
  /**
124
- * Commander description for the `--agent` option.
124
+ * Commander description for the `--harness` option.
125
125
  *
126
126
  * @private internal utility of `promptbookCli`
127
127
  */
128
- export const PROMPT_RUNNER_AGENT_OPTION_DESCRIPTION =
128
+ export const PROMPT_RUNNER_HARNESS_OPTION_DESCRIPTION =
129
129
  'Select runner: openai-codex, github-copilot, cline, claude-code, opencode, gemini (required for non-dry-run)';
130
130
 
131
131
  /**
@@ -146,7 +146,9 @@ export const PROMPT_RUNNER_MODEL_OPTION_DESCRIPTION = spaceTrim(`
146
146
  * @private internal utility of `promptbookCli`
147
147
  */
148
148
  export function addPromptRunnerSelectionOptions(command: Program): void {
149
- command.addOption(new Option('--agent <agent-name>', PROMPT_RUNNER_AGENT_OPTION_DESCRIPTION).env(PTBK_AGENT_ENV));
149
+ command.addOption(
150
+ new Option('--harness <harness-name>', PROMPT_RUNNER_HARNESS_OPTION_DESCRIPTION).env(PTBK_HARNESS_ENV),
151
+ );
150
152
  command.addOption(new Option('--model <model>', PROMPT_RUNNER_MODEL_OPTION_DESCRIPTION).env(PTBK_MODEL_ENV));
151
153
  }
152
154
 
@@ -227,7 +229,7 @@ export function normalizePromptRunnerSelectionCliOptions(
227
229
  },
228
230
  ): NormalizedPromptRunnerSelectionCliOptions {
229
231
  return {
230
- agentName: resolvePromptRunnerAgentName(cliOptions.agent, options),
232
+ agentName: resolvePromptRunnerHarnessName(cliOptions.harness, options),
231
233
  model: cliOptions.model,
232
234
  noUi: !cliOptions.ui,
233
235
  thinkingLevel: cliOptions.thinkingLevel,
@@ -236,38 +238,40 @@ export function normalizePromptRunnerSelectionCliOptions(
236
238
  }
237
239
 
238
240
  /**
239
- * Parses and validates one runner agent name.
241
+ * Parses and validates one runner harness name.
240
242
  */
241
- function resolvePromptRunnerAgentName(
242
- agent: string | undefined,
243
+ function resolvePromptRunnerHarnessName(
244
+ harness: string | undefined,
243
245
  options: {
244
246
  readonly isAgentRequired: boolean;
245
247
  },
246
- ): PromptRunnerAgentName | undefined {
247
- if (!agent) {
248
+ ): PromptRunnerHarnessName | undefined {
249
+ if (!harness) {
248
250
  if (!options.isAgentRequired) {
249
251
  return undefined;
250
252
  }
251
253
 
252
254
  throw new Error(
253
255
  colors.red(
254
- 'You must choose an agent using --agent <openai-codex|github-copilot|cline|claude-code|opencode|gemini>',
256
+ 'You must choose a harness using --harness <openai-codex|github-copilot|cline|claude-code|opencode|gemini>',
255
257
  ),
256
258
  );
257
259
  }
258
260
 
259
- if (isPromptRunnerAgentName(agent)) {
260
- return agent;
261
+ if (isPromptRunnerHarnessName(harness)) {
262
+ return harness;
261
263
  }
262
264
 
263
- throw new Error(colors.red(`Invalid agent "${agent}". Must be one of: ${PROMPT_RUNNER_AGENT_NAMES.join(', ')}`));
265
+ throw new Error(
266
+ colors.red(`Invalid harness "${harness}". Must be one of: ${PROMPT_RUNNER_HARNESS_NAMES.join(', ')}`),
267
+ );
264
268
  }
265
269
 
266
270
  /**
267
- * Checks whether a string is one supported runner agent name.
271
+ * Checks whether a string is one supported runner harness name.
268
272
  */
269
- function isPromptRunnerAgentName(agent: string): agent is PromptRunnerAgentName {
270
- return PROMPT_RUNNER_AGENT_NAMES.includes(agent as PromptRunnerAgentName);
273
+ function isPromptRunnerHarnessName(harness: string): harness is PromptRunnerHarnessName {
274
+ return PROMPT_RUNNER_HARNESS_NAMES.includes(harness as PromptRunnerHarnessName);
271
275
  }
272
276
 
273
277
  // Note: [🟡] Code for CLI runner options [promptRunnerCliOptions](src/cli/cli-commands/common/promptRunnerCliOptions.ts) should never be published outside of `@promptbook/cli`
@@ -6,6 +6,7 @@ import { EnvironmentMismatchError } from '../errors/EnvironmentMismatchError';
6
6
  import { $isRunningInNode } from '../utils/environment/$isRunningInNode';
7
7
  import { PROMPTBOOK_ENGINE_VERSION } from '../version';
8
8
  import { $initializeAboutCommand } from './cli-commands/about';
9
+ import { $initializeAgentCommand } from './cli-commands/agent';
9
10
  import { $initializeAgentFolderCommand } from './cli-commands/agent-folder';
10
11
  import { $initializeAgentsServerCommand } from './cli-commands/agents-server';
11
12
  import { $initializeCoderCommand } from './cli-commands/coder';
@@ -93,6 +94,7 @@ export async function promptbookCli(): Promise<void> {
93
94
  $initializeListScrapersCommand(program);
94
95
  $initializeStartAgentsServerCommand(program);
95
96
  $initializeStartPipelinesServerCommand(program);
97
+ $initializeAgentCommand(program);
96
98
  $initializeAgentFolderCommand(program);
97
99
  $initializeAgentsServerCommand(program);
98
100
  $initializeCoderCommand(program);