@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.
@@ -6,5 +6,8 @@ import type { Usage } from '../../../../src/execution/Usage';
6
6
  export declare const DEFAULT_CODEX_COMPLETION_SHARE = 0.1;
7
7
  /**
8
8
  * Builds usage stats from Codex CLI output.
9
+ *
10
+ * The `modelName` is omitted when Codex ran without a model override, in which case only Codex knows which
11
+ * model it picked and the price can be estimated from the fallback pricing alone.
9
12
  */
10
- export declare function buildCodexUsageFromOutput(output: string, modelName: string): Usage;
13
+ export declare function buildCodexUsageFromOutput(output: string, modelName: string | undefined): Usage;
@@ -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-28`).
18
+ * It follows semantic versioning (e.g., `0.114.0-29`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/node",
3
- "version": "0.114.0-29",
3
+ "version": "0.114.0-30",
4
4
  "description": "Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -97,7 +97,7 @@
97
97
  "types": "./esm/src/_packages/node.index.d.ts",
98
98
  "typings": "./esm/src/_packages/node.index.d.ts",
99
99
  "peerDependencies": {
100
- "@promptbook/core": "0.114.0-29"
100
+ "@promptbook/core": "0.114.0-30"
101
101
  },
102
102
  "dependencies": {
103
103
  "@openai/agents": "0.4.15",
package/umd/index.umd.js CHANGED
@@ -47,7 +47,7 @@
47
47
  * @generated
48
48
  * @see https://github.com/webgptorg/promptbook
49
49
  */
50
- const PROMPTBOOK_ENGINE_VERSION = '0.114.0-29';
50
+ const PROMPTBOOK_ENGINE_VERSION = '0.114.0-30';
51
51
  /**
52
52
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
53
53
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -4779,6 +4779,9 @@
4779
4779
  fi
4780
4780
  `);
4781
4781
  const thinkingLevel = (_a = options.thinkingLevel) !== null && _a !== void 0 ? _a : DEFAULT_CODEX_THINKING_LEVEL;
4782
+ // Note: Without an explicit model Codex keeps the model of its own configuration, which is what a
4783
+ // ChatGPT-account login needs — it rejects every model that Codex itself does not offer
4784
+ const modelArgument = options.model ? ` --model ${options.model}` : '';
4782
4785
  const lines = [
4783
4786
  'if [ -n "${PTBK_AGENTS_SERVER_ENV_FILE:-}" ] && [ -f "${PTBK_AGENTS_SERVER_ENV_FILE}" ]; then',
4784
4787
  'set -a',
@@ -4805,7 +4808,7 @@
4805
4808
  ' "${CODEX_LOGIN_METHOD_ARGUMENTS[@]}" \\',
4806
4809
  ` -c model_reasoning_effort="${thinkingLevel}" \\`,
4807
4810
  ` --ask-for-approval ${options.askForApproval} \\`,
4808
- ` exec --model ${options.model} \\`,
4811
+ ` exec${modelArgument} \\`,
4809
4812
  ...(options.isMachineReadableProgressEnabled ? [' --json \\'] : []),
4810
4813
  ' --local-provider none \\',
4811
4814
  ` --sandbox ${options.sandbox} \\`,
@@ -4853,6 +4856,9 @@
4853
4856
  const DEFAULT_CODEX_COMPLETION_SHARE = 0.1;
4854
4857
  /**
4855
4858
  * Builds usage stats from Codex CLI output.
4859
+ *
4860
+ * The `modelName` is omitted when Codex ran without a model override, in which case only Codex knows which
4861
+ * model it picked and the price can be estimated from the fallback pricing alone.
4856
4862
  */
4857
4863
  function buildCodexUsageFromOutput(output, modelName) {
4858
4864
  const breakdown = parseCodexTokenBreakdown(output);
@@ -4989,18 +4995,25 @@
4989
4995
  }
4990
4996
  /**
4991
4997
  * Resolves a pricing model to estimate Codex cost from total tokens.
4998
+ *
4999
+ * An unknown model — and a run without any model override, where Codex picked the model itself — is priced
5000
+ * with `CODEX_FALLBACK_PRICING_MODEL`, so the estimate stays in the right order of magnitude.
4992
5001
  */
4993
5002
  function resolveCodexPricing(modelName) {
4994
5003
  var _a, _b, _c;
4995
- const exactMatch = (_a = OPENAI_MODELS.find((model) => model.modelName === modelName)) === null || _a === void 0 ? void 0 : _a.pricing;
5004
+ const fallbackPricing = (_a = OPENAI_MODELS.find((model) => model.modelName === CODEX_FALLBACK_PRICING_MODEL)) === null || _a === void 0 ? void 0 : _a.pricing;
5005
+ if (modelName === undefined) {
5006
+ return fallbackPricing;
5007
+ }
5008
+ const exactMatch = (_b = OPENAI_MODELS.find((model) => model.modelName === modelName)) === null || _b === void 0 ? void 0 : _b.pricing;
4996
5009
  if (exactMatch) {
4997
5010
  return exactMatch;
4998
5011
  }
4999
- const prefixMatch = (_b = OPENAI_MODELS.find((model) => modelName.startsWith(model.modelName))) === null || _b === void 0 ? void 0 : _b.pricing;
5012
+ const prefixMatch = (_c = OPENAI_MODELS.find((model) => modelName.startsWith(model.modelName))) === null || _c === void 0 ? void 0 : _c.pricing;
5000
5013
  if (prefixMatch) {
5001
5014
  return prefixMatch;
5002
5015
  }
5003
- return (_c = OPENAI_MODELS.find((model) => model.modelName === CODEX_FALLBACK_PRICING_MODEL)) === null || _c === void 0 ? void 0 : _c.pricing;
5016
+ return fallbackPricing;
5004
5017
  }
5005
5018
 
5006
5019
  /**
@@ -5809,9 +5822,9 @@
5809
5822
  }
5810
5823
 
5811
5824
  /**
5812
- * Constant for default codex model.
5825
+ * Value of `--model` which asks for the default model of the selected harness instead of naming one.
5813
5826
  */
5814
- const DEFAULT_CODEX_MODEL = 'gpt-5.2-codex';
5827
+ const DEFAULT_MODEL_NAME = 'default';
5815
5828
  /**
5816
5829
  * Constant for cline model.
5817
5830
  */
@@ -5838,7 +5851,7 @@
5838
5851
  return createRunnerResolution(options, new ClineRunner({ model: CLINE_MODEL }));
5839
5852
  }
