@graphrefly/ts 0.0.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 (210) hide show
  1. package/LICENSE +21 -0
  2. package/dist/adapters/index.cjs +9015 -0
  3. package/dist/adapters/index.cjs.map +1 -0
  4. package/dist/adapters/index.d.cts +678 -0
  5. package/dist/adapters/index.d.ts +678 -0
  6. package/dist/adapters/index.js +2894 -0
  7. package/dist/adapters/index.js.map +1 -0
  8. package/dist/adapters/observe-storage.cjs +260 -0
  9. package/dist/adapters/observe-storage.cjs.map +1 -0
  10. package/dist/adapters/observe-storage.d.cts +77 -0
  11. package/dist/adapters/observe-storage.d.ts +77 -0
  12. package/dist/adapters/observe-storage.js +161 -0
  13. package/dist/adapters/observe-storage.js.map +1 -0
  14. package/dist/append-log-DisvEReb.d.cts +189 -0
  15. package/dist/append-log-DzKMmjxx.d.ts +189 -0
  16. package/dist/chunk-2ILL7HQI.js +1189 -0
  17. package/dist/chunk-2ILL7HQI.js.map +1 -0
  18. package/dist/chunk-4VLAQHZI.js +330 -0
  19. package/dist/chunk-4VLAQHZI.js.map +1 -0
  20. package/dist/chunk-6PHB5CJS.js +229 -0
  21. package/dist/chunk-6PHB5CJS.js.map +1 -0
  22. package/dist/chunk-COHO25CZ.js +2449 -0
  23. package/dist/chunk-COHO25CZ.js.map +1 -0
  24. package/dist/chunk-D6BG7U6A.js +161 -0
  25. package/dist/chunk-D6BG7U6A.js.map +1 -0
  26. package/dist/chunk-DJC4CHLQ.js +818 -0
  27. package/dist/chunk-DJC4CHLQ.js.map +1 -0
  28. package/dist/chunk-DK554R7P.js +67 -0
  29. package/dist/chunk-DK554R7P.js.map +1 -0
  30. package/dist/chunk-DKP56CSW.js +322 -0
  31. package/dist/chunk-DKP56CSW.js.map +1 -0
  32. package/dist/chunk-G4M3NHRJ.js +688 -0
  33. package/dist/chunk-G4M3NHRJ.js.map +1 -0
  34. package/dist/chunk-GAJW5I5P.js +1 -0
  35. package/dist/chunk-GAJW5I5P.js.map +1 -0
  36. package/dist/chunk-GDL26N2T.js +282 -0
  37. package/dist/chunk-GDL26N2T.js.map +1 -0
  38. package/dist/chunk-GTPCOEOZ.js +741 -0
  39. package/dist/chunk-GTPCOEOZ.js.map +1 -0
  40. package/dist/chunk-H2HTHFVN.js +1 -0
  41. package/dist/chunk-H2HTHFVN.js.map +1 -0
  42. package/dist/chunk-HDRL4VQQ.js +218 -0
  43. package/dist/chunk-HDRL4VQQ.js.map +1 -0
  44. package/dist/chunk-I3IHOHCJ.js +2267 -0
  45. package/dist/chunk-I3IHOHCJ.js.map +1 -0
  46. package/dist/chunk-JIMUDQN3.js +965 -0
  47. package/dist/chunk-JIMUDQN3.js.map +1 -0
  48. package/dist/chunk-JR4IKCR2.js +462 -0
  49. package/dist/chunk-JR4IKCR2.js.map +1 -0
  50. package/dist/chunk-K3FXTC3I.js +165 -0
  51. package/dist/chunk-K3FXTC3I.js.map +1 -0
  52. package/dist/chunk-OOEN33FB.js +65 -0
  53. package/dist/chunk-OOEN33FB.js.map +1 -0
  54. package/dist/chunk-PKVBHGBM.js +554 -0
  55. package/dist/chunk-PKVBHGBM.js.map +1 -0
  56. package/dist/chunk-RIIOUTGM.js +1857 -0
  57. package/dist/chunk-RIIOUTGM.js.map +1 -0
  58. package/dist/chunk-SCRFRCGR.js +33 -0
  59. package/dist/chunk-SCRFRCGR.js.map +1 -0
  60. package/dist/chunk-SWTLEQL6.js +53 -0
  61. package/dist/chunk-SWTLEQL6.js.map +1 -0
  62. package/dist/chunk-SZAETNNA.js +1 -0
  63. package/dist/chunk-SZAETNNA.js.map +1 -0
  64. package/dist/chunk-TEW47IVR.js +49 -0
  65. package/dist/chunk-TEW47IVR.js.map +1 -0
  66. package/dist/chunk-Y3ZLRGHC.js +1482 -0
  67. package/dist/chunk-Y3ZLRGHC.js.map +1 -0
  68. package/dist/chunk-Z2ANQ6JW.js +149 -0
  69. package/dist/chunk-Z2ANQ6JW.js.map +1 -0
  70. package/dist/codec-BB7p8fJc.d.cts +38 -0
  71. package/dist/codec-BB7p8fJc.d.ts +38 -0
  72. package/dist/composition/index.cjs +2505 -0
  73. package/dist/composition/index.cjs.map +1 -0
  74. package/dist/composition/index.d.cts +95 -0
  75. package/dist/composition/index.d.ts +95 -0
  76. package/dist/composition/index.js +19 -0
  77. package/dist/composition/index.js.map +1 -0
  78. package/dist/core/index.cjs +2475 -0
  79. package/dist/core/index.cjs.map +1 -0
  80. package/dist/core/index.d.cts +25 -0
  81. package/dist/core/index.d.ts +25 -0
  82. package/dist/core/index.js +74 -0
  83. package/dist/core/index.js.map +1 -0
  84. package/dist/cqrs/index.cjs +595 -0
  85. package/dist/cqrs/index.cjs.map +1 -0
  86. package/dist/cqrs/index.d.cts +200 -0
  87. package/dist/cqrs/index.d.ts +200 -0
  88. package/dist/cqrs/index.js +557 -0
  89. package/dist/cqrs/index.js.map +1 -0
  90. package/dist/data-structures/index.cjs +4277 -0
  91. package/dist/data-structures/index.cjs.map +1 -0
  92. package/dist/data-structures/index.d.cts +22 -0
  93. package/dist/data-structures/index.d.ts +22 -0
  94. package/dist/data-structures/index.js +31 -0
  95. package/dist/data-structures/index.js.map +1 -0
  96. package/dist/describe-BZb7AS2y.d.ts +57 -0
  97. package/dist/describe-Ciu8SUnN.d.cts +57 -0
  98. package/dist/graph/index.cjs +7832 -0
  99. package/dist/graph/index.cjs.map +1 -0
  100. package/dist/graph/index.d.cts +251 -0
  101. package/dist/graph/index.d.ts +251 -0
  102. package/dist/graph/index.js +131 -0
  103. package/dist/graph/index.js.map +1 -0
  104. package/dist/graph-DfdF9zy4.d.ts +666 -0
  105. package/dist/graph-s23RbbFO.d.cts +666 -0
  106. package/dist/index-CAEmLCYF.d.cts +166 -0
  107. package/dist/index-SnzZu3x7.d.ts +166 -0
  108. package/dist/index.cjs +15409 -0
  109. package/dist/index.cjs.map +1 -0
  110. package/dist/index.d.cts +23 -0
  111. package/dist/index.d.ts +23 -0
  112. package/dist/index.js +582 -0
  113. package/dist/index.js.map +1 -0
  114. package/dist/messages-BZqrGGm1.d.cts +55 -0
  115. package/dist/messages-BZqrGGm1.d.ts +55 -0
  116. package/dist/messaging/index.cjs +818 -0
  117. package/dist/messaging/index.cjs.map +1 -0
  118. package/dist/messaging/index.d.cts +235 -0
  119. package/dist/messaging/index.d.ts +235 -0
  120. package/dist/messaging/index.js +767 -0
  121. package/dist/messaging/index.js.map +1 -0
  122. package/dist/observe-event-log-0SVsx7JG.d.cts +88 -0
  123. package/dist/observe-event-log-Dnm76owp.d.ts +88 -0
  124. package/dist/operators/index.cjs +3774 -0
  125. package/dist/operators/index.cjs.map +1 -0
  126. package/dist/operators/index.d.cts +308 -0
  127. package/dist/operators/index.d.ts +308 -0
  128. package/dist/operators/index.js +112 -0
  129. package/dist/operators/index.js.map +1 -0
  130. package/dist/orchestration/index.cjs +3541 -0
  131. package/dist/orchestration/index.cjs.map +1 -0
  132. package/dist/orchestration/index.d.cts +302 -0
  133. package/dist/orchestration/index.d.ts +302 -0
  134. package/dist/orchestration/index.js +1004 -0
  135. package/dist/orchestration/index.js.map +1 -0
  136. package/dist/patterns/index.cjs +1045 -0
  137. package/dist/patterns/index.cjs.map +1 -0
  138. package/dist/patterns/index.d.cts +39 -0
  139. package/dist/patterns/index.d.ts +39 -0
  140. package/dist/patterns/index.js +33 -0
  141. package/dist/patterns/index.js.map +1 -0
  142. package/dist/reactive-collection-BxBqtIOE.d.cts +344 -0
  143. package/dist/reactive-collection-Cb1II1Fi.d.ts +344 -0
  144. package/dist/reactive-collection-storage-BNiEc-Gd.d.ts +217 -0
  145. package/dist/reactive-collection-storage-D-KmjE0J.d.cts +217 -0
  146. package/dist/reactive-map-BcB4KsQR.d.ts +256 -0
  147. package/dist/reactive-map-D-g3dv8I.d.cts +256 -0
  148. package/dist/read-through-B1CYPfq_.d.cts +82 -0
  149. package/dist/read-through-DwyJhGs1.d.ts +82 -0
  150. package/dist/render/index.cjs +250 -0
  151. package/dist/render/index.cjs.map +1 -0
  152. package/dist/render/index.d.cts +58 -0
  153. package/dist/render/index.d.ts +58 -0
  154. package/dist/render/index.js +20 -0
  155. package/dist/render/index.js.map +1 -0
  156. package/dist/resilience-Dig3Q7n0.d.cts +45 -0
  157. package/dist/resilience-Dig3Q7n0.d.ts +45 -0
  158. package/dist/semantic-memory-graph-BYoIlP35.d.cts +356 -0
  159. package/dist/semantic-memory-graph-CxyXLms3.d.ts +356 -0
  160. package/dist/solutions/index.cjs +3249 -0
  161. package/dist/solutions/index.cjs.map +1 -0
  162. package/dist/solutions/index.d.cts +520 -0
  163. package/dist/solutions/index.d.ts +520 -0
  164. package/dist/solutions/index.js +31 -0
  165. package/dist/solutions/index.js.map +1 -0
  166. package/dist/sources/browser.cjs +3095 -0
  167. package/dist/sources/browser.cjs.map +1 -0
  168. package/dist/sources/browser.d.cts +39 -0
  169. package/dist/sources/browser.d.ts +39 -0
  170. package/dist/sources/browser.js +137 -0
  171. package/dist/sources/browser.js.map +1 -0
  172. package/dist/sources/index.cjs +3021 -0
  173. package/dist/sources/index.cjs.map +1 -0
  174. package/dist/sources/index.d.cts +7 -0
  175. package/dist/sources/index.d.ts +7 -0
  176. package/dist/sources/index.js +63 -0
  177. package/dist/sources/index.js.map +1 -0
  178. package/dist/sources/node.cjs +675 -0
  179. package/dist/sources/node.cjs.map +1 -0
  180. package/dist/sources/node.d.cts +109 -0
  181. package/dist/sources/node.d.ts +109 -0
  182. package/dist/sources/node.js +639 -0
  183. package/dist/sources/node.js.map +1 -0
  184. package/dist/storage/browser.cjs +777 -0
  185. package/dist/storage/browser.cjs.map +1 -0
  186. package/dist/storage/browser.d.cts +40 -0
  187. package/dist/storage/browser.d.ts +40 -0
  188. package/dist/storage/browser.js +275 -0
  189. package/dist/storage/browser.js.map +1 -0
  190. package/dist/storage/index.cjs +1989 -0
  191. package/dist/storage/index.cjs.map +1 -0
  192. package/dist/storage/index.d.cts +92 -0
  193. package/dist/storage/index.d.ts +92 -0
  194. package/dist/storage/index.js +161 -0
  195. package/dist/storage/index.js.map +1 -0
  196. package/dist/storage/node.cjs +898 -0
  197. package/dist/storage/node.cjs.map +1 -0
  198. package/dist/storage/node.d.cts +66 -0
  199. package/dist/storage/node.d.ts +66 -0
  200. package/dist/storage/node.js +402 -0
  201. package/dist/storage/node.js.map +1 -0
  202. package/dist/testing/index.cjs +95 -0
  203. package/dist/testing/index.cjs.map +1 -0
  204. package/dist/testing/index.d.cts +20 -0
  205. package/dist/testing/index.d.ts +20 -0
  206. package/dist/testing/index.js +8 -0
  207. package/dist/testing/index.js.map +1 -0
  208. package/dist/types-bNMSWKqF.d.cts +732 -0
  209. package/dist/types-h12mNYbq.d.ts +732 -0
  210. package/package.json +250 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/sources/node.ts","../../src/protocol/messages.ts"],"sourcesContent":["/**\n * Node-only source factories. Import from `@graphrefly/ts/sources/node`; the universal\n * `@graphrefly/ts/sources` barrel stays browser-safe.\n */\n\nimport { execFileSync, type SpawnOptions, spawn } from \"node:child_process\";\nimport { type Dirent, existsSync, type FSWatcher, readdirSync, statSync, watch } from \"node:fs\";\nimport { dirname, join, relative, resolve as resolvePath } from \"node:path\";\nimport type { Ctx } from \"../ctx/types.js\";\nimport type {\n\tDriverResult,\n\tProcessResult as EnvironmentProcessResult,\n\tLocalProcessDriver,\n\tProcessCommand,\n} from \"../graph/environment.js\";\nimport type { Operator } from \"../graph/operators.js\";\nimport { errorPayload } from \"../protocol/messages.js\";\n\nexport type FSEventType = \"change\" | \"rename\" | \"create\" | \"delete\";\n\nexport interface FSEvent {\n\treadonly type: FSEventType;\n\treadonly path: string;\n\treadonly root: string;\n\treadonly relativePath: string;\n}\n\nexport interface FromFSWatchOptions {\n\t/** Use Node's recursive fs.watch mode where the host platform supports it. Default: false. */\n\treadonly recursive?: boolean;\n\t/** Coalesce events per path for this many milliseconds. Default: 100. */\n\treadonly debounceMs?: number;\n\t/** Emit create events for existing files after watcher registration. Default: false. */\n\treadonly initialScan?: boolean | \"files\";\n\t/** Include glob patterns matched against absolute and relative slash-normalized paths. */\n\treadonly include?: readonly string[];\n\t/** Exclude glob patterns matched against absolute and relative slash-normalized paths. */\n\treadonly exclude?: readonly string[];\n\t/** AbortSignal aborts the source to ERROR and closes all watchers. */\n\treadonly signal?: AbortSignal;\n}\n\nexport type SpawnEvent =\n\t| { readonly kind: \"stdout\"; readonly chunk: Buffer }\n\t| { readonly kind: \"stderr\"; readonly chunk: Buffer }\n\t| { readonly kind: \"exit\"; readonly code: number | null; readonly signal: NodeJS.Signals | null };\n\nexport interface FromSpawnOptions {\n\treadonly cwd?: string;\n\treadonly env?: NodeJS.ProcessEnv;\n\treadonly shell?: boolean | string;\n\treadonly signal?: AbortSignal;\n\treadonly stdio?: \"pipe\" | readonly (\"pipe\" | \"ignore\" | \"inherit\")[];\n\t/** Milliseconds after teardown SIGTERM before sending SIGKILL. Default: 1000. */\n\treadonly killGraceMs?: number;\n}\n\n/**\n * Node-only process driver options for D130/D131 EnvironmentDrivers.\n *\n * These knobs configure host child-process behavior at the driver boundary only; they do not\n * change graph wave, tier, or message semantics.\n */\nexport interface NodeProcessDriverOptions {\n\t/** Milliseconds after cancellation SIGTERM before sending SIGKILL. Default: 1000. */\n\treadonly killGraceMs?: number;\n\t/** Maximum captured stdout + stderr bytes before terminating with ERROR. Default: 16 MiB. */\n\treadonly maxBufferBytes?: number;\n\t/** Optional shell mode passed to Node's child_process.spawn. Default: false. */\n\treadonly shell?: boolean | string;\n}\n\nexport interface ProcessResult {\n\treadonly stdout: string;\n\treadonly stderr: string;\n\treadonly exitCode: number | null;\n\treadonly signal: NodeJS.Signals | null;\n}\n\nexport type GitHookType = \"post-commit\" | \"post-merge\" | \"post-checkout\" | \"post-rewrite\";\n\nexport interface GitEvent {\n\treadonly hook: GitHookType;\n\treadonly commit: string;\n\treadonly files: readonly string[];\n\treadonly message: string;\n\treadonly author: string;\n\treadonly timestamp_ns: string;\n}\n\nexport interface FromGitHookOptions {\n\treadonly pollMs?: number;\n\treadonly include?: readonly string[];\n\treadonly exclude?: readonly string[];\n\treadonly maxConsecutiveErrors?: number;\n\treadonly signal?: AbortSignal;\n}\n\nfunction source<T>(\n\tfactory: string,\n\tsetup: (ctx: Ctx) => undefined | (() => void),\n): Operator<never, T> {\n\treturn {\n\t\tfactory,\n\t\tbody: (ctx) => {\n\t\t\tconst cleanup = setup(ctx);\n\t\t\tif (typeof cleanup === \"function\") ctx.onDeactivation(cleanup);\n\t\t},\n\t};\n}\n\nfunction normalizePath(path: string): string {\n\treturn path.replaceAll(\"\\\\\", \"/\");\n}\n\nfunction escapeRegExp(value: string): string {\n\treturn value.replace(/[|\\\\{}()[\\]^$+?.]/g, \"\\\\$&\");\n}\n\nfunction globToRegExp(pattern: string): RegExp {\n\tlet out = \"^\";\n\tfor (let i = 0; i < pattern.length; i += 1) {\n\t\tconst ch = pattern[i];\n\t\tif (ch === \"*\") {\n\t\t\tif (pattern[i + 1] === \"*\") {\n\t\t\t\tout += \".*\";\n\t\t\t\ti += 1;\n\t\t\t} else {\n\t\t\t\tout += \"[^/]*\";\n\t\t\t}\n\t\t} else {\n\t\t\tout += escapeRegExp(ch);\n\t\t}\n\t}\n\treturn new RegExp(`${out}$`);\n}\n\nfunction matchesAny(value: string, patterns: readonly RegExp[]): boolean {\n\treturn patterns.some((pattern) => pattern.test(value));\n}\n\nfunction timestampNsNow(): string {\n\treturn (BigInt(Date.now()) * 1_000_000n).toString();\n}\n\nfunction validatePositiveFinite(name: string, value: number): void {\n\tif (!Number.isFinite(value) || value <= 0) {\n\t\tthrow new RangeError(`${name} must be a positive finite number`);\n\t}\n}\n\nfunction validateNonNegativeFinite(name: string, value: number): void {\n\tif (!Number.isFinite(value) || value < 0) {\n\t\tthrow new RangeError(`${name} must be a non-negative finite number`);\n\t}\n}\n\nfunction eventTypeFor(eventType: \"rename\" | \"change\", path: string): FSEventType {\n\tif (eventType === \"change\") return \"change\";\n\ttry {\n\t\treturn existsSync(path) ? \"create\" : \"delete\";\n\t} catch {\n\t\treturn \"rename\";\n\t}\n}\n\nfunction scanFiles(\n\troot: string,\n\trecursive: boolean,\n\tisExcluded: (abs: string, rel: string) => boolean,\n): readonly string[] {\n\tconst resolved = resolvePath(root);\n\ttry {\n\t\tconst st = statSync(resolved);\n\t\tif (st.isFile()) return [resolved];\n\t\tif (!st.isDirectory()) return [];\n\t} catch {\n\t\treturn [];\n\t}\n\n\tconst out: string[] = [];\n\tfunction walk(dir: string): void {\n\t\tlet entries: Dirent[];\n\t\ttry {\n\t\t\tentries = readdirSync(dir, { withFileTypes: true });\n\t\t} catch {\n\t\t\treturn;\n\t\t}\n\t\tfor (const entry of entries) {\n\t\t\tconst abs = join(dir, entry.name);\n\t\t\tconst rel = relative(resolved, abs);\n\t\t\tif (entry.isFile()) {\n\t\t\t\tout.push(abs);\n\t\t\t} else if (recursive && entry.isDirectory() && !isExcluded(abs, rel)) {\n\t\t\t\twalk(abs);\n\t\t\t}\n\t\t}\n\t}\n\twalk(resolved);\n\treturn out;\n}\n\n/**\n * fromFSWatch: Node.js filesystem watcher source.\n *\n * External fs callbacks are a source boundary (R-no-raw-async): events enter the graph only via\n * `ctx.down`, and cleanup is tied to node deactivation through `ctx.onDeactivation`.\n */\nexport function fromFSWatch(\n\tpaths: string | readonly string[],\n\topts: FromFSWatchOptions = {},\n): Operator<never, FSEvent> {\n\tconst list = (Array.isArray(paths) ? paths : [paths]).map((path) => resolvePath(path));\n\tif (list.length === 0) throw new RangeError(\"fromFSWatch: paths must not be empty\");\n\tconst {\n\t\trecursive = false,\n\t\tdebounceMs = 100,\n\t\tinitialScan = false,\n\t\tinclude,\n\t\texclude = [\"**/node_modules/**\", \"**/.git/**\", \"**/dist/**\"],\n\t\tsignal,\n\t} = opts;\n\tif (!Number.isFinite(debounceMs) || debounceMs < 0) {\n\t\tthrow new RangeError(\"fromFSWatch: debounceMs must be a non-negative finite number\");\n\t}\n\tconst includePatterns = (include ?? []).map(globToRegExp);\n\tconst excludePatterns = exclude.map(globToRegExp);\n\n\tconst accepts = (abs: string, rel: string): boolean => {\n\t\tconst normalized = normalizePath(abs);\n\t\tconst relNormalized = normalizePath(rel);\n\t\tconst included =\n\t\t\tincludePatterns.length === 0 ||\n\t\t\tmatchesAny(normalized, includePatterns) ||\n\t\t\tmatchesAny(relNormalized, includePatterns);\n\t\tif (!included) return false;\n\t\treturn !isExcluded(normalized, relNormalized);\n\t};\n\tconst isExcluded = (abs: string, rel: string): boolean => {\n\t\tconst normalized = normalizePath(abs);\n\t\tconst relNormalized = normalizePath(rel);\n\t\treturn (\n\t\t\tmatchesAny(normalized, excludePatterns) ||\n\t\t\tmatchesAny(relNormalized, excludePatterns) ||\n\t\t\tmatchesAny(`${normalized}/`, excludePatterns) ||\n\t\t\t(relNormalized !== \"\" && matchesAny(`${relNormalized}/`, excludePatterns))\n\t\t);\n\t};\n\n\treturn source<FSEvent>(\"fromFSWatch\", (ctx) => {\n\t\tlet stopped = false;\n\t\tlet terminal = false;\n\t\tlet ready = initialScan === false;\n\t\tlet generation = 0;\n\t\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\t\tconst watchers: FSWatcher[] = [];\n\t\tconst pending = new Map<string, FSEvent>();\n\t\tconst buffered = new Map<string, FSEvent>();\n\n\t\tconst close = () => {\n\t\t\tfor (const watcher of watchers.splice(0)) watcher.close();\n\t\t};\n\t\tconst cleanup = () => {\n\t\t\tstopped = true;\n\t\t\tgeneration += 1;\n\t\t\tif (timer !== undefined) clearTimeout(timer);\n\t\t\ttimer = undefined;\n\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\tclose();\n\t\t\tpending.clear();\n\t\t\tbuffered.clear();\n\t\t};\n\t\tconst emitError = (err: unknown) => {\n\t\t\tif (terminal) return;\n\t\t\tterminal = true;\n\t\t\tcleanup();\n\t\t\tctx.down([[\"ERROR\", errorPayload(err)]]);\n\t\t};\n\t\tfunction onAbort() {\n\t\t\temitError(signal?.reason);\n\t\t}\n\t\tconst flush = (token: number) => {\n\t\t\ttimer = undefined;\n\t\t\tif (stopped || terminal || token !== generation || pending.size === 0) return;\n\t\t\tconst msgs = [...pending.values()].map((event): [\"DATA\", FSEvent] => [\"DATA\", event]);\n\t\t\tpending.clear();\n\t\t\tctx.down(msgs);\n\t\t};\n\t\tconst schedule = () => {\n\t\t\tif (timer !== undefined) clearTimeout(timer);\n\t\t\tconst token = generation;\n\t\t\tif (debounceMs === 0) flush(token);\n\t\t\telse timer = setTimeout(() => flush(token), debounceMs);\n\t\t};\n\t\tconst enqueue = (event: FSEvent) => {\n\t\t\tif (!ready) {\n\t\t\t\tbuffered.set(event.path, event);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tpending.set(event.path, event);\n\t\t\tschedule();\n\t\t};\n\t\tconst eventFor = (\n\t\t\tbasePath: string,\n\t\t\teventType: \"rename\" | \"change\",\n\t\t\tfileName: string | Buffer | null,\n\t\t): FSEvent | undefined => {\n\t\t\tconst root = normalizePath(resolvePath(basePath));\n\t\t\tconst abs = normalizePath(fileName == null ? root : resolvePath(basePath, String(fileName)));\n\t\t\tconst rel = normalizePath(fileName == null ? \"\" : relative(root, abs));\n\t\t\tif (!accepts(abs, rel)) return undefined;\n\t\t\treturn {\n\t\t\t\ttype: eventTypeFor(eventType, abs),\n\t\t\t\tpath: abs,\n\t\t\t\troot,\n\t\t\t\trelativePath: rel,\n\t\t\t};\n\t\t};\n\n\t\tif (signal?.aborted) {\n\t\t\tonAbort();\n\t\t\treturn cleanup;\n\t\t}\n\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\n\t\ttry {\n\t\t\tfor (const basePath of list) {\n\t\t\t\tconst watcher = watch(basePath, { recursive }, (eventType, fileName) => {\n\t\t\t\t\tif (stopped || terminal) return;\n\t\t\t\t\tconst event = eventFor(basePath, eventType, fileName);\n\t\t\t\t\tif (event !== undefined) enqueue(event);\n\t\t\t\t});\n\t\t\t\twatcher.on(\"error\", emitError);\n\t\t\t\twatchers.push(watcher);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\temitError(err);\n\t\t\treturn cleanup;\n\t\t}\n\n\t\tif (initialScan !== false) {\n\t\t\ttry {\n\t\t\t\tfor (const basePath of list) {\n\t\t\t\t\tconst root = normalizePath(resolvePath(basePath));\n\t\t\t\t\tlet relRoot = root;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (statSync(basePath).isFile()) relRoot = dirname(root);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\trelRoot = root;\n\t\t\t\t\t}\n\t\t\t\t\tfor (const absPath of scanFiles(basePath, recursive, isExcluded)) {\n\t\t\t\t\t\tif (stopped || terminal) return cleanup;\n\t\t\t\t\t\tconst abs = normalizePath(absPath);\n\t\t\t\t\t\tconst rel = normalizePath(relative(relRoot, abs));\n\t\t\t\t\t\tif (!accepts(abs, rel)) continue;\n\t\t\t\t\t\tpending.set(abs, {\n\t\t\t\t\t\t\ttype: \"create\",\n\t\t\t\t\t\t\tpath: abs,\n\t\t\t\t\t\t\troot,\n\t\t\t\t\t\t\trelativePath: rel,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tready = true;\n\t\t\t\tfor (const [key, event] of buffered) pending.set(key, event);\n\t\t\t\tbuffered.clear();\n\t\t\t\tif (pending.size > 0) schedule();\n\t\t\t} catch (err) {\n\t\t\t\temitError(err);\n\t\t\t}\n\t\t}\n\n\t\treturn cleanup;\n\t});\n}\n\nexport function fromSpawn(\n\tcmd: string,\n\targs: readonly string[] = [],\n\topts: FromSpawnOptions = {},\n): Operator<never, SpawnEvent> {\n\tif (typeof cmd !== \"string\" || cmd.length === 0) {\n\t\tthrow new TypeError(\"fromSpawn: cmd must be a non-empty string\");\n\t}\n\tconst killGraceMs = opts.killGraceMs ?? 1000;\n\tvalidateNonNegativeFinite(\"fromSpawn: killGraceMs\", killGraceMs);\n\treturn source<SpawnEvent>(\"fromSpawn\", (ctx) => {\n\t\tlet alive = true;\n\t\tlet terminal = false;\n\t\tlet exitInfo: { code: number | null; signal: NodeJS.Signals | null } | undefined;\n\t\tlet child: ReturnType<typeof spawn>;\n\t\tlet killTimer: ReturnType<typeof setTimeout> | undefined;\n\t\tconst clearKillTimer = () => {\n\t\t\tif (killTimer !== undefined) clearTimeout(killTimer);\n\t\t\tkillTimer = undefined;\n\t\t};\n\t\tconst stop = () => {\n\t\t\talive = false;\n\t\t\tchild?.stdout?.removeAllListeners(\"data\");\n\t\t\tchild?.stderr?.removeAllListeners(\"data\");\n\t\t\tif (!terminal) {\n\t\t\t\ttry {\n\t\t\t\t\tchild?.kill(\"SIGTERM\");\n\t\t\t\t} catch {\n\t\t\t\t\t// Process may already have exited.\n\t\t\t\t}\n\t\t\t\tkillTimer = setTimeout(() => {\n\t\t\t\t\tif (!terminal) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tchild?.kill(\"SIGKILL\");\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t// Process may already have exited.\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}, killGraceMs);\n\t\t\t\tkillTimer.unref?.();\n\t\t\t}\n\t\t};\n\t\ttry {\n\t\t\tchild = spawn(cmd, [...args], {\n\t\t\t\tcwd: opts.cwd,\n\t\t\t\tenv: opts.env,\n\t\t\t\tshell: opts.shell,\n\t\t\t\tsignal: opts.signal,\n\t\t\t\tstdio: (opts.stdio as SpawnOptions[\"stdio\"]) ?? \"pipe\",\n\t\t\t});\n\t\t} catch (err) {\n\t\t\tterminal = true;\n\t\t\tctx.down([[\"ERROR\", errorPayload(err)]]);\n\t\t\treturn () => undefined;\n\t\t}\n\t\tchild.stdout?.on(\"data\", (chunk: Buffer) => {\n\t\t\tif (alive) ctx.down([[\"DATA\", { kind: \"stdout\", chunk }]]);\n\t\t});\n\t\tchild.stderr?.on(\"data\", (chunk: Buffer) => {\n\t\t\tif (alive) ctx.down([[\"DATA\", { kind: \"stderr\", chunk }]]);\n\t\t});\n\t\tchild.on(\"error\", (err) => {\n\t\t\tif (!alive || terminal) return;\n\t\t\tterminal = true;\n\t\t\talive = false;\n\t\t\tctx.down([[\"ERROR\", errorPayload(err)]]);\n\t\t});\n\t\tchild.on(\"exit\", (code, signal) => {\n\t\t\texitInfo = { code, signal: signal as NodeJS.Signals | null };\n\t\t});\n\t\tchild.on(\"close\", () => {\n\t\t\tclearKillTimer();\n\t\t\tif (!alive || terminal) return;\n\t\t\tterminal = true;\n\t\t\talive = false;\n\t\t\tconst info = exitInfo ?? { code: null, signal: null };\n\t\t\tctx.down([[\"DATA\", { kind: \"exit\", code: info.code, signal: info.signal }], [\"COMPLETE\"]]);\n\t\t});\n\t\treturn stop;\n\t});\n}\n\n/**\n * Node.js process EnvironmentDriver for D130/D131 adapters.\n *\n * Import this from `@graphrefly/ts/sources/node` and install it with\n * `EnvironmentDrivers.empty().withProcess(nodeProcessDriver())`. The child process is an\n * adapter-boundary side effect; graph nodes only observe ordinary ProcessResult DATA or ERROR.\n */\nexport function nodeProcessDriver(opts: NodeProcessDriverOptions = {}): LocalProcessDriver {\n\tconst killGraceMs = opts.killGraceMs ?? 1000;\n\tconst maxBufferBytes = opts.maxBufferBytes ?? 16 * 1024 * 1024;\n\tvalidateNonNegativeFinite(\"nodeProcessDriver: killGraceMs\", killGraceMs);\n\tvalidateNonNegativeFinite(\"nodeProcessDriver: maxBufferBytes\", maxBufferBytes);\n\treturn {\n\t\trun(command, callback) {\n\t\t\treturn runNodeProcessCommand(command, callback, {\n\t\t\t\tkillGraceMs,\n\t\t\t\tmaxBufferBytes,\n\t\t\t\tshell: opts.shell,\n\t\t\t});\n\t\t},\n\t};\n}\n\nexport function runProcess(\n\tcmd: string,\n\targs: readonly string[] = [],\n\topts: FromSpawnOptions = {},\n): Operator<never, ProcessResult> {\n\tif (typeof cmd !== \"string\" || cmd.length === 0) {\n\t\tthrow new TypeError(\"runProcess: cmd must be a non-empty string\");\n\t}\n\tconst killGraceMs = opts.killGraceMs ?? 1000;\n\tvalidateNonNegativeFinite(\"runProcess: killGraceMs\", killGraceMs);\n\treturn source<ProcessResult>(\"runProcess\", (ctx) => {\n\t\tlet alive = true;\n\t\tlet terminal = false;\n\t\tconst stdoutChunks: Buffer[] = [];\n\t\tconst stderrChunks: Buffer[] = [];\n\t\tlet exitInfo: { code: number | null; signal: NodeJS.Signals | null } | undefined;\n\t\tlet child: ReturnType<typeof spawn>;\n\t\tlet killTimer: ReturnType<typeof setTimeout> | undefined;\n\t\tconst clearKillTimer = () => {\n\t\t\tif (killTimer !== undefined) clearTimeout(killTimer);\n\t\t\tkillTimer = undefined;\n\t\t};\n\t\tconst stop = () => {\n\t\t\talive = false;\n\t\t\tchild?.stdout?.removeAllListeners(\"data\");\n\t\t\tchild?.stderr?.removeAllListeners(\"data\");\n\t\t\tif (!terminal) {\n\t\t\t\ttry {\n\t\t\t\t\tchild?.kill(\"SIGTERM\");\n\t\t\t\t} catch {\n\t\t\t\t\t// Process may already have exited.\n\t\t\t\t}\n\t\t\t\tkillTimer = setTimeout(() => {\n\t\t\t\t\tif (!terminal) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tchild?.kill(\"SIGKILL\");\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t// Process may already have exited.\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}, killGraceMs);\n\t\t\t\tkillTimer.unref?.();\n\t\t\t}\n\t\t};\n\t\ttry {\n\t\t\tchild = spawn(cmd, [...args], {\n\t\t\t\tcwd: opts.cwd,\n\t\t\t\tenv: opts.env,\n\t\t\t\tshell: opts.shell,\n\t\t\t\tsignal: opts.signal,\n\t\t\t\tstdio: (opts.stdio as SpawnOptions[\"stdio\"]) ?? \"pipe\",\n\t\t\t});\n\t\t} catch (err) {\n\t\t\tterminal = true;\n\t\t\tctx.down([[\"ERROR\", errorPayload(err)]]);\n\t\t\treturn () => undefined;\n\t\t}\n\t\tchild.stdout?.on(\"data\", (chunk: Buffer) => {\n\t\t\tif (alive) stdoutChunks.push(chunk);\n\t\t});\n\t\tchild.stderr?.on(\"data\", (chunk: Buffer) => {\n\t\t\tif (alive) stderrChunks.push(chunk);\n\t\t});\n\t\tchild.on(\"error\", (err) => {\n\t\t\tif (!alive || terminal) return;\n\t\t\tterminal = true;\n\t\t\talive = false;\n\t\t\tctx.down([[\"ERROR\", errorPayload(err)]]);\n\t\t});\n\t\tchild.on(\"exit\", (code, signal) => {\n\t\t\texitInfo = { code, signal: signal as NodeJS.Signals | null };\n\t\t});\n\t\tchild.on(\"close\", () => {\n\t\t\tclearKillTimer();\n\t\t\tif (!alive || terminal) return;\n\t\t\tterminal = true;\n\t\t\talive = false;\n\t\t\tconst info = exitInfo ?? { code: null, signal: null };\n\t\t\tctx.down([\n\t\t\t\t[\n\t\t\t\t\t\"DATA\",\n\t\t\t\t\t{\n\t\t\t\t\t\tstdout: Buffer.concat(stdoutChunks).toString(\"utf8\"),\n\t\t\t\t\t\tstderr: Buffer.concat(stderrChunks).toString(\"utf8\"),\n\t\t\t\t\t\texitCode: info.code,\n\t\t\t\t\t\tsignal: info.signal,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\t[\"COMPLETE\"],\n\t\t\t]);\n\t\t});\n\t\treturn stop;\n\t});\n}\n\nfunction runNodeProcessCommand(\n\tcommand: ProcessCommand,\n\tcallback: (result: DriverResult<EnvironmentProcessResult>) => void,\n\topts: {\n\t\treadonly killGraceMs: number;\n\t\treadonly maxBufferBytes: number;\n\t\treadonly shell?: boolean | string;\n\t},\n): () => void {\n\tif (typeof command.program !== \"string\" || command.program.length === 0) {\n\t\tcallback({\n\t\t\tok: false,\n\t\t\terror: new TypeError(\"nodeProcessDriver: program must be a non-empty string\"),\n\t\t});\n\t\treturn () => undefined;\n\t}\n\tlet alive = true;\n\tlet terminal = false;\n\tconst stdoutChunks: Buffer[] = [];\n\tconst stderrChunks: Buffer[] = [];\n\tlet bufferedBytes = 0;\n\tlet exitInfo: { code: number | null; signal: string | null } | undefined;\n\tlet child: ReturnType<typeof spawn>;\n\tlet killTimer: ReturnType<typeof setTimeout> | undefined;\n\tconst clearKillTimer = () => {\n\t\tif (killTimer !== undefined) clearTimeout(killTimer);\n\t\tkillTimer = undefined;\n\t};\n\tconst stop = () => {\n\t\tif (!alive) return;\n\t\talive = false;\n\t\tchild?.stdout?.removeAllListeners(\"data\");\n\t\tchild?.stderr?.removeAllListeners(\"data\");\n\t\tif (!terminal) {\n\t\t\ttry {\n\t\t\t\tchild?.kill(\"SIGTERM\");\n\t\t\t} catch {\n\t\t\t\t// Process may already have exited.\n\t\t\t}\n\t\t\tkillTimer = setTimeout(() => {\n\t\t\t\tif (!terminal) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tchild?.kill(\"SIGKILL\");\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// Process may already have exited.\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}, opts.killGraceMs);\n\t\t\tkillTimer.unref?.();\n\t\t}\n\t};\n\ttry {\n\t\tchild = spawn(command.program, [...command.args], {\n\t\t\tcwd: command.cwd,\n\t\t\tenv: command.env === undefined ? undefined : Object.fromEntries(command.env),\n\t\t\tshell: opts.shell,\n\t\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\t});\n\t} catch (err) {\n\t\tterminal = true;\n\t\tcallback({ ok: false, error: err });\n\t\treturn () => undefined;\n\t}\n\tconst fail = (error: unknown) => {\n\t\tclearKillTimer();\n\t\tif (!alive || terminal) return;\n\t\tterminal = true;\n\t\talive = false;\n\t\tchild.stdout?.removeAllListeners(\"data\");\n\t\tchild.stderr?.removeAllListeners(\"data\");\n\t\ttry {\n\t\t\tchild.kill(\"SIGTERM\");\n\t\t} catch {\n\t\t\t// Process may already have exited.\n\t\t}\n\t\tkillTimer = setTimeout(() => {\n\t\t\ttry {\n\t\t\t\tchild.kill(\"SIGKILL\");\n\t\t\t} catch {\n\t\t\t\t// Process may already have exited.\n\t\t\t}\n\t\t}, opts.killGraceMs);\n\t\tkillTimer.unref?.();\n\t\tcallback({ ok: false, error });\n\t};\n\tconst pushOutput = (chunks: Buffer[], chunk: Buffer) => {\n\t\tif (!alive) return;\n\t\tbufferedBytes += chunk.byteLength;\n\t\tif (bufferedBytes > opts.maxBufferBytes) {\n\t\t\tfail(\n\t\t\t\tnew RangeError(\n\t\t\t\t\t`nodeProcessDriver: stdout/stderr exceeded maxBufferBytes (${opts.maxBufferBytes})`,\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tchunks.push(chunk);\n\t};\n\tchild.stdout?.on(\"data\", (chunk: Buffer) => {\n\t\tpushOutput(stdoutChunks, chunk);\n\t});\n\tchild.stderr?.on(\"data\", (chunk: Buffer) => {\n\t\tpushOutput(stderrChunks, chunk);\n\t});\n\tchild.on(\"error\", (err) => {\n\t\tclearKillTimer();\n\t\tif (!alive || terminal) return;\n\t\tterminal = true;\n\t\talive = false;\n\t\tcallback({ ok: false, error: err });\n\t});\n\tchild.on(\"exit\", (code, signal) => {\n\t\texitInfo = { code, signal };\n\t});\n\tchild.on(\"close\", () => {\n\t\tclearKillTimer();\n\t\tif (!alive || terminal) return;\n\t\tterminal = true;\n\t\talive = false;\n\t\tconst info = exitInfo ?? { code: null, signal: null };\n\t\tcallback({\n\t\t\tok: true,\n\t\t\tvalue: {\n\t\t\t\tstdout: Buffer.concat(stdoutChunks).toString(\"utf8\"),\n\t\t\t\tstderr: Buffer.concat(stderrChunks).toString(\"utf8\"),\n\t\t\t\texitCode: info.code,\n\t\t\t\tsignal: info.signal,\n\t\t\t},\n\t\t});\n\t});\n\treturn stop;\n}\n\ninterface GitPollResult {\n\treadonly head: string;\n\treadonly files: readonly string[];\n\treadonly message: string;\n\treadonly author: string;\n}\n\nfunction stripFinalLineBreak(value: string): string {\n\treturn value.replace(/\\r?\\n$/, \"\");\n}\n\nfunction gitText(repoPath: string, args: readonly string[]): string {\n\treturn stripFinalLineBreak(execFileSync(\"git\", [\"-C\", repoPath, ...args], { encoding: \"utf8\" }));\n}\n\nfunction gitPathList(repoPath: string, args: readonly string[]): readonly string[] {\n\tconst out = execFileSync(\"git\", [\"-C\", repoPath, ...args, \"-z\"]) as Buffer;\n\tconst text = out.toString(\"utf8\");\n\tif (text.length === 0) return [];\n\treturn text.split(\"\\0\").filter((part) => part.length > 0);\n}\n\nfunction readGitHead(\n\trepoPath: string,\n\tpreviousHead: string | undefined,\n): GitPollResult | undefined {\n\tconst head = gitText(repoPath, [\"rev-parse\", \"HEAD\"]);\n\tif (head.length === 0 || head === previousHead) return undefined;\n\tconst files =\n\t\tpreviousHead === undefined\n\t\t\t? []\n\t\t\t: gitPathList(repoPath, [\"diff\", \"--name-only\", `${previousHead}..${head}`]);\n\treturn {\n\t\thead,\n\t\tfiles,\n\t\tmessage: gitText(repoPath, [\"log\", \"-1\", \"--format=%s\", head]),\n\t\tauthor: gitText(repoPath, [\"log\", \"-1\", \"--format=%an\", head]),\n\t};\n}\n\nexport function fromGitHook(\n\trepoPath: string,\n\topts: FromGitHookOptions = {},\n): Operator<never, GitEvent> {\n\tconst { pollMs = 5000, include, exclude, maxConsecutiveErrors = 1, signal } = opts;\n\tvalidatePositiveFinite(\"fromGitHook: pollMs\", pollMs);\n\tif (!Number.isFinite(maxConsecutiveErrors) && maxConsecutiveErrors !== Infinity) {\n\t\tthrow new RangeError(\"fromGitHook: maxConsecutiveErrors must be finite or Infinity\");\n\t}\n\tif (maxConsecutiveErrors <= 0) {\n\t\tthrow new RangeError(\"fromGitHook: maxConsecutiveErrors must be positive\");\n\t}\n\tconst resolvedRepoPath = resolvePath(repoPath);\n\tconst includePatterns = (include ?? []).map(globToRegExp);\n\tconst excludePatterns = (exclude ?? []).map(globToRegExp);\n\tconst accepts = (file: string): boolean => {\n\t\tconst normalized = normalizePath(file);\n\t\tconst included = includePatterns.length === 0 || matchesAny(normalized, includePatterns);\n\t\treturn included && !matchesAny(normalized, excludePatterns);\n\t};\n\n\treturn source<GitEvent>(\"fromGitHook\", (ctx) => {\n\t\tlet done = false;\n\t\tlet lastSeen: string | undefined;\n\t\tlet consecutiveErrors = 0;\n\t\tlet intervalId: ReturnType<typeof setInterval> | undefined;\n\t\tconst cleanup = () => {\n\t\t\tdone = true;\n\t\t\tif (intervalId !== undefined) clearInterval(intervalId);\n\t\t\tintervalId = undefined;\n\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t};\n\t\tconst fail = (err: unknown) => {\n\t\t\tif (done) return;\n\t\t\tcleanup();\n\t\t\tctx.down([[\"ERROR\", errorPayload(err)]]);\n\t\t};\n\t\tconst onAbort = () => fail(signal?.reason);\n\t\tconst poll = () => {\n\t\t\tif (done) return;\n\t\t\ttry {\n\t\t\t\tconst result = readGitHead(resolvedRepoPath, lastSeen);\n\t\t\t\tconsecutiveErrors = 0;\n\t\t\t\tif (result === undefined) return;\n\t\t\t\tconst isBaseline = lastSeen === undefined;\n\t\t\t\tlastSeen = result.head;\n\t\t\t\tif (isBaseline) return;\n\t\t\t\tctx.down([\n\t\t\t\t\t[\n\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\thook: \"post-commit\",\n\t\t\t\t\t\t\tcommit: result.head,\n\t\t\t\t\t\t\tfiles: result.files.filter(accepts),\n\t\t\t\t\t\t\tmessage: result.message,\n\t\t\t\t\t\t\tauthor: result.author,\n\t\t\t\t\t\t\ttimestamp_ns: timestampNsNow(),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t]);\n\t\t\t} catch (err) {\n\t\t\t\tconsecutiveErrors += 1;\n\t\t\t\tif (consecutiveErrors >= maxConsecutiveErrors) fail(err);\n\t\t\t}\n\t\t};\n\t\tif (signal?.aborted) {\n\t\t\tonAbort();\n\t\t\treturn cleanup;\n\t\t}\n\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t\tpoll();\n\t\tif (!done) intervalId = setInterval(poll, pollMs);\n\t\treturn cleanup;\n\t});\n}\n","/**\n * Wave-protocol message types and the tier const table.\n *\n * Canonical authority: ~/src/graphrefly/spec/rules.jsonl\n * R-msg-format, R-msg-closed-set, R-tier (D34), R-data-payload, R-sentinel.\n */\n\n/** Opaque pause-lock identifier (R-pause-lockset). */\nexport type LockId = string | symbol;\n\n/**\n * The CLOSED set of 10 message types (R-msg-closed-set / D9 + START handshake).\n * No open set, no user-defined custom types. Adding a type is a spec change.\n */\nexport type Message =\n\t| readonly [\"START\"]\n\t| readonly [\"DIRTY\"]\n\t| readonly [\"DATA\", unknown]\n\t| readonly [\"RESOLVED\"]\n\t| readonly [\"INVALIDATE\"]\n\t| readonly [\"COMPLETE\"]\n\t| readonly [\"ERROR\", unknown]\n\t| readonly [\"TEARDOWN\"]\n\t| readonly [\"PAUSE\", LockId]\n\t| readonly [\"RESUME\", LockId];\n\n/** One array of messages delivered in one call = one Wave (R-wave-boundary). */\nexport type Wave = readonly Message[];\n\n/** The message-type tag (the first tuple element). */\nexport type MessageType = Message[0];\n\n/**\n * SENTINEL = absence-of-DATA (R-sentinel / D16). TS representation is `undefined`.\n * Never a valid DATA payload; `null` IS a valid DATA value (domain-level absence).\n */\nexport const SENTINEL = undefined;\n\n/** R-data-payload: ERROR payloads must not collide with terminal metadata shorthand. */\nexport function isInvalidErrorPayload(v: unknown): boolean {\n\treturn v === SENTINEL || typeof v === \"boolean\";\n}\n\n/** R-data-payload / D78: host-language failures that collide with ctx.terminal shorthand become diagnostics. */\nexport function errorPayload(reason: unknown, fallback = \"error without a valid payload\"): unknown {\n\treturn isInvalidErrorPayload(reason) ? new Error(fallback) : reason;\n}\n\nexport const TIER_START = 0;\nexport const TIER_CONTROL = 1;\nexport const TIER_NOTIFICATION = 2;\nexport const TIER_VALUE = 3;\nexport const TIER_SETTLE = 4;\nexport const TIER_TERMINAL = 5;\nexport const TIER_TEARDOWN = 6;\n\n/**\n * Tier const table (R-tier / D34). Tiers below value dispatch immediately; value\n * and above are batch-deferred. This is a compile-time const table (D18), not runtime config.\n */\nconst TIER: Record<MessageType, number> = {\n\tSTART: TIER_START,\n\tPAUSE: TIER_CONTROL,\n\tRESUME: TIER_CONTROL,\n\tDIRTY: TIER_NOTIFICATION,\n\tDATA: TIER_VALUE,\n\tRESOLVED: TIER_VALUE,\n\tINVALIDATE: TIER_SETTLE,\n\tCOMPLETE: TIER_TERMINAL,\n\tERROR: TIER_TERMINAL,\n\tTEARDOWN: TIER_TEARDOWN,\n};\n\nexport function messageTier(t: MessageType): number {\n\treturn TIER[t];\n}\n\n/** Value and above are deferred inside a batch (DATA/RESOLVED/INVALIDATE/terminal/teardown). */\nexport function isDeferredTier(t: MessageType): boolean {\n\treturn TIER[t] >= TIER_VALUE;\n}\n\n/** Value-tier messages (DATA/RESOLVED) occupy the tier-3 slot. */\nexport function isValueTier(t: MessageType): boolean {\n\treturn TIER[t] === TIER_VALUE;\n}\n\n/** The pause buffer holds the settle slice only: value-tier DATA/RESOLVED plus INVALIDATE. */\nexport function isPauseBufferedTier(t: MessageType): boolean {\n\tconst tier = TIER[t];\n\treturn tier === TIER_VALUE || tier === TIER_SETTLE;\n}\n\n/**\n * A TERMINAL message = tier 5 (COMPLETE | ERROR), R-tier / D34. Detected via the CENTRAL tier\n * table, NOT a per-variant `=== \"COMPLETE\" || === \"ERROR\"` check — so terminal routing stays\n * driven by the one const table (feedback_use_tier_for_signal_routing); discriminate COMPLETE vs\n * ERROR within the tier by the message type only where the handling actually differs.\n */\nexport function isTerminal(t: MessageType): boolean {\n\treturn TIER[t] === TIER_TERMINAL;\n}\n\n/**\n * ctx.up carries control tiers only (R-ctx-up / DR-5): DIRTY, PAUSE, RESUME,\n * INVALIDATE, TEARDOWN. DATA/RESOLVED (tier 3) and COMPLETE/ERROR (tier 5) are\n * down-only.\n */\nexport function isUpAllowed(t: MessageType): boolean {\n\tconst tier = TIER[t];\n\treturn tier !== TIER_VALUE && tier !== TIER_TERMINAL;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,gCAA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AAA,QACD,CAAC;AAAA,MACF,SAAS,KAAK;AACb,6BAAqB;AACrB,YAAI,qBAAqB,qBAAsB,MAAK,GAAG;AAAA,MACxD;AAAA,IACD;AACA,QAAI,QAAQ,SAAS;AACpB,cAAQ;AACR,aAAO;AAAA,IACR;AACA,YAAQ,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK,CAAC;AACzD,SAAK;AACL,QAAI,CAAC,KAAM,cAAa,YAAY,MAAM,MAAM;AAChD,WAAO;AAAA,EACR,CAAC;AACF;","names":["resolvePath"]}
