@promptbook/cli 0.114.0-24 → 0.114.0-25
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/README.md +2 -2
- package/esm/index.es.js +239 -51
- package/esm/index.es.js.map +1 -1
- package/esm/scripts/run-codex-prompts/runners/common/estimateUsageFromTextLength.d.ts +33 -0
- package/esm/scripts/run-codex-prompts/runners/common/modelPricing.d.ts +41 -0
- package/esm/scripts/run-codex-prompts/runners/gemini/gemini-pricing.d.ts +5 -18
- package/esm/scripts/run-codex-prompts/runners/qwen-code/QwenCodeRunner.d.ts +23 -0
- package/esm/scripts/run-codex-prompts/runners/qwen-code/buildQwenCodeScript.d.ts +8 -0
- package/esm/scripts/run-codex-prompts/runners/qwen-code/parseQwenCodeUsageFromOutput.d.ts +9 -0
- package/esm/scripts/run-codex-prompts/runners/qwen-code/qwen-code-pricing.d.ts +30 -0
- package/esm/src/book-3.0/cliAgentEnv.d.ts +3 -3
- package/esm/src/cli/cli-commands/common/promptRunnerCliOptions.d.ts +8 -2
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/book-3.0/cliAgentEnv.ts +3 -2
- package/src/cli/cli-commands/common/harness/HarnessDefinition.ts +6 -0
- package/src/cli/cli-commands/common/promptRunnerCliOptions.ts +14 -8
- package/src/other/templates/getTemplatesPipelineCollection.ts +921 -733
- package/src/version.ts +2 -2
- package/src/versions.txt +1 -0
- package/umd/index.umd.js +239 -51
- package/umd/index.umd.js.map +1 -1
- package/umd/scripts/run-codex-prompts/runners/common/estimateUsageFromTextLength.d.ts +33 -0
- package/umd/scripts/run-codex-prompts/runners/common/modelPricing.d.ts +41 -0
- package/umd/scripts/run-codex-prompts/runners/gemini/gemini-pricing.d.ts +5 -18
- package/umd/scripts/run-codex-prompts/runners/qwen-code/QwenCodeRunner.d.ts +23 -0
- package/umd/scripts/run-codex-prompts/runners/qwen-code/buildQwenCodeScript.d.ts +8 -0
- package/umd/scripts/run-codex-prompts/runners/qwen-code/parseQwenCodeUsageFromOutput.d.ts +9 -0
- package/umd/scripts/run-codex-prompts/runners/qwen-code/qwen-code-pricing.d.ts +30 -0
- package/umd/src/book-3.0/cliAgentEnv.d.ts +3 -3
- package/umd/src/cli/cli-commands/common/promptRunnerCliOptions.d.ts +8 -2
- package/umd/src/version.d.ts +1 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Usage } from '../../../../src/execution/Usage';
|
|
2
|
+
import type { ModelPricing } from './modelPricing';
|
|
3
|
+
/**
|
|
4
|
+
* Options for estimating the usage of one harness run.
|
|
5
|
+
*/
|
|
6
|
+
export type EstimateUsageFromTextLengthOptions = {
|
|
7
|
+
/**
|
|
8
|
+
* Human-readable harness name used when the estimation itself fails.
|
|
9
|
+
*/
|
|
10
|
+
readonly harnessLabel: string;
|
|
11
|
+
/**
|
|
12
|
+
* The prompt that was sent to the harness.
|
|
13
|
+
*/
|
|
14
|
+
readonly prompt: string;
|
|
15
|
+
/**
|
|
16
|
+
* The output which the harness has printed.
|
|
17
|
+
*/
|
|
18
|
+
readonly output: string;
|
|
19
|
+
/**
|
|
20
|
+
* Reads the pricing of the model which was used for this run.
|
|
21
|
+
*
|
|
22
|
+
* It is resolved lazily so that a broken pricing table degrades to an uncertain estimate
|
|
23
|
+
* instead of failing the coding round, because a price estimate must never block coding work.
|
|
24
|
+
*/
|
|
25
|
+
readonly resolvePricing: () => ModelPricing;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Estimates the usage of one harness run from the length of its prompt and its output.
|
|
29
|
+
*
|
|
30
|
+
* Harnesses which do not report their own token counts are billed per token anyway, so the
|
|
31
|
+
* character counts are the only signal available for a price estimate.
|
|
32
|
+
*/
|
|
33
|
+
export declare function estimateUsageFromTextLength(options: EstimateUsageFromTextLengthOptions): Usage;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Price of one model per 1 million tokens in USD.
|
|
3
|
+
*/
|
|
4
|
+
export type ModelPricing = {
|
|
5
|
+
/**
|
|
6
|
+
* Price of 1 million input tokens in USD.
|
|
7
|
+
*/
|
|
8
|
+
readonly input: number;
|
|
9
|
+
/**
|
|
10
|
+
* Price of 1 million output tokens in USD.
|
|
11
|
+
*/
|
|
12
|
+
readonly output: number;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Pricing of all known models of one harness, keyed by the model identifier.
|
|
16
|
+
*/
|
|
17
|
+
export type ModelPricingTable = Readonly<Record<string, ModelPricing>>;
|
|
18
|
+
/**
|
|
19
|
+
* Options for resolving the pricing of one model.
|
|
20
|
+
*/
|
|
21
|
+
export type ResolveModelPricingOptions = {
|
|
22
|
+
/**
|
|
23
|
+
* Pricing of all models known to one harness.
|
|
24
|
+
*/
|
|
25
|
+
readonly pricingTable: ModelPricingTable;
|
|
26
|
+
/**
|
|
27
|
+
* Model whose pricing is used when the requested model is unknown.
|
|
28
|
+
*/
|
|
29
|
+
readonly modelNameForEstimation: string;
|
|
30
|
+
/**
|
|
31
|
+
* Model requested for the run, or `undefined` when the harness picks its own model.
|
|
32
|
+
*/
|
|
33
|
+
readonly modelName?: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Resolves the pricing of one model of one harness.
|
|
37
|
+
*
|
|
38
|
+
* It first tries exact match, then prefix match, then falls back to the pricing of a stable
|
|
39
|
+
* default model, because every harness names new models faster than the pricing tables grow.
|
|
40
|
+
*/
|
|
41
|
+
export declare function resolveModelPricing(options: ResolveModelPricingOptions): ModelPricing;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ModelPricing } from '../common/modelPricing';
|
|
1
2
|
/**
|
|
2
3
|
* The pricing for Gemini models per 1 million tokens in USD.
|
|
3
4
|
*
|
|
@@ -6,30 +7,16 @@
|
|
|
6
7
|
* @see https://ai.google.dev/pricing
|
|
7
8
|
*/
|
|
8
9
|
export declare const GEMINI_PRICING: {
|
|
9
|
-
'gemini-1.5-flash': {
|
|
10
|
-
input:
|
|
11
|
-
output:
|
|
10
|
+
readonly 'gemini-1.5-flash': {
|
|
11
|
+
readonly input: 0.1125;
|
|
12
|
+
readonly output: 0.45;
|
|
12
13
|
};
|
|
13
14
|
};
|
|
14
15
|
/**
|
|
15
16
|
* The model to use for price estimation.
|
|
16
17
|
*/
|
|
17
18
|
export declare const GEMINI_MODEL_FOR_ESTIMATION = "gemini-1.5-flash";
|
|
18
|
-
/**
|
|
19
|
-
* Gemini pricing entry per 1 million tokens.
|
|
20
|
-
*/
|
|
21
|
-
export type GeminiPricing = {
|
|
22
|
-
input: number;
|
|
23
|
-
output: number;
|
|
24
|
-
};
|
|
25
19
|
/**
|
|
26
20
|
* Resolves Gemini pricing for the requested model.
|
|
27
|
-
*
|
|
28
|
-
* It first tries exact match, then prefix match, then falls back to a stable
|
|
29
|
-
* default pricing model.
|
|
30
|
-
*/
|
|
31
|
-
export declare function resolveGeminiPricing(modelName?: string): GeminiPricing;
|
|
32
|
-
/**
|
|
33
|
-
* A an estimation of how many characters are in one token.
|
|
34
21
|
*/
|
|
35
|
-
export declare
|
|
22
|
+
export declare function resolveGeminiPricing(modelName?: string): ModelPricing;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { PromptRunner } from '../types/PromptRunner';
|
|
2
|
+
import type { PromptRunOptions } from '../types/PromptRunOptions';
|
|
3
|
+
import type { PromptRunResult } from '../types/PromptRunResult';
|
|
4
|
+
import type { QwenCodeRunnerOptions } from './QwenCodeRunnerOptions';
|
|
5
|
+
/**
|
|
6
|
+
* Default Qwen Code model used by the coding runner.
|
|
7
|
+
*/
|
|
8
|
+
export declare const DEFAULT_QWEN_CODE_MODEL = "qwen3.8-max";
|
|
9
|
+
/**
|
|
10
|
+
* Runs prompts via the Qwen Code CLI.
|
|
11
|
+
*/
|
|
12
|
+
export declare class QwenCodeRunner implements PromptRunner {
|
|
13
|
+
private readonly options;
|
|
14
|
+
readonly name = "qwen-code";
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new Qwen Code runner.
|
|
17
|
+
*/
|
|
18
|
+
constructor(options: QwenCodeRunnerOptions);
|
|
19
|
+
/**
|
|
20
|
+
* Runs the prompt using Qwen Code and parses usage output.
|
|
21
|
+
*/
|
|
22
|
+
runPrompt(options: PromptRunOptions): Promise<PromptRunResult>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { QwenCodeScriptOptions } from './QwenCodeScriptOptions';
|
|
2
|
+
/**
|
|
3
|
+
* Builds the shell script that runs Qwen Code with the prompt and coding context.
|
|
4
|
+
*
|
|
5
|
+
* Note: `-y` runs the harness unattended, because `ptbk coder` approves the whole prompt
|
|
6
|
+
* up front and there is nobody at the keyboard to confirm the single tool calls.
|
|
7
|
+
*/
|
|
8
|
+
export declare function buildQwenCodeScript(options: QwenCodeScriptOptions): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Usage } from '../../../../src/execution/Usage';
|
|
2
|
+
/**
|
|
3
|
+
* Parses Qwen Code CLI output and extracts usage information.
|
|
4
|
+
*
|
|
5
|
+
* @param output The output from the Qwen Code CLI.
|
|
6
|
+
* @param prompt The prompt that was sent to the Qwen Code CLI.
|
|
7
|
+
* @param modelName The Qwen Code model used for this run.
|
|
8
|
+
*/
|
|
9
|
+
export declare function parseQwenCodeUsageFromOutput(output: string, prompt: string, modelName?: string): Usage;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ModelPricing } from '../common/modelPricing';
|
|
2
|
+
/**
|
|
3
|
+
* The pricing for Qwen Code models per 1 million tokens in USD.
|
|
4
|
+
*
|
|
5
|
+
* Note: This is an estimation.
|
|
6
|
+
*
|
|
7
|
+
* @see https://www.alibabacloud.com/help/en/model-studio/models
|
|
8
|
+
*/
|
|
9
|
+
export declare const QWEN_CODE_PRICING: {
|
|
10
|
+
readonly 'qwen3-coder-plus': {
|
|
11
|
+
readonly input: 1;
|
|
12
|
+
readonly output: 5;
|
|
13
|
+
};
|
|
14
|
+
readonly 'qwen3-coder-flash': {
|
|
15
|
+
readonly input: 0.3;
|
|
16
|
+
readonly output: 1.5;
|
|
17
|
+
};
|
|
18
|
+
readonly 'qwen3-max': {
|
|
19
|
+
readonly input: 1.2;
|
|
20
|
+
readonly output: 6;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* The model to use for price estimation.
|
|
25
|
+
*/
|
|
26
|
+
export declare const QWEN_CODE_MODEL_FOR_ESTIMATION = "qwen3-coder-plus";
|
|
27
|
+
/**
|
|
28
|
+
* Resolves Qwen Code pricing for the requested model.
|
|
29
|
+
*/
|
|
30
|
+
export declare function resolveQwenCodePricing(modelName?: string): ModelPricing;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @public exported from `@promptbook/node`
|
|
5
5
|
*/
|
|
6
|
-
export declare const CLI_AGENT_HARNESS_NAMES: readonly ["openai-codex", "github-copilot", "cline", "claude-code", "opencode", "gemini"];
|
|
6
|
+
export declare const CLI_AGENT_HARNESS_NAMES: readonly ["openai-codex", "github-copilot", "cline", "claude-code", "opencode", "gemini", "qwen-code"];
|
|
7
7
|
/**
|
|
8
8
|
* All supported thinking-level values for CLI coding-agent runners.
|
|
9
9
|
*
|
|
@@ -13,8 +13,8 @@ export declare const CLI_AGENT_THINKING_LEVEL_VALUES: readonly ["low", "medium",
|
|
|
13
13
|
/**
|
|
14
14
|
* Environment variable used as the default runner identifier when `--harness` is omitted or not set in `CliAgent`.
|
|
15
15
|
*
|
|
16
|
-
* Set this to one of the harness names (`openai-codex`, `github-copilot`, `cline`, `claude-code`, `opencode`, `gemini
|
|
17
|
-
* so that `CliAgent` and `ptbk agent exec` can run without an explicit `harness` option.
|
|
16
|
+
* Set this to one of the harness names (`openai-codex`, `github-copilot`, `cline`, `claude-code`, `opencode`, `gemini`,
|
|
17
|
+
* `qwen-code`) so that `CliAgent` and `ptbk agent exec` can run without an explicit `harness` option.
|
|
18
18
|
*
|
|
19
19
|
* @public exported from `@promptbook/node`
|
|
20
20
|
*/
|
|
@@ -8,7 +8,7 @@ export { PTBK_HARNESS_ENV, PTBK_MODEL_ENV, PTBK_THINKING_LEVEL_ENV };
|
|
|
8
8
|
*
|
|
9
9
|
* @private internal utility of `promptbookCli`
|
|
10
10
|
*/
|
|
11
|
-
export declare const PROMPT_RUNNER_HARNESS_NAMES: readonly ["openai-codex", "github-copilot", "cline", "claude-code", "opencode", "gemini"];
|
|
11
|
+
export declare const PROMPT_RUNNER_HARNESS_NAMES: readonly ["openai-codex", "github-copilot", "cline", "claude-code", "opencode", "gemini", "qwen-code"];
|
|
12
12
|
/**
|
|
13
13
|
* Runner identifier supported by Promptbook CLI agent orchestration commands.
|
|
14
14
|
*
|
|
@@ -72,7 +72,13 @@ export declare const PROMPT_RUNNER_DESCRIPTION: string;
|
|
|
72
72
|
*
|
|
73
73
|
* @private internal utility of `promptbookCli`
|
|
74
74
|
*/
|
|
75
|
-
export declare const PROMPT_RUNNER_HARNESS_OPTION_DESCRIPTION
|
|
75
|
+
export declare const PROMPT_RUNNER_HARNESS_OPTION_DESCRIPTION: string;
|
|
76
|
+
/**
|
|
77
|
+
* Runner harness names listed as alternatives of the `--harness` option in error messages.
|
|
78
|
+
*
|
|
79
|
+
* @private internal utility of `promptbookCli`
|
|
80
|
+
*/
|
|
81
|
+
export declare const PROMPT_RUNNER_HARNESS_OPTION_HINT: string;
|
|
76
82
|
/**
|
|
77
83
|
* Commander description for the `--model` option.
|
|
78
84
|
*
|
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-24`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
|
@@ -12,6 +12,7 @@ export const CLI_AGENT_HARNESS_NAMES = [
|
|
|
12
12
|
'claude-code',
|
|
13
13
|
'opencode',
|
|
14
14
|
'gemini',
|
|
15
|
+
'qwen-code',
|
|
15
16
|
] as const;
|
|
16
17
|
|
|
17
18
|
/**
|
|
@@ -24,8 +25,8 @@ export const CLI_AGENT_THINKING_LEVEL_VALUES = ['low', 'medium', 'high', 'xhigh'
|
|
|
24
25
|
/**
|
|
25
26
|
* Environment variable used as the default runner identifier when `--harness` is omitted or not set in `CliAgent`.
|
|
26
27
|
*
|
|
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.
|
|
28
|
+
* Set this to one of the harness names (`openai-codex`, `github-copilot`, `cline`, `claude-code`, `opencode`, `gemini`,
|
|
29
|
+
* `qwen-code`) so that `CliAgent` and `ptbk agent exec` can run without an explicit `harness` option.
|
|
29
30
|
*
|
|
30
31
|
* @public exported from `@promptbook/node`
|
|
31
32
|
*/
|
|
@@ -78,6 +78,12 @@ export const HARNESS_DEFINITIONS: Readonly<Record<PromptRunnerHarnessName, Harne
|
|
|
78
78
|
commandName: 'gemini',
|
|
79
79
|
npmPackageName: '@google/gemini-cli',
|
|
80
80
|
},
|
|
81
|
+
'qwen-code': {
|
|
82
|
+
harnessName: 'qwen-code',
|
|
83
|
+
label: 'Qwen Code',
|
|
84
|
+
commandName: 'qwen',
|
|
85
|
+
npmPackageName: '@qwen-code/qwen-code',
|
|
86
|
+
},
|
|
81
87
|
};
|
|
82
88
|
|
|
83
89
|
/**
|
|
@@ -100,6 +100,7 @@ export const PROMPT_RUNNER_DESCRIPTION = spaceTrim(`
|
|
|
100
100
|
- claude-code: Claude Code integration
|
|
101
101
|
- opencode: Opencode integration
|
|
102
102
|
- gemini: Google Gemini CLI integration (requires --model)
|
|
103
|
+
- qwen-code: Qwen Code CLI integration (requires --model)
|
|
103
104
|
`);
|
|
104
105
|
|
|
105
106
|
/**
|
|
@@ -107,8 +108,16 @@ export const PROMPT_RUNNER_DESCRIPTION = spaceTrim(`
|
|
|
107
108
|
*
|
|
108
109
|
* @private internal utility of `promptbookCli`
|
|
109
110
|
*/
|
|
110
|
-
export const PROMPT_RUNNER_HARNESS_OPTION_DESCRIPTION =
|
|
111
|
-
'
|
|
111
|
+
export const PROMPT_RUNNER_HARNESS_OPTION_DESCRIPTION = `Select runner: ${PROMPT_RUNNER_HARNESS_NAMES.join(
|
|
112
|
+
', ',
|
|
113
|
+
)} (required for non-dry-run)`;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Runner harness names listed as alternatives of the `--harness` option in error messages.
|
|
117
|
+
*
|
|
118
|
+
* @private internal utility of `promptbookCli`
|
|
119
|
+
*/
|
|
120
|
+
export const PROMPT_RUNNER_HARNESS_OPTION_HINT = `--harness <${PROMPT_RUNNER_HARNESS_NAMES.join('|')}>`;
|
|
112
121
|
|
|
113
122
|
/**
|
|
114
123
|
* Commander description for the `--model` option.
|
|
@@ -116,10 +125,11 @@ export const PROMPT_RUNNER_HARNESS_OPTION_DESCRIPTION =
|
|
|
116
125
|
* @private internal utility of `promptbookCli`
|
|
117
126
|
*/
|
|
118
127
|
export const PROMPT_RUNNER_MODEL_OPTION_DESCRIPTION = spaceTrim(`
|
|
119
|
-
Model to use (required for openai-codex and
|
|
128
|
+
Model to use (required for openai-codex, gemini and qwen-code)
|
|
120
129
|
|
|
121
130
|
OpenAI examples: gpt-5.2-codex, default
|
|
122
131
|
Gemini examples: gemini-3-flash-preview, default
|
|
132
|
+
Qwen examples: qwen3.8-max, default
|
|
123
133
|
`);
|
|
124
134
|
|
|
125
135
|
/**
|
|
@@ -249,11 +259,7 @@ function resolvePromptRunnerHarnessName(
|
|
|
249
259
|
return undefined;
|
|
250
260
|
}
|
|
251
261
|
|
|
252
|
-
throw new Error(
|
|
253
|
-
colors.red(
|
|
254
|
-
'You must choose a harness using --harness <openai-codex|github-copilot|cline|claude-code|opencode|gemini>',
|
|
255
|
-
),
|
|
256
|
-
);
|
|
262
|
+
throw new Error(colors.red(`You must choose a harness using ${PROMPT_RUNNER_HARNESS_OPTION_HINT}`));
|
|
257
263
|
}
|
|
258
264
|
|
|
259
265
|
if (isPromptRunnerHarnessName(harness)) {
|