@codemieai/code 0.15.3 → 0.15.5

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 (208) hide show
  1. package/dist/agents/core/AgentCLI.d.ts.map +1 -1
  2. package/dist/agents/core/AgentCLI.js +9 -0
  3. package/dist/agents/core/AgentCLI.js.map +1 -1
  4. package/dist/agents/core/BaseAgentAdapter.d.ts.map +1 -1
  5. package/dist/agents/core/BaseAgentAdapter.js +34 -9
  6. package/dist/agents/core/BaseAgentAdapter.js.map +1 -1
  7. package/dist/agents/plugins/claude/claude.models.d.ts +58 -0
  8. package/dist/agents/plugins/claude/claude.models.d.ts.map +1 -1
  9. package/dist/agents/plugins/claude/claude.models.js +196 -10
  10. package/dist/agents/plugins/claude/claude.models.js.map +1 -1
  11. package/dist/agents/plugins/claude/claude.plugin.d.ts.map +1 -1
  12. package/dist/agents/plugins/claude/claude.plugin.js +147 -45
  13. package/dist/agents/plugins/claude/claude.plugin.js.map +1 -1
  14. package/dist/agents/plugins/claude/plugin/statusline.bundle.mjs +729 -0
  15. package/dist/agents/plugins/claude/statusline-installer.d.ts +1 -1
  16. package/dist/agents/plugins/claude/statusline-installer.d.ts.map +1 -1
  17. package/dist/agents/plugins/claude/statusline-installer.js +41 -3
  18. package/dist/agents/plugins/claude/statusline-installer.js.map +1 -1
  19. package/dist/agents/plugins/codex/codex-models.d.ts.map +1 -1
  20. package/dist/agents/plugins/codex/codex-models.js +109 -8
  21. package/dist/agents/plugins/codex/codex-models.js.map +1 -1
  22. package/dist/agents/plugins/codex/codex.correlation.d.ts +39 -0
  23. package/dist/agents/plugins/codex/codex.correlation.d.ts.map +1 -0
  24. package/dist/agents/plugins/codex/codex.correlation.js +150 -0
  25. package/dist/agents/plugins/codex/codex.correlation.js.map +1 -0
  26. package/dist/agents/plugins/codex/codex.plugin.d.ts.map +1 -1
  27. package/dist/agents/plugins/codex/codex.plugin.js +8 -40
  28. package/dist/agents/plugins/codex/codex.plugin.js.map +1 -1
  29. package/dist/agents/plugins/kimi/kimi.env-model.d.ts +27 -0
  30. package/dist/agents/plugins/kimi/kimi.env-model.d.ts.map +1 -0
  31. package/dist/agents/plugins/kimi/kimi.env-model.js +52 -0
  32. package/dist/agents/plugins/kimi/kimi.env-model.js.map +1 -0
  33. package/dist/agents/plugins/kimi/kimi.session.d.ts +6 -0
  34. package/dist/agents/plugins/kimi/kimi.session.d.ts.map +1 -1
  35. package/dist/agents/plugins/kimi/kimi.session.js +24 -2
  36. package/dist/agents/plugins/kimi/kimi.session.js.map +1 -1
  37. package/dist/agents/plugins/opencode/opencode-dynamic-models.js +1 -1
  38. package/dist/agents/plugins/opencode/opencode-dynamic-models.js.map +1 -1
  39. package/dist/cli/commands/analytics/cost/cost-enricher.d.ts +19 -2
  40. package/dist/cli/commands/analytics/cost/cost-enricher.d.ts.map +1 -1
  41. package/dist/cli/commands/analytics/cost/cost-enricher.js +171 -14
  42. package/dist/cli/commands/analytics/cost/cost-enricher.js.map +1 -1
  43. package/dist/cli/commands/analytics/cost/local-models.d.ts +15 -0
  44. package/dist/cli/commands/analytics/cost/local-models.d.ts.map +1 -0
  45. package/dist/cli/commands/analytics/cost/local-models.js +21 -0
  46. package/dist/cli/commands/analytics/cost/local-models.js.map +1 -0
  47. package/dist/cli/commands/analytics/cost/types.d.ts +60 -0
  48. package/dist/cli/commands/analytics/cost/types.d.ts.map +1 -1
  49. package/dist/cli/commands/analytics/cost/types.js.map +1 -1
  50. package/dist/cli/commands/analytics/cost/usage-readers.d.ts +25 -2
  51. package/dist/cli/commands/analytics/cost/usage-readers.d.ts.map +1 -1
  52. package/dist/cli/commands/analytics/cost/usage-readers.js +61 -3
  53. package/dist/cli/commands/analytics/cost/usage-readers.js.map +1 -1
  54. package/dist/cli/commands/analytics/formatter.d.ts +11 -0
  55. package/dist/cli/commands/analytics/formatter.d.ts.map +1 -1
  56. package/dist/cli/commands/analytics/formatter.js +28 -0
  57. package/dist/cli/commands/analytics/formatter.js.map +1 -1
  58. package/dist/cli/commands/analytics/index.d.ts.map +1 -1
  59. package/dist/cli/commands/analytics/index.js +113 -72
  60. package/dist/cli/commands/analytics/index.js.map +1 -1
  61. package/dist/cli/commands/analytics/otel-loader.d.ts.map +1 -1
  62. package/dist/cli/commands/analytics/otel-loader.js +60 -14
  63. package/dist/cli/commands/analytics/otel-loader.js.map +1 -1
  64. package/dist/cli/commands/analytics/otel-pricing.d.ts +38 -0
  65. package/dist/cli/commands/analytics/otel-pricing.d.ts.map +1 -0
  66. package/dist/cli/commands/analytics/otel-pricing.js +33 -0
  67. package/dist/cli/commands/analytics/otel-pricing.js.map +1 -0
  68. package/dist/cli/commands/analytics/report/client/app.js +279 -18
  69. package/dist/cli/commands/analytics/report/output-target.d.ts +22 -0
  70. package/dist/cli/commands/analytics/report/output-target.d.ts.map +1 -0
  71. package/dist/cli/commands/analytics/report/output-target.js +56 -0
  72. package/dist/cli/commands/analytics/report/output-target.js.map +1 -0
  73. package/dist/cli/commands/analytics/report/payload-builder.d.ts.map +1 -1
  74. package/dist/cli/commands/analytics/report/payload-builder.js +6 -0
  75. package/dist/cli/commands/analytics/report/payload-builder.js.map +1 -1
  76. package/dist/cli/commands/analytics/report/report-generator.d.ts +1 -1
  77. package/dist/cli/commands/analytics/report/report-generator.js +1 -1
  78. package/dist/cli/commands/analytics/report/session-report.d.ts +1 -3
  79. package/dist/cli/commands/analytics/report/session-report.d.ts.map +1 -1
  80. package/dist/cli/commands/analytics/report/session-report.js +1 -3
  81. package/dist/cli/commands/analytics/report/session-report.js.map +1 -1
  82. package/dist/cli/commands/analytics/report/template.html +6 -6
  83. package/dist/cli/commands/analytics/report/types.d.ts +17 -1
  84. package/dist/cli/commands/analytics/report/types.d.ts.map +1 -1
  85. package/dist/cli/commands/analytics/sources/sessions-source.d.ts.map +1 -1
  86. package/dist/cli/commands/analytics/sources/sessions-source.js +9 -11
  87. package/dist/cli/commands/analytics/sources/sessions-source.js.map +1 -1
  88. package/dist/cli/commands/analytics/sources/types.d.ts +0 -2
  89. package/dist/cli/commands/analytics/sources/types.d.ts.map +1 -1
  90. package/dist/cli/commands/analytics/types.d.ts +13 -7
  91. package/dist/cli/commands/analytics/types.d.ts.map +1 -1
  92. package/dist/cli/commands/doctor/checks/NpmPrefixOverrideCheck.d.ts +9 -0
  93. package/dist/cli/commands/doctor/checks/NpmPrefixOverrideCheck.d.ts.map +1 -0
  94. package/dist/cli/commands/doctor/checks/NpmPrefixOverrideCheck.js +42 -0
  95. package/dist/cli/commands/doctor/checks/NpmPrefixOverrideCheck.js.map +1 -0
  96. package/dist/cli/commands/doctor/checks/index.d.ts +1 -0
  97. package/dist/cli/commands/doctor/checks/index.d.ts.map +1 -1
  98. package/dist/cli/commands/doctor/checks/index.js +1 -0
  99. package/dist/cli/commands/doctor/checks/index.js.map +1 -1
  100. package/dist/cli/commands/doctor/index.d.ts.map +1 -1
  101. package/dist/cli/commands/doctor/index.js +2 -1
  102. package/dist/cli/commands/doctor/index.js.map +1 -1
  103. package/dist/cli/commands/models.d.ts.map +1 -1
  104. package/dist/cli/commands/models.js +16 -3
  105. package/dist/cli/commands/models.js.map +1 -1
  106. package/dist/cli/commands/proxy/connect-orchestrator.js +1 -1
  107. package/dist/cli/commands/proxy/connect-orchestrator.js.map +1 -1
  108. package/dist/cli/commands/proxy/connectors/tenant-catalog.d.ts +16 -4
  109. package/dist/cli/commands/proxy/connectors/tenant-catalog.d.ts.map +1 -1
  110. package/dist/cli/commands/proxy/connectors/tenant-catalog.js +42 -14
  111. package/dist/cli/commands/proxy/connectors/tenant-catalog.js.map +1 -1
  112. package/dist/cli/commands/proxy/connectors/vscode-models.d.ts +18 -0
  113. package/dist/cli/commands/proxy/connectors/vscode-models.d.ts.map +1 -1
  114. package/dist/cli/commands/proxy/connectors/vscode-models.js +58 -0
  115. package/dist/cli/commands/proxy/connectors/vscode-models.js.map +1 -1
  116. package/dist/cli/commands/proxy/connectors/vscode.d.ts +2 -2
  117. package/dist/cli/commands/proxy/connectors/vscode.d.ts.map +1 -1
  118. package/dist/cli/commands/proxy/connectors/vscode.js +27 -38
  119. package/dist/cli/commands/proxy/connectors/vscode.js.map +1 -1
  120. package/dist/cli/commands/update.d.ts.map +1 -1
  121. package/dist/cli/commands/update.js +4 -3
  122. package/dist/cli/commands/update.js.map +1 -1
  123. package/dist/frameworks/plugins/codegraph.plugin.js +2 -2
  124. package/dist/frameworks/plugins/codegraph.plugin.js.map +1 -1
  125. package/dist/providers/core/codemie-auth-helpers.d.ts.map +1 -1
  126. package/dist/providers/core/codemie-auth-helpers.js +6 -1
  127. package/dist/providers/core/codemie-auth-helpers.js.map +1 -1
  128. package/dist/providers/core/default-agent-hooks.d.ts.map +1 -1
  129. package/dist/providers/core/default-agent-hooks.js +9 -0
  130. package/dist/providers/core/default-agent-hooks.js.map +1 -1
  131. package/dist/providers/plugins/bedrock/bedrock.template.d.ts.map +1 -1
  132. package/dist/providers/plugins/bedrock/bedrock.template.js +5 -31
  133. package/dist/providers/plugins/bedrock/bedrock.template.js.map +1 -1
  134. package/dist/providers/plugins/sso/proxy/plugins/background-request-normalizer.plugin.d.ts +44 -0
  135. package/dist/providers/plugins/sso/proxy/plugins/background-request-normalizer.plugin.d.ts.map +1 -0
  136. package/dist/providers/plugins/sso/proxy/plugins/background-request-normalizer.plugin.js +106 -0
  137. package/dist/providers/plugins/sso/proxy/plugins/background-request-normalizer.plugin.js.map +1 -0
  138. package/dist/providers/plugins/sso/proxy/plugins/index.d.ts +3 -1
  139. package/dist/providers/plugins/sso/proxy/plugins/index.d.ts.map +1 -1
  140. package/dist/providers/plugins/sso/proxy/plugins/index.js +5 -1
  141. package/dist/providers/plugins/sso/proxy/plugins/index.js.map +1 -1
  142. package/dist/providers/plugins/sso/proxy/plugins/routing-header-injector.plugin.d.ts +67 -0
  143. package/dist/providers/plugins/sso/proxy/plugins/routing-header-injector.plugin.d.ts.map +1 -0
  144. package/dist/providers/plugins/sso/proxy/plugins/routing-header-injector.plugin.js +203 -0
  145. package/dist/providers/plugins/sso/proxy/plugins/routing-header-injector.plugin.js.map +1 -0
  146. package/dist/providers/plugins/sso/sso.http-client.d.ts +95 -0
  147. package/dist/providers/plugins/sso/sso.http-client.d.ts.map +1 -1
  148. package/dist/providers/plugins/sso/sso.http-client.js +79 -0
  149. package/dist/providers/plugins/sso/sso.http-client.js.map +1 -1
  150. package/dist/providers/plugins/sso/sso.models.d.ts +7 -0
  151. package/dist/providers/plugins/sso/sso.models.d.ts.map +1 -1
  152. package/dist/providers/plugins/sso/sso.models.js +22 -14
  153. package/dist/providers/plugins/sso/sso.models.js.map +1 -1
  154. package/dist/utils/bedrock-pricing.mjs +111 -0
  155. package/dist/utils/cli-bin.d.ts.map +1 -1
  156. package/dist/utils/cli-bin.js +3 -4
  157. package/dist/utils/cli-bin.js.map +1 -1
  158. package/dist/utils/cli-updater.d.ts +1 -0
  159. package/dist/utils/cli-updater.d.ts.map +1 -1
  160. package/dist/utils/cli-updater.js +37 -9
  161. package/dist/utils/cli-updater.js.map +1 -1
  162. package/dist/utils/credential-crypto.d.ts +51 -0
  163. package/dist/utils/credential-crypto.d.ts.map +1 -0
  164. package/dist/utils/credential-crypto.js +96 -0
  165. package/dist/utils/credential-crypto.js.map +1 -0
  166. package/dist/utils/model-normalizer.d.ts +6 -0
  167. package/dist/utils/model-normalizer.d.ts.map +1 -1
  168. package/dist/utils/model-normalizer.js +37 -19
  169. package/dist/utils/model-normalizer.js.map +1 -1
  170. package/dist/utils/npm-prefix.d.ts +48 -0
  171. package/dist/utils/npm-prefix.d.ts.map +1 -0
  172. package/dist/utils/npm-prefix.js +142 -0
  173. package/dist/utils/npm-prefix.js.map +1 -0
  174. package/dist/utils/paths.d.ts +7 -0
  175. package/dist/utils/paths.d.ts.map +1 -1
  176. package/dist/utils/paths.js +10 -0
  177. package/dist/utils/paths.js.map +1 -1
  178. package/dist/utils/platform.d.ts +10 -0
  179. package/dist/utils/platform.d.ts.map +1 -0
  180. package/dist/utils/platform.js +14 -0
  181. package/dist/utils/platform.js.map +1 -0
  182. package/dist/utils/price-resolution.d.ts +42 -0
  183. package/dist/utils/price-resolution.d.ts.map +1 -0
  184. package/dist/utils/price-resolution.js +112 -0
  185. package/dist/utils/price-resolution.js.map +1 -0
  186. package/dist/utils/pricing.d.ts +65 -6
  187. package/dist/utils/pricing.d.ts.map +1 -1
  188. package/dist/utils/pricing.js +91 -117
  189. package/dist/utils/pricing.js.map +1 -1
  190. package/dist/utils/pricing.json +201 -20
  191. package/dist/utils/processes.d.ts.map +1 -1
  192. package/dist/utils/processes.js +6 -3
  193. package/dist/utils/processes.js.map +1 -1
  194. package/dist/utils/routing-headers.mjs +104 -0
  195. package/dist/utils/security.d.ts +0 -32
  196. package/dist/utils/security.d.ts.map +1 -1
  197. package/dist/utils/security.js +20 -102
  198. package/dist/utils/security.js.map +1 -1
  199. package/package.json +4 -2
  200. package/scripts/bundle-statusline.mjs +37 -0
  201. package/scripts/copy-plugins.js +19 -2
  202. package/src/utils/tips.json +9 -9
  203. package/dist/agents/plugins/claude/plugin/__tests__/statusline.test.ts +0 -323
  204. package/dist/agents/plugins/claude/plugin/statusline.mjs +0 -282
  205. package/dist/cli/commands/analytics/exporter.d.ts +0 -20
  206. package/dist/cli/commands/analytics/exporter.d.ts.map +0 -1
  207. package/dist/cli/commands/analytics/exporter.js +0 -91
  208. package/dist/cli/commands/analytics/exporter.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"npm-prefix.d.ts","sourceRoot":"","sources":["../../src/utils/npm-prefix.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA2BH;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,GAAE,MAAqD,EACjE,QAAQ,GAAE,MAAM,CAAC,QAA2B,GAC3C,MAAM,GAAG,IAAI,CAwBf;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,GAAE,MAAM,CAAC,QAA2B,GAAG,MAAM,CAK3F;AAqBD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAS/D;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAWjE;AAED;;GAEG;AACH,wBAAsB,2BAA2B,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAE1E;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAY1D"}
