@beatos/bridge-runner 0.9.0 → 0.10.0
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 +75 -10
- package/dist/claude.js +2 -0
- package/dist/read-wall.js +90 -5
- package/dist/runner.js +10 -2
- package/dist/sessions-engine.js +436 -57
- package/dist/sessions-scan.js +271 -34
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -605,10 +605,16 @@ What each access can reach:
|
|
|
605
605
|
or `(`), the turn is refused. On Windows a chat
|
|
606
606
|
also cannot read a name that looks like a short name (with `~` and a digit,
|
|
607
607
|
like `DOCUME~1`): Windows opens a folder or a `.env` file by such a name
|
|
608
|
-
too, and a rule by the long name would not see it.
|
|
608
|
+
too, and a rule by the long name would not see it. A link that points at
|
|
609
|
+
the session's folder, into it, or at a folder above it gets no rule
|
|
610
|
+
(Windows has one on every PC: `C:\Documents and Settings` points to
|
|
611
|
+
`C:\Users`): Claude Code follows a link in a rule, and such a rule would
|
|
612
|
+
hide the session's own folder from Glob and Grep. What that link shows
|
|
613
|
+
stays closed by its real name. This wall is made of
|
|
609
614
|
Claude Code deny rules. It was checked with real sessions on Windows
|
|
610
615
|
(Claude Code 2.1.319): long and short names, links and junctions inside
|
|
611
|
-
the folder, other drives, network paths
|
|
616
|
+
the folder and above it, other drives, network paths, and that Glob and
|
|
617
|
+
Grep still find the files inside the folder. It is not an operating system
|
|
612
618
|
sandbox, and it was not checked on macOS or Linux. Ask it for a change
|
|
613
619
|
and it tells you what it would change.
|
|
614
620
|
- `work`: like a task run. The chat may change files and run commands **as
|
|
@@ -633,19 +639,68 @@ offers on beatos.app, see [Connect folders from beatos.app](#connect-folders-fro
|
|
|
633
639
|
- a short part of your last message (300 characters) and of the last answer
|
|
634
640
|
(1500 characters; a longer answer is sent as its start and its end);
|
|
635
641
|
- when you open a chat: the answers of the turns you start from Bridge, and
|
|
636
|
-
for an older session, its last 30 messages (your text and the answers)
|
|
642
|
+
for an older session, its last 30 messages (your text and the answers);
|
|
643
|
+
- while a turn you started from Bridge runs: a short line of what it does at
|
|
644
|
+
that moment, at most one every 2 seconds. The line is the name of the tool
|
|
645
|
+
and the command, file path or search it uses (300 characters at most), for
|
|
646
|
+
example `Read ~/projects/acme-app/README.md`.
|
|
637
647
|
|
|
638
|
-
What never leaves:
|
|
648
|
+
What never leaves: the output of tool calls, file contents, sessions in
|
|
639
649
|
other folders, `claude -p` sessions the runner did not start, and keys: a
|
|
640
650
|
text that looks like a key or a token becomes `[hidden]`, and the home folder
|
|
641
651
|
becomes `~`.
|
|
642
652
|
|
|
643
|
-
### A session you started by hand
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
653
|
+
### A session you started by hand: closed, the same session; open, a copy
|
|
654
|
+
|
|
655
|
+
From runner 0.10.0, on Windows. On macOS and Linux a session you started by
|
|
656
|
+
hand still continues as a copy, for now: the check with the real Claude Code
|
|
657
|
+
has only run on Windows so far.
|
|
658
|
+
|
|
659
|
+
- **Closed on this computer** (no Claude Code window or terminal holds it):
|
|
660
|
+
your message from Bridge continues the SAME session (Claude Code's
|
|
661
|
+
`--resume`, no copy). The next time you open it on the computer, Bridge's
|
|
662
|
+
turns are in it. The access box is the same as for any other chat turn
|
|
663
|
+
(`read` or `work`, the same deny rules and read wall).
|
|
664
|
+
- **Open on this computer**: the runner does not write into it. Bridge
|
|
665
|
+
continues it as a copy (Claude Code's `--fork-session`): the copy keeps the
|
|
666
|
+
history and gets a new id, and your open session stays as it was.
|
|
667
|
+
|
|
668
|
+
The runner decides, not beatos.app. It reads Claude Code's list of open
|
|
669
|
+
sessions (`~/.claude/sessions`) when it takes the message, again right
|
|
670
|
+
before Claude starts, and every 2 seconds while the turn runs. When it cannot
|
|
671
|
+
be sure, it counts the session as open: the list is missing or cannot be
|
|
672
|
+
read; no entry in it can be read but a file is not empty; the entry has no
|
|
673
|
+
process id or comes from another process space (WSL, a container); a file
|
|
674
|
+
that cannot be read belongs to a process that still runs (an empty one only
|
|
675
|
+
in its first 2 minutes). An empty leftover file of a program that died does
|
|
676
|
+
not count.
|
|
677
|
+
|
|
678
|
+
`session_open`: the reason the runner gives when it refuses a message because
|
|
679
|
+
the session is open on the computer (or it cannot tell). Close the session
|
|
680
|
+
there and send again, or continue it as a copy. When the session is opened
|
|
681
|
+
while your message waits for its turn, the turn ends with the error "the
|
|
682
|
+
session is open on the computer", Claude does not start, and the turn does
|
|
683
|
+
not count for the day. When someone opens it on the computer while the turn
|
|
684
|
+
runs, the turn is stopped and ends with the same error.
|
|
685
|
+
|
|
686
|
+
A turn that ends before Claude is started does not count for the day: a
|
|
687
|
+
refusal, an error in the runner's own setup of the turn, or a waiting turn
|
|
688
|
+
that is dropped (you stop it, Sessions are turned off, the runner stops or
|
|
689
|
+
restarts). A Claude that could not be started still counts.
|
|
690
|
+
|
|
691
|
+
A runner that is not on Windows, or that cannot name its own process space,
|
|
692
|
+
does not continue a session from the computer in place: it refuses such a
|
|
693
|
+
message as open (`session_open`). Bridge then offers the copy.
|
|
694
|
+
|
|
695
|
+
On the Sessions page, "open on the computer" uses the same rule as the
|
|
696
|
+
check: when an entry in the list makes the runner refuse a session, its card
|
|
697
|
+
says it is open. (An entry written by a Claude Code in another process space,
|
|
698
|
+
for example in WSL, counts on the card only on Windows.)
|
|
699
|
+
|
|
700
|
+
The runner tells beatos.app that it can do this in its heartbeat
|
|
701
|
+
(`capabilities.sessions.resume_local: true`), only on Windows and only when it
|
|
702
|
+
can read `~/.claude/sessions`. Without it, or with an older runner, Bridge always makes
|
|
703
|
+
a copy. Sessions started from Bridge are continued as they are.
|
|
649
704
|
|
|
650
705
|
### Limits
|
|
651
706
|
|
|
@@ -795,6 +850,16 @@ not run in CI):
|
|
|
795
850
|
node --experimental-strip-types --disable-warning=ExperimentalWarning scripts/sessions-live-check.mjs
|
|
796
851
|
```
|
|
797
852
|
|
|
853
|
+
Run it again after each Claude Code update. The read wall is made of Claude
|
|
854
|
+
Code deny rules, so it depends on how Claude Code matches paths and follows
|
|
855
|
+
links. The check tests both sides with the real program, each with a control:
|
|
856
|
+
a read session cannot reach the folder next door, and it can still find the
|
|
857
|
+
files in its own folder. Run it also before each release that changes how a
|
|
858
|
+
session from the computer is continued: checks 11 to 13 test the same session
|
|
859
|
+
path against Claude Code's real list of open sessions (the runner's own turn
|
|
860
|
+
is not taken for someone else; a second program that holds the session is
|
|
861
|
+
seen before the turn and during it).
|
|
862
|
+
|
|
798
863
|
See PUBLISHING.md to release it to npm.
|
|
799
864
|
|
|
800
865
|
## License
|
package/dist/claude.js
CHANGED
|
@@ -45,6 +45,8 @@ export async function runClaude(opts, cb = {}) {
|
|
|
45
45
|
env: opts.env,
|
|
46
46
|
windowsHide: true,
|
|
47
47
|
});
|
|
48
|
+
if (typeof child.pid === "number" && child.pid > 0)
|
|
49
|
+
cb.onSpawn?.(child.pid);
|
|
48
50
|
// A CLI that exits before it reads stdin must not crash the runner (EPIPE).
|
|
49
51
|
child.stdin?.on?.("error", () => undefined);
|
|
50
52
|
if (opts.stdinText !== undefined)
|
package/dist/read-wall.js
CHANGED
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
*
|
|
9
9
|
* - for each folder above the root, up to the drive root, every entry
|
|
10
10
|
* except the one on the path to the root: a folder as <entry>/**, a file
|
|
11
|
-
* as <entry> (a link gets both; a link is never
|
|
11
|
+
* as <entry> (a link gets both; a link is never listed);
|
|
12
|
+
* - but NO rule for a link that points at the root, into it, or at a folder
|
|
13
|
+
* above it (see "Links" below);
|
|
12
14
|
* - every other drive letter that exists, as X:/**;
|
|
13
15
|
* - each rule in every path form Claude Code matches (C:/..., //c/...,
|
|
14
16
|
* and ~/... under the home folder).
|
|
@@ -22,12 +24,28 @@
|
|
|
22
24
|
*
|
|
23
25
|
* Work access gets no wall: it has a shell, a wall would give false comfort.
|
|
24
26
|
*
|
|
27
|
+
* Links. Claude Code follows a link in a deny rule. Found live on 2026-11-14
|
|
28
|
+
* (2.1.319): every Windows PC has the hidden link C:/Documents and Settings
|
|
29
|
+
* -> C:/Users, and the rule for it made Glob and Grep hide every file under
|
|
30
|
+
* C:/Users, the session's own folder too ("No files found"; Read by full
|
|
31
|
+
* path still worked). So a link whose real target is the root, is in the
|
|
32
|
+
* root, or is a folder above the root gets no rule. That opens nothing: a
|
|
33
|
+
* read through such a link ends at a real path, and every real neighbor has
|
|
34
|
+
* its own rule. Checked with the real CLI, with a control: Read, Grep and
|
|
35
|
+
* Glob for the folder next door, asked for through that link, are refused,
|
|
36
|
+
* and a search that starts above the root does not show it
|
|
37
|
+
* (scripts/sessions-live-check.mjs, checks 8 to 10). A link that cannot be
|
|
38
|
+
* resolved keeps its rules. To resolve a link is to open the place it points
|
|
39
|
+
* at, so only a link to a place on this computer, on the root's own drive,
|
|
40
|
+
* is resolved: a link to a network share or to another drive keeps its
|
|
41
|
+
* rules unseen (no wait for a server that is off, no login sent to it).
|
|
42
|
+
*
|
|
25
43
|
* Not in these rules: on Windows a walled folder also opens by its 8.3 short
|
|
26
44
|
* name (DOCUME~1), and a rule here sees only the long name. chatDenyRules in
|
|
27
45
|
* safety.ts closes that for every chat turn (shortNameRules: no name with
|
|
28
46
|
* "~" and a digit can be read). Use the wall only together with it.
|
|
29
47
|
*/
|
|
30
|
-
import { existsSync, lstatSync, readdirSync } from "node:fs";
|
|
48
|
+
import { existsSync, lstatSync, readdirSync, readlinkSync, realpathSync } from "node:fs";
|
|
31
49
|
export const WALL_MAX = 6000;
|
|
32
50
|
export const realWallFs = {
|
|
33
51
|
lstat(p) {
|
|
@@ -55,6 +73,22 @@ export const realWallFs = {
|
|
|
55
73
|
return false;
|
|
56
74
|
}
|
|
57
75
|
},
|
|
76
|
+
readlink(p) {
|
|
77
|
+
try {
|
|
78
|
+
return readlinkSync(p);
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
realpath(p) {
|
|
85
|
+
try {
|
|
86
|
+
return realpathSync(p);
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
},
|
|
58
92
|
};
|
|
59
93
|
const SAFE = /^[A-Za-z0-9._ -]$/;
|
|
60
94
|
/** A name as a deny glob: "?" for every character outside the safe set. */
|
|
@@ -81,6 +115,36 @@ function split(abs) {
|
|
|
81
115
|
/** "C:/" or "/" for a drive root (never "C:", which means the current folder on C). */
|
|
82
116
|
const dirPath = (drive, parts) => (parts.length ? `${drive}/${parts.join("/")}` : `${drive}/`);
|
|
83
117
|
const childPath = (dir, name) => (dir.endsWith("/") ? `${dir}${name}` : `${dir}/${name}`);
|
|
118
|
+
/** A path as the OS gives it, made comparable: forward slashes, no \\?\ prefix, no slash at the end. */
|
|
119
|
+
function comparable(p, caseless) {
|
|
120
|
+
let s = p.replace(/\\/g, "/").replace(/^\/\/\?\//, "");
|
|
121
|
+
if (s.length > 1)
|
|
122
|
+
s = s.replace(/\/+$/, "");
|
|
123
|
+
return caseless ? s.toLowerCase() : s;
|
|
124
|
+
}
|
|
125
|
+
/** Is `real` the root, a folder above it, or something in it? (both made comparable) */
|
|
126
|
+
function onRootPath(real, root) {
|
|
127
|
+
const a = real.endsWith("/") ? real : `${real}/`;
|
|
128
|
+
const b = root.endsWith("/") ? root : `${root}/`;
|
|
129
|
+
return a.startsWith(b) || b.startsWith(a);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Is the place a link names on this computer and on the root's drive? A
|
|
133
|
+
* network place (//server/share, \\?\UNC\...) or another drive letter is
|
|
134
|
+
* not: it is never resolved. A relative target is beside the link: local.
|
|
135
|
+
*/
|
|
136
|
+
function localTarget(direct, drive) {
|
|
137
|
+
let s = direct.replace(/\\/g, "/");
|
|
138
|
+
if (/^\/\/\?\/UNC\//i.test(s))
|
|
139
|
+
return false;
|
|
140
|
+
s = s.replace(/^\/\/\?\//, "");
|
|
141
|
+
if (s.startsWith("//"))
|
|
142
|
+
return false;
|
|
143
|
+
const d = /^([A-Za-z]):/.exec(s);
|
|
144
|
+
if (d)
|
|
145
|
+
return drive !== "" && `${d[1].toUpperCase()}:` === drive;
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
84
148
|
/** Every form Claude Code matches: C:/x, //c/x, and ~/x under home. */
|
|
85
149
|
export function readForms(target, home, caseless) {
|
|
86
150
|
const out = [`Read(${target})`];
|
|
@@ -105,7 +169,22 @@ export function readWall(root, opts) {
|
|
|
105
169
|
return { ok: false, why: "bad_root", rules: 0 };
|
|
106
170
|
const rules = [];
|
|
107
171
|
let skipped = 0;
|
|
172
|
+
let rootLinks = 0;
|
|
173
|
+
const rootPath = dirPath(s.drive, s.parts);
|
|
174
|
+
const rootReal = comparable(fs.realpath?.(rootPath) ?? rootPath, caseless);
|
|
108
175
|
const add = (target) => rules.push(...readForms(target, opts.home, caseless));
|
|
176
|
+
/** Does this link point at the root, into it, or at a folder above it? Only a local link is resolved. */
|
|
177
|
+
const onTheRootPath = (link) => {
|
|
178
|
+
if (!fs.realpath)
|
|
179
|
+
return false;
|
|
180
|
+
if (fs.readlink) {
|
|
181
|
+
const direct = fs.readlink(link);
|
|
182
|
+
if (direct === null || !localTarget(direct, s.drive))
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
const real = fs.realpath(link);
|
|
186
|
+
return real !== null && onRootPath(comparable(real, caseless), rootReal);
|
|
187
|
+
};
|
|
109
188
|
for (let i = s.parts.length - 1; i >= 0; i--) {
|
|
110
189
|
const allowed = s.parts[i];
|
|
111
190
|
// The folders above the root, as globs (a "?" there only widens the deny side).
|
|
@@ -122,10 +201,16 @@ export function readWall(root, opts) {
|
|
|
122
201
|
skipped += 1;
|
|
123
202
|
continue;
|
|
124
203
|
}
|
|
125
|
-
const
|
|
204
|
+
const full = childPath(dir, name);
|
|
205
|
+
const st = fs.lstat(full);
|
|
126
206
|
const target = childPath(globDir, g);
|
|
127
|
-
// A link, or an entry that cannot be read (locked, gone): wall it off both ways.
|
|
128
207
|
if (!st || st.isSymbolicLink) {
|
|
208
|
+
// A link onto the root's own path: Claude Code follows it, and a rule for it would hide the root.
|
|
209
|
+
if (st?.isSymbolicLink && onTheRootPath(full)) {
|
|
210
|
+
rootLinks += 1;
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
// Any other link, or an entry that cannot be read (locked, gone): wall it off both ways.
|
|
129
214
|
add(target);
|
|
130
215
|
add(`${target}/**`);
|
|
131
216
|
}
|
|
@@ -147,5 +232,5 @@ export function readWall(root, opts) {
|
|
|
147
232
|
}
|
|
148
233
|
if (rules.length > max)
|
|
149
234
|
return { ok: false, why: "too_many", rules: rules.length };
|
|
150
|
-
return { ok: true, rules, skipped };
|
|
235
|
+
return { ok: true, rules, skipped, rootLinks };
|
|
151
236
|
}
|
package/dist/runner.js
CHANGED
|
@@ -50,7 +50,7 @@ import { decideAction } from "./policy.js";
|
|
|
50
50
|
import { claudeArgs, comprehensionArgs, sessionSettings, agentEnv } from "./safety.js";
|
|
51
51
|
import { processVideos, realVideoFs } from "./video.js";
|
|
52
52
|
import { comprehensionLanguage, comprehensionPrompt, comprehensionTaskText, TASK_TEXT_FILE, useSavedVideos, VAULT_LIMITS, } from "./video-vault.js";
|
|
53
|
-
export const RUNNER_VERSION = "0.
|
|
53
|
+
export const RUNNER_VERSION = "0.10.0";
|
|
54
54
|
/** A model name from Bridge goes into argv: plain names only. */
|
|
55
55
|
const MODEL_RE = /^[A-Za-z0-9._-]{1,64}$/;
|
|
56
56
|
const CLAIM_REFRESH_MS = 5 * 60_000;
|
|
@@ -290,7 +290,15 @@ export class Runner {
|
|
|
290
290
|
max_runs_per_day: this.d.cfg.maxRunsPerDay,
|
|
291
291
|
billing: this.d.cfg.billing,
|
|
292
292
|
// Sessions in Bridge (BEA-107): the access set in config.json; "off" when off.
|
|
293
|
-
|
|
293
|
+
// resume_local (0.10.0): a closed session from the computer continues as the
|
|
294
|
+
// same session. Only when the engine can read Claude Code's live registry
|
|
295
|
+
// here (else every such message would be refused as open). An older runner
|
|
296
|
+
// leaves it out, and absent means no.
|
|
297
|
+
sessions: {
|
|
298
|
+
access: this.sessionsAccess(),
|
|
299
|
+
protocol: 1,
|
|
300
|
+
...(this.d.sessions?.canResumeLocal?.() === true ? { resume_local: true } : {}),
|
|
301
|
+
},
|
|
294
302
|
},
|
|
295
303
|
max_concurrent: 1,
|
|
296
304
|
};
|