acryl 0.1.15 → 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 +202 -4
- package/lib/bin.js.map +1 -1
- package/lib/index.js +202 -4
- package/lib/index.js.map +1 -1
- package/package.json +12 -5
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
|
|
@@ -3168,12 +3169,14 @@ var ModelProfileOverlay = class {
|
|
|
3168
3169
|
const marker = row.configured ? "● " : "○ ";
|
|
3169
3170
|
const active = row.live ? " (active)" : "";
|
|
3170
3171
|
const noKey = row.apiKeyConfigured ? "" : " [no api key]";
|
|
3172
|
+
const oauthStatus = row.oauth === void 0 ? "" : row.grantConfigured ? " [oauth ✓]" : " [oauth]";
|
|
3171
3173
|
const confirm = this.confirmDelete === index ? " — press d again to delete" : "";
|
|
3172
|
-
const text = `${index === selected ? "› " : " "}${marker}${row.displayName}${active}${noKey}${confirm}`;
|
|
3174
|
+
const text = `${index === selected ? "› " : " "}${marker}${row.displayName}${active}${noKey}${oauthStatus}${confirm}`;
|
|
3173
3175
|
lines.push(index === selected ? invert$4(text) : text);
|
|
3174
3176
|
});
|
|
3175
3177
|
if (providers?.length === 0) lines.push(muted$9("No providers configured yet — press a to add one."));
|
|
3176
|
-
|
|
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`));
|
|
3177
3180
|
return lines;
|
|
3178
3181
|
}
|
|
3179
3182
|
handleListInput(data, mp) {
|
|
@@ -3210,6 +3213,11 @@ var ModelProfileOverlay = class {
|
|
|
3210
3213
|
if (model !== void 0) this.actions.setActiveModel(row.route, model.id);
|
|
3211
3214
|
return;
|
|
3212
3215
|
}
|
|
3216
|
+
if (data === "o") {
|
|
3217
|
+
const row = providers[selected];
|
|
3218
|
+
if (row.oauth !== void 0) this.actions.loginWithOAuth(row.route);
|
|
3219
|
+
return;
|
|
3220
|
+
}
|
|
3213
3221
|
if (data === "d") {
|
|
3214
3222
|
if (this.confirmDelete === selected) {
|
|
3215
3223
|
this.confirmDelete = void 0;
|
|
@@ -4931,6 +4939,170 @@ function logoutSuccessMessage(provider) {
|
|
|
4931
4939
|
function logoutNoneMessage() {
|
|
4932
4940
|
return "No active provider is selected; nothing to log out.";
|
|
4933
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
|
+
}
|
|
4934
5106
|
/** Canonical ACRYL version string used by the CLI and the release smoke checks. */
|
|
4935
5107
|
const ACRYL_VERSION = createRequire(import.meta.url)("../package.json").version;
|
|
4936
5108
|
//#endregion
|
|
@@ -5064,6 +5236,8 @@ async function attachSession(host, resumeId) {
|
|
|
5064
5236
|
const userValue = descriptor === void 0 ? void 0 : getAtPath(descriptor.user, entry.settingsPath);
|
|
5065
5237
|
const apiKeyRef = value?.apiKeyEnv ?? deriveApiKeyRef(entry.provider);
|
|
5066
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);
|
|
5067
5241
|
rows.push({
|
|
5068
5242
|
route: entry.provider,
|
|
5069
5243
|
displayName: value?.displayName ?? entry.displayName,
|
|
@@ -5075,6 +5249,8 @@ async function attachSession(host, resumeId) {
|
|
|
5075
5249
|
baseURL: value?.baseURL,
|
|
5076
5250
|
apiKeyRef,
|
|
5077
5251
|
apiKeyConfigured: info.configured,
|
|
5252
|
+
oauth,
|
|
5253
|
+
grantConfigured: grant !== void 0,
|
|
5078
5254
|
models: value?.models ?? [],
|
|
5079
5255
|
revision: descriptor?.revision
|
|
5080
5256
|
});
|
|
@@ -5237,6 +5413,26 @@ async function attachSession(host, resumeId) {
|
|
|
5237
5413
|
store.openModelProfile();
|
|
5238
5414
|
loadProviders();
|
|
5239
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
|
+
},
|
|
5240
5436
|
logout() {
|
|
5241
5437
|
(async () => {
|
|
5242
5438
|
const credentialsSvc = host.ctx.get("credentials");
|
|
@@ -5253,6 +5449,8 @@ async function attachSession(host, resumeId) {
|
|
|
5253
5449
|
return;
|
|
5254
5450
|
}
|
|
5255
5451
|
try {
|
|
5452
|
+
const oauth = oauthProviderFor(row.route);
|
|
5453
|
+
if (oauth !== void 0) await revokeOAuthGrant(oauth, credentialsSvc);
|
|
5256
5454
|
await credentialsSvc.unset(row.apiKeyRef);
|
|
5257
5455
|
store.setNotice(logoutSuccessMessage(row.displayName));
|
|
5258
5456
|
loadProviders();
|