@@ -0,0 +1,109 @@
1
+ import { i as LocalProcessDriver } from '../types-bNMSWKqF.cjs';
2
+ import { L as Operator } from '../graph-s23RbbFO.cjs';
3
+ import '../messages-BZqrGGm1.cjs';
4
+ import '../core/index.cjs';
5
+ import '../codec-BB7p8fJc.cjs';
6
+ import '../describe-Ciu8SUnN.cjs';
7
+
8
+ /**
9
+ * Node-only source factories. Import from `@graphrefly/ts/sources/node`; the universal
10
+ * `@graphrefly/ts/sources` barrel stays browser-safe.
11
+ */
12
+
13
+ type FSEventType = "change" | "rename" | "create" | "delete";
14
+ interface FSEvent {
15
+ readonly type: FSEventType;
16
+ readonly path: string;
17
+ readonly root: string;
18
+ readonly relativePath: string;
19
+ }
20
+ interface FromFSWatchOptions {
21
+ /** Use Node's recursive fs.watch mode where the host platform supports it. Default: false. */
22
+ readonly recursive?: boolean;
23
+ /** Coalesce events per path for this many milliseconds. Default: 100. */
24
+ readonly debounceMs?: number;
25
+ /** Emit create events for existing files after watcher registration. Default: false. */
26
+ readonly initialScan?: boolean | "files";
27
+ /** Include glob patterns matched against absolute and relative slash-normalized paths. */
28
+ readonly include?: readonly string[];
29
+ /** Exclude glob patterns matched against absolute and relative slash-normalized paths. */
30
+ readonly exclude?: readonly string[];
31
+ /** AbortSignal aborts the source to ERROR and closes all watchers. */
32
+ readonly signal?: AbortSignal;
33
+ }
34
+ type SpawnEvent = {
35
+ readonly kind: "stdout";
36
+ readonly chunk: Buffer;
37
+ } | {
38
+ readonly kind: "stderr";
39
+ readonly chunk: Buffer;
40
+ } | {
41
+ readonly kind: "exit";
42
+ readonly code: number | null;
43
+ readonly signal: NodeJS.Signals | null;
44
+ };
45
+ interface FromSpawnOptions {
46
+ readonly cwd?: string;
47
+ readonly env?: NodeJS.ProcessEnv;
48
+ readonly shell?: boolean | string;
49
+ readonly signal?: AbortSignal;
50
+ readonly stdio?: "pipe" | readonly ("pipe" | "ignore" | "inherit")[];
51
+ /** Milliseconds after teardown SIGTERM before sending SIGKILL. Default: 1000. */
52
+ readonly killGraceMs?: number;
53
+ }
54
+ /**
55
+ * Node-only process driver options for D130/D131 EnvironmentDrivers.
56
+ *
57
+ * These knobs configure host child-process behavior at the driver boundary only; they do not
58
+ * change graph wave, tier, or message semantics.
59
+ */
60
+ interface NodeProcessDriverOptions {
61
+ /** Milliseconds after cancellation SIGTERM before sending SIGKILL. Default: 1000. */
62
+ readonly killGraceMs?: number;
63
+ /** Maximum captured stdout + stderr bytes before terminating with ERROR. Default: 16 MiB. */
64
+ readonly maxBufferBytes?: number;
65
+ /** Optional shell mode passed to Node's child_process.spawn. Default: false. */
66
+ readonly shell?: boolean | string;
67
+ }
68
+ interface ProcessResult {
69
+ readonly stdout: string;
70
+ readonly stderr: string;
71
+ readonly exitCode: number | null;
72
+ readonly signal: NodeJS.Signals | null;
73
+ }
74
+ type GitHookType = "post-commit" | "post-merge" | "post-checkout" | "post-rewrite";
75
+ interface GitEvent {
76
+ readonly hook: GitHookType;
77
+ readonly commit: string;
78
+ readonly files: readonly string[];
79
+ readonly message: string;
80
+ readonly author: string;
81
+ readonly timestamp_ns: string;
82
+ }
83
+ interface FromGitHookOptions {
84
+ readonly pollMs?: number;
85
+ readonly include?: readonly string[];
86
+ readonly exclude?: readonly string[];
87
+ readonly maxConsecutiveErrors?: number;
88
+ readonly signal?: AbortSignal;
89
+ }
90
+ /**
91
+ * fromFSWatch: Node.js filesystem watcher source.
92
+ *
93
+ * External fs callbacks are a source boundary (R-no-raw-async): events enter the graph only via
94
+ * `ctx.down`, and cleanup is tied to node deactivation through `ctx.onDeactivation`.
95
+ */
96
+ declare function fromFSWatch(paths: string | readonly string[], opts?: FromFSWatchOptions): Operator<never, FSEvent>;
97
+ declare function fromSpawn(cmd: string, args?: readonly string[], opts?: FromSpawnOptions): Operator<never, SpawnEvent>;
98
+ /**
99
+ * Node.js process EnvironmentDriver for D130/D131 adapters.
100
+ *
101
+ * Import this from `@graphrefly/ts/sources/node` and install it with
102
+ * `EnvironmentDrivers.empty().withProcess(nodeProcessDriver())`. The child process is an
103
+ * adapter-boundary side effect; graph nodes only observe ordinary ProcessResult DATA or ERROR.
104
+ */
105
+ declare function nodeProcessDriver(opts?: NodeProcessDriverOptions): LocalProcessDriver;
106
+ declare function runProcess(cmd: string, args?: readonly string[], opts?: FromSpawnOptions): Operator<never, ProcessResult>;
107
+ declare function fromGitHook(repoPath: string, opts?: FromGitHookOptions): Operator<never, GitEvent>;
108
+
109
+ export { type FSEvent, type FSEventType, type FromFSWatchOptions, type FromGitHookOptions, type FromSpawnOptions, type GitEvent, type GitHookType, type NodeProcessDriverOptions, type ProcessResult, type SpawnEvent, fromFSWatch, fromGitHook, fromSpawn, nodeProcessDriver, runProcess };
@@ -0,0 +1,109 @@
1
+ import { i as LocalProcessDriver } from '../types-h12mNYbq.js';
2
+ import { L as Operator } from '../graph-DfdF9zy4.js';
3
+ import '../messages-BZqrGGm1.js';
4
+ import '../core/index.js';
5
+ import '../codec-BB7p8fJc.js';
6
+ import '../describe-BZb7AS2y.js';
7
+
8
+ /**
9
+ * Node-only source factories. Import from `@graphrefly/ts/sources/node`; the universal
10
+ * `@graphrefly/ts/sources` barrel stays browser-safe.
11
+ */
12
+
13
+ type FSEventType = "change" | "rename" | "create" | "delete";
14
+ interface FSEvent {
15
+ readonly type: FSEventType;
16
+ readonly path: string;
17
+ readonly root: string;
18
+ readonly relativePath: string;
19
+ }
20
+ interface FromFSWatchOptions {
21
+ /** Use Node's recursive fs.watch mode where the host platform supports it. Default: false. */
22
+ readonly recursive?: boolean;
23
+ /** Coalesce events per path for this many milliseconds. Default: 100. */
24
+ readonly debounceMs?: number;
25
+ /** Emit create events for existing files after watcher registration. Default: false. */
26
+ readonly initialScan?: boolean | "files";
27
+ /** Include glob patterns matched against absolute and relative slash-normalized paths. */
28
+ readonly include?: readonly string[];
29
+ /** Exclude glob patterns matched against absolute and relative slash-normalized paths. */
30
+ readonly exclude?: readonly string[];
31
+ /** AbortSignal aborts the source to ERROR and closes all watchers. */
32
+ readonly signal?: AbortSignal;
33
+ }
34
+ type SpawnEvent = {
35
+ readonly kind: "stdout";
36
+ readonly chunk: Buffer;
37
+ } | {
38
+ readonly kind: "stderr";
39
+ readonly chunk: Buffer;
40
+ } | {
41
+ readonly kind: "exit";
42
+ readonly code: number | null;
43
+ readonly signal: NodeJS.Signals | null;
44
+ };
45
+ interface FromSpawnOptions {
46
+ readonly cwd?: string;
47
+ readonly env?: NodeJS.ProcessEnv;
48
+ readonly shell?: boolean | string;
49
+ readonly signal?: AbortSignal;
50
+ readonly stdio?: "pipe" | readonly ("pipe" | "ignore" | "inherit")[];
51
+ /** Milliseconds after teardown SIGTERM before sending SIGKILL. Default: 1000. */
52
+ readonly killGraceMs?: number;
53
+ }
54
+ /**
55
+ * Node-only process driver options for D130/D131 EnvironmentDrivers.
56
+ *
57
+ * These knobs configure host child-process behavior at the driver boundary only; they do not
58
+ * change graph wave, tier, or message semantics.
59
+ */
60
+ interface NodeProcessDriverOptions {
61
+ /** Milliseconds after cancellation SIGTERM before sending SIGKILL. Default: 1000. */
62
+ readonly killGraceMs?: number;
63
+ /** Maximum captured stdout + stderr bytes before terminating with ERROR. Default: 16 MiB. */
64
+ readonly maxBufferBytes?: number;
65
+ /** Optional shell mode passed to Node's child_process.spawn. Default: false. */
66
+ readonly shell?: boolean | string;
67
+ }
68
+ interface ProcessResult {
69
+ readonly stdout: string;
70
+ readonly stderr: string;
71
+ readonly exitCode: number | null;
72
+ readonly signal: NodeJS.Signals | null;
73
+ }
74
+ type GitHookType = "post-commit" | "post-merge" | "post-checkout" | "post-rewrite";
75
+ interface GitEvent {
76
+ readonly hook: GitHookType;
77
+ readonly commit: string;
78
+ readonly files: readonly string[];
79
+ readonly message: string;
80
+ readonly author: string;
81
+ readonly timestamp_ns: string;
82
+ }
83
+ interface FromGitHookOptions {
84
+ readonly pollMs?: number;
85
+ readonly include?: readonly string[];
86
+ readonly exclude?: readonly string[];
87
+ readonly maxConsecutiveErrors?: number;
88
+ readonly signal?: AbortSignal;
89
+ }
90
+ /**
91
+ * fromFSWatch: Node.js filesystem watcher source.
92
+ *
93
+ * External fs callbacks are a source boundary (R-no-raw-async): events enter the graph only via
94
+ * `ctx.down`, and cleanup is tied to node deactivation through `ctx.onDeactivation`.
95
+ */
96
+ declare function fromFSWatch(paths: string | readonly string[], opts?: FromFSWatchOptions): Operator<never, FSEvent>;
97
+ declare function fromSpawn(cmd: string, args?: readonly string[], opts?: FromSpawnOptions): Operator<never, SpawnEvent>;
98
+ /**
99
+ * Node.js process EnvironmentDriver for D130/D131 adapters.
100
+ *
101
+ * Import this from `@graphrefly/ts/sources/node` and install it with
102
+ * `EnvironmentDrivers.empty().withProcess(nodeProcessDriver())`. The child process is an
103
+ * adapter-boundary side effect; graph nodes only observe ordinary ProcessResult DATA or ERROR.
104
+ */
105
+ declare function nodeProcessDriver(opts?: NodeProcessDriverOptions): LocalProcessDriver;
106
+ declare function runProcess(cmd: string, args?: readonly string[], opts?: FromSpawnOptions): Operator<never, ProcessResult>;
107
+ declare function fromGitHook(repoPath: string, opts?: FromGitHookOptions): Operator<never, GitEvent>;
108
+
109
+ export { type FSEvent, type FSEventType, type FromFSWatchOptions, type FromGitHookOptions, type FromSpawnOptions, type GitEvent, type GitHookType, type NodeProcessDriverOptions, type ProcessResult, type SpawnEvent, fromFSWatch, fromGitHook, fromSpawn, nodeProcessDriver, runProcess };