@sema-agent/core 5.19.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 (329) hide show
  1. package/CHANGELOG.md +102 -4
  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/roster-store.js +3 -0
  13. package/dist/agents/send-message-tool.d.ts +92 -0
  14. package/dist/agents/session-util.d.ts +5 -0
  15. package/dist/agents/subagent-steps.d.ts +66 -0
  16. package/dist/agents/subagent.d.ts +600 -0
  17. package/dist/agents/suspend-guard.d.ts +29 -0
  18. package/dist/agents/teacher.d.ts +75 -0
  19. package/dist/agents/team.d.ts +120 -1
  20. package/dist/agents/tool-filter.d.ts +34 -0
  21. package/dist/agents/verify.d.ts +198 -0
  22. package/dist/bench/metrics.d.ts +455 -0
  23. package/dist/brain/anthropic.d.ts +30 -0
  24. package/dist/brain/circuit-breaker.d.ts +33 -0
  25. package/dist/brain/circuit-breaker.js +14 -3
  26. package/dist/brain/context-overflow.d.ts +60 -3
  27. package/dist/brain/degrading.d.ts +67 -0
  28. package/dist/brain/errors.d.ts +42 -0
  29. package/dist/brain/failover.d.ts +15 -0
  30. package/dist/brain/media-degrade.d.ts +39 -0
  31. package/dist/brain/model-presets.d.ts +31 -0
  32. package/dist/brain/open-responses.d.ts +19 -0
  33. package/dist/brain/openai.d.ts +46 -0
  34. package/dist/brain/reasoning.d.ts +106 -1
  35. package/dist/brain/repetition.d.ts +83 -0
  36. package/dist/brain/request-params.d.ts +56 -0
  37. package/dist/brain/retry.d.ts +46 -0
  38. package/dist/brain/routing.d.ts +12 -0
  39. package/dist/brain/status-sink.d.ts +30 -1
  40. package/dist/brain/stream-engine.d.ts +147 -0
  41. package/dist/brain/stream-shared.d.ts +34 -0
  42. package/dist/brain/terminal-cause.d.ts +31 -0
  43. package/dist/brain/timeout.d.ts +108 -0
  44. package/dist/brain/timeout.js +11 -0
  45. package/dist/brain/tool-call-id.d.ts +20 -0
  46. package/dist/brain/tool-call-repair.d.ts +13 -0
  47. package/dist/config/catalog.d.ts +47 -0
  48. package/dist/config/defaults.d.ts +33 -0
  49. package/dist/core/a2a-task-state.d.ts +53 -0
  50. package/dist/core/a2a.d.ts +51 -0
  51. package/dist/core/arg-summary.d.ts +62 -0
  52. package/dist/core/ask-question.d.ts +272 -2
  53. package/dist/core/auto-compaction.d.ts +467 -0
  54. package/dist/core/auto-compaction.js +20 -6
  55. package/dist/core/auto-mode-prompt-assets.d.ts +8 -0
  56. package/dist/core/auto-mode-prompt.d.ts +27 -0
  57. package/dist/core/auto-mode.d.ts +54 -3
  58. package/dist/core/auto-promote.d.ts +100 -0
  59. package/dist/core/background-agent-store.d.ts +293 -0
  60. package/dist/core/background-agent-store.js +5 -0
  61. package/dist/core/background-shell.d.ts +110 -0
  62. package/dist/core/cache-break-detector.d.ts +34 -0
  63. package/dist/core/canonical-json.d.ts +57 -0
  64. package/dist/core/checkpoint-store.d.ts +1574 -16
  65. package/dist/core/compliance.d.ts +30 -0
  66. package/dist/core/consolidate-scope.d.ts +75 -0
  67. package/dist/core/context-edit.d.ts +99 -0
  68. package/dist/core/context-guard.d.ts +46 -0
  69. package/dist/core/exec-gate.d.ts +44 -0
  70. package/dist/core/exec-output-tail.d.ts +61 -0
  71. package/dist/core/file-snapshot-store.d.ts +104 -0
  72. package/dist/core/fs-write-gate-policy.d.ts +36 -0
  73. package/dist/core/git-worktree-env.d.ts +31 -0
  74. package/dist/core/governance-codes.d.ts +19 -0
  75. package/dist/core/hooks.d.ts +609 -1
  76. package/dist/core/human-input-projection.d.ts +37 -0
  77. package/dist/core/human-input-projection.js +13 -0
  78. package/dist/core/image-downsample.d.ts +74 -0
  79. package/dist/core/locked-config.d.ts +37 -0
  80. package/dist/core/lsp-diagnostics.d.ts +77 -0
  81. package/dist/core/lsp-protocol.d.ts +29 -0
  82. package/dist/core/lsp-session.d.ts +60 -1
  83. package/dist/core/lsp.d.ts +150 -1
  84. package/dist/core/mailbox-store.d.ts +57 -0
  85. package/dist/core/mailbox-store.js +2 -0
  86. package/dist/core/mcp.d.ts +385 -0
  87. package/dist/core/mcp.js +58 -11
  88. package/dist/core/media-byte-cap.d.ts +21 -0
  89. package/dist/core/memory-admission.d.ts +71 -0
  90. package/dist/core/memory-engine/content-origin.d.ts +64 -0
  91. package/dist/core/memory-engine/data-plane.d.ts +43 -0
  92. package/dist/core/memory-engine/dual-root.d.ts +24 -0
  93. package/dist/core/memory-engine/engine.d.ts +230 -0
  94. package/dist/core/memory-engine/engine.js +103 -35
  95. package/dist/core/memory-engine/file-backend.d.ts +155 -0
  96. package/dist/core/memory-engine/frontmatter.d.ts +16 -0
  97. package/dist/core/memory-engine/layout.d.ts +217 -0
  98. package/dist/core/memory-engine/memory-backend-contract.d.ts +12 -0
  99. package/dist/core/memory-engine/migrate.d.ts +9 -0
  100. package/dist/core/memory-engine/scan.d.ts +12 -0
  101. package/dist/core/memory-engine/scope-contract.d.ts +61 -1
  102. package/dist/core/memory-engine/sync-client.d.ts +87 -0
  103. package/dist/core/memory-engine/sync.d.ts +60 -0
  104. package/dist/core/memory-engine/tools.d.ts +41 -0
  105. package/dist/core/memory-engine/types.d.ts +188 -0
  106. package/dist/core/memory-recall.d.ts +141 -0
  107. package/dist/core/memory-vector.d.ts +20 -0
  108. package/dist/core/memory.d.ts +458 -0
  109. package/dist/core/message-utils.d.ts +6 -0
  110. package/dist/core/oracle-isolation.d.ts +69 -0
  111. package/dist/core/permission-rule-consent.d.ts +138 -0
  112. package/dist/core/permission-rule-model.d.ts +122 -0
  113. package/dist/core/permission-rule-store.d.ts +119 -3
  114. package/dist/core/permission-rules.d.ts +87 -1
  115. package/dist/core/present-plan-tool.d.ts +20 -0
  116. package/dist/core/pricing.d.ts +26 -0
  117. package/dist/core/property-harness.d.ts +86 -0
  118. package/dist/core/protocol-naming.d.ts +38 -0
  119. package/dist/core/protocol-table.d.ts +61 -0
  120. package/dist/core/push-queue.d.ts +1 -0
  121. package/dist/core/remote-env.d.ts +383 -1
  122. package/dist/core/retention-policy.d.ts +40 -0
  123. package/dist/core/retention-policy.js +21 -0
  124. package/dist/core/retention.d.ts +51 -0
  125. package/dist/core/roles.d.ts +59 -0
  126. package/dist/core/runner/active-skill-scope.d.ts +34 -0
  127. package/dist/core/runner/assemble-result.d.ts +134 -0
  128. package/dist/core/runner/compaction-call-options.d.ts +97 -1
  129. package/dist/core/runner/grounding-signal.d.ts +10 -0
  130. package/dist/core/runner/image.d.ts +17 -0
  131. package/dist/core/runner/image.js +29 -15
  132. package/dist/core/runner/memory-consolidation.d.ts +60 -0
  133. package/dist/core/runner/prepare-memory.d.ts +59 -0
  134. package/dist/core/runner/prepare-task.d.ts +1011 -2
  135. package/dist/core/runner/prepare-task.js +51 -14
  136. package/dist/core/runner/prompt-suggestions.d.ts +7 -0
  137. package/dist/core/runner/runtask.d.ts +304 -3
  138. package/dist/core/runner/runtask.js +17 -2
  139. package/dist/core/runner/session-file-state-replay.d.ts +49 -0
  140. package/dist/core/runner/session-rule-policy.d.ts +58 -0
  141. package/dist/core/runner/strict-output-schema.d.ts +18 -3
  142. package/dist/core/runner/synthetic-tools.d.ts +113 -0
  143. package/dist/core/runner/teardown-bounded.d.ts +34 -0
  144. package/dist/core/runner/tool-disclosure.d.ts +227 -0
  145. package/dist/core/runner/tool-output-projection.d.ts +6 -0
  146. package/dist/core/runner/turn-attachments.d.ts +634 -0
  147. package/dist/core/runner/usage-accounting.d.ts +32 -0
  148. package/dist/core/runtime.d.ts +9 -0
  149. package/dist/core/safe-notify.d.ts +64 -0
  150. package/dist/core/safety-axis-vocab.d.ts +23 -0
  151. package/dist/core/safety-merge-corpus.d.ts +37 -0
  152. package/dist/core/scheduler.d.ts +121 -0
  153. package/dist/core/secret-env.d.ts +32 -0
  154. package/dist/core/select-model.d.ts +15 -0
  155. package/dist/core/sensitive-path-policy.d.ts +42 -0
  156. package/dist/core/session-policy-store.d.ts +94 -0
  157. package/dist/core/session-reconcile.d.ts +80 -0
  158. package/dist/core/session-store.d.ts +85 -0
  159. package/dist/core/session.d.ts +153 -0
  160. package/dist/core/shared-memory/contract.d.ts +22 -0
  161. package/dist/core/shared-memory/normalize.d.ts +123 -2
  162. package/dist/core/shared-memory/tools.d.ts +14 -0
  163. package/dist/core/shared-memory/types.d.ts +105 -0
  164. package/dist/core/shutdown-debug.d.ts +6 -0
  165. package/dist/core/side-query.d.ts +38 -0
  166. package/dist/core/side-query.js +6 -1
  167. package/dist/core/skill-tool-specifier.d.ts +72 -0
  168. package/dist/core/skills-directory.d.ts +100 -1
  169. package/dist/core/spec-contract.d.ts +89 -0
  170. package/dist/core/store-contracts/background-agent-store-contract.d.ts +31 -0
  171. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +26 -0
  172. package/dist/core/store-contracts/contract-harness.d.ts +20 -0
  173. package/dist/core/store-contracts/contract-kit-version.d.ts +27 -0
  174. package/dist/core/store-contracts/file-snapshot-store-contract.d.ts +8 -0
  175. package/dist/core/store-contracts/mailbox-store-contract.d.ts +42 -0
  176. package/dist/core/store-contracts/tool-result-store-contract.d.ts +13 -0
  177. package/dist/core/strategy-store.d.ts +37 -0
  178. package/dist/core/stub-env.d.ts +7 -0
  179. package/dist/core/surrogate-safe-slice.d.ts +35 -0
  180. package/dist/core/task-notification.d.ts +202 -0
  181. package/dist/core/task-outcome.d.ts +53 -0
  182. package/dist/core/task-registry-agent.d.ts +337 -1
  183. package/dist/core/task-registry-agent.js +2 -0
  184. package/dist/core/task-registry-monitor.d.ts +12 -0
  185. package/dist/core/task-registry-shared.d.ts +540 -0
  186. package/dist/core/task-registry.d.ts +343 -0
  187. package/dist/core/task-registry.js +13 -2
  188. package/dist/core/task-tool-shape.d.ts +44 -0
  189. package/dist/core/tighten-task-spec.d.ts +21 -0
  190. package/dist/core/tool-detach.d.ts +21 -0
  191. package/dist/core/tool-errors.d.ts +131 -0
  192. package/dist/core/tool-errors.js +4 -0
  193. package/dist/core/tool-name-aliases.d.ts +27 -0
  194. package/dist/core/tool-policy.d.ts +555 -0
  195. package/dist/core/tool-policy.js +3 -0
  196. package/dist/core/tool-result-budget.d.ts +32 -0
  197. package/dist/core/tool-result-store.d.ts +174 -1
  198. package/dist/core/tools.d.ts +45 -0
  199. package/dist/core/trace.d.ts +323 -0
  200. package/dist/core/types.d.ts +3859 -2
  201. package/dist/core/untrusted-egress.d.ts +8 -0
  202. package/dist/core/untrusted-text.d.ts +156 -0
  203. package/dist/core/usage-window-store.d.ts +95 -0
  204. package/dist/core/version.d.ts +1 -0
  205. package/dist/core/warm-resume.d.ts +17 -0
  206. package/dist/core/wiring-manifest.d.ts +169 -0
  207. package/dist/core/with-retry.d.ts +24 -0
  208. package/dist/core/workflow-journal-store.d.ts +160 -0
  209. package/dist/core/workflow-run-store-contract.d.ts +25 -0
  210. package/dist/core/workflow-run-store.d.ts +119 -0
  211. package/dist/core/workflow-run-store.js +2 -0
  212. package/dist/engine/compaction/compaction.d.ts +256 -1
  213. package/dist/engine/compaction/utils.d.ts +94 -0
  214. package/dist/engine/execution-env/kill-tree.d.ts +29 -0
  215. package/dist/engine/execution-env/node-execution-env.d.ts +94 -0
  216. package/dist/engine/harness/agent-harness.d.ts +116 -0
  217. package/dist/engine/harness/agent-harness.js +3 -14
  218. package/dist/engine/harness/messages.d.ts +15 -0
  219. package/dist/engine/harness/types.d.ts +464 -2
  220. package/dist/engine/llm/diagnostics.d.ts +4 -0
  221. package/dist/engine/llm/event-stream.d.ts +3 -0
  222. package/dist/engine/llm/index.d.ts +7 -0
  223. package/dist/engine/llm/types.d.ts +500 -3
  224. package/dist/engine/llm/validation.d.ts +3 -0
  225. package/dist/engine/loop/agent-loop.d.ts +87 -2
  226. package/dist/engine/loop/runtime-deps.d.ts +7 -0
  227. package/dist/engine/loop/types.d.ts +424 -0
  228. package/dist/engine/lsp/frame-decoder.d.ts +13 -0
  229. package/dist/engine/lsp/node-lsp-manager.d.ts +107 -0
  230. package/dist/engine/lsp/stdio-lsp-transport.d.ts +7 -0
  231. package/dist/engine/session/import-validate.d.ts +27 -0
  232. package/dist/engine/session/log-digest.d.ts +93 -0
  233. package/dist/engine/session/memory-repo.d.ts +6 -0
  234. package/dist/engine/session/memory-storage.d.ts +2 -0
  235. package/dist/engine/session/session.d.ts +75 -0
  236. package/dist/engine/session/storage-base.d.ts +8 -0
  237. package/dist/fixtures/index.d.ts +36 -0
  238. package/dist/index.d.ts +17 -2
  239. package/dist/index.js +1 -2
  240. package/dist/internal/harness-types.d.ts +6 -0
  241. package/dist/internal/harness.d.ts +11 -0
  242. package/dist/internal/llm.d.ts +6 -0
  243. package/dist/orchestration/builtin-workflows.d.ts +53 -0
  244. package/dist/orchestration/dev-vm-script-runner.d.ts +19 -0
  245. package/dist/orchestration/goal.d.ts +57 -0
  246. package/dist/orchestration/goal.js +3 -0
  247. package/dist/orchestration/run-spec.d.ts +42 -0
  248. package/dist/orchestration/run-spec.js +4 -0
  249. package/dist/orchestration/run-workflow-tool.d.ts +169 -0
  250. package/dist/orchestration/workflow-governance.d.ts +61 -0
  251. package/dist/orchestration/workflow-meta.d.ts +28 -0
  252. package/dist/orchestration/workflow-observe.d.ts +60 -0
  253. package/dist/orchestration/workflow-primitives.d.ts +23 -1
  254. package/dist/orchestration/workflow-sandbox-conformance.d.ts +38 -0
  255. package/dist/orchestration/workflow-script-runner.d.ts +88 -0
  256. package/dist/orchestration/workflow-script-store.d.ts +98 -0
  257. package/dist/orchestration/workflow-size-guideline.d.ts +67 -0
  258. package/dist/orchestration/workflow-types.d.ts +169 -2
  259. package/dist/orchestration/workflow.d.ts +358 -0
  260. package/dist/orchestration/workflow.js +13 -2
  261. package/dist/prompt-assembly/artifact-store.d.ts +33 -0
  262. package/dist/prompt-assembly/artifact.d.ts +25 -0
  263. package/dist/prompt-assembly/assemble.d.ts +20 -0
  264. package/dist/prompt-assembly/composer.d.ts +29 -0
  265. package/dist/prompt-assembly/epoch.d.ts +55 -1
  266. package/dist/prompt-assembly/event-registry.d.ts +35 -0
  267. package/dist/prompt-assembly/explain.d.ts +12 -0
  268. package/dist/prompt-assembly/tool-catalog.d.ts +38 -0
  269. package/dist/prompt-assembly/turn-snapshot.d.ts +40 -0
  270. package/dist/prompt-assembly/types.d.ts +115 -0
  271. package/dist/prompts/coordinator.d.ts +27 -0
  272. package/dist/prompts/default.d.ts +539 -0
  273. package/dist/prompts/simple-sections.d.ts +45 -0
  274. package/dist/prompts/supervisor.d.ts +66 -0
  275. package/dist/scenarios/env.d.ts +28 -0
  276. package/dist/scenarios/full-body.d.ts +50 -0
  277. package/dist/scenarios/scenario-registry.d.ts +60 -0
  278. package/dist/scenarios/teacher-quickstart.d.ts +27 -0
  279. package/dist/server/http.d.ts +17 -0
  280. package/dist/stores/cc/lockfile.d.ts +6 -0
  281. package/dist/stores/cc/mailbox-store.d.ts +8 -0
  282. package/dist/stores/cc/roster-adapter.d.ts +4 -0
  283. package/dist/stores/cc/sidecar-transcript.d.ts +66 -0
  284. package/dist/stores/file/background-agent-store.d.ts +24 -0
  285. package/dist/stores/file/background-agent-store.js +2 -1
  286. package/dist/stores/file/checkpoint-store.d.ts +38 -0
  287. package/dist/stores/file/file-snapshot-store.d.ts +25 -0
  288. package/dist/stores/file/fs-atomic.d.ts +155 -0
  289. package/dist/stores/file/index.d.ts +89 -0
  290. package/dist/stores/file/mailbox-store.d.ts +36 -0
  291. package/dist/stores/file/mailbox-store.js +2 -0
  292. package/dist/stores/file/memory-store.d.ts +82 -0
  293. package/dist/stores/file/permission-rule-store.d.ts +79 -0
  294. package/dist/stores/file/session-policy-store.d.ts +28 -0
  295. package/dist/stores/file/session-store.d.ts +40 -0
  296. package/dist/stores/file/shared-ledger.d.ts +83 -0
  297. package/dist/stores/file/tool-result-store.d.ts +11 -0
  298. package/dist/stores/file/usage-window-store.d.ts +18 -0
  299. package/dist/stores/file/workflow-journal-store.d.ts +100 -0
  300. package/dist/stores/file/workflow-run-store.d.ts +11 -0
  301. package/dist/stores/file/workflow-run-store.js +2 -0
  302. package/dist/tools/fs/bash-readonly-classifier.d.ts +282 -0
  303. package/dist/tools/fs/encoding.d.ts +60 -0
  304. package/dist/tools/fs/fs-bash.d.ts +133 -0
  305. package/dist/tools/fs/fs-pdf.d.ts +28 -0
  306. package/dist/tools/fs/fs-search-tools.d.ts +5 -0
  307. package/dist/tools/fs/fs-shared.d.ts +360 -0
  308. package/dist/tools/fs/fs-write.d.ts +16 -0
  309. package/dist/tools/fs/gh-rate-limit.d.ts +22 -0
  310. package/dist/tools/fs/index.d.ts +79 -0
  311. package/dist/tools/fs/notebook.d.ts +56 -0
  312. package/dist/tools/fs/pdf.d.ts +70 -0
  313. package/dist/tools/fs/pdf.js +8 -2
  314. package/dist/tools/fs/repo-map.d.ts +10 -0
  315. package/dist/tools/fs/safety.d.ts +376 -0
  316. package/dist/tools/fs/search.d.ts +131 -0
  317. package/dist/tools/loop-tick.d.ts +24 -0
  318. package/dist/tools/monitor.d.ts +55 -0
  319. package/dist/tools/scheduler-tools.d.ts +51 -0
  320. package/dist/tools/sql-adapters.d.ts +18 -0
  321. package/dist/tools/sql.d.ts +25 -0
  322. package/dist/tools/task-list.d.ts +77 -0
  323. package/dist/tools/todo.d.ts +8 -0
  324. package/dist/tools/web.d.ts +184 -0
  325. package/dist/tools/web.js +32 -5
  326. package/dist/tools/worktree.d.ts +81 -0
  327. package/package.json +2 -2
  328. package/dist/tools/gitea-issue.d.ts +0 -13
  329. package/dist/tools/gitea-issue.js +0 -75
