@songsid/agend 2.1.6-beta.4 → 2.1.6-beta.6
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/dist/backend/claude-code.js +24 -0
- package/dist/backend/claude-code.js.map +1 -1
- package/dist/backend/factory.js +4 -1
- package/dist/backend/factory.js.map +1 -1
- package/dist/backend/muse.d.ts +90 -0
- package/dist/backend/muse.js +455 -0
- package/dist/backend/muse.js.map +1 -0
- package/dist/backend/types.d.ts +2 -0
- package/dist/backend/types.js.map +1 -1
- package/dist/channel/access-manager.d.ts +20 -0
- package/dist/channel/access-manager.js +25 -0
- package/dist/channel/access-manager.js.map +1 -1
- package/dist/channel/adapters/discord.d.ts +3 -0
- package/dist/channel/adapters/discord.js +13 -10
- package/dist/channel/adapters/discord.js.map +1 -1
- package/dist/channel/markdown-chunk.d.ts +8 -3
- package/dist/channel/markdown-chunk.js +12 -3
- package/dist/channel/markdown-chunk.js.map +1 -1
- package/dist/channel/tool-router.js +12 -2
- package/dist/channel/tool-router.js.map +1 -1
- package/dist/config-validator.js +14 -3
- package/dist/config-validator.js.map +1 -1
- package/dist/daemon.js +7 -2
- package/dist/daemon.js.map +1 -1
- package/dist/fleet-manager.d.ts +32 -0
- package/dist/fleet-manager.js +137 -12
- package/dist/fleet-manager.js.map +1 -1
- package/dist/instance-lifecycle.js +8 -4
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/locale.js +14 -0
- package/dist/locale.js.map +1 -1
- package/dist/logger.js +42 -25
- package/dist/logger.js.map +1 -1
- package/dist/outbound-schemas.d.ts +1 -0
- package/dist/outbound-schemas.js +1 -1
- package/dist/outbound-schemas.js.map +1 -1
- package/dist/quickstart-api.d.ts +3 -0
- package/dist/quickstart-api.js +1 -0
- package/dist/quickstart-api.js.map +1 -1
- package/dist/scheduler/db.js +17 -5
- package/dist/scheduler/db.js.map +1 -1
- package/dist/scheduler/db.test.js +34 -1
- package/dist/scheduler/db.test.js.map +1 -1
- package/dist/scheduler/types.d.ts +4 -0
- package/dist/scheduler/types.js.map +1 -1
- package/dist/setup-wizard.js +4 -0
- package/dist/setup-wizard.js.map +1 -1
- package/dist/steer-capability.js +4 -1
- package/dist/steer-capability.js.map +1 -1
- package/dist/tmux-manager.js +29 -4
- package/dist/tmux-manager.js.map +1 -1
- package/dist/topic-commands.js +1 -0
- package/dist/topic-commands.js.map +1 -1
- package/dist/web-api.js +2 -1
- package/dist/web-api.js.map +1 -1
- package/dist/web-terminal.d.ts +30 -1
- package/dist/web-terminal.js +86 -3
- package/dist/web-terminal.js.map +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync, chmodSync } from "node:fs";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
import { resolveBinary, shellQuote, validateModel, warnIfModelMismatch } from "./types.js";
|
|
6
|
+
import { appendWithMarker, removeMarker } from "./marker-utils.js";
|
|
7
|
+
/** Session ids are UUIDs (e.g. "01a0c784-fb91-…"); guard before shell interpolation. */
|
|
8
|
+
const SESSION_ID_RE = /^[0-9a-fA-F-]{8,}$/;
|
|
9
|
+
/**
|
|
10
|
+
* Enough of a session log to reach the `route_facts` record that names the
|
|
11
|
+
* working directory. Measured on a live session: `"cwd"` landed at byte 3899 of
|
|
12
|
+
* a 450KB log, at sequence 4. 64KiB is ~16x that headroom and keeps the scan
|
|
13
|
+
* cheap even with dozens of sessions on disk.
|
|
14
|
+
*/
|
|
15
|
+
const SESSION_HEAD_BYTES = 65_536;
|
|
16
|
+
/** Read the workspace a session was started in, without reading the whole log. */
|
|
17
|
+
export function museSessionCwd(head) {
|
|
18
|
+
return head.match(/"cwd":"((?:[^"\\]|\\.)*)"/)?.[1]?.replace(/\\(.)/g, "$1") ?? null;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Meta Muse Code — the `muse` CLI (v1.3.0 verified).
|
|
22
|
+
*
|
|
23
|
+
* Everything below was confirmed against live sessions on 2026-09-22 rather
|
|
24
|
+
* than read out of `--help`, because the two disagree in the places that
|
|
25
|
+
* matter. Three findings shaped this file:
|
|
26
|
+
*
|
|
27
|
+
* 1. The input prompt `❯` stays on screen the entire time muse works, so the
|
|
28
|
+
* ready pattern alone can never say "idle" — hence getBusyPattern().
|
|
29
|
+
* 2. Ctrl+C is QUIT (twice), not cancel. The TUI's own hint is "esc to
|
|
30
|
+
* interrupt", and Escape is what stops a run. Wiring C-c to cancel would
|
|
31
|
+
* have left every instance one stray keypress from death.
|
|
32
|
+
* 3. `--disable-approval` alone still stops at a workspace-trust dialog. It
|
|
33
|
+
* needs `--trust-workspace` beside it to reach the prompt unattended.
|
|
34
|
+
*/
|
|
35
|
+
export class MuseBackend {
|
|
36
|
+
instanceDir;
|
|
37
|
+
binaryName = "muse";
|
|
38
|
+
binaryPath;
|
|
39
|
+
// Cached from buildCommand/writeConfig so getSessionId() (which takes no
|
|
40
|
+
// args) can match sessions against this instance's workspace.
|
|
41
|
+
workingDirectory;
|
|
42
|
+
constructor(instanceDir) {
|
|
43
|
+
this.instanceDir = instanceDir;
|
|
44
|
+
this.binaryPath = resolveBinary("muse");
|
|
45
|
+
}
|
|
46
|
+
buildCommand(config) {
|
|
47
|
+
this.workingDirectory = config.workingDirectory;
|
|
48
|
+
// `muse` on PATH is a launcher script that checks for a new release, may
|
|
49
|
+
// replace the binary underneath us, and records an update notice that the
|
|
50
|
+
// next start prints. A fleet agent can run for days; an update arriving
|
|
51
|
+
// mid-run would repaint the pane and swap the CLI. One year in seconds
|
|
52
|
+
// keeps the check quiet while staying inside the launcher's own numeric
|
|
53
|
+
// guard (a non-numeric value also disables it, but undocumented).
|
|
54
|
+
let cmd = `MUSE_UPDATE_INTERVAL_SECONDS=31536000 ${this.binaryPath}`;
|
|
55
|
+
// Verified: `--disable-approval` on its own leaves the session parked on
|
|
56
|
+
// "Do you trust this workspace?" forever. Trust is a separate axis, so both
|
|
57
|
+
// flags are needed to reach the prompt unattended.
|
|
58
|
+
//
|
|
59
|
+
// NOT `--yolo`: that disables approval, trust AND the OS sandbox. The
|
|
60
|
+
// sandbox was measured to permit what an agent actually needs — writes in
|
|
61
|
+
// the workspace and to the temp dir, and outbound network through the proxy
|
|
62
|
+
// (curl to example.com returned 200) — so there is nothing to buy by
|
|
63
|
+
// switching it off, and a sandboxed shell is worth keeping.
|
|
64
|
+
if (config.skipPermissions !== false)
|
|
65
|
+
cmd += " --disable-approval --trust-workspace";
|
|
66
|
+
if (config.model) {
|
|
67
|
+
const model = validateModel(config.model);
|
|
68
|
+
warnIfModelMismatch("muse", model);
|
|
69
|
+
cmd += ` --model ${shellQuote(model)}`;
|
|
70
|
+
}
|
|
71
|
+
// muse accepts none|minimal|low|medium|high|xhigh|max|ultra; AgEnD's levels
|
|
72
|
+
// are a subset, so whatever the fleet holds is passed through unchanged.
|
|
73
|
+
if (config.effort)
|
|
74
|
+
cmd += ` --reasoning-effort ${shellQuote(config.effort)}`;
|
|
75
|
+
// Resume is a SUBCOMMAND, and root options may sit on either side of it
|
|
76
|
+
// (stated in `muse resume --help`, and verified: root flags + `resume <id>`
|
|
77
|
+
// launched into the prior conversation with the model flag applied).
|
|
78
|
+
// `resume --last` is workspace-scoped and would silently adopt a session the
|
|
79
|
+
// user started by hand in the same directory, so we resume the id we
|
|
80
|
+
// persisted and nothing else.
|
|
81
|
+
if (!config.skipResume) {
|
|
82
|
+
const sid = this.storedSessionId();
|
|
83
|
+
if (sid)
|
|
84
|
+
cmd += ` resume ${sid}`;
|
|
85
|
+
}
|
|
86
|
+
return cmd;
|
|
87
|
+
}
|
|
88
|
+
/** The daemon's persisted session id (written from getSessionId()), for resume. */
|
|
89
|
+
storedSessionId() {
|
|
90
|
+
try {
|
|
91
|
+
const sid = readFileSync(join(this.instanceDir, "session-id"), "utf-8").trim();
|
|
92
|
+
return SESSION_ID_RE.test(sid) ? sid : null;
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Per-instance MCP key. Instance names can be CJK (persona channels), and a
|
|
100
|
+
* settings file shared by every instance needs keys that cannot collide, so a
|
|
101
|
+
* non-ASCII name becomes an ASCII slug plus a hash of the original.
|
|
102
|
+
*/
|
|
103
|
+
mcpKey(mcpName, instanceName) {
|
|
104
|
+
const ascii = instanceName.replace(/[^\x20-\x7E]/g, "");
|
|
105
|
+
if (ascii === instanceName)
|
|
106
|
+
return `agend-${mcpName}-${instanceName}`;
|
|
107
|
+
const slug = ascii.replace(/[^A-Za-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
108
|
+
const hash = createHash("md5").update(instanceName).digest("hex").slice(0, 8);
|
|
109
|
+
return slug ? `agend-${mcpName}-${slug}-${hash}` : `agend-${mcpName}-${hash}`;
|
|
110
|
+
}
|
|
111
|
+
/** `$XDG_CONFIG_HOME/muse/settings.json`, else `~/.config/muse/settings.json`. */
|
|
112
|
+
settingsPath() {
|
|
113
|
+
const base = process.env.XDG_CONFIG_HOME || join(homedir(), ".config");
|
|
114
|
+
return join(base, "muse", "settings.json");
|
|
115
|
+
}
|
|
116
|
+
writeConfig(config) {
|
|
117
|
+
this.workingDirectory = config.workingDirectory;
|
|
118
|
+
// Muse reads MCP servers from ONE file — the user-level settings.json. It
|
|
119
|
+
// has no project-level equivalent (checked: `muse init` scaffolds AGENTS.md
|
|
120
|
+
// and nothing else, and the binary documents a single `$CONFIG_DIR` path).
|
|
121
|
+
// So this writes into the user's own settings, which means two rules:
|
|
122
|
+
// every key we did not put there is preserved, and ours are namespaced per
|
|
123
|
+
// instance so instances sharing a machine cannot overwrite each other.
|
|
124
|
+
//
|
|
125
|
+
// Isolating this per instance would mean relocating XDG_CONFIG_HOME, which
|
|
126
|
+
// also moves auth.json — the user's login. Not worth doing blind; left as a
|
|
127
|
+
// follow-up for whoever needs per-instance muse credentials.
|
|
128
|
+
const settingsPath = this.settingsPath();
|
|
129
|
+
let root = {};
|
|
130
|
+
try {
|
|
131
|
+
root = JSON.parse(readFileSync(settingsPath, "utf-8"));
|
|
132
|
+
}
|
|
133
|
+
catch { /* new file */ }
|
|
134
|
+
if (typeof root.schema_version !== "number")
|
|
135
|
+
root.schema_version = 1;
|
|
136
|
+
const servers = (root.mcpServers ?? {});
|
|
137
|
+
// Drop our own stale entries whose wrapper script is gone (deleted instance,
|
|
138
|
+
// cleared instance dir). Never touch a key we did not write.
|
|
139
|
+
for (const [key, val] of Object.entries(servers)) {
|
|
140
|
+
if (!key.startsWith("agend-"))
|
|
141
|
+
continue;
|
|
142
|
+
const cmd = val?.command;
|
|
143
|
+
if (typeof cmd === "string" && !existsSync(cmd))
|
|
144
|
+
delete servers[key];
|
|
145
|
+
}
|
|
146
|
+
for (const [name, entry] of Object.entries(config.mcpServers)) {
|
|
147
|
+
const allEnv = { ...entry.env, AGEND_INSTANCE_NAME: config.instanceName };
|
|
148
|
+
// Same wrapper as grok/kiro. Two jobs: export the env explicitly rather
|
|
149
|
+
// than trusting the CLI to forward the entry's `env` block, and wait for
|
|
150
|
+
// the IPC socket to exist — a server that starts first would fail to
|
|
151
|
+
// connect and every fleet tool (reply/react/…) would be dead for the run.
|
|
152
|
+
const wrapperPath = join(this.instanceDir, `mcp-wrapper-${name}.sh`);
|
|
153
|
+
const envExports = Object.entries(allEnv)
|
|
154
|
+
.map(([k, v]) => `export ${k}='${String(v).replace(/'/g, "'\\''")}'`)
|
|
155
|
+
.join("\n");
|
|
156
|
+
// 0o700: the wrapper inlines sensitive env (tokens, socket paths).
|
|
157
|
+
writeFileSync(wrapperPath, `#!/bin/bash\n${envExports}\n# Wait for IPC socket to be ready (up to 10s)\nfor i in $(seq 1 20); do [ -S "$AGEND_SOCKET_PATH" ] && break; sleep 0.5; done\nexec ${entry.command} ${entry.args.map((a) => JSON.stringify(a)).join(" ")}\n`, { mode: 0o700 });
|
|
158
|
+
chmodSync(wrapperPath, 0o700);
|
|
159
|
+
// Entry shape per muse's own documentation: type/command/args/env/mode.
|
|
160
|
+
// "optional" so a server that fails to start degrades the session instead
|
|
161
|
+
// of stopping it.
|
|
162
|
+
servers[this.mcpKey(name, config.instanceName)] = {
|
|
163
|
+
type: "stdio",
|
|
164
|
+
command: wrapperPath,
|
|
165
|
+
args: [],
|
|
166
|
+
mode: "optional",
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
root.mcpServers = servers;
|
|
170
|
+
try {
|
|
171
|
+
mkdirSync(join(settingsPath, ".."), { recursive: true });
|
|
172
|
+
writeFileSync(settingsPath, JSON.stringify(root, null, 2));
|
|
173
|
+
}
|
|
174
|
+
catch { /* best effort — a muse without MCP still starts */ }
|
|
175
|
+
// `muse init` scaffolds AGENTS.md and the binary reads it as project rules,
|
|
176
|
+
// the same convention as codex and grok. Additive + idempotent via marker.
|
|
177
|
+
if (config.instructions) {
|
|
178
|
+
try {
|
|
179
|
+
appendWithMarker(join(config.workingDirectory, "AGENTS.md"), config.instanceName, config.instructions);
|
|
180
|
+
}
|
|
181
|
+
catch { /* best effort */ }
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
requiresDeliveryEnterRetry() {
|
|
185
|
+
// Measured, not inferred. An Enter that arrives in the same keystroke burst
|
|
186
|
+
// as the text is taken as a NEWLINE: `tmux send-keys "probe N" Enter`
|
|
187
|
+
// failed to submit three times out of three, and the drafts stacked up in
|
|
188
|
+
// the input box —
|
|
189
|
+
//
|
|
190
|
+
// ❯ probe 1
|
|
191
|
+
// probe 2
|
|
192
|
+
// probe 3
|
|
193
|
+
//
|
|
194
|
+
// The damage is not a lost message but a merged one: the next Enter submits
|
|
195
|
+
// the whole draft as a single turn. The daemon's waitForPasteSettle already
|
|
196
|
+
// opens the gap muse needs (a paste followed by Enter a second later
|
|
197
|
+
// submitted every time, including mid-turn), so this is insurance against
|
|
198
|
+
// the case where the settle wait is blind and falls back to a fixed delay.
|
|
199
|
+
//
|
|
200
|
+
// Safe on every delivery, both preconditions verified live: a bare Enter is
|
|
201
|
+
// a no-op at an empty idle prompt, and a no-op mid-turn with empty input.
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
getReadyPattern() {
|
|
205
|
+
// The ready screen carries the `Muse Code <version>` header and an empty
|
|
206
|
+
// `❯` input row. Both survive scrollback, which is fine — this pattern only
|
|
207
|
+
// has to say "the TUI is up"; getBusyPattern() is what says "not now".
|
|
208
|
+
return /❯|Muse Code \d/m;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* The working line, which is on screen only while muse is generating.
|
|
212
|
+
*
|
|
213
|
+
* Required for the same reason grok and claude-code needed one: the input box
|
|
214
|
+
* (and therefore `❯`) stays visible the whole time muse works, so the ready
|
|
215
|
+
* pattern is effectively constant-true and the instance would never be seen
|
|
216
|
+
* as busy — no hang detection, and a frozen CLI reported as idle.
|
|
217
|
+
*
|
|
218
|
+
* Sampled from a live run. The phase word changes (`Thinking`, `Working`,
|
|
219
|
+
* `Double checking`) and the leading glyph cycles (◇ ◆ ◈), so neither is the
|
|
220
|
+
* anchor. What every working frame has, and no idle frame does, is the
|
|
221
|
+
* interrupt hint muse prints beside the elapsed timer:
|
|
222
|
+
*
|
|
223
|
+
* ◇ Thinking (2s · esc to interrupt)
|
|
224
|
+
* ◆ Double checking (4s · esc to interrupt)
|
|
225
|
+
*
|
|
226
|
+
* Anchoring on the glyph would be wrong in a way that matters: completed
|
|
227
|
+
* output lines start with `◆ ` too (`◆ Panes split the dark screen`), so a
|
|
228
|
+
* glyph-anchored pattern would pin a finished instance in `working` forever.
|
|
229
|
+
*/
|
|
230
|
+
getBusyPattern() {
|
|
231
|
+
return /\(\s*\d+(?:\.\d+)?s\s*·\s*esc to interrupt\s*\)/;
|
|
232
|
+
}
|
|
233
|
+
getErrorPatterns() {
|
|
234
|
+
// NOTE: an Escape-interrupted run prints "interrupting run" in the status
|
|
235
|
+
// bar. That is normal user-initiated behaviour, not an error — nothing here
|
|
236
|
+
// matches it, and nothing that does should be added.
|
|
237
|
+
return [
|
|
238
|
+
{ pattern: /rate.?limit|too many requests|\b429\b/i, type: "rate_limit", action: "failover", message: "Muse rate limit reached" },
|
|
239
|
+
{ pattern: /unauthorized|authentication (failed|error)|\b401\b|muse login/i, type: "auth_error", action: "pause", message: "Muse authentication error" },
|
|
240
|
+
{ pattern: /quota|usage limit|out of credits/i, type: "quota", action: "notify", message: "Muse quota exhausted" },
|
|
241
|
+
];
|
|
242
|
+
}
|
|
243
|
+
getStartupDialogs() {
|
|
244
|
+
return [
|
|
245
|
+
// Workspace trust. `--trust-workspace` normally prevents this from ever
|
|
246
|
+
// appearing; it is still handled because an instance configured with
|
|
247
|
+
// skip_permissions: false gets neither flag and would otherwise hang
|
|
248
|
+
// here forever. Verified layout: a two-row menu, option 1 preselected,
|
|
249
|
+
// "Use Up/Down or 1/2, then Enter."
|
|
250
|
+
{
|
|
251
|
+
pattern: /Do you trust this workspace\?/,
|
|
252
|
+
keys: ["1", "Enter"],
|
|
253
|
+
description: "Muse workspace trust — choose 'Trust and continue'",
|
|
254
|
+
},
|
|
255
|
+
// Login is BLOCKING and cannot be auto-dismissed — the user has to
|
|
256
|
+
// complete it. Empty keys mean the daemon sends nothing but keeps
|
|
257
|
+
// treating the screen as not-ready, so a login page is never mistaken
|
|
258
|
+
// for the idle prompt.
|
|
259
|
+
{
|
|
260
|
+
pattern: /muse login|Log in to (Meta|continue)|device code/i,
|
|
261
|
+
keys: [],
|
|
262
|
+
description: "Muse login — wait for the user to authenticate (no auto-dismiss)",
|
|
263
|
+
},
|
|
264
|
+
];
|
|
265
|
+
}
|
|
266
|
+
getRuntimeDialogs() {
|
|
267
|
+
return [
|
|
268
|
+
// Net for a tool-approval prompt arriving despite --disable-approval (an
|
|
269
|
+
// enterprise policy can pin approval on). Muse's menus are numbered with
|
|
270
|
+
// the first option preselected, same shape as the trust dialog.
|
|
271
|
+
{
|
|
272
|
+
pattern: /Allow this (tool|command)|Approve this (tool|command)|1\s+(Allow|Approve)/i,
|
|
273
|
+
keys: ["1", "Enter"],
|
|
274
|
+
description: "Muse tool approval — allow",
|
|
275
|
+
},
|
|
276
|
+
];
|
|
277
|
+
}
|
|
278
|
+
getContextUsage() {
|
|
279
|
+
// Muse reports context only inside `/status` ("98% left · 23.8K used /
|
|
280
|
+
// 1008K"), not on the persistent status bar, so there is nothing a passive
|
|
281
|
+
// reader can see between turns. Returning a stale or invented number would
|
|
282
|
+
// be worse than none.
|
|
283
|
+
return null;
|
|
284
|
+
}
|
|
285
|
+
/*
|
|
286
|
+
* No usage provider, deliberately — and this is the record of why, so the next
|
|
287
|
+
* person does not repeat the search.
|
|
288
|
+
*
|
|
289
|
+
* `/usage` (alias `/cost`) does exist, and it is real: inside the TUI it
|
|
290
|
+
* prints "Subscription · Muse Code Everyday Usage" with "Current 0% used ·
|
|
291
|
+
* Resets at 2:37 AM" and a weekly line beside it. Every route to that number
|
|
292
|
+
* from outside the TUI was checked on 2026-09-22 against muse 1.3.0:
|
|
293
|
+
*
|
|
294
|
+
* - No subcommand. `muse --help` lists resume, exec, config, export, trace,
|
|
295
|
+
* skills, plugins, sandbox, schema, serve, session-message, mcp, auth,
|
|
296
|
+
* login, logout, init — and nothing for usage, quota or cost.
|
|
297
|
+
* - Nothing on disk. Every other provider in src/usage/providers.ts reads a
|
|
298
|
+
* store its vendor writes; muse writes none. ~/.local/share/muse and
|
|
299
|
+
* ~/.config/muse hold sessions, skills, plugins and credentials, and the
|
|
300
|
+
* only files mentioning a quota are prompts that happen to use the word.
|
|
301
|
+
* - Fetched on demand. The panel is empty until the session has been to
|
|
302
|
+
* Meta at least once, so the number lives in the running process, not in
|
|
303
|
+
* anything a second process could read.
|
|
304
|
+
* - The endpoint is not ours to guess. The recorded trace carries no
|
|
305
|
+
* request URL, and an invented one would break silently the day Meta
|
|
306
|
+
* moved it — a usage row that is quietly wrong is worse than no row.
|
|
307
|
+
*
|
|
308
|
+
* So muse is absent from the usage list on purpose, tracked in #851. If Meta
|
|
309
|
+
* ships a non-interactive surface, a `fetchMuseUsage` slots into
|
|
310
|
+
* DEFAULT_PROVIDERS beside the others and nothing here has to change.
|
|
311
|
+
*/
|
|
312
|
+
getSessionId() {
|
|
313
|
+
// Sessions live at ~/.local/share/muse/sessions/<YYYY>/<MM>/<DD>/<uuid>/,
|
|
314
|
+
// filed by date rather than by workspace, so the workspace has to be read
|
|
315
|
+
// out of each session's own log (`route_facts` names the cwd near the top).
|
|
316
|
+
// Returns the most recently ACTIVE session started in this instance's
|
|
317
|
+
// directory, which is what the daemon persists for resume.
|
|
318
|
+
if (!this.workingDirectory)
|
|
319
|
+
return null;
|
|
320
|
+
try {
|
|
321
|
+
const root = join(homedir(), ".local", "share", "muse", "sessions");
|
|
322
|
+
let newestId = null;
|
|
323
|
+
let newestMtime = -1;
|
|
324
|
+
for (const sessionDir of museSessionDirs(root)) {
|
|
325
|
+
const name = sessionDir.slice(sessionDir.lastIndexOf("/") + 1);
|
|
326
|
+
if (!SESSION_ID_RE.test(name))
|
|
327
|
+
continue;
|
|
328
|
+
let head;
|
|
329
|
+
try {
|
|
330
|
+
const fd = readFileSync(join(sessionDir, "session.jsonl"), { encoding: "utf-8", flag: "r" });
|
|
331
|
+
head = fd.slice(0, SESSION_HEAD_BYTES);
|
|
332
|
+
}
|
|
333
|
+
catch {
|
|
334
|
+
continue;
|
|
335
|
+
}
|
|
336
|
+
if (museSessionCwd(head) !== this.workingDirectory)
|
|
337
|
+
continue;
|
|
338
|
+
// Activity = latest inner-file mtime. The directory's own mtime does not
|
|
339
|
+
// move when a log is appended, and is misleadingly recent for a session
|
|
340
|
+
// that was only just created — it must not outrank a resumed older
|
|
341
|
+
// session whose log was written to seconds ago.
|
|
342
|
+
let activity = -1;
|
|
343
|
+
try {
|
|
344
|
+
for (const f of readdirSync(sessionDir)) {
|
|
345
|
+
try {
|
|
346
|
+
const m = statSync(join(sessionDir, f)).mtimeMs;
|
|
347
|
+
if (m > activity)
|
|
348
|
+
activity = m;
|
|
349
|
+
}
|
|
350
|
+
catch { /* skip */ }
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
catch { /* unreadable */ }
|
|
354
|
+
if (activity > newestMtime) {
|
|
355
|
+
newestMtime = activity;
|
|
356
|
+
newestId = name;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return newestId;
|
|
360
|
+
}
|
|
361
|
+
catch {
|
|
362
|
+
return null;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
// `/quit` is muse's own "quit when idle". The key chord is Ctrl+C pressed
|
|
366
|
+
// TWICE ("Press Ctrl-C again to quit") — kept as the fallback, with the count
|
|
367
|
+
// the TUI actually requires.
|
|
368
|
+
getQuitCommand() { return "/quit"; }
|
|
369
|
+
getQuitKey() { return "C-c"; }
|
|
370
|
+
getQuitKeyPresses() { return 2; }
|
|
371
|
+
getCompactCommand() { return "/compact"; }
|
|
372
|
+
getClearCommand() { return "/clear"; }
|
|
373
|
+
/**
|
|
374
|
+
* Escape, not Ctrl+C. Verified both ways on a live session: Escape mid-run
|
|
375
|
+
* put "interrupting run" in the status bar and returned the prompt with the
|
|
376
|
+
* partial answer kept, while Ctrl+C armed the quit confirmation ("Press
|
|
377
|
+
* Ctrl-C again to quit"). Cancelling with C-c would leave every instance one
|
|
378
|
+
* stray keypress from exiting.
|
|
379
|
+
*/
|
|
380
|
+
getCancelKey() { return "Escape"; }
|
|
381
|
+
// `/effort` is in the TUI command list, so a level change needs no restart.
|
|
382
|
+
getEffortStrategy() { return "runtime"; }
|
|
383
|
+
// muse also accepts none|minimal|ultra, which AgEnD has no level for; the
|
|
384
|
+
// canonical five map straight through.
|
|
385
|
+
getEffortLevels() { return ["low", "medium", "high", "xhigh", "max"]; }
|
|
386
|
+
// `/model` opens an arrow-key picker, not a one-shot command → restart.
|
|
387
|
+
getModelSwitchStrategy() { return "restart"; }
|
|
388
|
+
async listModels() {
|
|
389
|
+
// muse has no models subcommand (the command table is: resume, exec,
|
|
390
|
+
// config, export, trace, skills, plugins, sandbox, schema, serve,
|
|
391
|
+
// session-message, mcp, auth, login, logout, init). This set was read off
|
|
392
|
+
// the live `/model` picker; the `-contributor` variants are the same models
|
|
393
|
+
// with content sharing enabled, which the picker spells out.
|
|
394
|
+
return [
|
|
395
|
+
{ id: "muse-spark-1.3", label: "muse-spark-1.3" },
|
|
396
|
+
{ id: "muse-spark-1.3-contributor", label: "muse-spark-1.3-contributor (shares content)" },
|
|
397
|
+
{ id: "muse-spark-1.2", label: "muse-spark-1.2" },
|
|
398
|
+
{ id: "muse-spark-1.2-contributor", label: "muse-spark-1.2-contributor (shares content)" },
|
|
399
|
+
];
|
|
400
|
+
}
|
|
401
|
+
async probeCLIEnv() {
|
|
402
|
+
const { probeCliVersion } = await import("./types.js");
|
|
403
|
+
// The selected model is the one thing muse persists where we can read it.
|
|
404
|
+
let currentModel;
|
|
405
|
+
try {
|
|
406
|
+
const settings = JSON.parse(readFileSync(this.settingsPath(), "utf-8"));
|
|
407
|
+
if (typeof settings.model === "string")
|
|
408
|
+
currentModel = settings.model;
|
|
409
|
+
}
|
|
410
|
+
catch { /* best effort */ }
|
|
411
|
+
return { version: probeCliVersion(this.binaryPath), models: await this.listModels(), currentModel };
|
|
412
|
+
}
|
|
413
|
+
cleanup(config) {
|
|
414
|
+
try {
|
|
415
|
+
const settingsPath = this.settingsPath();
|
|
416
|
+
const root = JSON.parse(readFileSync(settingsPath, "utf-8"));
|
|
417
|
+
if (root.mcpServers) {
|
|
418
|
+
for (const name of Object.keys(config.mcpServers)) {
|
|
419
|
+
delete root.mcpServers[this.mcpKey(name, config.instanceName)];
|
|
420
|
+
}
|
|
421
|
+
writeFileSync(settingsPath, JSON.stringify(root, null, 2));
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
catch { /* best effort */ }
|
|
425
|
+
try {
|
|
426
|
+
removeMarker(join(config.workingDirectory, "AGENTS.md"), config.instanceName);
|
|
427
|
+
}
|
|
428
|
+
catch { /* best effort */ }
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
/** Every `<year>/<month>/<day>/<uuid>` directory under the session store. */
|
|
432
|
+
export function museSessionDirs(root) {
|
|
433
|
+
const out = [];
|
|
434
|
+
const children = (dir) => {
|
|
435
|
+
try {
|
|
436
|
+
return readdirSync(dir);
|
|
437
|
+
}
|
|
438
|
+
catch {
|
|
439
|
+
return [];
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
for (const year of children(root)) {
|
|
443
|
+
if (!/^\d{4}$/.test(year))
|
|
444
|
+
continue;
|
|
445
|
+
for (const month of children(join(root, year))) {
|
|
446
|
+
for (const day of children(join(root, year, month))) {
|
|
447
|
+
for (const session of children(join(root, year, month, day))) {
|
|
448
|
+
out.push(join(root, year, month, day, session));
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
return out;
|
|
454
|
+
}
|
|
455
|
+
//# sourceMappingURL=muse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"muse.js","sourceRoot":"","sources":["../../src/backend/muse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC/G,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAuH,aAAa,EAAE,UAAU,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAChN,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEnE,wFAAwF;AACxF,MAAM,aAAa,GAAG,oBAAoB,CAAC;AAE3C;;;;;GAKG;AAC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AK,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;gBAClD,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/backend/types.d.ts
CHANGED
|
@@ -52,6 +52,8 @@ export interface ErrorPattern {
|
|
|
52
52
|
* when the match can't be re-derived. Receives the LAST match in the pane,
|
|
53
53
|
* i.e. the most recent occurrence. */
|
|
54
54
|
formatMessage?: (match: RegExpMatchArray) => string;
|
|
55
|
+
/** Run the backend's live quota check before surfacing a quota notice. */
|
|
56
|
+
verifyQuota?: boolean;
|
|
55
57
|
/** Skip the 5-min per-type notification cooldown so every occurrence notifies
|
|
56
58
|
* (e.g. Kiro "Response timed out" — each timeout should reach the user). */
|
|
57
59
|
skipCooldown?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/backend/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/backend/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAwG1C,mEAAmE;AACnE,MAAM,CAAC,MAAM,4BAA4B,GAAG,KAAK,CAAC;AAElD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;IAC1C,MAAM,EAAE,QAAQ,EAAG,gDAAgD;CACpE,CAAC;AAEF,kEAAkE;AAClE,MAAM,UAAU,iBAAiB,CAAC,WAAmB,EAAE,KAAa;IAClE,MAAM,OAAO,GAAG,sBAAsB,CAAC,WAAW,CAAC,CAAC;IACpD,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC,CAAC,iCAAiC;IAC5D,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC7B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,WAAmB,EAAE,KAAa;IACpE,IAAI,CAAC,iBAAiB,CAAC,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC;QAC3C,OAAO,CAAC,IAAI,CAAC,kBAAkB,KAAK,uCAAuC,WAAW,0BAA0B,CAAC,CAAC;IACpH,CAAC;AACH,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,UAAU,CAAC,CAAS;IAClC,OAAO,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC;AACzC,CAAC"}
|
|
@@ -4,6 +4,12 @@ export declare class AccessManager {
|
|
|
4
4
|
private statePath;
|
|
5
5
|
private state;
|
|
6
6
|
private failedAttempts;
|
|
7
|
+
/**
|
|
8
|
+
* The mode that came out of the state file, or undefined when the file had
|
|
9
|
+
* none. Kept separately because the constructor fills `state.mode` in from
|
|
10
|
+
* the config when the file is silent, after which the two are indistinguishable.
|
|
11
|
+
*/
|
|
12
|
+
private persistedMode?;
|
|
7
13
|
constructor(config: AccessConfig, statePath: string);
|
|
8
14
|
private persist;
|
|
9
15
|
private pruneExpired;
|
|
@@ -13,6 +19,20 @@ export declare class AccessManager {
|
|
|
13
19
|
confirmCode(code: string, callerUserId?: string): boolean;
|
|
14
20
|
setMode(mode: "pairing" | "locked" | "open"): void;
|
|
15
21
|
getMode(): "pairing" | "locked" | "open";
|
|
22
|
+
/**
|
|
23
|
+
* The configured mode that the state file is overriding, or null when they
|
|
24
|
+
* agree or nothing was persisted.
|
|
25
|
+
*
|
|
26
|
+
* State wins on purpose — a pairing that happened at runtime must survive a
|
|
27
|
+
* fleet restart — but the first `persist()` freezes whatever the mode was at
|
|
28
|
+
* the time, and from then on editing `access.mode` in fleet.yaml changes
|
|
29
|
+
* nothing. Without this, that reads as "my config edit did nothing" with no
|
|
30
|
+
* way to find out why.
|
|
31
|
+
*
|
|
32
|
+
* Reported rather than logged from here: the CLI also builds an AccessManager
|
|
33
|
+
* with a synthetic config, where a mismatch means nothing.
|
|
34
|
+
*/
|
|
35
|
+
overriddenConfigMode(): "pairing" | "locked" | "open" | null;
|
|
16
36
|
getAllowedUsers(): (number | string)[];
|
|
17
37
|
removeUser(userId: number | string): boolean;
|
|
18
38
|
}
|
|
@@ -5,6 +5,12 @@ export class AccessManager {
|
|
|
5
5
|
statePath;
|
|
6
6
|
state;
|
|
7
7
|
failedAttempts = new Map();
|
|
8
|
+
/**
|
|
9
|
+
* The mode that came out of the state file, or undefined when the file had
|
|
10
|
+
* none. Kept separately because the constructor fills `state.mode` in from
|
|
11
|
+
* the config when the file is silent, after which the two are indistinguishable.
|
|
12
|
+
*/
|
|
13
|
+
persistedMode;
|
|
8
14
|
constructor(config, statePath) {
|
|
9
15
|
this.config = config;
|
|
10
16
|
this.statePath = statePath;
|
|
@@ -13,6 +19,7 @@ export class AccessManager {
|
|
|
13
19
|
try {
|
|
14
20
|
const raw = readFileSync(statePath, "utf8");
|
|
15
21
|
const saved = JSON.parse(raw);
|
|
22
|
+
this.persistedMode = saved.mode;
|
|
16
23
|
this.state = {
|
|
17
24
|
mode: saved.mode,
|
|
18
25
|
allowed_users: saved.allowed_users ?? [],
|
|
@@ -138,6 +145,24 @@ export class AccessManager {
|
|
|
138
145
|
getMode() {
|
|
139
146
|
return this.state.mode ?? this.config.mode;
|
|
140
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* The configured mode that the state file is overriding, or null when they
|
|
150
|
+
* agree or nothing was persisted.
|
|
151
|
+
*
|
|
152
|
+
* State wins on purpose — a pairing that happened at runtime must survive a
|
|
153
|
+
* fleet restart — but the first `persist()` freezes whatever the mode was at
|
|
154
|
+
* the time, and from then on editing `access.mode` in fleet.yaml changes
|
|
155
|
+
* nothing. Without this, that reads as "my config edit did nothing" with no
|
|
156
|
+
* way to find out why.
|
|
157
|
+
*
|
|
158
|
+
* Reported rather than logged from here: the CLI also builds an AccessManager
|
|
159
|
+
* with a synthetic config, where a mismatch means nothing.
|
|
160
|
+
*/
|
|
161
|
+
overriddenConfigMode() {
|
|
162
|
+
if (this.persistedMode === undefined)
|
|
163
|
+
return null;
|
|
164
|
+
return this.persistedMode === this.config.mode ? null : this.config.mode;
|
|
165
|
+
}
|
|
141
166
|
getAllowedUsers() {
|
|
142
167
|
return [...this.state.allowed_users];
|
|
143
168
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"access-manager.js","sourceRoot":"","sources":["../../src/channel/access-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAgB1C,MAAM,OAAO,aAAa;IAChB,MAAM,CAAe;IACrB,SAAS,CAAS;IAClB,KAAK,CAAc;IACnB,cAAc,GAAwD,IAAI,GAAG,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"access-manager.js","sourceRoot":"","sources":["../../src/channel/access-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAgB1C,MAAM,OAAO,aAAa;IAChB,MAAM,CAAe;IACrB,SAAS,CAAS;IAClB,KAAK,CAAc;IACnB,cAAc,GAAwD,IAAI,GAAG,EAAE,CAAC;IACxF;;;;OAIG;IACK,aAAa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;QAClB,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS;YAAE,OAAO,IAAI,CAAC;QAClD,OAAO,IAAI,CAAC,aAAa,KAAK,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAC3E,CAAC;IAED,eAAe;QACb,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IACvC,CAAC;IAED,UAAU,CAAC,MAAuB;QAChC,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QAC3B,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;QACvE,IAAI,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC;YACf,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACxC,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -21,6 +21,9 @@ export declare const DISCORD_START_BACKEND_CHOICES: readonly [{
|
|
|
21
21
|
}, {
|
|
22
22
|
readonly name: "Grok Build";
|
|
23
23
|
readonly value: "grok";
|
|
24
|
+
}, {
|
|
25
|
+
readonly name: "Meta Muse Code";
|
|
26
|
+
readonly value: "muse";
|
|
24
27
|
}];
|
|
25
28
|
export interface DiscordAdapterOptions {
|
|
26
29
|
id: string;
|