@ponythewhite/base-context 1.0.0 → 1.0.1

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 (285) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/NOTICE +0 -5
  3. package/README.md +44 -27
  4. package/dist/NOTICE +0 -5
  5. package/dist/base-context-runtime/pyproject.toml +1 -1
  6. package/dist/base-context-runtime/src/rlm/__init__.py +7 -5
  7. package/dist/base-context-runtime/test/test_subagent_registry.py +28 -1
  8. package/dist/base-context-runtime/uv.lock +1 -1
  9. package/dist/build-info.json +1 -1
  10. package/dist/bundle/amazon-bedrock.js +21 -0
  11. package/dist/bundle/{anthropic-YY4S534V.js → anthropic-UV5GZDGU.js} +5 -5
  12. package/dist/bundle/{azure-openai-responses-JRP6MIM3.js → azure-openai-responses-WSNPXLYC.js} +6 -6
  13. package/dist/bundle/{bundled-modules-P5HARVZA.js → bundled-modules-TXUMJ2XQ.js} +71 -16
  14. package/dist/bundle/chunk-27QCJ2AZ.js +2578 -0
  15. package/dist/bundle/{chunk-MZHTNNVA.js → chunk-4GXPNXOJ.js} +8 -0
  16. package/dist/bundle/{chunk-SC5KG5R4.js → chunk-DGNX7HQ3.js} +1 -7
  17. package/dist/bundle/{chunk-A53O363M.js → chunk-GRJFXLBM.js} +0 -1
  18. package/dist/bundle/chunk-HKINIBP4.js +29 -0
  19. package/dist/bundle/{chunk-UDSW6FNG.js → chunk-KTNETTHI.js} +1 -1
  20. package/dist/bundle/{chunk-BYVP7LWV.js → chunk-S3INFPZZ.js} +1861 -4662
  21. package/dist/bundle/{chunk-73DCPU3D.js → chunk-V3L54UD6.js} +1019 -3427
  22. package/dist/bundle/{chunk-U7AUVG3B.js → chunk-VSIYFWYI.js} +24 -6
  23. package/dist/bundle/{chunk-IW77OXFS.js → chunk-W46VZFI6.js} +0 -2099
  24. package/dist/bundle/{cli-main-O4X7GFGY.js → cli-main-BYMSRPH6.js} +8 -6
  25. package/dist/bundle/cli.js +2 -2
  26. package/dist/bundle/{google-AUTVGDGZ.js → google-T32FMD4G.js} +6 -6
  27. package/dist/bundle/{google-vertex-Q75D7RKS.js → google-vertex-56KP6I3B.js} +3 -3
  28. package/dist/bundle/{main-XKOW2BV6.js → main-ODOYCEQC.js} +7 -5
  29. package/dist/bundle/{mistral-7ESB7QUD.js → mistral-WGBMYIVU.js} +5 -5
  30. package/dist/bundle/{openai-codex-responses-LV3QRPN4.js → openai-codex-responses-PIV2RQ3G.js} +6 -6
  31. package/dist/bundle/{openai-completions-OJECLPXJ.js → openai-completions-64C3JPR4.js} +11 -22
  32. package/dist/bundle/{openai-responses-FN6HZMBC.js → openai-responses-UI7RSTDV.js} +6 -6
  33. package/dist/cli/args.d.ts.map +1 -1
  34. package/dist/cli/args.js +108 -59
  35. package/dist/cli/args.js.map +1 -1
  36. package/dist/cli/daemon-ps.d.ts +4 -3
  37. package/dist/cli/daemon-ps.d.ts.map +1 -1
  38. package/dist/cli/daemon-ps.js +6 -1
  39. package/dist/cli/daemon-ps.js.map +1 -1
  40. package/dist/cli/product-doctor.d.ts +0 -1
  41. package/dist/cli/product-doctor.d.ts.map +1 -1
  42. package/dist/cli/product-doctor.js +6 -3
  43. package/dist/cli/product-doctor.js.map +1 -1
  44. package/dist/config.d.ts +0 -3
  45. package/dist/config.d.ts.map +1 -1
  46. package/dist/config.js +0 -8
  47. package/dist/config.js.map +1 -1
  48. package/dist/core/agent-session-config.d.ts +1 -2
  49. package/dist/core/agent-session-config.d.ts.map +1 -1
  50. package/dist/core/agent-session-config.js +0 -3
  51. package/dist/core/agent-session-config.js.map +1 -1
  52. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  53. package/dist/core/agent-session-runtime.js +5 -4
  54. package/dist/core/agent-session-runtime.js.map +1 -1
  55. package/dist/core/agent-session-services.d.ts +5 -3
  56. package/dist/core/agent-session-services.d.ts.map +1 -1
  57. package/dist/core/agent-session-services.js +2 -27
  58. package/dist/core/agent-session-services.js.map +1 -1
  59. package/dist/core/agent-session.d.ts +10 -6
  60. package/dist/core/agent-session.d.ts.map +1 -1
  61. package/dist/core/agent-session.js +107 -107
  62. package/dist/core/agent-session.js.map +1 -1
  63. package/dist/core/auth-storage.d.ts +8 -35
  64. package/dist/core/auth-storage.d.ts.map +1 -1
  65. package/dist/core/auth-storage.js +33 -243
  66. package/dist/core/auth-storage.js.map +1 -1
  67. package/dist/core/cron-jobs.d.ts.map +1 -1
  68. package/dist/core/cron-jobs.js +7 -1
  69. package/dist/core/cron-jobs.js.map +1 -1
  70. package/dist/core/inference-coordinator.d.ts +6 -1
  71. package/dist/core/inference-coordinator.d.ts.map +1 -1
  72. package/dist/core/inference-coordinator.js +18 -2
  73. package/dist/core/inference-coordinator.js.map +1 -1
  74. package/dist/core/kernel/bootstrap.d.ts.map +1 -1
  75. package/dist/core/kernel/bootstrap.js +2 -2
  76. package/dist/core/kernel/bootstrap.js.map +1 -1
  77. package/dist/core/kernel/repl-manager.d.ts +2 -0
  78. package/dist/core/kernel/repl-manager.d.ts.map +1 -1
  79. package/dist/core/kernel/repl-manager.js +44 -1
  80. package/dist/core/kernel/repl-manager.js.map +1 -1
  81. package/dist/core/logging.d.ts +4 -3
  82. package/dist/core/logging.d.ts.map +1 -1
  83. package/dist/core/logging.js +6 -6
  84. package/dist/core/logging.js.map +1 -1
  85. package/dist/core/mcp/mcp-manager.d.ts.map +1 -1
  86. package/dist/core/mcp/mcp-manager.js +3 -3
  87. package/dist/core/mcp/mcp-manager.js.map +1 -1
  88. package/dist/core/model-registry.d.ts +1 -16
  89. package/dist/core/model-registry.d.ts.map +1 -1
  90. package/dist/core/model-registry.js +88 -196
  91. package/dist/core/model-registry.js.map +1 -1
  92. package/dist/core/model-resolver.d.ts +2 -19
  93. package/dist/core/model-resolver.d.ts.map +1 -1
  94. package/dist/core/model-resolver.js +36 -266
  95. package/dist/core/model-resolver.js.map +1 -1
  96. package/dist/core/provider-contracts.d.ts +5 -6
  97. package/dist/core/provider-contracts.d.ts.map +1 -1
  98. package/dist/core/provider-contracts.js +25 -36
  99. package/dist/core/provider-contracts.js.map +1 -1
  100. package/dist/core/provider-display-names.d.ts.map +1 -1
  101. package/dist/core/provider-display-names.js +0 -2
  102. package/dist/core/provider-display-names.js.map +1 -1
  103. package/dist/core/rlm-max-subagents.d.ts +32 -0
  104. package/dist/core/rlm-max-subagents.d.ts.map +1 -0
  105. package/dist/core/rlm-max-subagents.js +50 -0
  106. package/dist/core/rlm-max-subagents.js.map +1 -0
  107. package/dist/core/rlm-runtime.d.ts +3 -3
  108. package/dist/core/rlm-runtime.d.ts.map +1 -1
  109. package/dist/core/rlm-runtime.js.map +1 -1
  110. package/dist/core/sdk.d.ts +4 -3
  111. package/dist/core/sdk.d.ts.map +1 -1
  112. package/dist/core/sdk.js +27 -14
  113. package/dist/core/sdk.js.map +1 -1
  114. package/dist/core/settings-manager.d.ts +3 -16
  115. package/dist/core/settings-manager.d.ts.map +1 -1
  116. package/dist/core/settings-manager.js +12 -44
  117. package/dist/core/settings-manager.js.map +1 -1
  118. package/dist/core/slash-commands.d.ts.map +1 -1
  119. package/dist/core/slash-commands.js +6 -6
  120. package/dist/core/slash-commands.js.map +1 -1
  121. package/dist/index.d.ts +1 -1
  122. package/dist/index.d.ts.map +1 -1
  123. package/dist/index.js.map +1 -1
  124. package/dist/installer.mjs +2 -3
  125. package/dist/main.d.ts.map +1 -1
  126. package/dist/main.js +39 -34
  127. package/dist/main.js.map +1 -1
  128. package/dist/modes/acp/acp-mode.d.ts.map +1 -1
  129. package/dist/modes/acp/acp-mode.js +1 -1
  130. package/dist/modes/acp/acp-mode.js.map +1 -1
  131. package/dist/modes/agent-connection/daemon-agent-connection.d.ts +6 -2
  132. package/dist/modes/agent-connection/daemon-agent-connection.d.ts.map +1 -1
  133. package/dist/modes/agent-connection/daemon-agent-connection.js +13 -2
  134. package/dist/modes/agent-connection/daemon-agent-connection.js.map +1 -1
  135. package/dist/modes/agent-connection/in-process-agent-connection.d.ts +2 -0
  136. package/dist/modes/agent-connection/in-process-agent-connection.d.ts.map +1 -1
  137. package/dist/modes/agent-connection/in-process-agent-connection.js +6 -0
  138. package/dist/modes/agent-connection/in-process-agent-connection.js.map +1 -1
  139. package/dist/modes/agent-connection/types.d.ts +3 -0
  140. package/dist/modes/agent-connection/types.d.ts.map +1 -1
  141. package/dist/modes/agent-connection/types.js.map +1 -1
  142. package/dist/modes/agents-view/agents-view-mode.d.ts.map +1 -1
  143. package/dist/modes/agents-view/agents-view-mode.js +2 -19
  144. package/dist/modes/agents-view/agents-view-mode.js.map +1 -1
  145. package/dist/modes/daemon/daemon-mode.d.ts +5 -0
  146. package/dist/modes/daemon/daemon-mode.d.ts.map +1 -1
  147. package/dist/modes/daemon/daemon-mode.js +107 -12
  148. package/dist/modes/daemon/daemon-mode.js.map +1 -1
  149. package/dist/modes/daemon/daemon-protocol.d.ts +194 -165
  150. package/dist/modes/daemon/daemon-protocol.d.ts.map +1 -1
  151. package/dist/modes/daemon/daemon-protocol.js +16 -11
  152. package/dist/modes/daemon/daemon-protocol.js.map +1 -1
  153. package/dist/modes/daemon/daemon-rlm-capacity-coordinator.d.ts +19 -0
  154. package/dist/modes/daemon/daemon-rlm-capacity-coordinator.d.ts.map +1 -0
  155. package/dist/modes/daemon/daemon-rlm-capacity-coordinator.js +74 -0
  156. package/dist/modes/daemon/daemon-rlm-capacity-coordinator.js.map +1 -0
  157. package/dist/modes/daemon/daemon-rlm-capacity.d.ts +19 -0
  158. package/dist/modes/daemon/daemon-rlm-capacity.d.ts.map +1 -0
  159. package/dist/modes/daemon/daemon-rlm-capacity.js +85 -0
  160. package/dist/modes/daemon/daemon-rlm-capacity.js.map +1 -0
  161. package/dist/modes/daemon/daemon-session-summarizer.d.ts +2 -3
  162. package/dist/modes/daemon/daemon-session-summarizer.d.ts.map +1 -1
  163. package/dist/modes/daemon/daemon-session-summarizer.js +32 -23
  164. package/dist/modes/daemon/daemon-session-summarizer.js.map +1 -1
  165. package/dist/modes/daemon/daemon-state-root.d.ts +15 -0
  166. package/dist/modes/daemon/daemon-state-root.d.ts.map +1 -0
  167. package/dist/modes/daemon/daemon-state-root.js +40 -0
  168. package/dist/modes/daemon/daemon-state-root.js.map +1 -0
  169. package/dist/modes/daemon/daemon-supervisor-ownership.d.ts +2 -0
  170. package/dist/modes/daemon/daemon-supervisor-ownership.d.ts.map +1 -1
  171. package/dist/modes/daemon/daemon-supervisor-ownership.js +27 -0
  172. package/dist/modes/daemon/daemon-supervisor-ownership.js.map +1 -1
  173. package/dist/modes/daemon/daemon-supervisor.d.ts +10 -1
  174. package/dist/modes/daemon/daemon-supervisor.d.ts.map +1 -1
  175. package/dist/modes/daemon/daemon-supervisor.js +213 -20
  176. package/dist/modes/daemon/daemon-supervisor.js.map +1 -1
  177. package/dist/modes/daemon/daemon-worker-protocol.d.ts +28 -1
  178. package/dist/modes/daemon/daemon-worker-protocol.d.ts.map +1 -1
  179. package/dist/modes/daemon/daemon-worker-protocol.js +16 -2
  180. package/dist/modes/daemon/daemon-worker-protocol.js.map +1 -1
  181. package/dist/modes/daemon/saved-session-catalog.d.ts.map +1 -1
  182. package/dist/modes/daemon/saved-session-catalog.js +2 -0
  183. package/dist/modes/daemon/saved-session-catalog.js.map +1 -1
  184. package/dist/modes/interactive/auth-flows.d.ts +0 -6
  185. package/dist/modes/interactive/auth-flows.d.ts.map +1 -1
  186. package/dist/modes/interactive/auth-flows.js +6 -126
  187. package/dist/modes/interactive/auth-flows.js.map +1 -1
  188. package/dist/modes/interactive/components/configuration-menu.d.ts +3 -0
  189. package/dist/modes/interactive/components/configuration-menu.d.ts.map +1 -1
  190. package/dist/modes/interactive/components/configuration-menu.js +13 -2
  191. package/dist/modes/interactive/components/configuration-menu.js.map +1 -1
  192. package/dist/modes/interactive/components/footer.d.ts +1 -1
  193. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  194. package/dist/modes/interactive/components/footer.js +2 -2
  195. package/dist/modes/interactive/components/footer.js.map +1 -1
  196. package/dist/modes/interactive/components/index.d.ts +0 -1
  197. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  198. package/dist/modes/interactive/components/index.js +0 -1
  199. package/dist/modes/interactive/components/index.js.map +1 -1
  200. package/dist/modes/interactive/components/login-dialog.d.ts +0 -1
  201. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  202. package/dist/modes/interactive/components/login-dialog.js +3 -40
  203. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  204. package/dist/modes/interactive/components/model-selector.d.ts +2 -0
  205. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  206. package/dist/modes/interactive/components/model-selector.js +13 -2
  207. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  208. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  209. package/dist/modes/interactive/components/oauth-selector.js +2 -11
  210. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  211. package/dist/modes/interactive/feature-hints.d.ts.map +1 -1
  212. package/dist/modes/interactive/feature-hints.js +0 -4
  213. package/dist/modes/interactive/feature-hints.js.map +1 -1
  214. package/dist/modes/interactive/interactive-mode.d.ts +3 -12
  215. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  216. package/dist/modes/interactive/interactive-mode.js +81 -507
  217. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  218. package/dist/modes/interactive/onboarding.d.ts +0 -3
  219. package/dist/modes/interactive/onboarding.d.ts.map +1 -1
  220. package/dist/modes/interactive/onboarding.js +0 -17
  221. package/dist/modes/interactive/onboarding.js.map +1 -1
  222. package/dist/modes/rpc/rpc-client.d.ts +2 -1
  223. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  224. package/dist/modes/rpc/rpc-client.js +24 -11
  225. package/dist/modes/rpc/rpc-client.js.map +1 -1
  226. package/dist/node/amazon-bedrock.d.ts +2 -0
  227. package/dist/node/amazon-bedrock.d.ts.map +1 -0
  228. package/dist/node/amazon-bedrock.js +6 -0
  229. package/dist/node/amazon-bedrock.js.map +1 -0
  230. package/dist/product-identity.d.ts +0 -1
  231. package/dist/product-identity.d.ts.map +1 -1
  232. package/dist/product-identity.js +0 -1
  233. package/dist/product-identity.js.map +1 -1
  234. package/docs/development.md +1 -1
  235. package/docs/fork-philosophy.md +4 -8
  236. package/docs/installation.md +83 -62
  237. package/docs/providers.md +23 -25
  238. package/docs/quickstart.md +19 -10
  239. package/docs/rlm-runtime.md +13 -5
  240. package/docs/rpc.md +4 -4
  241. package/docs/sdk.md +20 -11
  242. package/docs/sessions.md +0 -1
  243. package/docs/settings.md +9 -42
  244. package/docs/skills.md +0 -1
  245. package/docs/upstream-0.9.5.md +171 -0
  246. package/docs/usage.md +14 -10
  247. package/package.json +4 -4
  248. package/dist/core/agent-traces.d.ts +0 -149
  249. package/dist/core/agent-traces.d.ts.map +0 -1
  250. package/dist/core/agent-traces.js +0 -904
  251. package/dist/core/agent-traces.js.map +0 -1
  252. package/dist/core/prime-inference-auth.d.ts +0 -70
  253. package/dist/core/prime-inference-auth.d.ts.map +0 -1
  254. package/dist/core/prime-inference-auth.js +0 -352
  255. package/dist/core/prime-inference-auth.js.map +0 -1
  256. package/dist/core/prime-inference-model-selection.d.ts +0 -16
  257. package/dist/core/prime-inference-model-selection.d.ts.map +0 -1
  258. package/dist/core/prime-inference-model-selection.js +0 -16
  259. package/dist/core/prime-inference-model-selection.js.map +0 -1
  260. package/dist/core/prime-inference-models.d.ts +0 -6
  261. package/dist/core/prime-inference-models.d.ts.map +0 -1
  262. package/dist/core/prime-inference-models.js +0 -62
  263. package/dist/core/prime-inference-models.js.map +0 -1
  264. package/dist/core/telemetry.d.ts +0 -95
  265. package/dist/core/telemetry.d.ts.map +0 -1
  266. package/dist/core/telemetry.js +0 -637
  267. package/dist/core/telemetry.js.map +0 -1
  268. package/dist/modes/interactive/components/prime-onboarding-splash.d.ts +0 -39
  269. package/dist/modes/interactive/components/prime-onboarding-splash.d.ts.map +0 -1
  270. package/dist/modes/interactive/components/prime-onboarding-splash.js +0 -286
  271. package/dist/modes/interactive/components/prime-onboarding-splash.js.map +0 -1
  272. package/dist/modes/interactive/components/prime-team-selector.d.ts +0 -30
  273. package/dist/modes/interactive/components/prime-team-selector.d.ts.map +0 -1
  274. package/dist/modes/interactive/components/prime-team-selector.js +0 -166
  275. package/dist/modes/interactive/components/prime-team-selector.js.map +0 -1
  276. package/dist/skills/prime-intellect/SKILL.md +0 -87
  277. package/dist/skills/prime-intellect/references/compute.md +0 -45
  278. package/dist/skills/prime-intellect/references/environments.md +0 -73
  279. package/dist/skills/prime-intellect/references/inference.md +0 -47
  280. package/dist/skills/prime-intellect/references/sandboxes.md +0 -75
  281. package/skills/prime-intellect/SKILL.md +0 -87
  282. package/skills/prime-intellect/references/compute.md +0 -45
  283. package/skills/prime-intellect/references/environments.md +0 -73
  284. package/skills/prime-intellect/references/inference.md +0 -47
  285. package/skills/prime-intellect/references/sandboxes.md +0 -75