@@ -0,0 +1,142 @@
1
+ /**
2
+ * npm Prefix Utilities
3
+ *
4
+ * Resolves the npm prefix CodeMie runs from and detects the per-user prefix override that
5
+ * older CodeMie installers wrote to `.npmrc`.
6
+ */
7
+ import path from 'path';
8
+ import { existsSync } from 'fs';
9
+ import { readFile } from 'fs/promises';
10
+ import { homedir } from 'os';
11
+ import { getDirname, isSamePath } from '../utils/paths.js';
12
+ import { getPathModule, isWindows } from '../utils/platform.js';
13
+ import { exec } from '../utils/exec.js';
14
+ const WIN32_LAYOUT = ['node_modules', '@codemieai', 'code'];
15
+ const POSIX_LAYOUT = ['lib', 'node_modules', '@codemieai', 'code'];
16
+ function findPackageRoot(startDir) {
17
+ let dir = startDir;
18
+ for (;;) {
19
+ if (existsSync(path.join(dir, 'package.json'))) {
20
+ return dir;
21
+ }
22
+ const parent = path.dirname(dir);
23
+ if (parent === dir) {
24
+ return startDir;
25
+ }
26
+ dir = parent;
27
+ }
28
+ }
29
+ /**
30
+ * Get the npm prefix the running CodeMie package was installed into, derived from its
31
+ * location: `<prefix>\node_modules\@codemieai\code` on win32,
32
+ * `<prefix>/lib/node_modules/@codemieai/code` on POSIX.
33
+ *
34
+ * @param packageDir - Package root to inspect; defaults to the running package's own root.
35
+ * @param platform - Platform whose path rules and layout to use; defaults to `process.platform`.
36
+ * @returns The prefix, or `null` when `packageDir` does not match the layout (dev checkout,
37
+ * `npm link`) or, on win32, when `<prefix>\codemie.cmd` is missing (project-local dependency,
38
+ * npx cache).
39
+ */
40
+ export function getCodemieNpmPrefix(packageDir = findPackageRoot(getDirname(import.meta.url)), platform = process.platform) {
41
+ const p = getPathModule(platform);
42
+ const windows = isWindows(platform);
43
+ const layout = windows ? WIN32_LAYOUT : POSIX_LAYOUT;
44
+ const parts = p.resolve(packageDir).split(p.sep);
45
+ if (parts.length <= layout.length) {
46
+ return null;
47
+ }
48
+ const tail = parts.slice(-layout.length);
49
+ const matchesLayout = tail.every((part, i) => windows ? part.toLowerCase() === layout[i].toLowerCase() : part === layout[i]);
50
+ if (!matchesLayout) {
51
+ return null;
52
+ }
53
+ const prefix = parts.slice(0, -layout.length).join(p.sep) || p.sep;
54
+ if (windows && !existsSync(p.join(prefix, 'codemie.cmd'))) {
55
+ return null;
56
+ }
57
+ return prefix;
58
+ }
59
+ /**
60
+ * Path of the per-user npm prefix that older CodeMie installers wrote to `.npmrc`.
61
+ *
62
+ * @param platform - Platform to resolve the path for; defaults to `process.platform`.
63
+ */
64
+ export function getLegacyNpmPrefixPath(platform = process.platform) {
65
+ if (isWindows(platform)) {
66
+ return path.join(process.env.LOCALAPPDATA ?? '', 'CodeMie', 'npm-prefix');
67
+ }
68
+ return path.join(homedir(), '.codemie', 'npm-prefix');
69
+ }
70
+ async function readNpmValue(args) {
71
+ try {
72
+ const result = await exec('npm', args, { shell: isWindows() });
73
+ if (result.code !== 0) {
74
+ return null;
75
+ }
76
+ return result.stdout.trim() || null;
77
+ }
78
+ catch {
79
+ return null;
80
+ }
81
+ }
82
+ let globalNpmPrefix;
83
+ function getGlobalNpmPrefix() {
84
+ globalNpmPrefix ??= readNpmValue(['prefix', '-g']);
85
+ return globalNpmPrefix;
86
+ }
87
+ /**
88
+ * Extract the last `prefix=` value from `.npmrc` content, with surrounding quotes removed.
89
+ */
90
+ export function parseNpmrcPrefix(content) {
91
+ let prefix = null;
92
+ for (const line of content.split(/\r?\n/)) {
93
+ const match = /^\s*prefix\s*=\s*(.*?)\s*$/.exec(line);
94
+ if (match) {
95
+ prefix = match[1].replace(/^"(.*)"$/, '$1') || null;
96
+ }
97
+ }
98
+ return prefix;
99
+ }
100
+ /**
101
+ * Read the `prefix` set in the user-level `.npmrc` (the file `npm config get userconfig` points to).
102
+ *
103
+ * Unlike `npm config get prefix`, this ignores `NPM_CONFIG_PREFIX` and global/project config.
104
+ *
105
+ * @returns The prefix, or `null` when it is not set or the file cannot be read.
106
+ */
107
+ export async function getUserNpmrcPrefix() {
108
+ const userConfigPath = await readNpmValue(['config', 'get', 'userconfig']);
109
+ if (!userConfigPath) {
110
+ return null;
111
+ }
112
+ try {
113
+ return parseNpmrcPrefix(await readFile(userConfigPath, 'utf8'));
114
+ }
115
+ catch {
116
+ return null;
117
+ }
118
+ }
119
+ /**
120
+ * The prefix of the running CodeMie copy, or npm's global prefix when it cannot be derived.
121
+ */
122
+ export async function getCodemieOrGlobalNpmPrefix() {
123
+ return getCodemieNpmPrefix() ?? getGlobalNpmPrefix();
124
+ }
125
+ /**
126
+ * `--prefix` args that keep an npm global install/uninstall/list next to the running CodeMie copy.
127
+ *
128
+ * @returns `[]` when CodeMie runs from npm's global prefix, from a dev checkout, or when either
129
+ * prefix cannot be resolved; otherwise `['--prefix', <CodeMie prefix>]`.
130
+ */
131
+ export async function getNpmPrefixArgs() {
132
+ const codemiePrefix = getCodemieNpmPrefix();
133
+ if (!codemiePrefix) {
134
+ return [];
135
+ }
136
+ const globalPrefix = await getGlobalNpmPrefix();
137
+ if (!globalPrefix || isSamePath(codemiePrefix, globalPrefix)) {
138
+ return [];
139
+ }
140
+ return ['--prefix', codemiePrefix];
141
+ }
142
+ //# sourceMappingURL=npm-prefix.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"npm-prefix.js","sourceRoot":"","sources":["../../src/utils/npm-prefix.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC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ED,IAAI,CAAC;QACH,OAAO,gBAAgB,CAAC,MAAM,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC;IAClE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B;IAC/C,OAAO,mBAAmB,EAAE,IAAI,kBAAkB,EAAE,CAAC;AACvD,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,MAAM,aAAa,GAAG,mBAAmB,EAAE,CAAC;IAC5C,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,YAAY,GAAG,MAAM,kBAAkB,EAAE,CAAC;IAChD,IAAI,CAAC,YAAY,IAAI,UAAU,CAAC,aAAa,EAAE,YAAY,CAAC,EAAE,CAAC;QAC7D,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;AACrC,CAAC"}
@@ -142,6 +142,13 @@ export declare function validatePathDepth(filePath: string, baseDirName: string,
142
142
  * // Returns: false (prevented traversal attack)
143
143
  */
144
144
  export declare function isPathWithinDirectory(workingDir: string, resolvedPath: string): boolean;
145
+ /**
146
+ * Check whether two paths point to the same location, ignoring trailing separators and,
147
+ * on win32, letter case.
148
+ *
149
+ * @param platform - Platform whose path rules to use; defaults to `process.platform`.
150
+ */
151
+ export declare function isSamePath(a: string, b: string, platform?: NodeJS.Platform): boolean;
145
152
  /**
146
153
  * Validate if a string matches UUID format (any version)
147
154
  *
@@ -1 +1 @@
1
- {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/utils/paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAWH;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CA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;GAmBG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAMhF;AAMD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAE3D;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAMvC;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAEzD;AAYD;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAalE;AAMD;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAExD"}
@@ -13,6 +13,7 @@ import path from 'path';
13
13
  import { homedir } from 'os';
14
14
  import { fileURLToPath } from 'url';
15
15
  import { dirname } from 'path';
16
+ import { getPathModule } from './platform.js';
16
17
  // ============================================================================
17
18
  // Path Normalization and Manipulation
18
19
  // ============================================================================
@@ -203,6 +204,15 @@ export function isPathWithinDirectory(workingDir, resolvedPath) {
203
204
  // If path starts with '..' or is an absolute path, it's outside workingDir
204
205
  return !relative.startsWith('..') && !path.isAbsolute(relative);
205
206
  }
207
+ /**
208
+ * Check whether two paths point to the same location, ignoring trailing separators and,
209
+ * on win32, letter case.
210
+ *
211
+ * @param platform - Platform whose path rules to use; defaults to `process.platform`.
212
+ */
213
+ export function isSamePath(a, b, platform = process.platform) {
214
+ return getPathModule(platform).relative(a, b) === '';
215
+ }
206
216
  // ============================================================================
207
217
  // UUID Validation Utilities
208
218
  // ============================================================================
@@ -1 +1 @@
1
- {"version":3,"file":"paths.js","sourceRo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AG,CAAC,CAAC,EAAE,CAAC;IAC7E,CAAC;IAED,OAAO,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,SAAS,CAAC;AACpD,CAAC;AAED,+EAA+E;AAC/E,4BAA4B;AAC5B,+EAA+E;AAE/E;;;;;;;;;GASG;AACH,MAAM,UAAU,UAAU,CAAC,aAAqB;IAC9C,OAAO,OAAO,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Platform helpers.
3
+ */
4
+ import path from 'path';
5
+ export declare function isWindows(platform?: NodeJS.Platform): boolean;
6
+ /**
7
+ * The `path` implementation whose separator and case rules match `platform`.
8
+ */
9
+ export declare function getPathModule(platform?: NodeJS.Platform): path.PlatformPath;
10
+ //# sourceMappingURL=platform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../src/utils/platform.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,wBAAgB,SAAS,CAAC,QAAQ,GAAE,MAAM,CAAC,QAA2B,GAAG,OAAO,CAE/E;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,GAAE,MAAM,CAAC,QAA2B,GAAG,IAAI,CAAC,YAAY,CAE7F"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Platform helpers.
3
+ */
4
+ import path from 'path';
5
+ export function isWindows(platform = process.platform) {
6
+ return platform === 'win32';
7
+ }
8
+ /**
9
+ * The `path` implementation whose separator and case rules match `platform`.
10
+ */
11
+ export function getPathModule(platform = process.platform) {
12
+ return isWindows(platform) ? path.win32 : path.posix;
13
+ }
14
+ //# sourceMappingURL=platform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.js","sourceRoot":"","sources":["../../src/utils/platform.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,UAAU,SAAS,CAAC,WAA4B,OAAO,CAAC,QAAQ;IACpE,OAAO,QAAQ,KAAK,OAAO,CAAC;AAC9B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,WAA4B,OAAO,CAAC,QAAQ;IACxE,OAAO,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;AACvD,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Model-id → pricing-table-key resolution, shared by every consumer that prices a model id:
3
+ * src/utils/pricing.ts (the analytics report's resolvePrice()) and the standalone Claude
4
+ * statusline (src/agents/plugins/claude/plugin/statusline.ts, bundled into one self-contained file
5
+ * by scripts/bundle-statusline.mjs). Keeping one copy is what stops the live statusline cost and
6
+ * the analytics report from disagreeing on the same transcript.
7
+ *
8
+ * Deliberately free of I/O and of any import beyond model-normalizer.ts (itself dependency-free),
9
+ * so the statusline bundle stays small and never drags in fs/config/keytar-bearing modules. It
10
+ * knows nothing about the shape of a price row — callers pass a key lookup over their own table.
11
+ */
12
+ /** How an observed model id was matched to a table key. */
13
+ export type PriceMatch = 'exact' | 'snapshot' | 'reordered';
14
+ /** A table key an observed id resolved to, the value found under it, and how it matched. */
15
+ export interface PriceKeyHit<T> {
16
+ key: string;
17
+ match: PriceMatch;
18
+ value: T;
19
+ }
20
+ /**
21
+ * The table-key form of a raw pricing-data key: lowercased, dots turned to dashes, so `GLM-4.7`
22
+ * and `glm-4-7` land on the same entry. Both sides of a lookup must be folded the same way —
23
+ * observed ids go through {@link canonicalizeModelId}, which ends in this same folding.
24
+ */
25
+ export declare function priceTableKey(rawKey: string): string;
26
+ /**
27
+ * Canonicalizes an observed model id into the form used as a pricing-table key. Extends
28
+ * {@link normalizeModelName} (which strips Bedrock/Kimi/vendor-path prefixes) with:
29
+ * 1. Lowercasing, dots turned to dashes, and `@` turned to `-` (so Vertex's `claude-x@20260205`
30
+ * folds to the same shape as a dated id).
31
+ * 2. Stripping a trailing `-vertex` suffix.
32
+ * Used by the pricing resolver, the statusline and cost reconciliation, so every consumer treats
33
+ * the same observed id the same way.
34
+ */
35
+ export declare function canonicalizeModelId(model: string): string;
36
+ /**
37
+ * Resolves an observed model id against a pricing table through `lookup`, trying the keys of
38
+ * {@link priceKeyCandidates} in order and returning the first hit. Returns null when nothing
39
+ * matches — the model is unpriced, never a guessed price.
40
+ */
41
+ export declare function resolvePriceKey<T>(model: string, lookup: (key: string) => T | undefined): PriceKeyHit<T> | null;
42
+ //# sourceMappingURL=price-resolution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"price-resolution.d.ts","sourceRoot":"","sources":["../../src/utils/price-resolution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAsBH,2DAA2D;AAC3D,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,UAAU,GAAG,WAAW,CAAC;AAE5D,4FAA4F;AAC5F,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,UAAU,CAAC;IAClB,KAAK,EAAE,CAAC,CAAC;CACV;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIzD;AAoDD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,CAAC,GAAG,SAAS,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,IAAI,CAQ/G"}
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Model-id → pricing-table-key resolution, shared by every consumer that prices a model id:
3
+ * src/utils/pricing.ts (the analytics report's resolvePrice()) and the standalone Claude
4
+ * statusline (src/agents/plugins/claude/plugin/statusline.ts, bundled into one self-contained file
5
+ * by scripts/bundle-statusline.mjs). Keeping one copy is what stops the live statusline cost and
6
+ * the analytics report from disagreeing on the same transcript.
7
+ *
8
+ * Deliberately free of I/O and of any import beyond model-normalizer.ts (itself dependency-free),
9
+ * so the statusline bundle stays small and never drags in fs/config/keytar-bearing modules. It
10
+ * knows nothing about the shape of a price row — callers pass a key lookup over their own table.
11
+ */
12
+ import { normalizeModelName } from './model-normalizer.js';
13
+ /**
14
+ * A trailing snapshot/version suffix stripped once during lookup (never during canonicalization):
15
+ * an 8-digit date (`-20260205`), a dashed date (`-2026-02-05`), or the `-latest`/`-preview` tags.
16
+ * Applied at most once, so a key that is itself dated (`gpt-4o-2024-05-13`) is tried as an exact
17
+ * match first and never has a second suffix stripped from it.
18
+ */
19
+ const SNAPSHOT_SUFFIX_PATTERN = /-(?:\d{8}|\d{4}-\d{2}-\d{2}|latest|preview)$/;
20
+ /**
21
+ * Matches a Claude id given in version-first order — `claude-<ver>-<family>[<rest>]`, where `ver`
22
+ * is one or more dash-separated numeric segments and `family` is `opus`/`sonnet`/`haiku` — so it
23
+ * can be reordered to the family-first form (`claude-<family>-<ver>[<rest>]`) the pricing table
24
+ * keys newer Claude generations under (e.g. `claude-sonnet-4-5`, `claude-opus-4-8`; see
25
+ * pricing.json's own rows). Never applied to a key that is already family-first, since that
26
+ * doesn't match this pattern in the first place.
27
+ */
28
+ const CLAUDE_VERSION_FIRST_PATTERN = /^claude-(\d+(?:-\d+)*)-(opus|sonnet|haiku)(-.+)?$/;
29
+ /**
30
+ * The table-key form of a raw pricing-data key: lowercased, dots turned to dashes, so `GLM-4.7`
31
+ * and `glm-4-7` land on the same entry. Both sides of a lookup must be folded the same way —
32
+ * observed ids go through {@link canonicalizeModelId}, which ends in this same folding.
33
+ */
34
+ export function priceTableKey(rawKey) {
35
+ return rawKey.toLowerCase().replace(/\./g, '-');
36
+ }
37
+ /**
38
+ * Canonicalizes an observed model id into the form used as a pricing-table key. Extends
39
+ * {@link normalizeModelName} (which strips Bedrock/Kimi/vendor-path prefixes) with:
40
+ * 1. Lowercasing, dots turned to dashes, and `@` turned to `-` (so Vertex's `claude-x@20260205`
41
+ * folds to the same shape as a dated id).
42
+ * 2. Stripping a trailing `-vertex` suffix.
43
+ * Used by the pricing resolver, the statusline and cost reconciliation, so every consumer treats
44
+ * the same observed id the same way.
45
+ */
46
+ export function canonicalizeModelId(model) {
47
+ return priceTableKey(normalizeModelName(model))
48
+ .replace(/@/g, '-')
49
+ .replace(/-vertex$/, '');
50
+ }
51
+ /**
52
+ * Reorders a version-first Claude id (`claude-4-5-sonnet`) to the family-first form
53
+ * (`claude-sonnet-4-5`) the table keys such rows under, preserving any trailing suffix (a
54
+ * snapshot date, `-latest`, ...). Returns null when `id` isn't in that shape.
55
+ */
56
+ function reorderClaudeVersionFamily(id) {
57
+ const match = id.match(CLAUDE_VERSION_FIRST_PATTERN);
58
+ if (!match) {
59
+ return null;
60
+ }
61
+ const [, version, family, rest = ''] = match;
62
+ return `claude-${family}-${version}${rest}`;
63
+ }
64
+ /** `key` with one trailing snapshot suffix stripped, or null when it carries none. */
65
+ function withoutSnapshot(key) {
66
+ const stripped = key.replace(SNAPSHOT_SUFFIX_PATTERN, '');
67
+ return stripped === key ? null : stripped;
68
+ }
69
+ /**
70
+ * The ordered table keys tried for an observed id, against its {@link canonicalizeModelId} form:
71
+ * 1. Exact match — keeps distinct dated rows (e.g. `gpt-4o-2024-05-13`) authoritative.
72
+ * 2. Exact match after stripping one trailing snapshot suffix — e.g. `claude-opus-4-6-20260205`
73
+ * resolves to the `claude-opus-4-6` row.
74
+ * 3. A version-first Claude id (`claude-4-5-sonnet`) reordered to the table's family-first form
75
+ * (`claude-sonnet-4-5`), tried exact and then with a trailing snapshot suffix stripped — only
76
+ * once steps 1-2 have already failed on the as-is id. That ordering is what keeps every
77
+ * pre-existing version-first key (`claude-3-5-sonnet`, `claude-3-7-sonnet-20250219`, ...)
78
+ * resolving unchanged: those rows match as-is at step 1 and this fallback is never reached.
79
+ * There is no segment/family match and no same-tier fallback.
80
+ */
81
+ function priceKeyCandidates(model) {
82
+ const canonical = canonicalizeModelId(model);
83
+ const candidates = [{ key: canonical, match: 'exact' }];
84
+ const snapshot = withoutSnapshot(canonical);
85
+ if (snapshot) {
86
+ candidates.push({ key: snapshot, match: 'snapshot' });
87
+ }
88
+ const reordered = reorderClaudeVersionFamily(canonical);
89
+ if (reordered) {
90
+ candidates.push({ key: reordered, match: 'reordered' });
91
+ const reorderedSnapshot = withoutSnapshot(reordered);
92
+ if (reorderedSnapshot) {
93
+ candidates.push({ key: reorderedSnapshot, match: 'reordered' });
94
+ }
95
+ }
96
+ return candidates;
97
+ }
98
+ /**
99
+ * Resolves an observed model id against a pricing table through `lookup`, trying the keys of
100
+ * {@link priceKeyCandidates} in order and returning the first hit. Returns null when nothing
101
+ * matches — the model is unpriced, never a guessed price.
102
+ */
103
+ export function resolvePriceKey(model, lookup) {
104
+ for (const { key, match } of priceKeyCandidates(model)) {
105
+ const value = key ? lookup(key) : undefined;
106
+ if (value !== undefined) {
107
+ return { key, match, value };
108
+ }
109
+ }
110
+ return null;
111
+ }
112
+ //# sourceMappingURL=price-resolution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"price-resolution.js","sourceRoot":"","sources":["../../src/utils/price-resolution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,uBAAuB,GAAG,8CAA8C,CAAC;AAE/E;;;;;;;GAOG;AACH,MAAM,4BAA4B,GAAG,mDAAmD,CAAC;AAYzF;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,MAAc;IAC1C,OAAO,MAAM,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAClD,CAAC;AAED;;;;;;;;GAQG;AACH,MA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D,IAAI,SAAS,EAAE,CAAC;QACd,UAAU,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC;QACxD,MAAM,iBAAiB,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;QACrD,IAAI,iBAAiB,EAAE,CAAC;YACtB,UAAU,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,iBAAiB,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAI,KAAa,EAAE,MAAsC;IACtF,KAAK,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;QACvD,MAAM,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC5C,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;QAC/B,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -5,6 +5,8 @@
5
5
  * re-copy that file. Prices are USD per 1,000,000 tokens. The source uses
6
6
  * `cacheWrite`; we expose it as `cacheCreation` to match Claude's terminology.
7
7
  */
8
+ import { type PriceMatch } from './price-resolution.js';
9
+ export { canonicalizeModelId } from './price-resolution.js';
8
10
  /** USD per 1,000,000 tokens. */
9
11
  export interface ModelPrice {
10
12
  input: number;
@@ -12,14 +14,71 @@ export interface ModelPrice {
12
14
  cacheRead: number;
13
15
  cacheCreation: number;
14
16
  cacheWrite1h?: number;
17
+ /**
18
+ * Amazon Bedrock's premium for a regional/multi-region endpoint over this model's global one
19
+ * — present only on rows where Anthropic documents the two-endpoint-type Bedrock pricing
20
+ * structure (Sonnet 4.5+, Haiku 4.5+, Opus 4.5+ and their dated snapshots). Absent (no premium)
21
+ * on every older row, since Anthropic does not document this structure applying there. See
22
+ * isBedrockRegionalPremium()'s own doc comment (bedrock-pricing.mjs) for the source.
23
+ */
24
+ bedrockRegionalMultiplier?: number;
25
+ /**
26
+ * True when this row is not a directly published rate but an estimate (e.g. a tier-price
27
+ * carried forward for a model generation with no confirmed pricing yet). Every row's
28
+ * provenance should be cited in `pricing.json`'s `_meta.sources`/`note`; this flag is what
29
+ * callers use to surface "estimated" alongside the resolved price rather than presenting it
30
+ * as authoritative.
31
+ */
32
+ estimated?: boolean;
15
33
  }
34
+ export interface RawPrice {
35
+ input?: number;
36
+ output?: number;
37
+ cacheRead?: number;
38
+ cacheWrite?: number;
39
+ cacheWrite1h?: number;
40
+ bedrockRegionalMultiplier?: number;
41
+ estimated?: boolean;
42
+ }
43
+ /**
44
+ * Builds the rate card from a bag of raw rows (a parsed `pricing.json`, an injected fixture for
45
+ * tests, or any merge of the two): every key is lowercased and dots are turned to dashes, so
46
+ * `GLM-4.7` and `glm-4-7` land on the same table entry. When two distinct raw keys normalize to
47
+ * the same table key, they must carry identical prices — that is the only way the pricing data
48
+ * itself can declare two spellings of the same model (e.g. `gemini-3.7-flash` / `gemini-3-7-flash`)
49
+ * — otherwise the table is ambiguous and this throws rather than silently picking one.
50
+ */
51
+ export declare function buildPriceTable(rows: Record<string, RawPrice>): Record<string, ModelPrice>;
52
+ /**
53
+ * The fully built rate card: the vendored table with {@link CODEMIE_PRICES} merged over it and every
54
+ * key lowercased. Exported so consumers that cannot import this module — the standalone Claude
55
+ * statusline, which runs as a detached `node <path>` process — can be handed the same rates rather
56
+ * than a copy of the raw `pricing.json`, which carries none of the CodeMie-only rows.
57
+ */
58
+ export declare function priceTable(): Record<string, ModelPrice>;
59
+ /** How {@link resolvePrice} matched an observed model id to a table row. */
60
+ export interface PriceResolution {
61
+ price: ModelPrice;
62
+ key: string;
63
+ match: PriceMatch;
64
+ estimated: boolean;
65
+ }
66
+ /**
67
+ * Resolves pricing for a model, reporting how it was matched. Returns null when no entry
68
+ * matches (the caller marks the model `unpriced` — never a silent $0, and never a guessed
69
+ * family/tier price). The lookup order (exact, then one snapshot suffix stripped, then a
70
+ * version-first Claude id reordered to family-first) lives in {@link resolvePriceKey}, shared
71
+ * with the Claude statusline so the two can never price the same id differently.
72
+ *
73
+ * `model` is also checked, in its original unnormalized form, for a Bedrock region qualifier
74
+ * (see {@link applyBedrockRegionalPremium}) — pass the raw backend id straight through rather
75
+ * than pre-normalizing it, or the premium this exists to detect is invisible by the time it gets
76
+ * here.
77
+ */
78
+ export declare function resolvePrice(model: string): PriceResolution | null;
16
79
  /**
17
- * Look up pricing for a model. Returns null when no entry matches (the caller marks the model
18
- * `unpriced` — never a silent $0). Resolution order:
19
- * 1. Exact (normalized) match — authoritative.
20
- * 2. Longest key aligned to a segment boundary — a deliberate family fallback, logged as inexact.
21
- * 3. Latest same-tier Claude price — for a model newer than every table entry, logged as inexact.
22
- * Dots are folded to dashes first because the table keys use dashes (e.g. `gpt-4-1`, not `gpt-4.1`).
80
+ * Look up pricing for a model. Returns null when no entry matches. Thin wrapper over
81
+ * {@link resolvePrice} for callers that only need the price, not its provenance.
23
82
  */
24
83
  export declare function lookupPrice(model: string): ModelPrice | null;
25
84
  //# sourceMappingURL=pricing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pricing.d.ts","sourceRoot":"","sources":["../../src/utils/pricing.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,gCAAgC;AAChC,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AA0HD;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CA2B5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