notesoup 0.0.0-stage → 0.39.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/LICENSE +21 -0
- package/README.md +91 -2
- package/dist/src/boot/render.d.ts +16 -0
- package/dist/src/boot/render.js +95 -0
- package/dist/src/boot/snapshot.d.ts +32 -0
- package/dist/src/boot/snapshot.js +36 -0
- package/dist/src/boot/text.d.ts +21 -0
- package/dist/src/boot/text.js +52 -0
- package/dist/src/budget/constants.d.ts +9 -0
- package/dist/src/budget/constants.js +9 -0
- package/dist/src/budget/policy.d.ts +19 -0
- package/dist/src/budget/policy.js +36 -0
- package/dist/src/budget/text.d.ts +8 -0
- package/dist/src/budget/text.js +10 -0
- package/dist/src/claude/helper.d.ts +15 -0
- package/dist/src/claude/helper.js +87 -0
- package/dist/src/dream/doctor.d.ts +2 -0
- package/dist/src/dream/doctor.js +160 -0
- package/dist/src/dream/gates.d.ts +10 -0
- package/dist/src/dream/gates.js +26 -0
- package/dist/src/dream/git.d.ts +21 -0
- package/dist/src/dream/git.js +71 -0
- package/dist/src/dream/jail.d.ts +11 -0
- package/dist/src/dream/jail.js +71 -0
- package/dist/src/dream/lock.d.ts +31 -0
- package/dist/src/dream/lock.js +99 -0
- package/dist/src/dream/playbook.d.ts +1 -0
- package/dist/src/dream/playbook.js +2 -0
- package/dist/src/dream/report.d.ts +7 -0
- package/dist/src/dream/report.js +43 -0
- package/dist/src/dream/result.d.ts +9 -0
- package/dist/src/dream/result.js +1 -0
- package/dist/src/dream/settings.d.ts +10 -0
- package/dist/src/dream/settings.js +14 -0
- package/dist/src/history/history.d.ts +151 -0
- package/dist/src/history/history.js +195 -0
- package/dist/src/history/query.d.ts +75 -0
- package/dist/src/history/query.js +143 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/notes/address.d.ts +31 -0
- package/dist/src/notes/address.js +123 -0
- package/dist/src/notes/constants.d.ts +3 -0
- package/dist/src/notes/constants.js +3 -0
- package/dist/src/notes/errors.d.ts +11 -0
- package/dist/src/notes/errors.js +13 -0
- package/dist/src/notes/frontmatter.d.ts +44 -0
- package/dist/src/notes/frontmatter.js +145 -0
- package/dist/src/notes/fs-error.d.ts +2 -0
- package/dist/src/notes/fs-error.js +5 -0
- package/dist/src/notes/identity.d.ts +10 -0
- package/dist/src/notes/identity.js +33 -0
- package/dist/src/notes/index.d.ts +5 -0
- package/dist/src/notes/index.js +3 -0
- package/dist/src/notes/paths.d.ts +21 -0
- package/dist/src/notes/paths.js +113 -0
- package/dist/src/notes/store.d.ts +104 -0
- package/dist/src/notes/store.js +478 -0
- package/dist/src/pi/boot.d.ts +24 -0
- package/dist/src/pi/boot.js +56 -0
- package/dist/src/pi/budget.d.ts +13 -0
- package/dist/src/pi/budget.js +178 -0
- package/dist/src/pi/dream/cli.d.ts +10 -0
- package/dist/src/pi/dream/cli.js +140 -0
- package/dist/src/pi/dream/runner.d.ts +27 -0
- package/dist/src/pi/dream/runner.js +90 -0
- package/dist/src/pi/dream/settings.d.ts +7 -0
- package/dist/src/pi/dream/settings.js +17 -0
- package/dist/src/pi/entries.d.ts +7 -0
- package/dist/src/pi/entries.js +7 -0
- package/dist/src/pi/estimate.d.ts +16 -0
- package/dist/src/pi/estimate.js +99 -0
- package/dist/src/pi/extension.d.ts +10 -0
- package/dist/src/pi/extension.js +24 -0
- package/dist/src/pi/history-tools.d.ts +3 -0
- package/dist/src/pi/history-tools.js +10 -0
- package/dist/src/pi/history.d.ts +4 -0
- package/dist/src/pi/history.js +150 -0
- package/dist/src/pi/notes/adapter.d.ts +10 -0
- package/dist/src/pi/notes/adapter.js +27 -0
- package/dist/src/pi/notes/tools.d.ts +3 -0
- package/dist/src/pi/notes/tools.js +15 -0
- package/dist/src/pi/reset/artifacts.d.ts +24 -0
- package/dist/src/pi/reset/artifacts.js +84 -0
- package/dist/src/pi/reset/committed.d.ts +7 -0
- package/dist/src/pi/reset/committed.js +28 -0
- package/dist/src/pi/reset/lifecycle.d.ts +101 -0
- package/dist/src/pi/reset/lifecycle.js +277 -0
- package/dist/src/pi/reset/text.d.ts +5 -0
- package/dist/src/pi/reset/text.js +6 -0
- package/dist/src/pi/runtime.d.ts +3 -0
- package/dist/src/pi/runtime.js +206 -0
- package/dist/src/pi/session-reader.d.ts +5 -0
- package/dist/src/pi/session-reader.js +1 -0
- package/dist/src/pi/thresholds.d.ts +17 -0
- package/dist/src/pi/thresholds.js +33 -0
- package/dist/src/pi/tool-names.d.ts +11 -0
- package/dist/src/pi/tool-names.js +11 -0
- package/dist/src/pi/tool-result.d.ts +15 -0
- package/dist/src/pi/tool-result.js +29 -0
- package/dist/src/pi/window.d.ts +41 -0
- package/dist/src/pi/window.js +127 -0
- package/dist/src/settings.d.ts +9 -0
- package/dist/src/settings.js +18 -0
- package/dist/src/text-match.d.ts +5 -0
- package/dist/src/text-match.js +16 -0
- package/dist/src/tools/history.d.ts +67 -0
- package/dist/src/tools/history.js +251 -0
- package/dist/src/tools/notes.d.ts +282 -0
- package/dist/src/tools/notes.js +378 -0
- package/dist/src/tools/output.d.ts +23 -0
- package/dist/src/tools/output.js +39 -0
- package/dist/src/tools/result.d.ts +79 -0
- package/dist/src/tools/result.js +130 -0
- package/dist/src/tools/schema.d.ts +18 -0
- package/dist/src/tools/schema.js +31 -0
- package/dist/test/agent-loop.test.d.ts +1 -0
- package/dist/test/agent-loop.test.js +1497 -0
- package/dist/test/boot.integration.test.d.ts +1 -0
- package/dist/test/boot.integration.test.js +294 -0
- package/dist/test/budget-settings.integration.test.d.ts +1 -0
- package/dist/test/budget-settings.integration.test.js +144 -0
- package/dist/test/claude-mod.test.d.ts +1 -0
- package/dist/test/claude-mod.test.js +404 -0
- package/dist/test/dependencies.test.d.ts +1 -0
- package/dist/test/dependencies.test.js +101 -0
- package/dist/test/doctor.test.d.ts +1 -0
- package/dist/test/doctor.test.js +37 -0
- package/dist/test/dream-skill.test.d.ts +1 -0
- package/dist/test/dream-skill.test.js +72 -0
- package/dist/test/dream.test.d.ts +1 -0
- package/dist/test/dream.test.js +136 -0
- package/dist/test/helpers/dependency-graph.d.ts +5 -0
- package/dist/test/helpers/dependency-graph.js +73 -0
- package/dist/test/helpers/extension-test-environment.d.ts +1 -0
- package/dist/test/helpers/extension-test-environment.js +9 -0
- package/dist/test/helpers/extension.d.ts +119 -0
- package/dist/test/helpers/extension.js +368 -0
- package/dist/test/helpers/notes.d.ts +6 -0
- package/dist/test/helpers/notes.js +13 -0
- package/dist/test/history.integration.test.d.ts +1 -0
- package/dist/test/history.integration.test.js +556 -0
- package/dist/test/host-neutral.test.d.ts +1 -0
- package/dist/test/host-neutral.test.js +300 -0
- package/dist/test/notes-library.test.d.ts +1 -0
- package/dist/test/notes-library.test.js +214 -0
- package/dist/test/notes.integration.test.d.ts +1 -0
- package/dist/test/notes.integration.test.js +497 -0
- package/dist/test/notes.test.d.ts +1 -0
- package/dist/test/notes.test.js +528 -0
- package/dist/test/reset-lifecycle.test.d.ts +1 -0
- package/dist/test/reset-lifecycle.test.js +605 -0
- package/docs/architecture.md +63 -0
- package/docs/claude-code-mod.md +9 -0
- package/docs/notes-library.md +74 -0
- package/docs/reset-lifecycle.md +75 -0
- package/docs/sdk-integration.md +39 -0
- package/docs/skills.md +30 -0
- package/docs/tool-results.md +88 -0
- package/mods/notesoup/.claude-plugin/plugin.json +8 -0
- package/mods/notesoup/dist/claude/helper.js +9324 -0
- package/mods/notesoup/hooks/hooks.json +4 -0
- package/mods/notesoup/hooks/register.ts +241 -0
- package/mods/notesoup/playbook.md +34 -0
- package/mods/notesoup/skills/dream/SKILL.md +12 -0
- package/mods/pi-context/dist/claude/helper.js +9324 -0
- package/package.json +89 -5
- package/playbook.md +34 -0
- package/skills/dream/SKILL.md +12 -0
- package/skills/memory/SKILL.md +59 -0
- package/src/boot/render.ts +115 -0
- package/src/boot/snapshot.ts +46 -0
- package/src/boot/text.ts +66 -0
- package/src/budget/constants.ts +9 -0
- package/src/budget/policy.ts +36 -0
- package/src/budget/text.ts +11 -0
- package/src/claude/helper.ts +94 -0
- package/src/dream/doctor.ts +117 -0
- package/src/dream/gates.ts +26 -0
- package/src/dream/git.ts +73 -0
- package/src/dream/jail.ts +62 -0
- package/src/dream/lock.ts +82 -0
- package/src/dream/playbook.ts +3 -0
- package/src/dream/report.ts +36 -0
- package/src/dream/result.ts +2 -0
- package/src/dream/settings.ts +16 -0
- package/src/history/history.ts +270 -0
- package/src/history/query.ts +147 -0
- package/src/index.ts +1 -0
- package/src/notes/address.ts +110 -0
- package/src/notes/constants.ts +3 -0
- package/src/notes/errors.ts +15 -0
- package/src/notes/frontmatter.ts +166 -0
- package/src/notes/fs-error.ts +5 -0
- package/src/notes/identity.ts +40 -0
- package/src/notes/index.ts +24 -0
- package/src/notes/paths.ts +109 -0
- package/src/notes/store.ts +497 -0
- package/src/pi/boot.ts +88 -0
- package/src/pi/budget.ts +178 -0
- package/src/pi/dream/cli.ts +92 -0
- package/src/pi/dream/runner.ts +91 -0
- package/src/pi/dream/settings.ts +17 -0
- package/src/pi/entries.ts +7 -0
- package/src/pi/estimate.ts +116 -0
- package/src/pi/extension.ts +27 -0
- package/src/pi/history-tools.ts +12 -0
- package/src/pi/history.ts +162 -0
- package/src/pi/notes/adapter.ts +33 -0
- package/src/pi/notes/tools.ts +18 -0
- package/src/pi/reset/artifacts.ts +100 -0
- package/src/pi/reset/committed.ts +26 -0
- package/src/pi/reset/lifecycle.ts +342 -0
- package/src/pi/reset/text.ts +10 -0
- package/src/pi/runtime.ts +200 -0
- package/src/pi/session-reader.ts +6 -0
- package/src/pi/thresholds.ts +50 -0
- package/src/pi/tool-names.ts +13 -0
- package/src/pi/tool-result.ts +41 -0
- package/src/pi/window.ts +133 -0
- package/src/settings.ts +22 -0
- package/src/text-match.ts +14 -0
- package/src/tools/history.ts +273 -0
- package/src/tools/notes.ts +394 -0
- package/src/tools/output.ts +41 -0
- package/src/tools/result.ts +169 -0
- package/src/tools/schema.ts +31 -0
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { mkdir, readdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import { dirname, join, resolve } from "node:path";
|
|
4
|
+
import { earliestMatchOffsetChars } from "../text-match.js";
|
|
5
|
+
import { assertAddress, assertGlobPattern, addressFor, canonicalAddressFor, globToRegExp } from "./address.js";
|
|
6
|
+
import { isFilesystemError } from "./fs-error.js";
|
|
7
|
+
import { snapshotNotesIdentity } from "./identity.js";
|
|
8
|
+
import { NoteError } from "./errors.js";
|
|
9
|
+
import { MAX_NOTE_BYTES, MAX_NOTE_PATH_BYTES } from "./constants.js";
|
|
10
|
+
import { isOrigin, isScope, localIso, parseNote, serializeNote, stripLeadingFrontmatter } from "./frontmatter.js";
|
|
11
|
+
import { namespaceSlugs, noteFileName, physicalPath, scopeDir, SLUG_PATTERN } from "./paths.js";
|
|
12
|
+
// Recency sorts tie-break by address, so two writes sharing one Date.now() tick would silently invert the recent-first contract. Write stamps are strictly increasing per process.
|
|
13
|
+
let lastWriteStamp = 0;
|
|
14
|
+
function writeStamp() {
|
|
15
|
+
const now = Date.now();
|
|
16
|
+
lastWriteStamp = now > lastWriteStamp ? now : lastWriteStamp + 1;
|
|
17
|
+
return lastWriteStamp;
|
|
18
|
+
}
|
|
19
|
+
/** Public identity resolved for an operation, never a filesystem path. */
|
|
20
|
+
export function noteIdentity(identity, address) {
|
|
21
|
+
const resolved = assertAddress(address);
|
|
22
|
+
return {
|
|
23
|
+
address: addressFor(identity, resolved.scope, noteFileName(resolved.path), resolved.who),
|
|
24
|
+
...(resolved.scope === "project" ? { project_key: identity.projectKey } : {}),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const SCOPE_ORDER = ["session", "project", "human", "agent", "model"];
|
|
28
|
+
/** Mutations and read-modify-write reads serialize by physical file across all store instances. */
|
|
29
|
+
const pathQueues = new Map();
|
|
30
|
+
function withPathQueue(path, operation) {
|
|
31
|
+
const key = resolve(path);
|
|
32
|
+
const previous = pathQueues.get(key) ?? Promise.resolve();
|
|
33
|
+
const result = previous.then(operation);
|
|
34
|
+
const tail = result.then(() => undefined, () => undefined);
|
|
35
|
+
pathQueues.set(key, tail);
|
|
36
|
+
void tail.then(() => {
|
|
37
|
+
if (pathQueues.get(key) === tail)
|
|
38
|
+
pathQueues.delete(key);
|
|
39
|
+
});
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
function errno(error) {
|
|
43
|
+
return typeof error === "object" && error !== null ? error.code : undefined;
|
|
44
|
+
}
|
|
45
|
+
async function readFileIfExists(path) {
|
|
46
|
+
try {
|
|
47
|
+
return await readFile(path, "utf8");
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
if (errno(error) === "ENOENT")
|
|
51
|
+
return undefined;
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** Recursively list `.md` files under `dir` as forward-slash virtual paths relative to `base`. */
|
|
56
|
+
async function walkMarkdown(dir, base = dir) {
|
|
57
|
+
let entries;
|
|
58
|
+
try {
|
|
59
|
+
entries = await readdir(dir, { withFileTypes: true });
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
// A home that has never been created is normal. Other failures must reach the
|
|
63
|
+
// boot snapshot boundary instead of masquerading as an empty home.
|
|
64
|
+
if (errno(error) === "ENOENT")
|
|
65
|
+
return [];
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
const paths = [];
|
|
69
|
+
for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
70
|
+
const child = join(dir, entry.name);
|
|
71
|
+
if (entry.isDirectory())
|
|
72
|
+
paths.push(...await walkMarkdown(child, base));
|
|
73
|
+
else if (entry.isFile() && entry.name.endsWith(".md"))
|
|
74
|
+
paths.push(child.slice(base.length + 1).split("\\").join("/"));
|
|
75
|
+
}
|
|
76
|
+
return paths;
|
|
77
|
+
}
|
|
78
|
+
function matcherFor(pattern) {
|
|
79
|
+
const normalized = assertGlobPattern(pattern);
|
|
80
|
+
return normalized === undefined ? undefined : globToRegExp(normalized);
|
|
81
|
+
}
|
|
82
|
+
async function homesForPattern(pattern, identity) {
|
|
83
|
+
if (!pattern || !pattern.startsWith("@"))
|
|
84
|
+
return undefined;
|
|
85
|
+
const head = /^@([^/]+)\//.exec(pattern)?.[1];
|
|
86
|
+
if (head === "project")
|
|
87
|
+
return [{ scope: "project" }];
|
|
88
|
+
if (head === "human")
|
|
89
|
+
return [{ scope: "human" }];
|
|
90
|
+
if (head === "self")
|
|
91
|
+
return [{ scope: "agent" }];
|
|
92
|
+
if (head === "model")
|
|
93
|
+
return [{ scope: "model" }];
|
|
94
|
+
if (head === "agents" || head === "models") {
|
|
95
|
+
const scope = head === "agents" ? "agent" : "model";
|
|
96
|
+
const name = pattern.slice(head.length + 2).split("/")[0] ?? "";
|
|
97
|
+
if (name.length > 0 && !/[*?]/.test(name))
|
|
98
|
+
return [{ scope, who: assertWho(name) }];
|
|
99
|
+
return (await namespaceSlugs(head, identity.home)).map((who) => ({ scope, who }));
|
|
100
|
+
}
|
|
101
|
+
return [];
|
|
102
|
+
}
|
|
103
|
+
/** Relative pattern heads resolve to canonical names, so they match canonical addresses. */
|
|
104
|
+
function normalizePattern(pattern, identity) {
|
|
105
|
+
if (!pattern)
|
|
106
|
+
return pattern;
|
|
107
|
+
if (pattern.startsWith("@self/"))
|
|
108
|
+
return `@agents/${identity.agent}/${pattern.slice("@self/".length)}`;
|
|
109
|
+
if (pattern.startsWith("@model/"))
|
|
110
|
+
return `@models/${identity.model}/${pattern.slice("@model/".length)}`;
|
|
111
|
+
return pattern;
|
|
112
|
+
}
|
|
113
|
+
function assertScope(value) {
|
|
114
|
+
if (!isScope(value))
|
|
115
|
+
throw new NoteError("invalid_scope", `scope must be one of session, project, human, agent, model (got ${JSON.stringify(value)})`);
|
|
116
|
+
return value;
|
|
117
|
+
}
|
|
118
|
+
function assertOrigin(value) {
|
|
119
|
+
if (!isOrigin(value))
|
|
120
|
+
throw new NoteError("invalid_origin", `origin must be one of user, self, external (got ${JSON.stringify(value)})`);
|
|
121
|
+
return value;
|
|
122
|
+
}
|
|
123
|
+
function assertWho(value) {
|
|
124
|
+
if (typeof value !== "string" || !SLUG_PATTERN.test(value)) {
|
|
125
|
+
throw new NoteError("invalid_scope", "who must be a canonical lowercase slug");
|
|
126
|
+
}
|
|
127
|
+
return value;
|
|
128
|
+
}
|
|
129
|
+
async function homesFor(identity, opts) {
|
|
130
|
+
if (opts.scope !== undefined) {
|
|
131
|
+
const scope = assertScope(opts.scope);
|
|
132
|
+
if (opts.who !== undefined) {
|
|
133
|
+
const who = assertWho(opts.who);
|
|
134
|
+
if (scope !== "agent" && scope !== "model")
|
|
135
|
+
throw new NoteError("invalid_scope", "who is only valid with agent or model scope");
|
|
136
|
+
return [{ scope, who }];
|
|
137
|
+
}
|
|
138
|
+
return [{ scope }];
|
|
139
|
+
}
|
|
140
|
+
if (opts.who !== undefined)
|
|
141
|
+
throw new NoteError("invalid_scope", "who requires agent or model scope");
|
|
142
|
+
return await homesForPattern(normalizePattern(opts.pattern, identity), identity) ?? SCOPE_ORDER.map((scope) => ({ scope }));
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Line numbers (1-based) of every occurrence of `needle` in `body`. The scan walks forward
|
|
146
|
+
* once, counting newlines as it goes, so a body that repeats one anchor thousands of times
|
|
147
|
+
* costs one pass instead of one reslice per match.
|
|
148
|
+
*/
|
|
149
|
+
function matchLineNumbers(body, needle) {
|
|
150
|
+
const lines = [];
|
|
151
|
+
let line = 1;
|
|
152
|
+
let cursor = 0;
|
|
153
|
+
let scanned = 0;
|
|
154
|
+
for (;;) {
|
|
155
|
+
const index = body.indexOf(needle, cursor);
|
|
156
|
+
if (index === -1)
|
|
157
|
+
break;
|
|
158
|
+
for (; scanned < index; scanned++) {
|
|
159
|
+
if (body.charCodeAt(scanned) === 10)
|
|
160
|
+
line++;
|
|
161
|
+
}
|
|
162
|
+
lines.push(line);
|
|
163
|
+
cursor = index + Math.max(needle.length, 1);
|
|
164
|
+
}
|
|
165
|
+
return lines;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* How many match lines a refusal names inline. A body can repeat one anchor thousands of
|
|
169
|
+
* times, so the message carries a bounded sample plus the exact total; the typed error keeps
|
|
170
|
+
* the complete list, and the wire bounds what it repeats of it.
|
|
171
|
+
*/
|
|
172
|
+
const MAX_ANCHOR_LINES = 8;
|
|
173
|
+
function anchorLines(lines) {
|
|
174
|
+
const named = lines.slice(0, MAX_ANCHOR_LINES);
|
|
175
|
+
const rest = lines.length - named.length;
|
|
176
|
+
return `lines ${named.join(", ")}${rest > 0 ? `, and ${rest} more` : ""}`;
|
|
177
|
+
}
|
|
178
|
+
/** Every mutation uses a tmp file renamed into place in the same directory. */
|
|
179
|
+
async function atomicWrite(path, content) {
|
|
180
|
+
await mkdir(dirname(path), { recursive: true });
|
|
181
|
+
const tmp = `${path}.${process.pid}.${randomUUID()}.tmp`;
|
|
182
|
+
try {
|
|
183
|
+
await writeFile(tmp, content);
|
|
184
|
+
await rename(tmp, path);
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
try {
|
|
188
|
+
await rm(tmp, { force: true });
|
|
189
|
+
}
|
|
190
|
+
catch { /* Preserve the original write/rename failure. */ }
|
|
191
|
+
throw error;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/** The byte cap is a write-time boundary rule, never a path-jail rule. */
|
|
195
|
+
function assertWritablePath(vpath) {
|
|
196
|
+
const bytes = Buffer.byteLength(vpath, "utf8");
|
|
197
|
+
if (bytes > MAX_NOTE_PATH_BYTES)
|
|
198
|
+
throw new NoteError("too_large", `note path exceeds ${MAX_NOTE_PATH_BYTES} UTF-8 bytes (got ${bytes})`);
|
|
199
|
+
}
|
|
200
|
+
function assertSerializedSize(content) {
|
|
201
|
+
const bytes = Buffer.byteLength(content, "utf8");
|
|
202
|
+
if (bytes > MAX_NOTE_BYTES)
|
|
203
|
+
throw new NoteError("too_large", `note exceeds ${MAX_NOTE_BYTES} UTF-8 bytes (serialized ${bytes})`);
|
|
204
|
+
}
|
|
205
|
+
/** Frontmatter block only (the body separator stripped), for metadata-only change inputs. */
|
|
206
|
+
function frontmatterOf(meta) {
|
|
207
|
+
return serializeNote(meta, "").slice(0, -2);
|
|
208
|
+
}
|
|
209
|
+
/** Named agent/model homes are read-only to whoever is not running there. */
|
|
210
|
+
function assertWritableHome(scope, who, identity) {
|
|
211
|
+
if (who === undefined)
|
|
212
|
+
return;
|
|
213
|
+
const current = scope === "agent" ? identity.agent : identity.model;
|
|
214
|
+
if (who === current)
|
|
215
|
+
return;
|
|
216
|
+
const home = scope === "agent" ? `@agents/${who}/` : `@models/${who}/`;
|
|
217
|
+
throw new NoteError("invalid_scope", `${home} is not your home: writable homes are this session, @project/, @human/, @self/, and the current @model/ home`);
|
|
218
|
+
}
|
|
219
|
+
/** Normalize parsed metadata exactly as a read does, including its access mutation. */
|
|
220
|
+
function accessedMeta(meta, scope, now) {
|
|
221
|
+
const next = { ...meta, scope };
|
|
222
|
+
next.lastAccessed = now;
|
|
223
|
+
next.accessCount = (typeof next.accessCount === "number" ? next.accessCount : 0) + 1;
|
|
224
|
+
return next;
|
|
225
|
+
}
|
|
226
|
+
/** Create a store over one validated, immutable snapshot of the supplied explicit identity. */
|
|
227
|
+
export function createNotesStore(input) {
|
|
228
|
+
const identity = snapshotNotesIdentity(input);
|
|
229
|
+
async function write(address, content, options = {}) {
|
|
230
|
+
const stableOptions = { ...options };
|
|
231
|
+
const destination = assertAddress(address);
|
|
232
|
+
assertWritablePath(destination.path);
|
|
233
|
+
const scope = destination.scope;
|
|
234
|
+
assertWritableHome(scope, destination.who, identity);
|
|
235
|
+
const origin = assertOrigin(stableOptions.origin ?? "self");
|
|
236
|
+
const path = physicalPath(scope, destination.path, identity, destination.who);
|
|
237
|
+
return withPathQueue(path, async () => {
|
|
238
|
+
const now = writeStamp();
|
|
239
|
+
const cleanBody = stripLeadingFrontmatter(content);
|
|
240
|
+
const existingRaw = await readFileIfExists(path);
|
|
241
|
+
const existing = existingRaw === undefined ? undefined : parseNote(existingRaw, now).meta;
|
|
242
|
+
const outcome = existing === undefined ? "created" : existing.crumpledAt === undefined ? "overwrote" : "uncrumpled";
|
|
243
|
+
const meta = existing ?? {
|
|
244
|
+
scope,
|
|
245
|
+
origin,
|
|
246
|
+
createdAt: now,
|
|
247
|
+
updatedAt: now,
|
|
248
|
+
lastAccessed: now,
|
|
249
|
+
accessCount: 0,
|
|
250
|
+
...(scope === "session" ? { project: identity.projectKey } : {}),
|
|
251
|
+
};
|
|
252
|
+
meta.scope = scope;
|
|
253
|
+
meta.origin = origin;
|
|
254
|
+
delete meta.crumpledAt;
|
|
255
|
+
meta.updatedAt = now;
|
|
256
|
+
const serialized = serializeNote(meta, cleanBody);
|
|
257
|
+
assertSerializedSize(serialized);
|
|
258
|
+
await atomicWrite(path, serialized);
|
|
259
|
+
return { meta, outcome };
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
async function read(address) {
|
|
263
|
+
const destination = assertAddress(address);
|
|
264
|
+
const scope = destination.scope;
|
|
265
|
+
const path = physicalPath(scope, destination.path, identity, destination.who);
|
|
266
|
+
return withPathQueue(path, async () => {
|
|
267
|
+
const raw = await readFileIfExists(path);
|
|
268
|
+
if (raw === undefined)
|
|
269
|
+
return undefined;
|
|
270
|
+
const now = Date.now();
|
|
271
|
+
const parsed = parseNote(raw, now);
|
|
272
|
+
const meta = accessedMeta(parsed.meta, scope, now);
|
|
273
|
+
await atomicWrite(path, serializeNote(meta, parsed.body));
|
|
274
|
+
return { meta, body: parsed.body, resolvedScope: scope };
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
async function update(address, edits, options = {}) {
|
|
278
|
+
const operations = edits === undefined ? [] : edits.map((operation) => ({ ...operation }));
|
|
279
|
+
const stableOptions = { ...options };
|
|
280
|
+
const destination = assertAddress(address);
|
|
281
|
+
assertWritablePath(destination.path);
|
|
282
|
+
const scope = destination.scope;
|
|
283
|
+
assertWritableHome(scope, destination.who, identity);
|
|
284
|
+
if (operations.length === 0 && stableOptions.origin === undefined && stableOptions.crumpled === undefined) {
|
|
285
|
+
throw new NoteError("nothing_to_do", "nothing to do: provide edits or at least one of origin, crumpled");
|
|
286
|
+
}
|
|
287
|
+
const path = physicalPath(scope, destination.path, identity, destination.who);
|
|
288
|
+
return withPathQueue(path, async () => {
|
|
289
|
+
const raw = await readFileIfExists(path);
|
|
290
|
+
if (raw === undefined)
|
|
291
|
+
throw new NoteError("not_found", "note not found");
|
|
292
|
+
const { meta, body } = parseNote(raw);
|
|
293
|
+
meta.scope = scope;
|
|
294
|
+
const beforeMeta = { ...meta };
|
|
295
|
+
let next = body;
|
|
296
|
+
let applied = 0;
|
|
297
|
+
operations.forEach((operation, index) => {
|
|
298
|
+
const oldText = operation?.oldText;
|
|
299
|
+
const newText = operation?.newText;
|
|
300
|
+
if (typeof oldText !== "string" || oldText.length === 0)
|
|
301
|
+
throw new NoteError("no_match", `edit ${index}: oldText must be a non-empty string`, { editIndex: index });
|
|
302
|
+
if (typeof newText !== "string")
|
|
303
|
+
throw new NoteError("no_match", `edit ${index}: newText must be a string`, { editIndex: index });
|
|
304
|
+
const lines = matchLineNumbers(next, oldText);
|
|
305
|
+
if (lines.length === 0)
|
|
306
|
+
throw new NoteError("no_match", `edit ${index}: oldText does not occur in the note body`, { editIndex: index });
|
|
307
|
+
if (lines.length > 1 && !stableOptions.replaceAll) {
|
|
308
|
+
throw new NoteError("ambiguous_edit", `edit ${index}: oldText occurs ${lines.length} times (${anchorLines(lines)}); pass replace_all to replace every occurrence`, { lineNumbers: lines, editIndex: index });
|
|
309
|
+
}
|
|
310
|
+
if (oldText !== newText)
|
|
311
|
+
applied++;
|
|
312
|
+
// Positional splicing preserves user replacement text byte-for-byte.
|
|
313
|
+
if (stableOptions.replaceAll)
|
|
314
|
+
next = next.split(oldText).join(newText);
|
|
315
|
+
else {
|
|
316
|
+
const matchIndex = next.indexOf(oldText);
|
|
317
|
+
next = next.substring(0, matchIndex) + newText + next.substring(matchIndex + oldText.length);
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
if (stableOptions.origin !== undefined)
|
|
321
|
+
meta.origin = assertOrigin(stableOptions.origin);
|
|
322
|
+
if (stableOptions.crumpled === true && meta.crumpledAt === undefined)
|
|
323
|
+
meta.crumpledAt = localIso(Date.now());
|
|
324
|
+
if (stableOptions.crumpled === false)
|
|
325
|
+
delete meta.crumpledAt;
|
|
326
|
+
const bodyChanged = body !== next;
|
|
327
|
+
const originChanged = beforeMeta.origin !== meta.origin;
|
|
328
|
+
if (bodyChanged || originChanged)
|
|
329
|
+
meta.updatedAt = writeStamp();
|
|
330
|
+
const serialized = serializeNote(meta, next);
|
|
331
|
+
assertSerializedSize(serialized);
|
|
332
|
+
const metadataChanged = originChanged || beforeMeta.crumpledAt !== meta.crumpledAt;
|
|
333
|
+
let change;
|
|
334
|
+
if (bodyChanged && metadataChanged)
|
|
335
|
+
change = { kind: "file", before: raw, after: serialized };
|
|
336
|
+
else if (bodyChanged)
|
|
337
|
+
change = { kind: "body", before: body, after: next };
|
|
338
|
+
else if (metadataChanged)
|
|
339
|
+
change = { kind: "metadata", before: frontmatterOf(beforeMeta), after: frontmatterOf(meta) };
|
|
340
|
+
else
|
|
341
|
+
change = { kind: "none", before: "", after: "" };
|
|
342
|
+
await atomicWrite(path, serialized);
|
|
343
|
+
return { meta, applied, resolvedScope: scope, change };
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Move one note to a new address with every metadata key preserved. Both ends must be
|
|
348
|
+
* writable; a live target refuses, a crumpled target is replaced. Locks both paths in
|
|
349
|
+
* sorted order so crossed renames cannot deadlock.
|
|
350
|
+
*/
|
|
351
|
+
async function rename(fromAddress, toAddress) {
|
|
352
|
+
const from = assertAddress(fromAddress);
|
|
353
|
+
const to = assertAddress(toAddress);
|
|
354
|
+
const fromScope = from.scope;
|
|
355
|
+
const toScope = to.scope;
|
|
356
|
+
assertWritablePath(to.path);
|
|
357
|
+
assertWritableHome(fromScope, from.who, identity);
|
|
358
|
+
assertWritableHome(toScope, to.who, identity);
|
|
359
|
+
const fromPath = physicalPath(fromScope, from.path, identity, from.who);
|
|
360
|
+
const toPath = physicalPath(toScope, to.path, identity, to.who);
|
|
361
|
+
if (resolve(fromPath) === resolve(toPath))
|
|
362
|
+
throw new NoteError("nothing_to_do", "rename_to resolves to the same note");
|
|
363
|
+
const [first, second] = [fromPath, toPath].sort();
|
|
364
|
+
return withPathQueue(first, () => withPathQueue(second, async () => {
|
|
365
|
+
const raw = await readFileIfExists(fromPath);
|
|
366
|
+
if (raw === undefined)
|
|
367
|
+
throw new NoteError("not_found", "note not found");
|
|
368
|
+
const targetRaw = await readFileIfExists(toPath);
|
|
369
|
+
if (targetRaw !== undefined && parseNote(targetRaw).meta.crumpledAt === undefined) {
|
|
370
|
+
throw new NoteError("already_exists", "rename_to target is a live note; crumple it first or pick another address");
|
|
371
|
+
}
|
|
372
|
+
const { meta, body } = parseNote(raw);
|
|
373
|
+
meta.scope = toScope;
|
|
374
|
+
// Project ownership only changes when the move crosses the session boundary.
|
|
375
|
+
if (fromScope !== "session" && toScope === "session")
|
|
376
|
+
meta.project = identity.projectKey;
|
|
377
|
+
if (fromScope === "session" && toScope !== "session")
|
|
378
|
+
delete meta.project;
|
|
379
|
+
meta.updatedAt = writeStamp();
|
|
380
|
+
const serialized = serializeNote(meta, body);
|
|
381
|
+
assertSerializedSize(serialized);
|
|
382
|
+
await atomicWrite(toPath, serialized);
|
|
383
|
+
await rm(fromPath, { force: true });
|
|
384
|
+
return { meta, replacedCrumpledTarget: targetRaw !== undefined };
|
|
385
|
+
}));
|
|
386
|
+
}
|
|
387
|
+
async function* scan(options, status) {
|
|
388
|
+
const matcher = matcherFor(normalizePattern(options.pattern, identity));
|
|
389
|
+
let homes;
|
|
390
|
+
try {
|
|
391
|
+
homes = await homesFor(identity, options);
|
|
392
|
+
}
|
|
393
|
+
catch (error) {
|
|
394
|
+
if (!status || !isFilesystemError(error) || !/^@(agents|models)\//.test(options.pattern ?? ""))
|
|
395
|
+
throw error;
|
|
396
|
+
status.homesUnavailable.push(options.pattern.startsWith("@agents/") ? "@agents" : "@models");
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
for (const home of homes) {
|
|
400
|
+
const scope = home.scope;
|
|
401
|
+
const root = scopeDir(scope, identity, home.who);
|
|
402
|
+
const homeRows = [];
|
|
403
|
+
let excluded = 0;
|
|
404
|
+
try {
|
|
405
|
+
for (const path of await walkMarkdown(root)) {
|
|
406
|
+
if (matcher && !matcher.test(canonicalAddressFor(identity, scope, path, home.who)))
|
|
407
|
+
continue;
|
|
408
|
+
const address = addressFor(identity, scope, path, home.who);
|
|
409
|
+
const fullPath = join(root, path);
|
|
410
|
+
const raw = await withPathQueue(fullPath, () => readFile(fullPath, "utf8"));
|
|
411
|
+
const { meta, body } = parseNote(raw);
|
|
412
|
+
meta.scope = scope;
|
|
413
|
+
if ((meta.crumpledAt !== undefined) !== (options.wastebasket === true)) {
|
|
414
|
+
if (meta.crumpledAt !== undefined)
|
|
415
|
+
excluded++;
|
|
416
|
+
continue;
|
|
417
|
+
}
|
|
418
|
+
homeRows.push({ address, scope, path, meta, body });
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
catch (error) {
|
|
422
|
+
if (!status || !isFilesystemError(error))
|
|
423
|
+
throw error;
|
|
424
|
+
status.homesUnavailable.push(addressFor(identity, scope, "", home.who).replace(/\/$/, "") || "session");
|
|
425
|
+
continue;
|
|
426
|
+
}
|
|
427
|
+
if (status)
|
|
428
|
+
status.crumpledExcluded += excluded;
|
|
429
|
+
for (const row of homeRows)
|
|
430
|
+
yield row;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
async function list(options = {}) {
|
|
434
|
+
return (await listRows(options)).rows;
|
|
435
|
+
}
|
|
436
|
+
async function listRows(options, status) {
|
|
437
|
+
const stableOptions = { ...options };
|
|
438
|
+
const rows = [];
|
|
439
|
+
for await (const row of scan(stableOptions, status)) {
|
|
440
|
+
rows.push({ ...row, sizeBytes: Buffer.byteLength(row.body, "utf8") });
|
|
441
|
+
}
|
|
442
|
+
rows.sort((a, b) => b.meta.updatedAt - a.meta.updatedAt || a.address.localeCompare(b.address));
|
|
443
|
+
return { rows, status: status ?? { crumpledExcluded: 0, homesUnavailable: [] } };
|
|
444
|
+
}
|
|
445
|
+
function listWithStatus(options = {}) {
|
|
446
|
+
return listRows(options, { crumpledExcluded: 0, homesUnavailable: [] });
|
|
447
|
+
}
|
|
448
|
+
async function search(queries, options = {}) {
|
|
449
|
+
return (await searchRows(queries, options)).rows;
|
|
450
|
+
}
|
|
451
|
+
async function searchRows(queries, options, status) {
|
|
452
|
+
const stableQueries = [...queries];
|
|
453
|
+
const stableOptions = { ...options };
|
|
454
|
+
const rows = [];
|
|
455
|
+
for await (const note of scan(stableOptions, status)) {
|
|
456
|
+
const { address, path, scope, meta, body } = note;
|
|
457
|
+
// Offsets address the note body alone: no frontmatter length is predicted, so an
|
|
458
|
+
// access-counter rewrite cannot move a match out from under the caller.
|
|
459
|
+
let baseChars = 0;
|
|
460
|
+
const matches = [];
|
|
461
|
+
for (const [index, line] of body.split("\n").entries()) {
|
|
462
|
+
const offset = earliestMatchOffsetChars(line, stableQueries);
|
|
463
|
+
if (offset >= 0) {
|
|
464
|
+
matches.push({ line: index + 1, text: line, offsetChars: baseChars + offset });
|
|
465
|
+
}
|
|
466
|
+
baseChars += Array.from(line).length + 1;
|
|
467
|
+
}
|
|
468
|
+
if (matches.length > 0)
|
|
469
|
+
rows.push({ address, path, scope, meta, matches });
|
|
470
|
+
}
|
|
471
|
+
rows.sort((a, b) => a.address.localeCompare(b.address));
|
|
472
|
+
return { rows, status: status ?? { crumpledExcluded: 0, homesUnavailable: [] } };
|
|
473
|
+
}
|
|
474
|
+
function searchWithStatus(queries, options = {}) {
|
|
475
|
+
return searchRows(queries, options, { crumpledExcluded: 0, homesUnavailable: [] });
|
|
476
|
+
}
|
|
477
|
+
return { write, read, update, rename, list, search, listWithStatus, searchWithStatus };
|
|
478
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { type NotesSnapshot } from "../boot/snapshot.js";
|
|
3
|
+
export type IncompleteNotesNotifier = (ctx: ExtensionContext, windowId: string, snapshot: NotesSnapshot) => void;
|
|
4
|
+
/** The boot custom message: identity, notes snapshot, and static protocol; never reset prose. */
|
|
5
|
+
export type BootMessage = {
|
|
6
|
+
readonly customType: string;
|
|
7
|
+
readonly content: string;
|
|
8
|
+
readonly display: false;
|
|
9
|
+
readonly details: {
|
|
10
|
+
windowId: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Acquire one notes snapshot and build the boot custom message for a window. All identity
|
|
15
|
+
* fields are captured synchronously before the first filesystem await.
|
|
16
|
+
*/
|
|
17
|
+
export declare function buildBootMessage(ctx: ExtensionContext, windowId: string, previousId: string | undefined, notifyIncompleteNotes?: IncompleteNotesNotifier, isCurrent?: () => boolean): Promise<BootMessage>;
|
|
18
|
+
/** Persist one hidden boot message without triggering a model turn. */
|
|
19
|
+
export declare function sendBoot(pi: ExtensionAPI, boot: BootMessage): void;
|
|
20
|
+
/**
|
|
21
|
+
* Boot entry point for `session_start` / `session_tree`. Ordinary startup ensures one root
|
|
22
|
+
* boot; a reset marker instead asks reset-artifact repair to complete its persisted tail.
|
|
23
|
+
*/
|
|
24
|
+
export declare function ensureBoot(pi: ExtensionAPI, ctx: ExtensionContext, notifyIncompleteNotes?: IncompleteNotesNotifier, isCurrent?: () => boolean): Promise<void>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { PI_TOOL_NAMES } from "./tool-names.js";
|
|
2
|
+
import { notesIdentityFromPi } from "./notes/adapter.js";
|
|
3
|
+
import { loadNotesSnapshot } from "../boot/snapshot.js";
|
|
4
|
+
import { BOOT_TYPE } from "./entries.js";
|
|
5
|
+
import { renderBootBlock } from "../boot/render.js";
|
|
6
|
+
import { currentReset, currentWindowId, isWindowBoot, rootWindowId } from "./window.js";
|
|
7
|
+
import { repairResetTail } from "./reset/artifacts.js";
|
|
8
|
+
/** Render the boot block from one pre-await identity and acquired notes snapshot. */
|
|
9
|
+
function bootContent(agentName, modelName, firstWindowId, currentId, previousId, notes) {
|
|
10
|
+
return renderBootBlock({ agentName, modelName, firstWindowId, currentWindowId: currentId, previousWindowId: previousId, notes, tools: PI_TOOL_NAMES });
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Acquire one notes snapshot and build the boot custom message for a window. All identity
|
|
14
|
+
* fields are captured synchronously before the first filesystem await.
|
|
15
|
+
*/
|
|
16
|
+
export async function buildBootMessage(ctx, windowId, previousId, notifyIncompleteNotes, isCurrent = () => true) {
|
|
17
|
+
const identity = notesIdentityFromPi(ctx);
|
|
18
|
+
const notes = await loadNotesSnapshot(identity, Date.now());
|
|
19
|
+
if (isCurrent())
|
|
20
|
+
notifyIncompleteNotes?.(ctx, windowId, notes);
|
|
21
|
+
return {
|
|
22
|
+
customType: BOOT_TYPE,
|
|
23
|
+
content: bootContent(identity.agent, identity.model, rootWindowId(identity.sessionId), windowId, previousId, notes),
|
|
24
|
+
display: false,
|
|
25
|
+
details: { windowId },
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/** Persist one hidden boot message without triggering a model turn. */
|
|
29
|
+
export function sendBoot(pi, boot) {
|
|
30
|
+
pi.sendMessage({ customType: boot.customType, content: boot.content, display: boot.display, details: boot.details }, { triggerTurn: false });
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Boot entry point for `session_start` / `session_tree`. Ordinary startup ensures one root
|
|
34
|
+
* boot; a reset marker instead asks reset-artifact repair to complete its persisted tail.
|
|
35
|
+
*/
|
|
36
|
+
export async function ensureBoot(pi, ctx, notifyIncompleteNotes, isCurrent = () => true) {
|
|
37
|
+
const sessionId = ctx.sessionManager.getSessionId();
|
|
38
|
+
const reset = currentReset(ctx);
|
|
39
|
+
const windowId = reset?.data.windowId ?? rootWindowId(sessionId);
|
|
40
|
+
const stillCurrent = () => isCurrent() &&
|
|
41
|
+
ctx.signal?.aborted !== true &&
|
|
42
|
+
ctx.sessionManager.getSessionId() === sessionId &&
|
|
43
|
+
currentWindowId(ctx) === windowId;
|
|
44
|
+
if (reset) {
|
|
45
|
+
await repairResetTail(pi, ctx, reset, notifyIncompleteNotes, stillCurrent);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (ctx.sessionManager.buildSessionProjection().messages.some((message) => isWindowBoot(message, windowId)))
|
|
49
|
+
return;
|
|
50
|
+
const boot = await buildBootMessage(ctx, windowId, undefined, notifyIncompleteNotes, stillCurrent);
|
|
51
|
+
if (!stillCurrent())
|
|
52
|
+
return;
|
|
53
|
+
if (ctx.sessionManager.buildSessionProjection().messages.some((message) => isWindowBoot(message, windowId)))
|
|
54
|
+
return;
|
|
55
|
+
sendBoot(pi, boot);
|
|
56
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ExtensionAPI, type ExtensionContext, type SessionBoundaryDraft, type SettingsManager } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
/** Remaining tokens in the provider's active window, or null without a usable estimate. */
|
|
3
|
+
export declare function remainingTokens(ctx: Pick<ExtensionContext, "sessionManager" | "getContextUsage" | "model">): number | null;
|
|
4
|
+
export declare function registerBudget(pi: ExtensionAPI, isEnabled: () => boolean, settingsManager?: SettingsManager, onCloseOut?: (windowId: string) => void): {
|
|
5
|
+
automaticResetEnabled: (ctx: ExtensionContext) => boolean;
|
|
6
|
+
hardReserveDue: (ctx: ExtensionContext) => boolean;
|
|
7
|
+
consumeTurnEnd: (ctx: ExtensionContext) => SessionBoundaryDraft[];
|
|
8
|
+
/** The same close-out countdown the model sees, for user-facing status; null when usage is unknown. */
|
|
9
|
+
statusFor: (ctx: ExtensionContext) => {
|
|
10
|
+
remaining: number | null;
|
|
11
|
+
};
|
|
12
|
+
clear: () => void;
|
|
13
|
+
};
|