@arnilo/prism-tools 0.0.0-stage → 0.13.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 (331) hide show
  1. package/CHANGELOG.md +410 -0
  2. package/LICENSE +21 -0
  3. package/README.md +44 -2
  4. package/browser/README.md +98 -0
  5. package/browser/skills/browser-automation/SKILL.md +14 -0
  6. package/browser/src/actions/cdp.ts +131 -0
  7. package/browser/src/actions/dialog.ts +25 -0
  8. package/browser/src/actions/download_release.ts +22 -0
  9. package/browser/src/actions/index.ts +37 -0
  10. package/browser/src/actions/locator.ts +70 -0
  11. package/browser/src/actions/navigate.ts +23 -0
  12. package/browser/src/actions/screenshot.ts +27 -0
  13. package/browser/src/actions/scroll.ts +24 -0
  14. package/browser/src/actions/select_page.ts +21 -0
  15. package/browser/src/actions/types.ts +114 -0
  16. package/browser/src/actions/upload.ts +44 -0
  17. package/browser/src/actions/wait.ts +45 -0
  18. package/browser/src/browser.ts +197 -0
  19. package/browser/src/cdp.ts +178 -0
  20. package/browser/src/checkpoint.ts +189 -0
  21. package/browser/src/config.ts +72 -0
  22. package/browser/src/downloads.ts +253 -0
  23. package/browser/src/errors.ts +31 -0
  24. package/browser/src/evaluate.ts +101 -0
  25. package/browser/src/index.ts +129 -0
  26. package/browser/src/limits.ts +271 -0
  27. package/browser/src/manager.ts +730 -0
  28. package/browser/src/network.ts +263 -0
  29. package/browser/src/observe.ts +178 -0
  30. package/browser/src/policy.ts +133 -0
  31. package/browser/src/screenshot.ts +107 -0
  32. package/browser/src/shared-sandbox.ts +53 -0
  33. package/browser/src/snapshot.ts +99 -0
  34. package/browser/src/targets.ts +165 -0
  35. package/browser/src/tools.ts +480 -0
  36. package/browser/src/types.ts +316 -0
  37. package/browser/src/uploads.ts +174 -0
  38. package/coding/README.md +337 -0
  39. package/coding/src/agent/acp-operations.ts +146 -0
  40. package/coding/src/agent/artifacts.ts +38 -0
  41. package/coding/src/agent/ask-user-decision.ts +623 -0
  42. package/coding/src/agent/atomic-write.ts +23 -0
  43. package/coding/src/agent/bounded-file.ts +21 -0
  44. package/coding/src/agent/checks.ts +301 -0
  45. package/coding/src/agent/coding-checkpoint.ts +828 -0
  46. package/coding/src/agent/delete.ts +237 -0
  47. package/coding/src/agent/diagnostics-tool.ts +163 -0
  48. package/coding/src/agent/diagnostics.ts +262 -0
  49. package/coding/src/agent/edit-diff.ts +382 -0
  50. package/coding/src/agent/edit.ts +322 -0
  51. package/coding/src/agent/effects.ts +102 -0
  52. package/coding/src/agent/env.ts +28 -0
  53. package/coding/src/agent/execution-policy.ts +89 -0
  54. package/coding/src/agent/file-mutation-queue.ts +72 -0
  55. package/coding/src/agent/forge/github.ts +603 -0
  56. package/coding/src/agent/forge/index.ts +16 -0
  57. package/coding/src/agent/forge/types.ts +185 -0
  58. package/coding/src/agent/git-aware-repository.ts +305 -0
  59. package/coding/src/agent/git-exec.ts +326 -0
  60. package/coding/src/agent/git-status.ts +177 -0
  61. package/coding/src/agent/git-tools.ts +360 -0
  62. package/coding/src/agent/git.ts +1074 -0
  63. package/coding/src/agent/glob-match.ts +146 -0
  64. package/coding/src/agent/glob.ts +182 -0
  65. package/coding/src/agent/goal-verify.ts +385 -0
  66. package/coding/src/agent/grep-worker.ts +74 -0
  67. package/coding/src/agent/grep.ts +459 -0
  68. package/coding/src/agent/identity.ts +48 -0
  69. package/coding/src/agent/index.ts +676 -0
  70. package/coding/src/agent/language/client.ts +429 -0
  71. package/coding/src/agent/language/framing.ts +190 -0
  72. package/coding/src/agent/language/index.ts +23 -0
  73. package/coding/src/agent/language/intelligence.ts +682 -0
  74. package/coding/src/agent/language/types.ts +187 -0
  75. package/coding/src/agent/lifecycle-events.ts +121 -0
  76. package/coding/src/agent/lifecycle.ts +166 -0
  77. package/coding/src/agent/limits.ts +214 -0
  78. package/coding/src/agent/move.ts +178 -0
  79. package/coding/src/agent/mutation-path.ts +52 -0
  80. package/coding/src/agent/output-accumulator.ts +304 -0
  81. package/coding/src/agent/path-utils.ts +120 -0
  82. package/coding/src/agent/process/index.ts +58 -0
  83. package/coding/src/agent/process/recovery.ts +508 -0
  84. package/coding/src/agent/process/sessions-host.ts +222 -0
  85. package/coding/src/agent/process/sessions-monitor.ts +141 -0
  86. package/coding/src/agent/process/sessions-recovery.ts +241 -0
  87. package/coding/src/agent/process/sessions-spawn.ts +613 -0
  88. package/coding/src/agent/process/sessions-teardown.ts +281 -0
  89. package/coding/src/agent/process/sessions.ts +30 -0
  90. package/coding/src/agent/process/types.ts +358 -0
  91. package/coding/src/agent/read-path-set.ts +126 -0
  92. package/coding/src/agent/read.ts +713 -0
  93. package/coding/src/agent/repository/glob.ts +147 -0
  94. package/coding/src/agent/repository/indexed-search.ts +480 -0
  95. package/coding/src/agent/repository/list.ts +131 -0
  96. package/coding/src/agent/repository/operations.ts +22 -0
  97. package/coding/src/agent/repository/path.ts +98 -0
  98. package/coding/src/agent/repository/search.ts +277 -0
  99. package/coding/src/agent/repository/types.ts +243 -0
  100. package/coding/src/agent/repository/walk.ts +126 -0
  101. package/coding/src/agent/repository.ts +12 -0
  102. package/coding/src/agent/shell-background.ts +264 -0
  103. package/coding/src/agent/shell-output.ts +75 -0
  104. package/coding/src/agent/shell.ts +526 -0
  105. package/coding/src/agent/todo.ts +399 -0
  106. package/coding/src/agent/truncate.ts +251 -0
  107. package/coding/src/agent/write.ts +170 -0
  108. package/coding/src/ask-user-host.ts +48 -0
  109. package/coding/src/config.ts +278 -0
  110. package/coding/src/hard-deny.ts +97 -0
  111. package/coding/src/index.ts +318 -0
  112. package/coding/src/principal-guard.ts +84 -0
  113. package/coding/src/sandbox.ts +92 -0
  114. package/coding/src/security/approval.ts +144 -0
  115. package/coding/src/security/command-rules.ts +57 -0
  116. package/coding/src/security/docker-cli.ts +222 -0
  117. package/coding/src/security/docker-sandbox.ts +1205 -0
  118. package/coding/src/security/e2b-sandbox.ts +853 -0
  119. package/coding/src/security/egress/dns-pin.ts +88 -0
  120. package/coding/src/security/egress/index.ts +32 -0
  121. package/coding/src/security/egress/limits.ts +57 -0
  122. package/coding/src/security/egress/policy.ts +137 -0
  123. package/coding/src/security/egress/proxy.ts +599 -0
  124. package/coding/src/security/egress/types.ts +30 -0
  125. package/coding/src/security/index.ts +199 -0
  126. package/coding/src/security/native-sandbox.ts +639 -0
  127. package/coding/src/security/path-containment.ts +55 -0
  128. package/coding/src/security/sandbox-coding-operations.ts +392 -0
  129. package/coding/src/security/sandbox-fs-operations.ts +644 -0
  130. package/coding/src/security/sandbox-limits.ts +147 -0
  131. package/coding/src/security/sandbox-tar.ts +308 -0
  132. package/coding/src/security/sandbox.ts +179 -0
  133. package/coding/src/security/semaphore.ts +55 -0
  134. package/coding/src/targets.ts +110 -0
  135. package/coding/src/workspace/diff.ts +78 -0
  136. package/coding/src/workspace/errors.ts +28 -0
  137. package/coding/src/workspace/index.ts +5 -0
  138. package/coding/src/workspace/merge.ts +151 -0
  139. package/coding/src/workspace/routing.ts +76 -0
  140. package/coding/src/workspace/service.ts +545 -0
  141. package/computer-use/README.md +105 -0
  142. package/computer-use/skills/computer-use-linux/SKILL.md +17 -0
  143. package/computer-use/src/classify.ts +53 -0
  144. package/computer-use/src/command.ts +29 -0
  145. package/computer-use/src/config.ts +69 -0
  146. package/computer-use/src/create.ts +170 -0
  147. package/computer-use/src/devices.ts +247 -0
  148. package/computer-use/src/env.ts +28 -0
  149. package/computer-use/src/index.ts +157 -0
  150. package/computer-use/src/skill.ts +21 -0
  151. package/openapi/README.md +97 -0
  152. package/openapi/src/compile.ts +386 -0
  153. package/openapi/src/config.ts +73 -0
  154. package/openapi/src/errors.ts +16 -0
  155. package/openapi/src/execute.ts +241 -0
  156. package/openapi/src/index.ts +124 -0
  157. package/openapi/src/limits.ts +63 -0
  158. package/openapi/src/specs.ts +86 -0
  159. package/openapi/src/tools.ts +60 -0
  160. package/openapi/src/types.ts +61 -0
  161. package/package.json +171 -4
  162. package/research/README.md +72 -0
  163. package/research/skills/research-report/SKILL.md +12 -0
  164. package/research/skills/research-scoping/SKILL.md +10 -0
  165. package/research/skills/research-synthesis/SKILL.md +10 -0
  166. package/research/skills/source-triage/SKILL.md +10 -0
  167. package/research/src/check.ts +71 -0
  168. package/research/src/config.ts +41 -0
  169. package/research/src/index.ts +147 -0
  170. package/research/src/ledger.ts +157 -0
  171. package/research/src/urls.ts +21 -0
  172. package/web/README.md +287 -0
  173. package/web/skills/web-research/SKILL.md +17 -0
  174. package/web/src/brave.ts +66 -0
  175. package/web/src/cache.ts +151 -0
  176. package/web/src/config.ts +210 -0
  177. package/web/src/controls.ts +128 -0
  178. package/web/src/domains.ts +114 -0
  179. package/web/src/exa.ts +60 -0
  180. package/web/src/firecrawl.ts +160 -0
  181. package/web/src/index.ts +387 -0
  182. package/web/src/kagi.ts +73 -0
  183. package/web/src/limits.ts +55 -0
  184. package/web/src/native/convert.ts +84 -0
  185. package/web/src/native/fetch.ts +226 -0
  186. package/web/src/normalize.ts +131 -0
  187. package/web/src/obscura/cdp.ts +201 -0
  188. package/web/src/obscura/classify.ts +35 -0
  189. package/web/src/obscura/cli.ts +254 -0
  190. package/web/src/obscura/errors.ts +8 -0
  191. package/web/src/obscura/index.ts +59 -0
  192. package/web/src/obscura/limits.ts +92 -0
  193. package/web/src/obscura/mcp.ts +104 -0
  194. package/web/src/obscura/playwright.ts +133 -0
  195. package/web/src/obscura/process.ts +235 -0
  196. package/web/src/obscura/search-profile.ts +73 -0
  197. package/web/src/obscura/types.ts +48 -0
  198. package/web/src/obscura/web.ts +419 -0
  199. package/web/src/prompt-fetch.ts +88 -0
  200. package/web/src/render.ts +75 -0
  201. package/web/src/searxng.ts +78 -0
  202. package/web/src/slice.ts +139 -0
  203. package/web/src/tavily.ts +77 -0
  204. package/web/src/tools.ts +182 -0
  205. package/web/src/transport.ts +310 -0
  206. package/web/src/types.ts +199 -0
  207. package/work/README.md +77 -0
  208. package/work/THIRD_PARTY_NOTICES +24 -0
  209. package/work/docling/ocr.py +150 -0
  210. package/work/sandbox/Dockerfile +36 -0
  211. package/work/sandbox/soffice.sh +12 -0
  212. package/work/src/command.ts +29 -0
  213. package/work/src/config.ts +138 -0
  214. package/work/src/connectors/cli.ts +343 -0
  215. package/work/src/connectors/drafts.ts +647 -0
  216. package/work/src/connectors/errors.ts +8 -0
  217. package/work/src/connectors/file-bytes.ts +149 -0
  218. package/work/src/connectors/google-workspace-http.ts +399 -0
  219. package/work/src/connectors/google-workspace.ts +465 -0
  220. package/work/src/connectors/gws-tools.ts +378 -0
  221. package/work/src/connectors/http.ts +123 -0
  222. package/work/src/connectors/idempotency.ts +235 -0
  223. package/work/src/connectors/identity.ts +34 -0
  224. package/work/src/connectors/index.ts +93 -0
  225. package/work/src/connectors/limits.ts +50 -0
  226. package/work/src/connectors/m365-tools.ts +308 -0
  227. package/work/src/connectors/microsoft365-http.ts +428 -0
  228. package/work/src/connectors/microsoft365.ts +402 -0
  229. package/work/src/connectors/normalize.ts +120 -0
  230. package/work/src/connectors/tool-helpers.ts +398 -0
  231. package/work/src/connectors/tools.ts +42 -0
  232. package/work/src/connectors/types.ts +399 -0
  233. package/work/src/diagrams/canonicalize.ts +166 -0
  234. package/work/src/diagrams/caps.ts +52 -0
  235. package/work/src/diagrams/embed.ts +340 -0
  236. package/work/src/diagrams/errors.ts +76 -0
  237. package/work/src/diagrams/index.ts +81 -0
  238. package/work/src/diagrams/messages.ts +150 -0
  239. package/work/src/diagrams/origin.ts +52 -0
  240. package/work/src/diagrams/telemetry.ts +34 -0
  241. package/work/src/diagrams/xml.ts +267 -0
  242. package/work/src/document-extraction/index.ts +563 -0
  243. package/work/src/document-reader/ambient.d.ts +2 -0
  244. package/work/src/document-reader/errors.ts +7 -0
  245. package/work/src/document-reader/index.ts +181 -0
  246. package/work/src/document-reader/mistral-ocr.ts +318 -0
  247. package/work/src/document-reader/parsers.ts +171 -0
  248. package/work/src/documents/caps.ts +135 -0
  249. package/work/src/documents/diff.ts +269 -0
  250. package/work/src/documents/errors.ts +44 -0
  251. package/work/src/documents/fidelity.ts +98 -0
  252. package/work/src/documents/generate.ts +96 -0
  253. package/work/src/documents/hash.ts +8 -0
  254. package/work/src/documents/index.ts +14 -0
  255. package/work/src/documents/model-schema.ts +639 -0
  256. package/work/src/documents/parse.ts +252 -0
  257. package/work/src/documents/patch-history.ts +81 -0
  258. package/work/src/documents/patch.ts +476 -0
  259. package/work/src/documents/preview-html.ts +245 -0
  260. package/work/src/documents/preview.ts +227 -0
  261. package/work/src/documents/telemetry.ts +36 -0
  262. package/work/src/documents/translate/docx.ts +292 -0
  263. package/work/src/documents/translate/pptx.ts +304 -0
  264. package/work/src/documents/translate/xlsx.ts +137 -0
  265. package/work/src/documents/types.ts +188 -0
  266. package/work/src/index.ts +311 -0
  267. package/work/src/runtime/worker-pool-entry.ts +102 -0
  268. package/work/src/runtime/worker-pool.ts +267 -0
  269. package/work/src/sandbox/composition.ts +212 -0
  270. package/work/src/sandbox/image.ts +6 -0
  271. package/work/src/sandbox/index.ts +14 -0
  272. package/work/src/sheets/caps.ts +68 -0
  273. package/work/src/sheets/csv.ts +351 -0
  274. package/work/src/sheets/decimal.ts +388 -0
  275. package/work/src/sheets/errors.ts +52 -0
  276. package/work/src/sheets/index.ts +62 -0
  277. package/work/src/sheets/inference.ts +378 -0
  278. package/work/src/sheets/telemetry.ts +34 -0
  279. package/work/src/sheets/types.ts +162 -0
  280. package/work/src/sheets/xlsx.ts +388 -0
  281. package/work/src/skills/index.ts +8 -0
  282. package/work/src/skills/load.ts +43 -0
  283. package/work/src/tools/filesystem.ts +21 -0
  284. package/work/src/tools/index.ts +1 -0
  285. package/work/src/tools/local-filesystem.ts +33 -0
  286. package/work/src/tools/office.ts +311 -0
  287. package/work/vendor/hermes-agent/LICENSE +21 -0
  288. package/work/vendor/hermes-agent/skills/productivity/docx/LICENSE +21 -0
  289. package/work/vendor/hermes-agent/skills/productivity/docx/SKILL.md +196 -0
  290. package/work/vendor/hermes-agent/skills/productivity/docx/scripts/docx_comments.py +289 -0
  291. package/work/vendor/hermes-agent/skills/productivity/docx/scripts/docx_common.py +94 -0
  292. package/work/vendor/hermes-agent/skills/productivity/docx/scripts/docx_create.py +177 -0
  293. package/work/vendor/hermes-agent/skills/productivity/docx/scripts/docx_edit.py +250 -0
  294. package/work/vendor/hermes-agent/skills/productivity/docx/scripts/docx_read.py +149 -0
  295. package/work/vendor/hermes-agent/skills/productivity/docx/scripts/docx_revisions.py +147 -0
  296. package/work/vendor/hermes-agent/skills/productivity/docx/scripts/docx_template.py +70 -0
  297. package/work/vendor/hermes-agent/skills/productivity/docx/scripts/docx_validate.py +156 -0
  298. package/work/vendor/hermes-agent/skills/productivity/pdf/LICENSE +21 -0
  299. package/work/vendor/hermes-agent/skills/productivity/pdf/SKILL.md +125 -0
  300. package/work/vendor/hermes-agent/skills/productivity/pdf/scripts/_raster.py +76 -0
  301. package/work/vendor/hermes-agent/skills/productivity/pdf/scripts/extract_marker.py +88 -0
  302. package/work/vendor/hermes-agent/skills/productivity/pdf/scripts/extract_pymupdf.py +101 -0
  303. package/work/vendor/hermes-agent/skills/productivity/pdf/scripts/pdf_create.py +130 -0
  304. package/work/vendor/hermes-agent/skills/productivity/pdf/scripts/pdf_fill_form.py +97 -0
  305. package/work/vendor/hermes-agent/skills/productivity/pdf/scripts/pdf_form_layout.py +168 -0
  306. package/work/vendor/hermes-agent/skills/productivity/pdf/scripts/pdf_make_form.py +145 -0
  307. package/work/vendor/hermes-agent/skills/productivity/pdf/scripts/pdf_merge.py +50 -0
  308. package/work/vendor/hermes-agent/skills/productivity/pdf/scripts/pdf_meta.py +115 -0
  309. package/work/vendor/hermes-agent/skills/productivity/pdf/scripts/pdf_page_image.py +99 -0
  310. package/work/vendor/hermes-agent/skills/productivity/pdf/scripts/pdf_read.py +153 -0
  311. package/work/vendor/hermes-agent/skills/productivity/pdf/scripts/pdf_secure.py +71 -0
  312. package/work/vendor/hermes-agent/skills/productivity/pdf/scripts/pdf_split.py +84 -0
  313. package/work/vendor/hermes-agent/skills/productivity/pdf/scripts/pdf_stamp.py +143 -0
  314. package/work/vendor/hermes-agent/skills/productivity/pdf/scripts/pdf_watermark.py +51 -0
  315. package/work/vendor/hermes-agent/skills/productivity/powerpoint/LICENSE +21 -0
  316. package/work/vendor/hermes-agent/skills/productivity/powerpoint/SKILL.md +220 -0
  317. package/work/vendor/hermes-agent/skills/productivity/powerpoint/scripts/pptx_create.py +214 -0
  318. package/work/vendor/hermes-agent/skills/productivity/powerpoint/scripts/pptx_edit.py +436 -0
  319. package/work/vendor/hermes-agent/skills/productivity/powerpoint/scripts/pptx_from_template.py +88 -0
  320. package/work/vendor/hermes-agent/skills/productivity/powerpoint/scripts/pptx_read.py +131 -0
  321. package/work/vendor/hermes-agent/skills/productivity/powerpoint/scripts/pptx_render.py +93 -0
  322. package/work/vendor/hermes-agent/skills/productivity/xlsx/LICENSE +21 -0
  323. package/work/vendor/hermes-agent/skills/productivity/xlsx/SKILL.md +196 -0
  324. package/work/vendor/hermes-agent/skills/productivity/xlsx/scripts/csv_to_xlsx.py +104 -0
  325. package/work/vendor/hermes-agent/skills/productivity/xlsx/scripts/xlsx_create.py +259 -0
  326. package/work/vendor/hermes-agent/skills/productivity/xlsx/scripts/xlsx_edit.py +263 -0
  327. package/work/vendor/hermes-agent/skills/productivity/xlsx/scripts/xlsx_read.py +160 -0
  328. package/work/vendor/hermes-agent/skills/productivity/xlsx/scripts/xlsx_recalc.py +111 -0
  329. package/work/vendor/hermes-agent/skills/productivity/xlsx/scripts/xlsx_restructure.py +337 -0
  330. package/work/vendor/hermes-agent/skills/productivity/xlsx/scripts/xlsx_to_csv.py +69 -0
  331. package/work/vendor-lock.json +11 -0
