glimmervoid 0.29.1 → 0.31.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.
Files changed (67) hide show
  1. package/README.md +8 -10
  2. package/dist/bin/glimmervoid.js +152 -53
  3. package/dist/chunks/{adapters-DIavI9-i.js → adapters-ClA_GbtA.js} +1 -1
  4. package/dist/chunks/{adapters-Dlvu1FVB.js → adapters-gn7ulNO4.js} +49 -20
  5. package/dist/chunks/agent-api-cli-DAA7Jx8N.js +135 -0
  6. package/dist/chunks/{agent-api-core-D6LHrpSL.js → agent-api-core-hVcT26JW.js} +10 -1
  7. package/dist/chunks/{agent-setup-cli-C1CQ8Nkk.js → agent-setup-cli-CiJSDWSo.js} +15 -30
  8. package/dist/chunks/backoff-DjVpfHk7.js +14 -0
  9. package/dist/chunks/child-process-safe-BKPZ-5qQ.js +2 -0
  10. package/dist/chunks/{child-process-safe-Cz22RwlG.js → child-process-safe-Ch-Zgxqs.js} +2 -2
  11. package/dist/chunks/coerce-NSst8oRP.js +32 -0
  12. package/dist/chunks/{contracts-JKChPhZ0.js → config-W1Sv-iPK.js} +380 -1682
  13. package/dist/chunks/{config-store-DtPUFVaO.js → config-store-BCy4FHNG.js} +595 -327
  14. package/dist/chunks/config-store-DbBp7LJZ.js +2 -0
  15. package/dist/chunks/contracts-3LkrilQX.js +2078 -0
  16. package/dist/chunks/{grok-COekzawt.js → grok-CXKeSt2z.js} +69 -36
  17. package/dist/chunks/hook-command-core-DclEoE9e.js +14 -0
  18. package/dist/chunks/{hook-relay-core-BHfYFnYV.js → hook-relay-core-DA_bz2KA.js} +10 -5
  19. package/dist/chunks/hook-tools-UX2fmt81.js +72 -0
  20. package/dist/chunks/{ingest-editor-core-BuI1gMF_.js → ingest-editor-core-vR6Wv6bP.js} +24 -13
  21. package/dist/chunks/json-core-dfa_7Fak.js +23 -0
  22. package/dist/chunks/json-file-oEH9vt-0.js +352 -0
  23. package/dist/chunks/knowledge-graph-cli-D2tt5hPn.js +1354 -0
  24. package/dist/chunks/{loopback-post-C7C22eYi.js → loopback-post-DepQfdcM.js} +40 -26
  25. package/dist/chunks/{main-BVDjy7vH.js → main-DyTCWIu2.js} +28881 -20693
  26. package/dist/chunks/{node-pty-preflight-CK1knGIR.js → node-pty-preflight-C8QIlrtU.js} +4 -6
  27. package/dist/chunks/{pair-cli-BQQnhkkc.js → pair-cli-BbCBfd6l.js} +4 -3
  28. package/dist/chunks/paths-CeJl2Vcg.js +55 -0
  29. package/dist/chunks/{remote-config-BHoDFCpo.js → remote-config-DKIH_VxM.js} +43 -43
  30. package/dist/chunks/rtk-hook-core-BmEz2aq9.js +131 -0
  31. package/dist/chunks/rtk-resolver-BGDzw5XK.js +21 -0
  32. package/dist/chunks/rtk-resolver-D4Nke1Fr.js +2 -0
  33. package/dist/chunks/{runtime-paths-CVvq20A4.js → runtime-paths-BPoxENmK.js} +28 -8
  34. package/dist/chunks/runtime-paths-DU5jBEEO.js +2 -0
  35. package/dist/chunks/{sandbox-deps-BwvbDBDl.js → sandbox-deps-BPKE-ylr.js} +16 -13
  36. package/dist/chunks/sandbox-proxy-core-hnQgKR0T.js +27 -0
  37. package/dist/chunks/{session-CJtOveHl.js → session-fc4pFbon.js} +10 -2
  38. package/dist/chunks/text-DoirglWV.js +21 -0
  39. package/dist/chunks/timer-deps-u2DAQLok.js +15 -0
  40. package/dist/chunks/{visions-cli-DUZnopGY.js → visions-cli-CT5rjiwf.js} +1 -1
  41. package/dist/chunks/{visions-setup-C_kJobsy.js → visions-setup-BmOkI-QE.js} +20 -357
  42. package/dist/client/assets/index-C6KD8lgZ.css +1 -0
  43. package/dist/client/assets/index-CThQEAEy.js +249 -0
  44. package/dist/client/fonts/CommitMono-OFL.txt +92 -0
  45. package/dist/client/fonts/commit-mono-400-italic.woff2 +0 -0
  46. package/dist/client/fonts/commit-mono-400-regular.woff2 +0 -0
  47. package/dist/client/fonts/commit-mono-700-italic.woff2 +0 -0
  48. package/dist/client/fonts/commit-mono-700-regular.woff2 +0 -0
  49. package/dist/client/index.html +7 -24
  50. package/dist/client/octicons-LICENSE.txt +21 -0
  51. package/dist/scripts/postinstall-path-check.js +1 -1
  52. package/dist/server/index.js +3 -3
  53. package/dist/session/command-hook-relay.js +1 -1
  54. package/dist/session/hook-relay.js +3 -3
  55. package/dist/session/{rtk-relay.js → hook-tool-relay.js} +32 -15
  56. package/dist/session/sandbox-open-launcher.js +79 -0
  57. package/dist/session/statusline-relay.js +8 -18
  58. package/dist/session/visions-relay.js +20 -11
  59. package/package.json +5 -1
  60. package/dist/chunks/agent-api-cli-ClOzm28U.js +0 -71
  61. package/dist/chunks/config-store-DtUGwi4-.js +0 -2
  62. package/dist/chunks/ingest-core-DWI1Mbu4.js +0 -342
  63. package/dist/chunks/rtk-hook-core-DRYrKwYP.js +0 -26
  64. package/dist/chunks/rtk-resolver-DDVVNRBT.js +0 -2
  65. package/dist/chunks/rtk-resolver-oGmO-ew7.js +0 -58
  66. package/dist/client/assets/index-BTwYgSAH.js +0 -248
  67. package/dist/client/assets/index-DgA708PE.css +0 -1
