bazilion 0.12.0 → 0.12.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/README.md +3 -3
- package/dist/cli.js +20 -14
- package/dist/cli.js.map +1 -1
- package/dist/daemon.js +259 -197
- package/dist/daemon.js.map +1 -1
- package/dist/web/client/assets/{ProductionTeamPolicyEditor-CSL3W7XM.js → ProductionTeamPolicyEditor-CsWpTsy6.js} +1 -1
- package/dist/web/client/assets/{ProfileCommunicationEditor-CwU0QkmE.js → ProfileCommunicationEditor-C43HvUe-.js} +1 -1
- package/dist/web/client/assets/{TeamTabs-C1Hakkff.js → TeamTabs-DvqWieCq.js} +1 -1
- package/dist/web/client/assets/{TemplatesTabs-klEydJ8-.js → TemplatesTabs-6Jd_xQj7.js} +1 -1
- package/dist/web/client/assets/{_id-e4u7dmBb.js → _id-AOAT0H_5.js} +1 -1
- package/dist/web/client/assets/{_id-wkjjWLz0.js → _id-BUuz7Drv.js} +1 -1
- package/dist/web/client/assets/{_id-BOC7ioJu.js → _id-BegmVRmT.js} +1 -1
- package/dist/web/client/assets/{_id-CnVq-rED.js → _id-BrA4Crh_.js} +1 -1
- package/dist/web/client/assets/{activity-uqhwzmiy.js → activity-n0Fw9_w3.js} +1 -1
- package/dist/web/client/assets/{agents-FaQtkAWs.js → agents-B33VQtbl.js} +1 -1
- package/dist/web/client/assets/{agents-B2usE-L_.js → agents-C50pdxp7.js} +1 -1
- package/dist/web/client/assets/{approvals-DqLE6ttw.js → approvals-DVW0hX8h.js} +1 -1
- package/dist/web/client/assets/{attention-CkGozYnJ.js → attention-B2490jcN.js} +1 -1
- package/dist/web/client/assets/chevron-down-B0aNNOyn.js +1 -0
- package/dist/web/client/assets/{config-xrXoDEWM.js → config-CMMxxeX2.js} +2 -2
- package/dist/web/client/assets/{context-ZWqx3uiC.js → context-DcFzsfZ3.js} +1 -1
- package/dist/web/client/assets/{inbox-BoIvl9ZF.js → inbox-Bn1GbUsJ.js} +1 -1
- package/dist/web/client/assets/{index-nb2MV8X1.js → index-3nrK5iFr.js} +2 -2
- package/dist/web/client/assets/{learning-6_oYn1l7.js → learning-BUX1MFu2.js} +1 -1
- package/dist/web/client/assets/{login-DM1ytxQL.js → login-CMWpGDKv.js} +1 -1
- package/dist/web/client/assets/{mcp-CetZbyUh.js → mcp-lZV08dqc.js} +1 -1
- package/dist/web/client/assets/{members-DdqWtwZd.js → members-DAeaY2Cy.js} +1 -1
- package/dist/web/client/assets/{memory-FNrxFHmC.js → memory-HmMWxxdF.js} +1 -1
- package/dist/web/client/assets/plus-CPzRJg1V.js +1 -0
- package/dist/web/client/assets/{policy-BKPejYRI.js → policy-DaijITy7.js} +1 -1
- package/dist/web/client/assets/{routes-CH1ZTTo-.js → routes-BNk270AM.js} +1 -1
- package/dist/web/client/assets/{services-zk9SqN06.js → services-DtrpJrdo.js} +1 -1
- package/dist/web/client/assets/{skills-tXDpomHW.js → skills-Cv93A3P3.js} +1 -1
- package/dist/web/client/assets/{teams-D1c8zlxs.js → teams-CCFnSNKi.js} +1 -1
- package/dist/web/client/assets/{teams-BZYjekBN.js → teams-D92R9Pb7.js} +1 -1
- package/dist/web/client/assets/{telegram-DCe1CWMt.js → telegram-BF1vdgDB.js} +1 -1
- package/dist/web/client/assets/{tokens-DAPjRS0N.js → tokens-BXj6hWW-.js} +1 -1
- package/dist/web/client/assets/{triggers-D8R-5guA.js → triggers-NT24i4hZ.js} +1 -1
- package/dist/web/client/assets/{welcome-CuK0shDJ.js → welcome-D0cy68eZ.js} +1 -1
- package/dist/web/server/assets/{_tanstack-start-manifest_v-fLsYERQ-.js → _tanstack-start-manifest_v-BGDBdnUs.js} +53 -53
- package/dist/web/server/assets/{config-TeIoyYYc.js → config-1w2GiJUn.js} +1 -1
- package/dist/web/server/assets/{config-D2LAsud2.js → config-BmixCpz-.js} +17 -15
- package/dist/web/server/assets/{router-CQuj7553.js → router-CIVjTgNp.js} +2 -2
- package/dist/web/server/assets/{welcome-IYHGurWx.js → welcome-DDB11L5j.js} +2 -2
- package/dist/web/server/server.js +2 -2
- package/dist/worker.js +198 -135
- package/dist/worker.js.map +1 -1
- package/package.json +6 -6
- package/dist/web/client/assets/chevron-down-CJk0zGNT.js +0 -1
- package/dist/web/client/assets/plus-C3GroITC.js +0 -1
package/dist/daemon.js
CHANGED
|
@@ -22265,6 +22265,20 @@ var SERVICES = [
|
|
|
22265
22265
|
hint: "MiniMax M2/M3 family via the China endpoint",
|
|
22266
22266
|
fields: [{ envVar: "MINIMAX_CN_API_KEY", kind: "secret", label: "API key" }]
|
|
22267
22267
|
},
|
|
22268
|
+
{
|
|
22269
|
+
id: "qwen-token-plan",
|
|
22270
|
+
displayName: "Qwen Token Plan",
|
|
22271
|
+
category: "provider",
|
|
22272
|
+
hint: "Coding-model subscription endpoint in Singapore",
|
|
22273
|
+
fields: [{ envVar: "QWEN_TOKEN_PLAN_API_KEY", kind: "secret", label: "API key" }]
|
|
22274
|
+
},
|
|
22275
|
+
{
|
|
22276
|
+
id: "qwen-token-plan-cn",
|
|
22277
|
+
displayName: "Qwen Token Plan (CN)",
|
|
22278
|
+
category: "provider",
|
|
22279
|
+
hint: "Coding-model subscription endpoint in China",
|
|
22280
|
+
fields: [{ envVar: "QWEN_TOKEN_PLAN_CN_API_KEY", kind: "secret", label: "API key" }]
|
|
22281
|
+
},
|
|
22268
22282
|
{
|
|
22269
22283
|
id: "xiaomi",
|
|
22270
22284
|
displayName: "Xiaomi MiMo",
|
|
@@ -24738,17 +24752,28 @@ function selectCausalParent(messages) {
|
|
|
24738
24752
|
import { randomUUID as randomUUID21 } from "crypto";
|
|
24739
24753
|
|
|
24740
24754
|
// ../daemon/src/runtime/auth/openai-codex.ts
|
|
24741
|
-
import {
|
|
24755
|
+
import { openaiCodexProvider } from "@earendil-works/pi-ai/providers/openai-codex";
|
|
24742
24756
|
var OPENAI_CODEX_SECRET_KEY = "OPENAI_CODEX_OAUTH";
|
|
24743
24757
|
var REFRESH_MARGIN_MS = 6e4;
|
|
24744
24758
|
var refreshFlights = /* @__PURE__ */ new WeakMap();
|
|
24759
|
+
function openAICodexOAuth() {
|
|
24760
|
+
const oauth = openaiCodexProvider().auth.oauth;
|
|
24761
|
+
if (!oauth) throw new Error("Pi openai-codex provider does not expose OAuth");
|
|
24762
|
+
return oauth;
|
|
24763
|
+
}
|
|
24764
|
+
async function loginOpenAICodex(interaction) {
|
|
24765
|
+
return openAICodexOAuth().login(interaction);
|
|
24766
|
+
}
|
|
24767
|
+
async function refreshOpenAICodexToken(credential) {
|
|
24768
|
+
return openAICodexOAuth().refresh(credential);
|
|
24769
|
+
}
|
|
24745
24770
|
function readCredentials(db, authToken) {
|
|
24746
24771
|
const raw2 = openSecrets(db, authToken).get(OPENAI_CODEX_SECRET_KEY);
|
|
24747
24772
|
if (!raw2) return null;
|
|
24748
24773
|
try {
|
|
24749
24774
|
const parsed = JSON.parse(raw2);
|
|
24750
24775
|
if (typeof parsed.refresh === "string" && typeof parsed.access === "string" && typeof parsed.expires === "number") {
|
|
24751
|
-
return {
|
|
24776
|
+
return { ...parsed, type: "oauth" };
|
|
24752
24777
|
}
|
|
24753
24778
|
return null;
|
|
24754
24779
|
} catch {
|
|
@@ -24809,12 +24834,7 @@ async function refreshExpiredAccessToken(db, authToken) {
|
|
|
24809
24834
|
const creds = readCredentials(db, authToken);
|
|
24810
24835
|
if (!creds) throw credentialsMissingError();
|
|
24811
24836
|
if (creds.expires > Date.now() + REFRESH_MARGIN_MS) return creds.access;
|
|
24812
|
-
const
|
|
24813
|
-
const next = {
|
|
24814
|
-
refresh: refreshed.refresh,
|
|
24815
|
-
access: refreshed.access,
|
|
24816
|
-
expires: refreshed.expires
|
|
24817
|
-
};
|
|
24837
|
+
const next = await refreshOpenAICodexToken(creds);
|
|
24818
24838
|
const current = readCredentials(db, authToken);
|
|
24819
24839
|
if (!current) throw credentialsMissingError();
|
|
24820
24840
|
if (!sameCredentials(current, creds)) {
|
|
@@ -24833,11 +24853,7 @@ function sameCredentials(left, right) {
|
|
|
24833
24853
|
return left.refresh === right.refresh && left.access === right.access && left.expires === right.expires;
|
|
24834
24854
|
}
|
|
24835
24855
|
function saveLoginCredentials(db, authToken, creds) {
|
|
24836
|
-
writeCredentials(db, authToken, {
|
|
24837
|
-
refresh: creds.refresh,
|
|
24838
|
-
access: creds.access,
|
|
24839
|
-
expires: creds.expires
|
|
24840
|
-
});
|
|
24856
|
+
writeCredentials(db, authToken, { ...creds, type: "oauth" });
|
|
24841
24857
|
}
|
|
24842
24858
|
|
|
24843
24859
|
// ../daemon/src/runtime/memory/files.ts
|
|
@@ -25233,37 +25249,142 @@ function piMessagesToProviderView(messages) {
|
|
|
25233
25249
|
import { existsSync as existsSync14, mkdirSync as mkdirSync6, readdirSync as readdirSync9, statSync as statSync6 } from "fs";
|
|
25234
25250
|
import { basename as basename3, join as join19 } from "path";
|
|
25235
25251
|
import {
|
|
25236
|
-
AuthStorage,
|
|
25237
25252
|
createAgentSession,
|
|
25238
|
-
|
|
25239
|
-
ModelRegistry,
|
|
25253
|
+
DefaultResourceLoader,
|
|
25240
25254
|
SessionManager,
|
|
25241
25255
|
SettingsManager
|
|
25242
25256
|
} from "@earendil-works/pi-coding-agent";
|
|
25243
25257
|
|
|
25244
|
-
// ../daemon/src/runtime/providers/pi-
|
|
25245
|
-
import {
|
|
25246
|
-
|
|
25247
|
-
|
|
25248
|
-
|
|
25249
|
-
|
|
25250
|
-
|
|
25258
|
+
// ../daemon/src/runtime/providers/pi-runtime.ts
|
|
25259
|
+
import { InMemoryCredentialStore } from "@earendil-works/pi-ai";
|
|
25260
|
+
import { ModelRuntime } from "@earendil-works/pi-coding-agent";
|
|
25261
|
+
var PROVIDER_ALIASES = {
|
|
25262
|
+
bedrock: "amazon-bedrock",
|
|
25263
|
+
"azure-openai": "azure-openai-responses"
|
|
25264
|
+
};
|
|
25265
|
+
var LOCAL_PROVIDERS = {
|
|
25266
|
+
lmstudio: {
|
|
25267
|
+
baseUrl: "http://127.0.0.1:1234/v1",
|
|
25268
|
+
apiKey: "lm-studio",
|
|
25269
|
+
authHeader: false
|
|
25270
|
+
},
|
|
25271
|
+
ollama: { baseUrl: "http://127.0.0.1:11434/v1", apiKey: "ollama", authHeader: false },
|
|
25272
|
+
llamacpp: { baseUrl: "http://127.0.0.1:8080/v1", apiKey: "no-key", authHeader: true }
|
|
25273
|
+
};
|
|
25274
|
+
var API_KEY_ENV = {
|
|
25275
|
+
anthropic: ["ANTHROPIC_OAUTH_TOKEN", "ANTHROPIC_API_KEY"],
|
|
25276
|
+
openai: ["OPENAI_API_KEY"],
|
|
25277
|
+
google: ["GEMINI_API_KEY"],
|
|
25278
|
+
"azure-openai": ["AZURE_OPENAI_API_KEY"],
|
|
25279
|
+
mistral: ["MISTRAL_API_KEY"],
|
|
25280
|
+
groq: ["GROQ_API_KEY"],
|
|
25281
|
+
cerebras: ["CEREBRAS_API_KEY"],
|
|
25282
|
+
xai: ["XAI_API_KEY"],
|
|
25283
|
+
zai: ["ZAI_API_KEY"],
|
|
25284
|
+
huggingface: ["HF_TOKEN"],
|
|
25285
|
+
openrouter: ["OPENROUTER_API_KEY"],
|
|
25286
|
+
"vercel-ai-gateway": ["AI_GATEWAY_API_KEY"],
|
|
25287
|
+
deepseek: ["DEEPSEEK_API_KEY"],
|
|
25288
|
+
fireworks: ["FIREWORKS_API_KEY"],
|
|
25289
|
+
together: ["TOGETHER_API_KEY"],
|
|
25290
|
+
moonshotai: ["MOONSHOT_API_KEY"],
|
|
25291
|
+
"moonshotai-cn": ["MOONSHOT_CN_API_KEY"],
|
|
25292
|
+
"kimi-coding": ["KIMI_API_KEY"],
|
|
25293
|
+
minimax: ["MINIMAX_API_KEY"],
|
|
25294
|
+
"minimax-cn": ["MINIMAX_CN_API_KEY"],
|
|
25295
|
+
"qwen-token-plan": ["QWEN_TOKEN_PLAN_API_KEY"],
|
|
25296
|
+
"qwen-token-plan-cn": ["QWEN_TOKEN_PLAN_CN_API_KEY"],
|
|
25297
|
+
xiaomi: ["XIAOMI_API_KEY"],
|
|
25298
|
+
"xiaomi-token-plan-ams": ["XIAOMI_TOKEN_PLAN_AMS_API_KEY"],
|
|
25299
|
+
"xiaomi-token-plan-cn": ["XIAOMI_TOKEN_PLAN_CN_API_KEY"],
|
|
25300
|
+
"xiaomi-token-plan-sgp": ["XIAOMI_TOKEN_PLAN_SGP_API_KEY"],
|
|
25301
|
+
"ant-ling": ["ANT_LING_API_KEY"],
|
|
25302
|
+
nvidia: ["NVIDIA_API_KEY"],
|
|
25303
|
+
opencode: ["OPENCODE_API_KEY"],
|
|
25304
|
+
"opencode-go": ["OPENCODE_GO_API_KEY"],
|
|
25305
|
+
"zai-coding-cn": ["ZAI_CODING_CN_API_KEY"],
|
|
25306
|
+
"github-copilot": ["COPILOT_GITHUB_TOKEN"],
|
|
25307
|
+
"cloudflare-ai-gateway": ["CLOUDFLARE_API_KEY"],
|
|
25308
|
+
"cloudflare-workers-ai": ["CLOUDFLARE_API_KEY"],
|
|
25309
|
+
lmstudio: ["LMSTUDIO_API_KEY"],
|
|
25310
|
+
ollama: ["OLLAMA_API_KEY"],
|
|
25311
|
+
llamacpp: ["LLAMACPP_API_KEY"]
|
|
25312
|
+
};
|
|
25313
|
+
var PROVIDER_ENV = {
|
|
25314
|
+
bedrock: [
|
|
25315
|
+
"AWS_PROFILE",
|
|
25316
|
+
"AWS_BEARER_TOKEN_BEDROCK",
|
|
25317
|
+
"AWS_ACCESS_KEY_ID",
|
|
25318
|
+
"AWS_SECRET_ACCESS_KEY",
|
|
25319
|
+
"AWS_SESSION_TOKEN",
|
|
25320
|
+
"AWS_REGION",
|
|
25321
|
+
"AWS_DEFAULT_REGION"
|
|
25322
|
+
],
|
|
25323
|
+
"google-vertex": [
|
|
25324
|
+
"GOOGLE_CLOUD_PROJECT",
|
|
25325
|
+
"GOOGLE_CLOUD_LOCATION",
|
|
25326
|
+
"GOOGLE_APPLICATION_CREDENTIALS"
|
|
25327
|
+
],
|
|
25328
|
+
"cloudflare-ai-gateway": ["CLOUDFLARE_API_KEY", "CLOUDFLARE_ACCOUNT_ID", "CLOUDFLARE_GATEWAY_ID"],
|
|
25329
|
+
"cloudflare-workers-ai": ["CLOUDFLARE_API_KEY", "CLOUDFLARE_ACCOUNT_ID"]
|
|
25330
|
+
};
|
|
25331
|
+
function piProviderName(providerName) {
|
|
25332
|
+
return PROVIDER_ALIASES[providerName] ?? providerName;
|
|
25333
|
+
}
|
|
25334
|
+
function providerApiKey(providerName, env) {
|
|
25335
|
+
for (const name of API_KEY_ENV[providerName] ?? []) {
|
|
25336
|
+
const value = env[name];
|
|
25337
|
+
if (value) return value;
|
|
25338
|
+
}
|
|
25339
|
+
return LOCAL_PROVIDERS[providerName]?.apiKey;
|
|
25340
|
+
}
|
|
25341
|
+
function providerBaseUrl(providerName, env) {
|
|
25251
25342
|
switch (providerName) {
|
|
25252
25343
|
case "lmstudio":
|
|
25253
|
-
return
|
|
25344
|
+
return env.LMSTUDIO_URL ?? LOCAL_PROVIDERS.lmstudio?.baseUrl;
|
|
25254
25345
|
case "ollama":
|
|
25255
|
-
return
|
|
25346
|
+
return env.OLLAMA_URL ?? LOCAL_PROVIDERS.ollama?.baseUrl;
|
|
25347
|
+
case "llamacpp":
|
|
25348
|
+
return env.LLAMACPP_URL ?? LOCAL_PROVIDERS.llamacpp?.baseUrl;
|
|
25349
|
+
case "vercel-ai-gateway":
|
|
25350
|
+
return env.AI_GATEWAY_BASE_URL;
|
|
25256
25351
|
default:
|
|
25257
|
-
return
|
|
25352
|
+
return void 0;
|
|
25258
25353
|
}
|
|
25259
25354
|
}
|
|
25260
|
-
function
|
|
25355
|
+
function providerCredentialEnv(providerName, env) {
|
|
25356
|
+
const result = {};
|
|
25357
|
+
for (const name of PROVIDER_ENV[providerName] ?? []) {
|
|
25358
|
+
const value = env[name];
|
|
25359
|
+
if (value !== void 0) result[name] = value;
|
|
25360
|
+
}
|
|
25361
|
+
return Object.keys(result).length > 0 ? result : void 0;
|
|
25362
|
+
}
|
|
25363
|
+
function fallbackApi(providerName) {
|
|
25364
|
+
switch (providerName) {
|
|
25365
|
+
case "anthropic":
|
|
25366
|
+
return "anthropic-messages";
|
|
25367
|
+
case "google":
|
|
25368
|
+
return "google-generative-ai";
|
|
25369
|
+
case "google-vertex":
|
|
25370
|
+
return "google-vertex";
|
|
25371
|
+
case "azure-openai":
|
|
25372
|
+
return "azure-openai-responses";
|
|
25373
|
+
case "bedrock":
|
|
25374
|
+
return "bedrock-converse-stream";
|
|
25375
|
+
case "openai-codex":
|
|
25376
|
+
return "openai-codex-responses";
|
|
25377
|
+
default:
|
|
25378
|
+
return "openai-completions";
|
|
25379
|
+
}
|
|
25380
|
+
}
|
|
25381
|
+
function fallbackPiModel(providerName, modelId, baseUrl) {
|
|
25261
25382
|
return {
|
|
25262
25383
|
id: modelId,
|
|
25263
25384
|
name: modelId,
|
|
25264
|
-
api:
|
|
25265
|
-
provider:
|
|
25266
|
-
baseUrl:
|
|
25385
|
+
api: fallbackApi(providerName),
|
|
25386
|
+
provider: piProviderName(providerName),
|
|
25387
|
+
baseUrl: baseUrl ?? "",
|
|
25267
25388
|
reasoning: false,
|
|
25268
25389
|
input: ["text"],
|
|
25269
25390
|
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
@@ -25271,21 +25392,47 @@ function buildModelLiteral(cfg, modelId) {
|
|
|
25271
25392
|
maxTokens: 4096
|
|
25272
25393
|
};
|
|
25273
25394
|
}
|
|
25274
|
-
function
|
|
25275
|
-
const
|
|
25276
|
-
|
|
25277
|
-
|
|
25278
|
-
|
|
25279
|
-
|
|
25280
|
-
|
|
25281
|
-
|
|
25282
|
-
|
|
25283
|
-
|
|
25284
|
-
|
|
25285
|
-
|
|
25395
|
+
async function createBazilionPiRuntime(options) {
|
|
25396
|
+
const providerName = options.providerName;
|
|
25397
|
+
const canonicalName = piProviderName(providerName);
|
|
25398
|
+
const credentials = new InMemoryCredentialStore();
|
|
25399
|
+
const apiKey = options.apiKey ?? providerApiKey(providerName, options.env);
|
|
25400
|
+
const credentialEnv = providerCredentialEnv(providerName, options.env);
|
|
25401
|
+
if (apiKey || credentialEnv) {
|
|
25402
|
+
await credentials.modify(canonicalName, async () => ({
|
|
25403
|
+
type: "api_key",
|
|
25404
|
+
...apiKey ? { key: apiKey } : {},
|
|
25405
|
+
...credentialEnv ? { env: credentialEnv } : {}
|
|
25406
|
+
}));
|
|
25286
25407
|
}
|
|
25287
|
-
|
|
25408
|
+
const runtime = await ModelRuntime.create({ credentials, modelsPath: null });
|
|
25409
|
+
const local = LOCAL_PROVIDERS[providerName];
|
|
25410
|
+
const baseUrl = options.baseUrl ?? providerBaseUrl(providerName, options.env);
|
|
25411
|
+
if (local) {
|
|
25412
|
+
const modelId = options.modelId ?? "model-name";
|
|
25413
|
+
const model = fallbackPiModel(providerName, modelId, baseUrl ?? local.baseUrl);
|
|
25414
|
+
runtime.registerProvider(canonicalName, {
|
|
25415
|
+
baseUrl: baseUrl ?? local.baseUrl,
|
|
25416
|
+
api: "openai-completions",
|
|
25417
|
+
authHeader: local.authHeader,
|
|
25418
|
+
apiKey: apiKey ?? local.apiKey,
|
|
25419
|
+
models: [model]
|
|
25420
|
+
});
|
|
25421
|
+
} else if (baseUrl) {
|
|
25422
|
+
runtime.registerProvider(canonicalName, { baseUrl });
|
|
25423
|
+
}
|
|
25424
|
+
return runtime;
|
|
25425
|
+
}
|
|
25426
|
+
function resolvePiModel(runtime, providerName, modelId, baseUrl) {
|
|
25427
|
+
const known = runtime.getModel(piProviderName(providerName), modelId);
|
|
25428
|
+
if (known) return baseUrl ? { ...known, baseUrl } : known;
|
|
25429
|
+
return fallbackPiModel(providerName, modelId, baseUrl);
|
|
25288
25430
|
}
|
|
25431
|
+
|
|
25432
|
+
// ../daemon/src/runtime/providers/pi-adapter.ts
|
|
25433
|
+
import {
|
|
25434
|
+
Type
|
|
25435
|
+
} from "@earendil-works/pi-ai";
|
|
25289
25436
|
function convertMessages(messages) {
|
|
25290
25437
|
const out = [];
|
|
25291
25438
|
const now = Date.now();
|
|
@@ -25406,9 +25553,16 @@ function piProvider(cfg) {
|
|
|
25406
25553
|
return {
|
|
25407
25554
|
name: cfg.providerName,
|
|
25408
25555
|
async chat(req) {
|
|
25409
|
-
const model = resolveModel(cfg, req.model);
|
|
25410
25556
|
const apiKey = await resolveApiKey(cfg);
|
|
25411
|
-
const
|
|
25557
|
+
const runtime = cfg.runtimeFactory ? await cfg.runtimeFactory() : await createBazilionPiRuntime({
|
|
25558
|
+
providerName: cfg.providerName,
|
|
25559
|
+
env: cfg.env ?? {},
|
|
25560
|
+
...apiKey ? { apiKey } : {},
|
|
25561
|
+
...cfg.baseUrl ? { baseUrl: cfg.baseUrl } : {},
|
|
25562
|
+
modelId: req.model
|
|
25563
|
+
});
|
|
25564
|
+
const model = resolvePiModel(runtime, cfg.providerName, req.model, cfg.baseUrl);
|
|
25565
|
+
const stream = runtime.streamSimple(
|
|
25412
25566
|
model,
|
|
25413
25567
|
{
|
|
25414
25568
|
systemPrompt: req.system ?? "",
|
|
@@ -25576,6 +25730,7 @@ function withRetry(provider, opts = {}) {
|
|
|
25576
25730
|
// ../daemon/src/runtime/providers/registry.ts
|
|
25577
25731
|
function loadProviderConfigFromEnv(env = process.env, oauth) {
|
|
25578
25732
|
const config2 = {
|
|
25733
|
+
env,
|
|
25579
25734
|
lmstudio: {
|
|
25580
25735
|
...env.LMSTUDIO_URL !== void 0 ? { baseURL: env.LMSTUDIO_URL } : {},
|
|
25581
25736
|
...env.LMSTUDIO_API_KEY !== void 0 ? { apiKey: env.LMSTUDIO_API_KEY } : {}
|
|
@@ -25617,6 +25772,12 @@ function loadProviderConfigFromEnv(env = process.env, oauth) {
|
|
|
25617
25772
|
if (env.KIMI_API_KEY) config2.kimiCoding = { apiKey: env.KIMI_API_KEY };
|
|
25618
25773
|
if (env.MINIMAX_API_KEY) config2.minimax = { apiKey: env.MINIMAX_API_KEY };
|
|
25619
25774
|
if (env.MINIMAX_CN_API_KEY) config2.minimaxCn = { apiKey: env.MINIMAX_CN_API_KEY };
|
|
25775
|
+
if (env.QWEN_TOKEN_PLAN_API_KEY) {
|
|
25776
|
+
config2.qwenTokenPlan = { apiKey: env.QWEN_TOKEN_PLAN_API_KEY };
|
|
25777
|
+
}
|
|
25778
|
+
if (env.QWEN_TOKEN_PLAN_CN_API_KEY) {
|
|
25779
|
+
config2.qwenTokenPlanCn = { apiKey: env.QWEN_TOKEN_PLAN_CN_API_KEY };
|
|
25780
|
+
}
|
|
25620
25781
|
if (env.XIAOMI_API_KEY) config2.xiaomi = { apiKey: env.XIAOMI_API_KEY };
|
|
25621
25782
|
if (env.XIAOMI_TOKEN_PLAN_AMS_API_KEY) {
|
|
25622
25783
|
config2.xiaomiTokenPlanAms = { apiKey: env.XIAOMI_TOKEN_PLAN_AMS_API_KEY };
|
|
@@ -25656,7 +25817,6 @@ var PROVIDERS = {
|
|
|
25656
25817
|
configured: (c) => !!c.anthropic,
|
|
25657
25818
|
build: (c) => piProvider({
|
|
25658
25819
|
providerName: "anthropic",
|
|
25659
|
-
fallbackApi: "anthropic-messages",
|
|
25660
25820
|
apiKey: c.anthropic?.apiKey,
|
|
25661
25821
|
baseUrl: c.anthropic?.baseURL
|
|
25662
25822
|
}),
|
|
@@ -25666,7 +25826,6 @@ var PROVIDERS = {
|
|
|
25666
25826
|
configured: (c) => !!c.openai,
|
|
25667
25827
|
build: (c) => piProvider({
|
|
25668
25828
|
providerName: "openai",
|
|
25669
|
-
fallbackApi: "openai-completions",
|
|
25670
25829
|
apiKey: c.openai?.apiKey,
|
|
25671
25830
|
baseUrl: c.openai?.baseURL
|
|
25672
25831
|
}),
|
|
@@ -25684,7 +25843,6 @@ var PROVIDERS = {
|
|
|
25684
25843
|
if (!openaiCodex) throw new Error("openai-codex not configured");
|
|
25685
25844
|
return piProvider({
|
|
25686
25845
|
providerName: "openai-codex",
|
|
25687
|
-
fallbackApi: "openai-codex-responses",
|
|
25688
25846
|
apiKey: () => loadAccessToken(openaiCodex.db, openaiCodex.authToken)
|
|
25689
25847
|
});
|
|
25690
25848
|
},
|
|
@@ -25694,7 +25852,6 @@ var PROVIDERS = {
|
|
|
25694
25852
|
configured: (c) => !!c.google,
|
|
25695
25853
|
build: (c) => piProvider({
|
|
25696
25854
|
providerName: "google",
|
|
25697
|
-
fallbackApi: "google-generative-ai",
|
|
25698
25855
|
apiKey: c.google?.apiKey,
|
|
25699
25856
|
baseUrl: c.google?.baseURL
|
|
25700
25857
|
}),
|
|
@@ -25702,14 +25859,13 @@ var PROVIDERS = {
|
|
|
25702
25859
|
},
|
|
25703
25860
|
"google-vertex": {
|
|
25704
25861
|
configured: (c) => !!c.googleVertex,
|
|
25705
|
-
build: () => piProvider({ providerName: "google-vertex",
|
|
25862
|
+
build: (c) => piProvider({ providerName: "google-vertex", env: c.env }),
|
|
25706
25863
|
hint: "GOOGLE_CLOUD_PROJECT + GOOGLE_CLOUD_LOCATION + ADC (gcloud auth)"
|
|
25707
25864
|
},
|
|
25708
25865
|
"azure-openai": {
|
|
25709
25866
|
configured: (c) => !!c.azureOpenai,
|
|
25710
25867
|
build: (c) => piProvider({
|
|
25711
25868
|
providerName: "azure-openai",
|
|
25712
|
-
fallbackApi: "azure-openai-responses",
|
|
25713
25869
|
apiKey: c.azureOpenai?.apiKey,
|
|
25714
25870
|
baseUrl: c.azureOpenai?.baseURL
|
|
25715
25871
|
}),
|
|
@@ -25717,10 +25873,9 @@ var PROVIDERS = {
|
|
|
25717
25873
|
},
|
|
25718
25874
|
bedrock: {
|
|
25719
25875
|
configured: (c) => !!c.bedrock,
|
|
25720
|
-
build: () => piProvider({
|
|
25876
|
+
build: (c) => piProvider({
|
|
25721
25877
|
providerName: "bedrock",
|
|
25722
|
-
|
|
25723
|
-
fallbackApi: "bedrock-converse-stream"
|
|
25878
|
+
env: c.env
|
|
25724
25879
|
}),
|
|
25725
25880
|
hint: "AWS_PROFILE or AWS_ACCESS_KEY_ID+AWS_SECRET_ACCESS_KEY"
|
|
25726
25881
|
},
|
|
@@ -25728,7 +25883,6 @@ var PROVIDERS = {
|
|
|
25728
25883
|
configured: (c) => !!c.mistral,
|
|
25729
25884
|
build: (c) => piProvider({
|
|
25730
25885
|
providerName: "mistral",
|
|
25731
|
-
fallbackApi: "openai-completions",
|
|
25732
25886
|
apiKey: c.mistral?.apiKey,
|
|
25733
25887
|
baseUrl: c.mistral?.baseURL
|
|
25734
25888
|
}),
|
|
@@ -25738,7 +25892,6 @@ var PROVIDERS = {
|
|
|
25738
25892
|
configured: (c) => !!c.groq,
|
|
25739
25893
|
build: (c) => piProvider({
|
|
25740
25894
|
providerName: "groq",
|
|
25741
|
-
fallbackApi: "openai-completions",
|
|
25742
25895
|
apiKey: c.groq?.apiKey,
|
|
25743
25896
|
baseUrl: c.groq?.baseURL
|
|
25744
25897
|
}),
|
|
@@ -25748,7 +25901,6 @@ var PROVIDERS = {
|
|
|
25748
25901
|
configured: (c) => !!c.cerebras,
|
|
25749
25902
|
build: (c) => piProvider({
|
|
25750
25903
|
providerName: "cerebras",
|
|
25751
|
-
fallbackApi: "openai-completions",
|
|
25752
25904
|
apiKey: c.cerebras?.apiKey,
|
|
25753
25905
|
baseUrl: c.cerebras?.baseURL
|
|
25754
25906
|
}),
|
|
@@ -25758,7 +25910,6 @@ var PROVIDERS = {
|
|
|
25758
25910
|
configured: (c) => !!c.xai,
|
|
25759
25911
|
build: (c) => piProvider({
|
|
25760
25912
|
providerName: "xai",
|
|
25761
|
-
fallbackApi: "openai-completions",
|
|
25762
25913
|
apiKey: c.xai?.apiKey,
|
|
25763
25914
|
baseUrl: c.xai?.baseURL
|
|
25764
25915
|
}),
|
|
@@ -25768,7 +25919,6 @@ var PROVIDERS = {
|
|
|
25768
25919
|
configured: (c) => !!c.zai,
|
|
25769
25920
|
build: (c) => piProvider({
|
|
25770
25921
|
providerName: "zai",
|
|
25771
|
-
fallbackApi: "openai-completions",
|
|
25772
25922
|
apiKey: c.zai?.apiKey,
|
|
25773
25923
|
baseUrl: c.zai?.baseURL
|
|
25774
25924
|
}),
|
|
@@ -25778,7 +25928,6 @@ var PROVIDERS = {
|
|
|
25778
25928
|
configured: (c) => !!c.huggingface,
|
|
25779
25929
|
build: (c) => piProvider({
|
|
25780
25930
|
providerName: "huggingface",
|
|
25781
|
-
fallbackApi: "openai-completions",
|
|
25782
25931
|
apiKey: c.huggingface?.apiKey,
|
|
25783
25932
|
baseUrl: c.huggingface?.baseURL
|
|
25784
25933
|
}),
|
|
@@ -25788,7 +25937,6 @@ var PROVIDERS = {
|
|
|
25788
25937
|
configured: (c) => !!c.openrouter,
|
|
25789
25938
|
build: (c) => piProvider({
|
|
25790
25939
|
providerName: "openrouter",
|
|
25791
|
-
fallbackApi: "openai-completions",
|
|
25792
25940
|
apiKey: c.openrouter?.apiKey,
|
|
25793
25941
|
baseUrl: c.openrouter?.baseURL
|
|
25794
25942
|
}),
|
|
@@ -25798,7 +25946,6 @@ var PROVIDERS = {
|
|
|
25798
25946
|
configured: (c) => !!c.vercelAiGateway,
|
|
25799
25947
|
build: (c) => piProvider({
|
|
25800
25948
|
providerName: "vercel-ai-gateway",
|
|
25801
|
-
fallbackApi: "openai-completions",
|
|
25802
25949
|
apiKey: c.vercelAiGateway?.apiKey,
|
|
25803
25950
|
baseUrl: c.vercelAiGateway?.baseURL
|
|
25804
25951
|
}),
|
|
@@ -25808,7 +25955,6 @@ var PROVIDERS = {
|
|
|
25808
25955
|
configured: (c) => !!c.deepseek,
|
|
25809
25956
|
build: (c) => piProvider({
|
|
25810
25957
|
providerName: "deepseek",
|
|
25811
|
-
fallbackApi: "openai-completions",
|
|
25812
25958
|
apiKey: c.deepseek?.apiKey,
|
|
25813
25959
|
baseUrl: c.deepseek?.baseURL
|
|
25814
25960
|
}),
|
|
@@ -25818,7 +25964,6 @@ var PROVIDERS = {
|
|
|
25818
25964
|
configured: (c) => !!c.fireworks,
|
|
25819
25965
|
build: (c) => piProvider({
|
|
25820
25966
|
providerName: "fireworks",
|
|
25821
|
-
fallbackApi: "anthropic-messages",
|
|
25822
25967
|
apiKey: c.fireworks?.apiKey,
|
|
25823
25968
|
baseUrl: c.fireworks?.baseURL
|
|
25824
25969
|
}),
|
|
@@ -25828,7 +25973,6 @@ var PROVIDERS = {
|
|
|
25828
25973
|
configured: (c) => !!c.together,
|
|
25829
25974
|
build: (c) => piProvider({
|
|
25830
25975
|
providerName: "together",
|
|
25831
|
-
fallbackApi: "openai-completions",
|
|
25832
25976
|
apiKey: c.together?.apiKey,
|
|
25833
25977
|
baseUrl: c.together?.baseURL
|
|
25834
25978
|
}),
|
|
@@ -25838,7 +25982,6 @@ var PROVIDERS = {
|
|
|
25838
25982
|
configured: (c) => !!c.moonshotai,
|
|
25839
25983
|
build: (c) => piProvider({
|
|
25840
25984
|
providerName: "moonshotai",
|
|
25841
|
-
fallbackApi: "openai-completions",
|
|
25842
25985
|
apiKey: c.moonshotai?.apiKey,
|
|
25843
25986
|
baseUrl: c.moonshotai?.baseURL
|
|
25844
25987
|
}),
|
|
@@ -25848,7 +25991,6 @@ var PROVIDERS = {
|
|
|
25848
25991
|
configured: (c) => !!c.moonshotaiCn,
|
|
25849
25992
|
build: (c) => piProvider({
|
|
25850
25993
|
providerName: "moonshotai-cn",
|
|
25851
|
-
fallbackApi: "openai-completions",
|
|
25852
25994
|
apiKey: c.moonshotaiCn?.apiKey,
|
|
25853
25995
|
baseUrl: c.moonshotaiCn?.baseURL
|
|
25854
25996
|
}),
|
|
@@ -25858,7 +26000,6 @@ var PROVIDERS = {
|
|
|
25858
26000
|
configured: (c) => !!c.kimiCoding,
|
|
25859
26001
|
build: (c) => piProvider({
|
|
25860
26002
|
providerName: "kimi-coding",
|
|
25861
|
-
fallbackApi: "anthropic-messages",
|
|
25862
26003
|
apiKey: c.kimiCoding?.apiKey,
|
|
25863
26004
|
baseUrl: c.kimiCoding?.baseURL
|
|
25864
26005
|
}),
|
|
@@ -25868,7 +26009,6 @@ var PROVIDERS = {
|
|
|
25868
26009
|
configured: (c) => !!c.minimax,
|
|
25869
26010
|
build: (c) => piProvider({
|
|
25870
26011
|
providerName: "minimax",
|
|
25871
|
-
fallbackApi: "anthropic-messages",
|
|
25872
26012
|
apiKey: c.minimax?.apiKey,
|
|
25873
26013
|
baseUrl: c.minimax?.baseURL
|
|
25874
26014
|
}),
|
|
@@ -25878,17 +26018,33 @@ var PROVIDERS = {
|
|
|
25878
26018
|
configured: (c) => !!c.minimaxCn,
|
|
25879
26019
|
build: (c) => piProvider({
|
|
25880
26020
|
providerName: "minimax-cn",
|
|
25881
|
-
fallbackApi: "anthropic-messages",
|
|
25882
26021
|
apiKey: c.minimaxCn?.apiKey,
|
|
25883
26022
|
baseUrl: c.minimaxCn?.baseURL
|
|
25884
26023
|
}),
|
|
25885
26024
|
hint: "MINIMAX_CN_API_KEY"
|
|
25886
26025
|
},
|
|
26026
|
+
"qwen-token-plan": {
|
|
26027
|
+
configured: (c) => !!c.qwenTokenPlan,
|
|
26028
|
+
build: (c) => piProvider({
|
|
26029
|
+
providerName: "qwen-token-plan",
|
|
26030
|
+
apiKey: c.qwenTokenPlan?.apiKey,
|
|
26031
|
+
baseUrl: c.qwenTokenPlan?.baseURL
|
|
26032
|
+
}),
|
|
26033
|
+
hint: "QWEN_TOKEN_PLAN_API_KEY"
|
|
26034
|
+
},
|
|
26035
|
+
"qwen-token-plan-cn": {
|
|
26036
|
+
configured: (c) => !!c.qwenTokenPlanCn,
|
|
26037
|
+
build: (c) => piProvider({
|
|
26038
|
+
providerName: "qwen-token-plan-cn",
|
|
26039
|
+
apiKey: c.qwenTokenPlanCn?.apiKey,
|
|
26040
|
+
baseUrl: c.qwenTokenPlanCn?.baseURL
|
|
26041
|
+
}),
|
|
26042
|
+
hint: "QWEN_TOKEN_PLAN_CN_API_KEY"
|
|
26043
|
+
},
|
|
25887
26044
|
xiaomi: {
|
|
25888
26045
|
configured: (c) => !!c.xiaomi,
|
|
25889
26046
|
build: (c) => piProvider({
|
|
25890
26047
|
providerName: "xiaomi",
|
|
25891
|
-
fallbackApi: "openai-completions",
|
|
25892
26048
|
apiKey: c.xiaomi?.apiKey,
|
|
25893
26049
|
baseUrl: c.xiaomi?.baseURL
|
|
25894
26050
|
}),
|
|
@@ -25898,7 +26054,6 @@ var PROVIDERS = {
|
|
|
25898
26054
|
configured: (c) => !!c.xiaomiTokenPlanAms,
|
|
25899
26055
|
build: (c) => piProvider({
|
|
25900
26056
|
providerName: "xiaomi-token-plan-ams",
|
|
25901
|
-
fallbackApi: "openai-completions",
|
|
25902
26057
|
apiKey: c.xiaomiTokenPlanAms?.apiKey,
|
|
25903
26058
|
baseUrl: c.xiaomiTokenPlanAms?.baseURL
|
|
25904
26059
|
}),
|
|
@@ -25908,7 +26063,6 @@ var PROVIDERS = {
|
|
|
25908
26063
|
configured: (c) => !!c.xiaomiTokenPlanCn,
|
|
25909
26064
|
build: (c) => piProvider({
|
|
25910
26065
|
providerName: "xiaomi-token-plan-cn",
|
|
25911
|
-
fallbackApi: "openai-completions",
|
|
25912
26066
|
apiKey: c.xiaomiTokenPlanCn?.apiKey,
|
|
25913
26067
|
baseUrl: c.xiaomiTokenPlanCn?.baseURL
|
|
25914
26068
|
}),
|
|
@@ -25918,7 +26072,6 @@ var PROVIDERS = {
|
|
|
25918
26072
|
configured: (c) => !!c.xiaomiTokenPlanSgp,
|
|
25919
26073
|
build: (c) => piProvider({
|
|
25920
26074
|
providerName: "xiaomi-token-plan-sgp",
|
|
25921
|
-
fallbackApi: "openai-completions",
|
|
25922
26075
|
apiKey: c.xiaomiTokenPlanSgp?.apiKey,
|
|
25923
26076
|
baseUrl: c.xiaomiTokenPlanSgp?.baseURL
|
|
25924
26077
|
}),
|
|
@@ -25928,7 +26081,6 @@ var PROVIDERS = {
|
|
|
25928
26081
|
configured: (c) => !!c.antLing,
|
|
25929
26082
|
build: (c) => piProvider({
|
|
25930
26083
|
providerName: "ant-ling",
|
|
25931
|
-
fallbackApi: "openai-completions",
|
|
25932
26084
|
apiKey: c.antLing?.apiKey,
|
|
25933
26085
|
baseUrl: c.antLing?.baseURL
|
|
25934
26086
|
}),
|
|
@@ -25938,7 +26090,6 @@ var PROVIDERS = {
|
|
|
25938
26090
|
configured: (c) => !!c.nvidia,
|
|
25939
26091
|
build: (c) => piProvider({
|
|
25940
26092
|
providerName: "nvidia",
|
|
25941
|
-
fallbackApi: "openai-completions",
|
|
25942
26093
|
apiKey: c.nvidia?.apiKey,
|
|
25943
26094
|
baseUrl: c.nvidia?.baseURL
|
|
25944
26095
|
}),
|
|
@@ -25948,7 +26099,6 @@ var PROVIDERS = {
|
|
|
25948
26099
|
configured: (c) => !!c.opencode,
|
|
25949
26100
|
build: (c) => piProvider({
|
|
25950
26101
|
providerName: "opencode",
|
|
25951
|
-
fallbackApi: "openai-completions",
|
|
25952
26102
|
apiKey: c.opencode?.apiKey,
|
|
25953
26103
|
baseUrl: c.opencode?.baseURL
|
|
25954
26104
|
}),
|
|
@@ -25958,7 +26108,6 @@ var PROVIDERS = {
|
|
|
25958
26108
|
configured: (c) => !!c.opencodeGo,
|
|
25959
26109
|
build: (c) => piProvider({
|
|
25960
26110
|
providerName: "opencode-go",
|
|
25961
|
-
fallbackApi: "openai-completions",
|
|
25962
26111
|
apiKey: c.opencodeGo?.apiKey,
|
|
25963
26112
|
baseUrl: c.opencodeGo?.baseURL
|
|
25964
26113
|
}),
|
|
@@ -25968,7 +26117,6 @@ var PROVIDERS = {
|
|
|
25968
26117
|
configured: (c) => !!c.zaiCodingCn,
|
|
25969
26118
|
build: (c) => piProvider({
|
|
25970
26119
|
providerName: "zai-coding-cn",
|
|
25971
|
-
fallbackApi: "openai-completions",
|
|
25972
26120
|
apiKey: c.zaiCodingCn?.apiKey,
|
|
25973
26121
|
baseUrl: c.zaiCodingCn?.baseURL
|
|
25974
26122
|
}),
|
|
@@ -25978,7 +26126,6 @@ var PROVIDERS = {
|
|
|
25978
26126
|
configured: (c) => !!c.githubCopilot,
|
|
25979
26127
|
build: (c) => piProvider({
|
|
25980
26128
|
providerName: "github-copilot",
|
|
25981
|
-
fallbackApi: "anthropic-messages",
|
|
25982
26129
|
apiKey: c.githubCopilot?.apiKey
|
|
25983
26130
|
}),
|
|
25984
26131
|
hint: "COPILOT_GITHUB_TOKEN (generic GH_TOKEN/GITHUB_TOKEN are ignored)"
|
|
@@ -25987,7 +26134,7 @@ var PROVIDERS = {
|
|
|
25987
26134
|
configured: (c) => !!c.cloudflareAiGateway,
|
|
25988
26135
|
build: (c) => piProvider({
|
|
25989
26136
|
providerName: "cloudflare-ai-gateway",
|
|
25990
|
-
|
|
26137
|
+
env: c.env,
|
|
25991
26138
|
apiKey: c.cloudflareAiGateway?.apiKey
|
|
25992
26139
|
}),
|
|
25993
26140
|
hint: "CLOUDFLARE_API_KEY + CLOUDFLARE_ACCOUNT_ID + CLOUDFLARE_GATEWAY_ID"
|
|
@@ -25996,7 +26143,7 @@ var PROVIDERS = {
|
|
|
25996
26143
|
configured: (c) => !!c.cloudflareWorkersAi,
|
|
25997
26144
|
build: (c) => piProvider({
|
|
25998
26145
|
providerName: "cloudflare-workers-ai",
|
|
25999
|
-
|
|
26146
|
+
env: c.env,
|
|
26000
26147
|
apiKey: c.cloudflareWorkersAi?.apiKey
|
|
26001
26148
|
}),
|
|
26002
26149
|
hint: "CLOUDFLARE_API_KEY + CLOUDFLARE_ACCOUNT_ID"
|
|
@@ -26005,7 +26152,6 @@ var PROVIDERS = {
|
|
|
26005
26152
|
configured: () => true,
|
|
26006
26153
|
build: (c) => piProvider({
|
|
26007
26154
|
providerName: "lmstudio",
|
|
26008
|
-
fallbackApi: "openai-completions",
|
|
26009
26155
|
apiKey: c.lmstudio?.apiKey ?? "lm-studio",
|
|
26010
26156
|
baseUrl: c.lmstudio?.baseURL ?? "http://127.0.0.1:1234/v1"
|
|
26011
26157
|
}),
|
|
@@ -26015,7 +26161,6 @@ var PROVIDERS = {
|
|
|
26015
26161
|
configured: () => true,
|
|
26016
26162
|
build: (c) => piProvider({
|
|
26017
26163
|
providerName: "ollama",
|
|
26018
|
-
fallbackApi: "openai-completions",
|
|
26019
26164
|
apiKey: c.ollama?.apiKey ?? "ollama",
|
|
26020
26165
|
baseUrl: c.ollama?.baseURL ?? "http://127.0.0.1:11434/v1"
|
|
26021
26166
|
}),
|
|
@@ -26029,7 +26174,6 @@ var PROVIDERS = {
|
|
|
26029
26174
|
configured: () => true,
|
|
26030
26175
|
build: (c) => piProvider({
|
|
26031
26176
|
providerName: "llamacpp",
|
|
26032
|
-
fallbackApi: "openai-completions",
|
|
26033
26177
|
apiKey: c.llamacpp?.apiKey ?? "no-key",
|
|
26034
26178
|
baseUrl: c.llamacpp?.baseURL ?? "http://127.0.0.1:8080/v1"
|
|
26035
26179
|
}),
|
|
@@ -28569,30 +28713,16 @@ async function createBazilionSession(opts) {
|
|
|
28569
28713
|
if (enabledProviders.size > 0 && !enabledProviders.has(providerName)) {
|
|
28570
28714
|
throw new Error(`${providerName} provider is disabled \u2014 enable it on the /config page`);
|
|
28571
28715
|
}
|
|
28572
|
-
const
|
|
28573
|
-
const
|
|
28574
|
-
|
|
28575
|
-
|
|
28576
|
-
|
|
28577
|
-
|
|
28578
|
-
|
|
28579
|
-
},
|
|
28716
|
+
const apiKey = opts.apiKey ?? providerApiKey(providerName, env);
|
|
28717
|
+
const baseUrl = providerBaseUrl(providerName, env);
|
|
28718
|
+
const modelRuntime = await createBazilionPiRuntime({
|
|
28719
|
+
providerName,
|
|
28720
|
+
env,
|
|
28721
|
+
...apiKey ? { apiKey } : {},
|
|
28722
|
+
...baseUrl ? { baseUrl } : {},
|
|
28580
28723
|
modelId
|
|
28581
|
-
);
|
|
28582
|
-
const
|
|
28583
|
-
const authStorage = AuthStorage.inMemory();
|
|
28584
|
-
if (apiKey) {
|
|
28585
|
-
authStorage.setRuntimeApiKey(piProviderName, apiKey);
|
|
28586
|
-
}
|
|
28587
|
-
const modelRegistry = ModelRegistry.inMemory(authStorage);
|
|
28588
|
-
if (providerName === "lmstudio" || providerName === "ollama") {
|
|
28589
|
-
modelRegistry.registerProvider(piProviderName, {
|
|
28590
|
-
baseUrl: model.baseUrl,
|
|
28591
|
-
api: "openai-completions",
|
|
28592
|
-
authHeader: false,
|
|
28593
|
-
apiKey: apiKey ?? "dummy"
|
|
28594
|
-
});
|
|
28595
|
-
}
|
|
28724
|
+
});
|
|
28725
|
+
const model = resolvePiModel(modelRuntime, providerName, modelId, baseUrl);
|
|
28596
28726
|
const cwd = agent.team.path;
|
|
28597
28727
|
if (!existsSync14(cwd)) mkdirSync6(cwd, { recursive: true });
|
|
28598
28728
|
const promptSkills = restricted ? [] : loadPromptSkills(paths.skillsDir, agent.skills);
|
|
@@ -28622,7 +28752,17 @@ async function createBazilionSession(opts) {
|
|
|
28622
28752
|
skills: promptSkills,
|
|
28623
28753
|
sandboxMode: shellTools?.config.sandboxMode ?? "off"
|
|
28624
28754
|
});
|
|
28625
|
-
const resourceLoader =
|
|
28755
|
+
const resourceLoader = new DefaultResourceLoader({
|
|
28756
|
+
cwd,
|
|
28757
|
+
agentDir: join19(paths.home, "pi"),
|
|
28758
|
+
settingsManager,
|
|
28759
|
+
noExtensions: true,
|
|
28760
|
+
noSkills: true,
|
|
28761
|
+
noPromptTemplates: true,
|
|
28762
|
+
noThemes: true,
|
|
28763
|
+
noContextFiles: true,
|
|
28764
|
+
appendSystemPrompt: bazilionPrompt ? [bazilionPrompt] : void 0
|
|
28765
|
+
});
|
|
28626
28766
|
await resourceLoader.reload();
|
|
28627
28767
|
const bazilionTools = restricted ? restricted.tools : createBazilionCustomTools({
|
|
28628
28768
|
agent,
|
|
@@ -28646,13 +28786,12 @@ async function createBazilionSession(opts) {
|
|
|
28646
28786
|
customTools,
|
|
28647
28787
|
sessionManager,
|
|
28648
28788
|
settingsManager,
|
|
28649
|
-
|
|
28650
|
-
modelRegistry,
|
|
28789
|
+
modelRuntime,
|
|
28651
28790
|
resourceLoader
|
|
28652
28791
|
});
|
|
28653
28792
|
if (refreshApiKey) {
|
|
28654
28793
|
session.agent.getApiKey = async (requestedProvider) => {
|
|
28655
|
-
if (requestedProvider !== piProviderName) return void 0;
|
|
28794
|
+
if (requestedProvider !== piProviderName(providerName)) return void 0;
|
|
28656
28795
|
try {
|
|
28657
28796
|
return await refreshApiKey(providerName);
|
|
28658
28797
|
} catch {
|
|
@@ -28674,67 +28813,6 @@ function splitModelString(s) {
|
|
|
28674
28813
|
}
|
|
28675
28814
|
return { providerName: s.slice(0, idx), modelId: s.slice(idx + 1) };
|
|
28676
28815
|
}
|
|
28677
|
-
function mapProviderName(name) {
|
|
28678
|
-
if (name === "bedrock") return "amazon-bedrock";
|
|
28679
|
-
return name;
|
|
28680
|
-
}
|
|
28681
|
-
function pickFallbackApi(providerName) {
|
|
28682
|
-
switch (providerName) {
|
|
28683
|
-
case "anthropic":
|
|
28684
|
-
return "anthropic-messages";
|
|
28685
|
-
case "google":
|
|
28686
|
-
return "google-generative-ai";
|
|
28687
|
-
case "google-vertex":
|
|
28688
|
-
return "google-vertex";
|
|
28689
|
-
case "azure-openai":
|
|
28690
|
-
return "azure-openai-responses";
|
|
28691
|
-
case "bedrock":
|
|
28692
|
-
return "bedrock-converse-stream";
|
|
28693
|
-
case "openai-codex":
|
|
28694
|
-
return "openai-codex-responses";
|
|
28695
|
-
default:
|
|
28696
|
-
return "openai-completions";
|
|
28697
|
-
}
|
|
28698
|
-
}
|
|
28699
|
-
function resolveBaseUrl(providerName, env) {
|
|
28700
|
-
if (providerName === "lmstudio") return env.LMSTUDIO_URL ?? "http://127.0.0.1:1234/v1";
|
|
28701
|
-
if (providerName === "ollama") return env.OLLAMA_URL ?? "http://127.0.0.1:11434/v1";
|
|
28702
|
-
return void 0;
|
|
28703
|
-
}
|
|
28704
|
-
function resolveApiKey2(providerName, env) {
|
|
28705
|
-
switch (providerName) {
|
|
28706
|
-
case "anthropic":
|
|
28707
|
-
return env.ANTHROPIC_OAUTH_TOKEN ?? env.ANTHROPIC_API_KEY;
|
|
28708
|
-
case "openai":
|
|
28709
|
-
return env.OPENAI_API_KEY;
|
|
28710
|
-
case "google":
|
|
28711
|
-
return env.GEMINI_API_KEY;
|
|
28712
|
-
case "mistral":
|
|
28713
|
-
return env.MISTRAL_API_KEY;
|
|
28714
|
-
case "groq":
|
|
28715
|
-
return env.GROQ_API_KEY;
|
|
28716
|
-
case "cerebras":
|
|
28717
|
-
return env.CEREBRAS_API_KEY;
|
|
28718
|
-
case "xai":
|
|
28719
|
-
return env.XAI_API_KEY;
|
|
28720
|
-
case "zai":
|
|
28721
|
-
return env.ZAI_API_KEY;
|
|
28722
|
-
case "huggingface":
|
|
28723
|
-
return env.HF_TOKEN;
|
|
28724
|
-
case "openrouter":
|
|
28725
|
-
return env.OPENROUTER_API_KEY;
|
|
28726
|
-
case "vercel-ai-gateway":
|
|
28727
|
-
return env.AI_GATEWAY_API_KEY;
|
|
28728
|
-
case "azure-openai":
|
|
28729
|
-
return env.AZURE_OPENAI_API_KEY;
|
|
28730
|
-
case "lmstudio":
|
|
28731
|
-
return env.LMSTUDIO_API_KEY ?? "lm-studio";
|
|
28732
|
-
case "ollama":
|
|
28733
|
-
return env.OLLAMA_API_KEY ?? "ollama";
|
|
28734
|
-
default:
|
|
28735
|
-
return void 0;
|
|
28736
|
-
}
|
|
28737
|
-
}
|
|
28738
28816
|
function toPiThinkingLevel(level) {
|
|
28739
28817
|
switch (level) {
|
|
28740
28818
|
case "off":
|
|
@@ -28748,22 +28826,6 @@ function toPiThinkingLevel(level) {
|
|
|
28748
28826
|
return "medium";
|
|
28749
28827
|
}
|
|
28750
28828
|
}
|
|
28751
|
-
function createBazilionResourceLoader(appendSystemPrompt) {
|
|
28752
|
-
const extensions = { extensions: [], errors: [], runtime: createExtensionRuntime() };
|
|
28753
|
-
return {
|
|
28754
|
-
getExtensions: () => extensions,
|
|
28755
|
-
getSkills: () => ({ skills: [], diagnostics: [] }),
|
|
28756
|
-
getPrompts: () => ({ prompts: [], diagnostics: [] }),
|
|
28757
|
-
getThemes: () => ({ themes: [], diagnostics: [] }),
|
|
28758
|
-
getAgentsFiles: () => ({ agentsFiles: [] }),
|
|
28759
|
-
getSystemPrompt: () => void 0,
|
|
28760
|
-
getAppendSystemPrompt: () => appendSystemPrompt ? [appendSystemPrompt] : [],
|
|
28761
|
-
extendResources: () => {
|
|
28762
|
-
},
|
|
28763
|
-
async reload() {
|
|
28764
|
-
}
|
|
28765
|
-
};
|
|
28766
|
-
}
|
|
28767
28829
|
function loadInitialMessages(agent, paths) {
|
|
28768
28830
|
const sessionDir = join19(paths.agentDir(agent.agent.id), "sessions");
|
|
28769
28831
|
if (!existsSync14(sessionDir)) return [];
|
|
@@ -28822,7 +28884,7 @@ function findMostRecent(sessionDir) {
|
|
|
28822
28884
|
}
|
|
28823
28885
|
|
|
28824
28886
|
// ../daemon/src/runtime/providers/catalog.ts
|
|
28825
|
-
import {
|
|
28887
|
+
import { getBuiltinModels } from "@earendil-works/pi-ai/providers/all";
|
|
28826
28888
|
import { fetch as undiciFetch3 } from "undici";
|
|
28827
28889
|
var REGISTRY_TO_PI = {
|
|
28828
28890
|
bedrock: "amazon-bedrock",
|
|
@@ -28871,7 +28933,7 @@ function liveEndpointFor(providerName, env) {
|
|
|
28871
28933
|
function piModels(providerName) {
|
|
28872
28934
|
const piName = REGISTRY_TO_PI[providerName] ?? providerName;
|
|
28873
28935
|
try {
|
|
28874
|
-
const models =
|
|
28936
|
+
const models = getBuiltinModels(piName);
|
|
28875
28937
|
if (!models) return [];
|
|
28876
28938
|
return models.map((m2) => m2.id);
|
|
28877
28939
|
} catch {
|
|
@@ -36921,14 +36983,14 @@ authRouter.post("/auth/openai/login", async (c) => {
|
|
|
36921
36983
|
const { db, authToken } = getCtx();
|
|
36922
36984
|
try {
|
|
36923
36985
|
const creds = await loginOpenAICodex({
|
|
36924
|
-
|
|
36925
|
-
|
|
36986
|
+
notify: (event2) => {
|
|
36987
|
+
if (event2.type === "auth_url") openBrowser(event2.url);
|
|
36988
|
+
},
|
|
36989
|
+
prompt: (prompt) => prompt.type === "select" ? Promise.resolve(prompt.options[0]?.id ?? "") : Promise.reject(
|
|
36926
36990
|
new Error(
|
|
36927
36991
|
"interactive paste not supported in the web flow \u2014 cancel and try again, or use `bazilion auth openai login`"
|
|
36928
36992
|
)
|
|
36929
|
-
)
|
|
36930
|
-
onProgress: () => {
|
|
36931
|
-
}
|
|
36993
|
+
)
|
|
36932
36994
|
});
|
|
36933
36995
|
saveLoginCredentials(db, authToken, creds);
|
|
36934
36996
|
return c.json(getStatus(db, authToken));
|
|
@@ -36942,7 +37004,7 @@ authRouter.post("/providers/test", async (c) => {
|
|
|
36942
37004
|
return c.json({ error: "model is required" }, 400);
|
|
36943
37005
|
}
|
|
36944
37006
|
const message = typeof body.message === "string" && body.message ? body.message : "say hi briefly";
|
|
36945
|
-
const { db,
|
|
37007
|
+
const { db, authToken } = getCtx();
|
|
36946
37008
|
const env = mergeSecretsIntoEnv(db, authToken);
|
|
36947
37009
|
const reg = createProviderRegistry(loadProviderConfigFromEnv(env, { db, authToken }), {
|
|
36948
37010
|
enabledSet: providerState_exports.listEnabled(db)
|