@f5-sales-demo/xcsh 21.19.0 → 21.19.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.
- package/package.json +8 -8
- package/src/commit/agentic/index.ts +3 -1
- package/src/commit/pipeline.ts +3 -1
- package/src/config/model-registry.ts +96 -30
- package/src/config/settings.ts +12 -6
- package/src/internal-urls/build-info.generated.ts +8 -8
- package/src/internal-urls/docs-index.generated.ts +1 -1
- package/src/main.ts +4 -1
- package/src/modes/components/model-selector.ts +265 -78
- package/src/modes/controllers/litellm-login-transaction.ts +2 -1
- package/src/modes/controllers/login-model.ts +23 -1
- package/src/modes/controllers/model-selection.ts +54 -0
- package/src/modes/controllers/selector-controller.ts +23 -41
- package/src/routing/presets.ts +6 -15
- package/src/sandbox/containment.ts +4 -6
- package/src/sdk.ts +5 -2
- package/src/session/session-manager.ts +3 -0
- package/src/task/executor.ts +3 -1
- package/src/tools/xcsh-api.ts +15 -9
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@f5-sales-demo/xcsh",
|
|
4
|
-
"version": "21.19.
|
|
4
|
+
"version": "21.19.1",
|
|
5
5
|
"description": "Coding agent CLI with read, bash, edit, write tools and session management",
|
|
6
6
|
"homepage": "https://github.com/f5-sales-demo/xcsh",
|
|
7
7
|
"author": "Can Boluk",
|
|
@@ -62,13 +62,13 @@
|
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@agentclientprotocol/sdk": "1.3.0",
|
|
65
|
-
"@f5-sales-demo/pi-agent-core": "21.19.
|
|
66
|
-
"@f5-sales-demo/pi-ai": "21.19.
|
|
67
|
-
"@f5-sales-demo/pi-natives": "21.19.
|
|
68
|
-
"@f5-sales-demo/pi-resource-management": "21.19.
|
|
69
|
-
"@f5-sales-demo/pi-tui": "21.19.
|
|
70
|
-
"@f5-sales-demo/pi-utils": "21.19.
|
|
71
|
-
"@f5-sales-demo/xcsh-stats": "21.19.
|
|
65
|
+
"@f5-sales-demo/pi-agent-core": "21.19.1",
|
|
66
|
+
"@f5-sales-demo/pi-ai": "21.19.1",
|
|
67
|
+
"@f5-sales-demo/pi-natives": "21.19.1",
|
|
68
|
+
"@f5-sales-demo/pi-resource-management": "21.19.1",
|
|
69
|
+
"@f5-sales-demo/pi-tui": "21.19.1",
|
|
70
|
+
"@f5-sales-demo/pi-utils": "21.19.1",
|
|
71
|
+
"@f5-sales-demo/xcsh-stats": "21.19.1",
|
|
72
72
|
"@mozilla/readability": "^0.6",
|
|
73
73
|
"@sinclair/typebox": "^0.34",
|
|
74
74
|
"@xterm/headless": "^6.0",
|
|
@@ -29,7 +29,9 @@ export async function runAgenticCommit(args: CommitCommandArgs): Promise<void> {
|
|
|
29
29
|
const [settings, authStorage] = await Promise.all([Settings.init({ cwd }), discoverAuthStorage()]);
|
|
30
30
|
|
|
31
31
|
process.stdout.write("● Resolving model...\n");
|
|
32
|
-
const modelRegistry = new ModelRegistry(authStorage
|
|
32
|
+
const modelRegistry = new ModelRegistry(authStorage, undefined, {
|
|
33
|
+
getProviderOrder: () => settings.get("modelProviderOrder"),
|
|
34
|
+
});
|
|
33
35
|
await modelRegistry.refresh();
|
|
34
36
|
const stagedFilesPromise = (async () => {
|
|
35
37
|
let stagedFiles = await git.diff.changedFiles(cwd, { cached: true });
|
package/src/commit/pipeline.ts
CHANGED
|
@@ -42,7 +42,9 @@ async function runLegacyCommitCommand(args: CommitCommandArgs): Promise<void> {
|
|
|
42
42
|
const settings = await Settings.init();
|
|
43
43
|
const commitSettings = settings.getGroup("commit");
|
|
44
44
|
const authStorage = await discoverAuthStorage();
|
|
45
|
-
const modelRegistry = new ModelRegistry(authStorage
|
|
45
|
+
const modelRegistry = new ModelRegistry(authStorage, undefined, {
|
|
46
|
+
getProviderOrder: () => settings.get("modelProviderOrder"),
|
|
47
|
+
});
|
|
46
48
|
await modelRegistry.refresh();
|
|
47
49
|
|
|
48
50
|
const {
|
|
@@ -770,14 +770,6 @@ function getDisabledProviderIdsFromSettings(): Set<string> {
|
|
|
770
770
|
}
|
|
771
771
|
}
|
|
772
772
|
|
|
773
|
-
function getConfiguredProviderOrderFromSettings(): string[] {
|
|
774
|
-
try {
|
|
775
|
-
return settings.get("modelProviderOrder");
|
|
776
|
-
} catch {
|
|
777
|
-
return [];
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
|
|
781
773
|
/**
|
|
782
774
|
* Model registry - loads and manages models, resolves API keys via AuthStorage.
|
|
783
775
|
*/
|
|
@@ -802,6 +794,13 @@ export class ModelRegistry {
|
|
|
802
794
|
#backgroundRefresh?: Promise<void>;
|
|
803
795
|
#lastDiscoveryWarnings: Map<string, string> = new Map();
|
|
804
796
|
#hasProbed = false;
|
|
797
|
+
#refreshQueue: Promise<void> = Promise.resolve();
|
|
798
|
+
|
|
799
|
+
#enqueueRefresh(operation: () => Promise<void>): Promise<void> {
|
|
800
|
+
const pending = this.#refreshQueue.then(operation);
|
|
801
|
+
this.#refreshQueue = pending.catch(() => {});
|
|
802
|
+
return pending;
|
|
803
|
+
}
|
|
805
804
|
// Runtime extension model overlays — persist across refresh() cycles so that
|
|
806
805
|
// models registered by extensions survive the model selector's offline reload.
|
|
807
806
|
#runtimeModelOverlays: CustomModelOverlay[] = [];
|
|
@@ -815,6 +814,7 @@ export class ModelRegistry {
|
|
|
815
814
|
constructor(
|
|
816
815
|
readonly authStorage: AuthStorage,
|
|
817
816
|
modelsPath?: string,
|
|
817
|
+
private readonly options: { getProviderOrder?: () => readonly string[] } = {},
|
|
818
818
|
) {
|
|
819
819
|
this.#modelsConfigFile = ModelsConfigFile.relocate(modelsPath);
|
|
820
820
|
this.#cacheDbPath = modelsPath ? path.join(path.dirname(modelsPath), "models.db") : undefined;
|
|
@@ -833,7 +833,11 @@ export class ModelRegistry {
|
|
|
833
833
|
/**
|
|
834
834
|
* Reload models from disk (built-in + custom from models.json).
|
|
835
835
|
*/
|
|
836
|
-
|
|
836
|
+
refresh(strategy: ModelRefreshStrategy = "online-if-uncached"): Promise<void> {
|
|
837
|
+
return this.#enqueueRefresh(() => this.#refreshAll(strategy));
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
async #refreshAll(strategy: ModelRefreshStrategy): Promise<void> {
|
|
837
841
|
// On first refresh, probe LiteLLM proxy and upgrade config with discovery if available
|
|
838
842
|
if (!this.#hasProbed && hasLiteLLMEnv()) {
|
|
839
843
|
this.#hasProbed = true;
|
|
@@ -888,8 +892,12 @@ export class ModelRegistry {
|
|
|
888
892
|
return false;
|
|
889
893
|
}
|
|
890
894
|
|
|
891
|
-
|
|
892
|
-
this.#
|
|
895
|
+
refreshProvider(providerId: string, strategy: ModelRefreshStrategy = "online"): Promise<void> {
|
|
896
|
+
return this.#enqueueRefresh(() => this.#refreshProvider(providerId, strategy));
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
async #refreshProvider(providerId: string, strategy: ModelRefreshStrategy): Promise<void> {
|
|
900
|
+
if (getDisabledProviderIdsFromSettings().has(providerId)) return;
|
|
893
901
|
for (const selector of this.#suppressedSelectors.keys()) {
|
|
894
902
|
if (selector.startsWith(`${providerId}/`)) {
|
|
895
903
|
this.#suppressedSelectors.delete(selector);
|
|
@@ -1079,7 +1087,7 @@ export class ModelRegistry {
|
|
|
1079
1087
|
api: "openai-responses",
|
|
1080
1088
|
baseUrl: Bun.env.OLLAMA_BASE_URL || "http://127.0.0.1:11434",
|
|
1081
1089
|
discovery: { type: "ollama" },
|
|
1082
|
-
optional:
|
|
1090
|
+
optional: !Bun.env.OLLAMA_BASE_URL,
|
|
1083
1091
|
});
|
|
1084
1092
|
this.#keylessProviders.add("ollama");
|
|
1085
1093
|
}
|
|
@@ -1089,7 +1097,7 @@ export class ModelRegistry {
|
|
|
1089
1097
|
api: "openai-responses",
|
|
1090
1098
|
baseUrl: Bun.env.LLAMA_CPP_BASE_URL || "http://127.0.0.1:8080",
|
|
1091
1099
|
discovery: { type: "llama.cpp" },
|
|
1092
|
-
optional:
|
|
1100
|
+
optional: !Bun.env.LLAMA_CPP_BASE_URL,
|
|
1093
1101
|
});
|
|
1094
1102
|
// Only mark as keyless if no API key is configured
|
|
1095
1103
|
if (!this.authStorage.hasAuth("llama.cpp")) {
|
|
@@ -1102,7 +1110,7 @@ export class ModelRegistry {
|
|
|
1102
1110
|
api: "openai-completions",
|
|
1103
1111
|
baseUrl: Bun.env.LM_STUDIO_BASE_URL || "http://127.0.0.1:1234/v1",
|
|
1104
1112
|
discovery: { type: "lm-studio" },
|
|
1105
|
-
optional:
|
|
1113
|
+
optional: !Bun.env.LM_STUDIO_BASE_URL,
|
|
1106
1114
|
});
|
|
1107
1115
|
this.#keylessProviders.add("lm-studio");
|
|
1108
1116
|
}
|
|
@@ -1215,9 +1223,11 @@ export class ModelRegistry {
|
|
|
1215
1223
|
strategy: ModelRefreshStrategy,
|
|
1216
1224
|
providerFilter?: ReadonlySet<string>,
|
|
1217
1225
|
): Promise<void> {
|
|
1218
|
-
const selectedDiscoverableProviders =
|
|
1219
|
-
|
|
1220
|
-
|
|
1226
|
+
const selectedDiscoverableProviders = (
|
|
1227
|
+
providerFilter
|
|
1228
|
+
? this.#discoverableProviders.filter(provider => providerFilter.has(provider.provider))
|
|
1229
|
+
: this.#discoverableProviders
|
|
1230
|
+
).filter(provider => !getDisabledProviderIdsFromSettings().has(provider.provider));
|
|
1221
1231
|
const configuredDiscoveriesPromise =
|
|
1222
1232
|
selectedDiscoverableProviders.length === 0
|
|
1223
1233
|
? Promise.resolve<Model<Api>[]>([])
|
|
@@ -1229,9 +1239,11 @@ export class ModelRegistry {
|
|
|
1229
1239
|
this.#discoverBuiltInProviderModels(strategy, providerFilter),
|
|
1230
1240
|
]);
|
|
1231
1241
|
const discovered = [...configuredDiscovered, ...builtInDiscovered];
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1242
|
+
// Replace only catalogs which completed successfully, including an empty response.
|
|
1243
|
+
const refreshed = new Set([
|
|
1244
|
+
...selectedDiscoverableProviders.map(provider => provider.provider),
|
|
1245
|
+
...discovered.map(model => model.provider),
|
|
1246
|
+
]);
|
|
1235
1247
|
const discoveredModels = this.#applyHardcodedModelPolicies(
|
|
1236
1248
|
discovered.map(model => {
|
|
1237
1249
|
const existing = this.find(model.provider, model.id);
|
|
@@ -1255,6 +1267,9 @@ export class ModelRegistry {
|
|
|
1255
1267
|
: model;
|
|
1256
1268
|
}),
|
|
1257
1269
|
);
|
|
1270
|
+
this.#models = this.#models.filter(
|
|
1271
|
+
model => !refreshed.has(model.provider) || this.#providerDiscoveryStates.get(model.provider)?.status !== "ok",
|
|
1272
|
+
);
|
|
1258
1273
|
const resolved = this.#mergeResolvedModels(this.#models, discoveredModels);
|
|
1259
1274
|
const withConfigModels = this.#mergeCustomModels(resolved, this.#customModelOverlays);
|
|
1260
1275
|
// Merge runtime extension models so they survive online discovery completion
|
|
@@ -1310,7 +1325,7 @@ export class ModelRegistry {
|
|
|
1310
1325
|
? result.models.length > 0
|
|
1311
1326
|
? "cached"
|
|
1312
1327
|
: "unavailable"
|
|
1313
|
-
: result.
|
|
1328
|
+
: !result.stale && strategy !== "offline"
|
|
1314
1329
|
? "ok"
|
|
1315
1330
|
: cached
|
|
1316
1331
|
? "cached"
|
|
@@ -1320,7 +1335,7 @@ export class ModelRegistry {
|
|
|
1320
1335
|
status,
|
|
1321
1336
|
optional: providerConfig.optional ?? false,
|
|
1322
1337
|
stale: result.stale || status === "cached",
|
|
1323
|
-
fetchedAt: discoveryError ? cached?.updatedAt : Date.now(),
|
|
1338
|
+
fetchedAt: discoveryError || strategy === "offline" ? cached?.updatedAt : Date.now(),
|
|
1324
1339
|
models: result.models.map(model => model.id),
|
|
1325
1340
|
error: discoveryError,
|
|
1326
1341
|
});
|
|
@@ -1385,7 +1400,8 @@ export class ModelRegistry {
|
|
|
1385
1400
|
)
|
|
1386
1401
|
: new Set<string>();
|
|
1387
1402
|
|
|
1388
|
-
const managerOptions = (await this.#collectBuiltInModelManagerOptions()).filter(opts => {
|
|
1403
|
+
const managerOptions = (await this.#collectBuiltInModelManagerOptions(providerFilter)).filter(opts => {
|
|
1404
|
+
if (getDisabledProviderIdsFromSettings().has(opts.providerId)) return false;
|
|
1389
1405
|
if (configuredDiscoveryProviders.has(opts.providerId)) {
|
|
1390
1406
|
return false;
|
|
1391
1407
|
}
|
|
@@ -1403,7 +1419,7 @@ export class ModelRegistry {
|
|
|
1403
1419
|
return discoveries.flat();
|
|
1404
1420
|
}
|
|
1405
1421
|
|
|
1406
|
-
async #collectBuiltInModelManagerOptions(): Promise<ModelManagerOptions<Api>[]> {
|
|
1422
|
+
async #collectBuiltInModelManagerOptions(providerFilter?: ReadonlySet<string>): Promise<ModelManagerOptions<Api>[]> {
|
|
1407
1423
|
const specialProviderDescriptors: Array<{
|
|
1408
1424
|
providerId: string;
|
|
1409
1425
|
resolveKey: (value: string | undefined) => string | undefined;
|
|
@@ -1444,12 +1460,15 @@ export class ModelRegistry {
|
|
|
1444
1460
|
},
|
|
1445
1461
|
},
|
|
1446
1462
|
];
|
|
1447
|
-
const
|
|
1463
|
+
const selected = (provider: string) =>
|
|
1464
|
+
(!providerFilter || providerFilter.has(provider)) && !getDisabledProviderIdsFromSettings().has(provider);
|
|
1465
|
+
const peekKey = (descriptor: { providerId: string }) =>
|
|
1466
|
+
selected(descriptor.providerId) ? this.#peekApiKeyForProvider(descriptor.providerId) : undefined;
|
|
1448
1467
|
// Special providers discover entitlement-scoped models through OAuth. Refresh their
|
|
1449
1468
|
// credentials before discovery: an expired access token otherwise removes newly
|
|
1450
1469
|
// entitled models from explicit CLI resolution before a request can refresh it.
|
|
1451
1470
|
const resolveSpecialKey = (descriptor: { providerId: string }) =>
|
|
1452
|
-
this.getApiKeyForProvider(descriptor.providerId);
|
|
1471
|
+
selected(descriptor.providerId) ? this.getApiKeyForProvider(descriptor.providerId) : undefined;
|
|
1453
1472
|
const [standardProviderKeys, specialKeys] = await Promise.all([
|
|
1454
1473
|
Promise.all(PROVIDER_DESCRIPTORS.map(peekKey)),
|
|
1455
1474
|
Promise.all(specialProviderDescriptors.map(resolveSpecialKey)),
|
|
@@ -1458,7 +1477,7 @@ export class ModelRegistry {
|
|
|
1458
1477
|
for (let i = 0; i < PROVIDER_DESCRIPTORS.length; i++) {
|
|
1459
1478
|
const descriptor = PROVIDER_DESCRIPTORS[i];
|
|
1460
1479
|
const apiKey = standardProviderKeys[i];
|
|
1461
|
-
if (isAuthenticated(apiKey) || descriptor.allowUnauthenticated) {
|
|
1480
|
+
if (selected(descriptor.providerId) && (isAuthenticated(apiKey) || descriptor.allowUnauthenticated)) {
|
|
1462
1481
|
options.push(
|
|
1463
1482
|
descriptor.createModelManagerOptions({
|
|
1464
1483
|
apiKey: isAuthenticated(apiKey) ? apiKey : undefined,
|
|
@@ -1472,6 +1491,17 @@ export class ModelRegistry {
|
|
|
1472
1491
|
const descriptor = specialProviderDescriptors[i];
|
|
1473
1492
|
const key = descriptor.resolveKey(specialKeys[i]);
|
|
1474
1493
|
if (!isAuthenticated(key)) {
|
|
1494
|
+
if (selected(descriptor.providerId)) {
|
|
1495
|
+
const previous = this.#providerDiscoveryStates.get(descriptor.providerId);
|
|
1496
|
+
this.#providerDiscoveryStates.set(descriptor.providerId, {
|
|
1497
|
+
provider: descriptor.providerId,
|
|
1498
|
+
status: "unauthenticated",
|
|
1499
|
+
optional: false,
|
|
1500
|
+
stale: true,
|
|
1501
|
+
fetchedAt: previous?.fetchedAt,
|
|
1502
|
+
models: previous?.models ?? [],
|
|
1503
|
+
});
|
|
1504
|
+
}
|
|
1475
1505
|
continue;
|
|
1476
1506
|
}
|
|
1477
1507
|
options.push(descriptor.createOptions(key));
|
|
@@ -1485,7 +1515,26 @@ export class ModelRegistry {
|
|
|
1485
1515
|
): Promise<Model<Api>[]> {
|
|
1486
1516
|
const previous = this.#providerDiscoveryStates.get(options.providerId);
|
|
1487
1517
|
try {
|
|
1488
|
-
|
|
1518
|
+
let discoveryError: string | undefined;
|
|
1519
|
+
const fetchDynamicModels = options.fetchDynamicModels;
|
|
1520
|
+
const manager = createModelManager({
|
|
1521
|
+
...options,
|
|
1522
|
+
cacheDbPath: this.#cacheDbPath,
|
|
1523
|
+
...(fetchDynamicModels
|
|
1524
|
+
? {
|
|
1525
|
+
fetchDynamicModels: async () => {
|
|
1526
|
+
try {
|
|
1527
|
+
const models = await fetchDynamicModels();
|
|
1528
|
+
if (models === null) discoveryError = "Live model discovery unavailable";
|
|
1529
|
+
return models;
|
|
1530
|
+
} catch (error) {
|
|
1531
|
+
discoveryError = error instanceof Error ? error.message : String(error);
|
|
1532
|
+
return null;
|
|
1533
|
+
}
|
|
1534
|
+
},
|
|
1535
|
+
}
|
|
1536
|
+
: {}),
|
|
1537
|
+
});
|
|
1489
1538
|
const result = await manager.refresh(strategy);
|
|
1490
1539
|
const models = result.models.map(model =>
|
|
1491
1540
|
model.provider === options.providerId ? model : { ...model, provider: options.providerId },
|
|
@@ -1495,7 +1544,8 @@ export class ModelRegistry {
|
|
|
1495
1544
|
status: result.stale ? "cached" : "ok",
|
|
1496
1545
|
optional: false,
|
|
1497
1546
|
stale: result.stale,
|
|
1498
|
-
fetchedAt: Date.now(),
|
|
1547
|
+
fetchedAt: result.stale ? previous?.fetchedAt : Date.now(),
|
|
1548
|
+
error: discoveryError,
|
|
1499
1549
|
models: models.map(model => model.id),
|
|
1500
1550
|
});
|
|
1501
1551
|
return models;
|
|
@@ -1942,7 +1992,7 @@ export class ModelRegistry {
|
|
|
1942
1992
|
}
|
|
1943
1993
|
|
|
1944
1994
|
#providerRank(models: readonly Model<Api>[]): Map<string, number> {
|
|
1945
|
-
const configuredProviders =
|
|
1995
|
+
const configuredProviders = this.options.getProviderOrder?.() ?? [];
|
|
1946
1996
|
const result = new Map<string, number>();
|
|
1947
1997
|
let nextRank = 0;
|
|
1948
1998
|
for (const provider of configuredProviders) {
|
|
@@ -2072,6 +2122,22 @@ export class ModelRegistry {
|
|
|
2072
2122
|
.map(provider => provider.provider);
|
|
2073
2123
|
}
|
|
2074
2124
|
|
|
2125
|
+
/** Configured and authenticated providers remain browsable even with an empty catalog. */
|
|
2126
|
+
getProviderInventory(): string[] {
|
|
2127
|
+
const disabled = getDisabledProviderIdsFromSettings();
|
|
2128
|
+
return [
|
|
2129
|
+
...new Set([
|
|
2130
|
+
...this.#configuredProviderIds,
|
|
2131
|
+
...this.#discoverableProviders
|
|
2132
|
+
.filter(
|
|
2133
|
+
provider => !provider.optional || this.#models.some(model => model.provider === provider.provider),
|
|
2134
|
+
)
|
|
2135
|
+
.map(provider => provider.provider),
|
|
2136
|
+
...this.#models.filter(model => this.authStorage.hasAuth(model.provider)).map(model => model.provider),
|
|
2137
|
+
]),
|
|
2138
|
+
].filter(provider => !disabled.has(provider));
|
|
2139
|
+
}
|
|
2140
|
+
|
|
2075
2141
|
getProviderDiscoveryState(provider: string): ProviderDiscoveryState | undefined {
|
|
2076
2142
|
return this.#providerDiscoveryStates.get(provider);
|
|
2077
2143
|
}
|
package/src/config/settings.ts
CHANGED
|
@@ -282,7 +282,7 @@ export class Settings {
|
|
|
282
282
|
* Flush any pending saves to disk.
|
|
283
283
|
* Call before exit to ensure all changes are persisted.
|
|
284
284
|
*/
|
|
285
|
-
async flush(): Promise<void> {
|
|
285
|
+
async flush(options?: { throwOnError?: boolean }): Promise<void> {
|
|
286
286
|
if (this.#saveTimer) {
|
|
287
287
|
clearTimeout(this.#saveTimer);
|
|
288
288
|
this.#saveTimer = undefined;
|
|
@@ -291,7 +291,7 @@ export class Settings {
|
|
|
291
291
|
await this.#savePromise;
|
|
292
292
|
}
|
|
293
293
|
if (this.#modified.size > 0) {
|
|
294
|
-
await this.#saveNow();
|
|
294
|
+
await this.#saveNow(options?.throwOnError);
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
297
|
|
|
@@ -588,13 +588,18 @@ export class Settings {
|
|
|
588
588
|
}
|
|
589
589
|
this.#saveTimer = setTimeout(() => {
|
|
590
590
|
this.#saveTimer = undefined;
|
|
591
|
-
this.#saveNow()
|
|
592
|
-
|
|
593
|
-
|
|
591
|
+
const pending = this.#saveNow()
|
|
592
|
+
.catch(err => {
|
|
593
|
+
logger.warn("Settings: background save failed", { error: String(err) });
|
|
594
|
+
})
|
|
595
|
+
.finally(() => {
|
|
596
|
+
if (this.#savePromise === pending) this.#savePromise = undefined;
|
|
597
|
+
});
|
|
598
|
+
this.#savePromise = pending;
|
|
594
599
|
}, 100);
|
|
595
600
|
}
|
|
596
601
|
|
|
597
|
-
async #saveNow(): Promise<void> {
|
|
602
|
+
async #saveNow(throwOnError = false): Promise<void> {
|
|
598
603
|
if (!this.#persist || !this.#configPath || this.#modified.size === 0) return;
|
|
599
604
|
|
|
600
605
|
const configPath = this.#configPath;
|
|
@@ -623,6 +628,7 @@ export class Settings {
|
|
|
623
628
|
for (const p of modifiedPaths) {
|
|
624
629
|
this.#modified.add(p);
|
|
625
630
|
}
|
|
631
|
+
if (throwOnError) throw error;
|
|
626
632
|
}
|
|
627
633
|
|
|
628
634
|
this.#rebuildMerged();
|
|
@@ -17,17 +17,17 @@ export interface BuildInfo {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export const BUILD_INFO: BuildInfo = {
|
|
20
|
-
"version": "21.19.
|
|
21
|
-
"commit": "
|
|
22
|
-
"shortCommit": "
|
|
20
|
+
"version": "21.19.1",
|
|
21
|
+
"commit": "0a54074b62ad007d3b49be533e742eaa48abc209",
|
|
22
|
+
"shortCommit": "0a54074",
|
|
23
23
|
"branch": "main",
|
|
24
|
-
"tag": "v21.19.
|
|
25
|
-
"commitDate": "2026-09-
|
|
26
|
-
"buildDate": "2026-09-
|
|
24
|
+
"tag": "v21.19.1",
|
|
25
|
+
"commitDate": "2026-09-08T18:54:45+00:00",
|
|
26
|
+
"buildDate": "2026-09-08T19:49:25.104Z",
|
|
27
27
|
"dirty": true,
|
|
28
28
|
"prNumber": "",
|
|
29
29
|
"repoUrl": "https://github.com/f5-sales-demo/xcsh",
|
|
30
30
|
"repoSlug": "f5-sales-demo/xcsh",
|
|
31
|
-
"commitUrl": "https://github.com/f5-sales-demo/xcsh/commit/
|
|
32
|
-
"releaseUrl": "https://github.com/f5-sales-demo/xcsh/releases/tag/v21.19.
|
|
31
|
+
"commitUrl": "https://github.com/f5-sales-demo/xcsh/commit/0a54074b62ad007d3b49be533e742eaa48abc209",
|
|
32
|
+
"releaseUrl": "https://github.com/f5-sales-demo/xcsh/releases/tag/v21.19.1"
|
|
33
33
|
};
|
|
@@ -28,7 +28,7 @@ export const EMBEDDED_DOCS: Readonly<Record<string, string>> = {
|
|
|
28
28
|
"en/automate-extend/skills.mdx": "---\ntitle: \"Create and load skills\"\ndescription: \"Package task-specific instructions in `SKILL.md` files at user or project scope.\"\nsidebar:\n order: 5\n label: \"Create and load skills\"\n---\n\nA skill is a directory centered on `SKILL.md`. It tells an agent when and how to perform a bounded kind of work; it is not executable proof by itself.\n\n## Where do skills live?\n\nUse project scope under `.xcsh/skills/` for repository-specific instructions and user scope under the xcsh data directory for personal skills. Project instructions should be reviewable with the repository.\n\n## How do I test one?\n\nStart xcsh with `--skills <GLOB>` to narrow discovery, invoke a prompt that matches the trigger, and inspect the tools and output. Use `--no-skills` to confirm behavior without it.\n",
|
|
29
29
|
"en/configure-secure/environment-reference.mdx": "---\ntitle: \"Environment variable reference\"\ndescription: \"Look up the environment variables that select models, credentials, tenants, execution behavior, storage roots, and diagnostics.\"\nsidebar:\n order: 2\n label: \"Environment variables\"\n---\n\nEnvironment variables carry credentials and process-scoped overrides. Settings files and command flags keep their documented precedence; a similarly named variable is not automatically supported. Provider adapters read their own vendor key names, which the adapter defines rather than this list.\n\n## Which variables configure models, providers, and search?\n\n| Variable | Controls |\n| --- | --- |\n| `PI_SMOL_MODEL` | Default model for the lightweight role, equivalent to `--smol` |\n| `PI_SLOW_MODEL` | Default model for the reasoning role, equivalent to `--slow` |\n| `PI_PLAN_MODEL` | Default model for the planning role, equivalent to `--plan` |\n| `XCSH_LOCALE` | Interface locale, ahead of `PI_LOCALE` and `LANG` |\n\nA flag beats the variable: `--smol` overrides `PI_SMOL_MODEL` for that invocation. Model selection stays a model-registry decision, so a name these variables set must still resolve through `xcsh --list-models <PROVIDER>`.\n\n## Which variables address an F5 Distributed Cloud tenant?\n\n| Variable | Controls |\n| --- | --- |\n| `XCSH_API_URL` | Tenant application programming interface (API) endpoint when no named context is active |\n| `XCSH_API_TOKEN` | Tenant API credential for that endpoint |\n| `XCSH_TENANT` | Tenant identifier reported in context status |\n| `XCSH_CONTEXT_NAME` | Name of the context the session binds to |\n| `XCSH_NAMESPACE` | Namespace applied when a command does not pass `-n` |\n| `F5XC_NAMESPACE` | Namespace source recorded in resource operation records |\n\nTreat every value in this group as a secret. Supply them through the runtime environment or a named context, never through a committed file or a command argument that reaches shell history.\n\n## Which variables configure Python, shell, and tool execution?\n\n| Variable | Controls |\n| --- | --- |\n| `PI_PYTHON_GATEWAY_URL` | Endpoint the Python tool sends code to |\n| `PI_PYTHON_GATEWAY_TOKEN` | Credential for that gateway |\n| `PI_PYTHON_SKIP_CHECK` | Skips the gateway warm-up probe |\n| `PI_SHELL_PREFIX` | Command prefix wrapped around shell tool invocations |\n| `PI_BASH_NO_LOGIN` | Runs the shell without `-l` |\n| `PI_NO_PTY` | Disables pseudo-terminal (PTY) execution, equivalent to `--no-pty` |\n| `PI_EDIT_VARIANT` | Selects the edit tool implementation and rejects an unknown value |\n\nShell execution inherits the launched process environment, subject to the sandbox and command policy. Restrict dependencies, working directory, and credentials at the process boundary rather than in the prompt.\n\n## Which variables configure storage, runtime, and diagnostics?\n\n| Variable | Controls |\n| --- | --- |\n| `PI_CODING_AGENT_DIR` | Primary agent data root, including session storage |\n| `PI_CONFIG_DIR` | Configuration root directory name, `.xcsh` by default |\n| `PI_PACKAGE_DIR` | Packaged asset directory the runtime resolves against |\n| `PI_SESSION_FILE` | Session file a child process attaches to |\n| `PI_NATIVE_VARIANT` | Hardware variant the native addon loader prefers |\n| `PI_CACHE_RETENTION` | Cache retention policy, `short` by default |\n| `PI_NO_TITLE` | Disables title auto-generation, equivalent to `--no-title` |\n| `PI_NOTIFICATIONS` | Desktop notification behavior |\n| `PI_DEBUG_STARTUP` | Startup phase diagnostics |\n| `PI_TIMING` | Phase timing output |\n| `PI_TUI_DEBUG` | Terminal user interface (TUI) rendering diagnostics |\n\nProject configuration stays under `.xcsh/` even when `PI_CODING_AGENT_DIR` moves the user root. Never print a credential-bearing variable into a diagnostic receipt; name the variable and state whether it was set.\n",
|
|
30
30
|
"en/configure-secure/index.mdx": "---\ntitle: \"Configure and secure\"\ndescription: \"Control settings, providers, credentials, networking, secrets, sandboxing, and runtime boundaries.\"\nsidebar:\n order: 0\n label: \"Overview\"\n---\n\nConfiguration controls provider routing, settings precedence, filesystem access, and credential handling.\n\n## What should I configure first?\n\n1. Inspect [settings precedence and file locations](./settings-files/).\n2. Look up any [environment variable](./environment-reference/) the deployment sets.\n3. Choose a [provider and model route](./providers-routing/).\n4. Apply [secret handling and the filesystem boundary](./secrets-obfuscation/).\n5. Set the [sandbox boundaries](./sandbox-boundaries/) that enforce those decisions.\n\nStart with defaults; add project configuration only when collaborators need the same behavior.\n",
|
|
31
|
-
"en/configure-secure/providers-routing.mdx": "---\ntitle: \"Configure providers and model routing\"\ndescription: \"Select models directly or map default, smol, slow, and plan roles.\"\nsidebar:\n order: 3\n label: \"Configure providers and model routing\"\n---\n\nxcsh resolves a requested model against available providers and credentials. A provider-qualified model name is the most explicit route.\n\n## How do I confirm a route?\n\nRun `xcsh --list-models <PROVIDER>`, then pass one returned name to `--model`. Environment keys and supported subscription sessions authenticate providers; never store tokens in committed settings.\n\n## Where does LiteLLM fit?\n\nLiteLLM is an optional provider proxy installed or checked with `xcsh setup litellm`. Its base uniform resource locator (URL) and credential belong in the runtime environment. Successful text Responses support does not imply Realtime or audio support; test the exact endpoint your workflow uses.\n",
|
|
31
|
+
"en/configure-secure/providers-routing.mdx": "---\ntitle: \"Configure providers and model routing\"\ndescription: \"Select models directly or map default, smol, slow, and plan roles.\"\nsidebar:\n order: 3\n label: \"Configure providers and model routing\"\n---\n\nxcsh resolves a requested model against available providers and credentials. A provider-qualified model name is the most explicit route.\n\n## How do I confirm a route?\n\nRun `xcsh --list-models <PROVIDER>`, then pass one returned name to `--model`. Environment keys and supported subscription sessions authenticate providers; never store tokens in committed settings.\n\n## How do I select a model in a conversation?\n\nOpen `/model`. Tab and Shift+Tab browse providers; typing searches across them. The active conversation model and saved role badges are shown separately. Configured providers remain visible when discovery is empty, unavailable, or requires authentication. Use Ctrl+R to refresh the current provider or Ctrl+L to open login.\n\nChoose a model with Enter, then choose its scope:\n\n- **Use in this conversation** is preselected. It changes this session, including resume, without changing saved role assignments.\n- **Save as default** changes the current conversation and the default for future sessions.\n- **Assign to role** saves Default, Fast/SMOL, Thorough/SLOW, Plan, or another existing role. Roles other than Default leave the current conversation unchanged.\n\nChoose a reasoning level supported by that exact model and press Enter to confirm. Inherit displays the provider default; an existing supported reasoning selection is preselected. Escape backs out without applying an unfinished choice. Failed writes are reported before badges show success.\n\nA manual conversation choice remains in effect under automatic routing. Entering planning mode uses the Plan assignment; exiting restores the prior conversation model and reasoning. Explicit `--models` scopes still limit the picker.\n\n## Where does LiteLLM fit?\n\nLiteLLM is an optional provider proxy installed or checked with `xcsh setup litellm`. Its base uniform resource locator (URL) and credential belong in the runtime environment. Successful text Responses support does not imply Realtime or audio support; test the exact endpoint your workflow uses.\n\n## How do I test licensed Vertex locally?\n\n`bun run dev` and local coding-agent binary builds load the licensed Vertex OAuth client pair automatically. Explicit `XCSH_VERTEX_OAUTH_CLIENT_ID` and `XCSH_VERTEX_OAUTH_CLIENT_SECRET` build inputs take precedence; supply both together.\n\nFor local UAT, the first launch can recover the embedded client pair from an installed official xcsh binary\nand retain it in `$XDG_CONFIG_HOME/xcsh/vertex-build.json` (default `~/.config/xcsh/vertex-build.json`). The\nfile is outside the checkout, shared by local sessions and worktrees for the same operating-system user, and\ncreated with owner-only permissions. Each worktree needs this development/build launcher to load it\nautomatically. Later launches reuse it even if the installed binary changes.\n`XCSH_VERTEX_OAUTH_CREDENTIALS_FILE` selects another private local file containing `clientId` and\n`clientSecret` fields.\n\nThe source-runtime preload keeps the pair in process memory; local compiled candidates embed it. Do not copy\nthis file or its values into source control, logs, or UAT reports. CI does not read or recover workstation\ncredentials: official release builds continue to receive the pair through GitHub secrets. Unit tests use\nfixture credentials; the live provider smoke script uses the same local preload as development UAT.\n",
|
|
32
32
|
"en/configure-secure/sandbox-boundaries.mdx": "---\ntitle: \"Set sandbox boundaries\"\ndescription: \"Constrain filesystem, shell, native, browser, and extension effects at the layer that enforces them.\"\nsidebar:\n order: 5\n label: \"Sandbox boundaries\"\n---\n\nA model instruction is not a sandbox. Enforcement belongs to the tool, host process, container, operating system, or remote service that performs the action.\n\n## How do I restrict the exposed tool set?\n\nStart with `--no-tools` or an explicit `--tools` allow-list when a run needs only conversation. Disable Model Context Protocol (MCP) and extensions separately because they can register additional capabilities. Review custom tool and hook code with the same care as any locally executed module.\n\n## How do I constrain files and processes?\n\nFilesystem-aware tools resolve paths against their configured workspace boundary. The Bash runtime applies its sandbox and output limits before returning a result; large output may spill to an artifact instead of remaining inline. Containers add process and filesystem isolation, but mounted credentials and sockets still cross that boundary.\n\n## Where does remote authority differ from local authority?\n\nBrowser, editor, Office, and remote-service integrations enforce different permission models. Confirm the active host, account, context, namespace, and target immediately before a mutation. A successful read proves connectivity, not authorization for a write.\n",
|
|
33
33
|
"en/configure-secure/secrets-obfuscation.mdx": "---\ntitle: \"Resolve secrets safely\"\ndescription: \"Reference sensitive values without placing plaintext credentials in prompts, manifests, logs, or commits.\"\nsidebar:\n order: 4\n label: \"Resolve secrets safely\"\n---\n\nKeep provider keys and F5 Distributed Cloud contexts outside prompts, session exports, logs, and committed files. Pass secrets through supported environment or protected runtime files.\n\n## How does obfuscation work?\n\nWhen secret obfuscation is enabled, values declared in the protected `secrets.yml` source are resolved at runtime and replaced in observable text before it is retained or rendered. Environment values take their documented precedence over file-backed values.\n\nObfuscation reduces accidental disclosure in supported paths; it is not encryption for a compromised process or an excuse to place secrets in prompts.\n\n## How does the filesystem boundary work?\n\nxcsh discovers a task root and guards access outside it. Add an explicit path with `--allow-path`; use `--allow-home` only when the home directory is intentionally the task root. `--no-sandbox` removes that guard and should be reserved for a controlled diagnostic.\n\n## How do I inspect the boundary?\n\nRun `xcsh sandbox check`, then start a read-only session with the smallest required `--allow-path` set. A sandbox boundary limits file discovery; it does not replace operating-system permissions or tool review.\n",
|
|
34
34
|
"en/configure-secure/settings-files.mdx": "---\ntitle: \"Understand settings precedence\"\ndescription: \"Predict which user, project, environment, and command-line value xcsh resolves.\"\nsidebar:\n order: 1\n label: \"Understand settings precedence\"\n---\n\nProject settings apply to one repository; user settings apply across projects; command flags override both for one invocation. Use `xcsh config list --json` to inspect effective values.\n\n## How is configuration resolved?\n\nDiscovery collects fixed user, project, environment, and command-line sources, normalizes each through the schema-backed configuration wrapper, then resolves values by explicit priority. Capability-specific discovery uses the same roots but owns its own merge and deduplication rules. Native `.xcsh` providers participate through the documented provider interface, not an implicit recursive scan.\n\n## Where are settings stored?\n\nRun `xcsh config path` instead of assuming a platform path. Project data uses `.xcsh/`, including `settings.json`, `mcp.json`, contexts, skills, agents, extensions, tools, hooks, commands, and `XCSH.md`. Primary user data lives under the xcsh agent directory; `PI_CODING_AGENT_DIR` can override that location.\n\n## How do I change one value?\n\n```bash\nxcsh config get <KEY>\nxcsh config set <KEY> <VALUE>\nxcsh config reset <KEY>\n```\n\nUse environment variables for credentials and ephemeral process configuration. Do not copy an entire old settings file when only one key is needed.\n",
|
package/src/main.ts
CHANGED
|
@@ -681,7 +681,10 @@ export async function runRootCommand(rawArgs: string[]): Promise<void> {
|
|
|
681
681
|
|
|
682
682
|
// Create AuthStorage and ModelRegistry upfront
|
|
683
683
|
const authStorage = await logger.time("discoverModels", discoverAuthStorage);
|
|
684
|
-
const
|
|
684
|
+
const registrySettings = await Settings.init({ cwd: getProjectDir() });
|
|
685
|
+
const modelRegistry = new ModelRegistry(authStorage, undefined, {
|
|
686
|
+
getProviderOrder: () => registrySettings.get("modelProviderOrder"),
|
|
687
|
+
});
|
|
685
688
|
|
|
686
689
|
// The three early exits below return before extensions load, so no extension flag could ever be
|
|
687
690
|
// legal on them: anything unrecognized on those paths is a typo and is reported now. Every other
|