@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
package/README.md
CHANGED
|
@@ -549,7 +549,7 @@ Prompts marked with `[-]` are not ready yet, prompts containing `@@@` are treate
|
|
|
549
549
|
|
|
550
550
|
#### Features
|
|
551
551
|
|
|
552
|
-
- **Multi-runner execution:** `openai-codex`, `github-copilot`, `cline`, `claude-code`, `opencode`, `gemini`
|
|
552
|
+
- **Multi-runner execution:** `openai-codex`, `github-copilot`, `cline`, `claude-code`, `opencode`, `gemini`, `qwen-code`
|
|
553
553
|
- **Context injection:** `--agent agents/coding/developer.book --context AGENTS.md` or inline extra instructions
|
|
554
554
|
- **Reasoning control:** `--thinking-level low|medium|high|xhigh` for supported runners
|
|
555
555
|
- **Unattended or interactive runs:** default auto mode, or `--no-auto` to wait for user confirmation before each prompt
|
|
@@ -626,7 +626,7 @@ ptbk coder verify
|
|
|
626
626
|
| Flag | Purpose |
|
|
627
627
|
| -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
628
628
|
| `--harness <name>` | Selects the coding harness. |
|
|
629
|
-
| `--model <model>` | Chooses the runner model; required for `openai-codex` and `
|
|
629
|
+
| `--model <model>` | Chooses the runner model; required for `openai-codex`, `gemini` and `qwen-code`, optional for `github-copilot`. |
|
|
630
630
|
| `--context <text-or-file>` | Appends extra instructions inline or from a file like `AGENTS.md`. |
|
|
631
631
|
| `--test <command>` | Runs a verification command after each prompt attempt and feeds failing output back for retries. |
|
|
632
632
|
| `--test-before <mode>` | Runs tests before coding: `no` (default), `yes-and-fail` (stop with results), or `yes-and-fix` (create one repair prompt first); defaults to `npm test` when enabled without `--test`. |
|
package/esm/index.es.js
CHANGED
|
@@ -48,7 +48,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
48
48
|
* @generated
|
|
49
49
|
* @see https://github.com/webgptorg/promptbook
|
|
50
50
|
*/
|
|
51
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.114.0-
|
|
51
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.114.0-25';
|
|
52
52
|
/**
|
|
53
53
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
54
54
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -1721,6 +1721,7 @@ const CLI_AGENT_HARNESS_NAMES = [
|
|
|
1721
1721
|
'claude-code',
|
|
1722
1722
|
'opencode',
|
|
1723
1723
|
'gemini',
|
|
1724
|
+
'qwen-code',
|
|
1724
1725
|
];
|
|
1725
1726
|
/**
|
|
1726
1727
|
* All supported thinking-level values for CLI coding-agent runners.
|
|
@@ -1731,8 +1732,8 @@ const CLI_AGENT_THINKING_LEVEL_VALUES = ['low', 'medium', 'high', 'xhigh', 'max'
|
|
|
1731
1732
|
/**
|
|
1732
1733
|
* Environment variable used as the default runner identifier when `--harness` is omitted or not set in `CliAgent`.
|
|
1733
1734
|
*
|
|
1734
|
-
* Set this to one of the harness names (`openai-codex`, `github-copilot`, `cline`, `claude-code`, `opencode`, `gemini
|
|
1735
|
-
* so that `CliAgent` and `ptbk agent exec` can run without an explicit `harness` option.
|
|
1735
|
+
* Set this to one of the harness names (`openai-codex`, `github-copilot`, `cline`, `claude-code`, `opencode`, `gemini`,
|
|
1736
|
+
* `qwen-code`) so that `CliAgent` and `ptbk agent exec` can run without an explicit `harness` option.
|
|
1736
1737
|
*
|
|
1737
1738
|
* @public exported from `@promptbook/node`
|
|
1738
1739
|
*/
|
|
@@ -1817,23 +1818,31 @@ const PROMPT_RUNNER_DESCRIPTION = spaceTrim$1(`
|
|
|
1817
1818
|
- claude-code: Claude Code integration
|
|
1818
1819
|
- opencode: Opencode integration
|
|
1819
1820
|
- gemini: Google Gemini CLI integration (requires --model)
|
|
1821
|
+
- qwen-code: Qwen Code CLI integration (requires --model)
|
|
1820
1822
|
`);
|
|
1821
1823
|
/**
|
|
1822
1824
|
* Commander description for the `--harness` option.
|
|
1823
1825
|
*
|
|
1824
1826
|
* @private internal utility of `promptbookCli`
|
|
1825
1827
|
*/
|
|
1826
|
-
const PROMPT_RUNNER_HARNESS_OPTION_DESCRIPTION =
|
|
1828
|
+
const PROMPT_RUNNER_HARNESS_OPTION_DESCRIPTION = `Select runner: ${PROMPT_RUNNER_HARNESS_NAMES.join(', ')} (required for non-dry-run)`;
|
|
1829
|
+
/**
|
|
1830
|
+
* Runner harness names listed as alternatives of the `--harness` option in error messages.
|
|
1831
|
+
*
|
|
1832
|
+
* @private internal utility of `promptbookCli`
|
|
1833
|
+
*/
|
|
1834
|
+
const PROMPT_RUNNER_HARNESS_OPTION_HINT = `--harness <${PROMPT_RUNNER_HARNESS_NAMES.join('|')}>`;
|
|
1827
1835
|
/**
|
|
1828
1836
|
* Commander description for the `--model` option.
|
|
1829
1837
|
*
|
|
1830
1838
|
* @private internal utility of `promptbookCli`
|
|
1831
1839
|
*/
|
|
1832
1840
|
const PROMPT_RUNNER_MODEL_OPTION_DESCRIPTION = spaceTrim$1(`
|
|
1833
|
-
Model to use (required for openai-codex and
|
|
1841
|
+
Model to use (required for openai-codex, gemini and qwen-code)
|
|
1834
1842
|
|
|
1835
1843
|
OpenAI examples: gpt-5.2-codex, default
|
|
1836
1844
|
Gemini examples: gemini-3-flash-preview, default
|
|
1845
|
+
Qwen examples: qwen3.8-max, default
|
|
1837
1846
|
`);
|
|
1838
1847
|
/**
|
|
1839
1848
|
* Commander description for the `--git-changes` option.
|
|
@@ -1921,7 +1930,7 @@ function resolvePromptRunnerHarnessName(harness, options) {
|
|
|
1921
1930
|
if (!options.isAgentRequired) {
|
|
1922
1931
|
return undefined;
|
|
1923
1932
|
}
|
|
1924
|
-
throw new Error(colors.red(
|
|
1933
|
+
throw new Error(colors.red(`You must choose a harness using ${PROMPT_RUNNER_HARNESS_OPTION_HINT}`));
|
|
1925
1934
|
}
|
|
1926
1935
|
if (isPromptRunnerHarnessName(harness)) {
|
|
1927
1936
|
return harness;
|
|
@@ -24133,6 +24142,12 @@ const HARNESS_DEFINITIONS = {
|
|
|
24133
24142
|
commandName: 'gemini',
|
|
24134
24143
|
npmPackageName: '@google/gemini-cli',
|
|
24135
24144
|
},
|
|
24145
|
+
'qwen-code': {
|
|
24146
|
+
harnessName: 'qwen-code',
|
|
24147
|
+
label: 'Qwen Code',
|
|
24148
|
+
commandName: 'qwen',
|
|
24149
|
+
npmPackageName: '@qwen-code/qwen-code',
|
|
24150
|
+
},
|
|
24136
24151
|
};
|
|
24137
24152
|
/**
|
|
24138
24153
|
* Looks up the definition of one supported CLI coding harness.
|
|
@@ -26258,6 +26273,71 @@ function uncertainNumber(value, isUncertain) {
|
|
|
26258
26273
|
return { value };
|
|
26259
26274
|
}
|
|
26260
26275
|
|
|
26276
|
+
/**
|
|
26277
|
+
* An estimation of how many characters are in one token.
|
|
26278
|
+
*/
|
|
26279
|
+
const CHARS_PER_TOKEN = 4;
|
|
26280
|
+
/**
|
|
26281
|
+
* Estimates the usage of one harness run from the length of its prompt and its output.
|
|
26282
|
+
*
|
|
26283
|
+
* Harnesses which do not report their own token counts are billed per token anyway, so the
|
|
26284
|
+
* character counts are the only signal available for a price estimate.
|
|
26285
|
+
*/
|
|
26286
|
+
function estimateUsageFromTextLength(options) {
|
|
26287
|
+
const { harnessLabel, prompt, output, resolvePricing } = options;
|
|
26288
|
+
try {
|
|
26289
|
+
const pricing = resolvePricing();
|
|
26290
|
+
const inputTokens = Math.ceil(prompt.length / CHARS_PER_TOKEN);
|
|
26291
|
+
const outputTokens = Math.ceil(output.length / CHARS_PER_TOKEN);
|
|
26292
|
+
const price = uncertainNumber((inputTokens / 1000000) * pricing.input + (outputTokens / 1000000) * pricing.output);
|
|
26293
|
+
return {
|
|
26294
|
+
...UNCERTAIN_USAGE,
|
|
26295
|
+
price,
|
|
26296
|
+
input: {
|
|
26297
|
+
...UNCERTAIN_USAGE.input,
|
|
26298
|
+
tokensCount: uncertainNumber(inputTokens),
|
|
26299
|
+
},
|
|
26300
|
+
output: {
|
|
26301
|
+
...UNCERTAIN_USAGE.output,
|
|
26302
|
+
tokensCount: uncertainNumber(outputTokens),
|
|
26303
|
+
},
|
|
26304
|
+
};
|
|
26305
|
+
}
|
|
26306
|
+
catch (error) {
|
|
26307
|
+
console.error(colors.bgRed(`Error parsing ${harnessLabel} usage output:`), error);
|
|
26308
|
+
return UNCERTAIN_USAGE;
|
|
26309
|
+
}
|
|
26310
|
+
}
|
|
26311
|
+
|
|
26312
|
+
/**
|
|
26313
|
+
* Resolves the pricing of one model of one harness.
|
|
26314
|
+
*
|
|
26315
|
+
* It first tries exact match, then prefix match, then falls back to the pricing of a stable
|
|
26316
|
+
* default model, because every harness names new models faster than the pricing tables grow.
|
|
26317
|
+
*/
|
|
26318
|
+
function resolveModelPricing(options) {
|
|
26319
|
+
var _a;
|
|
26320
|
+
const { pricingTable, modelNameForEstimation, modelName } = options;
|
|
26321
|
+
const fallbackPricing = pricingTable[modelNameForEstimation];
|
|
26322
|
+
if (fallbackPricing === undefined) {
|
|
26323
|
+
throw new UnexpectedError(spaceTrim(`
|
|
26324
|
+
Missing pricing of the model \`${modelNameForEstimation}\` used for price estimation.
|
|
26325
|
+
|
|
26326
|
+
**The model used for estimation must always be listed in its own pricing table.**
|
|
26327
|
+
`));
|
|
26328
|
+
}
|
|
26329
|
+
if (!modelName) {
|
|
26330
|
+
return fallbackPricing;
|
|
26331
|
+
}
|
|
26332
|
+
const exactMatch = pricingTable[modelName];
|
|
26333
|
+
if (exactMatch) {
|
|
26334
|
+
return exactMatch;
|
|
26335
|
+
}
|
|
26336
|
+
const prefixMatch = (_a = Object.entries(pricingTable).find(([knownModelName]) => modelName.startsWith(knownModelName))) === null || _a === void 0 ? void 0 : _a[1];
|
|
26337
|
+
return prefixMatch !== null && prefixMatch !== void 0 ? prefixMatch : fallbackPricing;
|
|
26338
|
+
}
|
|
26339
|
+
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
26340
|
+
|
|
26261
26341
|
/**
|
|
26262
26342
|
* The pricing for Gemini models per 1 million tokens in USD.
|
|
26263
26343
|
*
|
|
@@ -26277,27 +26357,14 @@ const GEMINI_PRICING = {
|
|
|
26277
26357
|
const GEMINI_MODEL_FOR_ESTIMATION = 'gemini-1.5-flash';
|
|
26278
26358
|
/**
|
|
26279
26359
|
* Resolves Gemini pricing for the requested model.
|
|
26280
|
-
*
|
|
26281
|
-
* It first tries exact match, then prefix match, then falls back to a stable
|
|
26282
|
-
* default pricing model.
|
|
26283
26360
|
*/
|
|
26284
26361
|
function resolveGeminiPricing(modelName) {
|
|
26285
|
-
|
|
26286
|
-
|
|
26287
|
-
|
|
26288
|
-
|
|
26289
|
-
}
|
|
26290
|
-
const exactMatch = GEMINI_PRICING[modelName];
|
|
26291
|
-
if (exactMatch) {
|
|
26292
|
-
return exactMatch;
|
|
26293
|
-
}
|
|
26294
|
-
const prefixMatch = (_a = Object.entries(GEMINI_PRICING).find(([knownModel]) => modelName.startsWith(knownModel))) === null || _a === void 0 ? void 0 : _a[1];
|
|
26295
|
-
return prefixMatch !== null && prefixMatch !== void 0 ? prefixMatch : fallbackPricing;
|
|
26362
|
+
return resolveModelPricing({
|
|
26363
|
+
pricingTable: GEMINI_PRICING,
|
|
26364
|
+
modelNameForEstimation: GEMINI_MODEL_FOR_ESTIMATION,
|
|
26365
|
+
modelName,
|
|
26366
|
+
});
|
|
26296
26367
|
}
|
|
26297
|
-
/**
|
|
26298
|
-
* A an estimation of how many characters are in one token.
|
|
26299
|
-
*/
|
|
26300
|
-
const CHARS_PER_TOKEN = 4;
|
|
26301
26368
|
|
|
26302
26369
|
/**
|
|
26303
26370
|
* Parses Gemini CLI output and extracts usage information.
|
|
@@ -26307,28 +26374,12 @@ const CHARS_PER_TOKEN = 4;
|
|
|
26307
26374
|
* @param modelName The Gemini model used for this run.
|
|
26308
26375
|
*/
|
|
26309
26376
|
function parseGeminiUsageFromOutput(output, prompt, modelName) {
|
|
26310
|
-
|
|
26311
|
-
|
|
26312
|
-
|
|
26313
|
-
|
|
26314
|
-
|
|
26315
|
-
|
|
26316
|
-
...UNCERTAIN_USAGE,
|
|
26317
|
-
price,
|
|
26318
|
-
input: {
|
|
26319
|
-
...UNCERTAIN_USAGE.input,
|
|
26320
|
-
tokensCount: uncertainNumber(inputTokens),
|
|
26321
|
-
},
|
|
26322
|
-
output: {
|
|
26323
|
-
...UNCERTAIN_USAGE.output,
|
|
26324
|
-
tokensCount: uncertainNumber(outputTokens),
|
|
26325
|
-
},
|
|
26326
|
-
};
|
|
26327
|
-
}
|
|
26328
|
-
catch (error) {
|
|
26329
|
-
console.error(colors.bgRed('Error parsing Gemini usage output:'), error);
|
|
26330
|
-
return UNCERTAIN_USAGE;
|
|
26331
|
-
}
|
|
26377
|
+
return estimateUsageFromTextLength({
|
|
26378
|
+
harnessLabel: 'Gemini',
|
|
26379
|
+
prompt,
|
|
26380
|
+
output,
|
|
26381
|
+
resolvePricing: () => resolveGeminiPricing(modelName),
|
|
26382
|
+
});
|
|
26332
26383
|
}
|
|
26333
26384
|
|
|
26334
26385
|
/**
|
|
@@ -27716,6 +27767,114 @@ class OpencodeRunner {
|
|
|
27716
27767
|
}
|
|
27717
27768
|
}
|
|
27718
27769
|
|
|
27770
|
+
/**
|
|
27771
|
+
* Delimiter used for passing large prompts to the Qwen Code CLI.
|
|
27772
|
+
*/
|
|
27773
|
+
const QWEN_CODE_PROMPT_DELIMITER = 'QWEN_CODE_PROMPT';
|
|
27774
|
+
/**
|
|
27775
|
+
* Builds the shell script that runs Qwen Code with the prompt and coding context.
|
|
27776
|
+
*
|
|
27777
|
+
* Note: `-y` runs the harness unattended, because `ptbk coder` approves the whole prompt
|
|
27778
|
+
* up front and there is nobody at the keyboard to confirm the single tool calls.
|
|
27779
|
+
*/
|
|
27780
|
+
function buildQwenCodeScript(options) {
|
|
27781
|
+
return spaceTrim((block) => `
|
|
27782
|
+
qwen -y -m ${options.model} -p "$(cat <<'${QWEN_CODE_PROMPT_DELIMITER}'
|
|
27783
|
+
|
|
27784
|
+
${block(options.prompt)}
|
|
27785
|
+
|
|
27786
|
+
${QWEN_CODE_PROMPT_DELIMITER}
|
|
27787
|
+
)"
|
|
27788
|
+
`);
|
|
27789
|
+
}
|
|
27790
|
+
|
|
27791
|
+
/**
|
|
27792
|
+
* The pricing for Qwen Code models per 1 million tokens in USD.
|
|
27793
|
+
*
|
|
27794
|
+
* Note: This is an estimation.
|
|
27795
|
+
*
|
|
27796
|
+
* @see https://www.alibabacloud.com/help/en/model-studio/models
|
|
27797
|
+
*/
|
|
27798
|
+
const QWEN_CODE_PRICING = {
|
|
27799
|
+
'qwen3-coder-plus': {
|
|
27800
|
+
input: 1,
|
|
27801
|
+
output: 5,
|
|
27802
|
+
},
|
|
27803
|
+
'qwen3-coder-flash': {
|
|
27804
|
+
input: 0.3,
|
|
27805
|
+
output: 1.5,
|
|
27806
|
+
},
|
|
27807
|
+
'qwen3-max': {
|
|
27808
|
+
input: 1.2,
|
|
27809
|
+
output: 6,
|
|
27810
|
+
},
|
|
27811
|
+
};
|
|
27812
|
+
/**
|
|
27813
|
+
* The model to use for price estimation.
|
|
27814
|
+
*/
|
|
27815
|
+
const QWEN_CODE_MODEL_FOR_ESTIMATION = 'qwen3-coder-plus';
|
|
27816
|
+
/**
|
|
27817
|
+
* Resolves Qwen Code pricing for the requested model.
|
|
27818
|
+
*/
|
|
27819
|
+
function resolveQwenCodePricing(modelName) {
|
|
27820
|
+
return resolveModelPricing({
|
|
27821
|
+
pricingTable: QWEN_CODE_PRICING,
|
|
27822
|
+
modelNameForEstimation: QWEN_CODE_MODEL_FOR_ESTIMATION,
|
|
27823
|
+
modelName,
|
|
27824
|
+
});
|
|
27825
|
+
}
|
|
27826
|
+
|
|
27827
|
+
/**
|
|
27828
|
+
* Parses Qwen Code CLI output and extracts usage information.
|
|
27829
|
+
*
|
|
27830
|
+
* @param output The output from the Qwen Code CLI.
|
|
27831
|
+
* @param prompt The prompt that was sent to the Qwen Code CLI.
|
|
27832
|
+
* @param modelName The Qwen Code model used for this run.
|
|
27833
|
+
*/
|
|
27834
|
+
function parseQwenCodeUsageFromOutput(output, prompt, modelName) {
|
|
27835
|
+
return estimateUsageFromTextLength({
|
|
27836
|
+
harnessLabel: 'Qwen Code',
|
|
27837
|
+
prompt,
|
|
27838
|
+
output,
|
|
27839
|
+
resolvePricing: () => resolveQwenCodePricing(modelName),
|
|
27840
|
+
});
|
|
27841
|
+
}
|
|
27842
|
+
|
|
27843
|
+
/**
|
|
27844
|
+
* Default Qwen Code model used by the coding runner.
|
|
27845
|
+
*/
|
|
27846
|
+
const DEFAULT_QWEN_CODE_MODEL = 'qwen3.8-max';
|
|
27847
|
+
/**
|
|
27848
|
+
* Runs prompts via the Qwen Code CLI.
|
|
27849
|
+
*/
|
|
27850
|
+
class QwenCodeRunner {
|
|
27851
|
+
/**
|
|
27852
|
+
* Creates a new Qwen Code runner.
|
|
27853
|
+
*/
|
|
27854
|
+
constructor(options) {
|
|
27855
|
+
this.options = options;
|
|
27856
|
+
this.name = 'qwen-code';
|
|
27857
|
+
}
|
|
27858
|
+
/**
|
|
27859
|
+
* Runs the prompt using Qwen Code and parses usage output.
|
|
27860
|
+
*/
|
|
27861
|
+
async runPrompt(options) {
|
|
27862
|
+
const scriptContent = buildQwenCodeScript({
|
|
27863
|
+
prompt: options.prompt,
|
|
27864
|
+
model: this.options.model,
|
|
27865
|
+
});
|
|
27866
|
+
const output = await $runGoScriptWithOutput({
|
|
27867
|
+
scriptPath: options.scriptPath,
|
|
27868
|
+
scriptContent,
|
|
27869
|
+
logPath: options.logPath,
|
|
27870
|
+
shouldPrintLiveOutput: options.shouldPrintLiveOutput,
|
|
27871
|
+
preserveArtifactsOnSuccess: options.preserveArtifactsOnSuccess,
|
|
27872
|
+
});
|
|
27873
|
+
const usage = parseQwenCodeUsageFromOutput(output, options.prompt, this.options.model);
|
|
27874
|
+
return { usage };
|
|
27875
|
+
}
|
|
27876
|
+
}
|
|
27877
|
+
|
|
27719
27878
|
/**
|
|
27720
27879
|
* Constant for default codex model.
|
|
27721
27880
|
*/
|
|
@@ -27724,6 +27883,11 @@ const DEFAULT_CODEX_MODEL = 'gpt-5.2-codex';
|
|
|
27724
27883
|
* Constant for cline model.
|
|
27725
27884
|
*/
|
|
27726
27885
|
const CLINE_MODEL = 'gemini:gemini-3-flash-preview';
|
|
27886
|
+
/**
|
|
27887
|
+
* Harnesses which refuse to run without an explicit `--model`, because they expose many models
|
|
27888
|
+
* of very different capability and price and never pick a sensible one on their own.
|
|
27889
|
+
*/
|
|
27890
|
+
const MODEL_REQUIRING_HARNESS_NAMES = ['openai-codex', 'gemini', 'qwen-code'];
|
|
27727
27891
|
/**
|
|
27728
27892
|
* Resolves the configured prompt runner together with status-line metadata.
|
|
27729
27893
|
*
|
|
@@ -27761,6 +27925,9 @@ function resolvePromptRunner(options) {
|
|
|
27761
27925
|
if (agentName === 'gemini') {
|
|
27762
27926
|
return createGeminiRunnerResolution(options);
|
|
27763
27927
|
}
|
|
27928
|
+
if (agentName === 'qwen-code') {
|
|
27929
|
+
return createQwenCodeRunnerResolution(options);
|
|
27930
|
+
}
|
|
27764
27931
|
throw new Error(`Unknown harness: ${agentName}`);
|
|
27765
27932
|
}
|
|
27766
27933
|
/**
|
|
@@ -27802,6 +27969,23 @@ function createGeminiRunnerResolution(options) {
|
|
|
27802
27969
|
model: actualRunnerModel,
|
|
27803
27970
|
}), actualRunnerModel);
|
|
27804
27971
|
}
|
|
27972
|
+
/**
|
|
27973
|
+
* Builds the Qwen Code CLI runner resolution, including required-model validation.
|
|
27974
|
+
*/
|
|
27975
|
+
function createQwenCodeRunnerResolution(options) {
|
|
27976
|
+
const actualRunnerModel = resolveRequiredModel({
|
|
27977
|
+
agentName: 'qwen-code',
|
|
27978
|
+
providedModel: options.model,
|
|
27979
|
+
defaultModel: DEFAULT_QWEN_CODE_MODEL,
|
|
27980
|
+
exampleUsages: [
|
|
27981
|
+
`--harness qwen-code --model ${DEFAULT_QWEN_CODE_MODEL}`,
|
|
27982
|
+
'--harness qwen-code --model default',
|
|
27983
|
+
],
|
|
27984
|
+
});
|
|
27985
|
+
return createRunnerResolution(options, new QwenCodeRunner({
|
|
27986
|
+
model: actualRunnerModel,
|
|
27987
|
+
}), actualRunnerModel);
|
|
27988
|
+
}
|
|
27805
27989
|
/**
|
|
27806
27990
|
* Combines the instantiated runner with prompt status metadata.
|
|
27807
27991
|
*/
|
|
@@ -27817,9 +28001,7 @@ function createRunnerResolution(options, runner, actualRunnerModel) {
|
|
|
27817
28001
|
*/
|
|
27818
28002
|
function getRunnerMetadata(options, actualRunnerModel) {
|
|
27819
28003
|
const runnerName = options.agentName ? getHarnessDefinition(options.agentName).label : 'unknown';
|
|
27820
|
-
if (options.agentName === '
|
|
27821
|
-
options.agentName === 'github-copilot' ||
|
|
27822
|
-
options.agentName === 'gemini') {
|
|
28004
|
+
if (options.agentName === 'github-copilot' || isModelRequiringHarnessName(options.agentName)) {
|
|
27823
28005
|
return { runnerName, modelName: actualRunnerModel };
|
|
27824
28006
|
}
|
|
27825
28007
|
if (options.agentName === 'cline') {
|
|
@@ -27830,6 +28012,12 @@ function getRunnerMetadata(options, actualRunnerModel) {
|
|
|
27830
28012
|
}
|
|
27831
28013
|
return { runnerName };
|
|
27832
28014
|
}
|
|
28015
|
+
/**
|
|
28016
|
+
* Checks whether one harness refuses to run without an explicit `--model`.
|
|
28017
|
+
*/
|
|
28018
|
+
function isModelRequiringHarnessName(agentName) {
|
|
28019
|
+
return MODEL_REQUIRING_HARNESS_NAMES.includes(agentName);
|
|
28020
|
+
}
|
|
27833
28021
|
/**
|
|
27834
28022
|
* Resolves a runner model, allowing `default` but otherwise requiring an explicit value.
|
|
27835
28023
|
*/
|
|
@@ -39981,7 +40169,7 @@ function updateAgentRunUiForPulling(uiHandle, queueSnapshot, statusMessage) {
|
|
|
39981
40169
|
*/
|
|
39982
40170
|
function validateAgentRunOptions(options) {
|
|
39983
40171
|
if (!options.agentName) {
|
|
39984
|
-
throw new NotAllowed(
|
|
40172
|
+
throw new NotAllowed(`You must choose a harness using ${PROMPT_RUNNER_HARNESS_OPTION_HINT}.`);
|
|
39985
40173
|
}
|
|
39986
40174
|
if (options.autoPull && options.noCommit) {
|
|
39987
40175
|
throw new NotAllowed(spaceTrim$1(`
|
|
@@ -74653,7 +74841,7 @@ function parseRunOptions(args) {
|
|
|
74653
74841
|
exitWithUsageError(error instanceof Error ? error.message : String(error));
|
|
74654
74842
|
}
|
|
74655
74843
|
if (!agentName && !dryRun) {
|
|
74656
|
-
exitWithUsageError(
|
|
74844
|
+
exitWithUsageError(`You must choose a harness using ${PROMPT_RUNNER_HARNESS_OPTION_HINT}`);
|
|
74657
74845
|
}
|
|
74658
74846
|
return {
|
|
74659
74847
|
dryRun,
|