session-peer 0.2.1 → 0.3.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/PARITY.md +281 -17
- package/README.ja.md +12 -5
- package/README.ko.md +12 -5
- package/README.md +12 -4
- package/README.zh-CN.md +11 -4
- package/RELEASING.md +60 -7
- package/SECURITY.md +1 -1
- package/VALIDATION.md +186 -7
- package/dist/cli.d.ts +10 -1
- package/dist/cli.js +274 -44
- package/dist/diagnostics.d.ts +2 -0
- package/dist/diagnostics.js +1 -1
- package/dist/help.js +32 -5
- package/dist/output.d.ts +1 -1
- package/dist/output.js +15 -0
- package/dist/process.js +76 -5
- package/dist/protocol.d.ts +6 -3
- package/dist/protocol.js +17 -6
- package/dist/replies.d.ts +30 -0
- package/dist/replies.js +283 -0
- package/dist/ssh.d.ts +24 -0
- package/dist/ssh.js +114 -0
- package/dist/updates.d.ts +37 -0
- package/dist/updates.js +444 -0
- package/dist/windows.d.ts +1 -1
- package/dist/windows.js +4 -3
- package/docs/api.md +4 -4
- package/docs/design/remote-deployment.md +867 -0
- package/docs/guide.ja.md +116 -14
- package/docs/guide.ko.md +216 -21
- package/docs/guide.md +253 -23
- package/docs/guide.zh-CN.md +103 -13
- package/docs/shorthand.md +198 -0
- package/package.json +4 -3
- package/shorthand/sp.ps1 +11 -0
- package/shorthand/sp.sh +11 -0
package/docs/guide.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
[English](guide.md) | [한국어](guide.ko.md) | [日本語](guide.ja.md) | [简体中文](guide.zh-CN.md)
|
|
6
6
|
|
|
7
|
-
This guide covers 0.
|
|
7
|
+
This guide covers 0.3.0, which adds multi-host SSH, sender context and return routes, update checks and the optional `sp` shorthand to 0.2.1 ([changes](../PARITY.md#030-remote-usability-and-maintenance)). [Public 0.2.1 release evidence](../VALIDATION.md#public-021--2026-09-29-kst) records the previous publication. References to 0.1.0 below describe the older release.
|
|
8
8
|
|
|
9
9
|
## Contents
|
|
10
10
|
|
|
@@ -24,7 +24,7 @@ This guide covers 0.2.1, a reliability and hardening update to 0.2.0 ([changes](
|
|
|
24
24
|
**Find and message running Claude Code and Codex sessions, locally or over SSH.**
|
|
25
25
|
This TypeScript client runs on Node.js without Python.
|
|
26
26
|
|
|
27
|
-
This guide describes **0.
|
|
27
|
+
This guide describes **0.3.0**. The npm package and CLI command are both **`session-peer`**. This
|
|
28
28
|
project does not provide a Relay server or hosted service.
|
|
29
29
|
|
|
30
30
|
## Quick start
|
|
@@ -33,8 +33,8 @@ Use Node **22.13+ within 22.x or 24.x**. Check which `session-peer` your PATH
|
|
|
33
33
|
selects if the Python CLI is already installed; both packages use that command.
|
|
34
34
|
|
|
35
35
|
```sh
|
|
36
|
-
npm install --global --ignore-scripts session-peer@0.
|
|
37
|
-
session-peer --version # session-peer 0.
|
|
36
|
+
npm install --global --ignore-scripts session-peer@0.3.0
|
|
37
|
+
session-peer --version # session-peer 0.3.0 (typescript)
|
|
38
38
|
session-peer list --agent claude --json
|
|
39
39
|
session-peer send --to CLAUDE_PID --message 'Please review the API contract.' --dry-run --json
|
|
40
40
|
```
|
|
@@ -101,7 +101,7 @@ submits nothing. JSON adds sanitized `codexHomeResolution` and, when supplied by
|
|
|
101
101
|
native queue output, `queueId`; neither confirms consumption. See the
|
|
102
102
|
[selection contract](../PARITY.md#source-codex-home-selection--17--020).
|
|
103
103
|
Published **0.1.0** still requires an explicit live home and has no inactive opt-in.
|
|
104
|
-
On SSH,
|
|
104
|
+
On SSH, both ends need the same TypeScript client version (0.3.0).
|
|
105
105
|
|
|
106
106
|
## Requirements
|
|
107
107
|
|
|
@@ -125,11 +125,11 @@ npm run build
|
|
|
125
125
|
node dist/cli.js --version
|
|
126
126
|
npm pack --ignore-scripts
|
|
127
127
|
# Optional global install: first check which session-peer your PATH selects.
|
|
128
|
-
npm install --global --ignore-scripts ./session-peer-0.
|
|
128
|
+
npm install --global --ignore-scripts ./session-peer-0.3.0.tgz
|
|
129
129
|
session-peer --version
|
|
130
130
|
```
|
|
131
131
|
|
|
132
|
-
Expected: `session-peer 0.
|
|
132
|
+
Expected: `session-peer 0.3.0 (typescript)`. Keep the `./...tgz` path to
|
|
133
133
|
select the locally built artifact. Check the checkout version before using
|
|
134
134
|
these commands for a later release.
|
|
135
135
|
|
|
@@ -149,7 +149,7 @@ On Windows PowerShell, inspect competing commands with
|
|
|
149
149
|
npm ci --ignore-scripts
|
|
150
150
|
npm run build
|
|
151
151
|
npm pack --ignore-scripts
|
|
152
|
-
npm install --prefix "$env:TEMP\session-peer-ts-source" --ignore-scripts .\session-peer-0.
|
|
152
|
+
npm install --prefix "$env:TEMP\session-peer-ts-source" --ignore-scripts .\session-peer-0.3.0.tgz
|
|
153
153
|
& "$env:TEMP\session-peer-ts-source\node_modules\.bin\session-peer.cmd" --version
|
|
154
154
|
# Later: npm uninstall --prefix "$env:TEMP\session-peer-ts-source" session-peer
|
|
155
155
|
```
|
|
@@ -182,27 +182,179 @@ The default remote command is `session-peer` on remote PATH. An absolute
|
|
|
182
182
|
the TypeScript marker and exact version; a different implementation is refused.
|
|
183
183
|
SSH uses BatchMode and StrictHostKeyChecking. It never accepts new host keys,
|
|
184
184
|
installs a remote runtime or invokes Python as a fallback. Messages travel in a
|
|
185
|
-
JSON stdin request, not remote shell arguments.
|
|
186
|
-
|
|
187
|
-
|
|
185
|
+
JSON stdin request, not remote shell arguments. Forward access does not
|
|
186
|
+
establish reverse access. Since 0.3.0, Tailscale is used only as a routing
|
|
187
|
+
hint; see [Replies](#replies).
|
|
188
188
|
|
|
189
189
|
For a Windows SSH destination, add `--remote-platform win32` and select a
|
|
190
190
|
Windows `--remote-bin 'C:\absolute\path\session-peer.cmd'` if needed. A previously
|
|
191
191
|
authenticated OpenSSH control socket can be selected with
|
|
192
|
-
`--ssh-control-path /absolute/local/socket
|
|
193
|
-
verification or grant a new login. For local Windows Codex commands, use a full
|
|
192
|
+
`--ssh-control-path /absolute/local/socket` with exactly one `--host`; this
|
|
193
|
+
does not bypass host-key verification or grant a new login. For local Windows Codex commands, use a full
|
|
194
194
|
`C:\Users\...\.codex` path for `--codex-home`. The Python CLI, if present,
|
|
195
195
|
is not removed or replaced by this client.
|
|
196
196
|
|
|
197
|
+
### Several hosts and connection options
|
|
198
|
+
|
|
199
|
+
Since 0.3.0 (not in 0.2.1 or earlier), the CLI accepts repeated `--host` and a constrained
|
|
200
|
+
`--ssh-opt`:
|
|
201
|
+
|
|
202
|
+
```sh
|
|
203
|
+
session-peer list --host alpha --host user@[2001:db8::1] \
|
|
204
|
+
--ssh-opt=-p --ssh-opt=2222 --ssh-opt=-i --ssh-opt="$HOME/.ssh/id_ed25519" --json
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
- One `--host` returns one object, as before. Repeated `--host` returns a JSON
|
|
208
|
+
array in the same order; every element has `schemaVersion`, `ok`, `host` and
|
|
209
|
+
`command`. If any host fails, the exit code is 1. Text output prints one
|
|
210
|
+
`Host: <host>` block per destination.
|
|
211
|
+
- All hosts and options are validated before any `ssh` process starts. One bad
|
|
212
|
+
value refuses the whole command with `submitted:false`. Every `--host VALUE`
|
|
213
|
+
or `--host=VALUE` before `--` is collected first, so with two or more of them
|
|
214
|
+
any refusal, including an unknown option or a missing value, is an array with
|
|
215
|
+
one element per host. With fewer, it is one flat object.
|
|
216
|
+
- The same destination twice is `duplicate_ssh_host`. This check compares the
|
|
217
|
+
destination text only (user, case-insensitive host name, canonical IPv6). Two
|
|
218
|
+
aliases or addresses for the same machine are not detected.
|
|
219
|
+
- `--ssh-jump USER@HOST[:PORT]` (once, POSIX clients) routes every `ssh` call
|
|
220
|
+
for every `--host` through one jump host. The user is required, IPv6 needs
|
|
221
|
+
brackets (`hop@[2001:db8::1]:22`), and `%`, `$`, quotes, spaces and other
|
|
222
|
+
shell characters are refused (`invalid_ssh_jump`). Instead of `-J`, the CLI
|
|
223
|
+
builds a fixed `ProxyCommand`. The hop runs `ssh` with `BatchMode=yes`,
|
|
224
|
+
`StrictHostKeyChecking=yes`, `UpdateHostKeys=no`, `ConnectTimeout=10`,
|
|
225
|
+
`ConnectionAttempts=1`, `ProxyCommand=none`, `ProxyJump=none`,
|
|
226
|
+
`ControlPath=none`, `ForwardAgent=no`, `ClearAllForwardings=yes` and
|
|
227
|
+
`PermitLocalCommand=no`, then `-W [target]:port`. The outer `ssh` also gets
|
|
228
|
+
`ControlMaster=no`, `ControlPath=none` and `ProxyUseFdpass=no`, so a
|
|
229
|
+
configured control master cannot bypass the hop. `ProxyCommand` runs through
|
|
230
|
+
your login shell (`$SHELL`). It was verified with sh, bash and zsh; other
|
|
231
|
+
login shells (for example fish or csh) are unverified. The hop needs its own
|
|
232
|
+
known_hosts entry. `--ssh-opt` values, including `-4`/`-6`, apply to the
|
|
233
|
+
target only and are not passed to the hop; the
|
|
234
|
+
hop otherwise uses your ssh config for that host. Only one hop is supported.
|
|
235
|
+
`--ssh-jump` conflicts with `--ssh-control-path` (`conflicting_ssh_jump`) and
|
|
236
|
+
is refused on Windows clients (`ssh_jump_unsupported_platform`) until
|
|
237
|
+
Win32-OpenSSH's `ProxyCommand` handling is verified. Results add `sshJump`.
|
|
238
|
+
- Timeouts are bounded. On POSIX each `ssh` starts detached: in a new session
|
|
239
|
+
and process group with no controlling terminal. Cleanup covers that group
|
|
240
|
+
only; a descendant that leaves it with `setsid()` is out of scope, and there
|
|
241
|
+
is no PID scanning. At
|
|
242
|
+
a timeout or output overflow the whole group is killed, including a jump
|
|
243
|
+
`ProxyCommand` or any other descendant still holding the output pipes, and the
|
|
244
|
+
call returns shortly after. Ctrl-C, SIGTERM or SIGHUP to the CLI also kills the
|
|
245
|
+
group before the CLI exits. On Windows only the direct child is killed, so
|
|
246
|
+
descendants may linger, but the call still returns at the deadline. A preflight
|
|
247
|
+
timeout is a refusal (`ssh_preflight_timeout`); a request timeout is `unknown`
|
|
248
|
+
and is never retried.
|
|
249
|
+
- Each destination gets one preflight and at most one request, in order. A
|
|
250
|
+
refused or `unknown` host does not stop the next host and is never retried or
|
|
251
|
+
resent elsewhere. Check each element before acting on it.
|
|
252
|
+
- `--ssh-opt` accepts only `-p PORT`, `-l USER`, `-i IDENTITY_FILE`,
|
|
253
|
+
`-o Port=…`, `-o User=…`, `-o IdentityFile=…`, `-o IdentitiesOnly=yes|no`,
|
|
254
|
+
`-4` and `-6`. Everything else, including `ProxyCommand`, `LocalCommand`,
|
|
255
|
+
`-F`, `Include`, `-J`/`ProxyJump` and any `BatchMode`/`StrictHostKeyChecking`
|
|
256
|
+
change, is refused (`unsupported_ssh_option`). Use `--ssh-jump` instead of
|
|
257
|
+
`-J`: OpenSSH's own `-J` hop does not receive the command-line `BatchMode` or
|
|
258
|
+
`StrictHostKeyChecking`.
|
|
259
|
+
- IPv6 literals may be bare (`2001:db8::1`) or bracketed (`[2001:db8::1]`,
|
|
260
|
+
`user@[2001:db8::1]`); zone IDs are refused.
|
|
261
|
+
- Results add `sshUser` and `sshUserSource`: `explicit` for `USER@HOST` or
|
|
262
|
+
`-l USER`, `ssh_config_or_local_default` from `ssh -G`, or `unknown` with
|
|
263
|
+
`sshUser:null`. `-l` together with `USER@HOST` is refused. Without an explicit
|
|
264
|
+
user, a local `ssh -G` runs once per host, limited to 5 s. It does not
|
|
265
|
+
connect, but as ssh(1) and ssh_config(5) describe, it evaluates your ssh
|
|
266
|
+
configuration, including `Match exec` commands, just as a normal `ssh` would.
|
|
267
|
+
- Two trust boundaries apply. The allowlist governs only the options this CLI
|
|
268
|
+
passes on the command line. Your own `~/.ssh/config` (and the system config)
|
|
269
|
+
is trusted user configuration: its `ProxyCommand`, `ProxyJump`, `Match exec`
|
|
270
|
+
and similar settings run for every `ssh` this CLI starts, exactly as they do
|
|
271
|
+
for your own `ssh` commands.
|
|
272
|
+
|
|
273
|
+
A proposed design for provisioning destinations without Python (a private,
|
|
274
|
+
versioned install directory, integrity checks, ownership and rollback rules)
|
|
275
|
+
and for a protocol compatibility contract separate from package versions is in
|
|
276
|
+
[Remote deployment ADR](design/remote-deployment.md). It is not implemented; the exact
|
|
277
|
+
same-version requirement above still applies.
|
|
278
|
+
|
|
197
279
|
### Replies
|
|
198
280
|
|
|
199
281
|
Use a `session-peer://v1/reply?...` URI as `--to`. Unknown/duplicate fields,
|
|
200
282
|
unsafe hosts, malformed encoding and conflicting explicit routes are rejected.
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
283
|
+
Peer metadata is never authority, and a Reply-To URI is never executed as shell
|
|
284
|
+
text. A received Reply-To is data for the reader; no reply is observed or
|
|
285
|
+
confirmed automatically.
|
|
286
|
+
|
|
287
|
+
Since 0.3.0 (not in 0.2.1 or earlier), the CLI adds sender context and generated routes:
|
|
288
|
+
|
|
289
|
+
- **Sender.** Inside Claude Code, `CLAUDE_CODE_MESSAGING_SOCKET` must match
|
|
290
|
+
exactly one live registered session; its unique printable name (otherwise its
|
|
291
|
+
PID) becomes `From: claude:NAME`. Inside Codex, a valid `CODEX_THREAD_ID` (or
|
|
292
|
+
`CODEX_SESSION_ID`) gives `From: codex:UUID`. Conflicting, nested or invalid
|
|
293
|
+
evidence gives no identity, and then no generated Reply-To. `--no-from` omits
|
|
294
|
+
From only.
|
|
295
|
+
- **Generated Reply-To.** With a sender and no `--no-reply-to`, a local send gets
|
|
296
|
+
a `transport=local` URI. An SSH send, or `--reply-to`, gets a
|
|
297
|
+
`transport=ssh` URI whose host comes from `--reply-to HOST`, then
|
|
298
|
+
`SESSION_PEER_REPLY_HOST`, then `CC_PEER_REPLY_HOST`, then this machine's
|
|
299
|
+
tailnet name or address. A host without a user gets the current user. If no
|
|
300
|
+
host is found, no SSH route is added. `--reply-address URI` stays an explicit
|
|
301
|
+
alternative. `--reply-to`, `--reply-address` and `--no-reply-to` are mutually
|
|
302
|
+
exclusive. Every URI is checked by the same parser as `--to`.
|
|
303
|
+
- **JSON.** `replyRoute` reports the generated route: local routes are
|
|
304
|
+
`verified` (`same_machine_route`), SSH routes `unverified`
|
|
305
|
+
(`reverse_ssh_not_checked`). When `--to` is a URI, `addressResolution`
|
|
306
|
+
records its transport, and `normalizedFrom: "ssh_self"` when it was delivered
|
|
307
|
+
locally.
|
|
308
|
+
- **Same machine.** An SSH reply URI is delivered locally only when its host
|
|
309
|
+
includes this OS user and names this machine in an exact form (`localhost`,
|
|
310
|
+
canonical `127.x.y.z`, `::1`, `::ffff:127.x.y.z`, the host name or the
|
|
311
|
+
Tailscale self node; never a non-canonical numeric such as `127.1` or
|
|
312
|
+
`0177.0.0.1`, nor an IPv4-compatible address such as `::7f00:1`), and no `--host` or SSH option (including `--ssh-jump`) was given. A
|
|
313
|
+
different or missing user stays SSH.
|
|
314
|
+
- **Tailscale.** `tailscale status --json` (3 s bound) is a routing hint only.
|
|
315
|
+
A peer whose `Online` is the boolean `true` (with MagicDNS on) keeps your SSH
|
|
316
|
+
alias as the destination and adds `HostName=<MagicDNS name>`. It also adds
|
|
317
|
+
`HostKeyAlias=<original name>`, unless the same `ssh -G` that reads the user
|
|
318
|
+
shows a `HostKeyAlias` already set in your ssh config (that one is kept), or
|
|
319
|
+
that lookup fails (nothing is overridden). The result `host` is then the
|
|
320
|
+
MagicDNS name, and `sshHost` is the alias you gave. A peer whose `Online` is
|
|
321
|
+
the boolean `false`, even with MagicDNS off, or an ambiguous name, is refused
|
|
322
|
+
before SSH (`tailscale_peer_offline`, `tailscale_destination_ambiguous`). Any
|
|
323
|
+
other `Online` value, MagicDNS off, an unknown name, a stopped or missing
|
|
324
|
+
Tailscale, or `SESSION_PEER_TAILSCALE=off` means ordinary SSH.
|
|
325
|
+
- **Return route.** `doctor --check-return-route [--reply-to USER@HOST]` runs
|
|
326
|
+
`ssh … USER@HOST 'exit 0'` from the diagnosed machine (the `--host`
|
|
327
|
+
destination, or this one). It uses batch mode, no password or
|
|
328
|
+
keyboard-interactive prompts, strict host keys, no host-key updates, no
|
|
329
|
+
control socket and a 5 s connect timeout. The 8 s deadline applies to that
|
|
330
|
+
final `ssh` command only; the Tailscale status (3 s) and `ssh -G` (5 s)
|
|
331
|
+
lookups before it have their own limits. `exit 0` is a no-op in POSIX shells,
|
|
332
|
+
cmd.exe and PowerShell, so the return host may be any OpenSSH server with one
|
|
333
|
+
of those default shells (only POSIX return hosts have fixture coverage).
|
|
334
|
+
`returnRoute` is `verified` or `failed` with a reason
|
|
335
|
+
(`return_host_unavailable`, `return_host_is_receiver`,
|
|
336
|
+
`ssh_executable_missing`, `authentication_failed`, `host_key_failed`,
|
|
337
|
+
`timeout`, `transport_failed`, `remote_command_failed`). Locally, this user
|
|
338
|
+
on this machine is a local route without SSH. With `--host`, a loopback
|
|
339
|
+
return host that might name a machine is refused before SSH, without DNS:
|
|
340
|
+
`localhost`, `*.localhost`, canonical 127.0.0.0/8 and 0.0.0.0/8, `::1`,
|
|
341
|
+
`::`, their `::ffff:` mapped forms, IPv4-compatible IPv6 (`::a.b.c.d`), and
|
|
342
|
+
every non-canonical numeric (leading zeros, fewer than four parts, hex or
|
|
343
|
+
octal parts, single integers, overflow such as `127.1`, `0177.0.0.1`,
|
|
344
|
+
`2130706433` or `4294967296`), because resolvers disagree on those. It is
|
|
345
|
+
refused
|
|
346
|
+
(`invalid_return_route`), because the destination would read it as itself.
|
|
347
|
+
On the destination, a return host that is a known name of the destination
|
|
348
|
+
itself (for any user) or an unprovable numeric form fails as
|
|
349
|
+
`return_host_is_receiver` and is never reported as a verified local route.
|
|
350
|
+
"Known name" means only an exact match with the OS host name or the Tailscale
|
|
351
|
+
self names and addresses; other DNS or LAN aliases of a machine are not
|
|
352
|
+
detected. Likewise a remote send never advertises a loopback or non-canonical
|
|
353
|
+
numeric reply host (`invalid_reply_host`). It is never run automatically, never retried, and forward
|
|
354
|
+
reachability never implies it. Like every `ssh` this CLI starts, the probe
|
|
355
|
+
and its `ssh -G` user lookup use your trusted ssh configuration on the
|
|
356
|
+
probing machine, including `ProxyCommand` and `Match exec` (see the trust
|
|
357
|
+
boundaries above). The command-line allowlist does not apply to that file.
|
|
206
358
|
|
|
207
359
|
## What success means
|
|
208
360
|
|
|
@@ -258,12 +410,13 @@ separate approval. Licensed under [MIT](../LICENSE).
|
|
|
258
410
|
|
|
259
411
|
## Package release
|
|
260
412
|
|
|
261
|
-
Version 0.2.
|
|
262
|
-
[public release record](../VALIDATION.md#public-
|
|
263
|
-
exact version and current
|
|
413
|
+
Version 0.2.1 was published and verified on 2026-09-29 KST and 0.2.0 on
|
|
414
|
+
2026-09-28 KST; see the [0.2.1 public release record](../VALIDATION.md#public-021--2026-09-29-kst).
|
|
415
|
+
Later releases add their own dated records. Check the exact version and current
|
|
416
|
+
tags before installing:
|
|
264
417
|
|
|
265
418
|
```sh
|
|
266
|
-
npm view session-peer@0.
|
|
419
|
+
npm view session-peer@0.3.0 version dist.integrity
|
|
267
420
|
npm view session-peer dist-tags
|
|
268
421
|
```
|
|
269
422
|
|
|
@@ -299,7 +452,79 @@ inbox readiness means a live process advertises a pipe; it does not prove the
|
|
|
299
452
|
pipe exists or accepts connections. `capabilities` explicitly excludes
|
|
300
453
|
wake/wait/ACK and consumption confirmation. Optional TS skill metadata checks
|
|
301
454
|
never install anything. See [diagnostic boundaries](../PARITY.md#source-read-only-doctor--18--020).
|
|
302
|
-
SSH requires the same
|
|
455
|
+
SSH requires the same TypeScript client version on both ends.
|
|
456
|
+
### Update checks and notices (0.3.0, #22)
|
|
457
|
+
|
|
458
|
+
```sh
|
|
459
|
+
session-peer update --check --json
|
|
460
|
+
session-peer update --check --channel preview --output-format text
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
This command was added in 0.3.0; 0.2.1 and earlier do not have it. `update --check` makes one
|
|
464
|
+
request (3-second timeout, no retries) for the npm dist-tags of `session-peer`
|
|
465
|
+
and reports `current`, `latest`, `channel` (`latest` by default, or `preview`),
|
|
466
|
+
`source: "npm_registry"`, `status` (`update_available`, `up_to_date` or `ahead`),
|
|
467
|
+
`managedBy`, `updateCommand` and `guidance`. A command is given only when the
|
|
468
|
+
installation's owner is positively identified from the running CLI's path:
|
|
469
|
+
an npm global prefix whose own `session-peer` launcher points at this package
|
|
470
|
+
(default, Homebrew, nvm, nvm-windows and fnm prefixes), for example
|
|
471
|
+
`npm install --global --ignore-scripts session-peer@0.3.1`; a pnpm, Yarn or Bun
|
|
472
|
+
global store whose manifest declares `session-peer`; Volta; or the npx cache.
|
|
473
|
+
Project installs (`npm_project`, `pnpm_project`), source checkouts (`source`)
|
|
474
|
+
and anything else (`unknown`) get `updateCommand: null` and a `guidance`
|
|
475
|
+
sentence instead, so no command can modify an unrelated current directory.
|
|
476
|
+
Only npm versions are reported. Python `session-peer` releases are a separate
|
|
477
|
+
stream and are never compared. Registry failures exit 1 with
|
|
478
|
+
`registry_timeout`, `registry_unreachable`, `registry_http_error`,
|
|
479
|
+
`registry_response_invalid` or `dist_tag_missing`; response bodies are never printed.
|
|
480
|
+
|
|
481
|
+
`update` without `--check` does not modify anything: it refuses with
|
|
482
|
+
`self_update_unsupported` (exit 2) and returns `managedBy`, `updateCommand`,
|
|
483
|
+
`guidance` and `checkCommand`. `update` itself is local only: it rejects
|
|
484
|
+
`--host` and is refused over the SSH wire. Remote hosts, Python installations
|
|
485
|
+
and the separately managed `session-peer-ts` skill are never updated; the
|
|
486
|
+
result lists local TS skill metadata (`skills`, same contract as `doctor`) with
|
|
487
|
+
`skillsManagedBy: "separate"`.
|
|
488
|
+
|
|
489
|
+
Cached notices on `list`, `send` and `doctor` are **off by default** because
|
|
490
|
+
this CLI is mainly run by agents and scripts that should not make unrequested
|
|
491
|
+
network calls. Set `SESSION_PEER_UPDATE_NOTICE=1` to opt in. Then a fresh cache
|
|
492
|
+
(24 hours) that shows a newer stable npm version adds a `clientUpdate` object to
|
|
493
|
+
JSON results, or one line on stderr for text output. A missing, invalid or
|
|
494
|
+
expired cache starts one detached refresh and never delays or changes the
|
|
495
|
+
command's result or exit code; a failed refresh waits 1 hour before the next
|
|
496
|
+
attempt. Cache writes are single-flight and fail closed: every write, from a
|
|
497
|
+
background refresh or an explicit check, happens only while holding
|
|
498
|
+
`npm-update.lock`, and only over an older record. Nothing ever takes over or
|
|
499
|
+
removes a lock it did not create. If a refresh crashes, or an I/O error keeps it
|
|
500
|
+
from releasing the lock, the lock stays behind: background refreshes stop, and
|
|
501
|
+
`update --check` reports `cache: "skipped_stale_lock"`. Delete `npm-update.lock` by hand when no
|
|
502
|
+
session-peer process is running.
|
|
503
|
+
|
|
504
|
+
`--no-update-notice` and `SESSION_PEER_NO_UPDATE_NOTICE=1` suppress these
|
|
505
|
+
background notices and refreshes. An explicit `update --check` is an intended
|
|
506
|
+
request: it always contacts the registry and, for the `latest` channel, writes
|
|
507
|
+
the cache when the lock is free (`cache` reports `written`, `skipped_locked`,
|
|
508
|
+
`skipped_stale_lock`, `skipped_newer` or `failed`). Notices belong to the local client. With `--host` the client
|
|
509
|
+
adds `clientUpdate` (or the stderr line) to its own top-level output, including
|
|
510
|
+
results obtained over SSH. When repeated `--host` produces a JSON array, the
|
|
511
|
+
array and its elements keep their exact shape and no `clientUpdate` is added;
|
|
512
|
+
text output still gets the single stderr line. Each invocation refreshes at most
|
|
513
|
+
once, regardless of the number of hosts. A single-host result that failed
|
|
514
|
+
(for example a refused SSH preflight) can still carry the advisory, but parse
|
|
515
|
+
errors and local refusals never do, and the advisory never changes status, exit
|
|
516
|
+
code or retry decisions. A `clientUpdate` sent back by a remote host is
|
|
517
|
+
discarded. The receiver in `--stdio-request` mode never reads,
|
|
518
|
+
refreshes or produces a notice.
|
|
519
|
+
|
|
520
|
+
The cache is `npm-update.json` in `SESSION_PEER_CACHE_DIR` (absolute), otherwise
|
|
521
|
+
`$XDG_CACHE_HOME/session-peer`, `~/Library/Caches/session-peer` (macOS),
|
|
522
|
+
`~/.cache/session-peer` (Linux) or `%LOCALAPPDATA%\session-peer\Cache`
|
|
523
|
+
(Windows). It is written atomically with mode 0600 in a 0700 directory and
|
|
524
|
+
holds only public version data. `SESSION_PEER_UPDATE_REGISTRY` selects a mirror
|
|
525
|
+
(HTTPS, or HTTP on loopback only; no credentials). npm configuration and
|
|
526
|
+
`.npmrc` are not read. See [update boundaries](../PARITY.md#source-update-checks--22).
|
|
527
|
+
|
|
303
528
|
## Agent skill: explicit installation
|
|
304
529
|
|
|
305
530
|
The separate `session-peer-ts` companion skill is tracked in [companion PR #14](https://github.com/abruption/session-peer-skill/pull/14); it is not a new npm or skill-tag release. It supports the published 0.1.0 baseline, detects the TypeScript implementation marker, and checks help before using development capabilities. The Python `session-peer` skill remains separate.
|
|
@@ -322,3 +547,8 @@ agent/scope. Restart the agent if its catalog is cached. Runtime and skill
|
|
|
322
547
|
lifecycles are independent: npm `--ignore-scripts` works, no postinstall invokes
|
|
323
548
|
Skills CLI, and installing this skill does not overwrite the Python skill or
|
|
324
549
|
install a runtime. See [compatibility and validation](../PARITY.md#source-ts-skill-guidance--25--020).
|
|
550
|
+
|
|
551
|
+
## Optional sp shorthand
|
|
552
|
+
|
|
553
|
+
Optional `sp` shorthand ships with 0.3.0 and later (not 0.2.1 or earlier) and is
|
|
554
|
+
never enabled automatically. See [explicit activation and collisions](shorthand.md).
|
package/docs/guide.zh-CN.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
[English](guide.md) | [한국어](guide.ko.md) | [日本語](guide.ja.md) | [简体中文](guide.zh-CN.md)
|
|
6
6
|
|
|
7
|
-
这是 0.
|
|
7
|
+
这是 0.3.0 详细指南。0.3.0 在 0.2.1 基础上新增多主机 SSH、发送者信息与回复路由、更新检查以及可选的 `sp` 简写([变更](../PARITY.md#030-remote-usability-and-maintenance))。上一次发布记录见 [0.2.1 公开发布证据](../VALIDATION.md#public-021--2026-09-29-kst);下文 0.1.0 的说明用于旧版本对比。
|
|
8
8
|
|
|
9
9
|
## 目录
|
|
10
10
|
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
向正在运行的 **Claude Code 和 Codex 会话**发送消息,支持本机和跨机器 SSH。这是运行于 Node.js 的 TypeScript 客户端,不需要 Python。
|
|
23
23
|
|
|
24
|
-
**这是 0.
|
|
24
|
+
**这是 0.3.0 使用指南。**包名为 `session-peer`,CLI 命令为 **`session-peer`**。本项目不提供 Relay 服务器或托管服务。
|
|
25
25
|
|
|
26
26
|
## 功能与边界
|
|
27
27
|
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
|
|
39
39
|
构建后,`node dist/cli.js list --json` 合并列出 Claude/Codex,`list --agent codex --json` 查找已知 home。公开 npm **0.1.0** 仍要求显式 agent,以及 Codex 列表所需的 home;0.2.0 也支持显式命令格式。
|
|
40
40
|
|
|
41
|
-
范围仅限默认 `~/.codex`、`CODEX_HOME`、macOS Orca 下的直接账户 home,以及 JSON 数组 `SESSION_PEER_CODEX_HOMES`。`--codex-home` 固定 Codex 列表并绕过无关配置错误;`--agent claude` 完全跳过 Codex 探索。同一 home 的别名合并,不同 home 的相同 UUID 保留。发送时使用每行的 `codexHome`。可选 home 缺失不是错误;显式 home 缺失或无效会保留成功读取的行,并返回退出码 1。列表不会选择 writer 或提交消息。[列表契约](../PARITY.md#source-unified-listing-contract--16--020)说明排序、诊断、`--all` 和 SSH 行为。0.2.0的 Codex 发送在省略 `--codex-home` 时选择唯一且稳定的 live writer;显式 home 仍会检查所有已知竞争 home。非活动队列提交需要已保存的线程、所有候选均确认非活动,以及 `--codex-home HOME --allow-inactive-codex-home`,不会执行 wake/resume。Dry-run 不提交。JSON 新增诊断 `codexHomeResolution`,且仅在原生输出提供时包含 `queueId`;两者均不代表消费确认。请参阅[选择契约](../PARITY.md#source-codex-home-selection--17--020)。公开 **0.1.0** 仍需要显式 live home,且没有非活动许可选项。SSH
|
|
41
|
+
范围仅限默认 `~/.codex`、`CODEX_HOME`、macOS Orca 下的直接账户 home,以及 JSON 数组 `SESSION_PEER_CODEX_HOMES`。`--codex-home` 固定 Codex 列表并绕过无关配置错误;`--agent claude` 完全跳过 Codex 探索。同一 home 的别名合并,不同 home 的相同 UUID 保留。发送时使用每行的 `codexHome`。可选 home 缺失不是错误;显式 home 缺失或无效会保留成功读取的行,并返回退出码 1。列表不会选择 writer 或提交消息。[列表契约](../PARITY.md#source-unified-listing-contract--16--020)说明排序、诊断、`--all` 和 SSH 行为。0.2.0的 Codex 发送在省略 `--codex-home` 时选择唯一且稳定的 live writer;显式 home 仍会检查所有已知竞争 home。非活动队列提交需要已保存的线程、所有候选均确认非活动,以及 `--codex-home HOME --allow-inactive-codex-home`,不会执行 wake/resume。Dry-run 不提交。JSON 新增诊断 `codexHomeResolution`,且仅在原生输出提供时包含 `queueId`;两者均不代表消费确认。请参阅[选择契约](../PARITY.md#source-codex-home-selection--17--020)。公开 **0.1.0** 仍需要显式 live home,且没有非活动许可选项。SSH 两端需要相同的 TypeScript 客户端版本(0.3.0)。
|
|
42
42
|
|
|
43
43
|
### 0.2.0 CLI 易用性
|
|
44
44
|
|
|
@@ -61,11 +61,11 @@ macOS、Linux 或 Windows native;Node **22.x 中的 22.13 及以上,或 24.x
|
|
|
61
61
|
已验证的稳定版可在 Node 22.x 的 22.13 及以上或 24.x 上安装。Python CLI 也使用同一个命令名;若已有安装,请先检查 PATH。
|
|
62
62
|
|
|
63
63
|
```sh
|
|
64
|
-
npm install --global --ignore-scripts session-peer@0.
|
|
64
|
+
npm install --global --ignore-scripts session-peer@0.3.0
|
|
65
65
|
session-peer --version
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
-
预期输出:`session-peer 0.
|
|
68
|
+
预期输出:`session-peer 0.3.0 (typescript)`。
|
|
69
69
|
|
|
70
70
|
1. 用 `session-peer list --agent claude --json` 查找目标并选择准确 PID。
|
|
71
71
|
2. 用 `session-peer send --to CLAUDE_PID --message 'Please reply after checking.' --dry-run --json` 验证,不提交。
|
|
@@ -84,7 +84,7 @@ npm run build
|
|
|
84
84
|
node dist/cli.js --version
|
|
85
85
|
npm pack --ignore-scripts
|
|
86
86
|
# 可选:全局安装前先检查 PATH 选择的现有命令
|
|
87
|
-
npm install --global --ignore-scripts ./session-peer-0.
|
|
87
|
+
npm install --global --ignore-scripts ./session-peer-0.3.0.tgz
|
|
88
88
|
session-peer --version
|
|
89
89
|
```
|
|
90
90
|
|
|
@@ -94,7 +94,7 @@ session-peer --version
|
|
|
94
94
|
|
|
95
95
|
安装前后用 `type -a session-peer` 和 `command -v session-peer` 检查实际执行项。其他实现也可能提供同名命令;请选择 PATH 上的一种,或显式运行 `node /absolute/path/dist/cli.js`。不要用 `--force` 覆盖其他管理器的文件。本包不会自动安装、删除或调整 Python 包、技能或服务。卸载使用 `npm uninstall --global session-peer`,随后再次检查 PATH。
|
|
96
96
|
|
|
97
|
-
在 Windows PowerShell 中用 `Get-Command session-peer -All` 检查已有命令。为了不替换 Python CLI,可先执行 `npm ci --ignore-scripts`、`npm run build`、`npm pack --ignore-scripts`,再用 `npm install --prefix "$env:TEMP\session-peer-ts-source" --ignore-scripts .\session-peer-0.
|
|
97
|
+
在 Windows PowerShell 中用 `Get-Command session-peer -All` 检查已有命令。为了不替换 Python CLI,可先执行 `npm ci --ignore-scripts`、`npm run build`、`npm pack --ignore-scripts`,再用 `npm install --prefix "$env:TEMP\session-peer-ts-source" --ignore-scripts .\session-peer-0.3.0.tgz` 安装到隔离目录。以 `& "$env:TEMP\session-peer-ts-source\node_modules\.bin\session-peer.cmd" --version` 验证,并可用 `npm uninstall --prefix "$env:TEMP\session-peer-ts-source" session-peer` 卸载。
|
|
98
98
|
|
|
99
99
|
## 使用
|
|
100
100
|
|
|
@@ -114,13 +114,44 @@ session-peer send --host user@machine --remote-bin /absolute/path/session-peer \
|
|
|
114
114
|
--to CLAUDE_PID --message 'Please review the API contract.' --dry-run --json
|
|
115
115
|
```
|
|
116
116
|
|
|
117
|
-
默认远程命令是 PATH 中的 `session-peer`。绝对路径 `--remote-bin` 也可选择使用受支持 Node 的包装器。握手检查 TypeScript 标记及精确版本,不同实现会被拒绝。SSH 使用 BatchMode 和 StrictHostKeyChecking,不自动接受新主机密钥、不安装远程运行时,也不会退回 Python。消息通过 JSON stdin 传输,不放进远程 shell
|
|
117
|
+
默认远程命令是 PATH 中的 `session-peer`。绝对路径 `--remote-bin` 也可选择使用受支持 Node 的包装器。握手检查 TypeScript 标记及精确版本,不同实现会被拒绝。SSH 使用 BatchMode 和 StrictHostKeyChecking,不自动接受新主机密钥、不安装远程运行时,也不会退回 Python。消息通过 JSON stdin 传输,不放进远程 shell 参数。正向访问不意味着反向访问已配置。自 0.3.0 起 Tailscale 只用作路由提示,见[回复](#回复)。
|
|
118
118
|
|
|
119
|
-
对于 Windows SSH 目标,请指定 `--remote-platform win32`;若远端 PATH 中没有命令,再使用 `--remote-bin 'C:\absolute\path\session-peer.cmd'
|
|
119
|
+
对于 Windows SSH 目标,请指定 `--remote-platform win32`;若远端 PATH 中没有命令,再使用 `--remote-bin 'C:\absolute\path\session-peer.cmd'`。仅有一个 `--host` 时,可用 `--ssh-control-path /local/absolute/socket` 选择已认证的 OpenSSH 控制套接字;这不会跳过主机密钥验证或授予新登录。Windows 本机的 Codex home 使用完整 `C:\Users\...\.codex` 路径。已有 Python CLI 不会被自动删除或替换。
|
|
120
|
+
|
|
121
|
+
### 多主机与连接选项
|
|
122
|
+
|
|
123
|
+
自 0.3.0 起(0.2.1 及更早版本没有)接受重复的 `--host` 和受限的 `--ssh-opt`:
|
|
124
|
+
|
|
125
|
+
```sh
|
|
126
|
+
session-peer list --host alpha --host user@[2001:db8::1] \
|
|
127
|
+
--ssh-opt=-p --ssh-opt=2222 --ssh-opt=-i --ssh-opt="$HOME/.ssh/id_ed25519" --json
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
- 只有一个 `--host` 时与以前一样返回单个对象。重复 `--host` 时按相同顺序返回 JSON 数组,每个元素都有 `schemaVersion`、`ok`、`host` 和 `command`。任一主机失败时退出码为 1。文本输出为每个目标打印一个 `Host: <host>` 块。
|
|
131
|
+
- 在启动任何 `ssh` 进程之前校验所有主机和选项。只要有一个值无效,就拒绝整个命令并返回 `submitted:false`。`--` 之前的 `--host VALUE` 和 `--host=VALUE` 会先被收集,因此当它们有两个或更多时,任何拒绝(包括未知选项或缺少值)都会输出为每个主机一个元素的数组;少于两个时输出单个对象。
|
|
132
|
+
- 重复指定同一目标会返回 `duplicate_ssh_host`。该检查只比较目标文本(用户、不区分大小写的主机名、规范化的 IPv6),无法识别指向同一台机器的不同别名或地址。
|
|
133
|
+
- `--ssh-jump USER@HOST[:PORT]`(只能指定一次,限 POSIX 客户端)让所有 `--host` 的每次 `ssh` 调用都经过同一台跳板机。必须指定用户,IPv6 需要方括号(`hop@[2001:db8::1]:22`),`%`、`$`、引号、空格等 shell 字符会被拒绝(`invalid_ssh_jump`)。CLI 不使用 `-J`,而是构造一个固定的 `ProxyCommand`:跳板段的 `ssh` 以 `BatchMode=yes`、`StrictHostKeyChecking=yes`、`UpdateHostKeys=no`、`ConnectTimeout=10`、`ConnectionAttempts=1`、`ProxyCommand=none`、`ProxyJump=none`、`ControlPath=none`、`ForwardAgent=no`、`ClearAllForwardings=yes`、`PermitLocalCommand=no` 运行,再通过 `-W [目标]:端口` 连接。外层 `ssh` 也会设置 `ControlMaster=no`、`ControlPath=none` 和 `ProxyUseFdpass=no`,因此已配置的控制主连接无法绕过跳板机。`ProxyCommand` 通过你的登录 shell(`$SHELL`)运行,已在 sh、bash 和 zsh 中验证,其他登录 shell(如 fish、csh)未验证。跳板机也需要自己的 known_hosts 条目。`--ssh-opt` 的值(包括 `-4`/`-6`)只作用于目标,不会传给跳板机;除此之外,跳板段遵循你的 SSH 配置中该主机的设置。只支持一级跳板。它与 `--ssh-control-path` 冲突(`conflicting_ssh_jump`),在验证 Win32-OpenSSH 的 `ProxyCommand` 处理之前,Windows 客户端会拒绝它(`ssh_jump_unsupported_platform`)。结果新增 `sshJump`。
|
|
134
|
+
- 超时是有界的。在 POSIX 上,每个 `ssh` 都以分离方式启动:位于一个没有控制终端的新会话和进程组中。清理只覆盖该进程组;通过 `setsid()` 离开该组的子孙进程不在范围内,也不会扫描 PID。超时或输出超限时,会终止整个进程组,包括仍占用输出管道的跳板 `ProxyCommand` 等子孙进程,随后调用很快返回。CLI 收到 Ctrl-C、SIGTERM 或 SIGHUP 时,也会在退出前终止该进程组。在 Windows 上只终止直接子进程,子孙进程可能残留,但调用仍会在截止时间返回。预检超时视为拒绝(`ssh_preflight_timeout`),请求超时为 `unknown`,且不会重试。
|
|
135
|
+
- 每个目标按顺序只进行一次预检和最多一次请求。被拒绝或 `unknown` 的主机不会阻止下一个主机,也不会重试或改发到其他目标。请逐个检查元素后再采取行动。
|
|
136
|
+
- `--ssh-opt` 只接受 `-p PORT`、`-l USER`、`-i IDENTITY_FILE`、`-o Port=…`、`-o User=…`、`-o IdentityFile=…`、`-o IdentitiesOnly=yes|no`、`-4` 和 `-6`。其他选项一律拒绝(`unsupported_ssh_option`),包括 `ProxyCommand`、`LocalCommand`、`-F`、`Include`、`-J`/`ProxyJump` 以及对 `BatchMode`/`StrictHostKeyChecking` 的修改。请用 `--ssh-jump` 代替 `-J`:OpenSSH 自带的 `-J` 跳板连接不会获得命令行中的 `BatchMode` 和 `StrictHostKeyChecking`。
|
|
137
|
+
- IPv6 字面量可以不带方括号(`2001:db8::1`),也可以带方括号(`[2001:db8::1]`、`user@[2001:db8::1]`);区域 ID(`%`)会被拒绝。
|
|
138
|
+
- 结果新增 `sshUser` 和 `sshUserSource`:`USER@HOST` 或 `-l USER` 为 `explicit`;通过 `ssh -G` 得到的为 `ssh_config_or_local_default`;无法确定时为 `sshUser:null` 和 `unknown`。同时使用 `-l` 和 `USER@HOST` 会被拒绝。没有显式用户时,会为每个主机在本地运行一次 `ssh -G`(最长 5 秒)。它不建立连接,但如 ssh(1) 和 ssh_config(5) 所述,会像普通 `ssh` 一样解析 SSH 配置,包括执行 `Match exec` 命令。
|
|
139
|
+
- 存在两条信任边界。允许列表只约束本 CLI 在命令行上传递的选项。你自己的 `~/.ssh/config`(以及系统配置)属于受信任的用户配置,其中的 `ProxyCommand`、`ProxyJump`、`Match exec` 等设置,会像你自己运行 `ssh` 时一样,作用于本 CLI 启动的每个 `ssh`。
|
|
140
|
+
|
|
141
|
+
关于在不依赖 Python 的情况下准备目标机器(按版本划分的专用安装目录、完整性校验、所有权与回滚规则),以及独立于包版本的协议兼容性约定,设计提案见[远程部署 ADR](design/remote-deployment.md)。该提案尚未实现,上述相同版本要求仍然适用。
|
|
120
142
|
|
|
121
143
|
### 回复
|
|
122
144
|
|
|
123
|
-
可将 `session-peer://v1/reply?...` URI 用作 `--to`。未知 /
|
|
145
|
+
可将 `session-peer://v1/reply?...` URI 用作 `--to`。未知 / 重复字段、不安全主机、错误编码及与显式路由的冲突都会被拒绝。peer 元数据不是授权,Reply-To URI 也不会作为 shell 文本执行。收到的 Reply-To 只是供阅读的数据,不会自动观察或确认回复。
|
|
146
|
+
|
|
147
|
+
自 0.3.0 起(0.2.1 及更早版本没有)新增发送者信息和自动生成的回复路由:
|
|
148
|
+
|
|
149
|
+
- **发送者。** 在 Claude Code 中,`CLAUDE_CODE_MESSAGING_SOCKET` 必须恰好匹配一个已注册且存活的会话;该会话唯一且可打印的名称(否则用 PID)成为 `From: claude:NAME`。在 Codex 中,有效的 `CODEX_THREAD_ID`(或 `CODEX_SESSION_ID`)成为 `From: codex:UUID`。证据冲突、嵌套或无效时不确定发送者,此时也不生成回复路由。`--no-from` 只省略 From。
|
|
150
|
+
- **自动 Reply-To。** 有发送者且未指定 `--no-reply-to` 时,本机发送附加 `transport=local` 的 URI;SSH 发送或指定 `--reply-to` 时附加 `transport=ssh` 的 URI,主机依次取 `--reply-to HOST`、`SESSION_PEER_REPLY_HOST`、`CC_PEER_REPLY_HOST`、本机的 tailnet 名称或地址。不含用户的主机会加上当前用户。找不到主机时不附加 SSH 路由。`--reply-address URI` 仍是显式的替代方式。`--reply-to`、`--reply-address` 和 `--no-reply-to` 互斥。所有 URI 都用与 `--to` 相同的解析器校验。
|
|
151
|
+
- **JSON。** `replyRoute` 报告生成的路由:本机路由为 `verified`(`same_machine_route`),SSH 路由为 `unverified`(`reverse_ssh_not_checked`)。`--to` 为 URI 时,`addressResolution` 记录其传输方式;若改为本机投递,还会记录 `normalizedFrom: "ssh_self"`。
|
|
152
|
+
- **同一台机器。** 只有当 SSH 回复 URI 的主机包含当前操作系统用户、以精确形式指向本机(精确的 `localhost`、规范的 `127.x.y.z`、`::1`、`::ffff:127.x.y.z`、主机名或 Tailscale 自身节点;`127.1`、`0177.0.0.1` 等非规范数字形式以及 `::7f00:1` 等 IPv4 兼容地址都不算),且未给出 `--host` 或 SSH 选项(包括 `--ssh-jump`)时,才改为本机投递。用户不同或缺失时仍走 SSH。
|
|
153
|
+
- **Tailscale。** `tailscale status --json`(限时 3 秒)只作为路由提示。`Online` 为布尔值 `true` 的节点(MagicDNS 开启)保留你给出的 SSH 别名作为目标,并添加 `HostName=<MagicDNS 名称>`;同时添加 `HostKeyAlias=<原名称>`,但如果查询用户的同一次 `ssh -G` 显示 SSH 配置中已设置 `HostKeyAlias`,则保留该值,查询失败时也不覆盖任何设置。此时结果中的 `host` 为 MagicDNS 名称,`sshHost` 为你给出的别名。`Online` 为布尔值 `false` 的节点(即使 MagicDNS 关闭)或有歧义的名称在 SSH 之前被拒绝(`tailscale_peer_offline`、`tailscale_destination_ambiguous`)。其他 `Online` 值、MagicDNS 关闭、未知名称、已停止或未安装的 Tailscale,以及 `SESSION_PEER_TAILSCALE=off`,都按普通 SSH 处理。
|
|
154
|
+
- **回程路由检查。** `doctor --check-return-route [--reply-to USER@HOST]` 在被诊断的机器(`--host` 目标或本机)上执行 `ssh … USER@HOST 'exit 0'`:batch 模式、禁止密码和键盘交互提示、严格主机密钥、不更新主机密钥、不使用控制套接字、连接超时 5 秒。8 秒时限只作用于最后这条 `ssh` 命令;此前的 Tailscale 状态查询(3 秒)和 `ssh -G` 查询(5 秒)各有自己的时限。`exit 0` 在 POSIX shell、cmd.exe 和 PowerShell 中都是空操作,因此回程主机可以是以其中任一为默认 shell 的 OpenSSH 服务器(只有 POSIX 回程主机有夹具覆盖)。`returnRoute` 为 `verified` 或 `failed`,并附原因(`return_host_unavailable`、`return_host_is_receiver`、`ssh_executable_missing`、`authentication_failed`、`host_key_failed`、`timeout`、`transport_failed`、`remote_command_failed`)。本机检查时,同一台机器的当前用户按本机路由处理,不启动 SSH。使用 `--host` 时,可能指向某台机器自身的回程主机(不经 DNS 判断:`localhost`、`*.localhost`、规范形式的 127.0.0.0/8 和 0.0.0.0/8、`::1`、`::`、它们的 `::ffff:` 映射形式、IPv4 兼容 IPv6(`::a.b.c.d`),以及各解析器解释不一的所有非规范数字形式:前导零、少于四段、十六进制或八进制段、单个整数、`127.1`、`0177.0.0.1`、`2130706433`、`4294967296` 等越界值)会被目标机器理解为它自己,因此在 SSH 之前被拒绝(`invalid_return_route`)。在目标机器上,若回程主机是目标机器自身的已知名称(无论用户)或无法证明的数字形式,则以 `return_host_is_receiver` 失败,绝不报告为已验证的本机路由。“已知名称”仅指与操作系统主机名或 Tailscale 自身节点的名称、地址完全一致;其他 DNS 或局域网别名无法识别。远程发送同样不会公布回环或非规范数字形式的回复主机(`invalid_reply_host`)。该检查从不自动运行、从不重试,正向可达也绝不代表回程可达。与本 CLI 启动的其他 `ssh` 一样,该检查及其 `ssh -G` 用户查询会使用执行检查的机器上受信任的 SSH 配置(包括 `ProxyCommand` 和 `Match exec`,见上文的信任边界)。命令行允许列表不适用于该配置文件。
|
|
124
155
|
|
|
125
156
|
## 成功含义与安全性
|
|
126
157
|
|
|
@@ -152,11 +183,12 @@ Python 只用作开发时的兼容性基准(v1.0.2,`47c23713d0a2a3c11ebde618
|
|
|
152
183
|
|
|
153
184
|
## npm 版本
|
|
154
185
|
|
|
155
|
-
0.2.
|
|
186
|
+
0.2.1 已于 2026-09-29 KST、0.2.0 已于 2026-09-28 KST 公开并验证。请参阅
|
|
187
|
+
[0.2.1 公开记录](../VALIDATION.md#public-021--2026-09-29-kst)(之后的版本各自追加带日期的记录),
|
|
156
188
|
安装前核对准确版本与当前标签。
|
|
157
189
|
|
|
158
190
|
```sh
|
|
159
|
-
npm view session-peer@0.
|
|
191
|
+
npm view session-peer@0.3.0 version dist.integrity
|
|
160
192
|
npm view session-peer dist-tags
|
|
161
193
|
```
|
|
162
194
|
|
|
@@ -181,7 +213,60 @@ session-peer doctor --host user@host --json
|
|
|
181
213
|
不会执行 Codex、连接 inbox、获取 writer 锁或提交消息。Windows 就绪状态只表示
|
|
182
214
|
存活进程公布了 pipe,并不证明 pipe 存在或可以连接。`capabilities` 明确将
|
|
183
215
|
wake/wait/ACK 和消费确认标为不支持。可选的 TS 技能元数据检查也不会安装任何内容。
|
|
184
|
-
参见[诊断边界](../PARITY.md#source-read-only-doctor--18--020)。SSH
|
|
216
|
+
参见[诊断边界](../PARITY.md#source-read-only-doctor--18--020)。SSH 两端需要相同的 TypeScript 客户端版本。
|
|
217
|
+
### 更新检查与提示(0.3.0,#22)
|
|
218
|
+
|
|
219
|
+
```sh
|
|
220
|
+
session-peer update --check --json
|
|
221
|
+
session-peer update --check --channel preview --output-format text
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
此命令在 0.3.0 中加入,0.2.1 及更早版本没有。`update --check` 只请求一次 `session-peer` 的 npm
|
|
225
|
+
dist-tag(3 秒超时,不重试),并报告 `current`、`latest`、`channel`(默认 `latest`,
|
|
226
|
+
或 `preview`)、`source: "npm_registry"`、`status`(`update_available`、`up_to_date`、
|
|
227
|
+
`ahead`)、`managedBy`、`updateCommand` 和 `guidance`。只有根据当前 CLI 路径能确切识别
|
|
228
|
+
安装的管理方时才给出命令:其自身 `session-peer` 启动器指向本包的 npm 全局 prefix
|
|
229
|
+
(默认、Homebrew、nvm、nvm-windows、fnm,例如
|
|
230
|
+
`npm install --global --ignore-scripts session-peer@0.3.1`),清单中声明了
|
|
231
|
+
`session-peer` 的 pnpm、Yarn、Bun 全局存储,Volta,或 npx 缓存。项目安装
|
|
232
|
+
(`npm_project`、`pnpm_project`)、源码检出(`source`)以及其他情况(`unknown`)只返回
|
|
233
|
+
`updateCommand: null` 和一句 `guidance`,因此不会给出可能修改无关当前目录的命令。它只报告
|
|
234
|
+
npm 版本,Python 版 `session-peer` 的发布是独立的版本序列,从不与之比较。注册表失败时
|
|
235
|
+
退出码为 1,错误为 `registry_timeout`、`registry_unreachable`、`registry_http_error`、
|
|
236
|
+
`registry_response_invalid` 或 `dist_tag_missing`,不会输出响应正文。
|
|
237
|
+
|
|
238
|
+
不带 `--check` 的 `update` 不会修改任何内容:它以 `self_update_unsupported`(退出码 2)
|
|
239
|
+
拒绝,并返回 `managedBy`、`updateCommand`、`guidance` 和 `checkCommand`。`update` 本身
|
|
240
|
+
仅限本地:拒绝 `--host`,也拒绝经由 SSH wire 的请求。远程主机、Python 安装和单独管理的
|
|
241
|
+
`session-peer-ts` 技能都不会被更新;结果会列出本地 TS 技能元数据(`skills`,与 `doctor`
|
|
242
|
+
相同的约定)以及 `skillsManagedBy: "separate"`。
|
|
243
|
+
|
|
244
|
+
`list`、`send`、`doctor` 的缓存提示**默认关闭**,因为此 CLI 主要由代理和脚本调用,
|
|
245
|
+
不应发起未经请求的网络访问。设置 `SESSION_PEER_UPDATE_NOTICE=1` 开启后,若 24 小时内的
|
|
246
|
+
缓存显示有更新的 npm 稳定版,JSON 结果会增加 `clientUpdate` 对象,文本输出则在 stderr
|
|
247
|
+
写一行。缓存缺失、无效或过期时会启动一个分离的刷新进程,不会延迟或改变命令结果与退出码;
|
|
248
|
+
刷新失败后 1 小时内不再尝试。缓存写入是单次执行的,并在失败时保持关闭:无论是后台刷新还是
|
|
249
|
+
显式检查,写入都只在持有 `npm-update.lock` 时进行,且只覆盖更旧的记录。任何调用都不会接管或
|
|
250
|
+
删除不是自己创建的锁。若刷新异常退出,或因 I/O 错误未能释放锁而留下锁,后台刷新会停止,`update --check` 会报告
|
|
251
|
+
`cache: "skipped_stale_lock"`。请在没有 session-peer 进程运行时手动删除 `npm-update.lock`。
|
|
252
|
+
|
|
253
|
+
`--no-update-notice` 和 `SESSION_PEER_NO_UPDATE_NOTICE=1` 会抑制这些后台提示和刷新。
|
|
254
|
+
显式的 `update --check` 是有意的请求,总会访问注册表;对 `latest` 通道,在锁空闲时写入缓存
|
|
255
|
+
(`cache` 为 `written`、`skipped_locked`、`skipped_stale_lock`、`skipped_newer` 或 `failed`)。提示
|
|
256
|
+
属于本地客户端:使用 `--host` 时,客户端会在自身的顶层输出(包括经由 SSH 获得的结果)中
|
|
257
|
+
加入 `clientUpdate`(或 stderr 中的一行)。重复 `--host` 产生 JSON 数组时,数组及其元素保持原样,
|
|
258
|
+
不加入 `clientUpdate`;文本输出仍在 stderr 写一行。无论主机数量多少,每次调用最多刷新一次。失败的单主机结果(例如被拒绝的 SSH 预检)也可能带有提示,
|
|
259
|
+
但解析错误和本地拒绝不会带;提示从不改变状态、退出码或重试判断。远程主机返回的 `clientUpdate`
|
|
260
|
+
会被丢弃。`--stdio-request` 模式的接收端从不读取或刷新
|
|
261
|
+
缓存,也不会产生提示。
|
|
262
|
+
|
|
263
|
+
缓存文件为 `SESSION_PEER_CACHE_DIR`(绝对路径)下的 `npm-update.json`,否则依次为
|
|
264
|
+
`$XDG_CACHE_HOME/session-peer`、`~/Library/Caches/session-peer`(macOS)、
|
|
265
|
+
`~/.cache/session-peer`(Linux)或 `%LOCALAPPDATA%\session-peer\Cache`(Windows)。
|
|
266
|
+
以 0600 权限原子写入 0700 目录,仅包含公开的版本信息。`SESSION_PEER_UPDATE_REGISTRY`
|
|
267
|
+
可指定镜像(HTTPS,或仅限 loopback 的 HTTP;不允许凭据)。不会读取 npm 配置或 `.npmrc`。
|
|
268
|
+
参见[更新边界](../PARITY.md#source-update-checks--22)。
|
|
269
|
+
|
|
185
270
|
## 显式安装代理技能
|
|
186
271
|
|
|
187
272
|
独立的 `session-peer-ts` 技能在配套 PR 中管理,不代表新 npm 或技能标签发布。它支持已发布的 0.1.0 基础功能,通过 TypeScript 标识和帮助检查开发功能。Python 的 `session-peer` 技能仍独立保留。
|
|
@@ -202,3 +287,8 @@ npx -y skills@1.7.0 remove session-peer-ts --agent codex --yes
|
|
|
202
287
|
如果代理缓存了技能目录,请重启代理。运行时和技能独立管理:npm `--ignore-scripts` 可正常使用,
|
|
203
288
|
postinstall 不会调用 Skills CLI,安装此技能不会覆盖 Python 技能或安装运行时。
|
|
204
289
|
参见[兼容性和验证](../PARITY.md#source-ts-skill-guidance--25--020)。
|
|
290
|
+
|
|
291
|
+
## 可选 sp 简写
|
|
292
|
+
|
|
293
|
+
可选的 `sp` 简写包含在 0.3.0 及更高版本中(0.2.1 及更早版本没有),不会自动启用。
|
|
294
|
+
请参阅[显式启用、冲突与停用(英文)](shorthand.md)。
|