@promptbook/node 0.114.0-29 → 0.114.0-30

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 CHANGED
@@ -30,7 +30,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
30
30
  * @generated
31
31
  * @see https://github.com/webgptorg/promptbook
32
32
  */
33
- const PROMPTBOOK_ENGINE_VERSION = '0.114.0-29';
33
+ const PROMPTBOOK_ENGINE_VERSION = '0.114.0-30';
34
34
  /**
35
35
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
36
36
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -4762,6 +4762,9 @@ function buildCodexScript(options) {
4762
4762
  fi
4763
4763
  `);
4764
4764
  const thinkingLevel = (_a = options.thinkingLevel) !== null && _a !== void 0 ? _a : DEFAULT_CODEX_THINKING_LEVEL;
4765
+ // Note: Without an explicit model Codex keeps the model of its own configuration, which is what a
4766
+ // ChatGPT-account login needs — it rejects every model that Codex itself does not offer
4767
+ const modelArgument = options.model ? ` --model ${options.model}` : '';
4765
4768
  const lines = [
4766
4769
  'if [ -n "${PTBK_AGENTS_SERVER_ENV_FILE:-}" ] && [ -f "${PTBK_AGENTS_SERVER_ENV_FILE}" ]; then',
4767
4770
  'set -a',
@@ -4788,7 +4791,7 @@ function buildCodexScript(options) {
4788
4791
  ' "${CODEX_LOGIN_METHOD_ARGUMENTS[@]}" \\',
4789
4792
  ` -c model_reasoning_effort="${thinkingLevel}" \\`,
4790
4793
  ` --ask-for-approval ${options.askForApproval} \\`,
4791
- ` exec --model ${options.model} \\`,
4794
+ ` exec${modelArgument} \\`,
4792
4795
  ...(options.isMachineReadableProgressEnabled ? [' --json \\'] : []),
4793
4796
  ' --local-provider none \\',
4794
4797
  ` --sandbox ${options.sandbox} \\`,
@@ -4836,6 +4839,9 @@ const CODEX_FALLBACK_PRICING_MODEL = 'gpt-5.1';
4836
4839
  const DEFAULT_CODEX_COMPLETION_SHARE = 0.1;
4837
4840
  /**
4838
4841
  * Builds usage stats from Codex CLI output.
4842
+ *
4843
+ * The `modelName` is omitted when Codex ran without a model override, in which case only Codex knows which
4844
+ * model it picked and the price can be estimated from the fallback pricing alone.
4839
4845
  */