@@ -1,9 +1,34 @@
1
1
  import type { ImageContent } from "../../internal/llm.js";
2
+ /**
3
+ * RB-227 ([1937] N1) — the Read tool's Jupyter-notebook projection: `.ipynb` is rendered as cells
4
+ * with outputs (CC 2.1.220 parity: `Ctd`/`wtd`/`Zx_`/`Qx_`/`eI_`/`tI_`/`Atd`, pretty220.js
5
+ * :371265-:371426), never as raw JSON text. The raw-JSON rendering let a notebook's base64 outputs
6
+ * overflow the Read token cap, auto-paginate into an `isPartialView` entry, and thereby lock
7
+ * NotebookEdit out via the requireRead gate (RB-200 F2) — with the marker's own offset/limit hint
8
+ * pointing at a range that itself exceeds the cap (the base64 lives on one mega-line).
9
+ *
10
+ * Pure module (no I/O, no env): index.ts owns reading/decoding/state; this owns parse + render.
11
+ */
12
+ /** CC 220 `o3r` (:60226): extname === ".ipynb". */
2
13
  export declare function isNotebookPath(p: string): boolean;
14
+ /** CC 220 `Jx_ = 1e4` (:371426): PER-CELL cap on the summed output payload (text chars + image
15
+ * base64 chars). A cell over it has its ENTIRE outputs array replaced by one pointer line —
16
+ * per cell, never a running global budget (CC's `Xx_` accumulator restarts for every cell). */
3
17
  export declare const NOTEBOOK_CELL_OUTPUT_POINTER_CHARS = 10000;