@@ -0,0 +1,187 @@
1
+ import {
2
+ DEFAULT_MAX_LSP_DIAGNOSTICS_PER_FILE,
3
+ DEFAULT_MAX_LSP_MESSAGE_BYTES,
4
+ DEFAULT_MAX_LSP_PENDING_REQUESTS,
5
+ DEFAULT_MAX_LSP_RESULTS_PER_QUERY,
6
+ DEFAULT_MAX_LSP_SERVERS,
7
+ DEFAULT_MAX_LSP_TIMEOUT_MS,
8
+ HARD_MAX_LSP_DIAGNOSTICS_PER_FILE,
9
+ HARD_MAX_LSP_MESSAGE_BYTES,
10
+ HARD_MAX_LSP_PENDING_REQUESTS,
11
+ HARD_MAX_LSP_RESULTS_PER_QUERY,
12
+ HARD_MAX_LSP_SERVERS,
13
+ HARD_MAX_LSP_TIMEOUT_MS,
14
+ LSP_RESTARTS_PER_SERVER,
15
+ validateCodingLimit,
16
+ } from "../limits.js";
17
+
18
+ import type { ExecutionPolicy } from "../execution-policy.js";
19
+ export type LanguageIntelligenceErrorCode =
20
+ | "ERR_PRISM_LSP_FRAMING"
21
+ | "ERR_PRISM_LSP_SERVER"
22
+ | "ERR_PRISM_LSP_TIMEOUT"
23
+ | "ERR_PRISM_LSP_LIMIT"
24
+ | "ERR_PRISM_LSP_UNSUPPORTED"
25
+ | "ERR_PRISM_LSP_WORKSPACE";
26
+
27
+ export class LanguageIntelligenceError extends Error {
28
+ readonly code: LanguageIntelligenceErrorCode;
29
+ constructor(code: LanguageIntelligenceErrorCode, message: string) {
30
+ super(message);
31
+ this.name = "LanguageIntelligenceError";
32
+ this.code = code;
33
+ }
34
+ }
35
+
36
+ /** Host allow-listed server command; never model-supplied. */
37
+ export interface LanguageServerSpec {
38
+ readonly command: string;
39
+ readonly args?: readonly string[];
40
+ readonly languages: readonly string[];
41
+ readonly env?: Readonly<Record<string, string>>;
42
+ }
43
+
44
+ /** LSP 0-based position + workspace-relative file path. */
45
+ export interface LanguageLocation {
46
+ readonly file: string;
47
+ readonly line: number;
48
+ readonly character: number;
49
+ }
50
+
51
+ export interface LanguageSymbol {
52
+ readonly name: string;
53
+ readonly kind: number;
54
+ readonly file: string;
55
+ readonly line: number;
56
+ readonly character: number;
57
+ readonly containerName?: string;
58
+ }
59
+
60
+ export interface LanguageDiagnostic {
61
+ readonly file: string;
62
+ readonly line: number;
63
+ readonly character: number;
64
+ readonly endLine: number;
65
+ readonly endCharacter: number;
66
+ readonly severity: "error" | "warning" | "info" | "hint";
67
+ readonly message: string;
68
+ readonly source?: string;
69
+ readonly code?: string | number;
70
+ }
71
+
72
+ export interface LanguageTextEdit {
73
+ readonly file: string;
74
+ readonly newText: string;
75
+ readonly range: {
76
+ readonly start: { readonly line: number; readonly character: number };
77
+ readonly end: { readonly line: number; readonly character: number };
78
+ };
79
+ }
80
+
81
+ export interface LanguageWorkspaceEdit {
82
+ readonly edits: readonly LanguageTextEdit[];
83
+ }
84
+
85
+ export interface LanguageIntelligenceLimits {
86
+ readonly maxMessageBytes?: number;
87
+ readonly maxDiagnosticsPerFile?: number;
88
+ readonly maxPendingRequests?: number;
89
+ readonly maxResultsPerQuery?: number;
90
+ readonly requestTimeoutMs?: number;
91
+ readonly maxServers?: number;
92
+ /** Cap restarts after unexpected exit (freeze: 3). */
93
+ readonly maxRestartsPerServer?: number;
94
+ }
95
+
96
+ export interface ResolvedLanguageIntelligenceLimits {
97
+ readonly maxMessageBytes: number;
98
+ readonly maxDiagnosticsPerFile: number;
99
+ readonly maxPendingRequests: number;
100
+ readonly maxResultsPerQuery: number;
101
+ readonly requestTimeoutMs: number;
102
+ readonly maxServers: number;
103
+ readonly maxRestartsPerServer: number;
104
+ }
105
+
106
+ export function resolveLanguageIntelligenceLimits(options?: LanguageIntelligenceLimits): ResolvedLanguageIntelligenceLimits {
107
+ return {
108
+ maxMessageBytes: validateCodingLimit(
109
+ "maxMessageBytes",
110
+ options?.maxMessageBytes ?? DEFAULT_MAX_LSP_MESSAGE_BYTES,
111
+ HARD_MAX_LSP_MESSAGE_BYTES,
112
+ ),
113
+ maxDiagnosticsPerFile: validateCodingLimit(
114
+ "maxDiagnosticsPerFile",
115
+ options?.maxDiagnosticsPerFile ?? DEFAULT_MAX_LSP_DIAGNOSTICS_PER_FILE,
116
+ HARD_MAX_LSP_DIAGNOSTICS_PER_FILE,
117
+ ),
118
+ maxPendingRequests: validateCodingLimit(
119
+ "maxPendingRequests",
120
+ options?.maxPendingRequests ?? DEFAULT_MAX_LSP_PENDING_REQUESTS,
121
+ HARD_MAX_LSP_PENDING_REQUESTS,
122
+ ),
123
+ maxResultsPerQuery: validateCodingLimit(
124
+ "maxResultsPerQuery",
125
+ options?.maxResultsPerQuery ?? DEFAULT_MAX_LSP_RESULTS_PER_QUERY,
126
+ HARD_MAX_LSP_RESULTS_PER_QUERY,
127
+ ),
128
+ requestTimeoutMs: validateCodingLimit(
129
+ "requestTimeoutMs",
130
+ options?.requestTimeoutMs ?? DEFAULT_MAX_LSP_TIMEOUT_MS,
131
+ HARD_MAX_LSP_TIMEOUT_MS,
132
+ ),
133
+ maxServers: validateCodingLimit("maxServers", options?.maxServers ?? DEFAULT_MAX_LSP_SERVERS, HARD_MAX_LSP_SERVERS),
134
+ maxRestartsPerServer: validateCodingLimit(
135
+ "maxRestartsPerServer",
136
+ options?.maxRestartsPerServer ?? LSP_RESTARTS_PER_SERVER,
137
+ LSP_RESTARTS_PER_SERVER,
138
+ ),
139
+ };
140
+ }
141
+
142
+ export interface LanguageIntelligence {
143
+ workspaceSymbols(query: string, opts?: { signal?: AbortSignal }): Promise<readonly LanguageSymbol[]>;
144
+ definitions(loc: LanguageLocation, opts?: { signal?: AbortSignal }): Promise<readonly LanguageLocation[]>;
145
+ references(loc: LanguageLocation, opts?: { signal?: AbortSignal }): Promise<readonly LanguageLocation[]>;
146
+ diagnostics(file?: string, opts?: { signal?: AbortSignal }): Promise<readonly LanguageDiagnostic[]>;
147
+ hover(loc: LanguageLocation, opts?: { signal?: AbortSignal }): Promise<{ text: string } | undefined>;
148
+ rename(loc: LanguageLocation & { newName: string }, opts?: { signal?: AbortSignal }): Promise<LanguageWorkspaceEdit>;
149
+ /**
150
+ * Re-sync one file after an external edit: full-content didChange with a
151
+ * monotonic version. No-op when no host server handles the file's language
152
+ * (throws ERR_PRISM_LSP_UNSUPPORTED only when servers exist but none match).
153
+ */
154
+ syncDocument(file: string, opts?: { signal?: AbortSignal }): Promise<{ version: number }>;
155
+ /**
156
+ * Bounded push/pull diagnostic refresh for changed files. Generations are
157
+ * document versions; stale-version results never overwrite newer views.
158
+ */
159
+ diagnosticDelta(request: LanguageDiagnosticDeltaRequest, opts?: { signal?: AbortSignal }): Promise<LanguageDiagnosticDeltaResult>;
160
+ dispose(): Promise<void>;
161
+ }
162
+
163
+ export interface LanguageDiagnosticDeltaRequest {
164
+ /** Workspace-relative files to refresh; bounded per request. */
165
+ readonly files: readonly string[];
166
+ /** Prior normalized view per file (generation + diagnostics); optional. */
167
+ readonly previous?: Readonly<Record<string, LanguageFileDiagnostics>>;
168
+ }
169
+
170
+ export interface LanguageFileDiagnostics {
171
+ readonly generation: number;
172
+ readonly diagnostics: readonly import("../diagnostics.js").NormalizedDiagnostic[];
173
+ }
174
+
175
+ export interface LanguageDiagnosticDeltaResult {
176
+ /** Per-file delta; stale files (previous generation >= new generation) are omitted. */
177
+ readonly files: Record<string, import("../diagnostics.js").DiagnosticDelta>;
178
+ readonly generation: number;
179
+ }
180
+
181
+ export interface CreateLanguageIntelligenceOptions {
182
+ readonly workspaceRoot: string;
183
+ readonly servers: Readonly<Record<string, LanguageServerSpec>>;
184
+ readonly limits?: LanguageIntelligenceLimits;
185
+ readonly policy?: ExecutionPolicy;
186
+ // processes?: ProcessSessions — available after Task 3; host may wire later.
187
+ }
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Consumer-gated coding lifecycle event vocabulary (Phase 10 Task 1 freeze).
3
+ *
4
+ * Ships only event kinds with a consumer in 0.0.27 (ACP mapper and/or host
5
+ * `CodingLifecycleEmitter` callback). Deferred kinds — check_started/finished,
6
+ * task_created/completed, compaction_started/finished — MUST NOT be added here
7
+ * until a consumer exists (scripts/phase10-freeze-manifest.json lifecycle.deferredEvents).
8
+ *
9
+ * Types only: no runtime code, so a tool that type-imports the event it emits does not pull the
10
+ * limits or the emitter (those live in `lifecycle.ts`, which re-exports this module).
11
+ */
12
+ import type { AgentFinishReason, AgentRunStatus, RunLimitName } from "@arnilo/prism";
13
+ import type { CodingProcessEvent } from "./process/types.js";
14
+
15
+ export type FileChangeOp = "write" | "edit" | "delete" | "move";
16
+
17
+ export interface FileChangedEvent {
18
+ readonly type: "file_changed";
19
+ /** Workspace-relative or policy-checked absolute path. Never a raw file body. */
20
+ readonly path: string;
21
+ readonly op: FileChangeOp;
22
+ readonly toolCallId?: string;
23
+ }
24
+
25
+ export interface WorktreeChangedEvent {
26
+ readonly type: "worktree_changed";
27
+ readonly action: "add" | "remove";
28
+ readonly path: string;
29
+ readonly toolCallId?: string;
30
+ }
31
+
32
+ export interface PermissionDeniedEvent {
33
+ readonly type: "permission_denied";
34
+ /** Policy decision reason. Never includes raw tool arguments. */
35
+ readonly reason: string;
36
+ readonly toolName: string;
37
+ readonly toolCallId?: string;
38
+ readonly approvalId?: string;
39
+ }
40
+
41
+ export interface ConfigurationChangedEvent {
42
+ readonly type: "configuration_changed";
43
+ /** Changed config keys only; values never travel in the event. */
44
+ readonly keys: readonly string[];
45
+ }
46
+
47
+ export interface PlanChangedEvent {
48
+ readonly type: "plan_changed";
49
+ /** Workspace-relative plan path; doubles as the plan id on the ACP wire. */
50
+ readonly planPath: string;
51
+ /** Complete todo list at this point (same shape as `CodingTodoItem`). */
52
+ readonly todos: readonly { readonly id: string; readonly text: string; readonly done: boolean }[];
53
+ }
54
+
55
+ export interface PlanRemovedEvent {
56
+ readonly type: "plan_removed";
57
+ /** Workspace-relative plan path; doubles as the plan id on the ACP wire. */
58
+ readonly planPath: string;
59
+ }
60
+
61
+ /** Redacted supervisor milestone. Never includes child input, output, or path. */
62
+ export interface SubagentStartedEvent {
63
+ readonly type: "subagent_started";
64
+ readonly childId: string;
65
+ readonly delegationId: string;
66
+ readonly depth: number;
67
+ }
68
+
69
+ /**
70
+ * Redacted child failure attribution. Carried on `subagent_stopped` only when the observer opts into
71
+ * `includeFailure`, and only for the stop an error produced. Never carries child input, output, paths,
72
+ * tool arguments, or tool results.
73
+ */
74
+ export interface SubagentFailure {
75
+ /** Supervisor-redacted terminal reason, truncated to `DEFAULT_LIFECYCLE_MAX_REASON_BYTES`. */
76
+ readonly reason: string;
77
+ /** Fired run-limit axis when the child died on a configured ceiling; counts only, no child text. */
78
+ readonly limit?: RunLimitName;
79
+ /** The child's own terminal stop reason, when the run reported one. */
80
+ readonly stopReason?: AgentFinishReason;
81
+ }
82
+
83
+ /** Local mirror of the supervisor's per-child outcome vocabulary (no core-supervisor type import). */
84
+ export type SubagentRecoveryOutcome = "idle" | "running" | AgentRunStatus | "rejected";
85
+
86
+ /**
87
+ * Per-child recovery counters read from `summary()` at stop. Carried on `subagent_stopped` only when
88
+ * the observer opts into `includeRecovery` and the source exposes `summary`; integers and enums only.
89
+ */
90
+ export interface SubagentRecovery {
91
+ readonly attempts: number;
92
+ readonly retries: number;
93
+ readonly failures: number;
94
+ readonly failureRadius: number;
95
+ /** `idle` before the first delegation, `running` while one is live, else the terminal outcome. */
96
+ readonly outcome: SubagentRecoveryOutcome;
97
+ }
98
+
99
+ /** Terminal redacted supervisor milestone. */
100
+ export interface SubagentStoppedEvent {
101
+ readonly type: "subagent_stopped";
102
+ readonly childId: string;
103
+ readonly delegationId: string;
104
+ readonly depth: number;
105
+ readonly status: AgentRunStatus;
106
+ /** Present only when the observer's `includeFailure` is on and the stop followed a `child_failed`. */
107
+ readonly failure?: SubagentFailure;
108
+ /** Present only when the observer's `includeRecovery` is on and the source exposes `summary`. */
109
+ readonly recovery?: SubagentRecovery;
110
+ }
111
+
112
+ export type CodingLifecycleEvent =
113
+ | CodingProcessEvent
114
+ | FileChangedEvent
115
+ | WorktreeChangedEvent
116
+ | PermissionDeniedEvent
117
+ | ConfigurationChangedEvent
118
+ | PlanChangedEvent
119
+ | PlanRemovedEvent
120
+ | SubagentStartedEvent
121
+ | SubagentStoppedEvent;
@@ -0,0 +1,166 @@
1
+ /**
2
+ * Coding lifecycle limits and the consumer-gated emitter (Phase 10 Task 1 freeze).
3
+ *
4
+ * The event vocabulary itself is `./lifecycle-events.js`; this module owns the byte/count caps and
5
+ * the emitter that enforces them, and re-exports the vocabulary so existing imports keep working.
6
+ */
7
+ import type { CodingLifecycleEvent } from "./lifecycle-events.js";
8
+ import { validateCodingLimit } from "./limits.js";
9
+
10
+ export type {
11
+ CodingLifecycleEvent,
12
+ ConfigurationChangedEvent,
13
+ FileChangedEvent,
14
+ FileChangeOp,
15
+ PermissionDeniedEvent,
16
+ PlanChangedEvent,
17
+ PlanRemovedEvent,
18
+ SubagentFailure,
19
+ SubagentRecovery,
20
+ SubagentRecoveryOutcome,
21
+ SubagentStartedEvent,
22
+ SubagentStoppedEvent,
23
+ WorktreeChangedEvent,
24
+ } from "./lifecycle-events.js";
25
+
26
+ export const DEFAULT_LIFECYCLE_MAX_EVENT_BYTES = 16_384;
27
+ export const HARD_LIFECYCLE_MAX_EVENT_BYTES = 65_536;
28
+ export const DEFAULT_LIFECYCLE_MAX_PATH_BYTES = 4_096;
29
+ export const HARD_LIFECYCLE_MAX_PATH_BYTES = 16_384;
30
+ export const DEFAULT_LIFECYCLE_MAX_REASON_BYTES = 1_024;
31
+ export const HARD_LIFECYCLE_MAX_REASON_BYTES = 16_384;
32
+ export const DEFAULT_LIFECYCLE_MAX_TOOL_NAME_BYTES = 256;
33
+ export const HARD_LIFECYCLE_MAX_TOOL_NAME_BYTES = 4_096;
34
+ export const DEFAULT_LIFECYCLE_MAX_CONFIG_KEYS = 64;
35
+ export const HARD_LIFECYCLE_MAX_CONFIG_KEYS = 256;
36
+
37
+ export interface CodingLifecycleLimits {
38
+ readonly maxEventBytes?: number;
39
+ readonly maxPathBytes?: number;
40
+ readonly maxReasonBytes?: number;
41
+ readonly maxToolNameBytes?: number;
42
+ readonly maxConfigKeys?: number;
43
+ }
44
+
45
+ export interface ResolvedCodingLifecycleLimits {
46
+ readonly maxEventBytes: number;
47
+ readonly maxPathBytes: number;
48
+ readonly maxReasonBytes: number;
49
+ readonly maxToolNameBytes: number;
50
+ readonly maxConfigKeys: number;
51
+ }
52
+
53
+ export class CodingLifecycleError extends Error {
54
+ readonly code = "ERR_PRISM_LIFECYCLE_LIMIT";
55
+ constructor(message: string) {
56
+ super(message);
57
+ this.name = "CodingLifecycleError";
58
+ }
59
+ }
60
+
61
+ function validate(name: string, value: number, hard: number): number {
62
+ try {
63
+ return validateCodingLimit(name, value, hard);
64
+ } catch (error) {
65
+ throw new CodingLifecycleError(error instanceof Error ? error.message : String(error));
66
+ }
67
+ }
68
+
69
+ export function resolveCodingLifecycleLimits(limits?: CodingLifecycleLimits): ResolvedCodingLifecycleLimits {
70
+ return {
71
+ maxEventBytes: validate("maxEventBytes", limits?.maxEventBytes ?? DEFAULT_LIFECYCLE_MAX_EVENT_BYTES, HARD_LIFECYCLE_MAX_EVENT_BYTES),
72
+ maxPathBytes: validate("maxPathBytes", limits?.maxPathBytes ?? DEFAULT_LIFECYCLE_MAX_PATH_BYTES, HARD_LIFECYCLE_MAX_PATH_BYTES),
73
+ maxReasonBytes: validate(
74
+ "maxReasonBytes",
75
+ limits?.maxReasonBytes ?? DEFAULT_LIFECYCLE_MAX_REASON_BYTES,
76
+ HARD_LIFECYCLE_MAX_REASON_BYTES,
77
+ ),
78
+ maxToolNameBytes: validate(
79
+ "maxToolNameBytes",
80
+ limits?.maxToolNameBytes ?? DEFAULT_LIFECYCLE_MAX_TOOL_NAME_BYTES,
81
+ HARD_LIFECYCLE_MAX_TOOL_NAME_BYTES,
82
+ ),
83
+ maxConfigKeys: validate("maxConfigKeys", limits?.maxConfigKeys ?? DEFAULT_LIFECYCLE_MAX_CONFIG_KEYS, HARD_LIFECYCLE_MAX_CONFIG_KEYS),
84
+ };
85
+ }
86
+
87
+ /** Frozen shipped kinds: the six CodingProcessEvent kinds plus supported coding lifecycle kinds. */
88
+ const FROZEN_EVENT_TYPES = new Set<string>([
89
+ "process_started",
90
+ "process_exited",
91
+ "process_killed",
92
+ "process_released",
93
+ "process_expired",
94
+ "process_unknown",
95
+ "file_changed",
96
+ "worktree_changed",
97
+ "permission_denied",
98
+ "configuration_changed",
99
+ "plan_changed",
100
+ "plan_removed",
101
+ "subagent_started",
102
+ "subagent_stopped",
103
+ ]);
104
+
105
+ export interface CodingLifecycleEmitter {
106
+ /**
107
+ * Delivers the event to every registered listener. Returns true when at least one
108
+ * listener received it. Drops (returns false) without throwing for unknown kinds,
109
+ * oversized events, or when no listener is registered, so producer success paths
110
+ * never break on telemetry.
111
+ */
112
+ emit(event: CodingLifecycleEvent): boolean;
113
+ /** Registers a listener; the returned function unregisters it. */
114
+ on(listener: (event: CodingLifecycleEvent) => void): () => void;
115
+ }
116
+
117
+ export interface CreateCodingLifecycleEmitterOptions {
118
+ readonly limits?: CodingLifecycleLimits;
119
+ /** Convenience initial listener, equivalent to `on`. */
120
+ readonly onEvent?: (event: CodingLifecycleEvent) => void;
121
+ }
122
+
123
+ export function createCodingLifecycleEmitter(options: CreateCodingLifecycleEmitterOptions = {}): CodingLifecycleEmitter {
124
+ const limits = resolveCodingLifecycleLimits(options.limits);
125
+ const listeners = new Set<(event: CodingLifecycleEvent) => void>();
126
+ if (options.onEvent) listeners.add(options.onEvent);
127
+
128
+ return {
129
+ emit(event) {
130
+ if (!event || typeof event !== "object" || !FROZEN_EVENT_TYPES.has(event.type)) return false;
131
+ if (Buffer.byteLength(JSON.stringify(event), "utf8") > limits.maxEventBytes) return false;
132
+ switch (event.type) {
133
+ case "file_changed":
134
+ case "worktree_changed":
135
+ if (Buffer.byteLength(event.path, "utf8") > limits.maxPathBytes) return false;
136
+ break;
137
+ case "permission_denied":
138
+ if (Buffer.byteLength(event.reason, "utf8") > limits.maxReasonBytes) return false;
139
+ if (Buffer.byteLength(event.toolName, "utf8") > limits.maxToolNameBytes) return false;
140
+ break;
141
+ case "configuration_changed":
142
+ if (event.keys.length > limits.maxConfigKeys) return false;
143
+ break;
144
+ default:
145
+ break;
146
+ }
147
+ if (listeners.size === 0) return false;
148
+ for (const listener of [...listeners]) {
149
+ // A consumer that throws must not break the producer's success path (a worktree or file is
150
+ // already changed by the time we get here); the rest of the listeners still receive it.
151
+ try {
152
+ listener(event);
153
+ } catch {
154
+ // swallowed on purpose: telemetry never fails the operation that produced it
155
+ }
156
+ }
157
+ return true;
158
+ },
159
+ on(listener) {
160
+ listeners.add(listener);
161
+ return () => {
162
+ listeners.delete(listener);
163
+ };
164
+ },
165
+ };
166
+ }
@@ -0,0 +1,214 @@
1
+ export const DEFAULT_MAX_LINES = 2_000;
2
+ export const HARD_MAX_LINES = 100_000;
3
+ export const DEFAULT_MAX_BYTES = 50 * 1024;
4
+ export const HARD_MAX_BYTES = 1024 * 1024;
5
+
6
+ export const DEFAULT_MAX_TEXT_SCAN_BYTES = 64 * 1024 * 1024;
7
+ export const HARD_MAX_TEXT_SCAN_BYTES = 1024 * 1024 * 1024;
8
+ export const DEFAULT_MAX_IMAGE_BYTES = 10_000_000;
9
+ export const HARD_MAX_IMAGE_BYTES = 32 * 1024 * 1024;
10
+
11
+ export const DEFAULT_MAX_WRITE_BYTES = 8 * 1024 * 1024;
12
+ export const HARD_MAX_WRITE_BYTES = 64 * 1024 * 1024;
13
+ export const DEFAULT_MAX_EDIT_FILE_BYTES = 8 * 1024 * 1024;
14
+ export const HARD_MAX_EDIT_FILE_BYTES = 64 * 1024 * 1024;
15
+ export const DEFAULT_MAX_EDIT_INPUT_BYTES = 2 * 1024 * 1024;
16
+ export const HARD_MAX_EDIT_INPUT_BYTES = 16 * 1024 * 1024;
17
+ export const DEFAULT_MAX_EDITS = 100;
18
+ export const HARD_MAX_EDITS = 1_000;
19
+
20
+ export const DEFAULT_SHELL_TIMEOUT_SECONDS = 600;
21
+ export const HARD_SHELL_TIMEOUT_SECONDS = 3_600;
22
+ export const DEFAULT_MAX_TOTAL_OUTPUT_BYTES = 64 * 1024 * 1024;
23
+ export const HARD_MAX_TOTAL_OUTPUT_BYTES = 1024 * 1024 * 1024;
24
+
25
+ /** Repository list/search defaults and hard caps (Phase 4 / review-coverage). */
26
+ export const DEFAULT_MAX_REPO_DEPTH = 32;
27
+ export const HARD_MAX_REPO_DEPTH = 128;
28
+ export const DEFAULT_MAX_REPO_ENTRIES = 10_000;
29
+ export const HARD_MAX_REPO_ENTRIES = 100_000;
30
+ export const DEFAULT_MAX_REPO_FILES = 10_000;
31
+ export const HARD_MAX_REPO_FILES = 100_000;
32
+ export const DEFAULT_MAX_REPO_RESULTS = 1_000;
33
+ export const HARD_MAX_REPO_RESULTS = 10_000;
34
+ export const DEFAULT_MAX_REPO_CONCURRENCY = 8;
35
+ export const HARD_MAX_REPO_CONCURRENCY = 32;
36
+
37
+ export const DEFAULT_MAX_SEARCH_SCAN_BYTES = 64 * 1024 * 1024;
38
+ export const HARD_MAX_SEARCH_SCAN_BYTES = 1024 * 1024 * 1024;
39
+ export const DEFAULT_MAX_SEARCH_FILE_BYTES = 8 * 1024 * 1024;
40
+ export const HARD_MAX_SEARCH_FILE_BYTES = 64 * 1024 * 1024;
41
+ export const DEFAULT_MAX_SEARCH_MATCHES = 1_000;
42
+ export const HARD_MAX_SEARCH_MATCHES = 10_000;
43
+ export const DEFAULT_MAX_SEARCH_PATTERN_BYTES = 512;
44
+ export const HARD_MAX_SEARCH_PATTERN_BYTES = 4_096;
45
+ export const DEFAULT_MAX_SEARCH_LINE_BYTES = 50 * 1024;
46
+ export const HARD_MAX_SEARCH_LINE_BYTES = 1024 * 1024;
47
+ export const DEFAULT_MAX_SEARCH_CONTEXT_LINES = 5;
48
+ export const HARD_MAX_SEARCH_CONTEXT_LINES = 20;
49
+ export const DEFAULT_MAX_SEARCH_TIME_MS = 30_000;
50
+ export const HARD_MAX_SEARCH_TIME_MS = 300_000;
51
+ export const DEFAULT_BINARY_SNIFF_BYTES = 8_192;
52
+
53
+ /** Structured Git / named-check / PR-handoff defaults and hard caps (Phase 4). */
54
+ export const DEFAULT_MAX_GIT_PATHS = 1_000;
55
+ export const HARD_MAX_GIT_PATHS = 10_000;
56
+ export const DEFAULT_MAX_GIT_REF_BYTES = 1_024;
57
+ export const HARD_MAX_GIT_REF_BYTES = 4_096;
58
+ export const DEFAULT_MAX_GIT_MESSAGE_BYTES = 64 * 1024;
59
+ export const HARD_MAX_GIT_MESSAGE_BYTES = 256 * 1024;
60
+ export const DEFAULT_MAX_GIT_OUTPUT_BYTES = 4 * 1024 * 1024;
61
+ export const HARD_MAX_GIT_OUTPUT_BYTES = 64 * 1024 * 1024;
62
+ /** Phase 9 freeze: `git ls-files` stdout cap for ignore-aware enumeration. */
63
+ export const DEFAULT_MAX_LS_FILES_OUTPUT_BYTES = 8 * 1024 * 1024;
64
+ export const HARD_MAX_LS_FILES_OUTPUT_BYTES = 64 * 1024 * 1024;
65
+ export const DEFAULT_MAX_GIT_DIFF_LINES = 10_000;
66
+ export const HARD_MAX_GIT_DIFF_LINES = 100_000;
67
+ export const DEFAULT_MAX_GIT_CHANGED_FILES = 1_000;
68
+ export const HARD_MAX_GIT_CHANGED_FILES = 10_000;
69
+ export const DEFAULT_MAX_GIT_PATCH_BYTES = 16 * 1024 * 1024;
70
+ export const HARD_MAX_GIT_PATCH_BYTES = 64 * 1024 * 1024;
71
+ export const DEFAULT_MAX_GIT_WORKTREES = 4;
72
+ export const HARD_MAX_GIT_WORKTREES = 16;
73
+ export const DEFAULT_GIT_TIMEOUT_MS = 120_000;
74
+ export const HARD_GIT_TIMEOUT_MS = 600_000;
75
+
76
+ export const DEFAULT_MAX_CHECK_NAMES = 8;
77
+ export const HARD_MAX_CHECK_NAMES = 32;
78
+ export const DEFAULT_MAX_CHECK_CONCURRENCY = 1;
79
+ export const HARD_MAX_CHECK_CONCURRENCY = 4;
80
+ export const DEFAULT_CHECK_TIMEOUT_MS = 10 * 60_000;
81
+ export const HARD_CHECK_TIMEOUT_MS = 60 * 60_000;
82
+ export const DEFAULT_MAX_CHECK_DIAGNOSTIC_LINES = 2_000;
83
+ export const HARD_MAX_CHECK_DIAGNOSTIC_LINES = 100_000;
84
+ export const DEFAULT_MAX_CHECK_OUTPUT_BYTES = 4 * 1024 * 1024;
85
+ export const HARD_MAX_CHECK_OUTPUT_BYTES = 64 * 1024 * 1024;
86
+
87
+ export const DEFAULT_MAX_PR_HANDOFF_BYTES = 256 * 1024;
88
+ export const HARD_MAX_PR_HANDOFF_BYTES = 1024 * 1024;
89
+ export const DEFAULT_MAX_PR_COMMITS = 100;
90
+ export const HARD_MAX_PR_COMMITS = 1_000;
91
+
92
+ /** Durable coding plan / checkpoint metadata defaults and hard caps (Phase 4 Task 4). */
93
+ export const DEFAULT_MAX_PLAN_BYTES = 256 * 1024;
94
+ export const HARD_MAX_PLAN_BYTES = 1024 * 1024;
95
+ export const DEFAULT_MAX_TODOS = 1_000;
96
+ export const HARD_MAX_TODOS = 10_000;
97
+ export const DEFAULT_MAX_TODO_TEXT_BYTES = 512;
98
+ export const HARD_MAX_TODO_TEXT_BYTES = 4_096;
99
+ export const DEFAULT_MAX_CODING_ARTIFACTS = 16;
100
+ export const HARD_MAX_CODING_ARTIFACTS = 64;
101
+ export const DEFAULT_MAX_CODING_ARTIFACT_BYTES = 256 * 1024 * 1024;
102
+ export const HARD_MAX_CODING_ARTIFACT_BYTES = 2 * 1024 * 1024 * 1024;
103
+ export const DEFAULT_MAX_CHECK_SUMMARY_BYTES = 1_024;
104
+ export const HARD_MAX_CHECK_SUMMARY_BYTES = 8_192;
105
+ export const DEFAULT_MAX_CODING_CHECKPOINT_BYTES = 64 * 1024;
106
+ export const HARD_MAX_CODING_CHECKPOINT_BYTES = 512 * 1024;
107
+
108
+ /** Phase 9 freeze: language-intelligence / LSP client caps. */
109
+ export const DEFAULT_MAX_LSP_MESSAGE_BYTES = 4 * 1024 * 1024;
110
+ export const HARD_MAX_LSP_MESSAGE_BYTES = 32 * 1024 * 1024;
111
+ export const DEFAULT_MAX_LSP_DIAGNOSTICS_PER_FILE = 200;
112
+ export const HARD_MAX_LSP_DIAGNOSTICS_PER_FILE = 1_000;
113
+ export const DEFAULT_MAX_LSP_PENDING_REQUESTS = 32;
114
+ export const HARD_MAX_LSP_PENDING_REQUESTS = 128;
115
+ export const DEFAULT_MAX_LSP_RESULTS_PER_QUERY = 500;
116
+ export const HARD_MAX_LSP_RESULTS_PER_QUERY = 5_000;
117
+ export const DEFAULT_MAX_LSP_TIMEOUT_MS = 30_000;
118
+ export const HARD_MAX_LSP_TIMEOUT_MS = 120_000;
119
+ export const DEFAULT_MAX_LSP_SERVERS = 4;
120
+ export const HARD_MAX_LSP_SERVERS = 8;
121
+ /** Freeze: restart budget is fixed at 3 (not host-configurable above). */
122
+ export const LSP_RESTARTS_PER_SERVER = 3;
123
+
124
+ /** Phase 9 freeze: managed process-session caps. */
125
+ export const DEFAULT_MAX_PROCESS_SESSIONS = 8;
126
+ export const HARD_MAX_PROCESS_SESSIONS = 32;
127
+ export const DEFAULT_MAX_PROCESS_INPUT_BYTES = 64 * 1024;
128
+ export const HARD_MAX_PROCESS_INPUT_BYTES = 1024 * 1024;
129
+ export const DEFAULT_MAX_PROCESS_LIFETIME_MS = 4 * 60 * 60 * 1000;
130
+ export const HARD_MAX_PROCESS_LIFETIME_MS = 24 * 60 * 60 * 1000;
131
+ export const DEFAULT_MAX_PROCESS_OUTPUT_CHUNK_BYTES = 50 * 1024;
132
+ export const HARD_MAX_PROCESS_OUTPUT_CHUNK_BYTES = 1024 * 1024;
133
+ /** Total output reuses existing accumulator ceilings (64 MiB / 1 GiB). */
134
+ export const DEFAULT_MAX_PROCESS_TOTAL_OUTPUT_BYTES = DEFAULT_MAX_TOTAL_OUTPUT_BYTES;
135
+ export const HARD_MAX_PROCESS_TOTAL_OUTPUT_BYTES = HARD_MAX_TOTAL_OUTPUT_BYTES;
136
+
137
+ /** Phase 26 Task 0 freeze: host-selected PTY terminal caps (interactive sessions). */
138
+ export const DEFAULT_MAX_TERMINAL_COLUMNS = 120;
139
+ export const HARD_MAX_TERMINAL_COLUMNS = 500;
140
+ export const DEFAULT_MAX_TERMINAL_ROWS = 40;
141
+ export const HARD_MAX_TERMINAL_ROWS = 200;
142
+ export const DEFAULT_MAX_TERMINAL_TERM_BYTES = 64;
143
+ export const HARD_MAX_TERMINAL_TERM_BYTES = 256;
144
+ export const DEFAULT_MAX_TERMINAL_RESIZES_PER_MINUTE = 60;
145
+ export const HARD_MAX_TERMINAL_RESIZES_PER_MINUTE = 600;
146
+ export const DEFAULT_MAX_PTY_ATTACH_TIMEOUT_MS = 30_000;
147
+ export const HARD_MAX_PTY_ATTACH_TIMEOUT_MS = 120_000;
148
+ export const DEFAULT_MAX_PTY_BACKEND_METADATA_BYTES = 4 * 1024;
149
+ export const HARD_MAX_PTY_BACKEND_METADATA_BYTES = 16 * 1024;
150
+
151
+ /** Phase 26 Task 0 freeze: host index caps (indexed_literal/semantic grep). */
152
+ export const DEFAULT_MAX_INDEX_UPDATE_FILES = 1_000;
153
+ export const HARD_MAX_INDEX_UPDATE_FILES = 10_000;
154
+ export const DEFAULT_MAX_INDEX_UPDATE_BYTES = 16 * 1024 * 1024;
155
+ export const HARD_MAX_INDEX_UPDATE_BYTES = 64 * 1024 * 1024;
156
+ /** Index result cap reuses the repository results caps (1000 / 10000). */
157
+ export const DEFAULT_MAX_INDEX_SNIPPET_BYTES = 4 * 1024;
158
+ export const HARD_MAX_INDEX_SNIPPET_BYTES = 16 * 1024;
159
+ export const DEFAULT_MAX_INDEX_STALE_MAX_AGE_MS = 60_000;
160
+ export const HARD_MAX_INDEX_STALE_MAX_AGE_MS = 300_000;
161
+ export const DEFAULT_MAX_INDEX_QUERY_TIMEOUT_MS = 30_000;
162
+ export const HARD_MAX_INDEX_QUERY_TIMEOUT_MS = 120_000;
163
+
164
+ /** Diagnostic caps shared by `coding_check` deltas and the `diagnostics` tool. */
165
+ export const DEFAULT_MAX_REVIEW_DIAGNOSTICS = 500;
166
+ export const HARD_MAX_REVIEW_DIAGNOSTICS = 5_000;
167
+ export const DEFAULT_MAX_DIAGNOSTIC_MESSAGE_BYTES = 4 * 1024;
168
+ export const HARD_MAX_DIAGNOSTIC_MESSAGE_BYTES = 16 * 1024;
169
+
170
+ /** Forge (GitHub adapter) defaults and hard caps (Phase 9 Task 5). */
171
+ export const DEFAULT_MAX_FORGE_PAGES_PER_OPERATION = 10;
172
+ export const HARD_MAX_FORGE_PAGES_PER_OPERATION = 100;
173
+ export const DEFAULT_MAX_FORGE_PAYLOAD_BYTES = 1024 * 1024;
174
+ export const HARD_MAX_FORGE_PAYLOAD_BYTES = 8 * 1024 * 1024;
175
+ export const DEFAULT_MAX_FORGE_COMMENTS_PER_REVIEW = 100;
176
+ export const HARD_MAX_FORGE_COMMENTS_PER_REVIEW = 1000;
177
+ export const DEFAULT_MAX_FORGE_REQUEST_CONCURRENCY = 4;
178
+ export const HARD_MAX_FORGE_REQUEST_CONCURRENCY = 8;
179
+ export const DEFAULT_MAX_FORGE_REQUEST_TIMEOUT_MS = 30_000;
180
+ export const HARD_MAX_FORGE_REQUEST_TIMEOUT_MS = 120_000;
181
+
182
+ /** Plan 165 Task 6: `workspace.diff` bounds (files listed, bytes of one file's diff). */
183
+ export const DEFAULT_MAX_WORKSPACE_DIFF_FILES = 200;
184
+ export const HARD_MAX_WORKSPACE_DIFF_FILES = 2_000;
185
+ export const DEFAULT_MAX_WORKSPACE_DIFF_BYTES = 1024 * 1024;
186
+ export const HARD_MAX_WORKSPACE_DIFF_BYTES = 8 * 1024 * 1024;
187
+
188
+ /** Plan 026 Task 5: durable process/ACP recovery caps (frozen in the phase26 manifest). */
189
+ export const DEFAULT_MAX_RECOVERY_RECORDS = 32;
190
+ export const HARD_MAX_RECOVERY_RECORDS = 128;
191
+ export const DEFAULT_MAX_RECOVERY_LEASE_TTL_MS = 30_000;
192
+ export const HARD_MAX_RECOVERY_LEASE_TTL_MS = 300_000;
193
+ export const DEFAULT_MAX_RECOVERY_ATTACH_TIMEOUT_MS = 30_000;
194
+ export const HARD_MAX_RECOVERY_ATTACH_TIMEOUT_MS = 120_000;
195
+ export const DEFAULT_MAX_RECOVERY_BACKEND_REF_BYTES = 1024;
196
+ export const HARD_MAX_RECOVERY_BACKEND_REF_BYTES = 4 * 1024;
197
+ export const DEFAULT_MAX_RECOVERY_RECORD_BYTES = 64 * 1024;
198
+ export const HARD_MAX_RECOVERY_RECORD_BYTES = 256 * 1024;
199
+
200
+ /** Validate one configurable coding resource limit. Invalid values fail instead of clamping. */
201
+ export function validateCodingLimit(name: string, value: number, hardCap: number): number {
202
+ if (!Number.isSafeInteger(value) || value < 1 || value > hardCap) {
203
+ throw new Error(`${name} must be a positive safe integer at most ${hardCap}`);
204
+ }
205
+ return value;
206
+ }
207
+
208
+ /** Validate a non-negative integer limit (0 allowed), still capped. */
209
+ export function validateCodingLimitAllowZero(name: string, value: number, hardCap: number): number {
210
+ if (!Number.isSafeInteger(value) || value < 0 || value > hardCap) {
211
+ throw new Error(`${name} must be a non-negative safe integer at most ${hardCap}`);
212
+ }
213
+ return value;
214
+ }