@sandagent/runner-cli 0.9.9-beta.1 → 0.9.9-beta.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/dist/bundle.mjs +9 -24
- package/package.json +5 -5
package/dist/bundle.mjs
CHANGED
|
@@ -1302,26 +1302,6 @@ function parseModelSpec(model) {
|
|
|
1302
1302
|
function getEnvValue(optionsEnv, name) {
|
|
1303
1303
|
return optionsEnv?.[name] ?? process.env[name];
|
|
1304
1304
|
}
|
|
1305
|
-
function pushRunnerEnvToProcess(env) {
|
|
1306
|
-
if (!env)
|
|
1307
|
-
return () => {
|
|
1308
|
-
};
|
|
1309
|
-
const backup = {};
|
|
1310
|
-
for (const [key, value] of Object.entries(env)) {
|
|
1311
|
-
if (typeof value !== "string")
|
|
1312
|
-
continue;
|
|
1313
|
-
backup[key] = process.env[key];
|
|
1314
|
-
process.env[key] = value;
|
|
1315
|
-
}
|
|
1316
|
-
return () => {
|
|
1317
|
-
for (const [key, prev] of Object.entries(backup)) {
|
|
1318
|
-
if (prev === void 0)
|
|
1319
|
-
delete process.env[key];
|
|
1320
|
-
else
|
|
1321
|
-
process.env[key] = prev;
|
|
1322
|
-
}
|
|
1323
|
-
};
|
|
1324
|
-
}
|
|
1325
1305
|
function applyModelOverrides(model, provider, optionsEnv) {
|
|
1326
1306
|
if (model == null)
|
|
1327
1307
|
return;
|
|
@@ -1418,19 +1398,20 @@ function createPiRunner(options = {}) {
|
|
|
1418
1398
|
}
|
|
1419
1399
|
const { provider, modelName } = parseModelSpec(modelSpec.trim());
|
|
1420
1400
|
const cwd = options.cwd || process.cwd();
|
|
1401
|
+
const apiKeyEnvKey = `${provider.toUpperCase().replace(/-/g, "_")}_API_KEY`;
|
|
1402
|
+
const inlineApiKey = typeof options.env?.[apiKeyEnvKey] === "string" && options.env[apiKeyEnvKey].length > 0 ? options.env[apiKeyEnvKey] : void 0;
|
|
1421
1403
|
const modelRegistry = new ModelRegistry(AuthStorage.create());
|
|
1422
1404
|
const defaultModel = getModel(provider, modelName);
|
|
1423
1405
|
let model = defaultModel ?? modelRegistry.find(provider, modelName);
|
|
1424
1406
|
if (model == null) {
|
|
1425
1407
|
const baseUrlEnvKey = `${provider.toUpperCase().replace(/-/g, "_")}_BASE_URL`;
|
|
1426
|
-
const apiKeyEnvKey = `${provider.toUpperCase().replace(/-/g, "_")}_API_KEY`;
|
|
1427
1408
|
const baseUrl = getEnvValue(options.env, baseUrlEnvKey) ?? getEnvValue(options.env, "OPENAI_BASE_URL");
|
|
1428
1409
|
if (!baseUrl) {
|
|
1429
1410
|
throw new Error(`Pi runner: model "${modelSpec}" not found in built-in catalog. Set ${baseUrlEnvKey} (or OPENAI_BASE_URL) to auto-register it.`);
|
|
1430
1411
|
}
|
|
1431
1412
|
modelRegistry.registerProvider(provider, {
|
|
1432
1413
|
baseUrl,
|
|
1433
|
-
apiKey: apiKeyEnvKey,
|
|
1414
|
+
apiKey: inlineApiKey ?? apiKeyEnvKey,
|
|
1434
1415
|
api: "openai-completions",
|
|
1435
1416
|
models: [
|
|
1436
1417
|
{
|
|
@@ -1453,7 +1434,9 @@ function createPiRunner(options = {}) {
|
|
|
1453
1434
|
applyModelOverrides(model, provider, options.env);
|
|
1454
1435
|
return {
|
|
1455
1436
|
async *run(userInput) {
|
|
1456
|
-
|
|
1437
|
+
if (inlineApiKey !== void 0) {
|
|
1438
|
+
modelRegistry.authStorage.setRuntimeApiKey(provider, inlineApiKey);
|
|
1439
|
+
}
|
|
1457
1440
|
try {
|
|
1458
1441
|
const resume = options.sessionId?.trim();
|
|
1459
1442
|
const sessionManager = await (async () => {
|
|
@@ -1664,7 +1647,9 @@ ${options.systemPrompt}` : options.systemPrompt);
|
|
|
1664
1647
|
session.dispose();
|
|
1665
1648
|
}
|
|
1666
1649
|
} finally {
|
|
1667
|
-
|
|
1650
|
+
if (inlineApiKey !== void 0) {
|
|
1651
|
+
modelRegistry.authStorage.removeRuntimeApiKey(provider);
|
|
1652
|
+
}
|
|
1668
1653
|
}
|
|
1669
1654
|
}
|
|
1670
1655
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sandagent/runner-cli",
|
|
3
|
-
"version": "0.9.9-beta.
|
|
3
|
+
"version": "0.9.9-beta.2",
|
|
4
4
|
"description": "SandAgent Runner CLI - Like gemini-cli or claude-code, runs in your local terminal with AI SDK UI streaming",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -54,11 +54,11 @@
|
|
|
54
54
|
"typescript": "^5.3.0",
|
|
55
55
|
"vitest": "^1.6.1",
|
|
56
56
|
"@sandagent/runner-claude": "0.6.2",
|
|
57
|
-
"@sandagent/runner-gemini": "0.6.2",
|
|
58
|
-
"@sandagent/runner-core": "0.1.0",
|
|
59
|
-
"@sandagent/runner-opencode": "0.6.2",
|
|
60
57
|
"@sandagent/runner-codex": "0.6.2",
|
|
61
|
-
"@sandagent/runner-
|
|
58
|
+
"@sandagent/runner-core": "0.1.0",
|
|
59
|
+
"@sandagent/runner-gemini": "0.6.2",
|
|
60
|
+
"@sandagent/runner-pi": "0.6.3",
|
|
61
|
+
"@sandagent/runner-opencode": "0.6.2"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"build": "tsc && pnpm bundle",
|