18
+ /** Per-output text clip. CC clips each output at its bash-output limit first (`CCs` → `vtd`) and
19
+ * then the per-cell 10K pointer check dominates — in the all-cells projection a cell whose output
20
+ * text exceeds 10K is always pointered, so this clip is unreachable insurance kept at the same
21
+ * 10K yardstick (simplification of CC's two-stage clip, recorded deliberately). */
4
22
  export declare const NOTEBOOK_OUTPUT_TEXT_CLIP = 10000;
23
+ /** RB-227 E4 — cumulative image budget across the WHOLE notebook: the 10K per-cell pointer bounds
24
+ * one cell, but N cells × ~9KB images is unbounded. CC gets an implicit bound because image data
25
+ * counts toward its 256KB projected-JSON cap (`ePi = 262144`, :61029) and then HARD-ERRORS; sema
26
+ * reuses that same figure but as a DEGRADATION budget — images past it are dropped with an honest
27
+ * marker instead of making the notebook unreadable/uneditable (which is the RB-227 failure mode
28
+ * this whole lane exists to remove). Divergence-logged. */
5
29
  export declare const NOTEBOOK_IMAGE_BASE64_BUDGET = 262144;
6
30
  export interface NotebookOutputImage {
31
+ /** Whitespace-stripped base64 (magic-validated — never an unverified blob, see `imageFromData`). */
7
32
  image_data: string;
8
33
  media_type: "image/png" | "image/jpeg";
9
34
  }
