@animalabs/agent-framework 0.21.1 → 0.22.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 (271) hide show
  1. package/README.md +43 -0
  2. package/dist/src/agent.d.ts +17 -4
  3. package/dist/src/agent.d.ts.map +1 -1
  4. package/dist/src/agent.js +102 -42
  5. package/dist/src/agent.js.map +1 -1
  6. package/dist/src/code-execution/py-runner.d.ts +22 -1
  7. package/dist/src/code-execution/py-runner.d.ts.map +1 -1
  8. package/dist/src/code-execution/py-runner.js +64 -9
  9. package/dist/src/code-execution/py-runner.js.map +1 -1
  10. package/dist/src/code-execution/runtime-py.d.ts +4 -0
  11. package/dist/src/code-execution/runtime-py.d.ts.map +1 -1
  12. package/dist/src/code-execution/runtime-py.js +215 -38
  13. package/dist/src/code-execution/runtime-py.js.map +1 -1
  14. package/dist/src/framework.d.ts +250 -39
  15. package/dist/src/framework.d.ts.map +1 -1
  16. package/dist/src/framework.js +1602 -371
  17. package/dist/src/framework.js.map +1 -1
  18. package/dist/src/gate/event-gate.d.ts +21 -0
  19. package/dist/src/gate/event-gate.d.ts.map +1 -1
  20. package/dist/src/gate/event-gate.js +40 -7
  21. package/dist/src/gate/event-gate.js.map +1 -1
  22. package/dist/src/index.d.ts +5 -0
  23. package/dist/src/index.d.ts.map +1 -1
  24. package/dist/src/index.js +4 -0
  25. package/dist/src/index.js.map +1 -1
  26. package/dist/src/mcpl/channel-registry.d.ts.map +1 -1
  27. package/dist/src/mcpl/channel-registry.js +26 -3
  28. package/dist/src/mcpl/channel-registry.js.map +1 -1
  29. package/dist/src/mcpl/conversation-router.d.ts +28 -1
  30. package/dist/src/mcpl/conversation-router.d.ts.map +1 -1
  31. package/dist/src/mcpl/conversation-router.js +17 -0
  32. package/dist/src/mcpl/conversation-router.js.map +1 -1
  33. package/dist/src/mcpl/feature-set-manager.d.ts +11 -0
  34. package/dist/src/mcpl/feature-set-manager.d.ts.map +1 -1
  35. package/dist/src/mcpl/feature-set-manager.js +31 -7
  36. package/dist/src/mcpl/feature-set-manager.js.map +1 -1
  37. package/dist/src/mcpl/index.d.ts +2 -0
  38. package/dist/src/mcpl/index.d.ts.map +1 -1
  39. package/dist/src/mcpl/index.js +1 -0
  40. package/dist/src/mcpl/index.js.map +1 -1
  41. package/dist/src/mcpl/prose-stream-router.d.ts +27 -6
  42. package/dist/src/mcpl/prose-stream-router.d.ts.map +1 -1
  43. package/dist/src/mcpl/prose-stream-router.js +85 -22
  44. package/dist/src/mcpl/prose-stream-router.js.map +1 -1
  45. package/dist/src/mcpl/push-coalescer.d.ts +32 -4
  46. package/dist/src/mcpl/push-coalescer.d.ts.map +1 -1
  47. package/dist/src/mcpl/push-coalescer.js +46 -13
  48. package/dist/src/mcpl/push-coalescer.js.map +1 -1
  49. package/dist/src/mcpl/push-handler.d.ts +5 -3
  50. package/dist/src/mcpl/push-handler.d.ts.map +1 -1
  51. package/dist/src/mcpl/push-handler.js +41 -11
  52. package/dist/src/mcpl/push-handler.js.map +1 -1
  53. package/dist/src/mcpl/server-connection.d.ts +4 -0
  54. package/dist/src/mcpl/server-connection.d.ts.map +1 -1
  55. package/dist/src/mcpl/server-connection.js +45 -8
  56. package/dist/src/mcpl/server-connection.js.map +1 -1
  57. package/dist/src/mcpl/server-registry.d.ts +5 -2
  58. package/dist/src/mcpl/server-registry.d.ts.map +1 -1
  59. package/dist/src/mcpl/server-registry.js +25 -7
  60. package/dist/src/mcpl/server-registry.js.map +1 -1
  61. package/dist/src/mcpl/tool-lifecycle.d.ts +52 -2
  62. package/dist/src/mcpl/tool-lifecycle.d.ts.map +1 -1
  63. package/dist/src/mcpl/tool-lifecycle.js +47 -1
  64. package/dist/src/mcpl/tool-lifecycle.js.map +1 -1
  65. package/dist/src/mcpl/tool-pattern-check.d.ts +51 -0
  66. package/dist/src/mcpl/tool-pattern-check.d.ts.map +1 -0
  67. package/dist/src/mcpl/tool-pattern-check.js +79 -0
  68. package/dist/src/mcpl/tool-pattern-check.js.map +1 -0
  69. package/dist/src/mcpl/types.d.ts +15 -5
  70. package/dist/src/mcpl/types.d.ts.map +1 -1
  71. package/dist/src/mcpl/types.js.map +1 -1
  72. package/dist/src/mcpl/visible-content.d.ts +39 -0
  73. package/dist/src/mcpl/visible-content.d.ts.map +1 -0
  74. package/dist/src/mcpl/visible-content.js +54 -0
  75. package/dist/src/mcpl/visible-content.js.map +1 -0
  76. package/dist/src/module-registry.d.ts +81 -3
  77. package/dist/src/module-registry.d.ts.map +1 -1
  78. package/dist/src/module-registry.js +257 -16
  79. package/dist/src/module-registry.js.map +1 -1
  80. package/dist/src/modules/workspace/branch-intent.d.ts +72 -0
  81. package/dist/src/modules/workspace/branch-intent.d.ts.map +1 -0
  82. package/dist/src/modules/workspace/branch-intent.js +83 -0
  83. package/dist/src/modules/workspace/branch-intent.js.map +1 -0
  84. package/dist/src/modules/workspace/disk-agreement.d.ts +167 -0
  85. package/dist/src/modules/workspace/disk-agreement.d.ts.map +1 -0
  86. package/dist/src/modules/workspace/disk-agreement.js +259 -0
  87. package/dist/src/modules/workspace/disk-agreement.js.map +1 -0
  88. package/dist/src/modules/workspace/effects.d.ts +84 -0
  89. package/dist/src/modules/workspace/effects.d.ts.map +1 -0
  90. package/dist/src/modules/workspace/effects.js +368 -0
  91. package/dist/src/modules/workspace/effects.js.map +1 -0
  92. package/dist/src/modules/workspace/index.d.ts +155 -17
  93. package/dist/src/modules/workspace/index.d.ts.map +1 -1
  94. package/dist/src/modules/workspace/index.js +1059 -424
  95. package/dist/src/modules/workspace/index.js.map +1 -1
  96. package/dist/src/modules/workspace/observe.d.ts +278 -0
  97. package/dist/src/modules/workspace/observe.d.ts.map +1 -0
  98. package/dist/src/modules/workspace/observe.js +805 -0
  99. package/dist/src/modules/workspace/observe.js.map +1 -0
  100. package/dist/src/modules/workspace/reconcile.d.ts +224 -0
  101. package/dist/src/modules/workspace/reconcile.d.ts.map +1 -0
  102. package/dist/src/modules/workspace/reconcile.js +901 -0
  103. package/dist/src/modules/workspace/reconcile.js.map +1 -0
  104. package/dist/src/modules/workspace/sync.d.ts +6 -59
  105. package/dist/src/modules/workspace/sync.d.ts.map +1 -1
  106. package/dist/src/modules/workspace/sync.js +6 -257
  107. package/dist/src/modules/workspace/sync.js.map +1 -1
  108. package/dist/src/modules/workspace/types.d.ts +77 -10
  109. package/dist/src/modules/workspace/types.d.ts.map +1 -1
  110. package/dist/src/modules/workspace/types.js.map +1 -1
  111. package/dist/src/record-journal.d.ts +127 -0
  112. package/dist/src/record-journal.d.ts.map +1 -0
  113. package/dist/src/record-journal.js +202 -0
  114. package/dist/src/record-journal.js.map +1 -0
  115. package/dist/src/shutdown.d.ts +13 -0
  116. package/dist/src/shutdown.d.ts.map +1 -0
  117. package/dist/src/shutdown.js +46 -0
  118. package/dist/src/shutdown.js.map +1 -0
  119. package/dist/src/silent-heartbeat.d.ts +74 -0
  120. package/dist/src/silent-heartbeat.d.ts.map +1 -0
  121. package/dist/src/silent-heartbeat.js +77 -0
  122. package/dist/src/silent-heartbeat.js.map +1 -0
  123. package/dist/src/tool-presentation.d.ts +50 -0
  124. package/dist/src/tool-presentation.d.ts.map +1 -0
  125. package/dist/src/tool-presentation.js +235 -0
  126. package/dist/src/tool-presentation.js.map +1 -0
  127. package/dist/src/tool-result-guard.d.ts +125 -6
  128. package/dist/src/tool-result-guard.d.ts.map +1 -1
  129. package/dist/src/tool-result-guard.js +310 -35
  130. package/dist/src/tool-result-guard.js.map +1 -1
  131. package/dist/src/tool-result-history.d.ts +13 -0
  132. package/dist/src/tool-result-history.d.ts.map +1 -1
  133. package/dist/src/tool-result-history.js +21 -1
  134. package/dist/src/tool-result-history.js.map +1 -1
  135. package/dist/src/types/agent.d.ts +18 -2
  136. package/dist/src/types/agent.d.ts.map +1 -1
  137. package/dist/src/types/events.d.ts +4 -0
  138. package/dist/src/types/events.d.ts.map +1 -1
  139. package/dist/src/types/framework.d.ts +12 -0
  140. package/dist/src/types/framework.d.ts.map +1 -1
  141. package/dist/src/types/module.d.ts +14 -0
  142. package/dist/src/types/module.d.ts.map +1 -1
  143. package/dist/src/types/trace.d.ts +73 -0
  144. package/dist/src/types/trace.d.ts.map +1 -1
  145. package/dist/test/batched-wake-locus.test.d.ts +2 -0
  146. package/dist/test/batched-wake-locus.test.d.ts.map +1 -0
  147. package/dist/test/batched-wake-locus.test.js +166 -0
  148. package/dist/test/batched-wake-locus.test.js.map +1 -0
  149. package/dist/test/code-execution.test.js +386 -2
  150. package/dist/test/code-execution.test.js.map +1 -1
  151. package/dist/test/component-defaults.test.d.ts +2 -0
  152. package/dist/test/component-defaults.test.d.ts.map +1 -0
  153. package/dist/test/component-defaults.test.js +54 -0
  154. package/dist/test/component-defaults.test.js.map +1 -0
  155. package/dist/test/conversation-routing.test.js +57 -1
  156. package/dist/test/conversation-routing.test.js.map +1 -1
  157. package/dist/test/ephemeral-settle.test.js +3 -0
  158. package/dist/test/ephemeral-settle.test.js.map +1 -1
  159. package/dist/test/event-gate.test.js +118 -0
  160. package/dist/test/event-gate.test.js.map +1 -1
  161. package/dist/test/explicit-prose-routing.test.js +977 -0
  162. package/dist/test/explicit-prose-routing.test.js.map +1 -1
  163. package/dist/test/helpers/pytc-stop-rows.d.ts +11 -0
  164. package/dist/test/helpers/pytc-stop-rows.d.ts.map +1 -0
  165. package/dist/test/helpers/pytc-stop-rows.js +143 -0
  166. package/dist/test/helpers/pytc-stop-rows.js.map +1 -0
  167. package/dist/test/mcpl-coalescing.test.js +19 -6
  168. package/dist/test/mcpl-coalescing.test.js.map +1 -1
  169. package/dist/test/mcpl-config-diagnostics.test.d.ts +2 -0
  170. package/dist/test/mcpl-config-diagnostics.test.d.ts.map +1 -0
  171. package/dist/test/mcpl-config-diagnostics.test.js +449 -0
  172. package/dist/test/mcpl-config-diagnostics.test.js.map +1 -0
  173. package/dist/test/mcpl-empty-content.test.d.ts +2 -0
  174. package/dist/test/mcpl-empty-content.test.d.ts.map +1 -0
  175. package/dist/test/mcpl-empty-content.test.js +368 -0
  176. package/dist/test/mcpl-empty-content.test.js.map +1 -0
  177. package/dist/test/mcpl-tool-lifecycle-emitter.test.js +106 -1
  178. package/dist/test/mcpl-tool-lifecycle-emitter.test.js.map +1 -1
  179. package/dist/test/mcpl-tool-lifecycle-script.test.d.ts +2 -0
  180. package/dist/test/mcpl-tool-lifecycle-script.test.d.ts.map +1 -0
  181. package/dist/test/mcpl-tool-lifecycle-script.test.js +288 -0
  182. package/dist/test/mcpl-tool-lifecycle-script.test.js.map +1 -0
  183. package/dist/test/prose-stream-router.test.js +41 -0
  184. package/dist/test/prose-stream-router.test.js.map +1 -1
  185. package/dist/test/record-journal.test.d.ts +6 -0
  186. package/dist/test/record-journal.test.d.ts.map +1 -0
  187. package/dist/test/record-journal.test.js +269 -0
  188. package/dist/test/record-journal.test.js.map +1 -0
  189. package/dist/test/save-recent-image.test.js +102 -0
  190. package/dist/test/save-recent-image.test.js.map +1 -1
  191. package/dist/test/shutdown-errors.test.d.ts +2 -0
  192. package/dist/test/shutdown-errors.test.d.ts.map +1 -0
  193. package/dist/test/shutdown-errors.test.js +662 -0
  194. package/dist/test/shutdown-errors.test.js.map +1 -0
  195. package/dist/test/silent-heartbeat-rows.test.d.ts +2 -0
  196. package/dist/test/silent-heartbeat-rows.test.d.ts.map +1 -0
  197. package/dist/test/silent-heartbeat-rows.test.js +451 -0
  198. package/dist/test/silent-heartbeat-rows.test.js.map +1 -0
  199. package/dist/test/silent-heartbeat.test.js +49 -38
  200. package/dist/test/silent-heartbeat.test.js.map +1 -1
  201. package/dist/test/stop-with-work-in-flight.test.d.ts +23 -0
  202. package/dist/test/stop-with-work-in-flight.test.d.ts.map +1 -0
  203. package/dist/test/stop-with-work-in-flight.test.js +672 -0
  204. package/dist/test/stop-with-work-in-flight.test.js.map +1 -0
  205. package/dist/test/tool-batch-hook.test.d.ts +8 -0
  206. package/dist/test/tool-batch-hook.test.d.ts.map +1 -0
  207. package/dist/test/tool-batch-hook.test.js +275 -0
  208. package/dist/test/tool-batch-hook.test.js.map +1 -0
  209. package/dist/test/tool-presentation.test.d.ts +2 -0
  210. package/dist/test/tool-presentation.test.d.ts.map +1 -0
  211. package/dist/test/tool-presentation.test.js +268 -0
  212. package/dist/test/tool-presentation.test.js.map +1 -0
  213. package/dist/test/tool-result-guard.test.js +2330 -18
  214. package/dist/test/tool-result-guard.test.js.map +1 -1
  215. package/dist/test/tool-result-history.test.js +2 -1
  216. package/dist/test/tool-result-history.test.js.map +1 -1
  217. package/dist/test/turn-trigger-provenance.test.js +35 -0
  218. package/dist/test/turn-trigger-provenance.test.js.map +1 -1
  219. package/dist/test/unconvertible-tool-result.test.d.ts +2 -0
  220. package/dist/test/unconvertible-tool-result.test.d.ts.map +1 -0
  221. package/dist/test/unconvertible-tool-result.test.js +358 -0
  222. package/dist/test/unconvertible-tool-result.test.js.map +1 -0
  223. package/dist/test/workspace-materialize-freshness.test.d.ts +16 -0
  224. package/dist/test/workspace-materialize-freshness.test.d.ts.map +1 -0
  225. package/dist/test/workspace-materialize-freshness.test.js +252 -0
  226. package/dist/test/workspace-materialize-freshness.test.js.map +1 -0
  227. package/dist/test/workspace-three-way.test.d.ts +12 -0
  228. package/dist/test/workspace-three-way.test.d.ts.map +1 -0
  229. package/dist/test/workspace-three-way.test.js +3079 -0
  230. package/dist/test/workspace-three-way.test.js.map +1 -0
  231. package/dist/tsconfig.tsbuildinfo +1 -1
  232. package/package.json +2 -2
  233. package/src/agent.ts +120 -44
  234. package/src/code-execution/py-runner.ts +66 -9
  235. package/src/code-execution/runtime-py.ts +215 -38
  236. package/src/framework.ts +1661 -363
  237. package/src/gate/event-gate.ts +59 -7
  238. package/src/index.ts +11 -0
  239. package/src/mcpl/channel-registry.ts +24 -3
  240. package/src/mcpl/conversation-router.ts +34 -1
  241. package/src/mcpl/feature-set-manager.ts +36 -11
  242. package/src/mcpl/index.ts +2 -0
  243. package/src/mcpl/prose-stream-router.ts +79 -23
  244. package/src/mcpl/push-coalescer.ts +62 -13
  245. package/src/mcpl/push-handler.ts +41 -12
  246. package/src/mcpl/server-connection.ts +41 -10
  247. package/src/mcpl/server-registry.ts +24 -7
  248. package/src/mcpl/tool-lifecycle.ts +77 -2
  249. package/src/mcpl/tool-pattern-check.ts +106 -0
  250. package/src/mcpl/types.ts +15 -5
  251. package/src/mcpl/visible-content.ts +57 -0
  252. package/src/module-registry.ts +252 -16
  253. package/src/modules/workspace/branch-intent.ts +123 -0
  254. package/src/modules/workspace/disk-agreement.ts +325 -0
  255. package/src/modules/workspace/effects.ts +362 -0
  256. package/src/modules/workspace/index.ts +1058 -446
  257. package/src/modules/workspace/observe.ts +839 -0
  258. package/src/modules/workspace/reconcile.ts +1136 -0
  259. package/src/modules/workspace/sync.ts +6 -336
  260. package/src/modules/workspace/types.ts +75 -10
  261. package/src/record-journal.ts +246 -0
  262. package/src/shutdown.ts +49 -0
  263. package/src/silent-heartbeat.ts +141 -0
  264. package/src/tool-presentation.ts +188 -0
  265. package/src/tool-result-guard.ts +335 -33
  266. package/src/tool-result-history.ts +25 -1
  267. package/src/types/agent.ts +18 -2
  268. package/src/types/events.ts +4 -0
  269. package/src/types/framework.ts +12 -0
  270. package/src/types/module.ts +15 -0
  271. package/src/types/trace.ts +80 -0