4840
4846
  function buildCodexUsageFromOutput(output, modelName) {
4841
4847
  const breakdown = parseCodexTokenBreakdown(output);
@@ -4972,18 +4978,25 @@ function parseCodexTokenCount(value) {
4972
4978
  }
4973
4979
  /**
4974
4980
  * Resolves a pricing model to estimate Codex cost from total tokens.
4981
+ *
4982
+ * An unknown model — and a run without any model override, where Codex picked the model itself — is priced
4983
+ * with `CODEX_FALLBACK_PRICING_MODEL`, so the estimate stays in the right order of magnitude.
4975
4984
  */
4976
4985
  function resolveCodexPricing(modelName) {
4977
4986
  var _a, _b, _c;
4978
- const exactMatch = (_a = OPENAI_MODELS.find((model) => model.modelName === modelName)) === null || _a === void 0 ? void 0 : _a.pricing;
4987
+ const fallbackPricing = (_a = OPENAI_MODELS.find((model) => model.modelName === CODEX_FALLBACK_PRICING_MODEL)) === null || _a === void 0 ? void 0 : _a.pricing;
4988
+ if (modelName === undefined) {
4989
+ return fallbackPricing;
4990
+ }
4991
+ const exactMatch = (_b = OPENAI_MODELS.find((model) => model.modelName === modelName)) === null || _b === void 0 ? void 0 : _b.pricing;
4979
4992
  if (exactMatch) {
4980
4993
  return exactMatch;
4981
4994
  }
4982
- const prefixMatch = (_b = OPENAI_MODELS.find((model) => modelName.startsWith(model.modelName))) === null || _b === void 0 ? void 0 : _b.pricing;
4995
+ const prefixMatch = (_c = OPENAI_MODELS.find((model) => modelName.startsWith(model.modelName))) === null || _c === void 0 ? void 0 : _c.pricing;
4983
4996
  if (prefixMatch) {
4984
4997
  return prefixMatch;
4985
4998
  }
4986
- return (_c = OPENAI_MODELS.find((model) => model.modelName === CODEX_FALLBACK_PRICING_MODEL)) === null || _c === void 0 ? void 0 : _c.pricing;
4999
+ return fallbackPricing;
4987
5000
  }
4988
5001
 
4989
5002
  /**
@@ -5792,9 +5805,9 @@ class QwenCodeRunner {
5792
5805
  }
5793
5806
 
5794
5807
  /**
5795
- * Constant for default codex model.
5808
+ * Value of `--model` which asks for the default model of the selected harness instead of naming one.
5796
5809
  */
5797
- const DEFAULT_CODEX_MODEL = 'gpt-5.2-codex';
5810
+ const DEFAULT_MODEL_NAME = 'default';
5798
5811
  /**
5799
5812
  * Constant for cline model.
5800
5813
  */
@@ -5821,7 +5834,7 @@ function resolvePromptRunner(options) {
5821
5834
  return createRunnerResolution(options, new ClineRunner({ model: CLINE_MODEL }));
5822
5835
  }
5823
5836
  if (agentName === 'github-copilot') {
5824
- const actualRunnerModel = options.model === 'default' ? undefined : options.model;
5837
+ const actualRunnerModel = options.model === DEFAULT_MODEL_NAME ? undefined : options.model;
5825
5838
  return createRunnerResolution(options, new GitHubCopilotRunner({
5826
5839
  model: actualRunnerModel,
5827
5840
  thinkingLevel: options.thinkingLevel,
@@ -5853,7 +5866,9 @@ function createOpenAiCodexRunnerResolution(options) {
5853
5866
  const actualRunnerModel = resolveRequiredModel({
5854
5867
  agentName: 'openai-codex',
5855
5868
  providedModel: options.model,
5856
- defaultModel: DEFAULT_CODEX_MODEL,
5869
+ // Note: Codex must not be pinned to any model of ours, because a ChatGPT-account login only accepts the
5870
+ // models which Codex itself offers — `default` therefore keeps the model from `~/.codex/config.toml`
5871
+ defaultModel: undefined,
5857
5872
  availableModels: OPENAI_MODELS.filter((model) => model.modelVariant === 'CHAT').map((model) => model.modelName),
5858
5873
  exampleUsages: ['--harness openai-codex --model gpt-5.2-codex', '--harness openai-codex --model default'],
5859
5874
  });
@@ -5936,12 +5951,15 @@ function isModelRequiringHarnessName(agentName) {
5936
5951
  }
5937
5952
  /**
5938
5953
  * Resolves a runner model, allowing `default` but otherwise requiring an explicit value.
5954
+ *
5955
+ * The `defaultModel` of a harness is either the model name which `--model default` stands for, or `undefined`
5956
+ * when the harness must be started **without any model override** and keep the model of its own configuration.
5939
5957
  */
5940
5958
  function resolveRequiredModel(options) {
5941
5959
  if (!options.providedModel) {
5942
5960
  exitForMissingModel(options.agentName, options.availableModels, options.exampleUsages);
5943
5961
  }
5944
- if (options.providedModel === 'default') {
5962
+ if (options.providedModel === DEFAULT_MODEL_NAME) {
5945
5963
  return options.defaultModel;
5946
5964
  }
5947
5965
  return options.providedModel;