@@ -13,10 +38,19 @@ export interface NotebookOutput {
13
38
  image?: NotebookOutputImage;
14
39
  }
15
40
  export interface NotebookCell {
41
+ /** `cell.id`, or the synthesized `cell-${index}` for nbformat<4.5 — index = the UNFILTERED array
42
+ * position, because NotebookEdit's `/^cell-(\d+)$/` positional fallback resolves exactly that.
43
+ * Deliberate delta (review r2 finding 2): sema synthesizes for any NON-STRING id (`typeof id ===
44
+ * "string"` guard in `parseNotebookCells`) where CC's `wtd` uses `e.id ?? cell-${t}` (:371314)
45
+ * and would render e.g. a numeric id literally — but NotebookEdit's id match is string-only, so
46
+ * CC's literal form would be un-addressable while sema's positional alias resolves; nbformat
47
+ * ids are spec-string, so this branch only fires on out-of-spec input. */
16
48
  cell_id: string;
17
49
  cellType: string;
18
50
  source: string;
51
+ /** Code cells only (CC `wtd`). */
19
52
  language?: string;
53
+ /** Code cells only; CC drops falsy (`e.execution_count || void 0`). */
20
54
  execution_count?: number;
21
55
  outputs?: NotebookOutput[];
22
56
  }
