angelia-gateway 0.3.25 → 0.3.27
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 +4 -3
- package/dist/adapters/inbox.js +9 -8
- package/dist/adapters/telegram/adapter.js +4 -0
- package/dist/adapters/whatsapp/adapter.js +3 -2
- package/dist/adapters/whatsapp/parse.js +6 -2
- package/dist/brain/claude.js +2 -2
- package/dist/brain/codex.js +2 -2
- package/dist/brain/locate.js +1 -1
- package/dist/brain/tmux.js +115 -10
- package/dist/brain/tui-permissions.js +2 -2
- package/dist/brain/tui.js +84 -15
- package/dist/build.json +3 -3
- package/dist/capabilities/compile.js +4 -5
- package/dist/core/deliver/text.js +17 -3
- package/dist/core/orchestrator.js +53 -3
- package/dist/core/paths.js +46 -3
- package/dist/daemon/daemon.js +5 -5
- package/dist/daemon/launchd.js +128 -0
- package/dist/daemon/restart.js +69 -18
- package/dist/daemon/self.js +1 -1
- package/dist/daemon/service.js +61 -131
- package/dist/daemon/systemd.js +136 -0
- package/dist/daemon/update.js +7 -13
- package/dist/instance/config/load.js +3 -0
- package/dist/instance/config/schema.js +3 -0
- package/dist/instance/guide.js +2 -1
- package/dist/instance/instance.js +22 -4
- package/dist/instance/onboard.js +2 -2
- package/dist/instance/profile-files.js +4 -6
- package/dist/instance/profiles.js +1 -1
- package/dist/instance/workspace-commit.js +2 -2
- package/package.json +1 -1
- package/scripts/tui-permission-hook.mjs +3 -1
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ curl -fsSL https://useangelia.com/install | sh
|
|
|
16
16
|
<p align="center">
|
|
17
17
|
<a href="https://useangelia.com"><img src="https://img.shields.io/badge/Website-useangelia.com-D06B6B?style=for-the-badge" alt="Website"></a>
|
|
18
18
|
<a href="https://github.com/korengast/angelia/releases/latest"><img src="https://img.shields.io/github/v/release/korengast/angelia?style=for-the-badge&label=Release%20(signed)&color=1A120D" alt="Latest release, signed"></a>
|
|
19
|
-
<a href="#backends"><img src="https://img.shields.io/badge/Platform-macOS-A8474B?style=for-the-badge&logo=apple&logoColor=white" alt="macOS"></a>
|
|
19
|
+
<a href="#backends"><img src="https://img.shields.io/badge/Platform-macOS%20%7C%20Linux-A8474B?style=for-the-badge&logo=apple&logoColor=white" alt="macOS and Linux"></a>
|
|
20
20
|
<a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-green?style=for-the-badge" alt="License: MIT"></a>
|
|
21
21
|
</p>
|
|
22
22
|
|
|
@@ -65,6 +65,7 @@ You need:
|
|
|
65
65
|
- **Node 22.23.4+, 24.22.1+ or 26.12.1+** and **git** (it comes with the Xcode command line tools).
|
|
66
66
|
- **A supported coding agent CLI**, installed and signed in to your own account. See [Backends](#backends).
|
|
67
67
|
- **A Telegram bot.** Open [@BotFather](https://t.me/BotFather), send `/newbot` and keep the token ready. It is stored on your disk, never in a chat.
|
|
68
|
+
- **On Linux:** Node 22.23.4+ from nodejs.org or nvm (distro Node is usually older), and `git`. `tmux` from apt is fine, but below 3.7 Angelia prints a warning; the `brew` advice above and below is for macOS.
|
|
68
69
|
- Optional: `brew install openai-whisper ffmpeg` for voice notes, and `brew install tmux` (3.7+) to run a Claude Code profile in its full screen, so the chat also shows up in the Claude app.
|
|
69
70
|
|
|
70
71
|
After installation:
|
|
@@ -75,7 +76,7 @@ angelia service install # keep it running: starts at login, comes back after a
|
|
|
75
76
|
|
|
76
77
|
Then send *"what is in this folder?"* to your bot. The agent answers from the profile's folder.
|
|
77
78
|
|
|
78
|
-
> **Linux
|
|
79
|
+
> **Linux is experimental:** `angelia service install` writes a systemd user unit. On Ubuntu 26.04 with systemd 259 the service, a reboot with linger and `/restart` were measured; `angelia update`, a `$` in the config path and the `.inbox` link are not yet (the [runbook checks](docs/runbook.md#linux-server-over-tailscale)). `angelia init` offers the service on macOS only, so on Linux run `angelia service install` yourself. Sandboxed profiles work on Linux only with the extra bwrap step in the server guide, and not in `bypassPermissions`. Still macOS only until their sub-projects land: `angelia jobs`, voice replies and the pi backend. [Angelia on a Linux server](docs/linux-server.md) walks a VPS from empty to running. **Windows:** not yet.
|
|
79
80
|
|
|
80
81
|
---
|
|
81
82
|
|
|
@@ -232,7 +233,7 @@ Each chat keeps one warm process, so a message never waits for a CLI to start. P
|
|
|
232
233
|
|
|
233
234
|
Angelia is not an agent and will not become one. No second model, no skills system, no memory framework, no scheduler in the daemon, no plugin marketplace. Knowledge belongs in the profile's instruction file; scheduled work belongs to the operating system, which `angelia jobs` only sets up. No payments: the agent sends you a checkout link and you pay on your phone.
|
|
234
235
|
|
|
235
|
-
**Next:** an OpenCode backend.
|
|
236
|
+
**Next:** an OpenCode backend. `/profile` to switch which assistant answers a chat.
|
|
236
237
|
|
|
237
238
|
---
|
|
238
239
|
|
package/dist/adapters/inbox.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { constants, lstatSync, mkdirSync, readdirSync, realpathSync, rmSync } from 'node:fs';
|
|
2
|
-
import { open } from 'node:fs/promises';
|
|
1
|
+
import { constants, createWriteStream, lstatSync, mkdirSync, readdirSync, realpathSync, rmSync } from 'node:fs';
|
|
3
2
|
import { randomBytes } from 'node:crypto';
|
|
4
3
|
import { join } from 'node:path';
|
|
5
4
|
import { Readable } from 'node:stream';
|
|
6
5
|
import { pipeline } from 'node:stream/promises';
|
|
7
|
-
import {
|
|
6
|
+
import { openNoFollow } from '../core/paths.js';
|
|
8
7
|
/** A file from a chat is downloaded up to this size, on both platforms (Telegram's Bot API serves no more). */
|
|
9
8
|
export const MAX_INBOUND = 20 * 1024 * 1024;
|
|
10
9
|
/** One profile's .inbox stays under this; the oldest files go first. An open group cannot fill the disk. */
|
|
@@ -21,8 +20,8 @@ class TooBig extends Error {
|
|
|
21
20
|
*
|
|
22
21
|
* The daemon runs outside every sandbox, and `.inbox` sits in the one folder every agent may write. An
|
|
23
22
|
* agent talked into `ln -s ~/Library/LaunchAgents .inbox` would otherwise have the daemon write a
|
|
24
|
-
* sender's file there. So `.inbox` must be a plain folder, and on
|
|
25
|
-
*
|
|
23
|
+
* sender's file there. So `.inbox` must be a plain folder, and on every platform the file is opened with
|
|
24
|
+
* `openNoFollow`, which refuses a link anywhere in the path, so swapping `.inbox` for a link between the
|
|
26
25
|
* check and the write does not work either.
|
|
27
26
|
*/
|
|
28
27
|
export async function saveInbound(profileDir, ext, source, max = MAX_INBOUND, limit = INBOX_LIMIT) {
|
|
@@ -38,12 +37,14 @@ export async function saveInbound(profileDir, ext, source, max = MAX_INBOUND, li
|
|
|
38
37
|
yield c;
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
|
-
const
|
|
40
|
+
const fd = openNoFollow(dest, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL, 0o600);
|
|
41
|
+
// The stream owns the descriptor from here (the path is ignored when an fd is given) and closes it on finish or error; destroy() covers a failure before it started.
|
|
42
|
+
const out = createWriteStream('', { fd });
|
|
42
43
|
try {
|
|
43
|
-
await pipeline(Readable.from(capped()),
|
|
44
|
+
await pipeline(Readable.from(capped()), out);
|
|
44
45
|
}
|
|
45
46
|
catch (e) {
|
|
46
|
-
|
|
47
|
+
out.destroy();
|
|
47
48
|
rmSync(dest, { force: true });
|
|
48
49
|
if (e instanceof TooBig)
|
|
49
50
|
return undefined;
|
|
@@ -211,11 +211,15 @@ export class TelegramAdapter {
|
|
|
211
211
|
return (e.type === 'mention' && word === me) || (e.type === 'bot_command' && word.endsWith(me));
|
|
212
212
|
}) ||
|
|
213
213
|
m.reply_to_message?.from?.id === ctx.me.id;
|
|
214
|
+
// What a reply quotes: the part the user selected when there is one (Bot API TextQuote; the only text
|
|
215
|
+
// a reply to another chat, external_reply, carries), else the whole message replied to, or its caption.
|
|
216
|
+
const quoted = m.quote?.text || m.reply_to_message?.text || m.reply_to_message?.caption || undefined;
|
|
214
217
|
const head = {
|
|
215
218
|
platform: 'telegram', chat,
|
|
216
219
|
thread: m.message_thread_id !== undefined && m.is_topic_message ? String(m.message_thread_id) : undefined,
|
|
217
220
|
sender: String(m.from?.id ?? ''), senderName: m.from?.first_name,
|
|
218
221
|
text, isGroup, mentioned,
|
|
222
|
+
...(quoted ? { quoted } : {}),
|
|
219
223
|
};
|
|
220
224
|
const inbox = this.opts.inboxFor(head);
|
|
221
225
|
const file = inbox ? m.document ?? m.photo?.at(-1) ?? m.voice ?? m.audio ?? m.video : undefined;
|
|
@@ -6,7 +6,7 @@ import { ChatChains, MAX_INBOUND, SenderQuota, saveInbound } from '../inbox.js';
|
|
|
6
6
|
import { makeWASocket, useMultiFileAuthState, fetchLatestBaileysVersion, downloadMediaMessage, DisconnectReason } from 'baileys';
|
|
7
7
|
import qrcode from 'qrcode-terminal';
|
|
8
8
|
import { LidMap, normalizeJid } from './ids.js';
|
|
9
|
-
import { MAX_MENTIONS, parseMessage, SeenIds, withMentions } from './parse.js';
|
|
9
|
+
import { MAX_MENTIONS, parseMessage, SeenIds, toInbound, withMentions } from './parse.js';
|
|
10
10
|
import { GroupCache } from './groups.js';
|
|
11
11
|
import { SentMessages } from './sent.js';
|
|
12
12
|
import { isOpus } from '../../core/deliver/media.js';
|
|
@@ -300,7 +300,8 @@ export class WhatsAppAdapter extends EventEmitter {
|
|
|
300
300
|
if (m.key.id && !this.seen.first(`${p.chat}/${m.key.id}`))
|
|
301
301
|
return;
|
|
302
302
|
const senderId = this.lids.phoneFor(p.sender);
|
|
303
|
-
|
|
303
|
+
// One builder for the Inbound (toInbound), so a field parseMessage adds cannot be dropped here again.
|
|
304
|
+
const { media: _none, ...head } = toInbound(p, senderId, []);
|
|
304
305
|
const inbox = this.opts.inboxFor(head);
|
|
305
306
|
const note = (why) => { head.text = `${head.text}${head.text ? '\n' : ''}[${why}]`; };
|
|
306
307
|
let fetchIt = false;
|
|
@@ -99,11 +99,15 @@ export function parseMessage(m, us) {
|
|
|
99
99
|
const mentionedJids = Array.isArray(ctx?.mentionedJid) ? ctx.mentionedJid : [];
|
|
100
100
|
const quotedBy = ctx?.participant ? bareId(String(ctx.participant)) : '';
|
|
101
101
|
const mentioned = mentionedJids.some((j) => ours.has(bareId(String(j)))) || (!!quotedBy && ours.has(quotedBy));
|
|
102
|
-
|
|
102
|
+
const q = ctx?.quotedMessage ? messageContent({ key: {}, message: ctx.quotedMessage }) : undefined;
|
|
103
|
+
// Strings only, as for the message itself: a field of another type is not text.
|
|
104
|
+
const quoted = q ? [q.conversation, q.extendedTextMessage?.text, q.imageMessage?.caption, q.videoMessage?.caption, q.documentMessage?.caption]
|
|
105
|
+
.find((v) => typeof v === 'string' && v !== '') : undefined;
|
|
106
|
+
return { chat, sender, senderName: m.pushName ?? undefined, text, ...(quoted ? { quoted } : {}), isGroup, mentioned, media };
|
|
103
107
|
}
|
|
104
108
|
/** ParsedMessage -> Inbound, with the sender written the way routing.yaml expects (bare phone or lid). */
|
|
105
109
|
export function toInbound(p, senderId, mediaPaths) {
|
|
106
|
-
return { platform: 'whatsapp', chat: p.chat, sender: senderId, senderName: p.senderName, text: p.text, isGroup: p.isGroup, mentioned: p.mentioned, media: mediaPaths };
|
|
110
|
+
return { platform: 'whatsapp', chat: p.chat, sender: senderId, senderName: p.senderName, text: p.text, ...(p.quoted ? { quoted: p.quoted } : {}), isGroup: p.isGroup, mentioned: p.mentioned, media: mediaPaths };
|
|
107
111
|
}
|
|
108
112
|
/** At most this many members are tagged in one message: a tag notifies even a member who muted the group. */
|
|
109
113
|
export const MAX_MENTIONS = 5;
|
package/dist/brain/claude.js
CHANGED
|
@@ -171,7 +171,7 @@ export class ClaudeBrain extends EventEmitter {
|
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
/** `id` may be a prefix of a pending request id (the chat sees the first 8 chars). */
|
|
174
|
-
answerPermission(id, allow,
|
|
174
|
+
answerPermission(id, allow, how = {}) {
|
|
175
175
|
const full = this.permissions.take(id);
|
|
176
176
|
if (!full)
|
|
177
177
|
return false;
|
|
@@ -181,7 +181,7 @@ export class ClaudeBrain extends EventEmitter {
|
|
|
181
181
|
this.requested.delete(id);
|
|
182
182
|
this.send({
|
|
183
183
|
type: 'control_response',
|
|
184
|
-
response: { subtype: 'success', request_id: id, response: allow ? { behavior: 'allow', updatedInput: input ?? asked } : { behavior: 'deny', message: 'Denied from chat' } },
|
|
184
|
+
response: { subtype: 'success', request_id: id, response: allow ? { behavior: 'allow', updatedInput: how.input ?? asked } : { behavior: 'deny', message: how.message ?? 'Denied from chat' } },
|
|
185
185
|
});
|
|
186
186
|
return true;
|
|
187
187
|
}
|
package/dist/brain/codex.js
CHANGED
|
@@ -398,7 +398,7 @@ export class CodexBrain extends EventEmitter {
|
|
|
398
398
|
this.lines.off('exit', onExit);
|
|
399
399
|
}
|
|
400
400
|
}
|
|
401
|
-
answerPermission(id, allow) {
|
|
401
|
+
answerPermission(id, allow, how = {}) {
|
|
402
402
|
const full = this.permissions.take(id);
|
|
403
403
|
if (!full)
|
|
404
404
|
return false;
|
|
@@ -410,7 +410,7 @@ export class CodexBrain extends EventEmitter {
|
|
|
410
410
|
this.reply(p.rpcId, { permissions: allow ? p.grant ?? {} : {}, scope: 'turn' });
|
|
411
411
|
return true;
|
|
412
412
|
}
|
|
413
|
-
const decision = p.kind === 'legacy' ? (allow ? 'approved' : { denied: { rejection: 'Denied in the chat' } }) : (allow ? 'accept' : 'decline');
|
|
413
|
+
const decision = p.kind === 'legacy' ? (allow ? 'approved' : { denied: { rejection: how.message ?? 'Denied in the chat' } }) : (allow ? 'accept' : 'decline');
|
|
414
414
|
this.reply(p.rpcId, { decision });
|
|
415
415
|
return true;
|
|
416
416
|
}
|
package/dist/brain/locate.js
CHANGED
|
@@ -8,7 +8,7 @@ export const DEFAULT_BIN = { 'claude-code': 'claude', grok: 'grok', pi: 'pi', co
|
|
|
8
8
|
* ~/.local/bin, every tmux pane ran `claude`, found nothing and died, and the chat heard only
|
|
9
9
|
* "the agent exited while starting". */
|
|
10
10
|
export function fallbackDirs(home = homedir()) {
|
|
11
|
-
return [join(home, '.local', 'bin'), '/opt/homebrew/bin', '/usr/local/bin', join(home, '.bun', 'bin'), join(home, '.npm-global', 'bin')];
|
|
11
|
+
return [join(home, '.local', 'bin'), '/opt/homebrew/bin', '/usr/local/bin', join(home, '.bun', 'bin'), join(home, '.npm-global', 'bin'), '/usr/bin'];
|
|
12
12
|
}
|
|
13
13
|
function executable(path) {
|
|
14
14
|
try {
|
package/dist/brain/tmux.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { execFile } from 'node:child_process';
|
|
2
2
|
import { realpathSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
|
+
import { inServiceCgroup } from '../daemon/systemd.js';
|
|
4
5
|
/** Angelia's own tmux server. Sessions on this socket outlive the daemon, so a restart — or the
|
|
5
6
|
* crash the launchd unit is meant to catch — leaves every agent exactly where it was, and nothing
|
|
6
7
|
* else on the machine shares the socket. ANGELIA_TMUX_SOCKET moves it (tests). */
|
|
@@ -15,13 +16,26 @@ export function tmuxSocketPath(env = process.env) {
|
|
|
15
16
|
catch { /* not there: tmux makes it */ }
|
|
16
17
|
return join(base, `tmux-${process.getuid?.() ?? 0}`, TMUX_SOCKET);
|
|
17
18
|
}
|
|
19
|
+
/** The call run in a transient scope of its own: under systemd the service's KillMode kills every
|
|
20
|
+
* process in its cgroup, and the tmux server must outlive the daemon. */
|
|
21
|
+
export function scopedArgv(bin, args) {
|
|
22
|
+
return ['systemd-run', ['--user', '--scope', '--collect', '--quiet', '--description=angelia tmux', bin, ...args]];
|
|
23
|
+
}
|
|
24
|
+
/** `scope`: the call may start the server, so in angelia.service it goes through `systemd-run --scope`.
|
|
25
|
+
* When systemd-run is missing or fails (no user bus, a daemon in some other unit), the plain call
|
|
26
|
+
* runs once instead: tmux's own errors never start with "Failed to". `inService` overrides the cgroup check (tests). */
|
|
18
27
|
export function tmux(args, opts = {}) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
28
|
+
const full = ['-L', opts.socket ?? TMUX_SOCKET, ...args];
|
|
29
|
+
const run = (bin, argv) => new Promise((resolve) => {
|
|
30
|
+
execFile(bin, argv, { env: opts.env, maxBuffer: 8 << 20 }, (err, stdout, stderr) => {
|
|
31
|
+
const e = err;
|
|
32
|
+
resolve({ code: e ? Number(e.code ?? 1) : 0, out: stdout ?? '', err: stderr ?? '', missing: e?.code === 'ENOENT' });
|
|
23
33
|
});
|
|
24
34
|
});
|
|
35
|
+
const plain = () => run(opts.bin ?? 'tmux', full);
|
|
36
|
+
if (!(opts.scope && (opts.inService ?? inServiceCgroup())))
|
|
37
|
+
return plain();
|
|
38
|
+
return run(...scopedArgv(opts.bin ?? 'tmux', full)).then((r) => (r.missing || (r.code !== 0 && r.err.startsWith('Failed to')) ? plain() : r));
|
|
25
39
|
}
|
|
26
40
|
/** Put `text` in the named paste buffer. Through a file, never on the command line: tmux refuses a
|
|
27
41
|
* command longer than about 16 KB ("command too long"), so `set-buffer` silently dropped every long
|
|
@@ -120,12 +134,17 @@ export function permissionDialog(pane) {
|
|
|
120
134
|
/** A directory Claude Code has not been run in before opens a trust dialog before the first
|
|
121
135
|
* prompt, with "No, exit" preselected. Print mode never shows it. */
|
|
122
136
|
export const TRUST_MARKER = 'trust this folder';
|
|
137
|
+
/** The trust dialog is the open start dialog (see startDialog): its yes row is the last anchor on
|
|
138
|
+
* screen, with "No, exit" next to it. A trust frame left in the history above a later dialog is not
|
|
139
|
+
* open, so Enter goes to neither by mistake. */
|
|
123
140
|
export function trustDialogOpen(pane) {
|
|
124
|
-
|
|
141
|
+
const d = startDialog(pane, TRUST_MARKER, TRUST_ANSWERS);
|
|
142
|
+
return !!d && d.lines.slice(Math.max(0, d.at - 3), d.at + 4).some((l) => l.includes('No, exit'));
|
|
125
143
|
}
|
|
126
|
-
/** The trust dialog's cursor is on the "yes" row, so Enter accepts and nothing else. */
|
|
144
|
+
/** The open trust dialog's cursor is on the "yes" row, so Enter accepts and nothing else. */
|
|
127
145
|
export function trustAccepted(pane) {
|
|
128
|
-
|
|
146
|
+
const d = startDialog(pane, TRUST_MARKER, TRUST_ANSWERS);
|
|
147
|
+
return !!d && d.cursor === d.at;
|
|
129
148
|
}
|
|
130
149
|
/** A folder whose CLAUDE.md imports a file outside it (every profile does: the shared doctrine in
|
|
131
150
|
* `_shared/`) opens a second dialog on first run, "Allow external CLAUDE.md file imports?", with
|
|
@@ -133,11 +152,97 @@ export function trustAccepted(pane) {
|
|
|
133
152
|
* Claude has not seen before sits on this screen until it is answered. */
|
|
134
153
|
export const IMPORTS_MARKER = 'Allow external CLAUDE.md file imports?';
|
|
135
154
|
export function importsDialogOpen(pane) {
|
|
136
|
-
|
|
155
|
+
const d = startDialog(pane, IMPORTS_MARKER, IMPORTS_ANSWERS);
|
|
156
|
+
return !!d && d.lines.slice(d.at + 1).some((l) => l.includes('disable external imports'));
|
|
137
157
|
}
|
|
138
|
-
/** The cursor is on "Yes, allow external imports", so Enter accepts and nothing else. */
|
|
158
|
+
/** The cursor is on "Yes, allow external imports" of the open dialog, so Enter accepts and nothing else. */
|
|
139
159
|
export function importsAccepted(pane) {
|
|
140
|
-
|
|
160
|
+
const d = startDialog(pane, IMPORTS_MARKER, IMPORTS_ANSWERS);
|
|
161
|
+
return !!d && d.lines[d.cursor].includes('allow external imports');
|
|
162
|
+
}
|
|
163
|
+
/** A folder passed with `--add-dir` that Claude Code has not worked in opens its own dialog before
|
|
164
|
+
* the first prompt, "Adding a new directory:" with the folder on the next line and "No, exit"
|
|
165
|
+
* preselected. New in claude 2.1.326 (2026-11-16): every new session of a profile with add_dirs sat
|
|
166
|
+
* on it until the start timed out, so those chats got no answer. */
|
|
167
|
+
export const ADD_DIR_MARKER = 'Adding a new directory:';
|
|
168
|
+
/** Each start dialog is found by one line (anchorOf): the add-dir and imports titles, and the trust
|
|
169
|
+
* dialog's yes row (its title has changed between versions: "Accessing workspace:" on 2.1.326). Its
|
|
170
|
+
* answers are the rows the cursor may be on. */
|
|
171
|
+
const TRUST_ANSWERS = ['No, exit', TRUST_MARKER];
|
|
172
|
+
const IMPORTS_ANSWERS = ['disable external imports', 'allow external imports'];
|
|
173
|
+
const ADD_DIR_ANSWERS = ['No, exit', 'Yes, add it'];
|
|
174
|
+
/** Which start dialog `line` anchors, if any. A title must open its line (after the border and
|
|
175
|
+
* indent): a folder shown as "/x/Adding a new directory: /listed" names the dialog, it is not one. */
|
|
176
|
+
function anchorOf(line) {
|
|
177
|
+
const t = line.replace(/[│┃║]/g, '').trimStart();
|
|
178
|
+
if (t.startsWith(ADD_DIR_MARKER))
|
|
179
|
+
return ADD_DIR_MARKER;
|
|
180
|
+
if (t.startsWith(IMPORTS_MARKER))
|
|
181
|
+
return IMPORTS_MARKER;
|
|
182
|
+
return line.includes(TRUST_MARKER) ? TRUST_MARKER : null;
|
|
183
|
+
}
|
|
184
|
+
/** The open start dialog found by `marker`: its lines, the anchor's index and the cursor's line, or
|
|
185
|
+
* null when another start dialog, or none, is the one open. The dialog is drawn at the foot of the
|
|
186
|
+
* screen, so the last anchor of any start dialog is the live one; an earlier one is history (a
|
|
187
|
+
* resumed conversation that quotes the dialog, or the frame of a dialog already answered). A screen
|
|
188
|
+
* with an input box below the anchor is past every dialog: the quote is in the conversation above
|
|
189
|
+
* the prompt. And the last ❯ on screen must be one of this dialog's `answers`: under an answered
|
|
190
|
+
* frame another dialog (a permission prompt) holds the cursor, and Enter would answer that one. */
|
|
191
|
+
function startDialog(pane, marker, answers) {
|
|
192
|
+
const lines = pane.replace(/\n+$/, '').split('\n');
|
|
193
|
+
let at = -1;
|
|
194
|
+
for (let i = lines.length - 1; i >= 0 && at < 0; i--)
|
|
195
|
+
if (anchorOf(lines[i]))
|
|
196
|
+
at = i;
|
|
197
|
+
if (at < 0 || anchorOf(lines[at]) !== marker)
|
|
198
|
+
return null;
|
|
199
|
+
if (inputBoxStrict(lines.slice(at + 1).join('\n')) !== null)
|
|
200
|
+
return null;
|
|
201
|
+
// The trust dialog's anchor is its yes row, with "No, exit" just above it; the others are titles.
|
|
202
|
+
const cursor = lastLine(lines, /❯/, lines.length);
|
|
203
|
+
if (cursor < (marker === TRUST_MARKER ? at - 3 : at + 1) || !answers.some((a) => lines[cursor].includes(a)))
|
|
204
|
+
return null;
|
|
205
|
+
return { lines, at, cursor };
|
|
206
|
+
}
|
|
207
|
+
/** The folder the add-dir dialog asks about, or null when that dialog is not open. Both answers must
|
|
208
|
+
* be drawn below its title: one line that merely names the dialog is not the dialog. */
|
|
209
|
+
export function addDirDialog(pane) {
|
|
210
|
+
const d = startDialog(pane, ADD_DIR_MARKER, ADD_DIR_ANSWERS);
|
|
211
|
+
if (!d)
|
|
212
|
+
return null;
|
|
213
|
+
const { lines, at } = d;
|
|
214
|
+
const below = lines.slice(at + 1);
|
|
215
|
+
if (!below.some((l) => l.includes('No, exit')) || !below.some((l) => l.includes('Yes, add it')))
|
|
216
|
+
return null;
|
|
217
|
+
// The folder is on the title's line or on the first line below it that has text: the real frame
|
|
218
|
+
// puts a blank line between (2.1.326), and a bordered frame draws │ on each side.
|
|
219
|
+
const strip = (l) => l.replace(/[│┃║]/g, '').trimEnd();
|
|
220
|
+
const inline = strip(lines[at].slice(lines[at].indexOf(ADD_DIR_MARKER) + ADD_DIR_MARKER.length));
|
|
221
|
+
let first = at;
|
|
222
|
+
if (!inline.trim()) {
|
|
223
|
+
first = lines.findIndex((l, i) => i > at && i < at + 4 && strip(l).trim());
|
|
224
|
+
if (first < 0)
|
|
225
|
+
return '';
|
|
226
|
+
}
|
|
227
|
+
const head = first === at ? inline : strip(lines[first]);
|
|
228
|
+
// A folder longer than the pane wraps onto the next lines: claude 2.1.326 (Ink) wraps at column 219
|
|
229
|
+
// of a 220-column pane and indents each continuation as far as the first line. Read on to the next
|
|
230
|
+
// blank line (or the answers) and take that indent off, or a listed folder would match the head of
|
|
231
|
+
// a longer one. A folder with a space at the wrap reads with a space too many: refused, never yes.
|
|
232
|
+
const indent = head.length - head.trimStart().length;
|
|
233
|
+
let dir = head.trim();
|
|
234
|
+
for (let i = first + 1; i < lines.length; i++) {
|
|
235
|
+
const more = strip(lines[i]);
|
|
236
|
+
if (!more.trim() || more.includes('No, exit') || more.includes('Yes, add it'))
|
|
237
|
+
break;
|
|
238
|
+
dir += more.startsWith(' '.repeat(indent)) ? more.slice(indent) : more.trimStart();
|
|
239
|
+
}
|
|
240
|
+
return dir;
|
|
241
|
+
}
|
|
242
|
+
/** The cursor is on "Yes, add it" of the open add-dir dialog, so Enter accepts and nothing else. */
|
|
243
|
+
export function addDirAccepted(pane) {
|
|
244
|
+
const d = startDialog(pane, ADD_DIR_MARKER, ADD_DIR_ANSWERS);
|
|
245
|
+
return !!d && d.lines[d.cursor].includes('Yes, add it');
|
|
141
246
|
}
|
|
142
247
|
/** The pasted text (or its collapsed chip) is in the input box, so Enter submits that and
|
|
143
248
|
* nothing else. Never press Enter without this. */
|
|
@@ -81,13 +81,13 @@ export class PermissionRelay {
|
|
|
81
81
|
}
|
|
82
82
|
/** The owner's answer, for the hook waiting on this request and no other. False when no hook waits
|
|
83
83
|
* for it any more, though the last poll had not seen it go: nothing is left behind for nobody. */
|
|
84
|
-
answer(id, allow) {
|
|
84
|
+
answer(id, allow, message) {
|
|
85
85
|
if (!this.open.delete(id))
|
|
86
86
|
return false;
|
|
87
87
|
const request = join(this.dir, `${id}.request.json`);
|
|
88
88
|
if (!existsSync(request))
|
|
89
89
|
return false;
|
|
90
|
-
this.put(`${id}.answer.json`, { allow });
|
|
90
|
+
this.put(`${id}.answer.json`, !allow && message ? { allow, message } : { allow });
|
|
91
91
|
// The hook can step aside between the check and the write; then its answer file goes too.
|
|
92
92
|
if (existsSync(request))
|
|
93
93
|
return true;
|
package/dist/brain/tui.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { execFile, execFileSync } from 'node:child_process';
|
|
2
2
|
import { createHash, randomUUID } from 'node:crypto';
|
|
3
3
|
import { EventEmitter } from 'node:events';
|
|
4
|
-
import { closeSync, existsSync, fstatSync, mkdirSync, openSync, readFileSync, readSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import { closeSync, existsSync, fstatSync, mkdirSync, openSync, readFileSync, readSync, realpathSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
5
5
|
import { homedir } from 'node:os';
|
|
6
|
-
import { join } from 'node:path';
|
|
6
|
+
import { join, resolve } from 'node:path';
|
|
7
7
|
import { fileURLToPath } from 'node:url';
|
|
8
8
|
import { cleanText } from '../core/types.js';
|
|
9
9
|
import { childEnv, CLAUDE_ENV, claudeTuiArgv, MIN_CLAUDE_VERSION, remoteControlName, STRIP_ENV, versionAtLeast } from './argv.js';
|
|
10
10
|
import { PermissionBook } from './brain.js';
|
|
11
|
-
import { importsAccepted, importsDialogOpen, loadBuffer, paneBusy, paneIdle, pasteLanded, permissionDialog, submitPasted, tmux, TMUX_SOCKET, trustAccepted, trustDialogOpen } from './tmux.js';
|
|
11
|
+
import { addDirAccepted, addDirDialog, importsAccepted, importsDialogOpen, loadBuffer, paneBusy, paneIdle, pasteLanded, permissionDialog, submitPasted, tmux, TMUX_SOCKET, trustAccepted, trustDialogOpen } from './tmux.js';
|
|
12
12
|
import { paneVerdict, PermissionRelay, RELAY_BEAT_MS, relayedPermission, ScreenDialogs } from './tui-permissions.js';
|
|
13
13
|
import { LOST_SESSION_LINE, placeTranscript, transcriptPath } from './transcripts.js';
|
|
14
14
|
import { readRecord } from '../capabilities/compile.js';
|
|
@@ -19,6 +19,8 @@ const PERMISSION_HOOK = fileURLToPath(new URL('../../scripts/tui-permission-hook
|
|
|
19
19
|
* daemon's ten-minute deny. */
|
|
20
20
|
const PERMISSION_HOOK_TIMEOUT_S = 900;
|
|
21
21
|
const POLL_MS = 700;
|
|
22
|
+
/** How long claude's add-dir dialog must stand before keys reach it (it drops them for ~1 s, 2.1.326). */
|
|
23
|
+
const ADD_DIR_SETTLE_MS = 1500;
|
|
22
24
|
const START_TIMEOUT_MS = 90_000;
|
|
23
25
|
const PROMPT_TIMEOUT_MS = 10 * 60_000;
|
|
24
26
|
/** A turn has no end time: a long build or a run of subagents may take hours, and `/stop` ends a
|
|
@@ -78,7 +80,7 @@ export function tmuxVersion() {
|
|
|
78
80
|
* rest into the CLI. Angelia strips control characters from every message (cleanText), so this is a
|
|
79
81
|
* warning and not a refusal; the upgrade closes whatever tmux itself might still let through.
|
|
80
82
|
*/
|
|
81
|
-
export function tmuxWarnings(profiles, version = tmuxVersion()) {
|
|
83
|
+
export function tmuxWarnings(profiles, version = tmuxVersion(), platform = process.platform) {
|
|
82
84
|
const tui = Object.entries(profiles).filter(([, p]) => p.tui && p.backend === 'claude-code').map(([n]) => n);
|
|
83
85
|
if (!tui.length)
|
|
84
86
|
return [];
|
|
@@ -87,7 +89,7 @@ export function tmuxWarnings(profiles, version = tmuxVersion()) {
|
|
|
87
89
|
const m = /(\d+)\.(\d+)/.exec(version);
|
|
88
90
|
if (!m || Number(m[1]) > 3 || (Number(m[1]) === 3 && Number(m[2]) >= 7))
|
|
89
91
|
return [];
|
|
90
|
-
return [`tui: true in ${tui.join(', ')}, and ${version} is older than 3.7, which is the first to clean pasted text. Angelia strips control characters from messages, but upgrade: brew upgrade tmux, then tmux -L angelia kill-server when the chats are quiet (every pane resumes on its next message)`];
|
|
92
|
+
return [`tui: true in ${tui.join(', ')}, and ${version} is older than 3.7, which is the first to clean pasted text. Angelia strips control characters from messages, but upgrade: ${platform === 'darwin' ? 'brew upgrade tmux' : 'upgrade tmux to 3.7+'}, then tmux -L angelia kill-server when the chats are quiet (every pane resumes on its next message)`];
|
|
91
93
|
}
|
|
92
94
|
/** The start of the reason a pane gives when it died before its first prompt. */
|
|
93
95
|
export const START_EXIT = 'the agent exited while starting';
|
|
@@ -223,8 +225,8 @@ export class TuiBrain extends EventEmitter {
|
|
|
223
225
|
get envPath() { return join(this.dir, 'env'); }
|
|
224
226
|
/** Every tmux call runs with the server's environment, never the agent's: the first call starts the
|
|
225
227
|
* server, and every profile's panes inherit what it started with. */
|
|
226
|
-
tm(args) {
|
|
227
|
-
return tmux(args, { env: this.opts.hostEnv ?? childEnv(process.env) });
|
|
228
|
+
tm(args, o = {}) {
|
|
229
|
+
return tmux(args, { env: this.opts.hostEnv ?? childEnv(process.env), ...o });
|
|
228
230
|
}
|
|
229
231
|
/** The launch, plus what decides the agent's environment and permissions: a change in any of them
|
|
230
232
|
* relaunches an idle pane. Claude reads the compiled settings once, at launch, so a new deny from
|
|
@@ -299,7 +301,7 @@ export class TuiBrain extends EventEmitter {
|
|
|
299
301
|
const argv = this.argv(resume);
|
|
300
302
|
// remain-on-exit off in the same call: the server reads the user's ~/.tmux.conf, and a dead pane
|
|
301
303
|
// left on screen would pass for a live session, so a turn would wait on it for ever.
|
|
302
|
-
const r = await this.tm(['new-session', '-d', '-s', this.name, '-c', this.profile.cwd, '-x', '220', '-y', '50', ...pinned, ...wrap, 'env', ...unset, ...argv, ';', 'set-option', '-w', '-t', this.name, 'remain-on-exit', 'off']);
|
|
304
|
+
const r = await this.tm(['new-session', '-d', '-s', this.name, '-c', this.profile.cwd, '-x', '220', '-y', '50', ...pinned, ...wrap, 'env', ...unset, ...argv, ';', 'set-option', '-w', '-t', this.name, 'remain-on-exit', 'off'], { scope: true });
|
|
303
305
|
if (r.code !== 0) {
|
|
304
306
|
rmSync(this.envPath, { force: true });
|
|
305
307
|
return `tmux could not start the session: ${r.err.trim() || 'new-session failed'}`;
|
|
@@ -307,6 +309,9 @@ export class TuiBrain extends EventEmitter {
|
|
|
307
309
|
writeFileSync(this.launchPath, this.fingerprint(resume));
|
|
308
310
|
this.up = true;
|
|
309
311
|
const deadline = Date.now() + START_TIMEOUT_MS;
|
|
312
|
+
let asked;
|
|
313
|
+
const answered = new Set();
|
|
314
|
+
let unlisted;
|
|
310
315
|
while (Date.now() < deadline) {
|
|
311
316
|
// The pane is gone with its output, so say what was run and where: that is the one way to see why.
|
|
312
317
|
if (!(await this.sessionAlive())) {
|
|
@@ -314,12 +319,49 @@ export class TuiBrain extends EventEmitter {
|
|
|
314
319
|
return `${START_EXIT} (${argv[0]} in ${this.profile.cwd}; run it there by hand to see why)`;
|
|
315
320
|
}
|
|
316
321
|
const pane = await this.capture(40);
|
|
322
|
+
// Dialogs before the prompt: each counts only as the last dialog on screen with no input box
|
|
323
|
+
// below it, so a resumed conversation that quotes one is the prompt. Idle first would let a
|
|
324
|
+
// stale frame in the history (between two rules) pass for a box while a dialog is open.
|
|
317
325
|
if (trustDialogOpen(pane)) {
|
|
318
|
-
await this.acceptDialog(trustAccepted);
|
|
326
|
+
await this.acceptDialog(trustDialogOpen, trustAccepted);
|
|
319
327
|
continue;
|
|
320
328
|
}
|
|
321
329
|
if (importsDialogOpen(pane)) {
|
|
322
|
-
await this.acceptDialog(importsAccepted);
|
|
330
|
+
await this.acceptDialog(importsDialogOpen, importsAccepted);
|
|
331
|
+
continue;
|
|
332
|
+
}
|
|
333
|
+
const dir = addDirDialog(pane);
|
|
334
|
+
if (dir !== null) {
|
|
335
|
+
// claude 2.1.326 drops keys for about a second after it draws this dialog (measured: Down and
|
|
336
|
+
// Enter at once leave it on "No"), and a profile with two new folders gets one dialog each.
|
|
337
|
+
// So wait until a folder's dialog has stood ADD_DIR_SETTLE_MS, and give an answer time to land
|
|
338
|
+
// before the same folder is answered again.
|
|
339
|
+
if (asked?.dir !== dir)
|
|
340
|
+
asked = { dir, at: Date.now(), answered: 0 };
|
|
341
|
+
// Yes only for a folder the owner listed in add_dirs: that line was the answer. Anything else
|
|
342
|
+
// stays unanswered, and once it has stood as long (one frame drawn mid-redraw is no answer)
|
|
343
|
+
// the start fails with the folder named.
|
|
344
|
+
if (!addDirListed(dir, this.profile.add_dirs, homedir(), this.profile.cwd)) {
|
|
345
|
+
if (Date.now() - asked.at < ADD_DIR_SETTLE_MS) {
|
|
346
|
+
await sleep(250);
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
this.emit('log', `pane ${this.name} asks to add ${dir}, which is not in add_dirs`);
|
|
350
|
+
unlisted = dir;
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
353
|
+
if (Date.now() - asked.at < ADD_DIR_SETTLE_MS || Date.now() - asked.answered < ADD_DIR_SETTLE_MS * 2) {
|
|
354
|
+
await sleep(250);
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
// Bound to this folder: when its dialog closes and the next folder's opens, that one waits for
|
|
358
|
+
// its own listed check and settle time, and gets no Down or Enter meant for this one.
|
|
359
|
+
// The same folder can be answered more than once (an Enter dropped while the dialog was new).
|
|
360
|
+
if (await this.acceptDialog((p) => addDirDialog(p) === dir, addDirAccepted) && !answered.has(dir)) {
|
|
361
|
+
answered.add(dir);
|
|
362
|
+
this.emit('log', `pane ${this.name} answered add-dir ${dir}`);
|
|
363
|
+
}
|
|
364
|
+
asked.answered = Date.now();
|
|
323
365
|
continue;
|
|
324
366
|
}
|
|
325
367
|
if (paneIdle(pane))
|
|
@@ -338,6 +380,9 @@ export class TuiBrain extends EventEmitter {
|
|
|
338
380
|
catch {
|
|
339
381
|
this.emit('log', `pane ${this.name} never reached a prompt`);
|
|
340
382
|
}
|
|
383
|
+
// Named, so the owner sees which folder to list (or why claude asks about it) without the log.
|
|
384
|
+
if (unlisted !== undefined)
|
|
385
|
+
return `the session did not start: claude asks to add the folder ${unlisted}, which is not in this profile's add_dirs`;
|
|
341
386
|
return `the session never reached a prompt (look with: tmux -L angelia attach -t ${this.name})`;
|
|
342
387
|
}
|
|
343
388
|
argv(resume) {
|
|
@@ -356,10 +401,15 @@ export class TuiBrain extends EventEmitter {
|
|
|
356
401
|
* routing.yaml already names this directory as the profile's home and the permission mode it
|
|
357
402
|
* runs under, and the imports are the owner's own shared doctrine, so the answer was given when
|
|
358
403
|
* that line was written; press it instead of hanging. `accepted` says the cursor is on the yes
|
|
359
|
-
* row; it is checked before Enter, so a redraw can never turn this into "No".
|
|
360
|
-
|
|
404
|
+
* row; it is checked before Enter, so a redraw can never turn this into "No". `open` says the
|
|
405
|
+
* same dialog is still the one on screen; once it is not, no key is sent, since a key meant for
|
|
406
|
+
* this dialog would answer the next one. */
|
|
407
|
+
async acceptDialog(open, accepted) {
|
|
361
408
|
for (let i = 0; i < 8; i++) {
|
|
362
|
-
|
|
409
|
+
const pane = await this.capture(40);
|
|
410
|
+
if (!open(pane))
|
|
411
|
+
return false;
|
|
412
|
+
if (accepted(pane)) {
|
|
363
413
|
await this.tm(['send-keys', '-t', this.name, 'Enter']);
|
|
364
414
|
return true;
|
|
365
415
|
}
|
|
@@ -671,12 +721,12 @@ export class TuiBrain extends EventEmitter {
|
|
|
671
721
|
}
|
|
672
722
|
/** A chat answer goes to the hook waiting on that request, and to no other; no key is pressed. False
|
|
673
723
|
* when that hook has stepped aside already: Claude then asks in its own dialog. */
|
|
674
|
-
answerPermission(id, allow) {
|
|
724
|
+
answerPermission(id, allow, how = {}) {
|
|
675
725
|
const full = this.permissions.take(id);
|
|
676
726
|
if (!full)
|
|
677
727
|
return false;
|
|
678
728
|
this.relayedAt = Date.now();
|
|
679
|
-
return this.relay.answer(full, allow);
|
|
729
|
+
return this.relay.answer(full, allow, how.message);
|
|
680
730
|
}
|
|
681
731
|
/** The hook relays while this beats: written now, then every RELAY_BEAT_MS, whatever the reader is
|
|
682
732
|
* waiting on. One reader beats at a time. */
|
|
@@ -773,6 +823,25 @@ export class DialogWatch {
|
|
|
773
823
|
return { announce: this.id };
|
|
774
824
|
}
|
|
775
825
|
}
|
|
826
|
+
/** True when `dir`, as Claude Code's add-dir dialog shows it, is one of the profile's add_dirs
|
|
827
|
+
* (a leading ~ is the home folder; a trailing slash does not count). A relative entry is resolved
|
|
828
|
+
* against `base`, the profile's cwd, where claude runs and resolves it too. */
|
|
829
|
+
export function addDirListed(dir, addDirs, home = homedir(), base = process.cwd()) {
|
|
830
|
+
if (!dir)
|
|
831
|
+
return false;
|
|
832
|
+
// Claude shows the folder as it resolved it (/tmp is /private/tmp on macOS), so the real path counts too.
|
|
833
|
+
const forms = (d) => {
|
|
834
|
+
const p = resolve(base, d.replace(/^~(?=$|\/)/, home)).replace(/(.)\/+$/, '$1');
|
|
835
|
+
try {
|
|
836
|
+
return [p, realpathSync(p)];
|
|
837
|
+
}
|
|
838
|
+
catch {
|
|
839
|
+
return [p];
|
|
840
|
+
}
|
|
841
|
+
};
|
|
842
|
+
const want = forms(dir);
|
|
843
|
+
return addDirs.some((d) => forms(d).some((f) => want.includes(f)));
|
|
844
|
+
}
|
|
776
845
|
/** Assistant text and tool calls, in order, from a slice of a Claude Code transcript. */
|
|
777
846
|
export function transcriptEvents(chunk) {
|
|
778
847
|
const out = [];
|
package/dist/build.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { closeSync, constants, existsSync, fstatSync, ftruncateSync, lstatSync, mkdirSync,
|
|
1
|
+
import { closeSync, constants, existsSync, fstatSync, ftruncateSync, lstatSync, mkdirSync, readFileSync, readlinkSync, readdirSync, realpathSync, renameSync, rmSync, symlinkSync, unlinkSync, writeFileSync, writeSync } from 'node:fs';
|
|
2
2
|
import { homedir } from 'node:os';
|
|
3
3
|
import { dirname, join, relative, resolve, sep } from 'node:path';
|
|
4
4
|
import { resolveProfile } from './resolve.js';
|
|
5
5
|
import { SELF_END, SELF_START, openAgentFile, rewriteAgentFile, upsertSelfBlock } from '../daemon/self.js';
|
|
6
6
|
import { API_SOCKET, HOME_PRIVATE, INSTANCE_DIR, STATE_PRIVATE, commonDir, workspaceDir } from '../instance/instance.js';
|
|
7
|
-
import {
|
|
7
|
+
import { isInside, openNoFollow } from '../core/paths.js';
|
|
8
8
|
import { codexUserMcpServers } from '../brain/codex-config.js';
|
|
9
9
|
import { fileURLToPath } from 'node:url';
|
|
10
10
|
/**
|
|
@@ -401,8 +401,7 @@ function linkedFolders(cwd, paths) {
|
|
|
401
401
|
return [...out];
|
|
402
402
|
}
|
|
403
403
|
/**
|
|
404
|
-
* Write a whole file in a profile's folder without following a link anywhere on the way (
|
|
405
|
-
* on macOS, which refuses to be combined with O_NOFOLLOW; O_NOFOLLOW for the file itself elsewhere), and only into a plain file with no other name
|
|
404
|
+
* Write a whole file in a profile's folder without following a link anywhere on the way (`openNoFollow`), and only into a plain file with no other name
|
|
406
405
|
* (a hard link would carry the write out of the folder). One descriptor from the check to the write.
|
|
407
406
|
* O_NONBLOCK: a FIFO in the file's place must not hold the daemon (which compiles for /backend); the
|
|
408
407
|
* plain-file check then refuses it.
|
|
@@ -411,7 +410,7 @@ export function writePlain(cwd, file, text) {
|
|
|
411
410
|
const path = join(realpathSync(cwd), relative(cwd, file));
|
|
412
411
|
let fd;
|
|
413
412
|
try {
|
|
414
|
-
fd =
|
|
413
|
+
fd = openNoFollow(path, constants.O_WRONLY | constants.O_CREAT | constants.O_NONBLOCK, 0o644);
|
|
415
414
|
}
|
|
416
415
|
catch (e) {
|
|
417
416
|
if (e.code === 'ELOOP')
|