pi-jarvis 1.7.0 → 1.9.1
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/AGENTS.md +17 -1
- package/README.md +132 -3
- package/dist/archive-config.d.ts +15 -0
- package/dist/archive-config.d.ts.map +1 -0
- package/dist/archive-config.js +337 -0
- package/dist/archive-config.js.map +1 -0
- package/dist/archive-extension.d.ts +38 -0
- package/dist/archive-extension.d.ts.map +1 -0
- package/dist/archive-extension.js +334 -0
- package/dist/archive-extension.js.map +1 -0
- package/dist/archive-import.d.ts +74 -0
- package/dist/archive-import.d.ts.map +1 -0
- package/dist/archive-import.js +327 -0
- package/dist/archive-import.js.map +1 -0
- package/dist/archive-service.d.ts +69 -0
- package/dist/archive-service.d.ts.map +1 -0
- package/dist/archive-service.js +582 -0
- package/dist/archive-service.js.map +1 -0
- package/dist/archive-store.d.ts +53 -0
- package/dist/archive-store.d.ts.map +1 -0
- package/dist/archive-store.js +815 -0
- package/dist/archive-store.js.map +1 -0
- package/dist/archive-types.d.ts +57 -0
- package/dist/archive-types.d.ts.map +1 -0
- package/dist/archive-types.js +2 -0
- package/dist/archive-types.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +64 -0
- package/dist/index.js.map +1 -1
- package/dist/side-session.d.ts +6 -0
- package/dist/side-session.d.ts.map +1 -1
- package/dist/side-session.js +33 -3
- package/dist/side-session.js.map +1 -1
- package/package.json +7 -4
package/AGENTS.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Project Scope
|
|
4
4
|
- `pi-jarvis` is a Pi extension that opens a `/jarvis` side-conversation overlay.
|
|
5
|
-
- Core runtime files: `index.ts`, `side-session.ts`, `native-mcp.ts`, `overlay.ts`, `overlay-layout.ts`, `draft-editor.ts`, `transcript-viewport.ts`, `jarvis-branding.ts`, `model-picker.ts`, `jarvis-config.ts`, `session-ref.ts`,
|
|
5
|
+
- Core runtime files: `index.ts`, `side-session.ts`, `native-mcp.ts`, `overlay.ts`, `overlay-layout.ts`, `draft-editor.ts`, `transcript-viewport.ts`, `jarvis-branding.ts`, `model-picker.ts`, `jarvis-config.ts`, `session-ref.ts`, `memory-{types,config,content,store,service,extension}.ts`, and `archive-{types,config,store,service,extension,import}.ts`.
|
|
6
6
|
- Current baseline: Pi 1.0.0 (`@earendil-works` packages), Node.js >=22.19.0. Older Pi hosts are not supported.
|
|
7
7
|
|
|
8
8
|
## Current `/jarvis-model` and `/jarvis-thinking` Behavior
|
|
@@ -60,6 +60,22 @@
|
|
|
60
60
|
- Memory guidance is also request-local: use a custom advisory so Pi's later forced-prompt projection cannot discard it. Preserve other prompt/tool state; a mid-turn disable removes both advisory and recalled records from future requests.
|
|
61
61
|
- Model tools recheck live trust/settings/cancellation and permission generations at execution, including captured definitions. Broadcast observed policy changes across mounted lanes and revoke per-binding generations at session/tree boundaries; don't promise live push delivery across processes. Model forget requires cancellable human review and transactionally compares the reviewed version. Tombstones prevent identical event/title resurrection, not every semantic mention; Pi transcripts, backups and already-sent context remain. Do not promise encryption, a sandbox, or forensic erasure.
|
|
62
62
|
|
|
63
|
+
## Optional full-session archive (1.8.0)
|
|
64
|
+
- `archive-{types,config,store,service,extension}.ts` implement an independent OFF-by-default archive, explicitly mounted in main and Jarvis. Defaults enabled=false/capture=true/modelAccess=false; per-field project > global > defaults except explicit global enabled=false is master-off. Untrusted/config errors pause everything. Never enable/import real user data in tests.
|
|
65
|
+
- Separate settings: `<agentDir>/extensions/pi-jarvis-archive.json` and `.pi/jarvis-archive.json`, top-level `archive`. Controls default global. Settings writers may retry only a raced inode/unlink preflight read once under the existing cooperative lock; policy readers and locked-read races remain fail-closed, with no uncertain write replay. on/model-access on/clear require `--confirm-sensitive`; clear removes settings, not data, and fallback can re-enable. Archive tools are read-only and need modelAccess; humans can inspect with only capture/modelAccess off, but not full off.
|
|
66
|
+
- `/jarvis-archive` and overlay `/archive` commands are local, immediate, no provider/boot/queue work. Search/read/session default current-project; all-project access is explicit. Model tools cannot change controls, import, or delete. No auto context injection.
|
|
67
|
+
- Archive accepted finalized journal entries unredacted, including exposed thinking/tool/system/custom/error/inline-image data. Never capture intermediate message_end/tool_result/raw-provider payloads before later redactors. Baseline existing entry IDs on activation, never auto-backfill; parent/header provenance retained. Snapshots are not crash-safe audit logging and cannot recover unpersisted events, earlier truncation or external referenced files. Warn on storage/observation failures, not silent replay.
|
|
68
|
+
- Lazy private SQLite FTS5 at `<agentDir>/extensions/pi-jarvis-archive/archive.sqlite`, no automatic retention eviction. 64 MiB raw-entry/index budgets and 64K UTF-16 normalization-context hard rejection, no truncation of accepted raw JSON or silent partial indexing. Identical serialized payloads deduplicate across lanes; conflicting payloads for one identity fail without replacement. Search/read output max 24,000 JSON bytes plus notice; raw read offsets count Unicode codepoints and preserve pagination through output shrinking. Oversized display provenance is explicitly abbreviated; read(part=metadata) / read --metadata pages exact original metadata so every accepted entry stays accessible. Images/signatures are raw-retained, not text-indexed. Never load full payloads for search or scan all raw bodies on open. Inspection uses read-only schema snapshots and bounded observation of a version-zero, truly empty database while a concurrent creator initializes it; release each empty snapshot before waiting. Never let readers initialize/reset storage or retry record writes; unknown nonempty schemas reject.
|
|
69
|
+
- Explicit human single-file import streams one selected regular v3 JSONL file, honors its header's project/session provenance, checks live capture/epoch/cancellation at chunk/record boundaries, reports partial commits, never mutates source. No automatic directory scans or legacy auto-migration. Scoped forget-session/prune require --confirm; tombstones stop identical entry resurrection, not all copies. No encryption, sandbox, forensic erase, or hard total-disk-quota claims.
|
|
70
|
+
- Keep live trust/settings and per-binding stale-definition guards independent of Repo tools. Reader permission changes must not discard pending recording. Main owner closes storage after final archive snapshot; the side owner snapshots finalized entries before revoking its lifetime/context, without closing the shared service. Preserve archive finalization before main boot-generation invalidation. Settings observations propagate between mounted lanes, not by a cross-process watcher.
|
|
71
|
+
|
|
72
|
+
## Bulk archive import (1.9.0)
|
|
73
|
+
- `archive-import.ts` owns bounded discovery and the shared streaming reader. `/jarvis-archive import-all [absolute-directory]` is an explicit metadata-only recursive preview, defaulting to `<agentDir>/sessions` (older Jarvis side history lives under `<agentDir>/jarvis-sessions` and needs an explicit root). Require enabled recording/trust before scanning; never read transcript bodies or open archive records for preview. No startup scan, model import tool, or implicit history backfill.
|
|
74
|
+
- Confirmation requires `import-all --confirm-sensitive --preview <id>` and consumes the 10-minute preview once. Pin the exact reviewed set, root/directory/file identities and metadata; do not rescan or add newly discovered files. Bind to cwd/session and live permission/import generations; new previews replace old ones. Cancellation/revocation/session change stops remaining work, without replay or rollback promises.
|
|
75
|
+
- Bounded sequential discovery/import: 10,000 candidates, 50,000 entries visited, depth 64, approximately 8 MiB manifest. Skip nested symlinks, hardlinks and nonregular files. Fail incomplete/over-limit previews explicitly. Recheck opened FDs and directory identities, cap bulk reads at reviewed size, check mutation at streaming boundaries; do not claim a filesystem snapshot/sandbox.
|
|
76
|
+
- Preserve single-file import compatibility, v3/header provenance, dedup/conflict/tombstone semantics and partial counts. Per-file source failures continue; cancellation/permission/storage-wide failure stops the batch. Sources are never intentionally written. Tests use temporary synthetic session directories only.
|
|
77
|
+
- `import-report <id> [offset]` pages the latest ephemeral per-file report under the same project/session owner, with enabled archive but no model-access/capture requirement. Bound JSON output to 24,000 bytes, explicitly abbreviate oversized paths and preserve pagination progress. `import-cancel` cancels local imports/previews without changing settings and works while off. No persisted report or automatic context injection.
|
|
78
|
+
|
|
63
79
|
## Git and Release Policy
|
|
64
80
|
- Every new commit MUST have an annotated **stable version tag `vX.Y.Z`**. No `dev`, alpha, beta, release-candidate, build-metadata, or SHA-only tags. This is a released extension, not a prerelease channel.
|
|
65
81
|
- Before committing, choose the next unused stable version and update package metadata, lockfile, README, and a dated changelog entry together. Tag every commit, including intermediate and merge commits; never leave a new commit untagged. Run `npm run check:tags`, then push the commit and version tag atomically. Do not move or replace existing tags or rewrite shared history.
|
package/README.md
CHANGED
|
@@ -6,20 +6,24 @@
|
|
|
6
6
|
|
|
7
7
|
## A cinematic side-conversation overlay for Pi
|
|
8
8
|
|
|
9
|
-
**
|
|
9
|
+
**A second lane of thought—with shared memory and an optional searchable history archive.**
|
|
10
10
|
|
|
11
11
|
`pi-jarvis` adds `/jarvis`: a polished overlay where you can ask for status, inspect the repo when you explicitly allow it, and send a quiet note or a confirmed redirect back to the main lane.
|
|
12
12
|
|
|
13
|
+
**Remember what matters. Find the original history when you need it.** Main Pi and Jarvis share [persistent memory](#shared-memory); the separate, opt-in [full-session archive](#full-session-archive) adds indexed history search across sessions and, when explicitly requested, projects. **New in the 1.9 series: bulk-import existing Pi sessions with a preview and explicit confirmation.**
|
|
14
|
+
|
|
13
15
|
[](https://github.com/crustyhacker/pi-jarvis/actions/workflows/ci.yml)
|
|
14
16
|
[](https://www.npmjs.com/package/pi-jarvis)
|
|
15
17
|
[](./LICENSE)
|
|
16
18
|
[](https://github.com/crustyhacker/pi-jarvis)
|
|
17
19
|
[](./package.json)
|
|
18
20
|
|
|
19
|
-
<p><strong>Current version:</strong> 1.
|
|
21
|
+
<p><strong>Current version:</strong> 1.9.1</p>
|
|
20
22
|
|
|
21
23
|
<p>
|
|
22
24
|
<strong>Shared persistent memory</strong> ·
|
|
25
|
+
<strong>Optional indexed session archive</strong> ·
|
|
26
|
+
<strong>Confirmed bulk history import</strong> ·
|
|
23
27
|
<strong>Persistent side session</strong> ·
|
|
24
28
|
<strong>Live main-session awareness</strong> ·
|
|
25
29
|
<strong>Opt-in local tools + native MCP</strong> ·
|
|
@@ -74,11 +78,28 @@ The main Pi session should stay on the critical path.
|
|
|
74
78
|
|
|
75
79
|
---
|
|
76
80
|
|
|
81
|
+
## Two complementary memory features
|
|
82
|
+
|
|
83
|
+
| | Shared memory | Optional full-session archive |
|
|
84
|
+
|---|---|---|
|
|
85
|
+
| **Purpose** | Remember useful preferences, corrections, decisions and references | Find original recorded conversations, tool activity and session history |
|
|
86
|
+
| **What it keeps** | Curated notes plus bounded finalized user/assistant text captures | Complete accepted finalized Pi journal entries, with provenance and paged raw reads |
|
|
87
|
+
| **Default** | **On in trusted projects**, with separate capture/recall controls | **Off**; recording and model access are separately controlled |
|
|
88
|
+
| **Retrieval** | Automatic recall from global/current-project memory; explicit broader search | Local indexed search and session browsing; no automatic context injection |
|
|
89
|
+
| **Manage it** | `/jarvis-memory` · overlay `/memory` | `/jarvis-archive` · overlay `/archive` |
|
|
90
|
+
|
|
91
|
+
Both work across main Pi and Jarvis, independently of **Repo tools** and whether the overlay is open. Each has its own local SQLite store and global/project controls. Turning one off does not turn the other off.
|
|
92
|
+
|
|
93
|
+
**Privacy matters:** storage is local plaintext. Archive content is unredacted and can include secrets; granting model access can send retrieved content to your model provider. “Full” means accepted finalized data exposed by Pi—not hidden provider reasoning or a crash-safe audit log. Historical import is explicit. See the [memory controls](#shared-memory) and [archive limits](#full-session-archive) before enabling more access.
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
77
97
|
## At a glance
|
|
78
98
|
|
|
79
99
|
| Capability | What you get |
|
|
80
100
|
|---|---|
|
|
81
101
|
| **Shared memory** | Main Pi and Jarvis remember useful discussions across sessions; enabled by default, with global/project controls and a master off switch |
|
|
102
|
+
| **Optional full-session archive** | Off by default; raw finalized entries, local indexed cross-session search, separate model permission, and preview-confirmed bulk history import |
|
|
82
103
|
| **Persistent side lane** | `/jarvis` keeps its own isolated conversation state and restores prior side-session history |
|
|
83
104
|
| **Live awareness** | Jarvis sees the current main-session summary plus a delta since the last `/jarvis` turn |
|
|
84
105
|
| **Permission-gated tools** | Local `read`, `bash`, `edit`, `write`, and configured native MCP stay off until you enable Repo tools |
|
|
@@ -97,6 +118,10 @@ flowchart LR
|
|
|
97
118
|
M -->|summary + recent delta| J
|
|
98
119
|
M <-->|independent memory controls| S[Shared local memory]
|
|
99
120
|
J <-->|independent memory controls| S
|
|
121
|
+
M -->|recording opt-in| A[Separate local history archive]
|
|
122
|
+
J -->|recording opt-in| A
|
|
123
|
+
A -. separately authorized model reads .-> M
|
|
124
|
+
A -. separately authorized model reads .-> J
|
|
100
125
|
J -->|Repo tools enabled| R[Local tools\nread • bash • edit • write]
|
|
101
126
|
J -->|Repo tools enabled| C[Configured native MCP\nside-owned connections]
|
|
102
127
|
J -. Note main .-> M
|
|
@@ -154,6 +179,8 @@ Requires **Pi 1.0.0** and **Node.js 22.19.0 or newer**. Version **1.6.0** suppor
|
|
|
154
179
|
`pi install` registers the package automatically. For local development, build and load `./dist/index.js` with `pi -e ./dist/index.js`.
|
|
155
180
|
**New in 1.7.0: shared memory is enabled by default in trusted projects**, including main Pi even if you never open the overlay. A first-use notice explains capture and recall. Already using another memory extension? Run `/jarvis-memory off` before your first prompt; this disables both main and Jarvis memory without deleting anything.
|
|
156
181
|
|
|
182
|
+
**New in 1.8.0: the separate full-session archive is OFF by default.** Nothing is imported or recorded by that subsystem until you opt in. See [Full-session archive](#full-session-archive).
|
|
183
|
+
|
|
157
184
|
### 3) Open Jarvis
|
|
158
185
|
|
|
159
186
|
```bash
|
|
@@ -207,6 +234,9 @@ Removes the selected scope so `/jarvis` thinking falls back through the remainin
|
|
|
207
234
|
### `/jarvis-memory`
|
|
208
235
|
Reports shared-memory status. Use `/jarvis-memory help` for controls and data-management commands. Memory controls default to **global**, unlike model/thinking controls. See [Shared memory](#shared-memory) below.
|
|
209
236
|
|
|
237
|
+
### `/jarvis-archive`
|
|
238
|
+
Reports the separate full-session archive's status. It defaults **OFF**, with independent capture and model-access controls. `/jarvis-archive help` documents enablement warnings, paging, explicit import, and deletion. See [Full-session archive](#full-session-archive).
|
|
239
|
+
|
|
210
240
|
### Side-session commands inside `/jarvis`
|
|
211
241
|
The `/jarvis` input handles a small set of built-in commands against the isolated side-session:
|
|
212
242
|
|
|
@@ -216,6 +246,105 @@ The `/jarvis` input handles a small set of built-in commands against the isolate
|
|
|
216
246
|
- `/tree --summarize <entry-id> [instructions]` navigates and summarizes the branch being left.
|
|
217
247
|
- `/new` starts a fresh `/jarvis` side-session without changing the main Pi session.
|
|
218
248
|
- `/memory …` or `/jarvis-memory …` manages shared memory immediately, without sending a model prompt or waiting for queued side work. Initial forms such as `/jarvis /memory off` are also handled locally, without booting a side session.
|
|
249
|
+
- `/archive …` or `/jarvis-archive …` manages the separate optional archive locally, without model/queue work; initial `/jarvis /archive …` works without booting a side session.
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
## Full-session archive
|
|
254
|
+
|
|
255
|
+
This is a **separate, optional subsystem**, not a change to shared memory's curated notes or bounded text captures. It is **OFF by default**, independent of Repo tools, Note main, Redirect, and overlay open/close. Model reads are **also off by default**, even after recording is enabled. No archive content is automatically injected into prompts.
|
|
256
|
+
|
|
257
|
+
### Enable only after reviewing the risks
|
|
258
|
+
|
|
259
|
+
```text
|
|
260
|
+
/jarvis-archive # status; no archive-record reads
|
|
261
|
+
/jarvis-archive --project on --confirm-sensitive # record here only
|
|
262
|
+
/jarvis-archive on --confirm-sensitive # enable globally
|
|
263
|
+
/jarvis-archive model-access on --confirm-sensitive # allow model search/read; recording alone doesn't
|
|
264
|
+
/jarvis-archive capture off # pause recording default, retain access
|
|
265
|
+
/jarvis-archive off # global MASTER OFF; keep stored data
|
|
266
|
+
/jarvis-archive clear --confirm-sensitive # remove global settings; fallback may re-enable
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
Controls default to **global**; use `--project` for an override. Resolution is per-field project > global > defaults (`enabled: false`, `capture: true`, `modelAccess: false`), except an **explicit global off overrides every project**. `capture off` and `model-access off` set defaults that a project can override; inspect effective status. Use `clear --confirm-sensitive` to remove a scoped setting, never data. Malformed/unreadable settings and untrusted projects pause **all** archive access. Full off blocks even manual record inspection; recording-only/model-only pauses do not prevent explicit human reads. Separate files avoid interfering with memory/model settings:
|
|
270
|
+
|
|
271
|
+
- Global: `<active-agent-dir>/extensions/pi-jarvis-archive.json`
|
|
272
|
+
- Project: `.pi/jarvis-archive.json`
|
|
273
|
+
- Shape: `{ "archive": { "enabled": true, "capture": true, "modelAccess": false } }`
|
|
274
|
+
|
|
275
|
+
Enabling/model-access commands require the literal warning acknowledgment, and direct-file enablement shows a first-use warning. **This archive is unredacted plaintext and may retain passwords, tokens, private files, and sensitive tool output.** Model access can send retrieved data to the active provider. It is not a sandbox, encryption mechanism, or a substitute for carefully managing secrets.
|
|
276
|
+
|
|
277
|
+
### What “full” means
|
|
278
|
+
|
|
279
|
+
Accepted **new, finalized Pi journal entries** are retained as complete JSON, without memory's secret filtering, 16 KiB text cap, or 10,000-record eviction. This includes user/assistant/system messages, exposed thinking, tool calls/results and details, failed/aborted output that Pi retained, inline image payloads, custom entries, compaction/context edits, and branch metadata. Session headers retain provenance, including parent-session links. Search indexes textual content locally with SQLite FTS5; binary image data and opaque signatures are retained but not text-indexed. There is no OCR, embedding service, or background model call.
|
|
280
|
+
|
|
281
|
+
“Full” **does not mean an infallible wire/stream audit log**. Hidden provider reasoning, keystrokes, intermediate stream/tool updates, non-persisted commands/events, external attachment files, and output already truncated by Pi/tools are not recovered. Referenced files are **never automatically opened or copied**. Later message-redaction hooks run before capture. Raw history includes abandoned branches and superseded context, not just the effective current model context.
|
|
282
|
+
|
|
283
|
+
Recording begins after an activation baseline, never by importing pre-existing entries. Captures occur at finalized turn/settlement and supported session boundaries, not per token. The side owner takes a final snapshot of already-finalized entries before disposal, while recording remains authorized. Crashes, late shutdown hooks, unsupported journal APIs, failed storage, or permission transitions can leave gaps; warnings report observation/storage failures without replaying uncertain writes. Pending/disabled-period content is not backfilled after re-enable. Explicit **64 MiB raw-entry and indexing ceilings reject oversized work rather than truncating it**. Normalization uses bounded chunks; pathological Unicode combining/composition contexts beyond 64K UTF-16 units also reject explicitly. Conservative index budgeting can reject excessive whitespace/normalization expansion even if its final folded text would be smaller. No automatic eviction or strict total-disk quota is imposed: monitor space and prune deliberately. Large synchronous writes/indexing can pause the UI. Search/page order may change as other sessions append/delete records; pagination is not a frozen snapshot.
|
|
284
|
+
|
|
285
|
+
### Search and inspect
|
|
286
|
+
|
|
287
|
+
```text
|
|
288
|
+
/jarvis-archive search deployment decision
|
|
289
|
+
/jarvis-archive search --all --offset 20 deployment
|
|
290
|
+
/jarvis-archive session --all <session-id> 0
|
|
291
|
+
/jarvis-archive read --all <record-id> 0
|
|
292
|
+
/jarvis-archive read --all --metadata <record-id> 0
|
|
293
|
+
/jarvis-archive stats --all
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
Search/session pages return bounded excerpts of normalized indexing text with IDs, project, lane, timestamps and parent entry IDs. Excerpts are not exact quotations; use `read` for original case and content. Follow `nextOffset` to continue. Exceptionally large/escape-heavy provenance is explicitly labeled with `abbreviated` field names, never allowed to block record access; `read --metadata` (model tool `part: "metadata"`) pages the exact original metadata. `read` returns complete raw JSON **through pages**; its offsets count Unicode codepoints, not bytes or UTF-16 units. Results are bounded to 24,000 bytes of JSON plus an untrusted-data notice; stored payloads are not shortened. Use explicit `--all` to access other projects. Models get only three read-only tools—`jarvis_archive_search`, `jarvis_archive_read`, and `jarvis_archive_session`—when model access is enabled. No model controls, import, or deletion tools exist. Tools recheck current permissions/trust/cancellation and reject stale definitions.
|
|
297
|
+
|
|
298
|
+
Global accessibility is within the **same active Pi agent directory**, not cloud sync or other users' machines. Project controls govern operations initiated here; existing records from a paused project remain accessible through explicit all-project queries from another allowed project. Disabling is not deletion. Returned model-tool results persist normally in Pi and can be captured again as part of a later journal entry.
|
|
299
|
+
|
|
300
|
+
### Import all existing Pi sessions
|
|
301
|
+
|
|
302
|
+
With archive recording enabled, run:
|
|
303
|
+
|
|
304
|
+
```text
|
|
305
|
+
/jarvis-archive import-all
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
This **previews** `.jsonl` candidates recursively under the active Pi agent directory's `sessions` folder (normally `~/.pi/agent/sessions`). It shows the candidate file count before any transcript body is read or archived. Then paste the confirmation command supplied by the preview:
|
|
309
|
+
|
|
310
|
+
```text
|
|
311
|
+
/jarvis-archive import-all --confirm-sensitive --preview <preview-id>
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
For a different session directory, preview it explicitly:
|
|
315
|
+
|
|
316
|
+
```text
|
|
317
|
+
/jarvis-archive import-all /absolute/path/to/session-directory
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
The default covers Pi's standard main-session directory across projects. For older Jarvis side sessions, repeat the preview for `<active-agent-dir>/jarvis-sessions`; custom `--session-dir` locations also need an explicit directory preview.
|
|
321
|
+
|
|
322
|
+
The confirmation token selects the **exact reviewed file list**, not a fresh scan. Files created afterward are not silently added. Existing identical entries are skipped, and each source file keeps its original project/session identity. Bad/legacy files are reported individually rather than hiding failures or abandoning the rest of the batch. Original transcripts are never rewritten.
|
|
323
|
+
|
|
324
|
+
```text
|
|
325
|
+
/jarvis-archive import-report <report-id> # paged per-file results
|
|
326
|
+
/jarvis-archive import-report <report-id> <nextOffset> # follow the returned offset
|
|
327
|
+
/jarvis-archive import-cancel # stop pending/active imports
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
Previews expire after 10 minutes and are bound to the current project/session and permission generation. A new preview replaces the old one; confirmation consumes it once. The latest report is kept only in memory, not persisted or supplied to models. Policy/session changes, cancellation, or storage-wide failure stop remaining work; completed entries remain, with partial counts reported. The start notice supplies the report ID; progress counts update as each file settles, not on every entry. Counts cover acknowledged writes; a storage failure can leave an uncertain final commit. Re-preview explicitly to retry—imports are never automatically replayed.
|
|
331
|
+
|
|
332
|
+
Discovery skips symlinks below the selected root, hardlinked/nonregular files, and unrelated extensions. Unreadable directories or discovery limits abort the preview rather than calling a partial scan “all”: at most 10,000 candidates, 50,000 visited entries, depth 64, and an 8 MiB manifest budget. Opened files and reviewed directory identities are checked for substitution; bulk reads are limited to the reviewed size, with mutation checks during streaming. These are defensive checks, **not an immutable filesystem snapshot or sandbox**. Pause active sessions for the most reliable historical import; changed files are reported and may need a fresh preview.
|
|
333
|
+
|
|
334
|
+
Bulk import is a human command, not a model tool. It requires enabled recording in the initiating trusted project but does not require model access or Repo tools. Like single-file import, it can ingest sensitive unredacted history from multiple projects; no automatic startup scan or import occurs.
|
|
335
|
+
|
|
336
|
+
### Single-file import and retention
|
|
337
|
+
|
|
338
|
+
```text
|
|
339
|
+
/jarvis-archive import --confirm-sensitive /absolute/path/to/session.jsonl
|
|
340
|
+
/jarvis-archive forget-session --confirm <session-id>
|
|
341
|
+
/jarvis-archive prune --confirm 2026-01-01T00:00:00.000Z
|
|
342
|
+
/jarvis-archive prune --all --confirm 2026-01-01T00:00:00.000Z
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
Single-file import is **human-only**, requires enabled recording and an explicit regular v3 JSONL file, and preserves the source header's project/session identity—even if different from the current project. Directory discovery happens only through the explicit bulk preview above; no silent historical import occurs. Both import modes require v3 session files; legacy session versions require a separately reviewed conversion first. Completed entries survive a partial/cancelled import, with counts reported; duplicate entries are skipped, differing payloads for an existing identity are rejected, and originals are never modified. Deletion defaults to this project; `--all` is explicit. Stable identity tombstones prevent re-import of deleted entries, not every semantic copy or other previously unarchived entry.
|
|
346
|
+
|
|
347
|
+
Storage is lazy SQLite under `<active-agent-dir>/extensions/pi-jarvis-archive/archive.sqlite`, defaulting to `~/.pi/agent/extensions/pi-jarvis-archive/archive.sqlite`. Owned directories/files use private permissions where supported, with defensive link/type checks and concurrent-writer transactions. There is no background watcher: observed settings changes are propagated between mounted lanes, while other processes recheck at operation boundaries. Deletion does not erase original Pi files, prior search-result copies, already-sent model context or backups, and does not guarantee reclaimed disk space or forensic erasure. For a complete reset, stop all Pi processes using the store and remove only its archive directory yourself; that also removes tombstones. Shared memory stays separate and unchanged. To stop both Jarvis persistence layers, use both `/jarvis-archive off` and `/jarvis-memory off`; neither disables Pi's original session transcripts.
|
|
219
348
|
|
|
220
349
|
---
|
|
221
350
|
|
|
@@ -225,7 +354,7 @@ Main Pi and Jarvis use **one local memory service**, independent of the overlay
|
|
|
225
354
|
|
|
226
355
|
### What is remembered
|
|
227
356
|
|
|
228
|
-
- **
|
|
357
|
+
- **Bounded conversation captures (not the optional full-session archive):** only newly finalized user/assistant text observed after loading this feature, labeled with project, main/Jarvis lane, session ID, event identity and timestamps. No silent historical import or reconstruction from old session files.
|
|
229
358
|
- **Curated notes:** your active model can save concise preferences, corrections, project decisions and references during normal foreground work. Stable scoped titles update/deduplicate notes. You can save or edit notes explicitly too. Curation depends on the model choosing the tool; it is not a separate background summarizer.
|
|
230
359
|
- **Bounded recall:** a small request-local selection of global/current-project notes and matching conversation excerpts, using local keyword search. Other projects are available through explicit `search --all` or the model's cross-project search tool. Project scope uses the canonical working directory, not a remote repository name; separate worktrees remain separate scopes unless a note is global.
|
|
231
360
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ArchivePolicy, ArchiveScope } from "./archive-types.js";
|
|
2
|
+
type Scope = ArchiveScope;
|
|
3
|
+
/** Caller-spelled settings path, without I/O. Access canonicalizes only the chosen root. */
|
|
4
|
+
export declare function archiveConfigPath(cwd: string, agentDir: string, scope: Scope): string;
|
|
5
|
+
/** Reads settings only. Archiving defaults off; trust/read/validation failures disable every permission. */
|
|
6
|
+
export declare function resolveArchivePolicy(cwd: string, agentDir: string, trusted?: boolean): {
|
|
7
|
+
policy: ArchivePolicy;
|
|
8
|
+
errors: string[];
|
|
9
|
+
};
|
|
10
|
+
/** Merges only supplied fields into this scope; never materializes inherited/default values. */
|
|
11
|
+
export declare function saveArchivePolicy(cwd: string, agentDir: string, scope: Scope, patch: Partial<ArchivePolicy>): void;
|
|
12
|
+
/** Removes only archive controls. Corrupt files are never repaired or removed. */
|
|
13
|
+
export declare function clearArchivePolicy(cwd: string, agentDir: string, scope: Scope): void;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=archive-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"archive-config.d.ts","sourceRoot":"","sources":["../archive-config.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEtE,KAAK,KAAK,GAAG,YAAY,CAAC;AAa1B,4FAA4F;AAC5F,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,MAAM,CAGrF;AAED,4GAA4G;AAC5G,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,UAAO,GAAG;IACpF,MAAM,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAC;CACxC,CAoBA;AAED,gGAAgG;AAChG,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,CAOlH;AAED,kFAAkF;AAClF,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAMpF"}
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import { closeSync, constants, fstatSync, fsyncSync, lstatSync, mkdirSync, openSync, readSync, realpathSync, renameSync, unlinkSync, writeFileSync, } from "node:fs";
|
|
2
|
+
import { isUtf8 } from "node:buffer";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
import { basename, dirname, join, parse, resolve } from "node:path";
|
|
5
|
+
const FIELDS = ["enabled", "capture", "modelAccess"];
|
|
6
|
+
const CONFIG_LIMIT_BYTES = 1024 * 1024;
|
|
7
|
+
const LOCK_WAIT_MS = 2_000;
|
|
8
|
+
const LOCK_POLL_MS = 20;
|
|
9
|
+
const sleep = new Int32Array(new SharedArrayBuffer(4));
|
|
10
|
+
const noFollow = constants.O_NOFOLLOW ?? 0;
|
|
11
|
+
// A cooperative writer can atomically replace a file during the unlocked
|
|
12
|
+
// no-op preflight. Only writers retry that read once under the lock; policy
|
|
13
|
+
// readers and races during the locked read still fail closed.
|
|
14
|
+
class ArchiveSettingsReadRace extends Error {
|
|
15
|
+
}
|
|
16
|
+
/** Caller-spelled settings path, without I/O. Access canonicalizes only the chosen root. */
|
|
17
|
+
export function archiveConfigPath(cwd, agentDir, scope) {
|
|
18
|
+
if (scope !== "global" && scope !== "project")
|
|
19
|
+
throw new Error("Invalid archive settings scope.");
|
|
20
|
+
return scope === "global" ? join(agentDir, "extensions", "pi-jarvis-archive.json") : join(cwd, ".pi", "jarvis-archive.json");
|
|
21
|
+
}
|
|
22
|
+
/** Reads settings only. Archiving defaults off; trust/read/validation failures disable every permission. */
|
|
23
|
+
export function resolveArchivePolicy(cwd, agentDir, trusted = true) {
|
|
24
|
+
const errors = [];
|
|
25
|
+
const read = (scope) => {
|
|
26
|
+
try {
|
|
27
|
+
return parsePolicy(readConfig(settingsPath(cwd, agentDir, scope))?.archive);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// Never include parser messages, config contents, paths or underlying I/O errors.
|
|
31
|
+
errors.push(`Cannot read ${scope} archive settings; archive is disabled.`);
|
|
32
|
+
return {};
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const global = read("global");
|
|
36
|
+
const project = read("project");
|
|
37
|
+
if (errors.length || !trusted)
|
|
38
|
+
return { policy: { enabled: false, capture: false, modelAccess: false }, errors };
|
|
39
|
+
const base = { enabled: false, capture: true, modelAccess: false, ...global };
|
|
40
|
+
const policy = { ...base, ...project };
|
|
41
|
+
// Only explicit global enabled=false is a master switch; other fields remain independent preferences.
|
|
42
|
+
if (global.enabled === false)
|
|
43
|
+
policy.enabled = false;
|
|
44
|
+
return { policy, errors };
|
|
45
|
+
}
|
|
46
|
+
/** Merges only supplied fields into this scope; never materializes inherited/default values. */
|
|
47
|
+
export function saveArchivePolicy(cwd, agentDir, scope, patch) {
|
|
48
|
+
const parsed = parsePatch(patch);
|
|
49
|
+
changeConfig(cwd, agentDir, scope, (config) => {
|
|
50
|
+
if (!Object.keys(parsed).length)
|
|
51
|
+
return false;
|
|
52
|
+
config.archive = { ...config.archive, ...parsed };
|
|
53
|
+
return true;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/** Removes only archive controls. Corrupt files are never repaired or removed. */
|
|
57
|
+
export function clearArchivePolicy(cwd, agentDir, scope) {
|
|
58
|
+
changeConfig(cwd, agentDir, scope, (config) => {
|
|
59
|
+
if (!Object.hasOwn(config, "archive"))
|
|
60
|
+
return false;
|
|
61
|
+
delete config.archive;
|
|
62
|
+
return true;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function parsePolicy(value) {
|
|
66
|
+
if (value === undefined)
|
|
67
|
+
return {};
|
|
68
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
69
|
+
throw new Error("Invalid archive controls.");
|
|
70
|
+
const policy = {};
|
|
71
|
+
for (const field of FIELDS) {
|
|
72
|
+
if (!Object.hasOwn(value, field))
|
|
73
|
+
continue;
|
|
74
|
+
const setting = value[field];
|
|
75
|
+
if (typeof setting !== "boolean")
|
|
76
|
+
throw new Error("Invalid archive controls.");
|
|
77
|
+
policy[field] = setting;
|
|
78
|
+
}
|
|
79
|
+
return policy;
|
|
80
|
+
}
|
|
81
|
+
function parsePatch(patch) {
|
|
82
|
+
if (!patch || typeof patch !== "object" || Array.isArray(patch)
|
|
83
|
+
|| Object.keys(patch).some((key) => !FIELDS.includes(key))) {
|
|
84
|
+
throw new Error("Invalid archive controls patch.");
|
|
85
|
+
}
|
|
86
|
+
return parsePolicy(patch);
|
|
87
|
+
}
|
|
88
|
+
function missing(error) {
|
|
89
|
+
return error?.code === "ENOENT";
|
|
90
|
+
}
|
|
91
|
+
/** Resolve user-selected roots (including ancestor links), but never appended settings paths. */
|
|
92
|
+
function settingsPath(cwd, agentDir, scope) {
|
|
93
|
+
// Validate scope before choosing/canonicalizing a root.
|
|
94
|
+
archiveConfigPath(cwd, agentDir, scope);
|
|
95
|
+
const root = canonicalRoot(scope === "global" ? agentDir : cwd);
|
|
96
|
+
return scope === "global" ? join(root, "extensions", "pi-jarvis-archive.json") : join(root, ".pi", "jarvis-archive.json");
|
|
97
|
+
}
|
|
98
|
+
/** Missing roots inherit the real path of their nearest existing directory ancestor. */
|
|
99
|
+
function canonicalRoot(path) {
|
|
100
|
+
let current = resolve(path);
|
|
101
|
+
const suffix = [];
|
|
102
|
+
for (;;) {
|
|
103
|
+
try {
|
|
104
|
+
lstatSync(current);
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
if (!missing(error))
|
|
108
|
+
throw error;
|
|
109
|
+
const parent = dirname(current);
|
|
110
|
+
if (parent === current)
|
|
111
|
+
throw error;
|
|
112
|
+
suffix.unshift(basename(current));
|
|
113
|
+
current = parent;
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
// An existing dangling link or a nondirectory root is an error, not a missing config.
|
|
117
|
+
const canonical = realpathSync(current);
|
|
118
|
+
if (!lstatSync(canonical).isDirectory())
|
|
119
|
+
throw new Error("Unsafe archive settings root.");
|
|
120
|
+
return join(canonical, ...suffix);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/** Validate the canonical ancestry, missing root components and appended settings directories. */
|
|
124
|
+
function directories(path, create) {
|
|
125
|
+
const absolute = resolve(path);
|
|
126
|
+
const root = parse(absolute).root;
|
|
127
|
+
const parts = [];
|
|
128
|
+
let current = absolute;
|
|
129
|
+
while (current !== root) {
|
|
130
|
+
parts.push(current);
|
|
131
|
+
current = dirname(current);
|
|
132
|
+
}
|
|
133
|
+
parts.push(root);
|
|
134
|
+
for (const directory of parts.reverse()) {
|
|
135
|
+
let stat;
|
|
136
|
+
try {
|
|
137
|
+
stat = lstatSync(directory);
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
if (!missing(error))
|
|
141
|
+
throw error;
|
|
142
|
+
if (!create)
|
|
143
|
+
return false;
|
|
144
|
+
try {
|
|
145
|
+
mkdirSync(directory, { mode: 0o700 });
|
|
146
|
+
}
|
|
147
|
+
catch (mkdirError) {
|
|
148
|
+
if (mkdirError?.code !== "EEXIST")
|
|
149
|
+
throw mkdirError;
|
|
150
|
+
}
|
|
151
|
+
stat = lstatSync(directory);
|
|
152
|
+
}
|
|
153
|
+
if (!stat.isDirectory() || stat.isSymbolicLink())
|
|
154
|
+
throw new Error("Unsafe archive settings directory.");
|
|
155
|
+
}
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
function regularFile(path) {
|
|
159
|
+
let stat;
|
|
160
|
+
try {
|
|
161
|
+
stat = lstatSync(path);
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
if (missing(error))
|
|
165
|
+
return undefined;
|
|
166
|
+
throw error;
|
|
167
|
+
}
|
|
168
|
+
// A pathname lookup can retain the old inode while a concurrent rename or
|
|
169
|
+
// lock release unlinks it, so even lstat may legitimately report nlink=0.
|
|
170
|
+
if (stat.isFile() && !stat.isSymbolicLink() && stat.nlink === 0)
|
|
171
|
+
throw new ArchiveSettingsReadRace("Archive settings path was unlinked during lookup.");
|
|
172
|
+
if (!stat.isFile() || stat.isSymbolicLink() || stat.nlink !== 1)
|
|
173
|
+
throw new Error("Unsafe archive settings file.");
|
|
174
|
+
return stat;
|
|
175
|
+
}
|
|
176
|
+
function readConfig(path) {
|
|
177
|
+
if (!directories(dirname(path), false))
|
|
178
|
+
return undefined;
|
|
179
|
+
const stat = regularFile(path);
|
|
180
|
+
if (!stat)
|
|
181
|
+
return undefined;
|
|
182
|
+
if (stat.size > CONFIG_LIMIT_BYTES)
|
|
183
|
+
throw new Error("Archive settings exceed the size limit.");
|
|
184
|
+
// O_NONBLOCK prevents a raced special file from blocking before fstat rejects it.
|
|
185
|
+
const fd = openSync(path, constants.O_RDONLY | noFollow | constants.O_NONBLOCK);
|
|
186
|
+
let text;
|
|
187
|
+
try {
|
|
188
|
+
const opened = fstatSync(fd);
|
|
189
|
+
if (opened.isFile() && (opened.nlink === 0 || (opened.nlink === 1 && (opened.dev !== stat.dev || opened.ino !== stat.ino)))) {
|
|
190
|
+
throw new ArchiveSettingsReadRace("Archive settings changed while opening.");
|
|
191
|
+
}
|
|
192
|
+
if (!opened.isFile() || opened.nlink !== 1)
|
|
193
|
+
throw new Error("Unsafe archive settings file.");
|
|
194
|
+
if (opened.size > CONFIG_LIMIT_BYTES)
|
|
195
|
+
throw new Error("Archive settings exceed the size limit.");
|
|
196
|
+
// A bounded buffer also handles growth after fstat: readFileSync could allocate
|
|
197
|
+
// without limit in that race. The extra byte detects growth without reading it all.
|
|
198
|
+
const bytes = Buffer.alloc(opened.size + 1);
|
|
199
|
+
let length = 0;
|
|
200
|
+
while (length < bytes.length) {
|
|
201
|
+
const count = readSync(fd, bytes, length, bytes.length - length, null);
|
|
202
|
+
if (!count)
|
|
203
|
+
break;
|
|
204
|
+
length += count;
|
|
205
|
+
}
|
|
206
|
+
if (length !== opened.size)
|
|
207
|
+
throw new Error("Archive settings changed while reading.");
|
|
208
|
+
if (!isUtf8(bytes.subarray(0, length)))
|
|
209
|
+
throw new Error("Invalid archive settings encoding.");
|
|
210
|
+
text = bytes.toString("utf8", 0, length);
|
|
211
|
+
}
|
|
212
|
+
finally {
|
|
213
|
+
closeSync(fd);
|
|
214
|
+
}
|
|
215
|
+
let config;
|
|
216
|
+
try {
|
|
217
|
+
config = JSON.parse(text);
|
|
218
|
+
}
|
|
219
|
+
catch {
|
|
220
|
+
throw new Error("Invalid archive settings JSON.");
|
|
221
|
+
}
|
|
222
|
+
if (!config || typeof config !== "object" || Array.isArray(config))
|
|
223
|
+
throw new Error("Invalid archive settings object.");
|
|
224
|
+
const record = config;
|
|
225
|
+
// Validate controls even for clear calls; no operation may repair an invalid file.
|
|
226
|
+
parsePolicy(record.archive);
|
|
227
|
+
return record;
|
|
228
|
+
}
|
|
229
|
+
function changeConfig(cwd, agentDir, scope, change) {
|
|
230
|
+
try {
|
|
231
|
+
const path = settingsPath(cwd, agentDir, scope);
|
|
232
|
+
// Avoid creating directories/lock files for absent clears or already-applied changes.
|
|
233
|
+
try {
|
|
234
|
+
const existing = readConfig(path);
|
|
235
|
+
if (!change({ ...existing }))
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
catch (error) {
|
|
239
|
+
if (!(error instanceof ArchiveSettingsReadRace))
|
|
240
|
+
throw error;
|
|
241
|
+
// No write has occurred. Re-read/validate the current file under the
|
|
242
|
+
// existing cooperative lock rather than replaying an uncertain write.
|
|
243
|
+
}
|
|
244
|
+
directories(dirname(path), true);
|
|
245
|
+
withLock(path, () => {
|
|
246
|
+
const config = readConfig(path) ?? {};
|
|
247
|
+
if (change(config))
|
|
248
|
+
writeConfig(path, config);
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
catch {
|
|
252
|
+
throw new Error(`Cannot update ${scope} archive settings.`);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
/** Cooperative lock for archive writers only. Crashed writers leave locks; never steal a live lock. */
|
|
256
|
+
function withLock(path, run) {
|
|
257
|
+
const lock = `${path}.archive.lock`;
|
|
258
|
+
const deadline = performance.now() + LOCK_WAIT_MS;
|
|
259
|
+
let fd;
|
|
260
|
+
for (;;) {
|
|
261
|
+
try {
|
|
262
|
+
fd = openSync(lock, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | noFollow, 0o600);
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
catch (error) {
|
|
266
|
+
if (error?.code !== "EEXIST")
|
|
267
|
+
throw error;
|
|
268
|
+
try {
|
|
269
|
+
regularFile(lock);
|
|
270
|
+
} // Reject symlink/nonregular/hardlinked locks.
|
|
271
|
+
catch (lookupError) {
|
|
272
|
+
// The owner released it during lookup. Only a later exclusive open
|
|
273
|
+
// can acquire the path; keep the existing deadline and never unlink it.
|
|
274
|
+
if (!(lookupError instanceof ArchiveSettingsReadRace))
|
|
275
|
+
throw lookupError;
|
|
276
|
+
}
|
|
277
|
+
const remaining = deadline - performance.now();
|
|
278
|
+
if (remaining <= 0)
|
|
279
|
+
throw new Error("Archive settings lock timed out.");
|
|
280
|
+
Atomics.wait(sleep, 0, 0, Math.min(LOCK_POLL_MS, remaining));
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
let owned;
|
|
284
|
+
try {
|
|
285
|
+
owned = fstatSync(fd);
|
|
286
|
+
if (!owned.isFile() || owned.nlink !== 1)
|
|
287
|
+
throw new Error("Unsafe archive settings lock.");
|
|
288
|
+
run();
|
|
289
|
+
}
|
|
290
|
+
finally {
|
|
291
|
+
try {
|
|
292
|
+
closeSync(fd);
|
|
293
|
+
}
|
|
294
|
+
catch { /* Cleanup must not mask the primary failure. */ }
|
|
295
|
+
try {
|
|
296
|
+
const current = lstatSync(lock);
|
|
297
|
+
if (owned && current.dev === owned.dev && current.ino === owned.ino && current.isFile() && !current.isSymbolicLink())
|
|
298
|
+
unlinkSync(lock);
|
|
299
|
+
}
|
|
300
|
+
catch { /* Failed cleanup can leave a lock; bounded waits still fail closed. */ }
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
function writeConfig(path, config) {
|
|
304
|
+
const text = `${JSON.stringify(config, null, "\t")}\n`;
|
|
305
|
+
if (Buffer.byteLength(text, "utf8") > CONFIG_LIMIT_BYTES)
|
|
306
|
+
throw new Error("Archive settings exceed the size limit.");
|
|
307
|
+
const temporary = `${path}.${randomUUID()}.tmp`;
|
|
308
|
+
let fd;
|
|
309
|
+
let created = false;
|
|
310
|
+
try {
|
|
311
|
+
fd = openSync(temporary, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | noFollow, 0o600);
|
|
312
|
+
created = true;
|
|
313
|
+
writeFileSync(fd, text, "utf8");
|
|
314
|
+
fsyncSync(fd);
|
|
315
|
+
closeSync(fd);
|
|
316
|
+
fd = undefined;
|
|
317
|
+
directories(dirname(path), false);
|
|
318
|
+
regularFile(path); // Recheck the target before replacement; never replace a symlink.
|
|
319
|
+
renameSync(temporary, path);
|
|
320
|
+
created = false;
|
|
321
|
+
}
|
|
322
|
+
finally {
|
|
323
|
+
if (fd !== undefined) {
|
|
324
|
+
try {
|
|
325
|
+
closeSync(fd);
|
|
326
|
+
}
|
|
327
|
+
catch { /* Keep the primary failure. */ }
|
|
328
|
+
}
|
|
329
|
+
if (created) {
|
|
330
|
+
try {
|
|
331
|
+
unlinkSync(temporary);
|
|
332
|
+
}
|
|
333
|
+
catch { /* Keep the primary failure. */ }
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
//# sourceMappingURL=archive-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"archive-config.js","sourceRoot":"","sources":["../archive-config.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAC1E,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,GAC7D,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpE,MAAM,MAAM,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,aAAa,CAAU,CAAC;AAC9D,MAAM,kBAAkB,GAAG,IAAI,GAAG,IAAI,CAAC;AACvC,MAAM,YAAY,GAAG,KAAK,CAAC;AAC3B,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;AACvD,MAAM,QAAQ,GAAG,SAAS,CAAC,UAAU,IAAI,CAAC,CAAC;AAC3C,yEAAyE;AACzE,4EAA4E;AAC5E,8DAA8D;AAC9D,MAAM,uBAAwB,SAAQ,KAAK;CAAG;AAE9C,4FAA4F;AAC5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