@sema-agent/core 5.20.0 → 5.21.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 (312) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/agents/agent-definition.d.ts +7 -0
  3. package/dist/agents/agent-transcript-tool.d.ts +30 -0
  4. package/dist/agents/builtin-agents.d.ts +60 -0
  5. package/dist/agents/cascade.d.ts +107 -0
  6. package/dist/agents/cumulative-stats.d.ts +56 -0
  7. package/dist/agents/observer.d.ts +162 -0
  8. package/dist/agents/peer-admission.d.ts +95 -0
  9. package/dist/agents/repair-loop.d.ts +226 -0
  10. package/dist/agents/retain-ledger.d.ts +141 -0
  11. package/dist/agents/roster-store.d.ts +105 -0
  12. package/dist/agents/send-message-tool.d.ts +92 -0
  13. package/dist/agents/session-util.d.ts +5 -0
  14. package/dist/agents/subagent-steps.d.ts +66 -0
  15. package/dist/agents/subagent.d.ts +600 -0
  16. package/dist/agents/suspend-guard.d.ts +29 -0
  17. package/dist/agents/teacher.d.ts +75 -0
  18. package/dist/agents/team.d.ts +120 -1
  19. package/dist/agents/tool-filter.d.ts +34 -0
  20. package/dist/agents/verify.d.ts +198 -0
  21. package/dist/bench/metrics.d.ts +455 -0
  22. package/dist/brain/anthropic.d.ts +30 -0
  23. package/dist/brain/circuit-breaker.d.ts +33 -0
  24. package/dist/brain/context-overflow.d.ts +60 -3
  25. package/dist/brain/degrading.d.ts +67 -0
  26. package/dist/brain/errors.d.ts +42 -0
  27. package/dist/brain/failover.d.ts +15 -0
  28. package/dist/brain/media-degrade.d.ts +39 -0
  29. package/dist/brain/model-presets.d.ts +31 -0
  30. package/dist/brain/open-responses.d.ts +19 -0
  31. package/dist/brain/openai.d.ts +46 -0
  32. package/dist/brain/reasoning.d.ts +106 -1
  33. package/dist/brain/repetition.d.ts +83 -0
  34. package/dist/brain/request-params.d.ts +56 -0
  35. package/dist/brain/retry.d.ts +46 -0
  36. package/dist/brain/routing.d.ts +12 -0
  37. package/dist/brain/status-sink.d.ts +30 -1
  38. package/dist/brain/stream-engine.d.ts +147 -0
  39. package/dist/brain/stream-shared.d.ts +34 -0
  40. package/dist/brain/terminal-cause.d.ts +31 -0
  41. package/dist/brain/timeout.d.ts +107 -0
  42. package/dist/brain/tool-call-id.d.ts +20 -0
  43. package/dist/brain/tool-call-repair.d.ts +13 -0
  44. package/dist/config/catalog.d.ts +47 -0
  45. package/dist/config/defaults.d.ts +33 -0
  46. package/dist/core/a2a-task-state.d.ts +53 -0
  47. package/dist/core/a2a.d.ts +51 -0
  48. package/dist/core/arg-summary.d.ts +62 -0
  49. package/dist/core/ask-question.d.ts +272 -2
  50. package/dist/core/auto-compaction.d.ts +467 -0
  51. package/dist/core/auto-compaction.js +20 -6
  52. package/dist/core/auto-mode-prompt-assets.d.ts +8 -0
  53. package/dist/core/auto-mode-prompt.d.ts +27 -0
  54. package/dist/core/auto-mode.d.ts +54 -3
  55. package/dist/core/auto-promote.d.ts +100 -0
  56. package/dist/core/background-agent-store.d.ts +292 -0
  57. package/dist/core/background-shell.d.ts +110 -0
  58. package/dist/core/cache-break-detector.d.ts +34 -0
  59. package/dist/core/canonical-json.d.ts +57 -0
  60. package/dist/core/checkpoint-store.d.ts +1574 -16
  61. package/dist/core/compliance.d.ts +30 -0
  62. package/dist/core/consolidate-scope.d.ts +75 -0
  63. package/dist/core/context-edit.d.ts +99 -0
  64. package/dist/core/context-guard.d.ts +46 -0
  65. package/dist/core/exec-gate.d.ts +44 -0
  66. package/dist/core/exec-output-tail.d.ts +61 -0
  67. package/dist/core/file-snapshot-store.d.ts +104 -0
  68. package/dist/core/fs-write-gate-policy.d.ts +36 -0
  69. package/dist/core/git-worktree-env.d.ts +31 -0
  70. package/dist/core/governance-codes.d.ts +19 -0
  71. package/dist/core/hooks.d.ts +608 -1
  72. package/dist/core/human-input-projection.d.ts +37 -0
  73. package/dist/core/human-input-projection.js +13 -0
  74. package/dist/core/image-downsample.d.ts +74 -0
  75. package/dist/core/locked-config.d.ts +37 -0
  76. package/dist/core/lsp-diagnostics.d.ts +77 -0
  77. package/dist/core/lsp-protocol.d.ts +29 -0
  78. package/dist/core/lsp-session.d.ts +60 -1
  79. package/dist/core/lsp.d.ts +150 -1
  80. package/dist/core/mailbox-store.d.ts +57 -0
  81. package/dist/core/mcp.d.ts +381 -0
  82. package/dist/core/media-byte-cap.d.ts +21 -0
  83. package/dist/core/memory-admission.d.ts +71 -0
  84. package/dist/core/memory-engine/content-origin.d.ts +64 -0
  85. package/dist/core/memory-engine/data-plane.d.ts +43 -0
  86. package/dist/core/memory-engine/dual-root.d.ts +24 -0
  87. package/dist/core/memory-engine/engine.d.ts +230 -0
  88. package/dist/core/memory-engine/engine.js +103 -35
  89. package/dist/core/memory-engine/file-backend.d.ts +155 -0
  90. package/dist/core/memory-engine/frontmatter.d.ts +16 -0
  91. package/dist/core/memory-engine/layout.d.ts +217 -0
  92. package/dist/core/memory-engine/memory-backend-contract.d.ts +12 -0
  93. package/dist/core/memory-engine/migrate.d.ts +9 -0
  94. package/dist/core/memory-engine/scan.d.ts +12 -0
  95. package/dist/core/memory-engine/scope-contract.d.ts +61 -1
  96. package/dist/core/memory-engine/sync-client.d.ts +87 -0
  97. package/dist/core/memory-engine/sync.d.ts +60 -0
  98. package/dist/core/memory-engine/tools.d.ts +41 -0
  99. package/dist/core/memory-engine/types.d.ts +188 -0
  100. package/dist/core/memory-recall.d.ts +141 -0
  101. package/dist/core/memory-vector.d.ts +20 -0
  102. package/dist/core/memory.d.ts +458 -0
  103. package/dist/core/message-utils.d.ts +6 -0
  104. package/dist/core/oracle-isolation.d.ts +69 -0
  105. package/dist/core/permission-rule-consent.d.ts +138 -0
  106. package/dist/core/permission-rule-model.d.ts +122 -0
  107. package/dist/core/permission-rule-store.d.ts +119 -3
  108. package/dist/core/permission-rules.d.ts +87 -1
  109. package/dist/core/present-plan-tool.d.ts +20 -0
  110. package/dist/core/pricing.d.ts +26 -0
  111. package/dist/core/property-harness.d.ts +86 -0
  112. package/dist/core/protocol-naming.d.ts +38 -0
  113. package/dist/core/protocol-table.d.ts +61 -0
  114. package/dist/core/push-queue.d.ts +1 -0
  115. package/dist/core/remote-env.d.ts +383 -1
  116. package/dist/core/retention-policy.d.ts +33 -0
  117. package/dist/core/retention.d.ts +51 -0
  118. package/dist/core/roles.d.ts +59 -0
  119. package/dist/core/runner/active-skill-scope.d.ts +34 -0
  120. package/dist/core/runner/assemble-result.d.ts +134 -0
  121. package/dist/core/runner/compaction-call-options.d.ts +97 -1
  122. package/dist/core/runner/grounding-signal.d.ts +10 -0
  123. package/dist/core/runner/image.d.ts +17 -0
  124. package/dist/core/runner/image.js +29 -15
  125. package/dist/core/runner/memory-consolidation.d.ts +60 -0
  126. package/dist/core/runner/prepare-memory.d.ts +59 -0
  127. package/dist/core/runner/prepare-task.d.ts +1011 -2
  128. package/dist/core/runner/prepare-task.js +12 -11
  129. package/dist/core/runner/prompt-suggestions.d.ts +7 -0
  130. package/dist/core/runner/runtask.d.ts +304 -3
  131. package/dist/core/runner/session-file-state-replay.d.ts +49 -0
  132. package/dist/core/runner/session-rule-policy.d.ts +58 -0
  133. package/dist/core/runner/strict-output-schema.d.ts +18 -3
  134. package/dist/core/runner/synthetic-tools.d.ts +113 -0
  135. package/dist/core/runner/teardown-bounded.d.ts +34 -0
  136. package/dist/core/runner/tool-disclosure.d.ts +227 -0
  137. package/dist/core/runner/tool-output-projection.d.ts +6 -0
  138. package/dist/core/runner/turn-attachments.d.ts +634 -0
  139. package/dist/core/runner/usage-accounting.d.ts +32 -0
  140. package/dist/core/runtime.d.ts +9 -0
  141. package/dist/core/safe-notify.d.ts +64 -0
  142. package/dist/core/safety-axis-vocab.d.ts +23 -0
  143. package/dist/core/safety-merge-corpus.d.ts +37 -0
  144. package/dist/core/scheduler.d.ts +121 -0
  145. package/dist/core/secret-env.d.ts +32 -0
  146. package/dist/core/select-model.d.ts +15 -0
  147. package/dist/core/sensitive-path-policy.d.ts +42 -0
  148. package/dist/core/session-policy-store.d.ts +94 -0
  149. package/dist/core/session-reconcile.d.ts +80 -0
  150. package/dist/core/session-store.d.ts +85 -0
  151. package/dist/core/session.d.ts +153 -0
  152. package/dist/core/shared-memory/contract.d.ts +22 -0
  153. package/dist/core/shared-memory/normalize.d.ts +123 -2
  154. package/dist/core/shared-memory/tools.d.ts +14 -0
  155. package/dist/core/shared-memory/types.d.ts +105 -0
  156. package/dist/core/shutdown-debug.d.ts +6 -0
  157. package/dist/core/side-query.d.ts +38 -0
  158. package/dist/core/side-query.js +6 -1
  159. package/dist/core/skill-tool-specifier.d.ts +72 -0
  160. package/dist/core/skills-directory.d.ts +100 -1
  161. package/dist/core/spec-contract.d.ts +89 -0
  162. package/dist/core/store-contracts/background-agent-store-contract.d.ts +31 -0
  163. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +26 -0
  164. package/dist/core/store-contracts/contract-harness.d.ts +20 -0
  165. package/dist/core/store-contracts/contract-kit-version.d.ts +27 -0
  166. package/dist/core/store-contracts/file-snapshot-store-contract.d.ts +8 -0
  167. package/dist/core/store-contracts/mailbox-store-contract.d.ts +42 -0
  168. package/dist/core/store-contracts/tool-result-store-contract.d.ts +13 -0
  169. package/dist/core/strategy-store.d.ts +37 -0
  170. package/dist/core/stub-env.d.ts +7 -0
  171. package/dist/core/surrogate-safe-slice.d.ts +35 -0
  172. package/dist/core/task-notification.d.ts +202 -0
  173. package/dist/core/task-outcome.d.ts +53 -0
  174. package/dist/core/task-registry-agent.d.ts +337 -1
  175. package/dist/core/task-registry-monitor.d.ts +12 -0
  176. package/dist/core/task-registry-shared.d.ts +540 -0
  177. package/dist/core/task-registry.d.ts +343 -0
  178. package/dist/core/task-registry.js +13 -2
  179. package/dist/core/task-tool-shape.d.ts +44 -0
  180. package/dist/core/tighten-task-spec.d.ts +21 -0
  181. package/dist/core/tool-detach.d.ts +21 -0
  182. package/dist/core/tool-errors.d.ts +131 -0
  183. package/dist/core/tool-errors.js +4 -0
  184. package/dist/core/tool-name-aliases.d.ts +27 -0
  185. package/dist/core/tool-policy.d.ts +555 -0
  186. package/dist/core/tool-result-budget.d.ts +32 -0
  187. package/dist/core/tool-result-store.d.ts +174 -1
  188. package/dist/core/tools.d.ts +45 -0
  189. package/dist/core/trace.d.ts +323 -0
  190. package/dist/core/types.d.ts +3859 -2
  191. package/dist/core/untrusted-egress.d.ts +8 -0
  192. package/dist/core/untrusted-text.d.ts +156 -0
  193. package/dist/core/usage-window-store.d.ts +95 -0
  194. package/dist/core/version.d.ts +1 -0
  195. package/dist/core/warm-resume.d.ts +17 -0
  196. package/dist/core/wiring-manifest.d.ts +169 -0
  197. package/dist/core/with-retry.d.ts +24 -0
  198. package/dist/core/workflow-journal-store.d.ts +160 -0
  199. package/dist/core/workflow-run-store-contract.d.ts +25 -0
  200. package/dist/core/workflow-run-store.d.ts +119 -0
  201. package/dist/engine/compaction/compaction.d.ts +256 -1
  202. package/dist/engine/compaction/utils.d.ts +94 -0
  203. package/dist/engine/execution-env/kill-tree.d.ts +29 -0
  204. package/dist/engine/execution-env/node-execution-env.d.ts +94 -0
  205. package/dist/engine/harness/agent-harness.d.ts +116 -0
  206. package/dist/engine/harness/agent-harness.js +3 -14
  207. package/dist/engine/harness/messages.d.ts +15 -0
  208. package/dist/engine/harness/types.d.ts +464 -2
  209. package/dist/engine/llm/diagnostics.d.ts +4 -0
  210. package/dist/engine/llm/event-stream.d.ts +3 -0
  211. package/dist/engine/llm/index.d.ts +7 -0
  212. package/dist/engine/llm/types.d.ts +500 -3
  213. package/dist/engine/llm/validation.d.ts +3 -0
  214. package/dist/engine/loop/agent-loop.d.ts +87 -2
  215. package/dist/engine/loop/runtime-deps.d.ts +7 -0
  216. package/dist/engine/loop/types.d.ts +424 -0
  217. package/dist/engine/lsp/frame-decoder.d.ts +13 -0
  218. package/dist/engine/lsp/node-lsp-manager.d.ts +107 -0
  219. package/dist/engine/lsp/stdio-lsp-transport.d.ts +7 -0
  220. package/dist/engine/session/import-validate.d.ts +27 -0
  221. package/dist/engine/session/log-digest.d.ts +93 -0
  222. package/dist/engine/session/memory-repo.d.ts +6 -0
  223. package/dist/engine/session/memory-storage.d.ts +2 -0
  224. package/dist/engine/session/session.d.ts +75 -0
  225. package/dist/engine/session/storage-base.d.ts +8 -0
  226. package/dist/fixtures/index.d.ts +36 -0
  227. package/dist/index.d.ts +16 -1
  228. package/dist/index.js +0 -1
  229. package/dist/internal/harness-types.d.ts +6 -0
  230. package/dist/internal/harness.d.ts +11 -0
  231. package/dist/internal/llm.d.ts +6 -0
  232. package/dist/orchestration/builtin-workflows.d.ts +53 -0
  233. package/dist/orchestration/dev-vm-script-runner.d.ts +19 -0
  234. package/dist/orchestration/goal.d.ts +57 -0
  235. package/dist/orchestration/goal.js +3 -0
  236. package/dist/orchestration/run-spec.d.ts +42 -0
  237. package/dist/orchestration/run-workflow-tool.d.ts +169 -0
  238. package/dist/orchestration/workflow-governance.d.ts +61 -0
  239. package/dist/orchestration/workflow-meta.d.ts +28 -0
  240. package/dist/orchestration/workflow-observe.d.ts +60 -0
  241. package/dist/orchestration/workflow-primitives.d.ts +23 -1
  242. package/dist/orchestration/workflow-sandbox-conformance.d.ts +38 -0
  243. package/dist/orchestration/workflow-script-runner.d.ts +88 -0
  244. package/dist/orchestration/workflow-script-store.d.ts +98 -0
  245. package/dist/orchestration/workflow-size-guideline.d.ts +67 -0
  246. package/dist/orchestration/workflow-types.d.ts +169 -2
  247. package/dist/orchestration/workflow.d.ts +358 -0
  248. package/dist/prompt-assembly/artifact-store.d.ts +33 -0
  249. package/dist/prompt-assembly/artifact.d.ts +25 -0
  250. package/dist/prompt-assembly/assemble.d.ts +20 -0
  251. package/dist/prompt-assembly/composer.d.ts +29 -0
  252. package/dist/prompt-assembly/epoch.d.ts +55 -1
  253. package/dist/prompt-assembly/event-registry.d.ts +35 -0
  254. package/dist/prompt-assembly/explain.d.ts +12 -0
  255. package/dist/prompt-assembly/tool-catalog.d.ts +38 -0
  256. package/dist/prompt-assembly/turn-snapshot.d.ts +40 -0
  257. package/dist/prompt-assembly/types.d.ts +115 -0
  258. package/dist/prompts/coordinator.d.ts +27 -0
  259. package/dist/prompts/default.d.ts +539 -0
  260. package/dist/prompts/simple-sections.d.ts +45 -0
  261. package/dist/prompts/supervisor.d.ts +66 -0
  262. package/dist/scenarios/env.d.ts +28 -0
  263. package/dist/scenarios/full-body.d.ts +50 -0
  264. package/dist/scenarios/scenario-registry.d.ts +60 -0
  265. package/dist/scenarios/teacher-quickstart.d.ts +27 -0
  266. package/dist/server/http.d.ts +17 -0
  267. package/dist/stores/cc/lockfile.d.ts +6 -0
  268. package/dist/stores/cc/mailbox-store.d.ts +8 -0
  269. package/dist/stores/cc/roster-adapter.d.ts +4 -0
  270. package/dist/stores/cc/sidecar-transcript.d.ts +66 -0
  271. package/dist/stores/file/background-agent-store.d.ts +24 -0
  272. package/dist/stores/file/checkpoint-store.d.ts +38 -0
  273. package/dist/stores/file/file-snapshot-store.d.ts +25 -0
  274. package/dist/stores/file/fs-atomic.d.ts +155 -0
  275. package/dist/stores/file/index.d.ts +89 -0
  276. package/dist/stores/file/mailbox-store.d.ts +36 -0
  277. package/dist/stores/file/memory-store.d.ts +82 -0
  278. package/dist/stores/file/permission-rule-store.d.ts +79 -0
  279. package/dist/stores/file/session-policy-store.d.ts +28 -0
  280. package/dist/stores/file/session-store.d.ts +40 -0
  281. package/dist/stores/file/shared-ledger.d.ts +83 -0
  282. package/dist/stores/file/tool-result-store.d.ts +11 -0
  283. package/dist/stores/file/usage-window-store.d.ts +18 -0
  284. package/dist/stores/file/workflow-journal-store.d.ts +100 -0
  285. package/dist/stores/file/workflow-run-store.d.ts +11 -0
  286. package/dist/tools/fs/bash-readonly-classifier.d.ts +282 -0
  287. package/dist/tools/fs/encoding.d.ts +60 -0
  288. package/dist/tools/fs/fs-bash.d.ts +133 -0
  289. package/dist/tools/fs/fs-pdf.d.ts +28 -0
  290. package/dist/tools/fs/fs-search-tools.d.ts +5 -0
  291. package/dist/tools/fs/fs-shared.d.ts +360 -0
  292. package/dist/tools/fs/fs-write.d.ts +16 -0
  293. package/dist/tools/fs/gh-rate-limit.d.ts +22 -0
  294. package/dist/tools/fs/index.d.ts +79 -0
  295. package/dist/tools/fs/notebook.d.ts +56 -0
  296. package/dist/tools/fs/pdf.d.ts +70 -0
  297. package/dist/tools/fs/pdf.js +8 -2
  298. package/dist/tools/fs/repo-map.d.ts +10 -0
  299. package/dist/tools/fs/safety.d.ts +376 -0
  300. package/dist/tools/fs/search.d.ts +131 -0
  301. package/dist/tools/loop-tick.d.ts +24 -0
  302. package/dist/tools/monitor.d.ts +55 -0
  303. package/dist/tools/scheduler-tools.d.ts +51 -0
  304. package/dist/tools/sql-adapters.d.ts +18 -0
  305. package/dist/tools/sql.d.ts +25 -0
  306. package/dist/tools/task-list.d.ts +77 -0
  307. package/dist/tools/todo.d.ts +8 -0
  308. package/dist/tools/web.d.ts +184 -0
  309. package/dist/tools/worktree.d.ts +81 -0
  310. package/package.json +2 -2
  311. package/dist/tools/gitea-issue.d.ts +0 -13
  312. package/dist/tools/gitea-issue.js +0 -75