@@ -0,0 +1,278 @@
1
+ /**
2
+ * How the workspace observes disk for reconciliation, under the mount's
3
+ * boundary.
4
+ *
5
+ * Observation honors the boundary the way openContainedFile does: the lexical
6
+ * path is lstat'd first, a symlink is refused unless the mount follows
7
+ * symlinks, and a followed one must resolve inside the canonical mount root.
8
+ * Anything that isn't a regular file inside the mount is `unobserved` — it
9
+ * proves nothing either way, and reconciliation leaves the path alone.
10
+ *
11
+ * Reads go through one descriptor that is fstat'd, located inside the mount
12
+ * and then read, so what is read and the fingerprint recorded with its hash
13
+ * describe the same file, inside the mount. A hard link is a name inside the
14
+ * mount like any other, and reading through it shows what that path holds;
15
+ * only a write in place reaches a file's other names, so effects.ts refuses
16
+ * that instead.
17
+ *
18
+ * Directories are checked (CheckedDir): located inside the mount, with their
19
+ * identity, and what they showed — a listing, an absence — is accepted only
20
+ * if each is still the directory its logical path names afterwards. A walk records which
21
+ * directories it listed completely, and only those prove a file absent: an
22
+ * unreadable directory, an ignored subtree, the file cap, a symlink the walk
23
+ * doesn't descend, or a directory that changed while it was listed leave
24
+ * everything beneath them unproven. Outside a walk, absence is proven the
25
+ * same way: by a directory inside the mount, still at its path, that lacks
26
+ * the entry (confirmAbsent). A missing parent alone proves nothing, since a
27
+ * dangling symlink or a swapped directory looks just like one.
28
+ *
29
+ * Each check is made where the operation happens, against what is there at
30
+ * that moment, so the boundary holds against what is in the mount, including
31
+ * what appears while an operation runs. Node has no openat or fdopendir, so
32
+ * a directory is checked by its canonical path and identity, not held open:
33
+ * a parent replaced concurrently in the window between a check and its use
34
+ * (or replaced and restored around it) can still redirect a listing or
35
+ * lookup there. File contents are bound regardless: a file is read only
36
+ * through a descriptor bound to its path first.
37
+ */
38
+ import { type Fingerprint, type RootIdentity } from './disk-agreement.js';
39
+ export interface MountView {
40
+ /** Mount root as configured. */
41
+ root: string;
42
+ /**
43
+ * The root directory disk last agreed under, once the mount has evidence.
44
+ * A root that resolves to any other directory is unavailable.
45
+ */
46
+ rootIdentity?: RootIdentity;
47
+ followSymlinks: boolean;
48
+ /** Text above this size is not ingested. */
49
+ maxFileSize: number;
50
+ ignore: string[];
51
+ }
52
+ export type StatFingerprint = Omit<Fingerprint, 'hashedAt'>;
53
+ /**
54
+ * Opened with every read or write of a workspace path, where the platform has
55
+ * it: for a regular file it changes nothing, and a FIFO or other special file
56
+ * swapped in at the path neither blocks the open nor passes the regular-file
57
+ * check that follows.
58
+ */
59
+ export declare const NONBLOCK: number;
60
+ export type Observation = {
61
+ kind: 'absent';
62
+ } | {
63
+ kind: 'file';
64
+ size: number;
65
+ mtimeMs: number;
66
+ fp: StatFingerprint;
67
+ } | {
68
+ kind: 'unobserved';
69
+ reason: string;
70
+ };
71
+ export interface ReadResult {
72
+ kind: 'read';
73
+ size: number;
74
+ mtimeMs: number;
75
+ fp: Fingerprint;
76
+ hash: string;
77
+ /** The whole file, when it is at most the requested limit. */
78
+ bytes: Buffer | null;
79
+ /** First bytes, for binary detection and MIME sniffing. */
80
+ head: Buffer;
81
+ }
82
+ /** The first bytes of a file and its size: nothing else was read or hashed. */
83
+ export interface HeadResult {
84
+ kind: 'head';
85
+ size: number;
86
+ mtimeMs: number;
87
+ head: Buffer;
88
+ }
89
+ /** Bytes kept for binary detection and MIME sniffing. */
90
+ export declare const HEAD_BYTES = 8192;
91
+ /** Timestamps this close to the hashing time can't vouch for the bytes. */
92
+ export declare const RACY_WINDOW_MS = 2000;
93
+ export declare const OUTSIDE_PARENT = "a parent directory resolves outside the mount";
94
+ export declare const NOT_FOLLOWED = "a symlink, which this mount does not follow";
95
+ export declare const ROOT_UNAVAILABLE = "the mount root is unavailable";
96
+ export declare const ROOT_REPLACED: string;
97
+ export declare function errno(err: unknown): string | undefined;
98
+ export declare function contained(rootReal: string, candidate: string): boolean;
99
+ /** The mount-relative parent of a path ('' for the root). */
100
+ export declare function parentOf(relativePath: string): string;
101
+ /** The last component of a mount-relative path. */
102
+ export declare function nameOf(relativePath: string): string;
103
+ export type DirCheck = {
104
+ kind: 'checked';
105
+ dir: CheckedDir;
106
+ }
107
+ /**
108
+ * No directory there, proven: nothing can exist beneath the path. `by` is
109
+ * the directory whose entries prove it — the one that lacks it, or that
110
+ * holds the non-directory in its place.
111
+ */
112
+ | {
113
+ kind: 'absent';
114
+ by: string;
115
+ }
116
+ /** Unproven either way; `outside` when it resolves outside the mount. */
117
+ | {
118
+ kind: 'unobserved';
119
+ reason: string;
120
+ outside?: true;
121
+ };
122
+ /**
123
+ * A directory inside the mount, as it was checked: its canonical path and
124
+ * its identity. Its entries are named through that path, and what it showed
125
+ * is accepted only while it is still the directory its logical path names
126
+ * (see the module doc for what that does and doesn't bind).
127
+ */
128
+ export declare class CheckedDir {
129
+ /** Mount-relative path ('' for the root). */
130
+ readonly rel: string;
131
+ /** Its canonical location when checked. */
132
+ readonly real: string;
133
+ private readonly lexical;
134
+ private readonly dev;
135
+ private readonly ino;
136
+ constructor(
137
+ /** Mount-relative path ('' for the root). */
138
+ rel: string,
139
+ /** Its canonical location when checked. */
140
+ real: string, lexical: string, dev: bigint, ino: bigint);
141
+ /** Which directory it is. */
142
+ identity(): RootIdentity;
143
+ /** A path that reaches `name` in this directory. */
144
+ at(name: string): string;
145
+ /** Whether it is still the directory its logical path names: same location, same directory. */
146
+ stillHere(): Promise<boolean>;
147
+ /**
148
+ * Make its entries durable: this very directory, never one that replaced
149
+ * it at its path. Throws if it can't; a filesystem that can't sync
150
+ * directories (or Windows, where a directory can't be opened for it) is
151
+ * not a failure.
152
+ */
153
+ sync(): Promise<void>;
154
+ }
155
+ /**
156
+ * The mount root as it is now: its identity if it is available (a directory,
157
+ * the one the pass was given, and the one disk last agreed under), else why not.
158
+ */
159
+ export declare function locateRoot(view: MountView, rootReal: string): Promise<{
160
+ identity: RootIdentity;
161
+ } | {
162
+ reason: string;
163
+ }>;
164
+ /** The mount root as locateRoot finds it, checked, so a caller can ask later whether it's still there. */
165
+ export declare function checkRoot(view: MountView, rootReal: string): Promise<{
166
+ dir: CheckedDir;
167
+ } | {
168
+ reason: string;
169
+ }>;
170
+ /**
171
+ * Check the directory at a mount-relative path. With `create`, missing
172
+ * directories are made one at a time beneath the deepest one that exists;
173
+ * the mount root itself is never created (a missing root is an unavailable
174
+ * mount). Without it, a missing directory is `absent` only where that can be
175
+ * proven (confirmAbsent).
176
+ */
177
+ export declare function checkDir(view: MountView, rootReal: string, rel: string, opts?: {
178
+ create?: boolean;
179
+ }): Promise<DirCheck>;
180
+ /**
181
+ * Prove that nothing exists at a mount-relative path (`entry`), or that no
182
+ * directory does, so nothing can exist beneath it (`beneath`). Walking down
183
+ * from the root through checked directories: some directory lacks the next
184
+ * component; or a component is a non-directory, still the same one, beneath
185
+ * which nothing can exist. Either proves it only while every directory the
186
+ * walk went through, the root included, is still the one its path names
187
+ * afterwards: a root or parent replaced during the walk would otherwise lend
188
+ * its replacement's absence to the original's path. Symlinked directories
189
+ * inside the mount are followed as parents; any other symlink proves
190
+ * nothing. Returns the directory whose entries prove it, or why absence
191
+ * couldn't be shown.
192
+ */
193
+ export declare function confirmAbsent(view: MountView, rootReal: string, rel: string, target?: 'entry' | 'beneath'): Promise<{
194
+ by: string;
195
+ } | string>;
196
+ /** Same file, same bytes, as far as stat can tell. */
197
+ export declare function sameFingerprint(a: StatFingerprint, b: StatFingerprint): boolean;
198
+ /**
199
+ * Whether a recorded fingerprint vouches that the current file still holds
200
+ * the bytes hashed with it: the filesystem maintains ctime (so no user-space
201
+ * tool can restore the old stamps after a write), every field matches, and
202
+ * the file's timestamps were already more than the racy window old when it
203
+ * was hashed (a write in the same timestamp tick can't hide behind them).
204
+ * Device and inode are part of it, so a stat that reached another file — a
205
+ * path whose parent was swapped, say — can never vouch for P's bytes.
206
+ */
207
+ export declare function fingerprintVouches(recorded: Fingerprint | undefined, current: StatFingerprint, trusted: boolean): boolean;
208
+ /** Whether a statfs f_type is one of those filesystems. */
209
+ export declare function fsTypeTrustsCtime(type: number | bigint): boolean;
210
+ export declare function filesystemTrustsCtime(root: string): Promise<boolean>;
211
+ /**
212
+ * Observe a mount-relative path without reading it. A `file` here is only a
213
+ * stat — anything decided on its bytes is read through a located descriptor,
214
+ * or vouched for by a fingerprint of the very inode P was recorded from — so
215
+ * only `absent` needs proof beyond the path lookup, and gets it.
216
+ */
217
+ export declare function observePath(view: MountView, rootReal: string, relativePath: string): Promise<Observation>;
218
+ /**
219
+ * Read and hash a mount-relative file through one located descriptor. The
220
+ * whole file is returned when it is at most `limit` bytes; larger files are
221
+ * hashed in chunks and only their head is kept.
222
+ */
223
+ export declare function readPath(view: MountView, rootReal: string, relativePath: string, limit: number): Promise<ReadResult | Exclude<Observation, {
224
+ kind: 'file';
225
+ }>>;
226
+ /**
227
+ * The first bytes of a mount-relative file and its size, through the same
228
+ * located descriptor as readPath — for listing a file nothing tracks, which
229
+ * needs a MIME type, not a hash.
230
+ */
231
+ export declare function readHead(view: MountView, rootReal: string, relativePath: string): Promise<HeadResult | Exclude<Observation, {
232
+ kind: 'file';
233
+ }>>;
234
+ /** Null bytes in the first 8 KB: the store holds text only from disk. */
235
+ export declare function looksBinary(head: Buffer): boolean;
236
+ /** Image MIME type from magic bytes, for listing disk-only files. */
237
+ export declare function sniffImageMime(head: Buffer): string | undefined;
238
+ export interface Walk {
239
+ /** Regular files seen. */
240
+ files: Set<string>;
241
+ /** Directories seen. */
242
+ dirs: Set<string>;
243
+ /** Names seen that are neither (symlinks, sockets…), or ignored: present, unproven. */
244
+ others: Map<string, string>;
245
+ /** Directories listed completely. */
246
+ complete: Set<string>;
247
+ /** Directories that don't exist (everything beneath them is absent). */
248
+ missing: Set<string>;
249
+ /**
250
+ * Where the walk didn't reach, and why. `error` and `cap` regions may hide
251
+ * files the listing would show; `ignored` and `symlink` ones matter only
252
+ * where tracked entries lie beneath them.
253
+ */
254
+ incomplete: Array<{
255
+ path: string;
256
+ reason: string;
257
+ kind: 'error' | 'cap' | 'ignored' | 'symlink';
258
+ }>;
259
+ }
260
+ /** Simple ignore patterns, as the watcher and the old walk read them. */
261
+ export declare function isIgnored(relativePath: string, name: string, patterns: string[]): boolean;
262
+ /**
263
+ * List a directory scope ('' for the mount root), descending when recursive,
264
+ * up to `cap` files in total. A scope that resolves outside the mount is not
265
+ * listed at all; beneath it, the walk only descends real directories, never
266
+ * symlinks. Each directory's listing counts only if, once listed, it is still
267
+ * the directory at its path: a directory moved or replaced meanwhile is an
268
+ * incomplete region, contributing no names and proving nothing absent.
269
+ */
270
+ export declare function walkScope(view: MountView, rootReal: string, scope: string, recursive: boolean, cap: number): Promise<Walk>;
271
+ /**
272
+ * Whether the walk proves nothing exists at `path`: some ancestor directory
273
+ * is missing, or a completely listed ancestor holds no entry that could lead
274
+ * to it. Ancestors outside the walked scope are passed through, so a walk of
275
+ * `a/b` decides paths beneath `a/b` and nothing else.
276
+ */
277
+ export declare function provenAbsent(walk: Walk, path: string): boolean;
278
+ //# sourceMappingURL=observe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observe.d.ts","sourceRoot":"","sources":["../../../../src/modules/workspace/observe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAQH,OAAO,EAAoB,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAE5F,MAAM,WAAW,SAAS;IACxB,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,cAAc,EAAE,OAAO,CAAC;IACxB,4CAA4C;IAC5C,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;AAE5D;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,QAA0E,CAAC;AAEhG,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,eAAe,CAAA;CAAE,GACpE;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3C,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,WAAW,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,8DAA8D;IAC9D,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAC;CACd;AAED,+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