@@ -27,14 +61,36 @@ export type ParsedNotebook = {
27
61
  ok: false;
28
62
  reason: "json" | "shape";
29
63
  };
64
+ /**
65
+ * CC `Ctd` + `wtd` (:371373 / :371313): parse the notebook JSON into the projected cell list.
66
+ * Failure is a typed reason, not a throw — the Read lane falls back to raw text on it (sema
67
+ * divergence from CC's hard error: a corrupt notebook stays readable so the model can see what is
68
+ * wrong; NotebookEdit still refuses it with its own JSON-validation errors, so nothing is loosened).
69
+ * `notebookPath` is substituted into the per-cell pointer line (CC ships a literal
70
+ * `<notebook_path>` placeholder there; the real path makes the recipe directly runnable).
71
+ */
30
72
  export declare function parseNotebookCells(text: string, notebookPath: string): ParsedNotebook;
31
73
  export interface NotebookRender {
32
74
  blocks: Array<{
33
75
  type: "text";
34
76
  text: string;
35
77
  } | ImageContent>;
78
+ /** Total chars across the (merged) text blocks — the caller's token-cap yardstick. */
36
79
  textChars: number;
80
+ /** Total base64 chars actually emitted as image blocks (post-budget). */
37
81
  imageChars: number;
38
82
  }