@@ -1,5 +1,21 @@
1
+ /** Per-segment cap, measured AFTER encoding. A conservative portability policy adopted as contract
2
+ * (research (d) recommendation — NOT a verified third-party hard limit; uuidv7 = 36 chars fits). */
1
3
  export declare const SCOPE_SEGMENT_MAX_ENCODED = 64;
4
+ /**
5
+ * Canonical injective encoding for a raw identifier entering a scope key: everything outside
6
+ * `[A-Za-z0-9._-]` becomes `%XX` (UTF-8 bytes), INCLUDING `%` itself (that self-encoding is what
7
+ * makes the map injective — no `__`-style collidable escapes). Throws when the encoded segment
8
+ * exceeds {@link SCOPE_SEGMENT_MAX_ENCODED} (an over-long principal is a deployment config error)
9
+ * or when the raw value is empty.
10
+ */
2
11
  export declare function encodeScopeSegment(raw: string): string;
12
+ /**
13
+ * Inverse of {@link encodeScopeSegment}, CANONICAL-FORM ONLY (codex 复审 B6): the input must be
14
+ * exactly what the encoder produces — safe chars stay bare (so `%41` for `A` is refused: two
15
+ * spellings of one identity must not mint two keys), `%XX` sequences must decode as valid UTF-8
16
+ * (fatal decoder — no U+FFFD smoothing), and the 64-char cap holds here too (parse side enforces
17
+ * what the format side promised).
18
+ */
3
19
  export declare function decodeScopeSegment(encoded: string): string;
