@ponythewhite/base-context 1.0.0 → 1.0.2
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/CHANGELOG.md +37 -0
- package/NOTICE +0 -5
- package/README.md +44 -27
- package/dist/NOTICE +0 -5
- package/dist/base-context-runtime/pyproject.toml +1 -1
- package/dist/base-context-runtime/src/rlm/__init__.py +7 -5
- package/dist/base-context-runtime/test/test_subagent_registry.py +28 -1
- package/dist/base-context-runtime/uv.lock +1 -1
- package/dist/build-info.json +1 -1
- package/dist/bundle/amazon-bedrock.js +21 -0
- package/dist/bundle/{anthropic-YY4S534V.js → anthropic-UV5GZDGU.js} +5 -5
- package/dist/bundle/{azure-openai-responses-JRP6MIM3.js → azure-openai-responses-WSNPXLYC.js} +6 -6
- package/dist/bundle/{bundled-modules-P5HARVZA.js → bundled-modules-PWOGKUQQ.js} +71 -16
- package/dist/bundle/chunk-27QCJ2AZ.js +2578 -0
- package/dist/bundle/{chunk-BYVP7LWV.js → chunk-44PEHPOG.js} +1916 -4689
- package/dist/bundle/{chunk-MZHTNNVA.js → chunk-4GXPNXOJ.js} +8 -0
- package/dist/bundle/{chunk-SC5KG5R4.js → chunk-DGNX7HQ3.js} +1 -7
- package/dist/bundle/{chunk-A53O363M.js → chunk-GRJFXLBM.js} +0 -1
- package/dist/bundle/chunk-HKINIBP4.js +29 -0
- package/dist/bundle/{chunk-73DCPU3D.js → chunk-IADCPVEI.js} +1019 -3427
- package/dist/bundle/{chunk-UDSW6FNG.js → chunk-KTNETTHI.js} +1 -1
- package/dist/bundle/{chunk-U7AUVG3B.js → chunk-VSIYFWYI.js} +24 -6
- package/dist/bundle/{chunk-IW77OXFS.js → chunk-W46VZFI6.js} +0 -2099
- package/dist/bundle/{cli-main-O4X7GFGY.js → cli-main-4DS7Y3PI.js} +8 -6
- package/dist/bundle/cli.js +2 -2
- package/dist/bundle/{google-AUTVGDGZ.js → google-T32FMD4G.js} +6 -6
- package/dist/bundle/{google-vertex-Q75D7RKS.js → google-vertex-56KP6I3B.js} +3 -3
- package/dist/bundle/{main-XKOW2BV6.js → main-SV7JLVEB.js} +7 -5
- package/dist/bundle/{mistral-7ESB7QUD.js → mistral-WGBMYIVU.js} +5 -5
- package/dist/bundle/{openai-codex-responses-LV3QRPN4.js → openai-codex-responses-PIV2RQ3G.js} +6 -6
- package/dist/bundle/{openai-completions-OJECLPXJ.js → openai-completions-64C3JPR4.js} +11 -22
- package/dist/bundle/{openai-responses-FN6HZMBC.js → openai-responses-UI7RSTDV.js} +6 -6
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +108 -59
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/daemon-ps.d.ts +4 -3
- package/dist/cli/daemon-ps.d.ts.map +1 -1
- package/dist/cli/daemon-ps.js +6 -1
- package/dist/cli/daemon-ps.js.map +1 -1
- package/dist/cli/product-doctor.d.ts +0 -1
- package/dist/cli/product-doctor.d.ts.map +1 -1
- package/dist/cli/product-doctor.js +6 -3
- package/dist/cli/product-doctor.js.map +1 -1
- package/dist/config.d.ts +0 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +0 -8
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-config.d.ts +1 -2
- package/dist/core/agent-session-config.d.ts.map +1 -1
- package/dist/core/agent-session-config.js +0 -3
- package/dist/core/agent-session-config.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +5 -4
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +5 -3
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +2 -27
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +10 -6
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +107 -107
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +8 -35
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +33 -243
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/cron-jobs.d.ts.map +1 -1
- package/dist/core/cron-jobs.js +7 -1
- package/dist/core/cron-jobs.js.map +1 -1
- package/dist/core/inference-coordinator.d.ts +6 -1
- package/dist/core/inference-coordinator.d.ts.map +1 -1
- package/dist/core/inference-coordinator.js +18 -2
- package/dist/core/inference-coordinator.js.map +1 -1
- package/dist/core/kernel/bootstrap.d.ts.map +1 -1
- package/dist/core/kernel/bootstrap.js +2 -2
- package/dist/core/kernel/bootstrap.js.map +1 -1
- package/dist/core/kernel/repl-manager.d.ts +2 -0
- package/dist/core/kernel/repl-manager.d.ts.map +1 -1
- package/dist/core/kernel/repl-manager.js +44 -1
- package/dist/core/kernel/repl-manager.js.map +1 -1
- package/dist/core/logging.d.ts +4 -3
- package/dist/core/logging.d.ts.map +1 -1
- package/dist/core/logging.js +6 -6
- package/dist/core/logging.js.map +1 -1
- package/dist/core/mcp/mcp-manager.d.ts.map +1 -1
- package/dist/core/mcp/mcp-manager.js +3 -3
- package/dist/core/mcp/mcp-manager.js.map +1 -1
- package/dist/core/model-registry.d.ts +1 -16
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +88 -196
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +2 -19
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +36 -266
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/provider-contracts.d.ts +5 -6
- package/dist/core/provider-contracts.d.ts.map +1 -1
- package/dist/core/provider-contracts.js +25 -36
- package/dist/core/provider-contracts.js.map +1 -1
- package/dist/core/provider-display-names.d.ts.map +1 -1
- package/dist/core/provider-display-names.js +0 -2
- package/dist/core/provider-display-names.js.map +1 -1
- package/dist/core/rlm-max-subagents.d.ts +32 -0
- package/dist/core/rlm-max-subagents.d.ts.map +1 -0
- package/dist/core/rlm-max-subagents.js +50 -0
- package/dist/core/rlm-max-subagents.js.map +1 -0
- package/dist/core/rlm-runtime.d.ts +3 -3
- package/dist/core/rlm-runtime.d.ts.map +1 -1
- package/dist/core/rlm-runtime.js.map +1 -1
- package/dist/core/sdk.d.ts +4 -3
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +27 -14
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/settings-manager.d.ts +3 -16
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +12 -44
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +6 -6
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/installer.mjs +2 -3
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +39 -34
- package/dist/main.js.map +1 -1
- package/dist/modes/acp/acp-mode.d.ts.map +1 -1
- package/dist/modes/acp/acp-mode.js +1 -1
- package/dist/modes/acp/acp-mode.js.map +1 -1
- package/dist/modes/agent-connection/daemon-agent-connection.d.ts +6 -2
- package/dist/modes/agent-connection/daemon-agent-connection.d.ts.map +1 -1
- package/dist/modes/agent-connection/daemon-agent-connection.js +13 -2
- package/dist/modes/agent-connection/daemon-agent-connection.js.map +1 -1
- package/dist/modes/agent-connection/in-process-agent-connection.d.ts +2 -0
- package/dist/modes/agent-connection/in-process-agent-connection.d.ts.map +1 -1
- package/dist/modes/agent-connection/in-process-agent-connection.js +6 -0
- package/dist/modes/agent-connection/in-process-agent-connection.js.map +1 -1
- package/dist/modes/agent-connection/types.d.ts +3 -0
- package/dist/modes/agent-connection/types.d.ts.map +1 -1
- package/dist/modes/agent-connection/types.js.map +1 -1
- package/dist/modes/agents-view/agents-view-mode.d.ts.map +1 -1
- package/dist/modes/agents-view/agents-view-mode.js +2 -19
- package/dist/modes/agents-view/agents-view-mode.js.map +1 -1
- package/dist/modes/daemon/daemon-mode.d.ts +5 -0
- package/dist/modes/daemon/daemon-mode.d.ts.map +1 -1
- package/dist/modes/daemon/daemon-mode.js +107 -12
- package/dist/modes/daemon/daemon-mode.js.map +1 -1
- package/dist/modes/daemon/daemon-protocol.d.ts +194 -165
- package/dist/modes/daemon/daemon-protocol.d.ts.map +1 -1
- package/dist/modes/daemon/daemon-protocol.js +16 -11
- package/dist/modes/daemon/daemon-protocol.js.map +1 -1
- package/dist/modes/daemon/daemon-rlm-capacity-coordinator.d.ts +19 -0
- package/dist/modes/daemon/daemon-rlm-capacity-coordinator.d.ts.map +1 -0
- package/dist/modes/daemon/daemon-rlm-capacity-coordinator.js +74 -0
- package/dist/modes/daemon/daemon-rlm-capacity-coordinator.js.map +1 -0
- package/dist/modes/daemon/daemon-rlm-capacity.d.ts +19 -0
- package/dist/modes/daemon/daemon-rlm-capacity.d.ts.map +1 -0
- package/dist/modes/daemon/daemon-rlm-capacity.js +85 -0
- package/dist/modes/daemon/daemon-rlm-capacity.js.map +1 -0
- package/dist/modes/daemon/daemon-session-summarizer.d.ts +2 -3
- package/dist/modes/daemon/daemon-session-summarizer.d.ts.map +1 -1
- package/dist/modes/daemon/daemon-session-summarizer.js +32 -23
- package/dist/modes/daemon/daemon-session-summarizer.js.map +1 -1
- package/dist/modes/daemon/daemon-state-root.d.ts +15 -0
- package/dist/modes/daemon/daemon-state-root.d.ts.map +1 -0
- package/dist/modes/daemon/daemon-state-root.js +40 -0
- package/dist/modes/daemon/daemon-state-root.js.map +1 -0
- package/dist/modes/daemon/daemon-supervisor-ownership.d.ts +2 -0
- package/dist/modes/daemon/daemon-supervisor-ownership.d.ts.map +1 -1
- package/dist/modes/daemon/daemon-supervisor-ownership.js +27 -0
- package/dist/modes/daemon/daemon-supervisor-ownership.js.map +1 -1
- package/dist/modes/daemon/daemon-supervisor.d.ts +10 -1
- package/dist/modes/daemon/daemon-supervisor.d.ts.map +1 -1
- package/dist/modes/daemon/daemon-supervisor.js +213 -20
- package/dist/modes/daemon/daemon-supervisor.js.map +1 -1
- package/dist/modes/daemon/daemon-worker-protocol.d.ts +28 -1
- package/dist/modes/daemon/daemon-worker-protocol.d.ts.map +1 -1
- package/dist/modes/daemon/daemon-worker-protocol.js +16 -2
- package/dist/modes/daemon/daemon-worker-protocol.js.map +1 -1
- package/dist/modes/daemon/saved-session-catalog.d.ts.map +1 -1
- package/dist/modes/daemon/saved-session-catalog.js +2 -0
- package/dist/modes/daemon/saved-session-catalog.js.map +1 -1
- package/dist/modes/interactive/auth-flows.d.ts +0 -6
- package/dist/modes/interactive/auth-flows.d.ts.map +1 -1
- package/dist/modes/interactive/auth-flows.js +6 -126
- package/dist/modes/interactive/auth-flows.js.map +1 -1
- package/dist/modes/interactive/components/configuration-menu.d.ts +3 -0
- package/dist/modes/interactive/components/configuration-menu.d.ts.map +1 -1
- package/dist/modes/interactive/components/configuration-menu.js +13 -2
- package/dist/modes/interactive/components/configuration-menu.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +2 -2
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +0 -1
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js +0 -1
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +0 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +3 -40
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +2 -0
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +13 -2
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +2 -11
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/feature-hints.d.ts.map +1 -1
- package/dist/modes/interactive/feature-hints.js +0 -4
- package/dist/modes/interactive/feature-hints.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +3 -12
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +81 -507
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/onboarding.d.ts +0 -3
- package/dist/modes/interactive/onboarding.d.ts.map +1 -1
- package/dist/modes/interactive/onboarding.js +0 -17
- package/dist/modes/interactive/onboarding.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +4 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +82 -42
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/node/amazon-bedrock.d.ts +2 -0
- package/dist/node/amazon-bedrock.d.ts.map +1 -0
- package/dist/node/amazon-bedrock.js +6 -0
- package/dist/node/amazon-bedrock.js.map +1 -0
- package/dist/product-identity.d.ts +0 -1
- package/dist/product-identity.d.ts.map +1 -1
- package/dist/product-identity.js +0 -1
- package/dist/product-identity.js.map +1 -1
- package/docs/development.md +1 -1
- package/docs/fork-philosophy.md +4 -8
- package/docs/installation.md +83 -62
- package/docs/providers.md +23 -25
- package/docs/quickstart.md +19 -10
- package/docs/rlm-runtime.md +13 -5
- package/docs/rpc.md +4 -4
- package/docs/sdk.md +20 -11
- package/docs/sessions.md +0 -1
- package/docs/settings.md +9 -42
- package/docs/skills.md +0 -1
- package/docs/upstream-0.9.5.md +171 -0
- package/docs/usage.md +14 -10
- package/package.json +4 -4
- package/dist/core/agent-traces.d.ts +0 -149
- package/dist/core/agent-traces.d.ts.map +0 -1
- package/dist/core/agent-traces.js +0 -904
- package/dist/core/agent-traces.js.map +0 -1
- package/dist/core/prime-inference-auth.d.ts +0 -70
- package/dist/core/prime-inference-auth.d.ts.map +0 -1
- package/dist/core/prime-inference-auth.js +0 -352
- package/dist/core/prime-inference-auth.js.map +0 -1
- package/dist/core/prime-inference-model-selection.d.ts +0 -16
- package/dist/core/prime-inference-model-selection.d.ts.map +0 -1
- package/dist/core/prime-inference-model-selection.js +0 -16
- package/dist/core/prime-inference-model-selection.js.map +0 -1
- package/dist/core/prime-inference-models.d.ts +0 -6
- package/dist/core/prime-inference-models.d.ts.map +0 -1
- package/dist/core/prime-inference-models.js +0 -62
- package/dist/core/prime-inference-models.js.map +0 -1
- package/dist/core/telemetry.d.ts +0 -95
- package/dist/core/telemetry.d.ts.map +0 -1
- package/dist/core/telemetry.js +0 -637
- package/dist/core/telemetry.js.map +0 -1
- package/dist/modes/interactive/components/prime-onboarding-splash.d.ts +0 -39
- package/dist/modes/interactive/components/prime-onboarding-splash.d.ts.map +0 -1
- package/dist/modes/interactive/components/prime-onboarding-splash.js +0 -286
- package/dist/modes/interactive/components/prime-onboarding-splash.js.map +0 -1
- package/dist/modes/interactive/components/prime-team-selector.d.ts +0 -30
- package/dist/modes/interactive/components/prime-team-selector.d.ts.map +0 -1
- package/dist/modes/interactive/components/prime-team-selector.js +0 -166
- package/dist/modes/interactive/components/prime-team-selector.js.map +0 -1
- package/dist/skills/prime-intellect/SKILL.md +0 -87
- package/dist/skills/prime-intellect/references/compute.md +0 -45
- package/dist/skills/prime-intellect/references/environments.md +0 -73
- package/dist/skills/prime-intellect/references/inference.md +0 -47
- package/dist/skills/prime-intellect/references/sandboxes.md +0 -75
- package/skills/prime-intellect/SKILL.md +0 -87
- package/skills/prime-intellect/references/compute.md +0 -45
- package/skills/prime-intellect/references/environments.md +0 -73
- package/skills/prime-intellect/references/inference.md +0 -47
- 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,
|
|
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,
|
|
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
|
|
178
|
-
|
|
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
|
|
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
|
|
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,
|
|
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 = {}
|
|
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
|
|
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 !== "
|
|
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 !== "
|
|
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
|
-
|
|
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)
|
|
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 =
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
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 !== "
|
|
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 !== "
|
|
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 !== "
|
|
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.
|
|
732
|
-
* 3.
|
|
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 === "
|
|
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 === "
|
|
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
|
-
|
|
856
|
-
|
|
857
|
-
|
|
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
|
|
823
|
+
* Get supported registered OAuth providers. Read-only SDK storage cannot log in.
|
|
885
824
|
*/
|
|
886
825
|
getOAuthProviders() {
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
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
|