5840
5853
  if (agentName === 'github-copilot') {
5841
- const actualRunnerModel = options.model === 'default' ? undefined : options.model;
5854
+ const actualRunnerModel = options.model === DEFAULT_MODEL_NAME ? undefined : options.model;
5842
5855
  return createRunnerResolution(options, new GitHubCopilotRunner({
5843
5856
  model: actualRunnerModel,
5844
5857
  thinkingLevel: options.thinkingLevel,
@@ -5870,7 +5883,9 @@
5870
5883
  const actualRunnerModel = resolveRequiredModel({
5871
5884
  agentName: 'openai-codex',
5872
5885
  providedModel: options.model,
5873
- defaultModel: DEFAULT_CODEX_MODEL,
5886
+ // Note: Codex must not be pinned to any model of ours, because a ChatGPT-account login only accepts the
5887
+ // models which Codex itself offers — `default` therefore keeps the model from `~/.codex/config.toml`
5888
+ defaultModel: undefined,
5874
5889
  availableModels: OPENAI_MODELS.filter((model) => model.modelVariant === 'CHAT').map((model) => model.modelName),
5875
5890
  exampleUsages: ['--harness openai-codex --model gpt-5.2-codex', '--harness openai-codex --model default'],
5876
5891
  });
@@ -5953,12 +5968,15 @@
5953
5968
  }
5954
5969
  /**
5955
5970
  * Resolves a runner model, allowing `default` but otherwise requiring an explicit value.
5971
+ *
5972
+ * The `defaultModel` of a harness is either the model name which `--model default` stands for, or `undefined`
5973
+ * when the harness must be started **without any model override** and keep the model of its own configuration.
5956
5974
  */
5957
5975
  function resolveRequiredModel(options) {
5958
5976
  if (!options.providedModel) {
5959
5977
  exitForMissingModel(options.agentName, options.availableModels, options.exampleUsages);
5960
5978
  }
5961
- if (options.providedModel === 'default') {
5979
+ if (options.providedModel === DEFAULT_MODEL_NAME) {
5962
5980
  return options.defaultModel;
5963
5981
  }
5964
5982
  return options.providedModel;