acryl 0.1.14 → 0.1.16
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 +64 -3
- package/lib/bin.js +328 -7
- package/lib/bin.js.map +1 -1
- package/lib/index.js +328 -7
- package/lib/index.js.map +1 -1
- package/package.json +12 -7
package/README.md
CHANGED
|
@@ -1,5 +1,66 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ACRYL
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**A persistent, agent-agnostic coding environment.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Keep your project, context, and workflow while changing coding agents.
|
|
6
|
+
|
|
7
|
+
ACRYL owns the persistent development environment - workspace, context, tasks, artifacts, sessions, and handoffs - while coding agents remain replaceable workers. Use Claude Code, Codex, OpenCode, Pi, Gemini CLI, DeepSeek, ACP-compatible agents, or your own agent without tying your project to any one of them.
|
|
8
|
+
|
|
9
|
+
**Same project. Same context. Same work. Different agents.**
|
|
10
|
+
|
|
11
|
+
ACRYL is built to adapt to your workflow, not lock you into an agent. Extend it with agents, tools, context systems, memory, workflows, terminals, UI capabilities, and Cordis plugins.
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install -g acryl
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Run
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
acryl # terminal client (default)
|
|
23
|
+
acryl web # serve the local ACRYL web runtime
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
A standalone Desktop application is distributed separately.
|
|
27
|
+
|
|
28
|
+
## Why ACRYL?
|
|
29
|
+
|
|
30
|
+
Coding agents are temporary. Your development context shouldn't be.
|
|
31
|
+
|
|
32
|
+
Most coding agents own their own sessions, context, tools, and history. Switching agents usually means starting over, copying context manually, or maintaining several disconnected development environments.
|
|
33
|
+
|
|
34
|
+
ACRYL reverses that relationship:
|
|
35
|
+
|
|
36
|
+
```text
|
|
37
|
+
Project and context
|
|
38
|
+
↓
|
|
39
|
+
ACRYL
|
|
40
|
+
↓
|
|
41
|
+
Coding agents
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The project belongs to ACRYL. Agents enter, work, and leave.
|
|
45
|
+
|
|
46
|
+
## Make it yours
|
|
47
|
+
|
|
48
|
+
ACRYL is built around composable capabilities rather than a sealed application.
|
|
49
|
+
|
|
50
|
+
Agents, models, tools, memory systems, context engines, terminals, workflows, editors, and UI surfaces can be provided as replaceable capabilities.
|
|
51
|
+
|
|
52
|
+
Underneath, ACRYL uses Cordis for lifecycle-managed plugins, replaceable services, reactive dependency injection, typed events, scoped composition, and reversible effects.
|
|
53
|
+
|
|
54
|
+
The goal is simple:
|
|
55
|
+
|
|
56
|
+
**Change the agent, extend the environment, keep the work.**
|
|
57
|
+
|
|
58
|
+
## Links
|
|
59
|
+
|
|
60
|
+
- Website: https://acryl.dev
|
|
61
|
+
- Source: https://github.com/acryldev/acryl
|
|
62
|
+
- Discord: https://discord.gg/cY9KXMex69
|
|
63
|
+
|
|
64
|
+
## License
|
|
65
|
+
|
|
66
|
+
MIT
|
package/lib/bin.js
CHANGED
|
@@ -3,14 +3,15 @@ import { createRequire } from "node:module";
|
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { existsSync, realpathSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { dirname, join, relative, resolve } from "node:path";
|
|
6
|
-
import { spawn } from "node:child_process";
|
|
7
|
-
import { randomUUID } from "node:crypto";
|
|
6
|
+
import { execFile, spawn } from "node:child_process";
|
|
7
|
+
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
8
8
|
import { BlockAssembler, createUserMessage } from "@deepseek-ai/dsh-llm";
|
|
9
9
|
import { SessionId } from "@deepseek-ai/dsh-session";
|
|
10
10
|
import { DEFAULT_PROFILE_BUNDLES, boot, composeEntries, healProfilesModuleFallback, initProfile, loadProfile, resolveProfileDir } from "@deepseek-ai/dsh-app-boot";
|
|
11
11
|
import { diffLines } from "diff";
|
|
12
12
|
import { Container, Editor, HStack, Key, KeybindingsManager, ProcessTerminal, ScrollView, TUI_KEYBINDINGS, Text, TuiAltScreen, VStack, matchesKey, setKeybindings, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
|
|
13
13
|
import { readdir } from "node:fs/promises";
|
|
14
|
+
import { createServer } from "node:http";
|
|
14
15
|
import { ManualCompactionError } from "@deepseek-ai/dsh-compaction";
|
|
15
16
|
import { GoalError } from "@deepseek-ai/dsh-goal";
|
|
16
17
|
//#region src/cli/node-launcher.ts
|
|
@@ -1628,6 +1629,14 @@ const SLASH_COMMANDS = [
|
|
|
1628
1629
|
command: "/help",
|
|
1629
1630
|
description: "Show help and available commands"
|
|
1630
1631
|
},
|
|
1632
|
+
{
|
|
1633
|
+
command: "/login",
|
|
1634
|
+
description: "Configure provider authentication (API key)"
|
|
1635
|
+
},
|
|
1636
|
+
{
|
|
1637
|
+
command: "/logout",
|
|
1638
|
+
description: "Remove provider authentication"
|
|
1639
|
+
},
|
|
1631
1640
|
{
|
|
1632
1641
|
command: "/model",
|
|
1633
1642
|
description: "Manage LLM provider profiles"
|
|
@@ -1746,6 +1755,12 @@ function runSlashCommand(command, actions) {
|
|
|
1746
1755
|
case "/model":
|
|
1747
1756
|
actions.openModelProfile();
|
|
1748
1757
|
return;
|
|
1758
|
+
case "/login":
|
|
1759
|
+
actions.login();
|
|
1760
|
+
return;
|
|
1761
|
+
case "/logout":
|
|
1762
|
+
actions.logout();
|
|
1763
|
+
return;
|
|
1749
1764
|
case "/trajectory":
|
|
1750
1765
|
actions.openTrajectory();
|
|
1751
1766
|
return;
|
|
@@ -3154,12 +3169,14 @@ var ModelProfileOverlay = class {
|
|
|
3154
3169
|
const marker = row.configured ? "● " : "○ ";
|
|
3155
3170
|
const active = row.live ? " (active)" : "";
|
|
3156
3171
|
const noKey = row.apiKeyConfigured ? "" : " [no api key]";
|
|
3172
|
+
const oauthStatus = row.oauth === void 0 ? "" : row.grantConfigured ? " [oauth ✓]" : " [oauth]";
|
|
3157
3173
|
const confirm = this.confirmDelete === index ? " — press d again to delete" : "";
|
|
3158
|
-
const text = `${index === selected ? "› " : " "}${marker}${row.displayName}${active}${noKey}${confirm}`;
|
|
3174
|
+
const text = `${index === selected ? "› " : " "}${marker}${row.displayName}${active}${noKey}${oauthStatus}${confirm}`;
|
|
3159
3175
|
lines.push(index === selected ? invert$4(text) : text);
|
|
3160
3176
|
});
|
|
3161
3177
|
if (providers?.length === 0) lines.push(muted$9("No providers configured yet — press a to add one."));
|
|
3162
|
-
|
|
3178
|
+
const hasOauth = providers?.some((row) => row.oauth !== void 0) ?? false;
|
|
3179
|
+
lines.push(muted$9(`↑↓ select · enter edit · a add · d delete · s set active model${hasOauth ? " · o login with oauth" : ""} · esc close`));
|
|
3163
3180
|
return lines;
|
|
3164
3181
|
}
|
|
3165
3182
|
handleListInput(data, mp) {
|
|
@@ -3196,6 +3213,11 @@ var ModelProfileOverlay = class {
|
|
|
3196
3213
|
if (model !== void 0) this.actions.setActiveModel(row.route, model.id);
|
|
3197
3214
|
return;
|
|
3198
3215
|
}
|
|
3216
|
+
if (data === "o") {
|
|
3217
|
+
const row = providers[selected];
|
|
3218
|
+
if (row.oauth !== void 0) this.actions.loginWithOAuth(row.route);
|
|
3219
|
+
return;
|
|
3220
|
+
}
|
|
3199
3221
|
if (data === "d") {
|
|
3200
3222
|
if (this.confirmDelete === selected) {
|
|
3201
3223
|
this.confirmDelete = void 0;
|
|
@@ -4909,6 +4931,178 @@ async function walkDirectory(cwd) {
|
|
|
4909
4931
|
}
|
|
4910
4932
|
return results;
|
|
4911
4933
|
}
|
|
4934
|
+
//#endregion
|
|
4935
|
+
//#region src/tui/auth-guidance.ts
|
|
4936
|
+
function logoutSuccessMessage(provider) {
|
|
4937
|
+
return `Removed stored authentication for ${provider.trim() === "" ? "provider" : provider}.`;
|
|
4938
|
+
}
|
|
4939
|
+
function logoutNoneMessage() {
|
|
4940
|
+
return "No active provider is selected; nothing to log out.";
|
|
4941
|
+
}
|
|
4942
|
+
/** The DSH credential-key segment grammar: lowercase hyphenated identifier. */
|
|
4943
|
+
const KEY_SEGMENT_PATTERN = /^[a-z][a-z0-9-]*$/;
|
|
4944
|
+
/**
|
|
4945
|
+
* Build the `<scope>/<id>` CredentialKey address for one provider's grant
|
|
4946
|
+
* record. Mirrors the DSH `credentialKey` grammar so the record space stays
|
|
4947
|
+
* valid without a runtime dependency on `@deepseek-ai/dsh-credentials`.
|
|
4948
|
+
*/
|
|
4949
|
+
function grantKey(meta) {
|
|
4950
|
+
const scope = meta.ownerScope ?? "acryl-tui";
|
|
4951
|
+
for (const segment of [scope, meta.route]) if (!KEY_SEGMENT_PATTERN.test(segment)) throw new TypeError(`credential key segment "${segment}" must be a lowercase hyphenated identifier`);
|
|
4952
|
+
return `${scope}/${meta.route}`;
|
|
4953
|
+
}
|
|
4954
|
+
/** The OAuth-capable providers shipped with ACRYL. Empty until a real provider is wired. */
|
|
4955
|
+
const OAUTH_PROVIDERS = [];
|
|
4956
|
+
/** Resolve metadata for a provider route, or undefined when it is not OAuth-capable. */
|
|
4957
|
+
function oauthProviderFor(route) {
|
|
4958
|
+
return OAUTH_PROVIDERS.find((entry) => entry.route === route);
|
|
4959
|
+
}
|
|
4960
|
+
//#endregion
|
|
4961
|
+
//#region src/tui/oauth/flow.ts
|
|
4962
|
+
/**
|
|
4963
|
+
* OAuth authorization-code flow (L010 + L011): PKCE, a one-shot loopback
|
|
4964
|
+
* redirect listener, the code→token exchange, and grant persistence through
|
|
4965
|
+
* the `credentials` record seam (`modifyRecord`/`readRecord`/`deleteRecord`).
|
|
4966
|
+
*
|
|
4967
|
+
* The flow owns exactly one transient resource — an `http.Server` bound to
|
|
4968
|
+
* `127.0.0.1:0` — which is opened and closed inside `runOAuthLogin`. The PKCE
|
|
4969
|
+
* verifier and `state` are in-memory only and never surface to a transcript.
|
|
4970
|
+
* @module @tomowang/dsh-tui/tui/oauth/flow
|
|
4971
|
+
*/
|
|
4972
|
+
function base64Url(input) {
|
|
4973
|
+
return input.toString("base64url");
|
|
4974
|
+
}
|
|
4975
|
+
function makePkce() {
|
|
4976
|
+
const verifier = base64Url(randomBytes(32));
|
|
4977
|
+
return {
|
|
4978
|
+
verifier,
|
|
4979
|
+
challenge: base64Url(createHash("sha256").update(verifier).digest()),
|
|
4980
|
+
state: base64Url(randomBytes(16))
|
|
4981
|
+
};
|
|
4982
|
+
}
|
|
4983
|
+
function toGrantPayload(tokens) {
|
|
4984
|
+
return {
|
|
4985
|
+
accessToken: tokens.access_token,
|
|
4986
|
+
refreshToken: tokens.refresh_token,
|
|
4987
|
+
tokenType: tokens.token_type,
|
|
4988
|
+
expiresAt: tokens.expires_in !== void 0 ? Date.now() + tokens.expires_in * 1e3 : void 0
|
|
4989
|
+
};
|
|
4990
|
+
}
|
|
4991
|
+
function buildAuthorizeUrl(meta, redirectUri, pkce) {
|
|
4992
|
+
const params = new URLSearchParams({
|
|
4993
|
+
response_type: "code",
|
|
4994
|
+
client_id: meta.clientId,
|
|
4995
|
+
redirect_uri: redirectUri,
|
|
4996
|
+
scope: meta.scopes.join(" "),
|
|
4997
|
+
state: pkce.state
|
|
4998
|
+
});
|
|
4999
|
+
if (meta.pkce) {
|
|
5000
|
+
params.set("code_challenge", pkce.challenge);
|
|
5001
|
+
params.set("code_challenge_method", "S256");
|
|
5002
|
+
}
|
|
5003
|
+
if (meta.audience !== void 0) params.set("audience", meta.audience);
|
|
5004
|
+
return `${meta.authorizeUrl}?${params.toString()}`;
|
|
5005
|
+
}
|
|
5006
|
+
/** Attach the one-shot callback handler and return a promise for the code. */
|
|
5007
|
+
function awaitCallback(server, state, timeoutMs) {
|
|
5008
|
+
return new Promise((resolve, reject) => {
|
|
5009
|
+
const timer = setTimeout(() => {
|
|
5010
|
+
reject(/* @__PURE__ */ new Error("OAuth login timed out waiting for the redirect."));
|
|
5011
|
+
server.close();
|
|
5012
|
+
}, timeoutMs);
|
|
5013
|
+
server.on("request", (request, response) => {
|
|
5014
|
+
const url = new URL(request.url ?? "/", "http://127.0.0.1");
|
|
5015
|
+
if (url.pathname !== "/callback") {
|
|
5016
|
+
response.writeHead(404).end();
|
|
5017
|
+
return;
|
|
5018
|
+
}
|
|
5019
|
+
clearTimeout(timer);
|
|
5020
|
+
response.writeHead(200, { "content-type": "text/plain" }).end("Authorization complete. You can return to ACRYL.");
|
|
5021
|
+
const code = url.searchParams.get("code");
|
|
5022
|
+
const returnedState = url.searchParams.get("state");
|
|
5023
|
+
server.close();
|
|
5024
|
+
if (returnedState !== state) reject(/* @__PURE__ */ new Error("OAuth state mismatch."));
|
|
5025
|
+
else if (code === null) reject(/* @__PURE__ */ new Error("OAuth redirect did not include an authorization code."));
|
|
5026
|
+
else resolve(code);
|
|
5027
|
+
});
|
|
5028
|
+
});
|
|
5029
|
+
}
|
|
5030
|
+
/** Open the authorize URL in the platform's default browser. */
|
|
5031
|
+
function defaultOpenUrl(url) {
|
|
5032
|
+
const platform = process.platform;
|
|
5033
|
+
const command = platform === "darwin" ? ["open", [url]] : platform === "win32" ? ["cmd", [
|
|
5034
|
+
"/c",
|
|
5035
|
+
"start",
|
|
5036
|
+
"",
|
|
5037
|
+
url
|
|
5038
|
+
]] : ["xdg-open", [url]];
|
|
5039
|
+
return new Promise((resolve) => {
|
|
5040
|
+
execFile(command[0], command[1], () => resolve());
|
|
5041
|
+
});
|
|
5042
|
+
}
|
|
5043
|
+
/** POST the authorization code to the token endpoint and normalize the body. */
|
|
5044
|
+
async function exchangeCode(meta, code, redirectUri, pkce) {
|
|
5045
|
+
const body = new URLSearchParams({
|
|
5046
|
+
grant_type: "authorization_code",
|
|
5047
|
+
code,
|
|
5048
|
+
redirect_uri: redirectUri,
|
|
5049
|
+
client_id: meta.clientId
|
|
5050
|
+
});
|
|
5051
|
+
if (meta.pkce) body.set("code_verifier", pkce.verifier);
|
|
5052
|
+
return postToken(meta, body);
|
|
5053
|
+
}
|
|
5054
|
+
/** POST to the token endpoint; shared by the code and refresh exchanges. */
|
|
5055
|
+
async function postToken(meta, body) {
|
|
5056
|
+
const response = await fetch(meta.tokenUrl, {
|
|
5057
|
+
method: "POST",
|
|
5058
|
+
headers: { "content-type": "application/x-www-form-urlencoded" },
|
|
5059
|
+
body: body.toString()
|
|
5060
|
+
});
|
|
5061
|
+
if (!response.ok) {
|
|
5062
|
+
const text = await response.text().catch(() => "");
|
|
5063
|
+
throw new Error(`token request failed (${response.status}): ${text}`);
|
|
5064
|
+
}
|
|
5065
|
+
return await response.json();
|
|
5066
|
+
}
|
|
5067
|
+
/** Run the full authorization-code flow and persist the resulting grant. */
|
|
5068
|
+
async function runOAuthLogin(meta, credentials, options = {}) {
|
|
5069
|
+
const server = createServer();
|
|
5070
|
+
try {
|
|
5071
|
+
const pkce = makePkce();
|
|
5072
|
+
await new Promise((resolve, reject) => {
|
|
5073
|
+
server.once("error", reject);
|
|
5074
|
+
server.listen(0, "127.0.0.1", resolve);
|
|
5075
|
+
});
|
|
5076
|
+
const { port } = server.address();
|
|
5077
|
+
const redirectUri = `http://127.0.0.1:${port}/callback`;
|
|
5078
|
+
const authorizeUrl = buildAuthorizeUrl(meta, redirectUri, pkce);
|
|
5079
|
+
const codePromise = awaitCallback(server, pkce.state, options.timeoutMs ?? 3e5);
|
|
5080
|
+
codePromise.catch(() => {});
|
|
5081
|
+
await (options.openUrl ?? defaultOpenUrl)(authorizeUrl);
|
|
5082
|
+
const tokens = await exchangeCode(meta, await codePromise, redirectUri, pkce);
|
|
5083
|
+
await credentials.modifyRecord(grantKey(meta), async () => ({
|
|
5084
|
+
kind: "grant",
|
|
5085
|
+
payload: toGrantPayload(tokens)
|
|
5086
|
+
}));
|
|
5087
|
+
return { ok: true };
|
|
5088
|
+
} catch (error) {
|
|
5089
|
+
return {
|
|
5090
|
+
ok: false,
|
|
5091
|
+
error: error instanceof Error ? error.message : String(error)
|
|
5092
|
+
};
|
|
5093
|
+
} finally {
|
|
5094
|
+
if (server.listening) server.close();
|
|
5095
|
+
}
|
|
5096
|
+
}
|
|
5097
|
+
/** Read the stored grant for a provider, or undefined when none is stored. */
|
|
5098
|
+
async function readOAuthGrant(meta, credentials) {
|
|
5099
|
+
const record = await credentials.readRecord(grantKey(meta));
|
|
5100
|
+
return record?.kind === "grant" ? record.payload : void 0;
|
|
5101
|
+
}
|
|
5102
|
+
/** Revoke (delete) a provider's stored grant. Removing an absent record is a no-op. */
|
|
5103
|
+
async function revokeOAuthGrant(meta, credentials) {
|
|
5104
|
+
await credentials.deleteRecord(grantKey(meta));
|
|
5105
|
+
}
|
|
4912
5106
|
/** Canonical ACRYL version string used by the CLI and the release smoke checks. */
|
|
4913
5107
|
const ACRYL_VERSION = createRequire(import.meta.url)("../package.json").version;
|
|
4914
5108
|
//#endregion
|
|
@@ -4969,6 +5163,12 @@ function deriveApiKeyRef(route) {
|
|
|
4969
5163
|
const upper = route.toUpperCase().replace(/[^A-Z0-9]+/g, "_");
|
|
4970
5164
|
return `${/^[A-Z_]/.test(upper) ? upper : `P_${upper}`}_API_KEY`;
|
|
4971
5165
|
}
|
|
5166
|
+
/** Nest a provider settings section at its path, e.g. `['providers','deepseek']` -> `{ providers: { deepseek: section } }`. */
|
|
5167
|
+
function nestAtPath(path, section) {
|
|
5168
|
+
let patch = section;
|
|
5169
|
+
for (let index = path.length - 1; index >= 0; index--) patch = { [path[index]]: patch };
|
|
5170
|
+
return patch;
|
|
5171
|
+
}
|
|
4972
5172
|
/** English display names for the shipped preset ids (the metadata is authored in Chinese, and there is no server-side locale resolution). */
|
|
4973
5173
|
const PRESET_LABELS = {
|
|
4974
5174
|
standard: "Standard mode",
|
|
@@ -5036,6 +5236,8 @@ async function attachSession(host, resumeId) {
|
|
|
5036
5236
|
const userValue = descriptor === void 0 ? void 0 : getAtPath(descriptor.user, entry.settingsPath);
|
|
5037
5237
|
const apiKeyRef = value?.apiKeyEnv ?? deriveApiKeyRef(entry.provider);
|
|
5038
5238
|
const info = await credentialsSvc.describe(apiKeyRef);
|
|
5239
|
+
const oauth = oauthProviderFor(entry.provider);
|
|
5240
|
+
const grant = oauth === void 0 ? void 0 : await readOAuthGrant(oauth, credentialsSvc);
|
|
5039
5241
|
rows.push({
|
|
5040
5242
|
route: entry.provider,
|
|
5041
5243
|
displayName: value?.displayName ?? entry.displayName,
|
|
@@ -5047,6 +5249,8 @@ async function attachSession(host, resumeId) {
|
|
|
5047
5249
|
baseURL: value?.baseURL,
|
|
5048
5250
|
apiKeyRef,
|
|
5049
5251
|
apiKeyConfigured: info.configured,
|
|
5252
|
+
oauth,
|
|
5253
|
+
grantConfigured: grant !== void 0,
|
|
5050
5254
|
models: value?.models ?? [],
|
|
5051
5255
|
revision: descriptor?.revision
|
|
5052
5256
|
});
|
|
@@ -5205,6 +5409,56 @@ async function attachSession(host, resumeId) {
|
|
|
5205
5409
|
store.openModelProfile();
|
|
5206
5410
|
loadProviders();
|
|
5207
5411
|
},
|
|
5412
|
+
login() {
|
|
5413
|
+
store.openModelProfile();
|
|
5414
|
+
loadProviders();
|
|
5415
|
+
},
|
|
5416
|
+
loginWithOAuth(route) {
|
|
5417
|
+
(async () => {
|
|
5418
|
+
const credentialsSvc = host.ctx.get("credentials");
|
|
5419
|
+
if (credentialsSvc === void 0) {
|
|
5420
|
+
store.setNotice("Credentials are not available in this profile.");
|
|
5421
|
+
return;
|
|
5422
|
+
}
|
|
5423
|
+
const meta = oauthProviderFor(route);
|
|
5424
|
+
if (meta === void 0) {
|
|
5425
|
+
store.setNotice("OAuth is not available for this provider.");
|
|
5426
|
+
return;
|
|
5427
|
+
}
|
|
5428
|
+
store.setNotice(`Opening ${meta.route} OAuth login…`);
|
|
5429
|
+
const result = await runOAuthLogin(meta, credentialsSvc);
|
|
5430
|
+
if (result.ok) {
|
|
5431
|
+
store.setNotice(`OAuth login complete for ${meta.route}.`);
|
|
5432
|
+
loadProviders();
|
|
5433
|
+
} else store.setNotice(`OAuth login failed: ${result.error}`);
|
|
5434
|
+
})();
|
|
5435
|
+
},
|
|
5436
|
+
logout() {
|
|
5437
|
+
(async () => {
|
|
5438
|
+
const credentialsSvc = host.ctx.get("credentials");
|
|
5439
|
+
if (credentialsSvc === void 0) {
|
|
5440
|
+
store.setNotice("Credentials are not available in this profile.");
|
|
5441
|
+
return;
|
|
5442
|
+
}
|
|
5443
|
+
const selection = host.ctx.get("agentDefaultModel")?.currentSelection?.();
|
|
5444
|
+
const overlay = store.getSnapshot().overlay;
|
|
5445
|
+
const rows = overlay.kind === "modelProfile" ? overlay.modelProfile.providers : void 0;
|
|
5446
|
+
const row = rows?.find((entry) => entry.route === selection?.provider) ?? (rows !== void 0 && rows.length === 1 ? rows[0] : void 0);
|
|
5447
|
+
if (row === void 0) {
|
|
5448
|
+
store.setNotice(logoutNoneMessage());
|
|
5449
|
+
return;
|
|
5450
|
+
}
|
|
5451
|
+
try {
|
|
5452
|
+
const oauth = oauthProviderFor(row.route);
|
|
5453
|
+
if (oauth !== void 0) await revokeOAuthGrant(oauth, credentialsSvc);
|
|
5454
|
+
await credentialsSvc.unset(row.apiKeyRef);
|
|
5455
|
+
store.setNotice(logoutSuccessMessage(row.displayName));
|
|
5456
|
+
loadProviders();
|
|
5457
|
+
} catch (error) {
|
|
5458
|
+
store.setNotice(`logout failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
5459
|
+
}
|
|
5460
|
+
})();
|
|
5461
|
+
},
|
|
5208
5462
|
openTrajectory() {
|
|
5209
5463
|
store.openTrajectory();
|
|
5210
5464
|
},
|
|
@@ -5241,9 +5495,76 @@ async function attachSession(host, resumeId) {
|
|
|
5241
5495
|
draft: void 0
|
|
5242
5496
|
});
|
|
5243
5497
|
},
|
|
5244
|
-
editProvider() {
|
|
5245
|
-
|
|
5246
|
-
|
|
5498
|
+
editProvider(route) {
|
|
5499
|
+
const overlay = store.getSnapshot().overlay;
|
|
5500
|
+
if (overlay.kind !== "modelProfile") return;
|
|
5501
|
+
const row = overlay.modelProfile.providers?.find((entry) => entry.route === route);
|
|
5502
|
+
if (row === void 0) return;
|
|
5503
|
+
const draft = {
|
|
5504
|
+
route: row.route,
|
|
5505
|
+
isNew: false,
|
|
5506
|
+
settingsNs: row.settingsNs,
|
|
5507
|
+
settingsPath: row.settingsPath,
|
|
5508
|
+
displayName: row.displayName,
|
|
5509
|
+
api: row.api ?? "",
|
|
5510
|
+
baseURL: row.baseURL ?? "",
|
|
5511
|
+
apiKeyRef: row.apiKeyRef,
|
|
5512
|
+
apiKeyConfigured: row.apiKeyConfigured,
|
|
5513
|
+
apiKeyDraft: "",
|
|
5514
|
+
models: row.models,
|
|
5515
|
+
revision: row.revision
|
|
5516
|
+
};
|
|
5517
|
+
store.updateModelProfile({
|
|
5518
|
+
view: "form",
|
|
5519
|
+
draft,
|
|
5520
|
+
formKey: overlay.modelProfile.formKey + 1
|
|
5521
|
+
});
|
|
5522
|
+
},
|
|
5523
|
+
saveProvider(draft) {
|
|
5524
|
+
(async () => {
|
|
5525
|
+
const settingsSvc = host.ctx.get("settings");
|
|
5526
|
+
const credentialsSvc = host.ctx.get("credentials");
|
|
5527
|
+
if (settingsSvc === void 0 || credentialsSvc === void 0) {
|
|
5528
|
+
store.setNotice("Provider settings are not available in this profile.");
|
|
5529
|
+
return;
|
|
5530
|
+
}
|
|
5531
|
+
try {
|
|
5532
|
+
const key = draft.apiKeyDraft.trim();
|
|
5533
|
+
if (key !== "") await credentialsSvc.set(draft.apiKeyRef, key);
|
|
5534
|
+
const section = {
|
|
5535
|
+
displayName: draft.displayName,
|
|
5536
|
+
api: draft.api,
|
|
5537
|
+
baseURL: draft.baseURL,
|
|
5538
|
+
apiKeyEnv: draft.apiKeyRef,
|
|
5539
|
+
models: draft.models
|
|
5540
|
+
};
|
|
5541
|
+
await settingsSvc.update(draft.settingsNs, nestAtPath(draft.settingsPath, section), draft.revision);
|
|
5542
|
+
store.setNotice(`Saved ${draft.displayName || draft.route}.`);
|
|
5543
|
+
store.updateModelProfile({ view: "list" });
|
|
5544
|
+
loadProviders();
|
|
5545
|
+
} catch (error) {
|
|
5546
|
+
store.setNotice(`save failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
5547
|
+
}
|
|
5548
|
+
})();
|
|
5549
|
+
},
|
|
5550
|
+
deleteProvider(row) {
|
|
5551
|
+
(async () => {
|
|
5552
|
+
const settingsSvc = host.ctx.get("settings");
|
|
5553
|
+
const credentialsSvc = host.ctx.get("credentials");
|
|
5554
|
+
if (settingsSvc === void 0 || credentialsSvc === void 0) {
|
|
5555
|
+
store.setNotice("Provider settings are not available in this profile.");
|
|
5556
|
+
return;
|
|
5557
|
+
}
|
|
5558
|
+
try {
|
|
5559
|
+
await credentialsSvc.unset(row.apiKeyRef);
|
|
5560
|
+
await settingsSvc.update(row.settingsNs, nestAtPath(row.settingsPath, {}), row.revision);
|
|
5561
|
+
store.setNotice(`Removed ${row.displayName}.`);
|
|
5562
|
+
loadProviders();
|
|
5563
|
+
} catch (error) {
|
|
5564
|
+
store.setNotice(`delete failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
5565
|
+
}
|
|
5566
|
+
})();
|
|
5567
|
+
},
|
|
5247
5568
|
discoverModelsForDraft() {},
|
|
5248
5569
|
setActiveModel() {},
|
|
5249
5570
|
closeTrajectory() {
|