brane 0.1.1 → 0.3.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 +367 -0
- package/CHANGELOG.md +66 -0
- package/CONTRIBUTING.md +101 -0
- package/DESIGN.md +405 -0
- package/Dockerfile +61 -0
- package/LICENSE +656 -17
- package/README.md +174 -2
- package/SECURITY.md +213 -0
- package/dist/absorb/brane-id.js +11 -0
- package/dist/absorb/chatgpt.js +161 -0
- package/dist/absorb/claude-code.js +504 -0
- package/dist/absorb/index.js +543 -0
- package/dist/absorb/organelle.js +345 -0
- package/dist/absorb/run.js +520 -0
- package/dist/absorb/sources.js +168 -0
- package/dist/absorb/types.js +3 -0
- package/dist/agent-env.js +45 -0
- package/dist/agents.js +1168 -0
- package/dist/claude-live-session.js +124 -0
- package/dist/cli.js +50 -0
- package/dist/codex-tool-log.js +144 -0
- package/dist/commands/absorb.js +291 -0
- package/dist/commands/attach.js +31 -0
- package/dist/commands/certify.js +62 -0
- package/dist/commands/config.js +133 -0
- package/dist/commands/cost.js +126 -0
- package/dist/commands/daemon.js +350 -0
- package/dist/commands/doctor.js +262 -0
- package/dist/commands/fold.js +95 -0
- package/dist/commands/list.js +89 -0
- package/dist/commands/mcp.js +84 -0
- package/dist/commands/meld.js +360 -0
- package/dist/commands/memory.js +215 -0
- package/dist/commands/revive.js +74 -0
- package/dist/commands/run.js +85 -0
- package/dist/commands/spawn.js +1101 -0
- package/dist/commands/token.js +154 -0
- package/dist/copilot-tool-log.js +145 -0
- package/dist/cost/pricing.js +116 -0
- package/dist/cost/reprice.js +136 -0
- package/dist/crush-tool-log.js +293 -0
- package/dist/daemon/agent-scope.js +116 -0
- package/dist/daemon/awaiting.js +54 -0
- package/dist/daemon/cert-manager.js +349 -0
- package/dist/daemon/client.js +262 -0
- package/dist/daemon/gated-routes.js +112 -0
- package/dist/daemon/keep-awake.js +103 -0
- package/dist/daemon/local-socket.js +145 -0
- package/dist/daemon/presence-gate.js +206 -0
- package/dist/daemon/server.js +6353 -0
- package/dist/daemon/signal-source.js +35 -0
- package/dist/daemon/tailscale-rebind.js +58 -0
- package/dist/daemon/token-ring.js +263 -0
- package/dist/daemon/token-routes.js +190 -0
- package/dist/db/events.js +152 -0
- package/dist/db/mentions.js +179 -0
- package/dist/db/schema.js +643 -0
- package/dist/db/tokens.js +624 -0
- package/dist/db/tool-uses.js +647 -0
- package/dist/diagram/index.js +85 -0
- package/dist/diagram/label.js +455 -0
- package/dist/diagram/layout.js +476 -0
- package/dist/diagram/links.js +50 -0
- package/dist/diagram/metrics.js +152 -0
- package/dist/diagram/parse.js +487 -0
- package/dist/diagram/svg.js +389 -0
- package/dist/diagram/types.js +9 -0
- package/dist/export.js +629 -0
- package/dist/files/archive-types.js +2 -0
- package/dist/files/archive.js +182 -0
- package/dist/files/browse.js +327 -0
- package/dist/files/bytes.js +162 -0
- package/dist/files/codecs.js +33 -0
- package/dist/files/find.js +212 -0
- package/dist/files/tar.js +223 -0
- package/dist/files/zip.js +209 -0
- package/dist/folds.js +72 -0
- package/dist/grammars/ebnf.js +92 -0
- package/dist/highlight.js +250 -0
- package/dist/ids.js +24 -0
- package/dist/markdown-diagnostics.js +233 -0
- package/dist/math.js +168 -0
- package/dist/mcp/server.js +886 -0
- package/dist/memory/embedder.js +145 -0
- package/dist/memory/embedding-worker.js +71 -0
- package/dist/memory/embeddings.js +91 -0
- package/dist/memory/index.js +232 -0
- package/dist/memory/storage.js +587 -0
- package/dist/memory/wiki.js +688 -0
- package/dist/memory/wordpiece.js +247 -0
- package/dist/mentions-scan.js +40 -0
- package/dist/presence.js +259 -0
- package/dist/session-affinity.js +185 -0
- package/dist/shared/api-request.js +124 -0
- package/dist/shared/app-origin.js +26 -0
- package/dist/shared/block-glyphs.js +114 -0
- package/dist/shared/diagram-css.js +17 -0
- package/dist/shared/export-selection.js +101 -0
- package/dist/shared/find-in-text.js +110 -0
- package/dist/shared/glow-hues.js +225 -0
- package/dist/shared/hex-dump.js +62 -0
- package/dist/shared/hex-pages.js +52 -0
- package/dist/shared/hit-drum.js +79 -0
- package/dist/shared/known-nids.js +58 -0
- package/dist/shared/list-scroll-keys.js +56 -0
- package/dist/shared/markdown-lists.js +72 -0
- package/dist/shared/markdown-math.js +485 -0
- package/dist/shared/markdown-mentions.js +79 -0
- package/dist/shared/markdown-nids.js +41 -0
- package/dist/shared/markdown-protocols.js +53 -0
- package/dist/shared/markdown-refs.js +123 -0
- package/dist/shared/membrane-invasion.js +342 -0
- package/dist/shared/membrane-motion.js +83 -0
- package/dist/shared/membrane-palette.js +253 -0
- package/dist/shared/membrane-terrain.js +212 -0
- package/dist/shared/message-selection.js +123 -0
- package/dist/shared/mo-glyph.js +57 -0
- package/dist/shared/narrative-format.js +237 -0
- package/dist/shared/narrative-menu.js +84 -0
- package/dist/shared/narrative-sort.js +47 -0
- package/dist/shared/narrative-status.js +52 -0
- package/dist/shared/no-pan.js +85 -0
- package/dist/shared/pane-layout.js +50 -0
- package/dist/shared/payload-inline.js +83 -0
- package/dist/shared/speaker-color.js +61 -0
- package/dist/shared/token-rotation.js +14 -0
- package/dist/shared/view-url.js +216 -0
- package/dist/shared/wiki-links.js +70 -0
- package/dist/shared/wiki-window.js +4 -0
- package/dist/tailscale.js +55 -0
- package/dist/test/absorb-claude.test.js +892 -0
- package/dist/test/agent-scope.test.js +193 -0
- package/dist/test/agents.test.js +55 -0
- package/dist/test/api-request.test.js +122 -0
- package/dist/test/app-host-literal.test.js +53 -0
- package/dist/test/awaiting-glow.test.js +54 -0
- package/dist/test/awaiting.test.js +122 -0
- package/dist/test/bind-token.test.js +88 -0
- package/dist/test/block-glyphs.test.js +68 -0
- package/dist/test/cert-manager.test.js +262 -0
- package/dist/test/claude-live-session.test.js +110 -0
- package/dist/test/codex-tool-log.test.js +568 -0
- package/dist/test/config.test.js +71 -0
- package/dist/test/copilot-tool-log.test.js +93 -0
- package/dist/test/cors-preflight.test.js +56 -0
- package/dist/test/cost-linger.test.js +31 -0
- package/dist/test/cost-pricing.test.js +72 -0
- package/dist/test/cost-reprice.test.js +139 -0
- package/dist/test/cost-sessions.test.js +301 -0
- package/dist/test/crush-tool-log.test.js +289 -0
- package/dist/test/daemon-client.test.js +109 -0
- package/dist/test/daemon-socket.test.js +293 -0
- package/dist/test/diagram-arrows.test.js +205 -0
- package/dist/test/diagram-export.test.js +210 -0
- package/dist/test/diagram-labels.test.js +313 -0
- package/dist/test/diagram-parse.test.js +191 -0
- package/dist/test/diagram-render.test.js +175 -0
- package/dist/test/diagram-review.test.js +288 -0
- package/dist/test/diagram-self-loop-labels.test.js +303 -0
- package/dist/test/embedder.test.js +84 -0
- package/dist/test/events.test.js +123 -0
- package/dist/test/export-selection.test.js +102 -0
- package/dist/test/export.test.js +505 -0
- package/dist/test/files-browse.test.js +393 -0
- package/dist/test/files-find.test.js +272 -0
- package/dist/test/find-in-text.test.js +86 -0
- package/dist/test/first-paint-viewport.test.js +59 -0
- package/dist/test/fixtures/embedding-golden.js +23 -0
- package/dist/test/fixtures/wordpiece-golden.js +167 -0
- package/dist/test/glow-hues.test.js +202 -0
- package/dist/test/harness-cost.test.js +423 -0
- package/dist/test/helpers.js +21 -0
- package/dist/test/hex-pages.test.js +68 -0
- package/dist/test/highlight.test.js +69 -0
- package/dist/test/hit-drum.test.js +71 -0
- package/dist/test/hook-config.test.js +299 -0
- package/dist/test/json-gzip.test.js +70 -0
- package/dist/test/key-routing.test.js +58 -0
- package/dist/test/known-nids.test.js +106 -0
- package/dist/test/link-preview.test.js +67 -0
- package/dist/test/list-scroll-keys.test.js +66 -0
- package/dist/test/listen-own-words.test.js +147 -0
- package/dist/test/listen-timeout.test.js +33 -0
- package/dist/test/markdown-diagnostics.test.js +121 -0
- package/dist/test/markdown-lists.test.js +182 -0
- package/dist/test/markdown-math.test.js +256 -0
- package/dist/test/markdown-nids.test.js +146 -0
- package/dist/test/markdown-protocols.test.js +139 -0
- package/dist/test/mcp-bridge-cancel.test.js +98 -0
- package/dist/test/mcp-bridge-reconnect.test.js +121 -0
- package/dist/test/mcp-narrative.test.js +193 -0
- package/dist/test/mcp.test.js +548 -0
- package/dist/test/meld.test.js +143 -0
- package/dist/test/membrane-invasion.test.js +482 -0
- package/dist/test/membrane-motion.test.js +101 -0
- package/dist/test/membrane-palette.test.js +166 -0
- package/dist/test/membrane-terrain.test.js +170 -0
- package/dist/test/memory-log.test.js +202 -0
- package/dist/test/mentions-e2e.test.js +261 -0
- package/dist/test/mentions-ledger.test.js +265 -0
- package/dist/test/mentions-listen.test.js +265 -0
- package/dist/test/mentions.test.js +238 -0
- package/dist/test/message-selection.test.js +114 -0
- package/dist/test/mo-glyph.test.js +22 -0
- package/dist/test/model-resolution.test.js +166 -0
- package/dist/test/narrate-validate.test.js +77 -0
- package/dist/test/narrate-wait.test.js +160 -0
- package/dist/test/narrative-format.test.js +219 -0
- package/dist/test/narrative-menu.test.js +150 -0
- package/dist/test/narrative-sort.test.js +75 -0
- package/dist/test/no-pan.test.js +60 -0
- package/dist/test/pane-layout.test.js +153 -0
- package/dist/test/paths.test.js +37 -0
- package/dist/test/payload-inline.test.js +91 -0
- package/dist/test/precache-fonts.test.js +72 -0
- package/dist/test/presence-gate.test.js +440 -0
- package/dist/test/presence.test.js +160 -0
- package/dist/test/read-events.test.js +220 -0
- package/dist/test/remote-meld.test.js +128 -0
- package/dist/test/revive-cli.test.js +93 -0
- package/dist/test/search-floor.test.js +206 -0
- package/dist/test/search-fusion.test.js +168 -0
- package/dist/test/search.test.js +205 -0
- package/dist/test/security.test.js +48 -0
- package/dist/test/selection-wiring.test.js +61 -0
- package/dist/test/session-affinity.test.js +295 -0
- package/dist/test/signal-source.test.js +32 -0
- package/dist/test/socket-account.test.js +268 -0
- package/dist/test/spawn-toml.test.js +72 -0
- package/dist/test/speaker-color.test.js +90 -0
- package/dist/test/tailscale-rebind.test.js +79 -0
- package/dist/test/terminal-cursor.test.js +61 -0
- package/dist/test/terminal-resync.test.js +23 -0
- package/dist/test/terminal-size.test.js +36 -0
- package/dist/test/thin-cli.test.js +382 -0
- package/dist/test/token-bootstrap.test.js +272 -0
- package/dist/test/token-devices.test.js +646 -0
- package/dist/test/token-lapse.test.js +94 -0
- package/dist/test/token-ring.test.js +188 -0
- package/dist/test/token-rotate-cli.test.js +58 -0
- package/dist/test/token-routes.test.js +95 -0
- package/dist/test/tool-uses.test.js +1006 -0
- package/dist/test/usage-ledger.test.js +126 -0
- package/dist/test/view-url.test.js +627 -0
- package/dist/test/wiki-links.test.js +57 -0
- package/dist/test/wiki-sources.test.js +85 -0
- package/dist/test/wiki-window.test.js +31 -0
- package/dist/test/wiki.test.js +399 -0
- package/dist/test/wordpiece.test.js +68 -0
- package/dist/test/wrangler-route.test.js +27 -0
- package/dist/tls.js +148 -0
- package/dist/tmux.js +213 -0
- package/dist/user-agent.js +46 -0
- package/docker-entrypoint.sh +154 -0
- package/docs/README.md +3 -0
- package/docs/absorb.md +231 -0
- package/docs/cost-ledger.md +125 -0
- package/docs/daemon-api.md +189 -0
- package/docs/diagrams.md +163 -0
- package/docs/doctor.md +36 -0
- package/docs/export-scope.md +69 -0
- package/docs/files-view.md +133 -0
- package/docs/link-previews.md +38 -0
- package/docs/math.md +32 -0
- package/docs/mcp.md +69 -0
- package/docs/memory-search.md +75 -0
- package/docs/mentions.md +101 -0
- package/docs/multi-brane.md +14 -0
- package/docs/passkeys.md +165 -0
- package/docs/presence.md +202 -0
- package/docs/releasing.md +104 -0
- package/docs/rendering-warnings.md +22 -0
- package/docs/request-layer.md +72 -0
- package/docs/selection-store.md +50 -0
- package/docs/session-affinity.md +61 -0
- package/docs/terminal-mirroring.md +243 -0
- package/docs/token-rotation.md +431 -0
- package/docs/view-urls.md +134 -0
- package/docs/web-app.md +23 -0
- package/docs/wiki.md +43 -0
- package/expo/dist/_expo/static/js/web/entry-e94247f119fdcd3b424a1764233a41d2.js +1099 -0
- package/expo/dist/apple-touch-icon.png +0 -0
- package/expo/dist/favicon.svg +3 -0
- package/expo/dist/index.html +177 -0
- package/expo/dist/katex/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_Main-Bold.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_Main-Italic.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_Main-Regular.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_Math-Italic.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_Script-Regular.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/expo/dist/katex/katex.min.css +1 -0
- package/expo/dist/manifest.json +16 -0
- package/expo/dist/metadata.json +1 -0
- package/expo/dist/og/membrane.v1.png +0 -0
- package/expo/dist/pdf.min.mjs +28 -0
- package/expo/dist/pdf.worker.min.mjs +28 -0
- package/expo/dist/sw.js +154 -0
- package/package.json +79 -27
- package/protocols/LIVE_loop.md +407 -0
- package/protocols/bebrief.md +41 -0
- package/protocols/digest.md +231 -0
- package/protocols/fly.md +266 -0
- package/protocols/idle.md +81 -0
- package/protocols/keeper.md +829 -0
- package/protocols/markdown.md +80 -0
- package/protocols/memory.md +419 -0
- package/protocols/mentions.md +93 -0
- package/protocols/payloads.md +53 -0
- package/protocols/prelude.md +91 -0
- package/protocols/ramify.md +105 -0
- package/protocols/review.md +356 -0
- package/protocols/rrr.md +232 -0
- package/protocols/scribe.md +429 -0
- package/protocols/summarize.md +203 -0
- package/protocols/twin.md +174 -0
- package/protocols/wiki.md +438 -0
- package/protocols/worker.md +38 -0
- package/wiki/shared/append-only-event-log.md +148 -0
- package/wiki/shared/index.md +53 -0
- package/wiki/shared/owning-your-narratives.md +161 -0
- package/wiki/shared/premature-ontologies.md +435 -0
- package/wiki/shared/sedimentary-superintelligence.md +128 -0
- package/wiki/shared/sequestering-the-narrative.md +143 -0
- package/wiki/shared/why-wikis-work.md +216 -0
- package/.travis.yml +0 -7
- package/lib/brane.cjs.js +0 -12
- package/lib/brane.cjs.js.map +0 -1
- package/lib/brane.d.ts +0 -11
- package/lib/brane.js +0 -6
- package/lib/brane.js.map +0 -1
- package/lib/tests.d.ts +0 -1
- package/lib/tests.js +0 -8
- package/lib/tests.js.map +0 -1
- package/rollup.config.js +0 -21
- package/scripts/test.sh +0 -8
- package/src/brane.ts +0 -21
- package/src/tests.ts +0 -8
- package/tsconfig.json +0 -16
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/** The inventory behind a bare `brane absorb`: every session store brane
|
|
2
|
+
* knows how to look for, whether it is on this machine, and what an import
|
|
3
|
+
* would do with it. Reads no message content — the survey is a promise a
|
|
4
|
+
* new user can be given ("it tells you what it found; nothing leaves the
|
|
5
|
+
* machine, nothing is imported until you say") and it is kept by
|
|
6
|
+
* construction: `LocalSource.survey` is a stat and a head read, and the
|
|
7
|
+
* probes below are `existsSync`.
|
|
8
|
+
*/
|
|
9
|
+
import { existsSync, readdirSync, statSync } from "node:fs";
|
|
10
|
+
import { join } from "node:path";
|
|
11
|
+
import { claudeCodeSource } from "./claude-code.js";
|
|
12
|
+
import { toPortablePath } from "../db/schema.js";
|
|
13
|
+
import { deriveBraneId } from "./brane-id.js";
|
|
14
|
+
/** Local sources with an extractor, in the order the survey lists them. */
|
|
15
|
+
export const LOCAL_SOURCES = [claudeCodeSource];
|
|
16
|
+
export function getLocalSource(name) {
|
|
17
|
+
return LOCAL_SOURCES.find((s) => s.name === name);
|
|
18
|
+
}
|
|
19
|
+
/** Stores brane recognises but cannot read yet. Listed so the survey says
|
|
20
|
+
* "found, no extractor" rather than nothing — the operator learns what is
|
|
21
|
+
* on the machine either way, and which line to ask for next. Today the
|
|
22
|
+
* list is the agents brane can spawn (see `AGENTS` in src/agents.ts) plus
|
|
23
|
+
* the other Claude product with a local transcript, because those are the
|
|
24
|
+
* formats someone here has looked at. Nothing ties an entry — or a
|
|
25
|
+
* `LocalSource` — to spawn support: an importer for a tool brane cannot
|
|
26
|
+
* run is welcome (claude-xiy9e8wq:17); the list just isn't speculative. */
|
|
27
|
+
const PROBES = [
|
|
28
|
+
{ name: "codex", label: "Codex CLI rollouts", under: (h) => join(h, ".codex", "sessions") },
|
|
29
|
+
{ name: "goose", label: "goose sessions", under: (h) => join(h, ".local", "share", "goose", "sessions") },
|
|
30
|
+
{ name: "copilot", label: "GitHub Copilot CLI session store", under: (h) => join(h, ".copilot", "session-store.db") },
|
|
31
|
+
{ name: "gemini", label: "Gemini CLI", under: (h) => join(h, ".gemini", "tmp") },
|
|
32
|
+
{ name: "cline", label: "Cline tasks", under: (h) => join(h, ".cline", "data", "tasks") },
|
|
33
|
+
{ name: "amp", label: "Amp", under: (h) => join(h, ".amp") },
|
|
34
|
+
{
|
|
35
|
+
name: "claude-desktop",
|
|
36
|
+
label: "Claude Desktop agent-mode sessions",
|
|
37
|
+
under: (h) => join(h, "Library", "Application Support", "Claude", "local-agent-mode-sessions"),
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
/** Classify every candidate against the database in one pass: managed by a
|
|
41
|
+
* live narrative (any brane), absorbed before into `braneId` (and whether
|
|
42
|
+
* the file has changed since), or new to that brane. Shared by the survey
|
|
43
|
+
* and the import so they cannot disagree. */
|
|
44
|
+
export function classifySessions(db, source, candidates, braneId) {
|
|
45
|
+
const out = new Map();
|
|
46
|
+
if (candidates.length === 0)
|
|
47
|
+
return out;
|
|
48
|
+
// Live narratives of this agent type: the session ids they have bound.
|
|
49
|
+
const managed = new Map();
|
|
50
|
+
const rows = db
|
|
51
|
+
.prepare(`SELECT id, agent_session_id, session_ids FROM narratives
|
|
52
|
+
WHERE agent_type = ? AND role != 'absorbed'
|
|
53
|
+
AND (agent_session_id IS NOT NULL OR session_ids IS NOT NULL)`)
|
|
54
|
+
.all(source.name);
|
|
55
|
+
for (const r of rows) {
|
|
56
|
+
if (r.agent_session_id)
|
|
57
|
+
managed.set(r.agent_session_id, r.id);
|
|
58
|
+
if (r.session_ids) {
|
|
59
|
+
try {
|
|
60
|
+
const ids = JSON.parse(r.session_ids);
|
|
61
|
+
if (Array.isArray(ids))
|
|
62
|
+
for (const id of ids)
|
|
63
|
+
if (typeof id === "string")
|
|
64
|
+
managed.set(id, r.id);
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
// malformed column value; agent_session_id above still counts
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const absorbed = db.prepare(`SELECT id FROM narratives
|
|
72
|
+
WHERE agent_type = ? AND role = 'absorbed' AND agent_session_id = ? AND brane_id = ?`);
|
|
73
|
+
const fileRow = db.prepare("SELECT bytes, mtime, parser_version FROM absorb_files WHERE brane_id = ? AND provider = ? AND external_id = ?");
|
|
74
|
+
for (const c of candidates) {
|
|
75
|
+
const managedBy = managed.get(c.externalId) ?? null;
|
|
76
|
+
const abs = absorbed.get(source.name, c.externalId, braneId);
|
|
77
|
+
const f = fileRow.get(braneId, source.name, c.externalId);
|
|
78
|
+
// Unchanged means nothing new could come of reading it: the same
|
|
79
|
+
// bytes, read last time by a parser that knew what this one knows.
|
|
80
|
+
const sameFile = !!f && f.bytes === c.bytes && f.mtime === c.updatedAt;
|
|
81
|
+
const current = !!f && f.parser_version >= source.parserVersion;
|
|
82
|
+
out.set(c.externalId, {
|
|
83
|
+
managedBy,
|
|
84
|
+
absorbedBy: abs?.id ?? null,
|
|
85
|
+
unchanged: sameFile && current,
|
|
86
|
+
reparse: sameFile && !current,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return out;
|
|
90
|
+
}
|
|
91
|
+
export function surveyAbsorbSources(db, home) {
|
|
92
|
+
const sources = [];
|
|
93
|
+
for (const src of LOCAL_SOURCES) {
|
|
94
|
+
const root = src.locate(home);
|
|
95
|
+
const report = {
|
|
96
|
+
name: src.name,
|
|
97
|
+
label: labelFor(src.name),
|
|
98
|
+
path: toPortablePath(root ?? defaultPathFor(src.name, home)),
|
|
99
|
+
found: root !== null,
|
|
100
|
+
supported: true,
|
|
101
|
+
};
|
|
102
|
+
if (root) {
|
|
103
|
+
const candidates = src.survey(root);
|
|
104
|
+
// The survey answers for the brane a plain `brane absorb <source>`
|
|
105
|
+
// would target — the one derived from the account — since that is
|
|
106
|
+
// the import it is previewing.
|
|
107
|
+
const status = classifySessions(db, src, candidates, deriveBraneId(src.name, src.identity(home).id));
|
|
108
|
+
const s = { total: 0, new: 0, changed: 0, unchanged: 0, reparse: 0, managed: 0, bytes: 0, folds: 0, oldest: null, newest: null };
|
|
109
|
+
const folds = new Set();
|
|
110
|
+
for (const c of candidates) {
|
|
111
|
+
s.total++;
|
|
112
|
+
s.bytes += c.bytes;
|
|
113
|
+
if (c.cwd)
|
|
114
|
+
folds.add(c.cwd);
|
|
115
|
+
if (c.startedAt !== null && (s.oldest === null || c.startedAt < s.oldest))
|
|
116
|
+
s.oldest = c.startedAt;
|
|
117
|
+
if (s.newest === null || c.updatedAt > s.newest)
|
|
118
|
+
s.newest = c.updatedAt;
|
|
119
|
+
const st = status.get(c.externalId);
|
|
120
|
+
if (st.managedBy)
|
|
121
|
+
s.managed++;
|
|
122
|
+
else if (st.absorbedBy)
|
|
123
|
+
(st.unchanged ? s.unchanged++ : st.reparse ? s.reparse++ : s.changed++);
|
|
124
|
+
else
|
|
125
|
+
s.new++;
|
|
126
|
+
}
|
|
127
|
+
s.folds = folds.size;
|
|
128
|
+
report.sessions = s;
|
|
129
|
+
}
|
|
130
|
+
sources.push(report);
|
|
131
|
+
}
|
|
132
|
+
for (const probe of PROBES) {
|
|
133
|
+
const path = probe.under(home);
|
|
134
|
+
sources.push({
|
|
135
|
+
name: probe.name,
|
|
136
|
+
label: probe.label,
|
|
137
|
+
path: toPortablePath(path),
|
|
138
|
+
found: existsSync(path) && !isEmptyDir(path),
|
|
139
|
+
supported: false,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
return { home, sources };
|
|
143
|
+
}
|
|
144
|
+
function isEmptyDir(path) {
|
|
145
|
+
try {
|
|
146
|
+
return statSync(path).isDirectory() && readdirSync(path).length === 0;
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
function labelFor(name) {
|
|
153
|
+
switch (name) {
|
|
154
|
+
case "claude":
|
|
155
|
+
return "Claude Code sessions";
|
|
156
|
+
default:
|
|
157
|
+
return name;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function defaultPathFor(name, home) {
|
|
161
|
+
switch (name) {
|
|
162
|
+
case "claude":
|
|
163
|
+
return join(home, ".claude", "projects");
|
|
164
|
+
default:
|
|
165
|
+
return home;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=sources.js.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The environment variables that identify one agent session, which nothing
|
|
3
|
+
* the daemon starts may inherit.
|
|
4
|
+
*
|
|
5
|
+
* A daemon restarted from an agent's shell (as /rrr does) inherits that
|
|
6
|
+
* agent's environment, and so does every tmux server and session it then
|
|
7
|
+
* starts. Brane's own pair would let another session act as that agent
|
|
8
|
+
* (claude-jrjh1e8w:10). The harness's session variables do damage too: the
|
|
9
|
+
* MCP bridge forwards `CLAUDE_CODE_SESSION_ID` as its author's session, so a
|
|
10
|
+
* crush agent spawned by such a daemon stamped every narration with the
|
|
11
|
+
* restarting Claude session's id (claude-eiuzl79r:33), and carried a copy of
|
|
12
|
+
* that session's `CLAUDE_CODE_MESSAGING_TOKEN`. Claude overrides these for
|
|
13
|
+
* its own children; other harnesses do not.
|
|
14
|
+
*
|
|
15
|
+
* Only session-scoped names belong here. User configuration that happens to
|
|
16
|
+
* share a prefix (`CLAUDE_CODE_USE_BEDROCK`, `CLAUDE_CODE_MAX_OUTPUT_TOKENS`)
|
|
17
|
+
* is the operator's and passes through.
|
|
18
|
+
*/
|
|
19
|
+
export const INHERITED_AGENT_ENV = [
|
|
20
|
+
"BRANE_NARRATIVE_ID",
|
|
21
|
+
"BRANE_NARRATIVE_SECRET",
|
|
22
|
+
"CLAUDECODE",
|
|
23
|
+
"CLAUDE_CODE_SESSION_ID",
|
|
24
|
+
"CLAUDE_CODE_CHILD_SESSION",
|
|
25
|
+
"CLAUDE_CODE_ENTRYPOINT",
|
|
26
|
+
"CLAUDE_CODE_EXECPATH",
|
|
27
|
+
"CLAUDE_CODE_MESSAGING_SOCKET",
|
|
28
|
+
"CLAUDE_CODE_MESSAGING_TOKEN",
|
|
29
|
+
"CLAUDE_CODE_SESSION_ATTENDED",
|
|
30
|
+
"CLAUDE_CODE_SSE_PORT",
|
|
31
|
+
"CLAUDE_PID",
|
|
32
|
+
];
|
|
33
|
+
/** `env` without any inherited agent-session variable. */
|
|
34
|
+
export function withoutAgentEnv(env) {
|
|
35
|
+
const out = { ...env };
|
|
36
|
+
for (const name of INHERITED_AGENT_ENV)
|
|
37
|
+
delete out[name];
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
40
|
+
/** A shell prefix that runs a command with every inherited agent-session
|
|
41
|
+
* variable unset, for commands tmux starts from its global env. */
|
|
42
|
+
export function unsetAgentEnvPrefix() {
|
|
43
|
+
return `env ${INHERITED_AGENT_ENV.map((name) => `-u ${name}`).join(" ")}`;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=agent-env.js.map
|