83
+ /**
84
+ * CC `eI_`/`tI_`/`Atd` (:371339/:371349/:371399): render projected cells to content blocks.
85
+ * Tag shape is CC-verbatim, including the deliberately malformed closing tag `</cell id="X">`;
86
+ * `<cell_type>` only when not code, `<language>` only for code cells whose language !== "python".
87
+ * Output text rides with a leading "\n" (tI_) and adjacent text blocks merge with "\n" (Atd), so an
88
+ * all-text notebook collapses to a single text block. Images ride as real image blocks in sema's
89
+ * `{type:"image", data, mimeType}` shape, bounded by the cumulative `imageBase64Budget` (E4): past
90
+ * it the image is DROPPED with an honest text marker — a degradation, never an error.
91
+ */
39
92
  export declare function renderNotebookCells(cells: readonly NotebookCell[], imageBase64Budget: number): NotebookRender;
93
+ /** Wire-card projection of a cell: base64 replaced by a length marker so the `details` card never
94
+ * carries raw image bytes (they ride the model-facing content blocks; an oversized card would be
95
+ * omitted whole by the structuredFrom 4×cap and blind the shell). */
40
96
  export declare function stripNotebookImageData(cell: NotebookCell): NotebookCell;
@@ -1,29 +1,85 @@
1
+ /**
2
+ * PDF read pipeline (service [411]② + 审计 [485]⑤ — CC FileReadTool parity).
3
+ *
4
+ * CC ground truth (original-source-code, 取证 2026-07-07):
5
+ * - Whole-PDF path (`FileReadTool.ts:987-1016` + `utils/pdf.ts:88-103`): the file bytes are base64'd and
6
+ * sent as a native `{type:"document",source:{type:"base64",media_type:"application/pdf",data}}` content
7
+ * block — the model reads the text layer directly (no local text extraction).
8
+ * - Page-range path (`utils/pdf.ts:179-230`): CC does NOT split the PDF itself — it shells out to
9
+ * poppler's `pdftoppm -jpeg -r 100 -f F -l L` and returns the rendered pages as IMAGE blocks.
10
+ * - Page counting (`utils/pdf.ts:119-135`): poppler's `pdfinfo`, parsing `/^Pages:\s+(\d+)/m`; `null`
11
+ * (tool absent/failed) fails OPEN. We add a zero-dependency byte-scan fallback for uncompressed PDFs.
12
+ * - Limits (`constants/apiLimits.ts:46-84`): 20MB whole-send target, 100MB extraction ceiling, 20 pages
13
+ * per request, >10 pages ⇒ the `pages` parameter is REQUIRED.
14
+ *
15
+ * sema follows the same shape with the ExecutionEnv seam (works against remote envs too) and honest
16
+ * degradation when poppler is absent — never a fake success.
17
+ */
1
18
  import type { ExecutionEnv } from "../../internal/harness-types.js";
19
+ /** Max pages a single `pages` request may span (CC `PDF_MAX_PAGES_PER_READ`). */
2
20
  export declare const PDF_MAX_PAGES_PER_READ = 20;
21
+ /** Above this page count a whole-PDF read is refused and `pages` is required (CC `PDF_AT_MENTION_INLINE_THRESHOLD`). */
3
22
  export declare const PDF_INLINE_PAGE_THRESHOLD = 10;
