acryl 0.1.14 → 0.1.15
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/lib/bin.js +126 -3
- package/lib/bin.js.map +1 -1
- package/lib/index.js +126 -3
- package/lib/index.js.map +1 -1
- package/package.json +1 -3
package/lib/bin.js
CHANGED
|
@@ -1628,6 +1628,14 @@ const SLASH_COMMANDS = [
|
|
|
1628
1628
|
command: "/help",
|
|
1629
1629
|
description: "Show help and available commands"
|
|
1630
1630
|
},
|
|
1631
|
+
{
|
|
1632
|
+
command: "/login",
|
|
1633
|
+
description: "Configure provider authentication (API key)"
|
|
1634
|
+
},
|
|
1635
|
+
{
|
|
1636
|
+
command: "/logout",
|
|
1637
|
+
description: "Remove provider authentication"
|
|
1638
|
+
},
|
|
1631
1639
|
{
|
|
1632
1640
|
command: "/model",
|
|
1633
1641
|
description: "Manage LLM provider profiles"
|
|
@@ -1746,6 +1754,12 @@ function runSlashCommand(command, actions) {
|
|
|
1746
1754
|
case "/model":
|
|
1747
1755
|
actions.openModelProfile();
|
|
1748
1756
|
return;
|
|
1757
|
+
case "/login":
|
|
1758
|
+
actions.login();
|
|
1759
|
+
return;
|
|
1760
|
+
case "/logout":
|
|
1761
|
+
actions.logout();
|
|
1762
|
+
return;
|
|
1749
1763
|
case "/trajectory":
|
|
1750
1764
|
actions.openTrajectory();
|
|
1751
1765
|
return;
|
|
@@ -4909,6 +4923,14 @@ async function walkDirectory(cwd) {
|
|
|
4909
4923
|
}
|
|
4910
4924
|
return results;
|
|
4911
4925
|
}
|
|
4926
|
+
//#endregion
|
|
4927
|
+
//#region src/tui/auth-guidance.ts
|
|
4928
|
+
function logoutSuccessMessage(provider) {
|
|
4929
|
+
return `Removed stored authentication for ${provider.trim() === "" ? "provider" : provider}.`;
|
|
4930
|
+
}
|
|
4931
|
+
function logoutNoneMessage() {
|
|
4932
|
+
return "No active provider is selected; nothing to log out.";
|
|
4933
|
+
}
|
|
4912
4934
|
/** Canonical ACRYL version string used by the CLI and the release smoke checks. */
|
|
4913
4935
|
const ACRYL_VERSION = createRequire(import.meta.url)("../package.json").version;
|
|
4914
4936
|
//#endregion
|
|
@@ -4969,6 +4991,12 @@ function deriveApiKeyRef(route) {
|
|
|
4969
4991
|
const upper = route.toUpperCase().replace(/[^A-Z0-9]+/g, "_");
|
|
4970
4992
|
return `${/^[A-Z_]/.test(upper) ? upper : `P_${upper}`}_API_KEY`;
|
|
4971
4993
|
}
|
|
4994
|
+
/** Nest a provider settings section at its path, e.g. `['providers','deepseek']` -> `{ providers: { deepseek: section } }`. */
|
|
4995
|
+
function nestAtPath(path, section) {
|
|
4996
|
+
let patch = section;
|
|
4997
|
+
for (let index = path.length - 1; index >= 0; index--) patch = { [path[index]]: patch };
|
|
4998
|
+
return patch;
|
|
4999
|
+
}
|
|
4972
5000
|
/** English display names for the shipped preset ids (the metadata is authored in Chinese, and there is no server-side locale resolution). */
|
|
4973
5001
|
const PRESET_LABELS = {
|
|
4974
5002
|
standard: "Standard mode",
|
|
@@ -5205,6 +5233,34 @@ async function attachSession(host, resumeId) {
|
|
|
5205
5233
|
store.openModelProfile();
|
|
5206
5234
|
loadProviders();
|
|
5207
5235
|
},
|
|
5236
|
+
login() {
|
|
5237
|
+
store.openModelProfile();
|
|
5238
|
+
loadProviders();
|
|
5239
|
+
},
|
|
5240
|
+
logout() {
|
|
5241
|
+
(async () => {
|
|
5242
|
+
const credentialsSvc = host.ctx.get("credentials");
|
|
5243
|
+
if (credentialsSvc === void 0) {
|
|
5244
|
+
store.setNotice("Credentials are not available in this profile.");
|
|
5245
|
+
return;
|
|
5246
|
+
}
|
|
5247
|
+
const selection = host.ctx.get("agentDefaultModel")?.currentSelection?.();
|
|
5248
|
+
const overlay = store.getSnapshot().overlay;
|
|
5249
|
+
const rows = overlay.kind === "modelProfile" ? overlay.modelProfile.providers : void 0;
|
|
5250
|
+
const row = rows?.find((entry) => entry.route === selection?.provider) ?? (rows !== void 0 && rows.length === 1 ? rows[0] : void 0);
|
|
5251
|
+
if (row === void 0) {
|
|
5252
|
+
store.setNotice(logoutNoneMessage());
|
|
5253
|
+
return;
|
|
5254
|
+
}
|
|
5255
|
+
try {
|
|
5256
|
+
await credentialsSvc.unset(row.apiKeyRef);
|
|
5257
|
+
store.setNotice(logoutSuccessMessage(row.displayName));
|
|
5258
|
+
loadProviders();
|
|
5259
|
+
} catch (error) {
|
|
5260
|
+
store.setNotice(`logout failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
5261
|
+
}
|
|
5262
|
+
})();
|
|
5263
|
+
},
|
|
5208
5264
|
openTrajectory() {
|
|
5209
5265
|
store.openTrajectory();
|
|
5210
5266
|
},
|
|
@@ -5241,9 +5297,76 @@ async function attachSession(host, resumeId) {
|
|
|
5241
5297
|
draft: void 0
|
|
5242
5298
|
});
|
|
5243
5299
|
},
|
|
5244
|
-
editProvider() {
|
|
5245
|
-
|
|
5246
|
-
|
|
5300
|
+
editProvider(route) {
|
|
5301
|
+
const overlay = store.getSnapshot().overlay;
|
|
5302
|
+
if (overlay.kind !== "modelProfile") return;
|
|
5303
|
+
const row = overlay.modelProfile.providers?.find((entry) => entry.route === route);
|
|
5304
|
+
if (row === void 0) return;
|
|
5305
|
+
const draft = {
|
|
5306
|
+
route: row.route,
|
|
5307
|
+
isNew: false,
|
|
5308
|
+
settingsNs: row.settingsNs,
|
|
5309
|
+
settingsPath: row.settingsPath,
|
|
5310
|
+
displayName: row.displayName,
|
|
5311
|
+
api: row.api ?? "",
|
|
5312
|
+
baseURL: row.baseURL ?? "",
|
|
5313
|
+
apiKeyRef: row.apiKeyRef,
|
|
5314
|
+
apiKeyConfigured: row.apiKeyConfigured,
|
|
5315
|
+
apiKeyDraft: "",
|
|
5316
|
+
models: row.models,
|
|
5317
|
+
revision: row.revision
|
|
5318
|
+
};
|
|
5319
|
+
store.updateModelProfile({
|
|
5320
|
+
view: "form",
|
|
5321
|
+
draft,
|
|
5322
|
+
formKey: overlay.modelProfile.formKey + 1
|
|
5323
|
+
});
|
|
5324
|
+
},
|
|
5325
|
+
saveProvider(draft) {
|
|
5326
|
+
(async () => {
|
|
5327
|
+
const settingsSvc = host.ctx.get("settings");
|
|
5328
|
+
const credentialsSvc = host.ctx.get("credentials");
|
|
5329
|
+
if (settingsSvc === void 0 || credentialsSvc === void 0) {
|
|
5330
|
+
store.setNotice("Provider settings are not available in this profile.");
|
|
5331
|
+
return;
|
|
5332
|
+
}
|
|
5333
|
+
try {
|
|
5334
|
+
const key = draft.apiKeyDraft.trim();
|
|
5335
|
+
if (key !== "") await credentialsSvc.set(draft.apiKeyRef, key);
|
|
5336
|
+
const section = {
|
|
5337
|
+
displayName: draft.displayName,
|
|
5338
|
+
api: draft.api,
|
|
5339
|
+
baseURL: draft.baseURL,
|
|
5340
|
+
apiKeyEnv: draft.apiKeyRef,
|
|
5341
|
+
models: draft.models
|
|
5342
|
+
};
|
|
5343
|
+
await settingsSvc.update(draft.settingsNs, nestAtPath(draft.settingsPath, section), draft.revision);
|
|
5344
|
+
store.setNotice(`Saved ${draft.displayName || draft.route}.`);
|
|
5345
|
+
store.updateModelProfile({ view: "list" });
|
|
5346
|
+
loadProviders();
|
|
5347
|
+
} catch (error) {
|
|
5348
|
+
store.setNotice(`save failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
5349
|
+
}
|
|
5350
|
+
})();
|
|
5351
|
+
},
|
|
5352
|
+
deleteProvider(row) {
|
|
5353
|
+
(async () => {
|
|
5354
|
+
const settingsSvc = host.ctx.get("settings");
|
|
5355
|
+
const credentialsSvc = host.ctx.get("credentials");
|
|
5356
|
+
if (settingsSvc === void 0 || credentialsSvc === void 0) {
|
|
5357
|
+
store.setNotice("Provider settings are not available in this profile.");
|
|
5358
|
+
return;
|
|
5359
|
+
}
|
|
5360
|
+
try {
|
|
5361
|
+
await credentialsSvc.unset(row.apiKeyRef);
|
|
5362
|
+
await settingsSvc.update(row.settingsNs, nestAtPath(row.settingsPath, {}), row.revision);
|
|
5363
|
+
store.setNotice(`Removed ${row.displayName}.`);
|
|
5364
|
+
loadProviders();
|
|
5365
|
+
} catch (error) {
|
|
5366
|
+
store.setNotice(`delete failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
5367
|
+
}
|
|
5368
|
+
})();
|
|
5369
|
+
},
|
|
5247
5370
|
discoverModelsForDraft() {},
|
|
5248
5371
|
setActiveModel() {},
|
|
5249
5372
|
closeTrajectory() {
|