@@ -0,0 +1,352 @@
1
+ import { a as isMissingFileError, r as errorMessage } from "./text-DoirglWV.js";
2
+ import { r as nextBackoffMs } from "./backoff-DjVpfHk7.js";
3
+ import fs from "node:fs";
4
+ import path from "node:path";
5
+ import crypto from "node:crypto";
6
+ //#region server/spawn-gate.ts
7
+ var QUEUE_ADMISSION_TIMED_OUT = "serial-queue-admission-timed-out";
8
+ function isQueueAdmissionTimeout(error) {
9
+ return error instanceof Error && error.message === "serial-queue-admission-timed-out";
10
+ }
11
+ function createSerialQueue() {
12
+ let tail = Promise.resolve();
13
+ function run(fn, options = {}) {
14
+ let abandoned = false;
15
+ let started = false;
16
+ const result = tail.then(() => {
17
+ if (abandoned) throw new Error(QUEUE_ADMISSION_TIMED_OUT);
18
+ started = true;
19
+ return fn();
20
+ });
21
+ tail = result.then(() => void 0, () => void 0);
22
+ const admissionTimeoutMs = options.admissionTimeoutMs;
23
+ if (admissionTimeoutMs === void 0) return result;
24
+ return new Promise((resolve, reject) => {
25
+ const admissionTimer = setTimeout(() => {
26
+ if (started) return;
27
+ abandoned = true;
28
+ reject(/* @__PURE__ */ new Error(QUEUE_ADMISSION_TIMED_OUT));
29
+ }, admissionTimeoutMs);
30
+ result.then((value) => {
31
+ clearTimeout(admissionTimer);
32
+ resolve(value);
33
+ }, (error) => {
34
+ clearTimeout(admissionTimer);
35
+ reject(error);
36
+ });
37
+ });
38
+ }
39
+ return {
40
+ run,
41
+ idle: () => tail
42
+ };
43
+ }
44
+ function createKeyedSerialQueue() {
45
+ const queuesByKey = /* @__PURE__ */ new Map();
46
+ function run(key, fn) {
47
+ const entry = queuesByKey.get(key) ?? {
48
+ queue: createSerialQueue(),
49
+ pendingCount: 0
50
+ };
51
+ queuesByKey.set(key, entry);
52
+ entry.pendingCount += 1;
53
+ const result = entry.queue.run(fn);
54
+ result.then(() => void 0, () => void 0).then(() => {
55
+ entry.pendingCount -= 1;
56
+ if (entry.pendingCount === 0 && queuesByKey.get(key) === entry) queuesByKey.delete(key);
57
+ });
58
+ return result;
59
+ }
60
+ return { run };
61
+ }
62
+ var createSpawnGate = createSerialQueue;
63
+ //#endregion
64
+ //#region server/json-file.ts
65
+ function tmpPathFor(filePath) {
66
+ return `${filePath}.${process.pid}.${crypto.randomBytes(8).toString("hex")}.tmp`;
67
+ }
68
+ function writeOptions(mode, encoding, exclusive) {
69
+ return {
70
+ encoding,
71
+ ...mode == null ? {} : { mode },
72
+ ...exclusive ? { flag: "wx" } : {}
73
+ };
74
+ }
75
+ var RENAME_RETRY_CODES = /* @__PURE__ */ new Set([
76
+ "EPERM",
77
+ "EACCES",
78
+ "EBUSY"
79
+ ]);
80
+ var RENAME_RETRY_BASE_MS = 10;
81
+ var RENAME_RETRY_MAX_MS = 50;
82
+ function renameRetryDelayMs(attempt) {
83
+ return nextBackoffMs({
84
+ attempt: attempt + 1,
85
+ baseMs: RENAME_RETRY_BASE_MS,
86
+ maxMs: RENAME_RETRY_MAX_MS,
87
+ jitter: "none"
88
+ });
89
+ }
90
+ function isRetryableRename(error, attempt) {
91
+ if (attempt >= 4) return false;
92
+ const code = error?.code;
93
+ return typeof code === "string" && RENAME_RETRY_CODES.has(code);
94
+ }
95
+ function sleepSync(ms) {
96
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
97
+ }
98
+ function renameRetryPlan(error, attempt) {
99
+ if (!isRetryableRename(error, attempt)) return null;
100
+ return renameRetryDelayMs(attempt);
101
+ }
102
+ function decodeJsonState(text, parse) {
103
+ try {
104
+ const value = parse(JSON.parse(text));
105
+ if (value !== null) return { value };
106
+ return { error: /* @__PURE__ */ new Error("the parser rejected the file content") };
107
+ } catch (error) {
108
+ return { error };
109
+ }
110
+ }
111
+ async function loadJsonStateFile({ filePath, fsPromises = fs.promises, parse, nowMs = Date.now, quarantine = true, includeNotDir = true }) {
112
+ let text;
113
+ try {
114
+ text = await fsPromises.readFile(filePath, "utf8");
115
+ } catch (error) {
116
+ if (isMissingFileError(error, { includeNotDir })) return { status: "missing" };
117
+ return {
118
+ status: "unreadable",
119
+ error
120
+ };
121
+ }
122
+ const decoded = decodeJsonState(text, parse);
123
+ if ("value" in decoded) return {
124
+ status: "loaded",
125
+ value: decoded.value
126
+ };
127
+ if (!quarantine || !fsPromises.rename) return {
128
+ status: "corrupt",
129
+ error: decoded.error
130
+ };
131
+ const movedTo = `${filePath}.corrupt-${nowMs()}`;
132
+ try {
133
+ await fsPromises.rename(filePath, movedTo);
134
+ } catch (error) {
135
+ return {
136
+ status: "unreadable",
137
+ error
138
+ };
139
+ }
140
+ return {
141
+ status: "quarantined",
142
+ movedTo
143
+ };
144
+ }
145
+ function loadJsonStateFileSync({ filePath, fsSync = fs, parse, nowMs = Date.now, quarantine = true, includeNotDir = true }) {
146
+ let text;
147
+ try {
148
+ text = fsSync.readFileSync(filePath, "utf8");
149
+ } catch (error) {
150
+ if (isMissingFileError(error, { includeNotDir })) return { status: "missing" };
151
+ return {
152
+ status: "unreadable",
153
+ error
154
+ };
155
+ }
156
+ const decoded = decodeJsonState(text, parse);
157
+ if ("value" in decoded) return {
158
+ status: "loaded",
159
+ value: decoded.value
160
+ };
161
+ if (!quarantine || !fsSync.renameSync) return {
162
+ status: "corrupt",
163
+ error: decoded.error
164
+ };
165
+ const movedTo = `${filePath}.corrupt-${nowMs()}`;
166
+ try {
167
+ fsSync.renameSync(filePath, movedTo);
168
+ } catch (error) {
169
+ return {
170
+ status: "unreadable",
171
+ error
172
+ };
173
+ }
174
+ return {
175
+ status: "quarantined",
176
+ movedTo
177
+ };
178
+ }
179
+ function loadedJsonValue(outcome) {
180
+ return outcome.status === "loaded" ? outcome.value : null;
181
+ }
182
+ function jsonStateLoadError(outcome) {
183
+ if ("error" in outcome) return outcome.error;
184
+ return /* @__PURE__ */ new Error(`the state file is ${outcome.status}`);
185
+ }
186
+ function renameWithRetrySync(fsSync, tmpPath, filePath) {
187
+ for (let attempt = 0;; attempt += 1) try {
188
+ fsSync.renameSync(tmpPath, filePath);
189
+ return;
190
+ } catch (error) {
191
+ const delayMs = renameRetryPlan(error, attempt);
192
+ if (delayMs === null) throw error;
193
+ sleepSync(delayMs);
194
+ }
195
+ }
196
+ async function renameWithRetry(fsPromises, tmpPath, filePath) {
197
+ for (let attempt = 0;; attempt += 1) try {
198
+ await fsPromises.rename(tmpPath, filePath);
199
+ return;
200
+ } catch (error) {
201
+ const delayMs = renameRetryPlan(error, attempt);
202
+ if (delayMs === null) throw error;
203
+ await new Promise((resolve) => {
204
+ setTimeout(resolve, delayMs);
205
+ });
206
+ }
207
+ }
208
+ function mkdirSyncOf(fsSync) {
209
+ if (!fsSync.mkdirSync) throw new Error("the file system cannot create directories");
210
+ return fsSync.mkdirSync;
211
+ }
212
+ function mkdirOf(fsPromises) {
213
+ if (!fsPromises.mkdir) throw new Error("the file system cannot create directories");
214
+ return fsPromises.mkdir;
215
+ }
216
+ function appendFileOf(fsPromises) {
217
+ if (!fsPromises.appendFile) throw new Error("the file system cannot append to files");
218
+ return fsPromises.appendFile;
219
+ }
220
+ function writeTextAtomicSync(filePath, content, { mode, encoding = "utf8", mkdir = false, exclusive = false, enforceMode = false, fsSync = fs } = {}) {
221
+ if (mkdir) mkdirSyncOf(fsSync)(path.dirname(filePath), { recursive: true });
222
+ const tmpPath = tmpPathFor(filePath);
223
+ try {
224
+ fsSync.writeFileSync(tmpPath, content, writeOptions(mode, encoding, exclusive));
225
+ renameWithRetrySync(fsSync, tmpPath, filePath);
226
+ } catch (error) {
227
+ try {
228
+ fsSync.rmSync(tmpPath, { force: true });
229
+ } catch {}
230
+ throw error;
231
+ }
232
+ if (!enforceMode || mode == null || !fsSync.chmodSync) return;
233
+ try {
234
+ fsSync.chmodSync(filePath, mode);
235
+ } catch {}
236
+ }
237
+ function writeJsonAtomicSync(filePath, value, options) {
238
+ writeTextAtomicSync(filePath, JSON.stringify(value, null, 2), options);
239
+ }
240
+ async function writeTextAtomic(filePath, content, { mode, encoding = "utf8", mkdir = false, exclusive = false, enforceMode = false, fsPromises = fs.promises } = {}) {
241
+ if (mkdir) await mkdirOf(fsPromises)(path.dirname(filePath), { recursive: true });
242
+ const tmpPath = tmpPathFor(filePath);
243
+ try {
244
+ await fsPromises.writeFile(tmpPath, content, writeOptions(mode, encoding, exclusive));
245
+ await renameWithRetry(fsPromises, tmpPath, filePath);
246
+ } catch (error) {
247
+ try {
248
+ await fsPromises.rm(tmpPath, { force: true });
249
+ } catch {}
250
+ throw error;
251
+ }
252
+ if (!enforceMode || mode == null || !fsPromises.chmod) return;
253
+ try {
254
+ await fsPromises.chmod(filePath, mode);
255
+ } catch {}
256
+ }
257
+ async function writeJsonAtomic(filePath, value, options) {
258
+ await writeTextAtomic(filePath, JSON.stringify(value, null, 2), options);
259
+ }
260
+ var appendQueue = createKeyedSerialQueue();
261
+ function appendChained(filePath, payload, { fsPromises = fs.promises, mkdir = false, encoding = "utf8", mode } = {}) {
262
+ return appendQueue.run(filePath, async () => {
263
+ if (mkdir) await mkdirOf(fsPromises)(path.dirname(filePath), { recursive: true });
264
+ await appendFileOf(fsPromises)(filePath, payload, writeOptions(mode, encoding, false));
265
+ });
266
+ }
267
+ function appendJsonLine(filePath, value, options) {
268
+ return appendChained(filePath, `${JSON.stringify(value)}\n`, options);
269
+ }
270
+ function appendJsonLines(filePath, values, options) {
271
+ if (values.length === 0) return Promise.resolve();
272
+ return appendChained(filePath, values.map((value) => `${JSON.stringify(value)}\n`).join(""), options);
273
+ }
274
+ function createJsonStateWriter({ filePath, fsPromises = fs.promises, warn = () => {} }) {
275
+ let signature = null;
276
+ const writeQueue = createSerialQueue();
277
+ async function commit(payload) {
278
+ try {
279
+ await writeTextAtomic(filePath, payload, {
280
+ fsPromises,
281
+ mkdir: true
282
+ });
283
+ } catch (error) {
284
+ warn(error);
285
+ signature = null;
286
+ }
287
+ }
288
+ async function write(subject, buildPayload) {
289
+ const next = JSON.stringify(subject);
290
+ if (next === signature) return;
291
+ signature = next;
292
+ await writeQueue.run(() => commit(buildPayload())).catch(() => {});
293
+ }
294
+ function reset() {
295
+ signature = null;
296
+ }
297
+ return {
298
+ write,
299
+ reset,
300
+ idle: () => writeQueue.idle()
301
+ };
302
+ }
303
+ function createJsonStateStore({ name, filePath, fsPromises = fs.promises, parse, adopt, nowMs = Date.now, warn = () => {} }) {
304
+ const writer = filePath ? createJsonStateWriter({
305
+ filePath,
306
+ fsPromises,
307
+ warn: (error) => warn(`${name} write failed`, { error: errorMessage(error) })
308
+ }) : null;
309
+ let isFileReadable = true;
310
+ let loadPromise = null;
311
+ function load() {
312
+ const statePath = filePath;
313
+ if (!statePath) return Promise.resolve();
314
+ if (loadPromise) return loadPromise;
315
+ loadPromise = (async () => {
316
+ const outcome = await loadJsonStateFile({
317
+ filePath: statePath,
318
+ fsPromises,
319
+ parse,
320
+ nowMs
321
+ });
322
+ if (outcome.status === "unreadable" || outcome.status === "corrupt") {
323
+ isFileReadable = false;
324
+ loadPromise = null;
325
+ warn(`${name} unreadable`, {
326
+ path: statePath,
327
+ error: errorMessage(outcome.error)
328
+ });
329
+ return;
330
+ }
331
+ if (outcome.status === "quarantined") warn(`${name} quarantined`, {
332
+ path: statePath,
333
+ movedTo: outcome.movedTo
334
+ });
335
+ isFileReadable = true;
336
+ adopt(loadedJsonValue(outcome));
337
+ writer?.reset();
338
+ })();
339
+ return loadPromise;
340
+ }
341
+ async function write(subject, buildPayload) {
342
+ if (!writer || !isFileReadable) return;
343
+ await writer.write(subject, buildPayload);
344
+ }
345
+ return {
346
+ load,
347
+ write,
348
+ idle: () => writer ? writer.idle() : Promise.resolve()
349
+ };
350
+ }
351
+ //#endregion
352
+ export { isQueueAdmissionTimeout as _, jsonStateLoadError as a, loadedJsonValue as c, writeJsonAtomicSync as d, writeTextAtomic as f, createSpawnGate as g, createSerialQueue as h, createJsonStateWriter as i, sleepSync as l, createKeyedSerialQueue as m, appendJsonLines as n, loadJsonStateFile as o, writeTextAtomicSync as p, createJsonStateStore as r, loadJsonStateFileSync as s, appendJsonLine as t, writeJsonAtomic as u };