23
+ /** Max raw size sent whole as a document block (CC `PDF_TARGET_RAW_SIZE`). */
4
24
  export declare const PDF_TARGET_RAW_SIZE: number;
25
+ /** Max raw size the page-extraction (pdftoppm) path accepts (CC `PDF_MAX_EXTRACT_SIZE`). */
5
26
  export declare const PDF_MAX_EXTRACT_SIZE: number;
27
+ /** True when the bytes start with the `%PDF-` magic. Magic outranks extension both ways: a mis-named
28
+ * `.pdf` without it is refused, and a non-`.pdf` file carrying it is read AS a PDF. */
6
29
  export declare function pdfMagicMatches(bytes: Uint8Array): boolean;
30
+ /** A parsed 1-indexed inclusive page range. `last === Infinity` for an open range ("10-"). */
7
31
  export interface PdfPageRange {
8
32
  first: number;
9
33
  last: number;
10
34
  }
35
+ /** Parse the CC `pages` formats — "3", "1-5", "10-" (open range). `undefined` = invalid. */
11
36
  export declare function parsePdfPageRange(pages: string): PdfPageRange | undefined;
37
+ /**
38
+ * Zero-dependency page-count estimate: count `/Type /Page` leaf objects in the raw bytes. Exact for
39
+ * classically-serialized PDFs (incl. linearized — objects stay uncompressed); returns `undefined` when
40
+ * nothing matches (page tree inside compressed object streams — modern writers), NEVER a guess.
41
+ */
12
42
  export declare function countPdfPagesFromBytes(bytes: Uint8Array): number | undefined;
43
+ /** Max chars of a failed poppler call's stderr/stdout kept in the reported error (A-005.15). */
44
+ export declare const PDF_EXEC_ERROR_PREVIEW_CHARS = 400;
45
+ /** Bound a poppler exec failure's captured stream to {@link PDF_EXEC_ERROR_PREVIEW_CHARS}, marking the cut
46
+ * (a bare slice reads identical to a short capture that just happened to end there — the model has no way
47
+ * to tell "that's everything" from "that's all we kept"). Exactly-at-the-cap text is unmarked. */
48
+ export declare function previewExecStream(s: string): string;
49
+ /**
50
+ * Total page count via poppler `pdfinfo` (CC parity), falling back to {@link countPdfPagesFromBytes}
51
+ * when the tool is absent/fails and the bytes were already read. `undefined` = unknown (fail-open,
52
+ * matching CC's `getPDFPageCount → null`).
53
+ */
13
54
  export declare function getPdfPageCount(env: ExecutionEnv, absPath: string, bytes: Uint8Array | undefined, signal?: AbortSignal): Promise<number | undefined>;
55
+ /** How many leading pages the vision fallback (level 2) renders for a whole-PDF read on a model without
56
+ * document input — conservative per-request budget; the note directs the model to `pages` for more. */
14
57
  export declare const PDF_FALLBACK_RENDER_PAGES = 5;
58
+ /**
59
+ * PDF capability profile of the SERVING model, consumed by the Read tool's degradation chain (v2):
60
+ * - `document` — the brain path can forward a native `{type:"document"}` block (today: anthropic-messages
61
+ * WITH vision — anthropic.ts drops document blocks for no-vision models — or an explicit `input`
62
+ * declaration containing "document" for a future capability bit).
63
+ * - `vision` — `Model.input` contains "image" (absent metadata fails open = today's behavior).
64
+ * Structural parameter (no deep Model import): `prepare-task` passes the task's resolved Model.
65
+ */
15
66
  export interface PdfModelCapabilities {
16
67
  document: boolean;
17
68
  vision: boolean;
18
69
  }
70
+ /** Derive {@link PdfModelCapabilities} from a Model-shaped object. `undefined` model = fully capable
71
+ * (fail-open: no metadata ⇒ preserve the native document-block behavior, brain-level placeholder guards). */
19
72
  export declare function pdfModelCapabilitiesOf(model?: {
20
73
  api?: string;
21
74
  input?: readonly string[];
22
75
  }): PdfModelCapabilities;
76
+ /** Timeout for the poppler extraction commands (pdftotext / pdftoppm), in seconds. */
23
77
  export declare const PDF_EXEC_TIMEOUT_SEC = 120;
