dsh-session-sync 0.2.33 → 0.3.2
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/ARCHITECTURE.md +12 -4
- package/CHANGELOG.md +23 -0
- package/LICENSE +0 -0
- package/PRIVACY.md +0 -0
- package/README.en.md +27 -1
- package/README.es.md +27 -1
- package/README.hi.md +27 -1
- package/README.md +27 -1
- package/README.pt.md +27 -1
- package/SECURITY.md +0 -0
- package/THIRD_PARTY_NOTICES.md +0 -0
- package/cordis.patch.yml +17 -0
- package/icon.svg +0 -0
- package/index.mjs +96 -16
- package/lib/age.mjs +0 -0
- package/lib/backend.mjs +0 -0
- package/lib/constants.mjs +11 -0
- package/lib/cwdmap.mjs +248 -0
- package/lib/domain.mjs +0 -0
- package/lib/durability.mjs +80 -0
- package/lib/encrypted.mjs +10 -1
- package/lib/engine.mjs +68 -3
- package/lib/errors.mjs +0 -0
- package/lib/gate.mjs +0 -0
- package/lib/git.mjs +0 -0
- package/lib/merge.mjs +0 -0
- package/lib/mirror.mjs +294 -35
- package/lib/paths.mjs +0 -0
- package/lib/projection.mjs +191 -0
- package/lib/render.mjs +17 -2
- package/lib/sanitize.mjs +0 -0
- package/lib/sessionlog.mjs +142 -0
- package/lib/status.mjs +0 -0
- package/package.json +42 -23
- package/types.d.ts +40 -0
package/ARCHITECTURE.md
CHANGED
|
@@ -19,7 +19,11 @@
|
|
|
19
19
|
| `lib/paths.mjs` | Path resolution, nesting checks, and fork-file naming — pure |
|
|
20
20
|
| `lib/sanitize.mjs` | Pure display/log redaction (remote-URL credentials, tokens, `key=value` secrets, path-containment display) |
|
|
21
21
|
| `lib/merge.mjs` | Append-only three-way merge classification — pure |
|
|
22
|
-
| `lib/
|
|
22
|
+
| `lib/durability.mjs` | Host durability wait before an auto push: calls the public `ctx.sessions.flush(session)` barrier (the JSONL writer batches live events for up to 200 ms) with a timeout; never throws and never blocks the session |
|
|
23
|
+
| `lib/mirror.mjs` | Byte mirror from the session store into the worktree, restore back into the live store, and deletion protection (`node:fs`). Projection-aware: projected local copies are skipped as sources and reattached to the mirror's original header frame; `followSessionSymlinks` opts into contained links only |
|
|
24
|
+
| `lib/cwdmap.mjs` | Restore-time cwd matching/projection — pure (`cwdMap` longest-prefix + segment boundary, host-compatible `projectKey`, `--unmapped--` fallback) |
|
|
25
|
+
| `lib/sessionlog.mjs` | Session-log first frame read/rewrite (`node:zlib`): the header is its own zstd frame, so a projection replaces only that frame |
|
|
26
|
+
| `lib/projection.mjs` | Local projection state (`.git/dsh-session-sync-projection.json`): canonical↔projected path pairs, original cwd and header frame; plans restore placement and reconstructs canonical bytes on push |
|
|
23
27
|
| `lib/git.mjs` | Git command layer: verb whitelist + argument assertions, never force-push/reset/rebase/branch-switch |
|
|
24
28
|
| `lib/backend.mjs` | Transport backend seam contract + pure `selectEncryptionMode` (backend/mode/warnings selection) |
|
|
25
29
|
| `lib/age.mjs` | age binary probe (`detectAge`) + file-based `ageEncrypt`/`ageDecrypt` (optional external binary, graceful degrade) |
|
|
@@ -36,9 +40,10 @@
|
|
|
36
40
|
$DSH_HOME/sessions ──byte mirror──▶ <repoDir>/sessions ──git──▶ custom remote
|
|
37
41
|
```
|
|
38
42
|
|
|
39
|
-
1. **Mirror** copies each session file as opaque bytes into the worktree (symlinks refused, deletions only for files that vanished at the source and are neither fork files nor host-private artifacts). Host-private artifacts (`session.lock`, the harness session lease, and `session.migration.*.tmp` staging files) are runtime state, not syncable content: the mirror neither copies them in nor deletes them from the worktree.
|
|
43
|
+
1. **Mirror** copies each session file as opaque bytes into the worktree (symlinks refused by default, deletions only for files that vanished at the source and are neither fork files nor host-private artifacts). Host-private artifacts (`session.lock`, the harness session lease, and `session.migration.*.tmp` staging files) are runtime state, not syncable content: the mirror neither copies them in nor deletes them from the worktree. With `followSessionSymlinks: true` only links whose `realpath` stays inside `sessionRoot` are read (still never written through), and every skipped link is reported.
|
|
40
44
|
2. **Commit** records the mirror as a git commit (plugin identity, never the user's git identity).
|
|
41
45
|
3. **Push/pull** move commits to/from the configured remote over `ctx.subprocess`-driven git.
|
|
46
|
+
4. **Restore projection (`cwdMap`)** — a cross-OS session's `header.cwd` is not natively absolute on the receiving host, so neither the workspace index nor the JSONL backend can read it. On restore, `lib/cwdmap.mjs` maps the origin prefix to a local path (longest prefix, segment boundary), `lib/projection.mjs` rewrites the **first frame of the local copy only**, and the file lands at `<projectKey(mapped cwd)>/<sessionId>/<file>` — the same formula the host validates. The mirror keeps the origin device's bytes; on push the original header frame is reattached, so the remote sees only the locally appended frames (byte-identical append-only merge, no fork churn). Without a mapping entry a cross-platform cwd goes read-only to `<sessionRoot>/--unmapped--` (visible, `cwdUnmapped` in status, never a push source) and its mapped directory is created so the host can group it.
|
|
42
47
|
|
|
43
48
|
## Conflict resolution — never silently overwrite
|
|
44
49
|
|
|
@@ -71,7 +76,7 @@ Sync metadata (`deviceId`, `lastPullAt`, `lastPushAt`, `lastPushHead`, `lastErro
|
|
|
71
76
|
Every automatic behavior is a Cordis effect, so stop/hot-reload removes it:
|
|
72
77
|
|
|
73
78
|
- `autoPullOnStart` — `ctx.effect` pulls once on mount.
|
|
74
|
-
- `autoPushOnTurnEnd` — `ctx.on('session/event')` pushes after `turn/end
|
|
79
|
+
- `autoPushOnTurnEnd` — `ctx.on('session/event')` pushes after `turn/end`, but only after `ctx.sessions.flush(session)` has drained the host's buffered writes (bounded by `durabilityTimeoutMs`, default 2000 ms; on timeout it logs and pushes the current on-disk snapshot).
|
|
75
80
|
- `pullIntervalMinutes` — `ctx.effect` wraps a `setInterval` periodic pull (the disposer clears the timer).
|
|
76
81
|
|
|
77
82
|
Auto runs are covered by the config grant and never re-confirm.
|
|
@@ -80,12 +85,15 @@ Auto runs are covered by the config grant and never re-confirm.
|
|
|
80
85
|
|
|
81
86
|
- **Verb whitelist** in `lib/git.mjs`; `-f`/`--force`/`--force-with-lease`/`+refspec`, `reset`, `clean`, `rebase`, and branch-switch `checkout` are refused.
|
|
82
87
|
- **Path containment** before any join (`PATH_UNSAFE` fails loud).
|
|
83
|
-
- **Symlinks never followed** on either side of the mirror.
|
|
88
|
+
- **Symlinks never followed by default** on either side of the mirror. `followSessionSymlinks: true` (opt-in) reads only links whose `realpath` stays inside `sessionRoot`; writes still refuse link targets and escape paths.
|
|
89
|
+
- **Restore projection never rewrites the synced bytes.** Only the local copy's first frame changes; the mirror always receives the origin header frame plus the locally appended frames, so cross-platform mapping cannot create meaningless divergence.
|
|
84
90
|
- **Sanitize before display/log** — remote-URL credentials, tokens, and `key=value` secrets are redacted before reaching the model or the log.
|
|
85
91
|
- **Bounded subprocesses** — git runs with `GIT_TERMINAL_PROMPT=0` and `GIT_OPTIONAL_LOCKS=0`, deadline- and signal-bounded, with a per-stream output cap.
|
|
86
92
|
|
|
87
93
|
## Upstream asks (recorded, not implemented)
|
|
88
94
|
|
|
95
|
+
- **Host-side cwd alias for session indexing.** `dsh-workspace` indexes sessions by `realpath(header.cwd)` and `session-persistence-jsonl` rejects a header whose cwd is not natively absolute, so cross-OS visibility currently requires the plugin to rewrite a local copy of the header and move the file into the projected project directory. A host-level alias/foreign-root mapping (or a `SessionHeader` cwd override at read time) would let the mirror stay byte-identical everywhere and drop the projection state.
|
|
96
|
+
|
|
89
97
|
- **Session-directory layout version marker.** The mirror maps fork files back to sessions by path shape (`<projectKey>/<sessionId>/<file>` plus the legacy flat form). A version marker in the session-directory layout would let a future plugin declare which layout it understands instead of sniffing segment shapes; recorded here per the 0.1.6 adaptation review (P2, no code change requested).
|
|
90
98
|
|
|
91
99
|
## Backend vocabulary
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.3.1] - 2026-11-14
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **An auto push no longer mirrors a `turn/end` the host has not written yet.** The JSONL backend buffers live session events for up to 200 ms (`LIVE_WRITE_BATCH_MAX_DELAY_MS`, `session-persistence-jsonl/src/storage.ts:37`) and only `persistBatch`es on the timer or a `session/flush` (`:275-282`, `:555-562`). The `turn/end` listener used to `push()` immediately, so the mirror could miss the final `turn/end` line — or the whole session file on the first append — and a cross-device restore then saw an unclosed turn. The listener now awaits the host's public durability barrier `ctx.sessions.flush(session)` (`SessionStore.flush` → `session/flush` → backend `drainLive` + `handle.flush`) before mirroring; the wait yields one microtask first so the persistence router has enqueued the very event being handled. It is bounded by the new `durabilityTimeoutMs` (default `2000`, `0` = do not wait): a timeout, a rejecting barrier, or a host without `sessions.flush` (older than 0.2.2) is logged once and the push continues with the current on-disk snapshot, so a stalled backend can never block a turn.
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- devDependencies move from the `0.2.2-rc.1` wave to `0.2.2-rc.3`, including an explicit `@deepseek-ai/dsh-session-projection` pin so the optional peer no longer keeps a `0.2.2-rc.1` copy (and its zod 4.4.3) in the lockfile. The production `zod` pin moves 4.4.3 → 4.6.6 to match `dsh-storage-domain@0.2.2-rc.3`; peer ranges and `engines.dsh` already cover `>=0.2.2-0 <0.3.0`.
|
|
12
|
+
|
|
13
|
+
## [0.3.0] - 2026-11-13
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- **`cwdMap`: restore-time cwd projection so cross-OS sessions appear in the host workspace list (#28).** A session synced from another platform carries a `header.cwd` that is not natively absolute on the receiving host, so `@deepseek-ai/dsh-workspace` never indexes it (`realpathNormalize` refuses it) and `session-persistence-jsonl` cannot even parse the header — the bytes arrived but the session stayed invisible. `cwdMap: [{ from, to }]` maps an origin prefix to a local path; the longest matching prefix wins and prefixes end on a path-segment boundary (Windows prefixes compare case-insensitively, so `C:\Users\me2` does not match `C:\Users\me`). Restore rewrites the first frame of the **local copy** only and lands it at `<projectKey(mapped cwd)>/<sessionId>/<file>`, creating the mapped directory; the mirror keeps the origin device's bytes and a push reattaches the original header frame, so the other device still sees byte-identical appends and no meaningless conflicts. Cross-platform cwds with no entry land **read-only** under `<sessionRoot>/--unmapped--` and `sync_status` counts them (`cwdUnmapped`).
|
|
18
|
+
- **`followSessionSymlinks` (default `false`) and symlink diagnostics (#30).** Android/proot `link2symlink` reports host-written session files as symbolic links whose bytes are still readable, so the strict "never follow symlinks" mirror silently dropped every native session. `sync_status` now reports `skippedSymlinks` / `skippedSymlinkPaths` / `followedSymlinks` and push results carry the same warning; opting in follows only links whose `realpath` stays inside `sessionRoot` — links that escape are always skipped and counted.
|
|
19
|
+
- The auto-push listener logs its registration once at mount (`auto push listener registered …`), so a host that never delivers `session/event` is diagnosable from the outside (#30).
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
- `sync_status` gains `skippedSymlinks`, `skippedSymlinkPaths`, `followedSymlinks`, `cwdMapped`, `cwdUnmapped`, `cwdProjectionSkipped`, `cwdPlaceholder`, and `followSessionSymlinks`; `sync_pull` gains `cwdMapped` / `cwdUnmapped`; `sync_push` gains `skippedSymlinks` / `skippedSymlinkPaths`. All new fields are optional and JSON-safe.
|
|
24
|
+
- `@deepseek-ai/dsh-session-persistence-jsonl` joins the devDependencies as a test gate: the projection tests create a session log with a Windows cwd, restore it, and assert the **real host backend** `stat()`/`list()` accepts the projected layout (the host validates `<root>/<projectKey(header.cwd)>/<sessionId>/<file>`, which pins our `projectKey` implementation and directory layout).
|
|
25
|
+
|
|
3
26
|
## [0.2.33] - 2026-11-13
|
|
4
27
|
|
|
5
28
|
### Fixed
|
package/LICENSE
CHANGED
|
File without changes
|
package/PRIVACY.md
CHANGED
|
File without changes
|
package/README.en.md
CHANGED
|
@@ -154,10 +154,12 @@ Most-used keys:
|
|
|
154
154
|
| `branch` | `main` | Remote branch name |
|
|
155
155
|
| `autoPushOnTurnEnd` | `false` | Push after every closed turn |
|
|
156
156
|
| `pullIntervalMinutes` | `0` | Periodic pull every N minutes (`0` = off, max `10080`) |
|
|
157
|
+
| `cwdMap` | `[]` | Restore-time cwd projection `[{from, to}]` (longest prefix wins; unmatched cross-platform cwds go read-only under `<sessionRoot>/--unmapped--`) |
|
|
158
|
+
| `followSessionSymlinks` | `false` | Follow symbolic links whose realpath stays inside `sessionRoot` (Android/proot diagnostics) |
|
|
157
159
|
| `confirmVia` | `auto` | Confirmation channel: `auto` (userQuestions first, then approval), `userQuestions`, `approval` |
|
|
158
160
|
|
|
159
161
|
<details>
|
|
160
|
-
<summary>Full configuration table (
|
|
162
|
+
<summary>Full configuration table (24 keys)</summary>
|
|
161
163
|
|
|
162
164
|
| Key | Default | Meaning |
|
|
163
165
|
|---|---|---|
|
|
@@ -173,7 +175,10 @@ Most-used keys:
|
|
|
173
175
|
| `ageIdentity` | `''` | Path to a passphrase-less age secret key for decryption; empty = cannot decrypt, degrades to plaintext |
|
|
174
176
|
| `autoPullOnStart` | `false` | Pull once when the plugin mounts (config is the grant; no re-confirm) |
|
|
175
177
|
| `autoPushOnTurnEnd` | `false` | Push after every closed turn |
|
|
178
|
+
| `durabilityTimeoutMs` | `2000` | Upper bound for waiting on the session durability barrier (`ctx.sessions.flush`) before an auto push — the host JSONL writer batches live events for up to 200 ms; on timeout it logs and pushes anyway; `0` = do not wait |
|
|
176
179
|
| `pullIntervalMinutes` | `0` | Periodic pull every N minutes (`0` = off, max `10080`) |
|
|
180
|
+
| `cwdMap` | `[]` | Restore-time cwd projection `[{from, to}]` (longest prefix wins; unmatched cross-platform cwds go read-only under `<sessionRoot>/--unmapped--`) |
|
|
181
|
+
| `followSessionSymlinks` | `false` | Follow symbolic links whose realpath stays inside `sessionRoot` (Android/proot diagnostics) |
|
|
177
182
|
| `confirmVia` | `auto` | Confirmation channel: `auto` (userQuestions first, then approval), `userQuestions`, `approval` |
|
|
178
183
|
| `graceMs` | `10000` | Grace period for git kills (ms) |
|
|
179
184
|
| `commandTimeoutMs` | `120000` | Per-command timeout (ms) |
|
|
@@ -268,6 +273,27 @@ What it does **not** protect (the boundary):
|
|
|
268
273
|
|
|
269
274
|
Baseline: with `backend: git` (the default), session bytes are stored unencrypted in **your** git remote — use a private repository.
|
|
270
275
|
|
|
276
|
+
### Cross-OS sessions and cwd projection
|
|
277
|
+
|
|
278
|
+
A Windows session synced to Linux (or the reverse) carries a `header.cwd` that is not a fully qualified path on the receiving host: `dsh-workspace` indexes sessions through `realpath(header.cwd)`, and `session-persistence-jsonl` cannot even parse a header whose cwd is not natively absolute. Map the origin prefix to a local path:
|
|
279
|
+
|
|
280
|
+
```yaml
|
|
281
|
+
cwdMap:
|
|
282
|
+
- from: 'C:\Users\me'
|
|
283
|
+
to: /home/me/win
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
- The longest matching prefix wins, and prefixes end on a path-segment boundary (`C:\Users\me2` does not match `C:\Users\me`).
|
|
287
|
+
- Restore projects only the **local copy**: its first frame carries the local cwd and lands in the host's project directory, so the session shows up in the workspace list. The mirror keeps the origin device's bytes; a push reattaches the original header frame, so the other device still sees byte-identical appends and never gets meaningless conflicts.
|
|
288
|
+
- A cross-platform cwd with no entry lands under `<sessionRoot>/--unmapped--`: **visible but read-only** (`sync_status` reports it as `cwdUnmapped`, and local edits are never pushed). Add a `cwdMap` entry and pull again to turn it into a continuable local session.
|
|
289
|
+
|
|
290
|
+
### Symbolic links (Android/proot)
|
|
291
|
+
|
|
292
|
+
The mirror **never follows symbolic links** by default (a safety boundary). Android/proot's `link2symlink` reports host-written session files as symlinks (`readdir` says link, `readlink` is empty, the bytes are readable), so the phone's own sessions never reach the mirror. Diagnostics and opt-in following:
|
|
293
|
+
|
|
294
|
+
- `sync_status` reports `skippedSymlinks` / `skippedSymlinkPaths` (count and path samples) and `followedSymlinks`; push results carry the same warning.
|
|
295
|
+
- `followSessionSymlinks: true` (default `false`) follows only links whose `realpath` stays inside `sessionRoot`; links that escape are always skipped and counted.
|
|
296
|
+
|
|
271
297
|
## Known limitations
|
|
272
298
|
|
|
273
299
|
- **Encryption is optional, and age is an external dependency.** `backend: encrypted` adds an age layer (see "Encryption & threat model" above); a missing `age` or empty `ageRecipient`/`ageIdentity` warns explicitly and degrades to plaintext, and a passphrase-protected identity cannot be used (decryption would block on a TTY prompt, so it fails closed). With `backend: git` (the default), session bytes are stored unencrypted in **your** git remote — use a private repository.
|
package/README.es.md
CHANGED
|
@@ -154,10 +154,12 @@ Claves más usadas:
|
|
|
154
154
|
| `branch` | `main` | Nombre de la rama remota |
|
|
155
155
|
| `autoPushOnTurnEnd` | `false` | Push tras cada turno cerrado |
|
|
156
156
|
| `pullIntervalMinutes` | `0` | Pull periódico cada N minutos (`0` = apagado, máximo `10080`) |
|
|
157
|
+
| `cwdMap` | `[]` | Proyección de cwd en la restauración `[{from, to}]` (gana el prefijo más largo; los cwd multiplataforma sin coincidencia quedan en solo lectura bajo `<sessionRoot>/--unmapped--`) |
|
|
158
|
+
| `followSessionSymlinks` | `false` | Sigue enlaces simbólicos cuyo realpath permanece dentro de `sessionRoot` (diagnóstico para Android/proot) |
|
|
157
159
|
| `confirmVia` | `auto` | Canal de confirmación: `auto` (primero userQuestions, luego approval), `userQuestions`, `approval` |
|
|
158
160
|
|
|
159
161
|
<details>
|
|
160
|
-
<summary>Tabla de configuración completa (
|
|
162
|
+
<summary>Tabla de configuración completa (24 claves)</summary>
|
|
161
163
|
|
|
162
164
|
| Clave | Valor por defecto | Significado |
|
|
163
165
|
|---|---|---|
|
|
@@ -173,7 +175,10 @@ Claves más usadas:
|
|
|
173
175
|
| `ageIdentity` | `''` | Ruta a una clave secreta age sin frase de contraseña para descifrar; vacío = no puede descifrar, degrada a texto plano |
|
|
174
176
|
| `autoPullOnStart` | `false` | Pull una vez al montar el plugin (la configuración es la autorización; no reconfirma) |
|
|
175
177
|
| `autoPushOnTurnEnd` | `false` | Push tras cada turno cerrado |
|
|
178
|
+
| `durabilityTimeoutMs` | `2000` | Límite de espera de la barrera de durabilidad (`ctx.sessions.flush`) antes de un push automático: el escritor JSONL del host agrupa eventos live hasta 200 ms; al expirar, registra y hace push igualmente; `0` = no esperar |
|
|
176
179
|
| `pullIntervalMinutes` | `0` | Pull periódico cada N minutos (`0` = apagado, máximo `10080`) |
|
|
180
|
+
| `cwdMap` | `[]` | Proyección de cwd en la restauración `[{from, to}]` (gana el prefijo más largo; los cwd multiplataforma sin coincidencia quedan en solo lectura bajo `<sessionRoot>/--unmapped--`) |
|
|
181
|
+
| `followSessionSymlinks` | `false` | Sigue enlaces simbólicos cuyo realpath permanece dentro de `sessionRoot` (diagnóstico para Android/proot) |
|
|
177
182
|
| `confirmVia` | `auto` | Canal de confirmación: `auto` (primero userQuestions, luego approval), `userQuestions`, `approval` |
|
|
178
183
|
| `graceMs` | `10000` | Margen de gracia para matar git (ms) |
|
|
179
184
|
| `commandTimeoutMs` | `120000` | Timeout por comando (ms) |
|
|
@@ -268,6 +273,27 @@ Qué **no** protege (la frontera):
|
|
|
268
273
|
|
|
269
274
|
Línea base: con `backend: git` (el predeterminado), los bytes de sesión se almacenan sin cifrar en **tu** remoto git — usa un repositorio privado.
|
|
270
275
|
|
|
276
|
+
### Sesiones multiplataforma y proyección de cwd
|
|
277
|
+
|
|
278
|
+
Una sesión de Windows sincronizada en Linux (o al revés) lleva un `header.cwd` que no es una ruta absoluta nativa en el host receptor: `dsh-workspace` indexa las sesiones con `realpath(header.cwd)`, y `session-persistence-jsonl` ni siquiera puede analizar un header cuyo cwd no sea absoluto nativo. Asigna el prefijo de origen a una ruta local:
|
|
279
|
+
|
|
280
|
+
```yaml
|
|
281
|
+
cwdMap:
|
|
282
|
+
- from: 'C:\Users\me'
|
|
283
|
+
to: /home/me/win
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
- Gana el prefijo más largo y los prefijos deben terminar en un límite de segmento (`C:\Users\me2` no coincide con `C:\Users\me`).
|
|
287
|
+
- La restauración solo proyecta la **copia local**: su primer frame lleva el cwd local y aterriza en el directorio de proyecto del host, así la sesión aparece en la lista de workspaces. El espejo conserva los bytes del dispositivo de origen; un push vuelve a enganchar el frame de cabecera original, de modo que el otro dispositivo sigue viendo appends idénticos byte a byte y nunca recibe conflictos sin sentido.
|
|
288
|
+
- Un cwd multiplataforma sin entrada cae en `<sessionRoot>/--unmapped--`: **visible pero de solo lectura** (`sync_status` lo informa como `cwdUnmapped` y las ediciones locales nunca se suben). Añade una entrada `cwdMap` y vuelve a hacer pull para convertirlo en una sesión local continuable.
|
|
289
|
+
|
|
290
|
+
### Enlaces simbólicos (Android/proot)
|
|
291
|
+
|
|
292
|
+
El espejo **nunca sigue enlaces simbólicos** por defecto (límite de seguridad). El `link2symlink` de Android/proot informa los archivos de sesión escritos por el host como enlaces simbólicos (`readdir` dice enlace, `readlink` está vacío, los bytes son legibles), así que las sesiones propias del teléfono nunca llegan al espejo. Diagnóstico y seguimiento opcional:
|
|
293
|
+
|
|
294
|
+
- `sync_status` informa `skippedSymlinks` / `skippedSymlinkPaths` (recuento y muestras de rutas) y `followedSymlinks`; el resultado de push lleva el mismo aviso.
|
|
295
|
+
- `followSessionSymlinks: true` (por defecto `false`) sigue solo los enlaces cuyo `realpath` permanece dentro de `sessionRoot`; los enlaces que escapan siempre se omiten y se cuentan.
|
|
296
|
+
|
|
271
297
|
## Limitaciones conocidas
|
|
272
298
|
|
|
273
299
|
- **El cifrado es opcional y age es una dependencia externa.** `backend: encrypted` añade una capa age (ver «Cifrado y modelo de amenazas» arriba); si falta `age` o `ageRecipient`/`ageIdentity` están vacíos, avisa explícitamente y cae a texto plano, y una identidad protegida con frase de contraseña no se puede usar (el descifrado bloquearía en un prompt TTY, así que falla en cerrado). Con `backend: git` (el predeterminado), los bytes de sesión se almacenan sin cifrar en **tu** remoto git — usa un repositorio privado.
|
package/README.hi.md
CHANGED
|
@@ -154,10 +154,12 @@ sync: cancelled: approval requires an open turn; /sync commands run between turn
|
|
|
154
154
|
| `branch` | `main` | रिमोट branch का नाम |
|
|
155
155
|
| `autoPushOnTurnEnd` | `false` | हर बंद टर्न के बाद push |
|
|
156
156
|
| `pullIntervalMinutes` | `0` | हर N मिनट में आवधिक pull (`0` = बंद, अधिकतम `10080`) |
|
|
157
|
+
| `cwdMap` | `[]` | पुनर्स्थापन के समय cwd प्रोजेक्शन `[{from, to}]` (सबसे लंबा प्रीफ़िक्स जीतता है; बिना मेल वाले क्रॉस-प्लेटफ़ॉर्म cwd `<sessionRoot>/--unmapped--` के नीचे केवल-पढ़ने योग्य रहते हैं) |
|
|
158
|
+
| `followSessionSymlinks` | `false` | उन सिम्बोलिक लिंक का पालन करें जिनका realpath `sessionRoot` के भीतर ही रहता है (Android/proot निदान) |
|
|
157
159
|
| `confirmVia` | `auto` | पुष्टि चैनल: `auto` (पहले userQuestions, फिर approval), `userQuestions`, `approval` |
|
|
158
160
|
|
|
159
161
|
<details>
|
|
160
|
-
<summary>पूरी कॉन्फ़िगरेशन तालिका (
|
|
162
|
+
<summary>पूरी कॉन्फ़िगरेशन तालिका (24 कुंजियाँ)</summary>
|
|
161
163
|
|
|
162
164
|
| कुंजी | डिफ़ॉल्ट | अर्थ |
|
|
163
165
|
|---|---|---|
|
|
@@ -173,7 +175,10 @@ sync: cancelled: approval requires an open turn; /sync commands run between turn
|
|
|
173
175
|
| `ageIdentity` | `''` | डिक्रिप्शन के लिए पासफ़्रेज़-रहित age गुप्त कुंजी फ़ाइल का पथ; खाली = डिक्रिप्ट नहीं कर सकता, plaintext पर अवनति |
|
|
174
176
|
| `autoPullOnStart` | `false` | प्लगइन माउंट होने पर एक बार pull (कॉन्फ़िग ही अनुमति है; दोबारा पुष्टि नहीं) |
|
|
175
177
|
| `autoPushOnTurnEnd` | `false` | हर बंद टर्न के बाद push |
|
|
178
|
+
| `durabilityTimeoutMs` | `2000` | ऑटो push से पहले सत्र की durability बाधा (`ctx.sessions.flush`) की प्रतीक्षा की सीमा — होस्ट का JSONL writer live इवेंट को 200 ms तक बैच करता है; टाइमआउट पर लॉग करके push जारी रहता है; `0` = प्रतीक्षा नहीं |
|
|
176
179
|
| `pullIntervalMinutes` | `0` | हर N मिनट में आवधिक pull (`0` = बंद, अधिकतम `10080`) |
|
|
180
|
+
| `cwdMap` | `[]` | पुनर्स्थापन के समय cwd प्रोजेक्शन `[{from, to}]` (सबसे लंबा प्रीफ़िक्स जीतता है; बिना मेल वाले क्रॉस-प्लेटफ़ॉर्म cwd `<sessionRoot>/--unmapped--` के नीचे केवल-पढ़ने योग्य रहते हैं) |
|
|
181
|
+
| `followSessionSymlinks` | `false` | उन सिम्बोलिक लिंक का पालन करें जिनका realpath `sessionRoot` के भीतर ही रहता है (Android/proot निदान) |
|
|
177
182
|
| `confirmVia` | `auto` | पुष्टि चैनल: `auto` (पहले userQuestions, फिर approval), `userQuestions`, `approval` |
|
|
178
183
|
| `graceMs` | `10000` | git को समाप्त करने की छूट अवधि (ms) |
|
|
179
184
|
| `commandTimeoutMs` | `120000` | प्रति-कमांड timeout (ms) |
|
|
@@ -268,6 +273,27 @@ sync: cancelled: approval requires an open turn; /sync commands run between turn
|
|
|
268
273
|
|
|
269
274
|
आधार रेखा: `backend: git` (डिफ़ॉल्ट) के साथ सत्र बाइट्स **आपके** git रिमोट में बिना एन्क्रिप्शन के संग्रहीत होते हैं — निजी रिपॉज़िटरी का उपयोग करें।
|
|
270
275
|
|
|
276
|
+
### क्रॉस-प्लेटफ़ॉर्म सत्र और cwd प्रोजेक्शन
|
|
277
|
+
|
|
278
|
+
Windows से Linux (या उलटा) सिंक किए गए सत्र का `header.cwd` प्राप्तकर्ता होस्ट पर मूल निरपेक्ष पथ नहीं होता: `dsh-workspace` सत्रों को `realpath(header.cwd)` से अनुक्रमित करता है, और `session-persistence-jsonl` ऐसे header को पढ़ ही नहीं सकता जिसका cwd मूल रूप से निरपेक्ष न हो। स्रोत प्रीफ़िक्स को स्थानीय पथ पर मैप करें:
|
|
279
|
+
|
|
280
|
+
```yaml
|
|
281
|
+
cwdMap:
|
|
282
|
+
- from: 'C:\Users\me'
|
|
283
|
+
to: /home/me/win
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
- सबसे लंबा मिलता प्रीफ़िक्स जीतता है, और प्रीफ़िक्स पथ-खंड सीमा पर समाप्त होना चाहिए (`C:\Users\me2` `C:\Users\me` से मेल नहीं खाता)।
|
|
287
|
+
- पुनर्स्थापन केवल **स्थानीय प्रति** को प्रोजेक्ट करता है: उसका पहला फ़्रेम स्थानीय cwd लेकर होस्ट के प्रोजेक्ट निर्देशिका में जाता है, इसलिए सत्र workspace सूची में दिखता है। मिरर स्रोत डिवाइस के बाइट्स रखता है; push मूल हेडर फ़्रेम को फिर जोड़ देता है, इसलिए दूसरा डिवाइस अभी भी बाइट-दर-बाइट समान appends देखता है और व्यर्थ conflicts नहीं पाता।
|
|
288
|
+
- बिना मेल वाला क्रॉस-प्लेटफ़ॉर्म cwd `<sessionRoot>/--unmapped--` में जाता है: **दिखता है पर केवल-पढ़ने योग्य** (`sync_status` इसे `cwdUnmapped` बताता है, और स्थानीय बदलाव कभी push नहीं होते)। `cwdMap` प्रविष्टि जोड़कर फिर pull करें तो यह जारी रखने योग्य स्थानीय सत्र बन जाता है।
|
|
289
|
+
|
|
290
|
+
### सिम्बोलिक लिंक (Android/proot)
|
|
291
|
+
|
|
292
|
+
मिरर डिफ़ॉल्ट रूप से **सिम्बोलिक लिंक का पालन कभी नहीं करता** (सुरक्षा सीमा)। Android/proot का `link2symlink` होस्ट द्वारा लिखी सत्र फ़ाइलों को सिम्बोलिक लिंक बताता है (`readdir` लिंक कहता है, `readlink` खाली है, बाइट्स पढ़े जा सकते हैं), इसलिए फ़ोन के अपने सत्र मिरर तक कभी नहीं पहुँचते। निदान और वैकल्पिक पालन:
|
|
293
|
+
|
|
294
|
+
- `sync_status` अब `skippedSymlinks` / `skippedSymlinkPaths` (गिनती और पथ नमूने) तथा `followedSymlinks` बताता है; push परिणाम में वही चेतावनी आती है।
|
|
295
|
+
- `followSessionSymlinks: true` (डिफ़ॉल्ट `false`) केवल उन लिंक का पालन करता है जिनका `realpath` `sessionRoot` के भीतर रहता है; बाहर जाने वाले लिंक हमेशा छोड़े और गिने जाते हैं।
|
|
296
|
+
|
|
271
297
|
## ज्ञात सीमाएँ
|
|
272
298
|
|
|
273
299
|
- **एन्क्रिप्शन वैकल्पिक है, और age बाहरी निर्भरता है।** `backend: encrypted` age परत जोड़ता है (ऊपर «एन्क्रिप्शन और ख़तरा मॉडल» देखें); `age` न होना या `ageRecipient`/`ageIdentity` का खाली होना स्पष्ट चेतावनी देकर plaintext पर अवनति करता है, और पासफ़्रेज़-संरक्षित identity उपयोग नहीं की जा सकती (डिक्रिप्शन TTY प्रॉम्प्ट पर अटक जाता, इसलिए बंद होकर विफल होता है)। `backend: git` (डिफ़ॉल्ट) के साथ सत्र बाइट्स **आपके** git रिमोट में बिना एन्क्रिप्शन के रहते हैं — निजी रिपॉज़िटरी का उपयोग करें।
|
package/README.md
CHANGED
|
@@ -154,10 +154,12 @@ sync: cancelled: approval requires an open turn; /sync commands run between turn
|
|
|
154
154
|
| `branch` | `main` | 远端分支名 |
|
|
155
155
|
| `autoPushOnTurnEnd` | `false` | 每个关闭轮次后推送 |
|
|
156
156
|
| `pullIntervalMinutes` | `0` | 每 N 分钟周期拉取(`0` = 关闭,最大 `10080`) |
|
|
157
|
+
| `cwdMap` | `[]` | 恢复期 cwd 投影表 `[{from, to}]`(最长前缀优先;未命中的跨平台 cwd 归一到 `<sessionRoot>/--unmapped--`,只读) |
|
|
158
|
+
| `followSessionSymlinks` | `false` | 是否跟随 realpath 仍在 `sessionRoot` 内的符号链接(Android/proot 诊断) |
|
|
157
159
|
| `confirmVia` | `auto` | 确认通道:`auto`(优先 userQuestions,其次 approval)、`userQuestions`、`approval` |
|
|
158
160
|
|
|
159
161
|
<details>
|
|
160
|
-
<summary>完整配置表(
|
|
162
|
+
<summary>完整配置表(24 个键)</summary>
|
|
161
163
|
|
|
162
164
|
| 键 | 默认值 | 含义 |
|
|
163
165
|
|---|---|---|
|
|
@@ -173,7 +175,10 @@ sync: cancelled: approval requires an open turn; /sync commands run between turn
|
|
|
173
175
|
| `ageIdentity` | `''` | 无口令 age 私钥文件路径(用于解密);空 = 无法解密、降级明文 |
|
|
174
176
|
| `autoPullOnStart` | `false` | 插件挂载时拉取一次(配置即授权,不再确认) |
|
|
175
177
|
| `autoPushOnTurnEnd` | `false` | 每个关闭轮次后推送 |
|
|
178
|
+
| `durabilityTimeoutMs` | `2000` | 自动推送前等待该会话落盘的上限:宿主 JSONL 对 live 事件有 200ms 批量写窗,这里调用公开的 `ctx.sessions.flush` 落盘屏障;超时只记日志并照常推送;`0` = 不等待 |
|
|
176
179
|
| `pullIntervalMinutes` | `0` | 每 N 分钟周期拉取(`0` = 关闭,最大 `10080`) |
|
|
180
|
+
| `cwdMap` | `[]` | 恢复期 cwd 投影表 `[{from, to}]`(最长前缀优先;未命中的跨平台 cwd 归一到 `<sessionRoot>/--unmapped--`,只读) |
|
|
181
|
+
| `followSessionSymlinks` | `false` | 是否跟随 realpath 仍在 `sessionRoot` 内的符号链接(Android/proot 诊断) |
|
|
177
182
|
| `confirmVia` | `auto` | 确认通道:`auto`(优先 userQuestions,其次 approval)、`userQuestions`、`approval` |
|
|
178
183
|
| `graceMs` | `10000` | git 终止宽限(毫秒) |
|
|
179
184
|
| `commandTimeoutMs` | `120000` | 单条命令超时(毫秒) |
|
|
@@ -268,6 +273,27 @@ sync: cancelled: approval requires an open turn; /sync commands run between turn
|
|
|
268
273
|
|
|
269
274
|
基线:`backend: git`(默认)下,会话字节以未加密形式存放在**你的** git 远端——请使用私有仓库。
|
|
270
275
|
|
|
276
|
+
### 跨平台会话与 cwd 投影
|
|
277
|
+
|
|
278
|
+
Windows ↔ Linux 会话的 `header.cwd` 在另一台机器上不是本机绝对路径:宿主 `dsh-workspace` 按 `realpath(header.cwd)` 建索引,`session-persistence-jsonl` 更是 header 解析失败就完全看不到会话。用 `cwdMap` 把源设备前缀映射到本机路径:
|
|
279
|
+
|
|
280
|
+
```yaml
|
|
281
|
+
cwdMap:
|
|
282
|
+
- from: 'C:\Users\me'
|
|
283
|
+
to: /home/me/win
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
- 最长前缀优先,前缀必须结束在路径段边界上(`C:\Users\me2` 不匹配 `C:\Users\me`)。
|
|
287
|
+
- 恢复时只投影**本地副本**:首帧 cwd 改写为本机路径、文件落到宿主布局的项目目录,因此会话出现在 workspace 列表里。同步仓库里的字节始终是源设备的 cwd;推送时把原首帧接回,对端看到的仍是逐字节 append,不会产生无意义分叉。
|
|
288
|
+
- 没有命中的跨平台 cwd 归一到 `<sessionRoot>/--unmapped--`:会话**可见但只读**,`sync_status` 的 `cwdUnmapped` 会计数,本地改动不会推送。给它补一条 `cwdMap` 后重新 pull 即可变成可继续的本地会话。
|
|
289
|
+
|
|
290
|
+
### 符号链接(Android/proot)
|
|
291
|
+
|
|
292
|
+
默认**绝不跟随符号链接**(安全边界)。Android/proot 的 `link2symlink` 会把宿主写入的会话文件报成符号链接(`readdir` 说是链接、`readlink` 为空、内容可读),导致手机自己的会话永远不进镜像。诊断与可选跟随:
|
|
293
|
+
|
|
294
|
+
- `sync_status` 新增 `skippedSymlinks` / `skippedSymlinkPaths`(数量与路径样本)、`followedSymlinks`,push 结果也会带同类 warning;
|
|
295
|
+
- `followSessionSymlinks: true`(默认 `false`)只跟随 `realpath` 仍落在 `sessionRoot` 内的链接,越界链接一律跳过并计数。
|
|
296
|
+
|
|
271
297
|
## 已知限制
|
|
272
298
|
|
|
273
299
|
- **加密可选、age 为外部依赖。** `backend: encrypted` 增加一层 age 加密(见上文「加密与威胁模型」);`age` 缺失或 `ageRecipient`/`ageIdentity` 为空时显式告警并降级明文,口令保护的 identity 不可用(解密会阻塞在 TTY 提示上,因此失败关闭)。`backend: git`(默认)下,会话字节以未加密形式存放在**你的** git 远端——请使用私有仓库。
|
package/README.pt.md
CHANGED
|
@@ -154,10 +154,12 @@ Chaves mais usadas:
|
|
|
154
154
|
| `branch` | `main` | Nome do branch remoto |
|
|
155
155
|
| `autoPushOnTurnEnd` | `false` | Push após cada turno fechado |
|
|
156
156
|
| `pullIntervalMinutes` | `0` | Pull periódico a cada N minutos (`0` = desligado, máximo `10080`) |
|
|
157
|
+
| `cwdMap` | `[]` | Projeção de cwd na restauração `[{from, to}]` (o prefixo mais longo vence; cwds multiplataforma sem entrada ficam somente leitura em `<sessionRoot>/--unmapped--`) |
|
|
158
|
+
| `followSessionSymlinks` | `false` | Segue links simbólicos cujo realpath permanece dentro de `sessionRoot` (diagnóstico Android/proot) |
|
|
157
159
|
| `confirmVia` | `auto` | Canal de confirmação: `auto` (userQuestions primeiro, depois approval), `userQuestions`, `approval` |
|
|
158
160
|
|
|
159
161
|
<details>
|
|
160
|
-
<summary>Tabela de configuração completa (
|
|
162
|
+
<summary>Tabela de configuração completa (24 chaves)</summary>
|
|
161
163
|
|
|
162
164
|
| Chave | Padrão | Significado |
|
|
163
165
|
|---|---|---|
|
|
@@ -173,7 +175,10 @@ Chaves mais usadas:
|
|
|
173
175
|
| `ageIdentity` | `''` | Caminho de uma chave secreta age sem frase de senha para descriptografar; vazio = não consegue descriptografar, degrada para texto plano |
|
|
174
176
|
| `autoPullOnStart` | `false` | Pull uma vez ao montar o plugin (a configuração é a autorização; sem reconfirmação) |
|
|
175
177
|
| `autoPushOnTurnEnd` | `false` | Push após cada turno fechado |
|
|
178
|
+
| `durabilityTimeoutMs` | `2000` | Limite de espera pela barreira de durabilidade (`ctx.sessions.flush`) antes de um push automático — o writer JSONL do host agrupa eventos live por até 200 ms; no timeout, registra e faz push mesmo assim; `0` = não aguardar |
|
|
176
179
|
| `pullIntervalMinutes` | `0` | Pull periódico a cada N minutos (`0` = desligado, máximo `10080`) |
|
|
180
|
+
| `cwdMap` | `[]` | Projeção de cwd na restauração `[{from, to}]` (o prefixo mais longo vence; cwds multiplataforma sem entrada ficam somente leitura em `<sessionRoot>/--unmapped--`) |
|
|
181
|
+
| `followSessionSymlinks` | `false` | Segue links simbólicos cujo realpath permanece dentro de `sessionRoot` (diagnóstico Android/proot) |
|
|
177
182
|
| `confirmVia` | `auto` | Canal de confirmação: `auto` (userQuestions primeiro, depois approval), `userQuestions`, `approval` |
|
|
178
183
|
| `graceMs` | `10000` | Período de carência para matar o git (ms) |
|
|
179
184
|
| `commandTimeoutMs` | `120000` | Timeout por comando (ms) |
|
|
@@ -268,6 +273,27 @@ O que ela **não** protege (a fronteira):
|
|
|
268
273
|
|
|
269
274
|
Linha de base: com `backend: git` (o padrão), os bytes de sessão são armazenados sem criptografia no **seu** remoto git — use um repositório privado.
|
|
270
275
|
|
|
276
|
+
### Sessões multiplataforma e projeção de cwd
|
|
277
|
+
|
|
278
|
+
Uma sessão do Windows sincronizada no Linux (ou o contrário) carrega um `header.cwd` que não é um caminho absoluto nativo no host receptor: o `dsh-workspace` indexa sessões via `realpath(header.cwd)`, e o `session-persistence-jsonl` nem consegue analisar um header cujo cwd não seja absoluto nativo. Mapeie o prefixo de origem para um caminho local:
|
|
279
|
+
|
|
280
|
+
```yaml
|
|
281
|
+
cwdMap:
|
|
282
|
+
- from: 'C:\Users\me'
|
|
283
|
+
to: /home/me/win
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
- O prefixo mais longo vence, e os prefixos terminam num limite de segmento (`C:\Users\me2` não corresponde a `C:\Users\me`).
|
|
287
|
+
- A restauração projeta apenas a **cópia local**: o primeiro frame leva o cwd local e cai no diretório de projeto do host, então a sessão aparece na lista de workspaces. O espelho mantém os bytes do dispositivo de origem; um push reanexa o frame de cabeçalho original, então o outro dispositivo continua vendo appends idênticos byte a byte e nunca recebe conflitos sem sentido.
|
|
288
|
+
- Um cwd multiplataforma sem entrada vai para `<sessionRoot>/--unmapped--`: **visível mas somente leitura** (`sync_status` o informa como `cwdUnmapped`, e edições locais nunca são enviadas). Adicione uma entrada `cwdMap` e faça pull de novo para torná-lo uma sessão local continuável.
|
|
289
|
+
|
|
290
|
+
### Links simbólicos (Android/proot)
|
|
291
|
+
|
|
292
|
+
O espelho **nunca segue links simbólicos** por padrão (limite de segurança). O `link2symlink` do Android/proot informa os arquivos de sessão escritos pelo host como links simbólicos (`readdir` diz link, `readlink` está vazio, os bytes são legíveis), então as sessões do próprio telefone nunca chegam ao espelho. Diagnóstico e seguimento opcional:
|
|
293
|
+
|
|
294
|
+
- `sync_status` informa `skippedSymlinks` / `skippedSymlinkPaths` (contagem e amostras de caminhos) e `followedSymlinks`; o resultado do push leva o mesmo aviso.
|
|
295
|
+
- `followSessionSymlinks: true` (padrão `false`) segue apenas links cujo `realpath` permanece dentro de `sessionRoot`; links que escapam são sempre ignorados e contados.
|
|
296
|
+
|
|
271
297
|
## Limitações conhecidas
|
|
272
298
|
|
|
273
299
|
- **A criptografia é opcional e o age é uma dependência externa.** `backend: encrypted` adiciona uma camada age (ver «Criptografia e modelo de ameaças» acima); se o `age` faltar ou `ageRecipient`/`ageIdentity` estiverem vazios, avisa explicitamente e cai para texto plano, e uma identidade protegida por frase de senha não pode ser usada (a descriptografia bloquearia num prompt TTY, então falha fechada). Com `backend: git` (o padrão), os bytes de sessão são armazenados sem criptografia no **seu** remoto git — use um repositório privado.
|
package/SECURITY.md
CHANGED
|
File without changes
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
File without changes
|
package/cordis.patch.yml
CHANGED
|
@@ -35,11 +35,28 @@
|
|
|
35
35
|
# covered by the config grant and never re-confirm.
|
|
36
36
|
autoPullOnStart: false
|
|
37
37
|
autoPushOnTurnEnd: false
|
|
38
|
+
# Upper bound (ms) for waiting on the host's session durability barrier
|
|
39
|
+
# (ctx.sessions.flush) before an auto push. The JSONL writer batches live
|
|
40
|
+
# events for up to 200 ms, so a push issued exactly at turn/end can miss
|
|
41
|
+
# the final event; on timeout the plugin logs and pushes the current
|
|
42
|
+
# on-disk snapshot anyway. 0 = do not wait.
|
|
43
|
+
durabilityTimeoutMs: 2000
|
|
38
44
|
pullIntervalMinutes: 0
|
|
39
45
|
# Confirmation channel for /sync pull|push and the sync_* tools:
|
|
40
46
|
# auto (userQuestions first, then approval) · userQuestions · approval.
|
|
41
47
|
# Read-only surfaces (status/diff/log) never ask.
|
|
42
48
|
confirmVia: auto
|
|
49
|
+
# Restore-time cwd projection (cross-OS sessions). Each entry maps an
|
|
50
|
+
# origin-device prefix to a local path; longest matching prefix wins and
|
|
51
|
+
# prefixes end on a path-segment boundary (C:\Users\me2 does not match
|
|
52
|
+
# C:\Users\me). The mirror keeps the origin device's bytes; only the
|
|
53
|
+
# restored local copy carries the local cwd. Cross-platform cwds with no
|
|
54
|
+
# entry are shown read-only under <sessionRoot>/--unmapped--.
|
|
55
|
+
cwdMap: []
|
|
56
|
+
# Mirror symbolic links whose realpath stays inside sessionRoot
|
|
57
|
+
# (Android/proot link2symlink hosts). Default false keeps "never follow
|
|
58
|
+
# symlinks"; skipped links are counted and listed in sync_status.
|
|
59
|
+
followSessionSymlinks: false
|
|
43
60
|
# Subprocess tuning: grace period for git kills, per-command timeout,
|
|
44
61
|
# and the per-stream collected-output cap.
|
|
45
62
|
graceMs: 10000
|
package/icon.svg
CHANGED
|
File without changes
|
package/index.mjs
CHANGED
|
@@ -57,6 +57,20 @@ import { collectStatus } from './lib/status.mjs'
|
|
|
57
57
|
import { renderDiff, renderPull, renderPush, renderStatus, errorValue } from './lib/render.mjs'
|
|
58
58
|
import { confirmSync, hasOpenTurn, makeEventGate, maybeAppendSessionEvent, openTurnFromProjection } from './lib/gate.mjs'
|
|
59
59
|
import { sessionSyncDomainSpec } from './lib/domain.mjs'
|
|
60
|
+
import { waitForSessionDurability } from './lib/durability.mjs'
|
|
61
|
+
import {
|
|
62
|
+
matchCwdMap,
|
|
63
|
+
normalizeCwdMap,
|
|
64
|
+
projectCwd,
|
|
65
|
+
projectKey,
|
|
66
|
+
projectedRelOf,
|
|
67
|
+
} from './lib/cwdmap.mjs'
|
|
68
|
+
import {
|
|
69
|
+
canonicalizeProjectedFile,
|
|
70
|
+
planRestoreFile,
|
|
71
|
+
readProjectionState,
|
|
72
|
+
} from './lib/projection.mjs'
|
|
73
|
+
import { readSessionHeader } from './lib/sessionlog.mjs'
|
|
60
74
|
|
|
61
75
|
export const name = PLUGIN_NAME
|
|
62
76
|
|
|
@@ -105,8 +119,11 @@ export function probeIgnorableAppend() {
|
|
|
105
119
|
* @property {string} [ageIdentity] age 身份文件路径(无口令私钥;空 = 无法解密,降级明文)。
|
|
106
120
|
* @property {boolean} [autoPullOnStart] 挂载时自动拉取一次(配置即授权,不再确认)。
|
|
107
121
|
* @property {boolean} [autoPushOnTurnEnd] 每个 turn/end 后自动推送(配置即授权)。
|
|
122
|
+
* @property {number} [durabilityTimeoutMs] 自动推送前等该会话落盘的上限 ms(宿主 JSONL 有 200ms 批量写窗;0 = 不等待,超时只记日志并继续)。
|
|
108
123
|
* @property {number} [pullIntervalMinutes] 周期自动拉取间隔分钟(0 = 关闭)。
|
|
109
124
|
* @property {'auto'|'userQuestions'|'approval'} [confirmVia] 确认通道(auto 优先 userQuestions)。
|
|
125
|
+
* @property {ReadonlyArray<{from: string, to: string}>} [cwdMap] 恢复期 cwd 投影表(最长前缀优先;未命中的跨平台 cwd 归一到 sessionRoot/--unmapped--)。
|
|
126
|
+
* @property {boolean} [followSessionSymlinks] 镜像时是否跟随 realpath 仍在 sessionRoot 内的符号链接(默认 false)。
|
|
110
127
|
* @property {number} [graceMs] git 子进程终止宽限(ms)。
|
|
111
128
|
* @property {number} [commandTimeoutMs] 单条 git 命令超时(ms)。
|
|
112
129
|
* @property {number} [maxOutputBytes] git 输出单流收集上限(字节)。
|
|
@@ -130,8 +147,14 @@ export const Config = Schema.object({
|
|
|
130
147
|
ageIdentity: Schema.string().default(DEFAULTS.AGE_IDENTITY),
|
|
131
148
|
autoPullOnStart: Schema.boolean().default(DEFAULTS.AUTO_PULL_ON_START),
|
|
132
149
|
autoPushOnTurnEnd: Schema.boolean().default(DEFAULTS.AUTO_PUSH_ON_TURN_END),
|
|
150
|
+
durabilityTimeoutMs: Schema.number().default(DEFAULTS.DURABILITY_TIMEOUT_MS),
|
|
133
151
|
pullIntervalMinutes: Schema.number().default(DEFAULTS.PULL_INTERVAL_MINUTES),
|
|
134
152
|
confirmVia: Schema.union(Object.values(CONFIRM_CHANNELS)).default(DEFAULTS.CONFIRM_VIA),
|
|
153
|
+
cwdMap: Schema.array(Schema.object({
|
|
154
|
+
from: Schema.string().required(),
|
|
155
|
+
to: Schema.string().required(),
|
|
156
|
+
})).default([...DEFAULTS.CWD_MAP]),
|
|
157
|
+
followSessionSymlinks: Schema.boolean().default(DEFAULTS.FOLLOW_SESSION_SYMLINKS),
|
|
135
158
|
graceMs: Schema.number().default(DEFAULTS.GRACE_MS),
|
|
136
159
|
commandTimeoutMs: Schema.number().default(DEFAULTS.COMMAND_TIMEOUT_MS),
|
|
137
160
|
maxOutputBytes: Schema.number().default(DEFAULTS.MAX_OUTPUT_BYTES),
|
|
@@ -160,8 +183,11 @@ export function resolveConfig(config = {}) {
|
|
|
160
183
|
ageIdentity: config.ageIdentity ?? DEFAULTS.AGE_IDENTITY,
|
|
161
184
|
autoPullOnStart: config.autoPullOnStart ?? DEFAULTS.AUTO_PULL_ON_START,
|
|
162
185
|
autoPushOnTurnEnd: config.autoPushOnTurnEnd ?? DEFAULTS.AUTO_PUSH_ON_TURN_END,
|
|
186
|
+
durabilityTimeoutMs: config.durabilityTimeoutMs ?? DEFAULTS.DURABILITY_TIMEOUT_MS,
|
|
163
187
|
pullIntervalMinutes: config.pullIntervalMinutes ?? DEFAULTS.PULL_INTERVAL_MINUTES,
|
|
164
188
|
confirmVia: config.confirmVia ?? DEFAULTS.CONFIRM_VIA,
|
|
189
|
+
cwdMap: normalizeCwdMap(config.cwdMap ?? DEFAULTS.CWD_MAP),
|
|
190
|
+
followSessionSymlinks: config.followSessionSymlinks ?? DEFAULTS.FOLLOW_SESSION_SYMLINKS,
|
|
165
191
|
graceMs: config.graceMs ?? DEFAULTS.GRACE_MS,
|
|
166
192
|
commandTimeoutMs: config.commandTimeoutMs ?? DEFAULTS.COMMAND_TIMEOUT_MS,
|
|
167
193
|
maxOutputBytes: config.maxOutputBytes ?? DEFAULTS.MAX_OUTPUT_BYTES,
|
|
@@ -204,6 +230,12 @@ export function resolveConfig(config = {}) {
|
|
|
204
230
|
if (!Number.isInteger(resolved.pullIntervalMinutes) || resolved.pullIntervalMinutes < LIMITS.MIN_PULL_INTERVAL_MINUTES || resolved.pullIntervalMinutes > LIMITS.MAX_PULL_INTERVAL_MINUTES) {
|
|
205
231
|
throw badConfig(`pullIntervalMinutes must be an integer in [${LIMITS.MIN_PULL_INTERVAL_MINUTES}, ${LIMITS.MAX_PULL_INTERVAL_MINUTES}]`)
|
|
206
232
|
}
|
|
233
|
+
if (!Number.isInteger(resolved.durabilityTimeoutMs) || resolved.durabilityTimeoutMs < LIMITS.MIN_DURABILITY_TIMEOUT_MS || resolved.durabilityTimeoutMs > LIMITS.MAX_DURABILITY_TIMEOUT_MS) {
|
|
234
|
+
throw badConfig(`durabilityTimeoutMs must be an integer in [${LIMITS.MIN_DURABILITY_TIMEOUT_MS}, ${LIMITS.MAX_DURABILITY_TIMEOUT_MS}]`)
|
|
235
|
+
}
|
|
236
|
+
if (typeof resolved.followSessionSymlinks !== 'boolean') {
|
|
237
|
+
throw badConfig('followSessionSymlinks must be a boolean')
|
|
238
|
+
}
|
|
207
239
|
if (typeof resolved.commitName !== 'string' || resolved.commitName.trim().length === 0) {
|
|
208
240
|
throw badConfig('commitName must be a non-empty string')
|
|
209
241
|
}
|
|
@@ -348,9 +380,9 @@ const TOOL_TEXT = {
|
|
|
348
380
|
}
|
|
349
381
|
|
|
350
382
|
/** sync_status 工具规范结果(与工具 schema 同构)。 */
|
|
351
|
-
/** @typedef {{ok: boolean, branch: string, remote: string, head?: string, remoteHead?: string, ahead: number, behind: number, dirty: string[], forks: string[], diffStat: string, mergeInProgress: boolean, lastCommits: string[], lastPullAt?: number, lastPushAt?: number, lastError?: string, error?: string, warnings?: string[]}} StatusValue */
|
|
352
|
-
/** @typedef {{ok: boolean, pulled?: boolean, merged?: boolean, adopted?: number, appended?: number, diverged?: number, forks?: string[], head?: string, error?: string, warnings?: string[]}} PullValue */
|
|
353
|
-
/** @typedef {{ok: boolean, pushed?: boolean, head?: string, mirrored?: number, deleted?: number, remote?: string, error?: string, warnings?: string[]}} PushValue */
|
|
383
|
+
/** @typedef {{ok: boolean, branch: string, remote: string, head?: string, remoteHead?: string, ahead: number, behind: number, dirty: string[], forks: string[], diffStat: string, mergeInProgress: boolean, lastCommits: string[], lastPullAt?: number, lastPushAt?: number, lastError?: string, error?: string, skippedSymlinks?: number, skippedSymlinkPaths?: string[], followedSymlinks?: number, cwdMapped?: number, cwdUnmapped?: number, cwdProjectionSkipped?: number, cwdPlaceholder?: string, followSessionSymlinks?: boolean, warnings?: string[]}} StatusValue */
|
|
384
|
+
/** @typedef {{ok: boolean, pulled?: boolean, merged?: boolean, adopted?: number, appended?: number, diverged?: number, forks?: string[], head?: string, restored?: number, cwdMapped?: number, cwdUnmapped?: number, error?: string, warnings?: string[]}} PullValue */
|
|
385
|
+
/** @typedef {{ok: boolean, pushed?: boolean, head?: string, mirrored?: number, deleted?: number, remote?: string, skippedSymlinks?: number, skippedSymlinkPaths?: string[], error?: string, warnings?: string[]}} PushValue */
|
|
354
386
|
|
|
355
387
|
/**
|
|
356
388
|
* sync_status 工具定义(read-only:不确认、不触网)。
|
|
@@ -384,6 +416,14 @@ export function makeSyncStatusTool(engine, readMeta) {
|
|
|
384
416
|
lastPushAt: { type: 'integer' },
|
|
385
417
|
lastError: { type: 'string' },
|
|
386
418
|
error: { type: 'string' },
|
|
419
|
+
skippedSymlinks: { type: 'integer' },
|
|
420
|
+
skippedSymlinkPaths: { type: 'array', items: { type: 'string' } },
|
|
421
|
+
followedSymlinks: { type: 'integer' },
|
|
422
|
+
cwdMapped: { type: 'integer' },
|
|
423
|
+
cwdUnmapped: { type: 'integer' },
|
|
424
|
+
cwdProjectionSkipped: { type: 'integer' },
|
|
425
|
+
cwdPlaceholder: { type: 'string' },
|
|
426
|
+
followSessionSymlinks: { type: 'boolean' },
|
|
387
427
|
warnings: { type: 'array', items: { type: 'string' } },
|
|
388
428
|
},
|
|
389
429
|
},
|
|
@@ -437,6 +477,9 @@ export function makeSyncPullTool(deps) {
|
|
|
437
477
|
diverged: { type: 'integer' },
|
|
438
478
|
forks: { type: 'array', items: { type: 'string' } },
|
|
439
479
|
head: { type: 'string' },
|
|
480
|
+
restored: { type: 'integer' },
|
|
481
|
+
cwdMapped: { type: 'integer' },
|
|
482
|
+
cwdUnmapped: { type: 'integer' },
|
|
440
483
|
error: { type: 'string' },
|
|
441
484
|
warnings: { type: 'array', items: { type: 'string' } },
|
|
442
485
|
},
|
|
@@ -496,6 +539,8 @@ export function makeSyncPushTool(deps) {
|
|
|
496
539
|
mirrored: { type: 'integer' },
|
|
497
540
|
deleted: { type: 'integer' },
|
|
498
541
|
remote: { type: 'string' },
|
|
542
|
+
skippedSymlinks: { type: 'integer' },
|
|
543
|
+
skippedSymlinkPaths: { type: 'array', items: { type: 'string' } },
|
|
499
544
|
error: { type: 'string' },
|
|
500
545
|
warnings: { type: 'array', items: { type: 'string' } },
|
|
501
546
|
},
|
|
@@ -670,6 +715,8 @@ export function apply(ctx, config = {}) {
|
|
|
670
715
|
remote: resolved.remote,
|
|
671
716
|
branch: resolved.branch,
|
|
672
717
|
deviceId: 'pending',
|
|
718
|
+
cwdMap: resolved.cwdMap,
|
|
719
|
+
followSessionSymlinks: resolved.followSessionSymlinks,
|
|
673
720
|
reportMeta,
|
|
674
721
|
reportError,
|
|
675
722
|
logger,
|
|
@@ -863,22 +910,45 @@ export function apply(ctx, config = {}) {
|
|
|
863
910
|
}, `${PLUGIN_NAME}.auto-pull-on-start`)
|
|
864
911
|
}
|
|
865
912
|
|
|
866
|
-
// turn/end
|
|
913
|
+
// turn/end 自动推送(配置即授权;每轮结束先等该会话落盘,再拉快照推送)。
|
|
867
914
|
if (resolved.autoPushOnTurnEnd) {
|
|
915
|
+
// #30:有些宿主(Android/proot 的 DSH Go)不发 session/event;把"监听器已
|
|
916
|
+
// 注册"记进日志,让外部可判断的是宿主事件还是插件注册。
|
|
917
|
+
logger.info(`auto push listener registered (session/event turn/end → push); pullIntervalMinutes=${resolved.pullIntervalMinutes}; durabilityTimeoutMs=${resolved.durabilityTimeoutMs}`)
|
|
918
|
+
let durabilityUnsupportedWarned = false
|
|
919
|
+
const autoPush = async (session) => {
|
|
920
|
+
// 宿主的 JSONL 持久化对 live 事件有 200ms 批量写窗(见 lib/durability.mjs):
|
|
921
|
+
// 不等这层落盘屏障,镜像就会缺最后一条 turn/end —— 跨设备恢复会看到未闭合
|
|
922
|
+
// 轮次。等待有上限且绝不抛出:超时/失败只记日志,照常推送当前盘上快照。
|
|
923
|
+
const durability = await waitForSessionDurability(session, {
|
|
924
|
+
sessions: ctx.sessions,
|
|
925
|
+
timeoutMs: resolved.durabilityTimeoutMs,
|
|
926
|
+
})
|
|
927
|
+
if (durability.timedOut === true) {
|
|
928
|
+
warn(`auto push: session ${session.id} was not durable within ${resolved.durabilityTimeoutMs}ms; mirroring the current on-disk snapshot`)
|
|
929
|
+
} else if (durability.unsupported === true) {
|
|
930
|
+
if (!durabilityUnsupportedWarned) {
|
|
931
|
+
durabilityUnsupportedWarned = true
|
|
932
|
+
warn('auto push: this host exposes no sessions.flush(); mirroring without a durability wait (host older than 0.2.2)')
|
|
933
|
+
}
|
|
934
|
+
} else if (durability.error !== undefined) {
|
|
935
|
+
warn(`auto push: durability wait failed for session ${session.id}: ${durability.error}; mirroring the current on-disk snapshot`)
|
|
936
|
+
}
|
|
937
|
+
const result = await engine.push()
|
|
938
|
+
maybeAppendSessionEvent(session, SESSION_EVENTS.PUSH, {
|
|
939
|
+
sessionId: session.id,
|
|
940
|
+
ok: result.ok,
|
|
941
|
+
error: result.error,
|
|
942
|
+
pushed: result.pushed,
|
|
943
|
+
mirrored: result.mirrored,
|
|
944
|
+
deleted: result.deleted,
|
|
945
|
+
head: result.head,
|
|
946
|
+
}, eventGate, warn)
|
|
947
|
+
if (!result.ok) warn(`auto push failed: ${result.error ?? 'unknown error'}`)
|
|
948
|
+
}
|
|
868
949
|
ctx.on('session/event', (session, event) => {
|
|
869
950
|
if (event.type !== 'turn/end') return
|
|
870
|
-
void
|
|
871
|
-
maybeAppendSessionEvent(session, SESSION_EVENTS.PUSH, {
|
|
872
|
-
sessionId: session.id,
|
|
873
|
-
ok: result.ok,
|
|
874
|
-
error: result.error,
|
|
875
|
-
pushed: result.pushed,
|
|
876
|
-
mirrored: result.mirrored,
|
|
877
|
-
deleted: result.deleted,
|
|
878
|
-
head: result.head,
|
|
879
|
-
}, eventGate, warn)
|
|
880
|
-
if (!result.ok) warn(`auto push failed: ${result.error ?? 'unknown error'}`)
|
|
881
|
-
})
|
|
951
|
+
void autoPush(session).catch(error => warn(`auto push failed: ${messageOf(error)}`))
|
|
882
952
|
})
|
|
883
953
|
}
|
|
884
954
|
|
|
@@ -923,4 +993,14 @@ export {
|
|
|
923
993
|
sessionSyncDomainSpec,
|
|
924
994
|
registryUnavailable,
|
|
925
995
|
errorValue,
|
|
996
|
+
// 跨平台 cwd 投影(#28)与符号链接诊断(#30)的复用/测试面。
|
|
997
|
+
normalizeCwdMap,
|
|
998
|
+
matchCwdMap,
|
|
999
|
+
projectCwd,
|
|
1000
|
+
projectKey,
|
|
1001
|
+
projectedRelOf,
|
|
1002
|
+
planRestoreFile,
|
|
1003
|
+
canonicalizeProjectedFile,
|
|
1004
|
+
readProjectionState,
|
|
1005
|
+
readSessionHeader,
|
|
926
1006
|
}
|
package/lib/age.mjs
CHANGED
|
File without changes
|
package/lib/backend.mjs
CHANGED
|
File without changes
|