notesoup 0.61.0 → 0.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/plugins/marketplace.json +15 -0
- package/README.md +14 -11
- package/dist/plugins/antigravity/src/cli.d.ts +1 -0
- package/dist/plugins/antigravity/src/cli.js +23 -0
- package/dist/plugins/antigravity/src/hooks.d.ts +18 -0
- package/dist/plugins/antigravity/src/hooks.js +53 -0
- package/dist/plugins/antigravity/src/identity.d.ts +26 -0
- package/dist/plugins/antigravity/src/identity.js +129 -0
- package/dist/plugins/claude/src/helper.js +24 -5
- package/dist/plugins/claude/src/text.d.ts +7 -0
- package/dist/plugins/claude/src/text.js +12 -1
- package/dist/plugins/codex/src/hooks.js +1 -0
- package/dist/plugins/codex/src/identity.d.ts +6 -1
- package/dist/plugins/codex/src/identity.js +13 -1
- package/dist/plugins/codex/src/mcp.d.ts +35 -7
- package/dist/plugins/codex/src/mcp.js +26 -88
- package/dist/plugins/codex/src/text.js +3 -3
- package/dist/plugins/dsh/tools.js +8 -4
- package/dist/plugins/mcp/operations.d.ts +15 -0
- package/dist/plugins/mcp/operations.js +43 -0
- package/dist/plugins/mcp/server.d.ts +14 -0
- package/dist/plugins/mcp/server.js +13 -0
- package/dist/plugins/pi/budget.d.ts +4 -1
- package/dist/plugins/pi/budget.js +35 -8
- package/dist/plugins/pi/entries.d.ts +2 -0
- package/dist/plugins/pi/entries.js +2 -0
- package/dist/plugins/pi/history-tools.js +2 -1
- package/dist/plugins/pi/history.js +18 -1
- package/dist/plugins/pi/notes/tools.js +7 -3
- package/dist/plugins/pi/render.d.ts +7 -1
- package/dist/plugins/pi/render.js +2 -2
- package/dist/plugins/pi/reset/artifacts.d.ts +1 -1
- package/dist/plugins/pi/reset/artifacts.js +4 -4
- package/dist/plugins/pi/reset/lifecycle.d.ts +9 -2
- package/dist/plugins/pi/reset/lifecycle.js +109 -31
- package/dist/plugins/pi/runtime.js +104 -63
- package/dist/plugins/pi/tool-result.js +7 -7
- package/dist/plugins/pi/window.d.ts +25 -3
- package/dist/plugins/pi/window.js +219 -9
- package/dist/src/boot/render.js +18 -15
- package/dist/src/boot/text.d.ts +3 -1
- package/dist/src/boot/text.js +22 -20
- package/dist/src/budget/text.d.ts +7 -3
- package/dist/src/budget/text.js +24 -15
- package/dist/src/history/claude.d.ts +2 -0
- package/dist/src/history/claude.js +46 -0
- package/dist/src/history/codex-transcript.js +7 -5
- package/dist/src/history/codex.js +3 -0
- package/dist/src/history/corpus.d.ts +28 -1
- package/dist/src/history/corpus.js +40 -0
- package/dist/src/history/history.d.ts +37 -46
- package/dist/src/history/history.js +21 -40
- package/dist/src/history/local.js +67 -32
- package/dist/src/history/pi.d.ts +2 -1
- package/dist/src/history/pi.js +122 -48
- package/dist/src/history/prefilter.js +76 -19
- package/dist/src/history/query.d.ts +28 -49
- package/dist/src/history/query.js +83 -68
- package/dist/src/history/summary-cache.d.ts +8 -1
- package/dist/src/history/summary-cache.js +138 -12
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.js +1 -1
- package/dist/src/notes/errors.d.ts +1 -1
- package/dist/src/notes/frontmatter.d.ts +0 -2
- package/dist/src/notes/frontmatter.js +0 -2
- package/dist/src/notes/index.d.ts +1 -1
- package/dist/src/notes/index.js +1 -1
- package/dist/src/notes/policy.d.ts +15 -1
- package/dist/src/notes/policy.js +46 -5
- package/dist/src/notes/store.d.ts +12 -0
- package/dist/src/notes/store.js +16 -20
- package/dist/src/text-match.d.ts +10 -1
- package/dist/src/text-match.js +42 -3
- package/dist/src/tools/dream.d.ts +22 -93
- package/dist/src/tools/dream.js +30 -27
- package/dist/src/tools/history.d.ts +33 -26
- package/dist/src/tools/history.js +257 -163
- package/dist/src/tools/notes.d.ts +51 -163
- package/dist/src/tools/notes.js +146 -100
- package/dist/src/tools/output.d.ts +2 -1
- package/dist/src/tools/output.js +2 -1
- package/dist/src/tools/result.d.ts +4 -7
- package/dist/src/tools/result.js +8 -9
- package/dist/src/tools/schema.d.ts +4 -1
- package/dist/src/tools/schema.js +25 -1
- package/dist/test/agent-loop.test.js +394 -56
- package/dist/test/antigravity-live.test.d.ts +1 -0
- package/dist/test/antigravity-live.test.js +142 -0
- package/dist/test/antigravity-plugin.test.d.ts +1 -0
- package/dist/test/antigravity-plugin.test.js +101 -0
- package/dist/test/boot.integration.test.js +156 -15
- package/dist/test/budget-settings.integration.test.js +4 -4
- package/dist/test/claude-history.test.js +14 -13
- package/dist/test/claude-mod.test.js +199 -16
- package/dist/test/claude-validation.test.js +69 -2
- package/dist/test/codex-history.test.js +15 -3
- package/dist/test/codex-plugin.test.js +76 -38
- package/dist/test/dependencies.test.js +7 -3
- package/dist/test/dream-skill.test.js +3 -3
- package/dist/test/dream-tools.test.js +101 -56
- package/dist/test/dsh.test.js +34 -19
- package/dist/test/helpers/dependency-graph.js +2 -2
- package/dist/test/helpers/extension.d.ts +68 -3
- package/dist/test/helpers/extension.js +74 -5
- package/dist/test/history-corpus.test.js +79 -77
- package/dist/test/history-summary-cache.test.js +97 -9
- package/dist/test/history.integration.test.js +234 -168
- package/dist/test/host-neutral.test.js +69 -19
- package/dist/test/marker.test.js +1 -1
- package/dist/test/model-facing-text.test.js +13 -3
- package/dist/test/note-policy.test.js +96 -77
- package/dist/test/notes.integration.test.js +212 -94
- package/dist/test/notes.test.js +184 -113
- package/dist/test/pi-render.test.js +20 -12
- package/dist/test/project-namespace.test.js +3 -2
- package/dist/test/reset-lifecycle.test.js +12 -2
- package/docs/antigravity.md +44 -0
- package/docs/architecture.md +6 -4
- package/docs/claude-code-mod.md +7 -7
- package/docs/codex.md +36 -38
- package/docs/dsh.md +3 -3
- package/docs/history-sessions.md +28 -50
- package/docs/notes-library.md +4 -4
- package/docs/reset-lifecycle.md +1 -1
- package/docs/skills.md +3 -3
- package/docs/tool-results.md +47 -28
- package/package.json +3 -2
- package/playbook.md +1 -1
- package/plugins/antigravity/dist/antigravity/notesoup.js +26886 -0
- package/plugins/antigravity/hooks.json +7 -0
- package/plugins/antigravity/mcp_config.json +8 -0
- package/plugins/antigravity/plugin.json +6 -0
- package/plugins/antigravity/src/cli.ts +22 -0
- package/plugins/antigravity/src/hooks.ts +51 -0
- package/plugins/antigravity/src/identity.ts +127 -0
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/claude/dist/claude/helper.js +1108 -539
- package/plugins/claude/hooks/register.ts +202 -62
- package/plugins/claude/playbook.md +1 -1
- package/plugins/claude/skills/dream/SKILL.md +1 -1
- package/plugins/claude/skills/notesoup-guide/SKILL.md +92 -0
- package/plugins/claude/src/helper.ts +24 -5
- package/plugins/claude/src/text.ts +14 -1
- package/plugins/codex/.codex-plugin/plugin.json +8 -0
- package/plugins/codex/.mcp.json +11 -0
- package/plugins/codex/README.md +5 -21
- package/plugins/codex/dist/codex/notesoup.js +18480 -17946
- package/plugins/codex/src/hooks.ts +1 -0
- package/plugins/codex/src/identity.ts +14 -1
- package/plugins/codex/src/mcp.ts +28 -98
- package/plugins/codex/src/text.ts +3 -3
- package/plugins/dsh/tools.ts +8 -4
- package/plugins/mcp/operations.ts +50 -0
- package/plugins/mcp/server.ts +23 -0
- package/plugins/paseo/README.md +5 -10
- package/plugins/paseo/client/brain-empty-card.tsx +3 -3
- package/plugins/paseo/client/markdown.tsx +50 -38
- package/plugins/paseo/client/notes-op-card.tsx +12 -9
- package/plugins/paseo/client/paper-card.tsx +6 -5
- package/plugins/paseo/client/paper-palette.ts +2 -9
- package/plugins/paseo/client/sticky-card.tsx +2 -2
- package/plugins/paseo/client/tool-result.ts +7 -14
- package/plugins/paseo/package-lock.json +3406 -0
- package/plugins/paseo/package.json +1 -0
- package/plugins/paseo/test/markdown-core.test.ts +73 -66
- package/plugins/pi/budget.ts +31 -8
- package/plugins/pi/entries.ts +2 -0
- package/plugins/pi/history-tools.ts +2 -1
- package/plugins/pi/history.ts +30 -1
- package/plugins/pi/notes/tools.ts +7 -3
- package/plugins/pi/render.ts +6 -6
- package/plugins/pi/reset/artifacts.ts +4 -3
- package/plugins/pi/reset/lifecycle.ts +125 -32
- package/plugins/pi/runtime.ts +98 -62
- package/plugins/pi/tool-result.ts +8 -8
- package/plugins/pi/window.ts +210 -10
- package/skills/dream/SKILL.md +1 -1
- package/skills/notesoup-guide/SKILL.md +92 -0
- package/src/boot/render.ts +18 -15
- package/src/boot/text.ts +23 -19
- package/src/budget/text.ts +27 -15
- package/src/history/claude.ts +41 -0
- package/src/history/codex-transcript.ts +6 -4
- package/src/history/codex.ts +2 -0
- package/src/history/corpus.ts +51 -2
- package/src/history/history.ts +35 -44
- package/src/history/local.ts +67 -27
- package/src/history/pi.ts +113 -35
- package/src/history/prefilter.ts +73 -15
- package/src/history/query.ts +93 -73
- package/src/history/summary-cache.ts +142 -17
- package/src/index.ts +2 -2
- package/src/notes/errors.ts +1 -1
- package/src/notes/frontmatter.ts +0 -3
- package/src/notes/index.ts +1 -1
- package/src/notes/policy.ts +44 -5
- package/src/notes/store.ts +17 -20
- package/src/text-match.ts +46 -4
- package/src/tools/dream.ts +29 -31
- package/src/tools/history.ts +249 -142
- package/src/tools/notes.ts +145 -113
- package/src/tools/output.ts +2 -1
- package/src/tools/result.ts +12 -11
- package/src/tools/schema.ts +24 -1
- package/plugins/claude/skills/memory/SKILL.md +0 -69
- package/plugins/codex/mcp.json +0 -10
- package/plugins/codex/plugin.json +0 -6
- package/plugins/paseo/client/markdown-core.tsx +0 -189
- package/plugins/paseo/client/typography.ts +0 -24
- package/skills/memory/SKILL.md +0 -69
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Your agent's memory gets wiped when the context fills. notesoup makes that survivable: the agent writes itself a checkpoint before the wipe, wakes up in a fresh window, and digs up whatever it still needs from the old conversation. For you it's mostly invisible — an occasional notification, `/fresh-window` to force a fresh window, `/notesoup` to toggle.
|
|
4
4
|
|
|
5
|
-
The architecture — durable context windows, model-authored notes, searchable history — is the one OpenAI prototyped in Codex's `context_management` experiment and switched off ten days later, because it was welded to their backend. notesoup is the same architecture running entirely on your machine,
|
|
5
|
+
The architecture — durable context windows, model-authored notes, searchable history — is the one OpenAI prototyped in Codex's `context_management` experiment and switched off ten days later, because it was welded to their backend. notesoup is the same architecture running entirely on your machine, with a shared local store and host-specific plugins. No backend, no subscription gate, no server that can 404 at the worst possible moment. It can't be switched off from far away, because there is no far away.
|
|
6
6
|
|
|
7
7
|
## Renamed from pi-context
|
|
8
8
|
|
|
@@ -32,23 +32,23 @@ pi -e npm:notesoup
|
|
|
32
32
|
- **A boot block at every window head.** Pi keeps the window identity and notes snapshot in a hidden user-role boot; its fixed recovery protocol and pinned-page teaching live in a named system section. Every note body, including `@human` pins, stays user-role data. Claude, Codex and dsh keep their existing combined boot injection.
|
|
33
33
|
- **`get_context_remaining`** — how much room the brain has left before the hard-reserve wipe, including the warning runway.
|
|
34
34
|
- **Notes:** `notes_list` browses current notebooks by default. Add `glob` to select notebooks or paths and `query` for literal, case-insensitive matches with lines and read offsets. Open a page with `notes_read`, create or replace one with `notes_write`, and edit, move or crumple it with `notes_update`.
|
|
35
|
-
- **History:** `history_list` browses
|
|
36
|
-
- **Cross-session history:**
|
|
35
|
+
- **History:** `history_list` browses one timeline with exclusive integer `after` / `before` seqs (and optional ISO 8601 `since` / `until`), or lists recent sessions when given a wildcard `session`. `history_search` finds passages by required `query`, optionally with `context` around hits and ISO 8601 `since` / `until` bounds. `history_read` opens one event by seq.
|
|
36
|
+
- **Cross-session history:** all three tools accept a session ID or prefix (optionally qualified with `pi:`, `claude:`, `codex:` or `dsh:`). `history_list({ session: "*" })` gives a session overview (one representative event per session), and `history_search({ session: "*", query: "phrase" })` searches across local sessions. Copy the session heading, seq and any preview offset into `history_read`. Omit `session` for the current session. See [cross-session history](docs/history-sessions.md).
|
|
37
37
|
|
|
38
38
|
- **Runtime toggle** — `/notesoup off` stops new automatic resets; `/notesoup on` re-enables them; bare `/notesoup` reports the state.
|
|
39
39
|
- **Context cap (Pi and Claude)** — `/notesoup cap 100k` limits the capacity used by notesoup's budget to `min(model window, 100000)`. Existing reserves and warning margins are deducted from that capacity; 100k is not the used-token reset point. `/notesoup cap` shows the configured cap and `/notesoup cap off` removes it. Whole tokens and decimal `k`/`m` suffixes are accepted; caps too small for the host's reserves are refused. The cap applies only to the running session, survives notesoup resets and model changes, and is lost on reload/restart/session switch. It never writes host settings or environment variables, changes the provider's advertised model window, or enables disabled automatic resets.
|
|
40
40
|
|
|
41
41
|
## Per-note policy
|
|
42
42
|
|
|
43
|
-
Notes have optional `pinned`, `
|
|
43
|
+
Notes have optional `pinned`, `readonly`, and `description` fields settable through `notes_write` and `notes_update` (and `budget` in frontmatter for manual overrides):
|
|
44
44
|
|
|
45
45
|
```json
|
|
46
|
-
{ "address": "@project/decisions.md", "pinned": true, "
|
|
46
|
+
{ "address": "@project/decisions.md", "pinned": true, "readonly": false, "description": "Architecture choices and why they stand." }
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
- **Pinned** notes are injected
|
|
50
|
-
- **Budget**
|
|
51
|
-
- **Description** is an optional single-line summary (
|
|
49
|
+
- **Pinned** notes are injected at boot, truncated to their UTF-8 byte budget on a character boundary if oversized (with `[truncated at X/Y; offset_chars=X]`). Root `CHEATSHEET.md` defaults to pinned; every other page defaults to unpinned, and explicit `pinned: false` overrides even a default page. Live pins per notebook are capped (crumpled notes do not count); writes, restores, or moves that would exceed the cap refuse without mutating either note, and manually over-cap notebooks get a boot warning naming the omitted pins. Unpinned live notes appear in a bounded auto-generated per-shelf index at boot (sorted by recency).
|
|
50
|
+
- **Budget** is a per-note UTF-8 byte budget (default **4096 bytes** for root `CHEATSHEET.md`, **8192 bytes** for ordinary notes; overridable in frontmatter). Over-budget writes and updates still save whole with a `<notesoup:warning>` notice; boot truncates over-budget pinned bodies. Tool results, read metadata, and list/search expose effective policy and warnings.
|
|
51
|
+
- **Description** is an optional single-line summary (whitespace is collapsed and an empty string clears it). Oversized descriptions still save with a warning and truncate in the boot shelf index. It is rendered in the boot shelf index (falling back to the first heading/line when absent) as well as `notes_read` metadata and `notes_list` rows.
|
|
52
52
|
- **Readonly** defaults to false. `readonly: true` is a **soft lock**, not security: mutations refuse until explicitly unlocked with `readonly: false`, either by itself or in the same call as the requested changes. A write can create and lock a note together. Reads still record access metadata; direct filesystem edits can bypass the lock.
|
|
53
53
|
|
|
54
54
|
Absent fields stay absent on disk. On move/rename, implicit pin defaults follow the new root path; explicit true/false values travel with the note. The original origin, other metadata, and unknown frontmatter are preserved. See the [library API](docs/notes-library.md#per-note-policy) for details.
|
|
@@ -94,8 +94,9 @@ Environment variables:
|
|
|
94
94
|
- [Standalone notes library](docs/notes-library.md) — use the notes store from Node, no Pi required
|
|
95
95
|
- [DeepSeek Harness](docs/dsh.md) — adapter and profile patch for dsh 0.2.1-alpha.2
|
|
96
96
|
- [Claude Code Mod](docs/claude-code-mod.md) — early-access notes and persisted-session history tools for Claude Code
|
|
97
|
-
- [Codex plugin](docs/codex.md) — native notes boot
|
|
98
|
-
- [
|
|
97
|
+
- [Codex plugin](docs/codex.md) — native notes boot and persisted history; compatibility is determined from host data, not a CLI version number
|
|
98
|
+
- [Antigravity plugin](docs/antigravity.md) — automatic startup notes and the four notes tools over stdio MCP
|
|
99
|
+
- [Skills and dream](docs/skills.md) — `/skill:notesoup-guide`, `/skill:dream`, the `dream_*` tools and the dream lock
|
|
99
100
|
|
|
100
101
|
## Development
|
|
101
102
|
|
|
@@ -115,7 +116,9 @@ The repository splits host-neutral code from host plugins:
|
|
|
115
116
|
| `plugins/pi/` | The Pi extension (`plugins/pi/index.ts` is what `pi.extensions` loads from source). |
|
|
116
117
|
| `plugins/claude/` | The self-contained Claude Code plugin (`.claude-plugin/`, `hooks/`, bundled `dist/claude/helper.js`, skills and playbook), with its adapter sources in `plugins/claude/src/`. |
|
|
117
118
|
| `plugins/dsh/` | The Cordis rows published as `notesoup/dsh` and `notesoup/dsh/engine`. |
|
|
118
|
-
| `plugins/codex/` | The
|
|
119
|
+
| `plugins/codex/` | The native Codex plugin: manifests, hooks, and the bundled `dist/codex/notesoup.js` MCP/hook helper. |
|
|
120
|
+
|
|
121
|
+
`plugins/mcp/` exposes the core tool schemas and results over stdio; `plugins/antigravity/` and `plugins/codex/` supply per-call identity and their own lifecycle hooks. Pi keeps using its native tool API.
|
|
119
122
|
|
|
120
123
|
Each plugin owns its host's words — Pi's pre-reset hints and `last_word` nudge live in `plugins/pi/text.ts`, Claude's reset and missing-history prose in `plugins/claude/src/text.ts` — while the shared boot, protocol and warning bodies stay in `src/boot/text.ts` and `src/budget/text.ts`.
|
|
121
124
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { runToolServer } from "../../mcp/server.js";
|
|
2
|
+
import { createNoteTools } from "../../mcp/operations.js";
|
|
3
|
+
import { preInvocation } from "./hooks.js";
|
|
4
|
+
import { resolveContext } from "./identity.js";
|
|
5
|
+
async function main() {
|
|
6
|
+
if (process.argv[2] === "mcp") {
|
|
7
|
+
await runToolServer({ name: "notesoup", ...createNoteTools(meta => resolveContext(meta)) });
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
if (process.argv[2] !== "pre-invocation")
|
|
11
|
+
throw new Error("Expected mcp or pre-invocation.");
|
|
12
|
+
let raw = "";
|
|
13
|
+
for await (const chunk of process.stdin) {
|
|
14
|
+
raw += chunk;
|
|
15
|
+
if (Buffer.byteLength(raw) > 1024 * 1024)
|
|
16
|
+
throw new Error("Hook input exceeds 1 MiB.");
|
|
17
|
+
}
|
|
18
|
+
const value = JSON.parse(raw);
|
|
19
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
20
|
+
throw new Error("Expected a hook object.");
|
|
21
|
+
process.stdout.write(JSON.stringify(await preInvocation(value)) + "\n");
|
|
22
|
+
}
|
|
23
|
+
main().catch(error => { process.stderr.write(`notesoup: ${error instanceof Error ? error.message : String(error)}\n`); process.exitCode = 1; });
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type InjectedStep = {
|
|
2
|
+
systemMessage: {
|
|
3
|
+
systemMessage: string;
|
|
4
|
+
};
|
|
5
|
+
} | {
|
|
6
|
+
userMessage: string;
|
|
7
|
+
} | {
|
|
8
|
+
errorMessage: {
|
|
9
|
+
userMessage: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
type HookOutput = {
|
|
13
|
+
injectSteps?: InjectedStep[];
|
|
14
|
+
terminationBehavior?: "terminate";
|
|
15
|
+
};
|
|
16
|
+
/** PreInvocation is the host's model boundary, for both a new conversation and subsequent invocations. */
|
|
17
|
+
export declare function preInvocation(payload: Record<string, unknown>, env?: NodeJS.ProcessEnv): Promise<HookOutput>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { renderBootContext } from "../../../src/boot/render.js";
|
|
2
|
+
import { loadNotesSnapshot } from "../../../src/boot/snapshot.js";
|
|
3
|
+
import { DEFAULT_BOOT_TOOL_NAMES, MAPS_BLOCK, renderProtocolBlock } from "../../../src/boot/text.js";
|
|
4
|
+
import { AntigravityIdentityError, bindingFromHook, contextForBinding, invalidateBinding, readBinding, writeBinding } from "./identity.js";
|
|
5
|
+
const TOOLS = {
|
|
6
|
+
...DEFAULT_BOOT_TOOL_NAMES,
|
|
7
|
+
historySentence: "Notesoup has no Antigravity history tool. Record important details in notes rather than relying on a Notesoup history index.",
|
|
8
|
+
budgetParagraph: "Notesoup has no Antigravity context-budget or reset tool. The host manages its own conversation context; this plugin does not promise recovery after native context compaction.",
|
|
9
|
+
};
|
|
10
|
+
const MAX_BOOT_BYTES = 128 * 1024;
|
|
11
|
+
function inject(message) { return { injectSteps: [{ systemMessage: { systemMessage: message } }] }; }
|
|
12
|
+
/** PreInvocation is the host's model boundary, for both a new conversation and subsequent invocations. */
|
|
13
|
+
export async function preInvocation(payload, env = process.env) {
|
|
14
|
+
let binding;
|
|
15
|
+
try {
|
|
16
|
+
if (payload.hookEventName !== "PreInvocation")
|
|
17
|
+
throw new Error("Unexpected hook event.");
|
|
18
|
+
binding = bindingFromHook(payload, env);
|
|
19
|
+
const existing = await readBinding(env, binding.conversationId);
|
|
20
|
+
if (existing && ((existing.rootConversationId !== undefined && binding.rootConversationId !== undefined && existing.rootConversationId !== binding.rootConversationId) || (existing.parentConversationId !== undefined && binding.parentConversationId !== undefined && existing.parentConversationId !== binding.parentConversationId)))
|
|
21
|
+
throw new Error("Conversation ancestry changed; refusing to overwrite an existing binding.");
|
|
22
|
+
// Retain known ancestry through later hooks that omit these optional fields.
|
|
23
|
+
binding = { ...binding, bootEmitted: existing?.bootEmitted ?? false, ...(existing?.rootConversationId === undefined ? {} : { rootConversationId: existing.rootConversationId }), ...(existing?.parentConversationId === undefined ? {} : { parentConversationId: existing.parentConversationId }) };
|
|
24
|
+
await writeBinding(env, binding);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
if (!(error instanceof AntigravityIdentityError && error.code === "mismatched_home"))
|
|
28
|
+
await invalidateBinding(env, payload.conversationId).catch(() => { });
|
|
29
|
+
// Never let a failed identity refresh continue the invocation with an older model/cwd.
|
|
30
|
+
return { injectSteps: [{ errorMessage: { userMessage: `Notesoup: could not establish this invocation (${error instanceof Error ? error.message : String(error)}).` } }], terminationBehavior: "terminate" };
|
|
31
|
+
}
|
|
32
|
+
// The first PreInvocation is a model boundary for both root and child conversations.
|
|
33
|
+
if (binding.bootEmitted)
|
|
34
|
+
return {};
|
|
35
|
+
try {
|
|
36
|
+
const { identity } = contextForBinding(binding);
|
|
37
|
+
const notes = await loadNotesSnapshot(identity, Date.now());
|
|
38
|
+
const protocol = `${renderProtocolBlock(TOOLS, identity.agent)}\n\n${MAPS_BLOCK}`;
|
|
39
|
+
const boot = renderBootContext({
|
|
40
|
+
agentName: identity.agent, modelName: binding.model, notes, tools: TOOLS,
|
|
41
|
+
tree: { trunk: `Antigravity conversation ${binding.conversationId}`, windows: [{ shortName: "conversation", isCurrent: true }] },
|
|
42
|
+
});
|
|
43
|
+
if (Buffer.byteLength(protocol + boot, "utf8") > MAX_BOOT_BYTES)
|
|
44
|
+
throw new Error("Boot exceeds 128 KiB; slim the pinned notes. No partial boot was injected.");
|
|
45
|
+
await writeBinding(env, { ...binding, bootEmitted: true });
|
|
46
|
+
return { injectSteps: [{ systemMessage: { systemMessage: protocol } }, { userMessage: boot }] };
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
// Do not place diagnostics derived from note contents into a trusted message.
|
|
50
|
+
process.stderr.write(`notesoup: boot failed: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
51
|
+
return inject("Notesoup: could not render the notes boot. No partial boot was injected; use notes_list to inspect the library.");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type NotesToolContext } from "../../../src/tools/notes-context.js";
|
|
2
|
+
export declare class AntigravityIdentityError extends Error {
|
|
3
|
+
readonly code: string;
|
|
4
|
+
constructor(code: string, message: string);
|
|
5
|
+
}
|
|
6
|
+
export declare function conversationId(value: unknown): string;
|
|
7
|
+
export declare function notesHome(env: NodeJS.ProcessEnv): string;
|
|
8
|
+
export type ConversationBinding = Readonly<{
|
|
9
|
+
conversationId: string;
|
|
10
|
+
rootConversationId?: string;
|
|
11
|
+
parentConversationId?: string;
|
|
12
|
+
cwd: string;
|
|
13
|
+
model: string;
|
|
14
|
+
/** Absent in many native hooks, including 1.5.17's dynamically defined subagents. */
|
|
15
|
+
agent?: string;
|
|
16
|
+
home: string;
|
|
17
|
+
bootEmitted: boolean;
|
|
18
|
+
}>;
|
|
19
|
+
export declare function bindingFromHook(payload: Record<string, unknown>, env: NodeJS.ProcessEnv): ConversationBinding;
|
|
20
|
+
export declare function contextForBinding(binding: ConversationBinding, agent?: string): NotesToolContext;
|
|
21
|
+
export declare function readBinding(env: NodeJS.ProcessEnv, id: string): Promise<ConversationBinding | undefined>;
|
|
22
|
+
export declare function writeBinding(env: NodeJS.ProcessEnv, binding: ConversationBinding): Promise<void>;
|
|
23
|
+
/** A hook lacking current model/cwd facts must not leave a usable older binding. */
|
|
24
|
+
export declare function invalidateBinding(env: NodeJS.ProcessEnv, id: unknown): Promise<void>;
|
|
25
|
+
/** Never fall back to root ID, MCP process cwd, a previous call, or model-supplied arguments. */
|
|
26
|
+
export declare function resolveContext(meta: Record<string, unknown>, env?: NodeJS.ProcessEnv): Promise<NotesToolContext>;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { mkdir, readFile, rename, unlink, writeFile } from "node:fs/promises";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
5
|
+
import { projectKey, slugify, snapshotNotesIdentity } from "../../../src/notes/index.js";
|
|
6
|
+
import { NAMELESS_AGENT } from "../../../src/boot/text.js";
|
|
7
|
+
import { notesToolContext } from "../../../src/tools/notes-context.js";
|
|
8
|
+
const PREFIX = "antigravity.google/";
|
|
9
|
+
const UUID = /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i;
|
|
10
|
+
export class AntigravityIdentityError extends Error {
|
|
11
|
+
code;
|
|
12
|
+
constructor(code, message) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.code = code;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function text(value) {
|
|
18
|
+
return typeof value === "string" && value.trim() !== "" ? value.trim() : undefined;
|
|
19
|
+
}
|
|
20
|
+
export function conversationId(value) {
|
|
21
|
+
if (typeof value !== "string" || !UUID.test(value))
|
|
22
|
+
throw new AntigravityIdentityError("invalid_conversation", "Antigravity did not supply a valid native conversation ID.");
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
function modelName(value) {
|
|
26
|
+
const id = text(value)?.split("/").pop();
|
|
27
|
+
if (!id || !/[a-z0-9]/i.test(id) || /^(?:auto|default)$/i.test(id))
|
|
28
|
+
throw new AntigravityIdentityError("missing_model", "The Antigravity hook did not name a concrete model; select a specific model before using Notesoup.");
|
|
29
|
+
return slugify(id);
|
|
30
|
+
}
|
|
31
|
+
function absolute(value, field) {
|
|
32
|
+
if (typeof value !== "string" || !isAbsolute(value) || value.includes("\0"))
|
|
33
|
+
throw new AntigravityIdentityError("invalid_identity", `Antigravity ${field} is not an absolute path.`);
|
|
34
|
+
return resolve(value);
|
|
35
|
+
}
|
|
36
|
+
export function notesHome(env) {
|
|
37
|
+
return env.NOTESOUP_HOME === undefined ? join(homedir(), ".agents", "notes") : absolute(env.NOTESOUP_HOME, "NOTESOUP_HOME");
|
|
38
|
+
}
|
|
39
|
+
export function bindingFromHook(payload, env) {
|
|
40
|
+
const id = conversationId(payload.conversationId);
|
|
41
|
+
const parent = text(payload.parentConversationId);
|
|
42
|
+
const root = text(payload.rootConversationId);
|
|
43
|
+
if (parent !== undefined)
|
|
44
|
+
conversationId(parent);
|
|
45
|
+
if (root !== undefined)
|
|
46
|
+
conversationId(root);
|
|
47
|
+
if (parent === id || (root === id && parent !== undefined))
|
|
48
|
+
throw new AntigravityIdentityError("invalid_identity", "The Antigravity hook's conversation ancestry is inconsistent.");
|
|
49
|
+
const agent = text(payload.agentName);
|
|
50
|
+
return {
|
|
51
|
+
conversationId: id, ...(root === undefined ? {} : { rootConversationId: root }), ...(parent === undefined ? {} : { parentConversationId: parent }),
|
|
52
|
+
cwd: absolute(payload.cwd, "hook cwd"), model: modelName(payload.modelName),
|
|
53
|
+
...(agent === undefined ? {} : { agent: slugify(agent) }), home: notesHome(env), bootEmitted: false,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function bindingPath(env, id) {
|
|
57
|
+
return join(absolute(env.PLUGIN_DATA, "PLUGIN_DATA"), "conversations", `${conversationId(id)}.json`);
|
|
58
|
+
}
|
|
59
|
+
export function contextForBinding(binding, agent = binding.agent ?? NAMELESS_AGENT) {
|
|
60
|
+
return notesToolContext(snapshotNotesIdentity({
|
|
61
|
+
home: binding.home, sessionId: binding.conversationId, projectKey: projectKey(binding.cwd, binding.home),
|
|
62
|
+
agent, model: binding.model,
|
|
63
|
+
}), binding.cwd);
|
|
64
|
+
}
|
|
65
|
+
export async function readBinding(env, id) {
|
|
66
|
+
let content;
|
|
67
|
+
try {
|
|
68
|
+
content = await readFile(bindingPath(env, id), "utf8");
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
if (error.code === "ENOENT")
|
|
72
|
+
return undefined;
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
const row = JSON.parse(content);
|
|
76
|
+
if (!row || row.conversationId !== id || typeof row.bootEmitted !== "boolean" || typeof row.model !== "string" || slugify(row.model) !== row.model ||
|
|
77
|
+
(row.agent !== undefined && (typeof row.agent !== "string" || slugify(row.agent) !== row.agent)))
|
|
78
|
+
throw new AntigravityIdentityError("invalid_binding", "Antigravity's saved conversation binding is invalid.");
|
|
79
|
+
if (row.rootConversationId !== undefined)
|
|
80
|
+
conversationId(row.rootConversationId);
|
|
81
|
+
if (row.parentConversationId !== undefined)
|
|
82
|
+
conversationId(row.parentConversationId);
|
|
83
|
+
if (row.parentConversationId === id || (row.rootConversationId === id && row.parentConversationId !== undefined))
|
|
84
|
+
throw new AntigravityIdentityError("invalid_binding", "Antigravity's saved conversation ancestry is inconsistent.");
|
|
85
|
+
absolute(row.cwd, "saved cwd");
|
|
86
|
+
if (absolute(row.home, "saved notes home") !== notesHome(env))
|
|
87
|
+
throw new AntigravityIdentityError("mismatched_home", "The conversation binding belongs to another NOTESOUP_HOME. Start a new conversation with the intended home.");
|
|
88
|
+
return row;
|
|
89
|
+
}
|
|
90
|
+
export async function writeBinding(env, binding) {
|
|
91
|
+
const path = bindingPath(env, binding.conversationId);
|
|
92
|
+
await mkdir(dirname(path), { recursive: true, mode: 0o700 });
|
|
93
|
+
const temp = `${path}.${randomUUID()}.tmp`;
|
|
94
|
+
try {
|
|
95
|
+
await writeFile(temp, `${JSON.stringify(binding)}\n`, { mode: 0o600 });
|
|
96
|
+
await rename(temp, path);
|
|
97
|
+
}
|
|
98
|
+
finally {
|
|
99
|
+
await unlink(temp).catch(() => { });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/** A hook lacking current model/cwd facts must not leave a usable older binding. */
|
|
103
|
+
export async function invalidateBinding(env, id) {
|
|
104
|
+
try {
|
|
105
|
+
await unlink(bindingPath(env, conversationId(id)));
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
if (error.code !== "ENOENT")
|
|
109
|
+
throw error;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/** Never fall back to root ID, MCP process cwd, a previous call, or model-supplied arguments. */
|
|
113
|
+
export async function resolveContext(meta, env = process.env) {
|
|
114
|
+
const id = conversationId(meta[`${PREFIX}conversation_id`]);
|
|
115
|
+
const root = conversationId(meta[`${PREFIX}root_conversation_id`]);
|
|
116
|
+
const binding = await readBinding(env, id);
|
|
117
|
+
if (!binding)
|
|
118
|
+
throw new AntigravityIdentityError("unknown_conversation", "No Notesoup hook binding exists for this Antigravity conversation. Enable the plugin hooks and start a model invocation in this conversation.");
|
|
119
|
+
const parent = text(meta[`${PREFIX}parent_conversation_id`]);
|
|
120
|
+
const agent = text(meta[`${PREFIX}agent_name`]);
|
|
121
|
+
if (parent !== undefined)
|
|
122
|
+
conversationId(parent);
|
|
123
|
+
if ((binding.rootConversationId !== undefined && binding.rootConversationId !== root) ||
|
|
124
|
+
(binding.parentConversationId !== undefined && parent !== undefined && parent !== binding.parentConversationId) ||
|
|
125
|
+
(binding.agent !== undefined && agent !== undefined && slugify(agent) !== binding.agent) || parent === id || (parent !== undefined && root === id)) {
|
|
126
|
+
throw new AntigravityIdentityError("mismatched_conversation", "The Antigravity call disagrees with its own hook identity; no notes were accessed.");
|
|
127
|
+
}
|
|
128
|
+
return contextForBinding(binding, agent === undefined ? binding.agent : slugify(agent));
|
|
129
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { realpathSync } from "node:fs";
|
|
1
|
+
import { readFileSync, realpathSync } from "node:fs";
|
|
2
2
|
import { pathToFileURL } from "node:url";
|
|
3
3
|
import { Check } from "typebox/value";
|
|
4
4
|
import { paramProblem } from "../../../src/tools/schema.js";
|
|
5
5
|
import { notesList, notesRead, notesUpdate, notesWrite } from "../../../src/tools/notes.js";
|
|
6
|
-
import { historyList, historyRead } from "../../../src/tools/history.js";
|
|
6
|
+
import { historyList, historySearch, historyRead } from "../../../src/tools/history.js";
|
|
7
7
|
import { localHistoryCorpus } from "../../../src/history/local.js";
|
|
8
8
|
import { readClaudeHistory } from "./history.js";
|
|
9
9
|
import { loadNotesSnapshot } from "../../../src/boot/snapshot.js";
|
|
10
10
|
import { renderBootBlock } from "../../../src/boot/render.js";
|
|
11
11
|
import { selectContinuation } from "../../../src/budget/text.js";
|
|
12
|
-
import { claudeHistoryGapNotice, claudeHistoryUnconfirmedSeq, CLAUDE_HISTORY_UNKNOWN_WINDOW, CLAUDE_HISTORY_UNAVAILABLE_SENTENCE, CLAUDE_WARNING_PROMPT } from "./text.js";
|
|
12
|
+
import { claudeCommandWarningContent, claudeHistoryGapNotice, claudeHistoryUnconfirmedSeq, CLAUDE_COMMAND_PROMPTED_HEAD, CLAUDE_HISTORY_UNKNOWN_WINDOW, CLAUDE_HISTORY_UNAVAILABLE_SENTENCE, CLAUDE_WARNING_PROMPT } from "./text.js";
|
|
13
13
|
import { resolveClaudeLimits } from "./thresholds.js";
|
|
14
14
|
import { parseContextCap } from "../../../src/budget/cap.js";
|
|
15
15
|
import { projectKey, snapshotNotesIdentity } from "../../../src/notes/index.js";
|
|
@@ -41,6 +41,7 @@ const OPERATIONS = {
|
|
|
41
41
|
};
|
|
42
42
|
const HISTORY_OPERATIONS = {
|
|
43
43
|
history_list: boundOperation(historyList),
|
|
44
|
+
history_search: boundOperation(historySearch),
|
|
44
45
|
history_read: boundOperation(historyRead),
|
|
45
46
|
};
|
|
46
47
|
function historySource(value, sessionId) {
|
|
@@ -51,6 +52,18 @@ function historySource(value, sessionId) {
|
|
|
51
52
|
throw new Error("Claude history binding belongs to a different session");
|
|
52
53
|
return source;
|
|
53
54
|
}
|
|
55
|
+
function readPluginVersion() {
|
|
56
|
+
for (const candidate of ["../../.claude-plugin/plugin.json", "../../../../package.json", "../../../package.json"]) {
|
|
57
|
+
try {
|
|
58
|
+
const parsed = JSON.parse(readFileSync(new URL(candidate, import.meta.url), "utf8"));
|
|
59
|
+
if (typeof parsed.version === "string" && parsed.version.length > 0)
|
|
60
|
+
return parsed.version;
|
|
61
|
+
}
|
|
62
|
+
catch { /* try the next layout */ }
|
|
63
|
+
}
|
|
64
|
+
return "dev";
|
|
65
|
+
}
|
|
66
|
+
const PLUGIN_VERSION = readPluginVersion();
|
|
54
67
|
export async function dispatch(request, historyOptions = {}) {
|
|
55
68
|
if (!request || typeof request !== "object" || Array.isArray(request))
|
|
56
69
|
throw new Error("malformed request");
|
|
@@ -72,12 +85,18 @@ export async function dispatch(request, historyOptions = {}) {
|
|
|
72
85
|
// The shared reset prose lives here, not in the sandboxed hooks module, so Pi and Claude
|
|
73
86
|
// cannot drift apart. The hooks module caches one copy per session.
|
|
74
87
|
if (value.op === "texts")
|
|
75
|
-
return {
|
|
88
|
+
return {
|
|
89
|
+
version: PLUGIN_VERSION,
|
|
90
|
+
warning: CLAUDE_WARNING_PROMPT,
|
|
91
|
+
commandBare: claudeCommandWarningContent(),
|
|
92
|
+
commandPrompted: CLAUDE_COMMAND_PROMPTED_HEAD,
|
|
93
|
+
historyUnavailableSentence: CLAUDE_HISTORY_UNAVAILABLE_SENTENCE,
|
|
94
|
+
};
|
|
76
95
|
// The caller draws once per artifact and caches the answer; text reads never draw.
|
|
77
96
|
if (value.op === "continuation") {
|
|
78
97
|
if (value.origin !== "normal" && value.origin !== "forced")
|
|
79
98
|
throw new Error("invalid reset origin");
|
|
80
|
-
return { text: selectContinuation(value.origin) };
|
|
99
|
+
return { text: selectContinuation(value.origin, { betweenTurns: value.betweenTurns === true }) };
|
|
81
100
|
}
|
|
82
101
|
// Threshold derivation crosses the boundary as raw facts: everything the engine could
|
|
83
102
|
// read, unvalidated. resolveClaudeLimits guards every field and never throws.
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
export declare const CLAUDE_HISTORY_UNAVAILABLE_SENTENCE = "History isn't available in this Claude session: no main transcript_path was supplied. Keep essential state in notes; don't pretend those notes are the missing transcript.";
|
|
3
3
|
/** The same notice as Pi; empty_brain's result explains Claude's deferred reset. */
|
|
4
4
|
export declare const CLAUDE_WARNING_PROMPT: string;
|
|
5
|
+
/** Manual close-out notices omit budget timing and never claim Claude's chat view is erased. */
|
|
6
|
+
export declare const CLAUDE_COMMAND_NOTICE: {
|
|
7
|
+
prompted: string;
|
|
8
|
+
bare: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const CLAUDE_COMMAND_PROMPTED_HEAD: string;
|
|
11
|
+
export declare function claudeCommandWarningContent(commandLine?: string): string;
|
|
5
12
|
export declare const CLAUDE_HISTORY_UNKNOWN_WINDOW = "Claude history cannot determine the current window ordinal across a missing ancestor; restore the ancestry or use a retained notesoup boot to re-anchor it.";
|
|
6
13
|
export declare function claudeHistoryUnconfirmedSeq(seq: number): string;
|
|
7
14
|
/** Bounded host-only evidence, outside event documents/search offsets and shared schemas. */
|
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
import { warningNotice } from "../../../src/budget/text.js";
|
|
1
|
+
import { COUNTDOWN_LINE, GUIDANCE_CLOSE_TAG, GUIDANCE_OPEN_TAG, WARNING_BODY, WARNING_CALL, warningNotice } from "../../../src/budget/text.js";
|
|
2
2
|
/** Claude's boot says history is missing rather than naming tools it cannot serve. */
|
|
3
3
|
export const CLAUDE_HISTORY_UNAVAILABLE_SENTENCE = "History isn't available in this Claude session: no main transcript_path was supplied. Keep essential state in notes; don't pretend those notes are the missing transcript.";
|
|
4
4
|
/** The same notice as Pi; empty_brain's result explains Claude's deferred reset. */
|
|
5
5
|
export const CLAUDE_WARNING_PROMPT = warningNotice();
|
|
6
|
+
/** Manual close-out notices omit budget timing and never claim Claude's chat view is erased. */
|
|
7
|
+
export const CLAUDE_COMMAND_NOTICE = {
|
|
8
|
+
prompted: "The human ran /empty. Save your notes now and call `empty_brain` immediately. The command below is context for your notes, not a task for the fresh window.",
|
|
9
|
+
bare: "The human ran /empty. Save your notes now and call `empty_brain` immediately.",
|
|
10
|
+
};
|
|
11
|
+
export const CLAUDE_COMMAND_PROMPTED_HEAD = `${GUIDANCE_OPEN_TAG}\n${CLAUDE_COMMAND_NOTICE.prompted}\n${WARNING_BODY}\n${WARNING_CALL}\n${COUNTDOWN_LINE}\n${GUIDANCE_CLOSE_TAG}`;
|
|
12
|
+
export function claudeCommandWarningContent(commandLine) {
|
|
13
|
+
if (commandLine)
|
|
14
|
+
return `${CLAUDE_COMMAND_PROMPTED_HEAD}\n${commandLine}`;
|
|
15
|
+
return `${GUIDANCE_OPEN_TAG}\n${CLAUDE_COMMAND_NOTICE.bare}\n${WARNING_BODY}\n${WARNING_CALL}\n${COUNTDOWN_LINE}\n${GUIDANCE_CLOSE_TAG}`;
|
|
16
|
+
}
|
|
6
17
|
export const CLAUDE_HISTORY_UNKNOWN_WINDOW = "Claude history cannot determine the current window ordinal across a missing ancestor; restore the ancestry or use a retained notesoup boot to re-anchor it.";
|
|
7
18
|
export function claudeHistoryUnconfirmedSeq(seq) {
|
|
8
19
|
return `Seq ${seq} is outside the confirmed selected history; it may be on another branch or beyond an unresolved ancestry gap.`;
|
|
@@ -122,6 +122,7 @@ async function startHook(event, payload, env) {
|
|
|
122
122
|
home: notesHome(env),
|
|
123
123
|
transcriptPath,
|
|
124
124
|
windowId: native.state.currentWindowId,
|
|
125
|
+
windowNumber: native.state.currentWindowNumber,
|
|
125
126
|
...(target.agentType === undefined ? {} : { agentType: target.agentType }),
|
|
126
127
|
boundAt: new Date().toISOString(),
|
|
127
128
|
};
|
|
@@ -16,12 +16,17 @@ export type ThreadBinding = Readonly<{
|
|
|
16
16
|
transcriptPath: string;
|
|
17
17
|
/** Native window at bind time; a later MCP call must name this same window. */
|
|
18
18
|
windowId: string;
|
|
19
|
+
/** The same native window's monotonic number, used in newer MCP metadata. */
|
|
20
|
+
windowNumber?: number;
|
|
19
21
|
agentType?: string;
|
|
20
22
|
boundAt: string;
|
|
21
23
|
}>;
|
|
22
24
|
export declare function safeThreadId(value: unknown, field?: string): string;
|
|
23
|
-
/** The
|
|
25
|
+
/** The hook receives the native plugin's data directory directly from Codex. */
|
|
24
26
|
export declare function pluginDataRoot(env?: NodeJS.ProcessEnv): string;
|
|
27
|
+
/** Native Codex MCP launches don't inject PLUGIN_DATA (0.171.0). The installed
|
|
28
|
+
* notesoup@notesoup package has a fixed native data path under CODEX_HOME. */
|
|
29
|
+
export declare function mcpPluginDataRoot(env?: NodeJS.ProcessEnv): string;
|
|
25
30
|
export declare function notesHome(env?: NodeJS.ProcessEnv): string;
|
|
26
31
|
/** Native ids arrive provider-prefixed; @model is the last segment, slugged like every other notebook. */
|
|
27
32
|
export declare function modelSlug(value: unknown): string | undefined;
|
|
@@ -20,7 +20,7 @@ export function safeThreadId(value, field = "threadId") {
|
|
|
20
20
|
}
|
|
21
21
|
return value;
|
|
22
22
|
}
|
|
23
|
-
/** The
|
|
23
|
+
/** The hook receives the native plugin's data directory directly from Codex. */
|
|
24
24
|
export function pluginDataRoot(env = process.env) {
|
|
25
25
|
const value = env.PLUGIN_DATA;
|
|
26
26
|
if (typeof value !== "string" || value.trim() === "" || !isAbsolute(value)) {
|
|
@@ -28,6 +28,14 @@ export function pluginDataRoot(env = process.env) {
|
|
|
28
28
|
}
|
|
29
29
|
return resolve(value);
|
|
30
30
|
}
|
|
31
|
+
/** Native Codex MCP launches don't inject PLUGIN_DATA (0.171.0). The installed
|
|
32
|
+
* notesoup@notesoup package has a fixed native data path under CODEX_HOME. */
|
|
33
|
+
export function mcpPluginDataRoot(env = process.env) {
|
|
34
|
+
if (env.PLUGIN_DATA !== undefined)
|
|
35
|
+
return pluginDataRoot(env);
|
|
36
|
+
const home = env.CODEX_HOME?.trim() || join(homedir(), ".codex");
|
|
37
|
+
return resolve(home, "plugins", "data", "notesoup-notesoup");
|
|
38
|
+
}
|
|
31
39
|
export function notesHome(env = process.env) {
|
|
32
40
|
const value = env.NOTESOUP_HOME;
|
|
33
41
|
return value !== undefined && value.trim() !== "" ? resolve(value) : join(homedir(), ".agents", "notes");
|
|
@@ -79,6 +87,9 @@ export async function readBinding(root, threadId) {
|
|
|
79
87
|
const cwd = required(row.cwd, "cwd");
|
|
80
88
|
const transcriptPath = required(row.transcriptPath, "transcriptPath");
|
|
81
89
|
const windowId = required(row.windowId, "windowId");
|
|
90
|
+
const windowNumber = row.windowNumber;
|
|
91
|
+
if (windowNumber !== undefined && (typeof windowNumber !== "number" || !Number.isSafeInteger(windowNumber) || windowNumber < 0))
|
|
92
|
+
throw new CodexIdentityError("invalid_binding", "Stored notesoup binding has an invalid native window number.");
|
|
82
93
|
if (!isAbsolute(home) || !isAbsolute(cwd) || !isAbsolute(transcriptPath))
|
|
83
94
|
throw new CodexIdentityError("invalid_binding", "The stored notesoup binding contains a non-absolute path.");
|
|
84
95
|
return {
|
|
@@ -91,6 +102,7 @@ export async function readBinding(root, threadId) {
|
|
|
91
102
|
home,
|
|
92
103
|
transcriptPath,
|
|
93
104
|
windowId,
|
|
105
|
+
...(windowNumber === undefined ? {} : { windowNumber }),
|
|
94
106
|
...(typeof row.agentType === "string" && row.agentType.length > 0 ? { agentType: row.agentType } : {}),
|
|
95
107
|
boundAt: required(row.boundAt, "boundAt"),
|
|
96
108
|
};
|
|
@@ -1,7 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
export declare const createServer: (env?: NodeJS.ProcessEnv) => import("@modelcontextprotocol/sdk/server").Server<{
|
|
2
|
+
method: string;
|
|
3
|
+
params?: {
|
|
4
|
+
[x: string]: unknown;
|
|
5
|
+
_meta?: {
|
|
6
|
+
[x: string]: unknown;
|
|
7
|
+
progressToken?: string | number | undefined;
|
|
8
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
9
|
+
taskId: string;
|
|
10
|
+
} | undefined;
|
|
11
|
+
} | undefined;
|
|
12
|
+
} | undefined;
|
|
13
|
+
}, {
|
|
14
|
+
method: string;
|
|
15
|
+
params?: {
|
|
16
|
+
[x: string]: unknown;
|
|
17
|
+
_meta?: {
|
|
18
|
+
[x: string]: unknown;
|
|
19
|
+
progressToken?: string | number | undefined;
|
|
20
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
21
|
+
taskId: string;
|
|
22
|
+
} | undefined;
|
|
23
|
+
} | undefined;
|
|
24
|
+
} | undefined;
|
|
25
|
+
}, {
|
|
26
|
+
[x: string]: unknown;
|
|
27
|
+
_meta?: {
|
|
28
|
+
[x: string]: unknown;
|
|
29
|
+
progressToken?: string | number | undefined;
|
|
30
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
31
|
+
taskId: string;
|
|
32
|
+
} | undefined;
|
|
33
|
+
} | undefined;
|
|
34
|
+
}>;
|
|
35
|
+
export declare const runMcp: (env?: NodeJS.ProcessEnv) => Promise<void>;
|