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/index.js
CHANGED
|
@@ -1609,6 +1609,14 @@ const SLASH_COMMANDS = [
|
|
|
1609
1609
|
command: "/help",
|
|
1610
1610
|
description: "Show help and available commands"
|
|
1611
1611
|
},
|
|
1612
|
+
{
|
|
1613
|
+
command: "/login",
|
|
1614
|
+
description: "Configure provider authentication (API key)"
|
|
1615
|
+
},
|
|
1616
|
+
{
|
|
1617
|
+
command: "/logout",
|
|
1618
|
+
description: "Remove provider authentication"
|
|
1619
|
+
},
|
|
1612
1620
|
{
|
|
1613
1621
|
command: "/model",
|
|
1614
1622
|
description: "Manage LLM provider profiles"
|
|
@@ -1727,6 +1735,12 @@ function runSlashCommand(command, actions) {
|
|
|
1727
1735
|
case "/model":
|
|
1728
1736
|
actions.openModelProfile();
|
|
1729
1737
|
return;
|
|
1738
|
+
case "/login":
|
|
1739
|
+
actions.login();
|
|
1740
|
+
return;
|
|
1741
|
+
case "/logout":
|
|
1742
|
+
actions.logout();
|
|
1743
|
+
return;
|
|
1730
1744
|
case "/trajectory":
|
|
1731
1745
|
actions.openTrajectory();
|
|
1732
1746
|
return;
|
|
@@ -4891,6 +4905,14 @@ async function walkDirectory(cwd) {
|
|
|
4891
4905
|
return results;
|
|
4892
4906
|
}
|
|
4893
4907
|
//#endregion
|
|
4908
|
+
//#region src/tui/auth-guidance.ts
|
|
4909
|
+
function logoutSuccessMessage(provider) {
|
|
4910
|
+
return `Removed stored authentication for ${provider.trim() === "" ? "provider" : provider}.`;
|
|
4911
|
+
}
|
|
4912
|
+
function logoutNoneMessage() {
|
|
4913
|
+
return "No active provider is selected; nothing to log out.";
|
|
4914
|
+
}
|
|
4915
|
+
//#endregion
|
|
4894
4916
|
//#region src/tui-app/session.ts
|
|
4895
4917
|
/**
|
|
4896
4918
|
* ACRYL terminal host adapter: brings up one normal local runtime, opens or
|
|
@@ -4948,6 +4970,12 @@ function deriveApiKeyRef(route) {
|
|
|
4948
4970
|
const upper = route.toUpperCase().replace(/[^A-Z0-9]+/g, "_");
|
|
4949
4971
|
return `${/^[A-Z_]/.test(upper) ? upper : `P_${upper}`}_API_KEY`;
|
|
4950
4972
|
}
|
|
4973
|
+
/** Nest a provider settings section at its path, e.g. `['providers','deepseek']` -> `{ providers: { deepseek: section } }`. */
|
|
4974
|
+
function nestAtPath(path, section) {
|
|
4975
|
+
let patch = section;
|
|
4976
|
+
for (let index = path.length - 1; index >= 0; index--) patch = { [path[index]]: patch };
|
|
4977
|
+
return patch;
|
|
4978
|
+
}
|
|
4951
4979
|
/** English display names for the shipped preset ids (the metadata is authored in Chinese, and there is no server-side locale resolution). */
|
|
4952
4980
|
const PRESET_LABELS = {
|
|
4953
4981
|
standard: "Standard mode",
|
|
@@ -5184,6 +5212,34 @@ async function attachSession(host, resumeId) {
|
|
|
5184
5212
|
store.openModelProfile();
|
|
5185
5213
|
loadProviders();
|
|
5186
5214
|
},
|
|
5215
|
+
login() {
|
|
5216
|
+
store.openModelProfile();
|
|
5217
|
+
loadProviders();
|
|
5218
|
+
},
|
|
5219
|
+
logout() {
|
|
5220
|
+
(async () => {
|
|
5221
|
+
const credentialsSvc = host.ctx.get("credentials");
|
|
5222
|
+
if (credentialsSvc === void 0) {
|
|
5223
|
+
store.setNotice("Credentials are not available in this profile.");
|
|
5224
|
+
return;
|
|
5225
|
+
}
|
|
5226
|
+
const selection = host.ctx.get("agentDefaultModel")?.currentSelection?.();
|
|
5227
|
+
const overlay = store.getSnapshot().overlay;
|
|
5228
|
+
const rows = overlay.kind === "modelProfile" ? overlay.modelProfile.providers : void 0;
|
|
5229
|
+
const row = rows?.find((entry) => entry.route === selection?.provider) ?? (rows !== void 0 && rows.length === 1 ? rows[0] : void 0);
|
|
5230
|
+
if (row === void 0) {
|
|
5231
|
+
store.setNotice(logoutNoneMessage());
|
|
5232
|
+
return;
|
|
5233
|
+
}
|
|
5234
|
+
try {
|
|
5235
|
+
await credentialsSvc.unset(row.apiKeyRef);
|
|
5236
|
+
store.setNotice(logoutSuccessMessage(row.displayName));
|
|
5237
|
+
loadProviders();
|
|
5238
|
+
} catch (error) {
|
|
5239
|
+
store.setNotice(`logout failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
5240
|
+
}
|
|
5241
|
+
})();
|
|
5242
|
+
},
|
|
5187
5243
|
openTrajectory() {
|
|
5188
5244
|
store.openTrajectory();
|
|
5189
5245
|
},
|
|
@@ -5220,9 +5276,76 @@ async function attachSession(host, resumeId) {
|
|
|
5220
5276
|
draft: void 0
|
|
5221
5277
|
});
|
|
5222
5278
|
},
|
|
5223
|
-
editProvider() {
|
|
5224
|
-
|
|
5225
|
-
|
|
5279
|
+
editProvider(route) {
|
|
5280
|
+
const overlay = store.getSnapshot().overlay;
|
|
5281
|
+
if (overlay.kind !== "modelProfile") return;
|
|
5282
|
+
const row = overlay.modelProfile.providers?.find((entry) => entry.route === route);
|
|
5283
|
+
if (row === void 0) return;
|
|
5284
|
+
const draft = {
|
|
5285
|
+
route: row.route,
|
|
5286
|
+
isNew: false,
|
|
5287
|
+
settingsNs: row.settingsNs,
|
|
5288
|
+
settingsPath: row.settingsPath,
|
|
5289
|
+
displayName: row.displayName,
|
|
5290
|
+
api: row.api ?? "",
|
|
5291
|
+
baseURL: row.baseURL ?? "",
|
|
5292
|
+
apiKeyRef: row.apiKeyRef,
|
|
5293
|
+
apiKeyConfigured: row.apiKeyConfigured,
|
|
5294
|
+
apiKeyDraft: "",
|
|
5295
|
+
models: row.models,
|
|
5296
|
+
revision: row.revision
|
|
5297
|
+
};
|
|
5298
|
+
store.updateModelProfile({
|
|
5299
|
+
view: "form",
|
|
5300
|
+
draft,
|
|
5301
|
+
formKey: overlay.modelProfile.formKey + 1
|
|
5302
|
+
});
|
|
5303
|
+
},
|
|
5304
|
+
saveProvider(draft) {
|
|
5305
|
+
(async () => {
|
|
5306
|
+
const settingsSvc = host.ctx.get("settings");
|
|
5307
|
+
const credentialsSvc = host.ctx.get("credentials");
|
|
5308
|
+
if (settingsSvc === void 0 || credentialsSvc === void 0) {
|
|
5309
|
+
store.setNotice("Provider settings are not available in this profile.");
|
|
5310
|
+
return;
|
|
5311
|
+
}
|
|
5312
|
+
try {
|
|
5313
|
+
const key = draft.apiKeyDraft.trim();
|
|
5314
|
+
if (key !== "") await credentialsSvc.set(draft.apiKeyRef, key);
|
|
5315
|
+
const section = {
|
|
5316
|
+
displayName: draft.displayName,
|
|
5317
|
+
api: draft.api,
|
|
5318
|
+
baseURL: draft.baseURL,
|
|
5319
|
+
apiKeyEnv: draft.apiKeyRef,
|
|
5320
|
+
models: draft.models
|
|
5321
|
+
};
|
|
5322
|
+
await settingsSvc.update(draft.settingsNs, nestAtPath(draft.settingsPath, section), draft.revision);
|
|
5323
|
+
store.setNotice(`Saved ${draft.displayName || draft.route}.`);
|
|
5324
|
+
store.updateModelProfile({ view: "list" });
|
|
5325
|
+
loadProviders();
|
|
5326
|
+
} catch (error) {
|
|
5327
|
+
store.setNotice(`save failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
5328
|
+
}
|
|
5329
|
+
})();
|
|
5330
|
+
},
|
|
5331
|
+
deleteProvider(row) {
|
|
5332
|
+
(async () => {
|
|
5333
|
+
const settingsSvc = host.ctx.get("settings");
|
|
5334
|
+
const credentialsSvc = host.ctx.get("credentials");
|
|
5335
|
+
if (settingsSvc === void 0 || credentialsSvc === void 0) {
|
|
5336
|
+
store.setNotice("Provider settings are not available in this profile.");
|
|
5337
|
+
return;
|
|
5338
|
+
}
|
|
5339
|
+
try {
|
|
5340
|
+
await credentialsSvc.unset(row.apiKeyRef);
|
|
5341
|
+
await settingsSvc.update(row.settingsNs, nestAtPath(row.settingsPath, {}), row.revision);
|
|
5342
|
+
store.setNotice(`Removed ${row.displayName}.`);
|
|
5343
|
+
loadProviders();
|
|
5344
|
+
} catch (error) {
|
|
5345
|
+
store.setNotice(`delete failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
5346
|
+
}
|
|
5347
|
+
})();
|
|
5348
|
+
},
|
|
5226
5349
|
discoverModelsForDraft() {},
|
|
5227
5350
|
setActiveModel() {},
|
|
5228
5351
|
closeTrajectory() {
|