@@ -6,14 +6,13 @@
6
6
  * try to refresh tokens simultaneously.
7
7
  */
8
8
  import { createHash } from "node:crypto";
9
- import { findEnvKeys, getEnvApiKey, getPrimeTeamId, } from "@ponythewhite/base-context-ai";
9
+ import { findEnvKeys, getEnvApiKey, } from "@ponythewhite/base-context-ai";
10
10
  import { getOAuthApiKey, getOAuthProvider, getOAuthProviders } from "@ponythewhite/base-context-ai/oauth";
11
11
  import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
12
12
  import { dirname, join } from "path";
13
13
  import lockfile from "proper-lockfile";
14
14
  import { getAgentDir } from "../config.js";
15
15
  import { assertProductStatePath } from "../runtime-paths.js";
16
- import { clearPrimeCliCredentials, getPrimeCliConfigPath, loadPrimeCliConfig, PRIME_INFERENCE_PROVIDER_ID, savePrimeCliApiKey, savePrimeCliTeamSelection, } from "./prime-inference-auth.js";
17
16
  import { getProviderAuthContract, isProviderApiKeyAllowed } from "./provider-contracts.js";
18
17
  import { resolveConfigValue, resolveConfigValueUncached } from "./resolve-config-value.js";
19
18
  export class FileAuthStorageBackend {
@@ -160,7 +159,6 @@ export class InMemoryAuthStorageBackend {
160
159
  */
161
160
  export class AuthStorage {
162
161
  storage;
163
- options;
164
162
  existingOpenAICodexSubscription;
165
163
  data = {};
166
164
  runtimeOverrides = new Map();
@@ -168,23 +166,21 @@ export class AuthStorage {
168
166
  fallbackResolver;
169
167
  loadError = null;
170
168
  errors = [];
171
- constructor(storage, options = {}, existingOpenAICodexSubscription = false) {
169
+ constructor(storage, existingOpenAICodexSubscription = false) {
172
170
  this.storage = storage;
173
- this.options = options;
174
171
  this.existingOpenAICodexSubscription = existingOpenAICodexSubscription;
175
172
  this.reload();
176
173
  }
177
- static create(authPath, options) {
178
- const authOptions = options ?? { usePrimeCliConfig: authPath === undefined };
179
- return new AuthStorage(new FileAuthStorageBackend(authPath ?? join(getAgentDir(), "auth.json")), authOptions);
174
+ static create(authPath) {
175
+ return new AuthStorage(new FileAuthStorageBackend(authPath ?? join(getAgentDir(), "auth.json")));
180
176
  }
181
177
  /** Reuse an existing host login only through an explicitly read-only backend.
182
- * This does not authorize this distribution's OAuth login or refresh client.
178
+ * This SDK mode never logs in, writes credentials, or refreshes tokens.
183
179
  */
184
180
  static fromStorage(storage, options) {
185
181
  const existing = options?.existingOpenAICodexSubscription === true;
186
182
  if (!existing)
187
- return new AuthStorage(storage, options);
183
+ return new AuthStorage(storage);
188
184
  if (storage instanceof FileAuthStorageBackend)
189
185
  throw new Error("Existing OpenAI subscription requires a read-only auth backend");
190
186
  const readOnly = {
@@ -199,7 +195,7 @@ export class AuthStorage {
199
195
  throw new Error("Existing OpenAI subscription refresh is disabled");
200
196
  },
201
197
  };
202
- return new AuthStorage(readOnly, { ...options, usePrimeCliConfig: false }, true);
198
+ return new AuthStorage(readOnly, true);
203
199
  }
204
200
  isExistingOpenAICodexSubscription(provider) {
205
201
  return this.existingOpenAICodexSubscription && provider === "openai-codex";
@@ -208,10 +204,10 @@ export class AuthStorage {
208
204
  if (this.existingOpenAICodexSubscription)
209
205
  throw new Error("Existing OpenAI subscription storage is read-only");
210
206
  }
211
- static inMemory(data = {}, options) {
207
+ static inMemory(data = {}) {
212
208
  const storage = new InMemoryAuthStorageBackend();
213
209
  storage.withLock(() => ({ result: undefined, next: JSON.stringify(data, null, 2) }));
214
- return AuthStorage.fromStorage(storage, options);
210
+ return AuthStorage.fromStorage(storage);
215
211
  }
216
212
  /**
217
213
  * Set a runtime API key override (not persisted to disk).
@@ -282,7 +278,7 @@ export class AuthStorage {
282
278
  }
283
279
  if (this.isExistingOpenAICodexSubscription(providerId))
284
280
  return `oauth:${credential.access}\0${credential.expires}`;
285
- if (getProviderAuthContract(providerId).oauth !== "validated") {
281
+ if (getProviderAuthContract(providerId).oauth !== "supported") {
286
282
  return undefined;
287
283
  }
288
284
  const provider = getOAuthProvider(providerId);
@@ -304,26 +300,11 @@ export class AuthStorage {
304
300
  }),
305
301
  };
306
302
  }
307
- getPrimeCliAuthCandidate(provider) {
308
- const apiKey = this.getPrimeCliApiKey(provider);
309
- if (!apiKey) {
310
- return undefined;
311
- }
312
- return {
313
- label: "Base Context provider config",
314
- ...this.createAuthSourceCandidate({
315
- configured: false,
316
- source: "prime_cli",
317
- identityMaterial: provider,
318
- valueMaterial: apiKey,
319
- }),
320
- };
321
- }
322
303
  getStoredAuthCandidate(provider, options) {
323
304
  const credential = this.data[provider];
324
305
  if (!credential ||
325
306
  (credential.type === "oauth" &&
326
- getProviderAuthContract(provider).oauth !== "validated" &&
307
+ getProviderAuthContract(provider).oauth !== "supported" &&
327
308
  !this.isExistingOpenAICodexSubscription(provider))) {
328
309
  return undefined;
329
310
  }
@@ -352,12 +333,11 @@ export class AuthStorage {
352
333
  });
353
334
  }
354
335
  getEnvironmentApiKey(provider) {
355
- // The generic resolver prefers ANTHROPIC_OAUTH_TOKEN, an unavailable subscription route.
356
- const apiKey = provider === "anthropic" ? process.env.ANTHROPIC_API_KEY : getEnvApiKey(provider);
336
+ const apiKey = getEnvApiKey(provider);
357
337
  return apiKey && isProviderApiKeyAllowed(provider, apiKey) ? apiKey : undefined;
358
338
  }
359
339
  getEnvironmentAuthCandidate(provider) {
360
- const envKeys = findEnvKeys(provider)?.filter((key) => key !== "ANTHROPIC_OAUTH_TOKEN");
340
+ const envKeys = findEnvKeys(provider);
361
341
  const envKey = envKeys?.[0];
362
342
  const apiKey = this.getEnvironmentApiKey(provider);
363
343
  if (!apiKey) {
@@ -416,20 +396,12 @@ export class AuthStorage {
416
396
  }
417
397
  getAuthSourceCandidates(provider, options) {
418
398
  const fallbackCandidate = options?.includeFallback === false ? undefined : this.getFallbackAuthCandidate(provider);
419
- const candidates = provider === PRIME_INFERENCE_PROVIDER_ID
420
- ? [
421
- this.getRuntimeAuthCandidate(provider),
422
- this.getEnvironmentAuthCandidate(provider),
423
- this.getPrimeCliAuthCandidate(provider),
424
- this.getStoredAuthCandidate(provider),
425
- fallbackCandidate,
426
- ]
427
- : [
428
- this.getRuntimeAuthCandidate(provider),
429
- this.getStoredAuthCandidate(provider),
430
- this.getEnvironmentAuthCandidate(provider),
431
- fallbackCandidate,
432
- ];
399
+ const candidates = [
400
+ this.getRuntimeAuthCandidate(provider),
401
+ this.getStoredAuthCandidate(provider),
402
+ this.getEnvironmentAuthCandidate(provider),
403
+ fallbackCandidate,
404
+ ];
433
405
  return candidates.filter((candidate) => candidate !== undefined);
434
406
  }
435
407
  isAuthSourceStale(provider, candidate) {
@@ -655,7 +627,7 @@ export class AuthStorage {
655
627
  async login(providerId, callbacks) {
656
628
  this.assertWritableStorage();
657
629
  const contract = getProviderAuthContract(providerId);
658
- if (contract.oauth !== "validated") {
630
+ if (contract.oauth !== "supported") {
659
631
  throw new Error(contract.guidance);
660
632
  }
661
633
  const provider = getOAuthProvider(providerId);
@@ -669,16 +641,6 @@ export class AuthStorage {
669
641
  * Logout from a provider.
670
642
  */
671
643
  logout(provider) {
672
- if (provider === PRIME_INFERENCE_PROVIDER_ID && this.isPrimeCliConfigEnabled()) {
673
- try {
674
- clearPrimeCliCredentials(this.getEnabledPrimeCliConfigPath());
675
- this.clearStaleAuthSource(provider, "prime_cli");
676
- }
677
- catch (error) {
678
- this.recordError(error);
679
- throw error;
680
- }
681
- }
682
644
  this.remove(provider);
683
645
  }
684
646
  /**
@@ -686,7 +648,7 @@ export class AuthStorage {
686
648
  * Multiple pi instances may try to refresh simultaneously when tokens expire.
687
649
  */
688
650
  async refreshOAuthTokenWithLock(providerId) {
689
- if (getProviderAuthContract(providerId).oauth !== "validated") {
651
+ if (getProviderAuthContract(providerId).oauth !== "supported") {
690
652
  return null;
691
653
  }
692
654
  const provider = getOAuthProvider(providerId);
@@ -698,7 +660,7 @@ export class AuthStorage {
698
660
  this.data = currentData;
699
661
  this.loadError = null;
700
662
  const cred = currentData[providerId];
701
- if (cred?.type !== "oauth" || getProviderAuthContract(providerId).oauth !== "validated") {
663
+ if (cred?.type !== "oauth" || getProviderAuthContract(providerId).oauth !== "supported") {
702
664
  return { result: null };
703
665
  }
704
666
  if (Date.now() < cred.expires) {
@@ -728,8 +690,8 @@ export class AuthStorage {
728
690
  * Get API key for a provider.
729
691
  * Priority:
730
692
  * 1. Runtime override (CLI --api-key)
731
- * 2. Prime Inference: environment variable, Base Context provider config, auth.json
732
- * 3. Other providers: auth.json, environment variable
693
+ * 2. auth.json
694
+ * 3. Environment variable
733
695
  * 4. Fallback resolver (models.json custom providers)
734
696
  */
735
697
  async getApiKeyWithSourceToken(providerId, options) {
@@ -762,27 +724,6 @@ export class AuthStorage {
762
724
  sourceToken: this.getAuthSourceTokenForCandidate(providerId, runtimeCandidate),
763
725
  };
764
726
  }
765
- const envCandidate = this.getEnvironmentAuthCandidate(providerId);
766
- const envKey = this.getEnvironmentApiKey(providerId);
767
- if (providerId === PRIME_INFERENCE_PROVIDER_ID &&
768
- envKey &&
769
- envCandidate &&
770
- !this.isAuthSourceStale(providerId, envCandidate)) {
771
- return {
772
- apiKey: envKey,
773
- sourceToken: this.getAuthSourceTokenForCandidate(providerId, envCandidate),
774
- };
775
- }
776
- if (providerId === PRIME_INFERENCE_PROVIDER_ID) {
777
- const primeCliCandidate = this.getPrimeCliAuthCandidate(providerId);
778
- const primeCliKey = this.getPrimeCliApiKey(providerId);
779
- if (primeCliKey && primeCliCandidate && !this.isAuthSourceStale(providerId, primeCliCandidate)) {
780
- return {
781
- apiKey: primeCliKey,
782
- sourceToken: this.getAuthSourceTokenForCandidate(providerId, primeCliCandidate),
783
- };
784
- }
785
- }
786
727
  const cred = this.data[providerId];
787
728
  if (cred?.type === "api_key") {
788
729
  const storedCandidate = this.getStoredAuthCandidate(providerId);
@@ -802,7 +743,7 @@ export class AuthStorage {
802
743
  }
803
744
  }
804
745
  }
805
- if (cred?.type === "oauth" && getProviderAuthContract(providerId).oauth === "validated") {
746
+ if (cred?.type === "oauth" && getProviderAuthContract(providerId).oauth === "supported") {
806
747
  const storedCandidate = this.getStoredAuthCandidate(providerId);
807
748
  if (storedCandidate && !this.isAuthSourceStale(providerId, storedCandidate)) {
808
749
  const provider = getOAuthProvider(providerId);
@@ -830,7 +771,7 @@ export class AuthStorage {
830
771
  this.reload();
831
772
  const updatedCred = this.data[providerId];
832
773
  if (updatedCred?.type === "oauth" &&
833
- getProviderAuthContract(providerId).oauth === "validated" &&
774
+ getProviderAuthContract(providerId).oauth === "supported" &&
834
775
  Date.now() < updatedCred.expires) {
835
776
  const updatedCandidate = this.getStoredAuthCandidate(providerId);
836
777
  return {
@@ -852,11 +793,9 @@ export class AuthStorage {
852
793
  }
853
794
  }
854
795
  }
855
- // Stored auth wins over environment variables for non-Prime-Inference providers.
856
- if (providerId !== PRIME_INFERENCE_PROVIDER_ID &&
857
- envKey &&
858
- envCandidate &&
859
- !this.isAuthSourceStale(providerId, envCandidate)) {
796
+ const envCandidate = this.getEnvironmentAuthCandidate(providerId);
797
+ const envKey = this.getEnvironmentApiKey(providerId);
798
+ if (envKey && envCandidate && !this.isAuthSourceStale(providerId, envCandidate)) {
860
799
  return {
861
800
  apiKey: envKey,
862
801
  sourceToken: this.getAuthSourceTokenForCandidate(providerId, envCandidate),
@@ -881,161 +820,12 @@ export class AuthStorage {
881
820
  return result.apiKey;
882
821
  }
883
822
  /**
884
- * Get registered OAuth providers validated for this distribution.
823
+ * Get supported registered OAuth providers. Read-only SDK storage cannot log in.
885
824
  */
886
825
  getOAuthProviders() {
887
- return getOAuthProviders().filter((provider) => getProviderAuthContract(provider.id).oauth === "validated");
888
- }
889
- setPrimeInferenceTeamSelection(team) {
890
- if (this.isPrimeCliConfigEnabled()) {
891
- try {
892
- savePrimeCliTeamSelection(team, this.getEnabledPrimeCliConfigPath());
893
- }
894
- catch (error) {
895
- this.recordError(error);
896
- throw error;
897
- }
898
- return;
899
- }
900
- const credential = this.data[PRIME_INFERENCE_PROVIDER_ID];
901
- if (credential?.type !== "api_key") {
902
- return;
903
- }
904
- this.set(PRIME_INFERENCE_PROVIDER_ID, {
905
- ...credential,
906
- primeTeam: team ? this.toPrimeTeamCredential(team) : null,
907
- });
908
- }
909
- setPrimeInferenceApiKey(apiKey) {
910
- if (this.isPrimeCliConfigEnabled()) {
911
- try {
912
- const configPath = this.getEnabledPrimeCliConfigPath();
913
- const config = loadPrimeCliConfig(configPath);
914
- const existingCredential = this.data[PRIME_INFERENCE_PROVIDER_ID];
915
- const legacyPrimeTeam = existingCredential?.type === "api_key" ? existingCredential.primeTeam : undefined;
916
- if (config.apiKey !== apiKey) {
917
- savePrimeCliApiKey(apiKey, configPath);
918
- }
919
- else if (!config.teamIdFromEnv && (legacyPrimeTeam === null || (!config.teamId && legacyPrimeTeam))) {
920
- savePrimeCliTeamSelection(legacyPrimeTeam, configPath);
921
- }
922
- this.clearStaleAuthSource(PRIME_INFERENCE_PROVIDER_ID, "prime_cli");
923
- }
924
- catch (error) {
925
- this.recordError(error);
926
- throw error;
927
- }
928
- if (this.data[PRIME_INFERENCE_PROVIDER_ID]) {
929
- this.remove(PRIME_INFERENCE_PROVIDER_ID);
930
- }
931
- return;
932
- }
933
- const existingCredential = this.data[PRIME_INFERENCE_PROVIDER_ID];
934
- const existingPrimeTeam = existingCredential?.type === "api_key" ? existingCredential.primeTeam : undefined;
935
- this.set(PRIME_INFERENCE_PROVIDER_ID, {
936
- type: "api_key",
937
- key: apiKey,
938
- ...(existingPrimeTeam !== undefined ? { primeTeam: existingPrimeTeam } : {}),
939
- });
940
- }
941
- getPrimeInferenceTeamSelection() {
942
- if (getPrimeTeamId()) {
943
- return undefined;
944
- }
945
- let config;
946
- if (this.isPrimeCliConfigEnabled()) {
947
- config = this.getPrimeCliConfig(PRIME_INFERENCE_PROVIDER_ID);
948
- if (config?.teamIdFromEnv) {
949
- return undefined;
950
- }
951
- }
952
- const credential = this.data[PRIME_INFERENCE_PROVIDER_ID];
953
- const authSource = this.getAuthStatus(PRIME_INFERENCE_PROVIDER_ID).source;
954
- if (authSource === "runtime" || authSource === "environment") {
955
- return undefined;
956
- }
957
- if (authSource === "prime_cli") {
958
- if (credential?.type === "api_key" && credential.primeTeam === null) {
959
- return null;
960
- }
961
- if (config?.teamId) {
962
- return this.toPrimeTeamCredential({
963
- teamId: config.teamId,
964
- name: config.teamName ?? "Prime Inference team",
965
- ...(config.teamRole ? { role: config.teamRole } : {}),
966
- });
967
- }
968
- if (credential?.type === "api_key" && credential.primeTeam) {
969
- return credential.primeTeam;
970
- }
971
- return null;
972
- }
973
- if (credential?.type === "api_key" && credential.primeTeam !== undefined) {
974
- return credential.primeTeam;
975
- }
976
- if (!config?.apiKey && config?.teamId) {
977
- return this.toPrimeTeamCredential({
978
- teamId: config.teamId,
979
- name: config.teamName ?? "Prime Inference team",
980
- ...(config.teamRole ? { role: config.teamRole } : {}),
981
- });
982
- }
983
- return undefined;
984
- }
985
- getProviderHeaders(providerId) {
986
- if (providerId !== PRIME_INFERENCE_PROVIDER_ID) {
987
- return undefined;
988
- }
989
- const environmentTeamId = getPrimeTeamId();
990
- if (environmentTeamId) {
991
- return { "X-Prime-Team-ID": environmentTeamId };
992
- }
993
- const teamId = this.getPrimeInferenceTeamSelection()?.teamId;
994
- return teamId ? { "X-Prime-Team-ID": teamId } : undefined;
995
- }
996
- getPrimeCliConfigPath() {
997
- if (!this.isPrimeCliConfigEnabled()) {
998
- return undefined;
999
- }
1000
- return getPrimeCliConfigPath(this.options.primeCliConfigPath);
1001
- }
1002
- toPrimeTeamCredential(team) {
1003
- const credential = {
1004
- teamId: team.teamId,
1005
- name: team.name,
1006
- };
1007
- if (team.slug) {
1008
- credential.slug = team.slug;
1009
- }
1010
- if (team.role) {
1011
- credential.role = team.role;
1012
- }
1013
- if (team.createdAt) {
1014
- credential.createdAt = team.createdAt;
1015
- }
1016
- return credential;
1017
- }
1018
- getPrimeCliConfig(providerId) {
1019
- if (providerId !== PRIME_INFERENCE_PROVIDER_ID) {
1020
- return undefined;
1021
- }
1022
- if (!this.isPrimeCliConfigEnabled()) {
1023
- return undefined;
1024
- }
1025
- return loadPrimeCliConfig(this.options.primeCliConfigPath);
1026
- }
1027
- getPrimeCliApiKey(providerId) {
1028
- return this.getPrimeCliConfig(providerId)?.apiKey;
1029
- }
1030
- getEnabledPrimeCliConfigPath() {
1031
- const configPath = this.getPrimeCliConfigPath();
1032
- if (!configPath) {
1033
- throw new Error("Base Context Prime Inference config is not enabled");
1034
- }
1035
- return configPath;
1036
- }
1037
- isPrimeCliConfigEnabled() {
1038
- return Boolean(this.options.usePrimeCliConfig || this.options.primeCliConfigPath);
826
+ if (this.existingOpenAICodexSubscription)
827
+ return [];
828
+ return getOAuthProviders().filter((provider) => getProviderAuthContract(provider.id).oauth === "supported");
1039
829
  }
1040
830
  }
1041
831
  //# sourceMappingURL=auth-storage.js.map