24
78
  export type PdfTextResult = {
25
79
  ok: true;
26
80
  text: string;
81
+ /** Set when pdftotext hit its exec timeout but had already written partial text: the extraction is
82
+ * INCOMPLETE (covers only the leading part of the requested range) and the caller must say so. */
27
83
  timedOutAfterSec?: number;
28
84
  } | {
29
85
  ok: false;
@@ -31,6 +87,13 @@ export type PdfTextResult = {
31
87
  timedOut?: boolean;
32
88
  error: string;
33
89
  };
90
+ /**
91
+ * Extract the PDF text layer via poppler `pdftotext -layout` (degradation-chain level 1: models without
92
+ * native document input get the text instead of a placeholder). Optional 1-indexed inclusive page range
93
+ * (`-f`/`-l`). Output goes through a temp FILE (not exec stdout — env exec seams may cap/mangle stdout),
94
+ * read back over the env seam so it works against remote envs too. `toolMissing` distinguishes
95
+ * "install poppler" from a real extraction failure.
96
+ */
34
97
  export declare function extractPdfTextLayer(env: ExecutionEnv, absPath: string, range?: {
35
98
  first: number;
36
99
  last: number;
@@ -41,6 +104,8 @@ export type PdfExtractResult = {
41
104
  pageNumber: number;
42
105
  jpeg: Uint8Array;
43
106
  }>;
107
+ /** Set when pdftoppm hit its exec timeout but had already rendered complete leading pages: `pages`
108
+ * covers only a PREFIX of the requested range and the caller must label the delivery as partial. */
44
109
  timedOutAfterSec?: number;
45
110
  } | {
46
111
  ok: false;
@@ -48,4 +113,9 @@ export type PdfExtractResult = {
48
113
  timedOut?: boolean;
49
114
  error: string;
50
115
  };
116
+ /**
117
+ * Render pages [first..last] to JPEGs via poppler `pdftoppm` (CC `extractPDFPages` parity: `-jpeg -r 100`,
118
+ * 120s timeout). Runs through the ExecutionEnv seam (temp dir + exec + readBinaryFile), so it works
119
+ * wherever the env does. `toolMissing` distinguishes "install poppler" from a real extraction failure.
120
+ */
51
121
  export declare function extractPdfPagesAsImages(env: ExecutionEnv, absPath: string, first: number, last: number, signal?: AbortSignal): Promise<PdfExtractResult>;
@@ -29,6 +29,12 @@ export function countPdfPagesFromBytes(bytes) {
29
29
  function shellQuote(arg) {
30
30
  return `'${arg.replaceAll("'", `'\\''`)}'`;
31
31
  }
32
+ export const PDF_EXEC_ERROR_PREVIEW_CHARS = 400;
33
+ export function previewExecStream(s) {
34
+ return s.length > PDF_EXEC_ERROR_PREVIEW_CHARS
35
+ ? `${s.slice(0, PDF_EXEC_ERROR_PREVIEW_CHARS)} …[${s.length - PDF_EXEC_ERROR_PREVIEW_CHARS} chars truncated]`
36
+ : s;
37
+ }
32
38
  export async function getPdfPageCount(env, absPath, bytes, signal) {
33
39
  try {
34
40
  const r = await env.exec(`pdfinfo ${shellQuote(absPath)}`, { timeout: 10, abortSignal: signal });
@@ -82,7 +88,7 @@ export async function extractPdfTextLayer(env, absPath, range, signal) {
82
88
  return { ok: false, toolMissing: false, error: r.error.message };
83
89
  }
84
90
  if (r.value.exitCode !== 0) {
85
- const stderr = (r.value.stderr || r.value.stdout || "").trim().slice(0, 400);
91
+ const stderr = previewExecStream((r.value.stderr || r.value.stdout || "").trim());
86
92
  const missing = r.value.exitCode === 127 || /not found|command not found/i.test(stderr);
87
93
  return { ok: false, toolMissing: missing, error: stderr || `pdftotext exited with code ${r.value.exitCode}` };
88
94
  }
@@ -145,7 +151,7 @@ export async function extractPdfPagesAsImages(env, absPath, first, last, signal)
145
151
  return { ok: false, toolMissing: false, error: r.error.message };
146
152
  }
147
153
  if (r.value.exitCode !== 0) {
148
- const stderr = (r.value.stderr || r.value.stdout || "").trim().slice(0, 400);
154
+ const stderr = previewExecStream((r.value.stderr || r.value.stdout || "").trim());
149
155
  const missing = r.value.exitCode === 127 || /not found|No such file or directory: pdftoppm|command not found/i.test(stderr);
150
156
  return { ok: false, toolMissing: missing, error: stderr || `pdftoppm exited with code ${r.value.exitCode}` };
151
157
  }
@@ -1,4 +1,14 @@
1
1
  import type { AgentTool } from "../../internal/harness-types.js";
2
2
  import type { ExecutionEnv } from "../../internal/harness-types.js";
3
+ /** Extract top-level symbol names (deduped, in first-seen order) from source text. A lightweight
4
+ * comment/docstring state machine (council #4) skips column-0 declaration-like lines that are really
5
+ * inside a `/* … *​/` block comment or a Python `"""`/`'''` docstring — otherwise e.g. a module
6
+ * docstring containing `def foo():` at column 0 produces a phantom symbol. Not a full parser (v1
7
+ * heuristic): it tracks whole-line block/docstring regions, the common false-positive source.
8
+ *
9
+ * ⚠️ **Exported ONLY as a v1 heuristic, NOT a containment proof** (design/79 §3): it is column-0 /
10
+ * source-only and skips indented lines, so it CANNOT enumerate everything an artifact can call. The
11
+ * auto-promote tripwire (src/core/auto-promote.ts) consumes it in ESCALATE-ONLY mode — a clean scan
12
+ * contributes nothing; it can only ever raise an escalation, never clear one. */
3
13
  export declare function extractSymbols(text: string): string[];
4
14
  export declare function createRepoMapTool(env: ExecutionEnv, rootCanonical: string, additionalRoots?: readonly string[]): AgentTool;