4
20
  export type ParsedScopeKey = {
5
21
  kind: "user";
@@ -15,7 +31,9 @@ export type ParsedScopeKey = {
15
31
  kind: "userproj";
16
32
  principal: string;
17
33
  projectId: string;
18
- } | {
34
+ }
35
+ /** No recognized v2 prefix: an opaque legacy scope (fully valid under the v2 contract too). */
36
+ | {
19
37
  kind: "legacy";
20
38
  raw: string;
21
39
  };
@@ -23,20 +41,62 @@ export declare function formatUserScope(principal: string): string;
23
41
  export declare function formatOrgScope(tenant: string): string;
24
42
  export declare function formatProjScope(tenant: string, projectId: string): string;
25
43
  export declare function formatUserProjScope(principal: string, projectId: string): string;
44
+ /**
45
+ * Parse a scope key under the v2 contract. A key carrying a recognized prefix MUST be well-formed
46
+ * (fail-loud — a malformed `proj:` key under an explicit opt-in is a config error, not an opaque
47
+ * scope); anything without a recognized prefix parses as `{ kind: "legacy" }` and keeps today's
48
+ * opaque behavior. NEVER call this on a deployment that has not opted in (see module header).
49
+ */
26
50
  export declare function parseScopeKey(key: string): ParsedScopeKey;
51
+ /** True when a v2-parsed key belongs to a PERSONAL plane (`user:` / `userproj:`). */
27
52
  export declare function isPersonalScope(parsed: ParsedScopeKey): boolean;
53
+ /** True when the key's AUTHORITY is central (design/142 §2 表: user/userproj/org rows) — these keys
54
+ * must never project into an in-repo memory dir (they would leak to every collaborator AND enter
55
+ * commit history; codex 复审 B1 extended the F9 gate from personal to org). `proj:`/legacy stay
56
+ * repo-planed. */
28
57
  export declare function isCentralAuthorityScope(parsed: ParsedScopeKey): boolean;
58
+ /**
59
+ * design/142 §7 S1 hard gate (复审 F9): until S1b per-scope physical roots land, ALL scopes of a
60
+ * session materialize under ONE root — so a v2 session mixing `user:*`/`userproj:*` keys with an
61
+ * IN-REPO memory dir would project personal memory into the repo (the exact §2.7 leak shape:
62
+ * personal notes committed to a shared/open repo). Fail-loud, never fail-open: this throws a
63
+ * `config.`-coded error the prepare path must NOT swallow.
64
+ */
29
65
  export declare function assertScopeContractPlacement(args: {
30
66
  parsedScopes: readonly ParsedScopeKey[];
31
67
  memoryDir: string;
68
+ /** The repo/workspace root the session works in (undefined = no repo context, gate passes). */
32
69
  repoRoot: string | undefined;
33
70
  }): void;
71
+ /** Repo-root marker file: minted once (by scaffold/deployment, NEVER by the engine), committed, and
72
+ * from then on the project's identity survives clone/copy/rename/machine/cloud-sandbox. */
34
73
  export declare const PROJECT_MARKER_PATH = ".sema/project";
74
+ /** projectId 格式单源([637]① 承诺):generic UUID,version nibble 不收紧——宽读严写(读面认外部/
75
+ * 历史 v4;铸造面 formatProjectMarker / center mint 统一产 uuidv7)。center 侧自持镜像+dev-only
76
+ * drift 锁对着这条(registry-core coreTypes 先例)。 */
35
77
  export declare const PROJECT_ID_REGEX: RegExp;
78
+ /** Serialize a marker file body (scaffold-side helper; the engine itself never writes one). */
36
79
  export declare function formatProjectMarker(projectId: string): string;
80
+ /** Parse a marker body: TOML-subset `key = value` lines, `#` comments and blank lines ignored,
81
+ * optional quotes around the value. Unknown keys are ignored (forward-compatible). codex 复审 H7:
82
+ * ANY line that starts a `projectId` assignment but is not one canonical UUID assignment is a
83
+ * CORRUPT marker (fail-loud, `config.memory_project_marker`) — an empty value, an unclosed quote,
84
+ * a non-UUID, or a DUPLICATE projectId line must never degrade to "no marker" (that would be a
85
+ * silent identity change back to the path key). Returns null only when NO projectId line exists. */
37
86
  export declare function parseProjectMarker(body: string): {
38
87
  projectId: string;
39
88
  } | null;
89
+ /**
90
+ * design/142 §1.1 — resolve a project's identity. READS ONLY THE MARKER (复审 F2: never derives an
91
+ * identity from a git remote; remote-URL normalization is a scaffold-side minting heuristic, not an
92
+ * identity source). v1 scope (复审 F10): ONE marker at the project root —
93
+ * - inside a git repo, the root is the REPO root; a marker at a nested directory that is not the
94
+ * repo root is fail-loud (`config.memory_project_marker_nested`) — monorepo sub-project identity
95
+ * is a future need-signal, not a silent second identity;
96
+ * - outside git, the given rootDir IS the project root (path-form local projects).
97
+ * Returns null when no marker exists (callers fall through the resolution ladder: explicit
98
+ * declaration → path fallback with a warning).
99
+ */
40
100
  export declare function resolveProjectId(rootDir: string): {
41
101
  projectId: string;
42
102
  markerDir: string;
@@ -1,35 +1,72 @@
1
1
  import { type MemorySyncCursor } from "./sync.js";
2
2
  import type { MemoryBackend, MemoryEntry, PatchReport } from "./types.js";
3
+ /** The injected HTTP seam — core never bundles a fetch. The deployment maps `path` (e.g.
4
+ * `/v1/memory/sync/user%3Aalice`) onto its server base URL, attaches auth, and returns the
5
+ * DECODED JSON body of a 2xx response; any non-2xx / network failure should THROW (the round then
6
+ * aborts with zero local side effects — the transport runs before any local write). */
3
7
  export type MemorySyncTransport = (path: string, body: unknown) => Promise<unknown>;
8
+ /** The wire REQUEST of one round (the server's `parseMemorySyncRequest` twin — [671]①): the push
9
+ * half as computed against the client's own cursor. `deletes` ⊆ `Object.keys(baseRevs)` by
10
+ * construction (a delete is CAS'd on its baseline; an id never synced cannot be delete-propagated). */
4
11
  export interface MemorySyncRequestBody {
5
12
  peer: string;
13
+ /** id → rev at the last completed round (the cursor's baseRevs; empty = first round). */
6
14
  baseRevs: Record<string, string>;
15
+ /** Full state of every entry new/changed here since the baseline. When
16
+ * {@link SyncMemoryScopeOptions.maxPushEntries} is set this is the id-ascending PREFIX of the
17
+ * full push set ([767]③ batching — the remainder rides later rounds). */
7
18
  entries: MemoryEntry[];
19
+ /** Ids deleted here since the baseline (tombstoned or gone from the local plane). Deletes are
20
+ * NEVER batched/split — they are id+baseRev pairs, weightless next to entry bodies ([767]③). */
8
21
  deletes: string[];
22
+ /** [767]③ pull-half batching (wire contract; server implements the response side): ask the
23
+ * server to cap this round's pull half at `limit` items. Absent ⇔ unbatched (the pre-[767]③
24
+ * wire shape byte-for-byte — old servers never see the key). */
9
25
  pull?: {
10
26
  limit?: number;
11
27
  };
12
28
  }
29
+ /** The wire RESPONSE of one round (server `MemorySyncResponse` twin — [671]①: one RTT, both
30
+ * directions; `serverDeletes` is the delete-propagation leg [codex B4 — without it a central
31
+ * removal never crosses = livelock]; `cursor` is the server-computed next baseline with the
32
+ * retention discipline ALREADY applied to the pull half). */
13
33
  export interface MemorySyncResponseBody {
34
+ /** Ops the server actually landed from our push (empty on an idempotent replay). */
14
35
  applied: PatchReport["applied"];
36
+ /** Server-side rejections/divergences: inbound-gate rejects, rev lies, CAS losses, both-sides
37
+ * divergence (resolve via the §3 ladder — loser minted as a sibling, never dropped). */
15
38
  conflicts: Array<{
16
39
  id: string;
17
40
  reason: string;
18
41
  baseRev?: string;
19
42
  currentRev?: string;
20
43
  }>;
44
+ /** The pull half: entries new/changed centrally since our baseline. */
21
45
  serverEntries: MemoryEntry[];
46
+ /** The pull half's delete leg: centrally deleted, unchanged here since baseline (CAS baseRev). */
22
47
  serverDeletes: Array<{
23
48
  id: string;
24
49
  baseRev: string;
25
50
  }>;
51
+ /** The next baseline to persist AFTER the pull half lands (the client cannot compute it — it
52
+ * does not hold the central set). Pull-half ids are retained at the OLD baseline inside; the
53
+ * client advances the LANDED ones to their landed state before persisting (see ⑤ — otherwise
54
+ * every landed pull echoes back next round and a central delete can be resurrected). */
26
55
  cursor: {
27
56
  peer: string;
28
57
  baseRevs: Record<string, string>;
29
58
  updatedAtMs: number;
30
59
  };
60
+ /** [767]③ pull-half batching (wire contract; server sets it): true ⇔ the server withheld part
61
+ * of the pull half under the requested `pull.limit` — the caller should run another round.
62
+ * The server MUST retain every withheld id at the OLD baseline inside `cursor` (the client
63
+ * refuses prefilled undelivered revs — see ⑤ defense — so violating this only costs the
64
+ * server an ignored advance plus a disclosed warning, never a permanently-missed pull). */
31
65
  pullTruncated?: true;
32
66
  }
67
+ /** One aggregated conflict: `server` = reported by the central half (its gate/CAS/divergence),
68
+ * `local` = produced landing the pull half here (our CAS refusals, inbound-gate rejects, rev
69
+ * lies). Nothing is hidden; the caller resolves via the §3 ladder (loser-as-sibling). */
33
70
  export interface MemorySyncClientConflict {
34
71
  side: "server" | "local";
35
72
  id: string;
@@ -38,29 +75,79 @@ export interface MemorySyncClientConflict {
38
75
  currentRev?: string;
39
76
  }
40
77
  export interface SyncMemoryScopeOptions {
78
+ /** The LOCAL authority plane (TOC: the File backend). */
41
79
  backend: MemoryBackend;
80
+ /** The scope this round syncs (one round = one scope, mirroring the server route). */
42
81
  scope: string;
82
+ /** The injected HTTP seam. */
43
83
  transport: MemorySyncTransport;
84
+ /** The persisted cursor from the last completed round with this peer; absent = first round. */
44
85
  cursor?: MemorySyncCursor;
86
+ /** Peer name for the cursor partition (defaults to the cursor's peer, else "central"). */
45
87
  peer?: string;
88
+ /** Caller-injected clock (engine precedent) — stamps the returned cursor's updatedAtMs. */
46
89
  now?: () => number;
90
+ /** [767]③ push-half batching: cap the number of push-half ENTRIES sent this round. The full
91
+ * push set is put in STABLE order (id ascending — deterministic across rounds/replicas) and the
92
+ * first `maxPushEntries` ride the wire; a cut round reports `pushTruncated: true`. Deletes are
93
+ * never split (id+baseRev pairs are weightless next to bodies). CALLER CONTRACT: on
94
+ * `pushTruncated`/`pullTruncated`, persist the returned cursor and run ANOTHER round until both
95
+ * flags clear — core deliberately never loops internally (the runner loop is the deployment's,
96
+ * server-side semantics per [767]③); bound your loop (e.g. a fixed max-rounds cap ≥
97
+ * ⌈expected entries / limit⌉ + slack) so a misbehaving peer cannot spin it forever. Must be a
98
+ * POSITIVE integer (≥ 1 — C5: a 0 cap would flag pushTruncated forever and livelock the caller
99
+ * loop); absent ⇔ unbatched (pre-[767]③ behavior byte-for-byte). */
47
100
  maxPushEntries?: number;
101
+ /** [767]③ pull-half batching: forwarded verbatim as the wire request's `pull.limit`; a server
102
+ * that withholds part of its pull half answers `pullTruncated`, passed through on the result.
103
+ * Same caller contract as {@link maxPushEntries}: continue rounds (bounded) until it clears.
104
+ * Must be a POSITIVE integer (≥ 1 — C5, same livelock gate); absent ⇔ the request carries NO
105
+ * `pull` key (old-server compatible, pre-[767]③ wire bytes). */
48
106
  maxPullEntries?: number;
107
+ /** design/178 §3 — per-entry byte bound for the PUSH gate, matched against the entry's serialized
108
+ * file form (the same domain the harvest gate measures). Defaults to {@link MAX_MEMORY_BYTES},
109
+ * the engine's own per-file cap, so the wire cannot carry an entry the local gate would have
110
+ * refused: `scanMemoryWrite`'s size rung only runs when it is given a bound, and an entry that
111
+ * reached the backend out of band is exactly the population this gate exists for. */
49
112
  maxEntryBytes?: number;
50
113
  }
51
114
  export interface MemorySyncClientResult {
115
+ /** True ⇔ the round was fully clean: cursor advanced AND zero conflicts on either side. */
52
116
  ok: boolean;
117
+ /** What the push half contained (ids only — the bodies already went over the wire). */
53
118
  pushed: {
54
119
  entries: string[];
55
120
  deletes: string[];
56
121
  };
122
+ /** Ops the server landed from our push (response `applied` verbatim). */
57
123
  serverApplied: PatchReport["applied"];
124
+ /** Ops we landed locally from the pull half. */
58
125
  localApplied: PatchReport["applied"];
126
+ /** Aggregated server-reported + local conflicts (never hidden). */
59
127
  conflicts: MemorySyncClientConflict[];
128
+ /** True ⇔ every pull-half item landed cleanly, so `cursor` is the NEW baseline to persist. */
60
129
  cursorAdvanced: boolean;
130
+ /** The cursor the caller should now persist: advanced on full success, otherwise the INPUT
131
+ * cursor unchanged (undefined on a failed first round) — the retention discipline. */
61
132
  cursor: MemorySyncCursor | undefined;
133
+ /** [767]③: present (true) ⇔ `maxPushEntries` cut this round's push set — run another round off
134
+ * the persisted cursor until it clears (see the {@link SyncMemoryScopeOptions.maxPushEntries}
135
+ * caller contract). Never present on an uncut round (additive: old callers see no new key). */
62
136
  pushTruncated?: true;
137
+ /** [767]③: present (true) ⇔ the server reported its pull half was cut under `pull.limit` —
138
+ * same continue-until-clear caller contract. */
63
139
  pullTruncated?: true;
140
+ /** Honest-disclosure channel for tolerated protocol violations (present only when non-empty).
141
+ * Today's single producer is the ⑤ cursor-prefill defense: a server that advances a
142
+ * NOT-DELIVERED-HERE id's rev inside the response cursor gets that advance REFUSED (old
143
+ * baseline kept / unknown id dropped) and disclosed here — silently swallowing it would turn
144
+ * the next round's pull judgment into a permanent miss (baseline == central rev ⇒ never
145
+ * pulled) or, for an unknown id, a spurious push-half DELETE of an entry never seen here. */
64
146
  warnings?: string[];
65
147
  }
148
+ /**
149
+ * One full CLIENT sync round for one (scope, peer) against the [671]① central sync API — see the
150
+ * module header for the ①-⑤ flow and the cursor retention discipline. Pure orchestration: all I/O
151
+ * rides the injected backend/transport; the caller persists the returned cursor.
152
+ */
66
153
  export declare function syncMemoryScope(opts: SyncMemoryScopeOptions): Promise<MemorySyncClientResult>;
@@ -1,36 +1,96 @@
1
1
  import type { MemoryEntry, ScoredMemoryEntry } from "./types.js";
2
+ /**
3
+ * design/142 §3 — the per-replica per-scope sync cursor: the COMMON BASELINE a reconciliation run
4
+ * judges divergence against (`id → rev` as of the last completed sync round). This is a NEW
5
+ * persistence face — deliberately NOT revs.json (that is the local disk-vs-committed ledger): File
6
+ * plane = a control-plane sidecar, DB plane = a service-owned table (PG+TiDB, [628] dual-dialect).
7
+ * Serializable by construction.
8
+ */
2
9
  export interface MemorySyncCursor {
3
10
  scope: string;
11
+ /** The PEER this cursor tracks (e.g. "central", a repo remote name) — one cursor per peer. */
4
12
  peer: string;
13
+ /** id → rev at the last completed sync round with this peer. */
5
14
  baseRevs: Record<string, string>;
15
+ /** Caller-injected clock (never Date.now inside the engine — clock-injection precedent). */
6
16
  updatedAtMs: number;
7
17
  }
8
18
  export interface MemorySyncConflict {
9
19
  id: string;
20
+ /** Present when the side still has the entry (absent = deleted on that side). */
10
21
  local?: MemoryEntry;
11
22
  remote?: MemoryEntry;
12
23
  baseRev?: string;
13
24
  }
14
25
  export interface MemorySyncPlan {
26
+ /** Entries the LOCAL side should send to the peer (new here or changed-here-only). 独立轨 F8 —
27
+ * CAS discipline for the peer write: a push item exists ONLY when the peer is still at the
28
+ * baseline, so the peer-side conditional write uses `baseRevs[id]` as its baseRev (absent from
29
+ * the baseline ⇒ the peer has no such entry ⇒ plain add). Never write the peer unconditionally. */
15
30
  push: MemoryEntry[];
31
+ /** Entries the LOCAL side should adopt from the peer (new there or changed-there-only). Same CAS
32
+ * discipline as {@link push}, mirrored: local conditional write with `baseRevs[id]`. */
16
33
  pull: MemoryEntry[];
34
+ /** codex 复审 B4 — DELETE propagation (without these the removal never crosses and every round
35
+ * re-plans the same state = livelock): the peer removed an entry the local side left UNCHANGED
36
+ * since baseline ⇒ delete locally (CAS on baseRev — a local edit racing in makes the delete a
37
+ * conflict on the next round instead of silent loss). */
17
38
  deleteLocal: Array<{
18
39
  id: string;
19
40
  baseRev: string;
20
41
  }>;
42
+ /** Symmetric: locally removed, peer unchanged since baseline ⇒ delete on the peer. */
21
43
  deleteRemote: Array<{
22
44
  id: string;
23
45
  baseRev: string;
24
46
  }>;
47
+ /** Both sides diverged from the baseline (or delete-vs-edit races): the caller resolves via the
48
+ * §3 ladder — winner by the caller's policy, LOSER MINTED AS A SIBLING entry (never dropped),
49
+ * the pair recorded so a three-way exchange cannot rebuild the same conflict forever. */
25
50
  conflicts: MemorySyncConflict[];
51
+ /** Ids deleted on BOTH sides since the baseline (pure cursor cleanup, no data movement). */
26
52
  cleared: string[];
27
53
  }
54
+ /**
55
+ * Pure three-way set reconciliation over one scope. `baseRevs` = the persisted common baseline
56
+ * (empty object = first sync round: everything present is "new" on its side; identical revs on
57
+ * both sides collapse to no-op).
58
+ *
59
+ * Judgment per id (rev lineage, mtime never consulted):
60
+ * - both sides at baseline rev → no-op; identical revs (any lineage) → no-op + baseline advance;
61
+ * - changed on exactly ONE side → push/pull;
62
+ * - changed on BOTH sides, or delete-on-one × edit-on-the-other → conflict (caller's ladder);
63
+ * - deleted on one side × UNCHANGED on the other → the delete propagates (deleteLocal/deleteRemote,
64
+ * CAS on baseRev — codex B4: without this leg removals never cross and the plan livelocks);
65
+ * - present only on one side with NO baseline → new entry → propagate;
66
+ * - absent on both but present in baseline → cleared (cursor cleanup).
67
+ */
28
68
  export declare function reconcileMemoryEntries(baseRevs: Readonly<Record<string, string>>, local: readonly MemoryEntry[], remote: readonly MemoryEntry[]): MemorySyncPlan;
69
+ /** The baseline to persist AFTER a sync round completes: every id both sides now agree on. The
70
+ * caller passes the POST-round entry sets (after applying push/pull and resolving conflicts). */
29
71
  export declare function nextSyncBaseline(local: readonly MemoryEntry[], remote: readonly MemoryEntry[]): Record<string, string>;
72
+ /**
73
+ * A third-party semantic recall side-channel (Mem0/Zep/Cognee/… adapters — research 2026-07-12:
74
+ * all five surveyed engines fit THIS seat; none fits the authority seat). STRICTLY READ-ONLY by
75
+ * construction: a RecallSource feeds candidate hits into injection-time recall; it never sees the
76
+ * write path, never participates in harvest, and the system runs identically without it.
77
+ *
78
+ * Score contract: DISTANCE in [0, 2] (0 = identical, 2 = orthogonal — the vector-rung convention);
79
+ * adapters normalize their similarity/relevance scores into this scale. Returned entries may be
80
+ * the third party's RE-STATEMENTS (extractive engines rewrite) — that is acceptable HERE precisely
81
+ * because the seat is advisory: the authoritative body is re-read from the real backend by id/slug
82
+ * when a hit is followed. Mount point: a deployment composes its RecallSource(s) inside its recall
83
+ * select hook (the design/65 selective-recall trust seat) or pre-queries before prepare; core adds
84
+ * no RunnerDeps seat until a real integration signals the need (YAGNI, [622]③ two-lane ruling).
85
+ */
30
86
  export interface RecallSource {
87
+ /** Stable adapter name (diagnostics/attribution: hits are labeled, never silently mixed). */
31
88
  name: string;
32
89
  search(query: string, scopes: readonly string[], opts?: {
33
90
  limit?: number;
34
91
  }): Promise<ScoredMemoryEntry[]>;
35
92
  }
93
+ /** Merge recall hits from multiple sources with the authority backend's own results: id-deduped
94
+ * (FIRST occurrence wins — callers order sources by trust, authority first), ascending by score
95
+ * (distance), capped at `limit`. Pure — no I/O, no source calls. */
36
96
  export declare function mergeRecallHits(hitLists: ReadonlyArray<readonly ScoredMemoryEntry[]>, limit: number): ScoredMemoryEntry[];
@@ -1,14 +1,49 @@
1
+ /**
2
+ * design/178 v1 — the two engine-memory retrieval tools (`memory_search` / `memory_get`).
3
+ *
4
+ * These are the first runner-wired consumers of the `MemoryBackend.search()`/`getByIds()` contract:
5
+ * a deterministic keyword lookup over the session's mounted scopes plus a paged full-content read.
6
+ * Zero contract changes — the tools sit entirely ON TOP of the backend seam.
7
+ *
8
+ * READ-ONLY BY STRUCTURE. Neither tool can write; the write path stays the file channel + harvest
9
+ * gate. Entry content returned to the model is DATA, not instructions: every body fragment rides an
10
+ * untrusted fence (`delimitUntrusted`) and every header field a model could have authored
11
+ * (name/description/slug/scope) is neutralized inline. Results are byte-bounded.
12
+ *
13
+ * THE PAIR IS ATOMIC. Each tool names the other in its description, so a half-mount would teach a
14
+ * tool that is not there — the mount site (runner/prepare-task.ts) mounts both or neither.
15
+ *
16
+ * RESULT ORDER IS THE BACKEND CONTRACT ORDER (v1 pinned): ascending cosine-distance score with the
17
+ * deterministic id tie-break, exactly what `MemoryBackend.search()` promises. Multi-plane sessions
18
+ * merge by the same comparator, so a single-plane session's order is byte-equal to the backend's.
19
+ * No other signal participates — in particular the retrieved account is WRITTEN here and never read.
20
+ *
21
+ * REFUSALS ARE VALUES (shared-memory tools precedent): every negative outcome is a structured result
22
+ * with a machine reason; exceptions are reserved for defects and for cancellation, which is re-thrown
23
+ * so the engine's abort path stays the abort path.
24
+ */
1
25
  import type { ToolSpec } from "../types.js";
2
26
  import type { MemoryBackend } from "./types.js";
3
27
  export declare const MEMORY_SEARCH_TOOL_NAME = "memory_search";
4
28
  export declare const MEMORY_GET_TOOL_NAME = "memory_get";
29
+ /** The atomic pair, in mount order (same shape as SHARED_MEMORY_TOOL_NAMES). */
5
30
  export declare const MEMORY_ENGINE_TOOL_NAMES: readonly ["memory_search", "memory_get"];
31
+ /** Default / maximum hit counts for one search call. */
6
32
  export declare const MEMORY_SEARCH_DEFAULT_LIMIT = 8;
7
33
  export declare const MEMORY_SEARCH_MAX_LIMIT = 20;
34
+ /** Per-hit body-fragment bound (code points, enforced by the fence itself). */
8
35
  export declare const MEMORY_SEARCH_SNIPPET_CAP = 600;
36
+ /** Default / maximum lines of one memory_get page. */
9
37
  export declare const MEMORY_GET_PAGE_LINES = 200;
10
38
  export declare const MEMORY_GET_MAX_PAGE_LINES = 1000;
39
+ /** Byte bound of one memory_get page body (lines past it defer to the next page). */
11
40
  export declare const MEMORY_GET_PAGE_CAP_BYTES: number;
41
+ /**
42
+ * One retrieval plane: a backend plus the scopes THIS SESSION mounted on it (dual-root sessions have
43
+ * two, single-root sessions one). `scopes` is the containment boundary — `getByIds` is id-keyed
44
+ * across every scope the backend knows, so results are filtered back to the mounted set here.
45
+ * `recordRetrieved` feeds the plane's control-plane retrieved account (collect-only, never throws).
46
+ */
12
47
  export interface MemoryEnginePlane {
13
48
  backend: MemoryBackend;
14
49
  scopes: readonly string[];
@@ -16,6 +51,7 @@ export interface MemoryEnginePlane {
16
51
  }
17
52
  export interface MemoryEngineToolsOptions {
18
53
  planes: ReadonlyArray<MemoryEnginePlane>;
54
+ /** Clock (tests); default Date.now. Drives the natural-language age rendering only. */
19
55
  now?: () => number;
20
56
  }
21
57
  export interface MemorySearchHit {
@@ -24,6 +60,7 @@ export interface MemorySearchHit {
24
60
  slug: string;
25
61
  name?: string;
26
62
  description?: string;
63
+ /** Cosine-distance ∈ [0,2], 0 best — the backend contract's score, untransformed (v1). */
27
64
  score: number;
28
65
  mtimeMs: number;
29
66
  sizeBytes: number;
@@ -39,6 +76,7 @@ export interface MemoryGetDetails {
39
76
  id?: string;
40
77
  scope?: string;
41
78
  slug?: string;
79
+ /** Candidates of an ambiguous bare-slug lookup — scope-qualified, never silently picked from. */
42
80
  candidates?: Array<{
43
81
  scope: string;
44
82
  slug: string;
@@ -48,6 +86,9 @@ export interface MemoryGetDetails {
48
86
  lines?: number;
49
87
  totalLines?: number;
50
88
  }
89
+ /** Cut `text` to at most `maxBytes` UTF-8 bytes on a CODE POINT boundary (a byte-wise slice would
90
+ * strand half a character), reporting how many bytes were dropped. Unchanged text reports 0.
91
+ * Exported for the truncation-invariant registry — a bound-taking function has to be provable. */
51
92
  export declare function cutToBytes(text: string, maxBytes: number): {
52
93
  text: string;
53
94
  omittedBytes: number;