indusagi-coding-agent 0.2.4 → 0.2.8

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 (267) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/LICENSE +661 -0
  3. package/README.md +99 -1
  4. package/dist/entry.js +13551 -23107
  5. package/dist/guardrails.js +822 -8248
  6. package/dist/index.js +12547 -22190
  7. package/package.json +8 -7
  8. package/dist/types/addons/addons.test.d.ts +0 -21
  9. package/dist/types/addons/contract.d.ts +0 -640
  10. package/dist/types/addons/dispatch/event-dispatcher.d.ts +0 -140
  11. package/dist/types/addons/dispatch/index.d.ts +0 -23
  12. package/dist/types/addons/dispatch/tool-interceptor.d.ts +0 -128
  13. package/dist/types/addons/host.d.ts +0 -246
  14. package/dist/types/addons/index.d.ts +0 -51
  15. package/dist/types/addons/manifest.d.ts +0 -56
  16. package/dist/types/addons/sandbox.d.ts +0 -103
  17. package/dist/types/addons/surface.d.ts +0 -42
  18. package/dist/types/boot/auth-vault.d.ts +0 -29
  19. package/dist/types/boot/boot.d.ts +0 -26
  20. package/dist/types/boot/boot.test.d.ts +0 -15
  21. package/dist/types/boot/contract.d.ts +0 -236
  22. package/dist/types/boot/heap.d.ts +0 -31
  23. package/dist/types/boot/index.d.ts +0 -20
  24. package/dist/types/boot/invocation.d.ts +0 -40
  25. package/dist/types/boot/invocation.test.d.ts +0 -8
  26. package/dist/types/boot/runners/addon-wiring.d.ts +0 -103
  27. package/dist/types/boot/runners/addon-wiring.test.d.ts +0 -19
  28. package/dist/types/boot/runners/checkpoint.d.ts +0 -133
  29. package/dist/types/boot/runners/checkpoint.test.d.ts +0 -12
  30. package/dist/types/boot/runners/delegate-runner.d.ts +0 -109
  31. package/dist/types/boot/runners/delegate-runner.test.d.ts +0 -13
  32. package/dist/types/boot/runners/index.d.ts +0 -13
  33. package/dist/types/boot/runners/link-runner.d.ts +0 -20
  34. package/dist/types/boot/runners/memdir.d.ts +0 -103
  35. package/dist/types/boot/runners/memdir.test.d.ts +0 -12
  36. package/dist/types/boot/runners/oneshot-runner.d.ts +0 -19
  37. package/dist/types/boot/runners/read-state.d.ts +0 -82
  38. package/dist/types/boot/runners/read-state.test.d.ts +0 -10
  39. package/dist/types/boot/runners/registry.d.ts +0 -30
  40. package/dist/types/boot/runners/repl-runner.d.ts +0 -19
  41. package/dist/types/boot/runners/server-mode.d.ts +0 -71
  42. package/dist/types/boot/runners/session-persist.test.d.ts +0 -10
  43. package/dist/types/boot/runners/session.d.ts +0 -88
  44. package/dist/types/boot/runners/session.test.d.ts +0 -15
  45. package/dist/types/boot/server-token.d.ts +0 -97
  46. package/dist/types/boot/stages.d.ts +0 -92
  47. package/dist/types/boot/upgrade/apply.d.ts +0 -45
  48. package/dist/types/boot/upgrade/index.d.ts +0 -13
  49. package/dist/types/boot/upgrade/upgrades.d.ts +0 -126
  50. package/dist/types/briefing/briefing.test.d.ts +0 -15
  51. package/dist/types/briefing/compose.d.ts +0 -37
  52. package/dist/types/briefing/context-docs.d.ts +0 -38
  53. package/dist/types/briefing/context-docs.test.d.ts +0 -18
  54. package/dist/types/briefing/contract.d.ts +0 -686
  55. package/dist/types/briefing/index.d.ts +0 -29
  56. package/dist/types/briefing/macros.d.ts +0 -206
  57. package/dist/types/briefing/skills.d.ts +0 -67
  58. package/dist/types/capability-deck/bridge-ledger/index.d.ts +0 -25
  59. package/dist/types/capability-deck/bridge-ledger/key.d.ts +0 -65
  60. package/dist/types/capability-deck/bridge-ledger/ledger.d.ts +0 -129
  61. package/dist/types/capability-deck/bridge-ledger/network.d.ts +0 -115
  62. package/dist/types/capability-deck/builtin-bridge.d.ts +0 -114
  63. package/dist/types/capability-deck/capability-deck.test.d.ts +0 -18
  64. package/dist/types/capability-deck/cards/bg-process-card.d.ts +0 -99
  65. package/dist/types/capability-deck/cards/index.d.ts +0 -37
  66. package/dist/types/capability-deck/cards/memory-card.d.ts +0 -68
  67. package/dist/types/capability-deck/cards/plan-file.d.ts +0 -56
  68. package/dist/types/capability-deck/cards/plan-tools.d.ts +0 -97
  69. package/dist/types/capability-deck/cards/plan-tools.test.d.ts +0 -9
  70. package/dist/types/capability-deck/cards/saas-card.d.ts +0 -78
  71. package/dist/types/capability-deck/cards/task-card.d.ts +0 -106
  72. package/dist/types/capability-deck/cards/todo-card.d.ts +0 -78
  73. package/dist/types/capability-deck/cards/workflow-card.d.ts +0 -55
  74. package/dist/types/capability-deck/cards/workflow-card.test.d.ts +0 -12
  75. package/dist/types/capability-deck/checkpoint.int.test.d.ts +0 -25
  76. package/dist/types/capability-deck/contract.d.ts +0 -318
  77. package/dist/types/capability-deck/index.d.ts +0 -46
  78. package/dist/types/capability-deck/manifest.d.ts +0 -60
  79. package/dist/types/capability-deck/provision.d.ts +0 -76
  80. package/dist/types/capability-deck/read-edit-gate.int.test.d.ts +0 -21
  81. package/dist/types/channels/channels.test.d.ts +0 -15
  82. package/dist/types/channels/contract.d.ts +0 -489
  83. package/dist/types/channels/framer.d.ts +0 -49
  84. package/dist/types/channels/index.d.ts +0 -24
  85. package/dist/types/channels/link/dialog.d.ts +0 -138
  86. package/dist/types/channels/link/driver.d.ts +0 -81
  87. package/dist/types/channels/link/index.d.ts +0 -13
  88. package/dist/types/channels/link/server.d.ts +0 -70
  89. package/dist/types/channels/oneshot.d.ts +0 -37
  90. package/dist/types/channels/ops.d.ts +0 -89
  91. package/dist/types/channels/session-ops.d.ts +0 -80
  92. package/dist/types/conductor/bash-guard.d.ts +0 -106
  93. package/dist/types/conductor/bash-guard.test.d.ts +0 -17
  94. package/dist/types/conductor/catalog/catalog.d.ts +0 -87
  95. package/dist/types/conductor/catalog/index.d.ts +0 -14
  96. package/dist/types/conductor/catalog/matcher.d.ts +0 -47
  97. package/dist/types/conductor/conductor.d.ts +0 -213
  98. package/dist/types/conductor/conductor.test.d.ts +0 -10
  99. package/dist/types/conductor/contract.d.ts +0 -838
  100. package/dist/types/conductor/diagnostics.d.ts +0 -183
  101. package/dist/types/conductor/diagnostics.test.d.ts +0 -10
  102. package/dist/types/conductor/index.d.ts +0 -26
  103. package/dist/types/conductor/permission-gate.integration.test.d.ts +0 -22
  104. package/dist/types/conductor/permission-wiring.test.d.ts +0 -14
  105. package/dist/types/conductor/permissions.d.ts +0 -287
  106. package/dist/types/conductor/permissions.test.d.ts +0 -12
  107. package/dist/types/conductor/plan-mode.integration.test.d.ts +0 -23
  108. package/dist/types/conductor/post-edit-diagnostics.test.d.ts +0 -18
  109. package/dist/types/conductor/quota-error.d.ts +0 -35
  110. package/dist/types/conductor/signal-hub/hub.d.ts +0 -83
  111. package/dist/types/conductor/signal-hub/index.d.ts +0 -19
  112. package/dist/types/conductor/signal-hub/translate.d.ts +0 -77
  113. package/dist/types/conductor/skill-parse/index.d.ts +0 -10
  114. package/dist/types/conductor/skill-parse/parse.d.ts +0 -67
  115. package/dist/types/conductor/submit.test.d.ts +0 -28
  116. package/dist/types/conductor/transcript-store/index.d.ts +0 -16
  117. package/dist/types/conductor/transcript-store/serialize.d.ts +0 -106
  118. package/dist/types/conductor/transcript-store/serialize.test.d.ts +0 -10
  119. package/dist/types/conductor/transcript-store/store.d.ts +0 -188
  120. package/dist/types/console/auth-status.d.ts +0 -28
  121. package/dist/types/console/components/AgentsView.d.ts +0 -41
  122. package/dist/types/console/components/BackgroundAgents.d.ts +0 -63
  123. package/dist/types/console/components/BackgroundAgents.test.d.ts +0 -8
  124. package/dist/types/console/components/Banner.d.ts +0 -110
  125. package/dist/types/console/components/Composer.d.ts +0 -37
  126. package/dist/types/console/components/StatusBar.d.ts +0 -42
  127. package/dist/types/console/components/TerminalConsole.d.ts +0 -27
  128. package/dist/types/console/components/WorkingIndicator.d.ts +0 -44
  129. package/dist/types/console/components/WorkingIndicator.test.d.ts +0 -9
  130. package/dist/types/console/components/banner-sweep.d.ts +0 -55
  131. package/dist/types/console/components/banner.test.d.ts +0 -9
  132. package/dist/types/console/components/welcome.d.ts +0 -115
  133. package/dist/types/console/components/welcome.test.d.ts +0 -9
  134. package/dist/types/console/console.test.d.ts +0 -19
  135. package/dist/types/console/contract.d.ts +0 -611
  136. package/dist/types/console/index.d.ts +0 -34
  137. package/dist/types/console/input/complete.d.ts +0 -120
  138. package/dist/types/console/input/dir-reader.d.ts +0 -28
  139. package/dist/types/console/input/index.d.ts +0 -24
  140. package/dist/types/console/input/input.test.d.ts +0 -14
  141. package/dist/types/console/input/keymap.d.ts +0 -193
  142. package/dist/types/console/input/paste.d.ts +0 -183
  143. package/dist/types/console/mount.d.ts +0 -53
  144. package/dist/types/console/overlays/approval-queue.d.ts +0 -88
  145. package/dist/types/console/overlays/approval.d.ts +0 -104
  146. package/dist/types/console/overlays/approval.test.d.ts +0 -17
  147. package/dist/types/console/overlays/auth.d.ts +0 -31
  148. package/dist/types/console/overlays/boards.d.ts +0 -55
  149. package/dist/types/console/overlays/host.d.ts +0 -45
  150. package/dist/types/console/overlays/index.d.ts +0 -15
  151. package/dist/types/console/overlays/pickers.d.ts +0 -37
  152. package/dist/types/console/overlays/sessions.d.ts +0 -29
  153. package/dist/types/console/reducer.d.ts +0 -51
  154. package/dist/types/console/slash/builtins.d.ts +0 -33
  155. package/dist/types/console/slash/commands/dynamic.d.ts +0 -57
  156. package/dist/types/console/slash/commands/dynamic.test.d.ts +0 -9
  157. package/dist/types/console/slash/commands/integrations.d.ts +0 -28
  158. package/dist/types/console/slash/commands/integrations.test.d.ts +0 -18
  159. package/dist/types/console/slash/commands/shared.d.ts +0 -72
  160. package/dist/types/console/slash/commands/transcript.d.ts +0 -24
  161. package/dist/types/console/slash/commands/transcript.test.d.ts +0 -10
  162. package/dist/types/console/slash/commands/workbench.d.ts +0 -21
  163. package/dist/types/console/slash/commands/workbench.test.d.ts +0 -10
  164. package/dist/types/console/slash/index.d.ts +0 -34
  165. package/dist/types/console/slash/registry.d.ts +0 -90
  166. package/dist/types/console/slash/resolve.d.ts +0 -109
  167. package/dist/types/console/slash/slash.test.d.ts +0 -18
  168. package/dist/types/console/startup.d.ts +0 -119
  169. package/dist/types/console/theme/adapter.d.ts +0 -79
  170. package/dist/types/console/theme/index.d.ts +0 -18
  171. package/dist/types/console/theme/palette.d.ts +0 -77
  172. package/dist/types/console/theme/resolve.d.ts +0 -45
  173. package/dist/types/console/theme/theme.test.d.ts +0 -16
  174. package/dist/types/console/theme/tokens.d.ts +0 -62
  175. package/dist/types/entry.d.ts +0 -17
  176. package/dist/types/guardrails.d.ts +0 -33
  177. package/dist/types/index.d.ts +0 -24
  178. package/dist/types/insight/channel.d.ts +0 -45
  179. package/dist/types/insight/contract.d.ts +0 -411
  180. package/dist/types/insight/index.d.ts +0 -26
  181. package/dist/types/insight/insight.test.d.ts +0 -17
  182. package/dist/types/insight/recorder.d.ts +0 -63
  183. package/dist/types/insight/redaction.d.ts +0 -44
  184. package/dist/types/insight/replay.d.ts +0 -77
  185. package/dist/types/insight/sampling.d.ts +0 -84
  186. package/dist/types/insight/serialize.d.ts +0 -54
  187. package/dist/types/insight/sinks/console.d.ts +0 -36
  188. package/dist/types/insight/sinks/file.d.ts +0 -37
  189. package/dist/types/insight/sinks/index.d.ts +0 -16
  190. package/dist/types/insight/sinks/stream.d.ts +0 -53
  191. package/dist/types/kit/clipboard-image.d.ts +0 -40
  192. package/dist/types/kit/external-editor.d.ts +0 -35
  193. package/dist/types/kit/image.d.ts +0 -102
  194. package/dist/types/kit/index.d.ts +0 -29
  195. package/dist/types/kit/kit.test.d.ts +0 -13
  196. package/dist/types/kit/shell.d.ts +0 -50
  197. package/dist/types/kit/tool-fetch.d.ts +0 -165
  198. package/dist/types/launch/catalog.d.ts +0 -51
  199. package/dist/types/launch/contract.d.ts +0 -387
  200. package/dist/types/launch/credentials.d.ts +0 -112
  201. package/dist/types/launch/index.d.ts +0 -28
  202. package/dist/types/launch/invocation/attachments.d.ts +0 -72
  203. package/dist/types/launch/invocation/flags.d.ts +0 -59
  204. package/dist/types/launch/invocation/index.d.ts +0 -23
  205. package/dist/types/launch/invocation/read.d.ts +0 -52
  206. package/dist/types/launch/invocation/usage.d.ts +0 -25
  207. package/dist/types/launch/launch.test.d.ts +0 -20
  208. package/dist/types/launch/login.d.ts +0 -68
  209. package/dist/types/launch/oauth.d.ts +0 -101
  210. package/dist/types/launch/oauth.test.d.ts +0 -20
  211. package/dist/types/launch/packages.d.ts +0 -75
  212. package/dist/types/launch/packages.test.d.ts +0 -15
  213. package/dist/types/launch/pickers.d.ts +0 -97
  214. package/dist/types/runtime-bridge/bridges/_drive.d.ts +0 -74
  215. package/dist/types/runtime-bridge/bridges/builtins.d.ts +0 -77
  216. package/dist/types/runtime-bridge/bridges/claude-cli.d.ts +0 -37
  217. package/dist/types/runtime-bridge/bridges/codex-cli.d.ts +0 -27
  218. package/dist/types/runtime-bridge/bridges/index.d.ts +0 -15
  219. package/dist/types/runtime-bridge/bridges/indusagi-cli.d.ts +0 -36
  220. package/dist/types/runtime-bridge/broker.d.ts +0 -182
  221. package/dist/types/runtime-bridge/contract.d.ts +0 -436
  222. package/dist/types/runtime-bridge/index.d.ts +0 -21
  223. package/dist/types/runtime-bridge/runtime-bridge.test.d.ts +0 -17
  224. package/dist/types/runtime-bridge/sink.d.ts +0 -59
  225. package/dist/types/sessions/contract.d.ts +0 -79
  226. package/dist/types/sessions/index.d.ts +0 -11
  227. package/dist/types/sessions/library.d.ts +0 -95
  228. package/dist/types/sessions/sessions.test.d.ts +0 -11
  229. package/dist/types/settings/contract.d.ts +0 -175
  230. package/dist/types/settings/index.d.ts +0 -13
  231. package/dist/types/settings/manager.d.ts +0 -109
  232. package/dist/types/settings/settings.test.d.ts +0 -16
  233. package/dist/types/transcript-export/index.d.ts +0 -20
  234. package/dist/types/transcript-export/publish.d.ts +0 -81
  235. package/dist/types/transcript-export/sgr.d.ts +0 -90
  236. package/dist/types/transcript-export/template.d.ts +0 -64
  237. package/dist/types/transcript-export/theme-bridge.d.ts +0 -99
  238. package/dist/types/transcript-export/transcript-export.test.d.ts +0 -16
  239. package/dist/types/window-budget/budget/estimate.d.ts +0 -47
  240. package/dist/types/window-budget/budget/gate.d.ts +0 -37
  241. package/dist/types/window-budget/budget/index.d.ts +0 -14
  242. package/dist/types/window-budget/budget/slice.d.ts +0 -38
  243. package/dist/types/window-budget/condenser.d.ts +0 -73
  244. package/dist/types/window-budget/contract.d.ts +0 -182
  245. package/dist/types/window-budget/index.d.ts +0 -17
  246. package/dist/types/window-budget/microcompact.d.ts +0 -68
  247. package/dist/types/window-budget/microcompact.test.d.ts +0 -16
  248. package/dist/types/window-budget/rehydrate.d.ts +0 -56
  249. package/dist/types/window-budget/summarize/condense.d.ts +0 -76
  250. package/dist/types/window-budget/summarize/index.d.ts +0 -12
  251. package/dist/types/window-budget/summarize/prompt.d.ts +0 -56
  252. package/dist/types/window-budget/window-budget.test.d.ts +0 -18
  253. package/dist/types/workflow-engine/agent-runner.d.ts +0 -124
  254. package/dist/types/workflow-engine/agent-runner.test.d.ts +0 -8
  255. package/dist/types/workflow-engine/display.d.ts +0 -148
  256. package/dist/types/workflow-engine/display.test.d.ts +0 -1
  257. package/dist/types/workflow-engine/engine.d.ts +0 -183
  258. package/dist/types/workflow-engine/engine.test.d.ts +0 -1
  259. package/dist/types/workflow-engine/index.d.ts +0 -21
  260. package/dist/types/workflow-engine/parse.d.ts +0 -64
  261. package/dist/types/workflow-engine/parse.test.d.ts +0 -1
  262. package/dist/types/workflow-engine/structured-output.d.ts +0 -51
  263. package/dist/types/workflow-engine/structured-output.test.d.ts +0 -1
  264. package/dist/types/workspace/brand.d.ts +0 -26
  265. package/dist/types/workspace/index.d.ts +0 -11
  266. package/dist/types/workspace/locator.d.ts +0 -50
  267. package/dist/types/workspace/runtime-detect.d.ts +0 -56
@@ -1,64 +0,0 @@
1
- /**
2
- * Page-shell template — the standalone HTML/CSS scaffold the transcript publisher
3
- * fills.
4
- *
5
- * This module is a freshly authored single-file page: its own element names
6
- * (`<main class="xscript">`, `.turn`, `.turn-tag`, `.turn-body`, `.tool-frame`,
7
- * `.aside-note`), its own stylesheet, and its own `{{TOKEN}}` placeholder names —
8
- * the {@link SHELL_SLOTS} values from the briefing contract
9
- * (`THEME_VARS`/`PAGE_SURFACE`/…/`MARKED_LIB`/`HIGHLIGHT_LIB`). None of the class
10
- * names, DOM structure, placeholder tokens, or color values are carried over from
11
- * any prior export template.
12
- *
13
- * The publisher computes a value for every slot and calls {@link fill} to splice
14
- * them in. The page is self-contained: theme colors arrive as CSS custom
15
- * properties in `:root`, the markdown and syntax-highlight libraries are inlined,
16
- * the session payload is embedded as base64, and a small client renderer
17
- * (the `SCRIPT` slot) hydrates the transcript on load.
18
- */
19
- import { type ShellSlot } from "../briefing/contract";
20
- /**
21
- * The page stylesheet, emitted into the `STYLES` slot. Reads its colors from the
22
- * `--x-*` custom properties the `THEME_VARS` slot defines, so re-theming is a
23
- * matter of changing the variables, not the rules. Class names are this page's
24
- * own (`xscript`, `turn`, `tool-frame`, `aside-note`, the `sgr-*` family the
25
- * painter emits, and the highlight `xhl` block).
26
- */
27
- export declare const PAGE_STYLES: string;
28
- /**
29
- * The client-side renderer, emitted into the `SCRIPT` slot. Decodes the base64
30
- * session payload, walks its turns, and renders each into the `.xscript` root
31
- * using the inlined `marked` (markdown) and `highlight.js` (code) libraries. Code
32
- * fences are highlighted into the page's own `xhl-*` classes; prose is parsed by
33
- * marked. Pre-rendered tool widgets and SGR-painted text arrive already-HTML in
34
- * the payload and are inserted verbatim.
35
- */
36
- export declare const CLIENT_SCRIPT: string;
37
- /**
38
- * The HTML page shell carrying every {@link SHELL_SLOTS} placeholder as a
39
- * `{{TOKEN}}` marker. {@link fill} replaces each marker with its computed value.
40
- * The structure: a themed `:root`, the inlined stylesheet, the two vendored
41
- * libraries, the base64 payload bound to `window.__XSCRIPT_PAYLOAD__`, and the
42
- * client renderer that hydrates `#xscript-root`.
43
- */
44
- export declare const PAGE_SHELL = "<!doctype html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\" />\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n<title>Session Transcript</title>\n<style>\n:root {\n{{THEME_VARS}}\n --x-page-surface: {{PAGE_SURFACE}};\n --x-card-surface: {{CARD_SURFACE}};\n --x-note-surface: {{NOTE_SURFACE}};\n}\n{{STYLES}}\n</style>\n</head>\n<body>\n<main class=\"xscript\">\n <header class=\"xscript-head\">\n <h1>Session Transcript</h1>\n <div class=\"xscript-meta\">Self-contained HTML export</div>\n </header>\n <div id=\"xscript-root\"></div>\n</main>\n<script>\n/* {{MARKED_LIB}} */\n</script>\n<script>\n/* {{HIGHLIGHT_LIB}} */\n</script>\n<script>\nwindow.__XSCRIPT_PAYLOAD__ = \"{{PAYLOAD}}\";\n</script>\n<script>\n{{SCRIPT}}\n</script>\n</body>\n</html>";
45
- /**
46
- * The map a {@link fill} call supplies — one value per {@link ShellSlot} token. A
47
- * value may be omitted, in which case its placeholder is replaced with the empty
48
- * string (so a partial fill leaves no stray `{{TOKEN}}` in the output).
49
- */
50
- export type SlotValues = Partial<Record<ShellSlot, string>>;
51
- /**
52
- * Replace every `{{TOKEN}}` placeholder in a template with the value supplied for
53
- * that slot, returning the filled string.
54
- *
55
- * Walks the known {@link SHELL_SLOTS} (not an open scan), so only sanctioned
56
- * placeholders are substituted and a stray `{{…}}` in user content is left
57
- * untouched. Each token is replaced globally; a slot with no supplied value
58
- * collapses to the empty string. The replacement is value-literal — a `$` in a
59
- * value does not trigger regex backreference expansion.
60
- *
61
- * @param template the shell carrying `{{TOKEN}}` markers
62
- * @param values the per-slot values to splice in
63
- */
64
- export declare function fill(template: string, values: SlotValues): string;
@@ -1,99 +0,0 @@
1
- /**
2
- * ThemeBridge — the color service behind the HTML transcript export.
3
- *
4
- * Everything the publisher needs to turn an {@link ExportTheme} token bag into
5
- * concrete page colors lives here: parsing CSS colors into {@link Rgb}, measuring
6
- * a color's WCAG relative luminance through a precomputed lookup table, deciding
7
- * whether the theme reads {@link ThemeMode} light or dark, deriving lighter/darker
8
- * surface variants from a base, and projecting the whole theme to the CSS custom
9
- * properties the page shell consumes.
10
- *
11
- * Two facts are interface-dictated and kept faithful:
12
- * - The WCAG relative-luminance formula — linearize each sRGB channel with the
13
- * gamma piecewise curve, then weight `0.2126 R + 0.7152 G + 0.0722 B`. The
14
- * per-channel linearization is precomputed once into {@link buildLuminanceLut}
15
- * (a {@link LuminanceLut}) so a luminance read is three table lookups plus a
16
- * weighted sum, never a `pow` per pixel.
17
- * - Readable foreground selection — given a background, pick the foreground
18
- * (from the theme's own ink choices) whose contrast against that background is
19
- * the larger, so text on any derived surface stays legible.
20
- *
21
- * Every default color the bridge falls back to is this rebuild's own
22
- * {@link FALLBACK_EXPORT_THEME} (a deep-slate palette), never a legacy export's
23
- * magic constant.
24
- */
25
- import { type ExportTheme, type LuminanceLut, type Rgb, type ThemeBridge, type ThemeMode } from "../briefing/contract";
26
- /**
27
- * Build the 256-entry sRGB→linear lookup table the WCAG relative-luminance
28
- * formula needs for each channel.
29
- *
30
- * For a channel value `v` in `0–255`, normalize to `s = v / 255`, then apply the
31
- * standard gamma-expansion: `s ≤ 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ^
32
- * 2.4`. The table holds the linearized value at each integer channel so a
33
- * luminance read avoids the per-call `pow`. The math is the published standard's;
34
- * the table is this module's.
35
- */
36
- export declare function buildLuminanceLut(): Float64Array;
37
- /**
38
- * Parse a CSS color string into its {@link Rgb} channels. Recognizes `#rgb`,
39
- * `#rrggbb` (and their alpha-bearing `#rgba` / `#rrggbbaa` forms, alpha dropped)
40
- * and the functional `rgb(r, g, b)` / `rgba(r, g, b, a)` notations. Any
41
- * unrecognized input resolves to `null`, which the bridge treats as "fall back to
42
- * the theme default" rather than throwing.
43
- *
44
- * @param color a CSS color string
45
- */
46
- export declare function parseColor(color: string): Rgb | null;
47
- /** Render an {@link Rgb} back to a `#rrggbb` CSS string. */
48
- export declare function formatColor(rgb: Rgb): string;
49
- /**
50
- * The concrete {@link ThemeBridge}. Holds a resolved {@link ExportTheme} and a
51
- * {@link LuminanceLut}, and serves every color query the publisher makes against
52
- * them. Pure with respect to its inputs — construction resolves the theme once and
53
- * the methods only read.
54
- */
55
- export declare class DefaultThemeBridge implements ThemeBridge {
56
- readonly theme: ExportTheme;
57
- private readonly lut;
58
- /**
59
- * @param theme an {@link ExportTheme} to serve; defaults to the rebuild's own
60
- * {@link FALLBACK_EXPORT_THEME}.
61
- * @param lut the luminance lookup table to read; defaults to the shared
62
- * module-level table.
63
- */
64
- constructor(theme?: ExportTheme, lut?: LuminanceLut);
65
- /** The WCAG relative luminance (0–1) of a CSS color; unparseable input reads 0. */
66
- luminance(color: string): number;
67
- /** Whether the theme's page surface reads light or dark. */
68
- mode(): ThemeMode;
69
- /**
70
- * Derive a surface variant from a base color. The `amount` is a signed lightness
71
- * delta in channel space; the sign is honored directly so a caller can lighten
72
- * (`+`) or darken (`−`) explicitly. When `amount` is `0` the base is returned
73
- * formatted but unchanged. Unparseable bases fall through to the theme's card
74
- * surface so a derivation never yields an empty string.
75
- *
76
- * @param base the base CSS color to adjust
77
- * @param amount signed lightness delta (positive lightens, negative darkens)
78
- */
79
- deriveSurface(base: string, amount: number): string;
80
- /**
81
- * Pick the more readable of the theme's two ink colors for a given background by
82
- * comparing each ink's WCAG contrast against it and returning the higher. This
83
- * is the bridge's own readable-foreground chooser — used when text sits on a
84
- * derived surface whose lightness is not known ahead of time.
85
- *
86
- * @param background the surface the text will sit on
87
- */
88
- readableInk(background: string): string;
89
- /** Project the theme to its CSS custom properties, keyed by token name. */
90
- toCssVars(): Readonly<Record<string, string>>;
91
- }
92
- /**
93
- * Build a {@link ThemeBridge} over an optional {@link ExportTheme}. The convenience
94
- * factory the publisher calls; omitting the theme yields a bridge over the
95
- * rebuild's own fallback palette.
96
- *
97
- * @param theme an export palette to serve, or undefined for the fallback
98
- */
99
- export declare function createThemeBridge(theme?: ExportTheme): ThemeBridge;
@@ -1,16 +0,0 @@
1
- /**
2
- * Transcript-export subsystem — Phase 9 behavioral tests.
3
- *
4
- * Three concerns, exercised purely (no disk, no network):
5
- * 1. {@link paintSgr} — the table-driven SGR machine turns an ANSI string
6
- * (bold + red foreground + a 256-color index) into HTML spans carrying this
7
- * page's own `sgr-*` classes and resolved colors, and a reset returns the
8
- * text to a bare (span-less) run.
9
- * 2. {@link DefaultThemeBridge} — picks a readable foreground for a dark and a
10
- * light background through the WCAG luminance LUT, and never resolves to a
11
- * forbidden upstream color (#343541 / rgb(24,24,30)).
12
- * 3. {@link publishTranscript} — renders a small transcript to a self-contained
13
- * HTML string carrying the new token/class names, the marked-rendered
14
- * markdown, and none of the upstream magic colors.
15
- */
16
- export {};
@@ -1,47 +0,0 @@
1
- /**
2
- * Token estimation — the heuristic "meter stick" for the window-budget
3
- * subsystem.
4
- *
5
- * Before we can decide whether the transcript is over budget (gate.ts) or where
6
- * to slice it (slice.ts), we need a cheap, deterministic estimate of how many
7
- * tokens each {@link AgentMessage} occupies. We do *not* call a tokenizer; we
8
- * walk the serialized content and apply a small, transparent weighting model.
9
- *
10
- * Design notes (clean-room, deliberately distinct from any chars/4 + flat-image
11
- * baseline):
12
- * - The estimate is computed over a *serialization* of each message's
13
- * payload, not over a JSON blob of the whole object — structural framing
14
- * (braces, quotes, field names) is accounted for with small per-block adds
15
- * rather than being measured character-for-character.
16
- * - Constants below are this module's OWN tunables (a fractional
17
- * bytes-per-token divisor plus per-block framing adds and a flat image
18
- * cost). They are intentionally not the legacy fingerprint values.
19
- * - The estimator is conservative (rounds up, adds framing) so the gate fires
20
- * a little early rather than a little late — overflowing the window is worse
21
- * than condensing one turn sooner than strictly necessary.
22
- */
23
- import type { AgentMessage } from "../contract.js";
24
- /**
25
- * Estimate the token cost of one message in isolation. Exposed so the slice
26
- * planner can build a prefix-sum without re-deriving the per-message weight.
27
- *
28
- * Cost = `ceil(serialized_chars / CHARS_PER_TOKEN)` + framing tokens +
29
- * `images * IMAGE_TOKENS`. Always `>= 0` and biased high (conservative).
30
- */
31
- export declare function estimateMessageTokens(message: AgentMessage): number;
32
- /**
33
- * Estimate the total token cost of a transcript: the sum of every message's
34
- * {@link estimateMessageTokens}. This is a pure heuristic — the gate prefers a
35
- * provider-anchored figure when one exists, and only falls back to this.
36
- */
37
- export declare function estimateTokens(messages: AgentMessage[]): number;
38
- /**
39
- * Build a FORWARD prefix-sum array of per-message token estimates.
40
- *
41
- * Returns an array of length `messages.length + 1` where `result[i]` is the
42
- * total estimated tokens of `messages[0 .. i)` (so `result[0] === 0` and
43
- * `result[messages.length] === estimateTokens(messages)`). This monotonically
44
- * non-decreasing array is exactly what {@link planSlice} binary-searches to find
45
- * the cut boundary in O(log n).
46
- */
47
- export declare function prefixTokens(messages: AgentMessage[]): number[];
@@ -1,37 +0,0 @@
1
- /**
2
- * Budget gate — the trigger predicate for the window-budget subsystem.
3
- *
4
- * {@link isOverBudget} answers the single question "is the transcript large
5
- * enough that we should condense before the next turn?" by comparing a token
6
- * estimate against a window-relative threshold derived from the model's
7
- * `contextWindow` and the caller-supplied {@link BudgetPolicy}.
8
- *
9
- * The threshold is computed as:
10
- *
11
- * limit = (contextWindow - reserveTokens?) * triggerRatio
12
- *
13
- * i.e. optional fixed headroom is carved off the window first, then the
14
- * remaining capacity is scaled by the window-relative trigger ratio. This keeps
15
- * the trigger free of baked-in token counts — `triggerRatio` lives in `(0, 1]`
16
- * and `reserveTokens` is an optional config value, never a fingerprint constant.
17
- */
18
- import type { AgentMessage, BudgetPolicy, Model } from "../contract.js";
19
- import type { Api } from "indusagi/ai";
20
- /**
21
- * Compute the absolute token limit at which condensing should fire for a given
22
- * model and policy. Exposed for callers that want the number itself (e.g. to
23
- * display headroom) rather than just the boolean.
24
- *
25
- * `reserveTokens` (when present) is subtracted from the window before the ratio
26
- * is applied; the result is floored at `0` so a misconfigured reserve larger
27
- * than the window can never yield a negative limit.
28
- */
29
- export declare function budgetLimit(model: Model<Api>, policy: BudgetPolicy): number;
30
- /**
31
- * Decide whether the transcript is over budget for the given model and policy.
32
- *
33
- * Uses the heuristic {@link estimateTokens} over the serialized transcript and
34
- * compares it to {@link budgetLimit}. Returns `true` once the estimate strictly
35
- * exceeds the limit — the signal the conductor uses to kick off a condense.
36
- */
37
- export declare function isOverBudget(messages: AgentMessage[], model: Model<Api>, policy: BudgetPolicy): boolean;
@@ -1,14 +0,0 @@
1
- /**
2
- * Window-budget / budget — pure budget math.
3
- *
4
- * The arithmetic core of the window-budget subsystem, free of I/O, prompts, and
5
- * model calls:
6
- * - {@link estimateTokens} / {@link estimateMessageTokens} / {@link prefixTokens}
7
- * — heuristic token measurement and the forward cumulative-token array.
8
- * - {@link isOverBudget} / {@link budgetLimit} — the window-relative trigger.
9
- * - {@link planSlice} — forward prefix-sum + binary-search cut planning that
10
- * never splits a tool_call from its tool_result.
11
- */
12
- export { estimateMessageTokens, estimateTokens, prefixTokens } from "./estimate.js";
13
- export { budgetLimit, isOverBudget } from "./gate.js";
14
- export { planSlice } from "./slice.js";
@@ -1,38 +0,0 @@
1
- /**
2
- * Slice planner — decides *where* to cut the transcript when it is over budget.
3
- *
4
- * {@link planSlice} partitions a transcript into a `dropped` prefix (older
5
- * messages destined for a summary) and a `kept` suffix (the verbatim recent
6
- * tail), choosing the boundary so the tail holds roughly `policy.keepRecent`
7
- * tokens. It does this with a FORWARD prefix-sum + BINARY SEARCH (not a backward
8
- * accumulate-and-snap):
9
- *
10
- * 1. Build the cumulative-token array `prefix` (forward, monotonic).
11
- * 2. The total is `prefix[n]`; we want the tail to be ~`keepRecent` tokens, so
12
- * the *ideal* cut sits at the first index `i` whose suffix
13
- * `prefix[n] - prefix[i]` has fallen to `<= keepRecent`. Equivalently, the
14
- * first `i` with `prefix[i] >= prefix[n] - keepRecent`. That predicate is
15
- * monotonic in `i`, so we BINARY-SEARCH the lower bound of the threshold
16
- * `prefix[n] - keepRecent` over `prefix`.
17
- * 3. Snap the resulting index FORWARD to the nearest *legal* boundary so we
18
- * never land between a tool_call and its matching tool_result. A boundary
19
- * is legal iff the message it lands on is not a `toolResult` (a tool result
20
- * always belongs with the assistant turn that issued the call, so the tail
21
- * may never begin with one).
22
- *
23
- * If the whole transcript already fits within `keepRecent`, or snapping forward
24
- * consumes everything, the cut is `0` (nothing condensable — keep it all).
25
- */
26
- import type { AgentMessage, BudgetPolicy, CondensePlan } from "../contract.js";
27
- /**
28
- * Plan the condense slice for a transcript under a {@link BudgetPolicy}.
29
- *
30
- * Chooses the cut via forward prefix-sum + binary search for the boundary that
31
- * keeps ~`policy.keepRecent` recent tokens, then snaps that boundary forward to
32
- * a legal point (never between a tool_call and its tool_result).
33
- *
34
- * @returns a {@link CondensePlan} with the chosen `cut`, the `kept` tail
35
- * (`messages.slice(cut)`) and the `dropped` head (`messages.slice(0, cut)`).
36
- * `cut === 0` when nothing is condensable.
37
- */
38
- export declare function planSlice(messages: AgentMessage[], policy: BudgetPolicy): CondensePlan;
@@ -1,73 +0,0 @@
1
- /**
2
- * Window-budget — the condenser factory (the conductor-consumable seam).
3
- *
4
- * {@link createCondenser} ties the three pure pieces together into a single
5
- * function the conductor can drop into its auto-compaction hook:
6
- *
7
- * 1. **Gate** — {@link isOverBudget} asks "is this transcript large enough to
8
- * condense?" against the bound model's window and the {@link BudgetPolicy}.
9
- * 2. **Slice** — {@link planSlice} splits the transcript into a `dropped` head
10
- * (older turns to fold away) and a verbatim `kept` tail, never cutting
11
- * between a `toolCall` and its `toolResult`.
12
- * 3. **Condense** — {@link summarize} turns the dropped head into one synthetic
13
- * digest message (scope `"session"`), via the injectable model completer.
14
- *
15
- * The returned value is a {@link Condenser} — structurally a conductor
16
- * `CondenseFn` `(messages) => AgentMessage[] | Promise<AgentMessage[]>`:
17
- * - When over budget it returns `[summaryMessage, ...kept]` (a strictly smaller
18
- * transcript: one digest in place of the dropped prefix, plus the recent tail).
19
- * - Otherwise it returns the input list unchanged (the no-op identity the
20
- * conductor expects when nothing needs doing).
21
- *
22
- * It is **network-free-testable**: with no `model` bound the gate cannot measure a
23
- * window, so the condenser is an identity transform; inject a {@link CompleteFn}
24
- * stub (and a `model`) to drive the summary path with no real API call.
25
- *
26
- * Branch-archival is *not* a second engine — {@link condenseScope} forwards to the
27
- * shared {@link summarize} core pinned to scope `"branch"`. {@link condense} is the
28
- * matching session-scope entrypoint. Both are re-exported here so callers can
29
- * summarize a slice directly without building a full {@link Condenser}.
30
- */
31
- import type { AgentMessage, BudgetPolicy, CondenserDeps, Condenser, Summary } from "./contract.js";
32
- import { condenseScope, type SummarizeDeps } from "./summarize/index.js";
33
- /**
34
- * The fallback {@link BudgetPolicy} when the caller supplies none. These are
35
- * ordinary configuration defaults — a window-relative ratio plus a token tail —
36
- * computed from the model's own context window rather than fixed magic numbers.
37
- * - `triggerRatio` 0.75 — condense once ~three-quarters of the window is used.
38
- * - `keepRecent` 6000 — keep roughly the last 6k tokens of turns verbatim.
39
- * - `reserveTokens` 2048 — carve a little headroom off the window first.
40
- *
41
- * Exported as {@link AUTO_CONDENSE_POLICY} so the conductor's token gate and the
42
- * session runner's slice planner share **one** policy — the value the auto-path
43
- * trigger ({@link isOverBudget}) compares against must equal the value the slice
44
- * planner ({@link planSlice}) cuts with, or the gate and the cut disagree.
45
- */
46
- export declare const AUTO_CONDENSE_POLICY: BudgetPolicy;
47
- /**
48
- * Build a {@link Condenser} from a {@link CondenserDeps} bundle. The result plugs
49
- * straight into the conductor's `CondenseFn` seam.
50
- *
51
- * Behavior of the returned condenser, given a transcript `messages`:
52
- * - If no `model` is bound (so the window is unknown), or the transcript is
53
- * **not** over budget, return `messages` **unchanged**.
54
- * - Otherwise {@link planSlice} the transcript; if there is nothing to drop
55
- * (`cut === 0`) return it unchanged; else {@link summarize} the dropped head
56
- * (scope `"session"`) and return `[summary.message, ...plan.kept]`.
57
- *
58
- * All dependencies are optional, so `createCondenser()` yields a working,
59
- * network-free condenser (a no-op until a model and policy are supplied).
60
- */
61
- export declare function createCondenser(deps?: CondenserDeps): Condenser;
62
- /**
63
- * Session-scope summarization: fold a slice of dropped messages into one digest
64
- * for the active session. A thin wrapper over the shared {@link summarize} core
65
- * pinned to scope `"session"` (the default), so callers don't pass the flag.
66
- */
67
- export declare function condense(messages: AgentMessage[], deps?: Omit<SummarizeDeps, "scope">): Promise<Summary>;
68
- /**
69
- * Branch-scope summarization: archive an abandoned branch into one digest. Folds
70
- * branch-summarization into the same machinery behind the scope flag — re-exported
71
- * from the summarize subsystem so this module is the single condenser entrypoint.
72
- */
73
- export { condenseScope };
@@ -1,182 +0,0 @@
1
- /**
2
- * Window-budget contract — the FROZEN type surface of the context-window
3
- * budgeting subsystem (Phase 3, subsystem 05).
4
- *
5
- * A long-running coding session accrues messages — user turns, assistant turns,
6
- * tool calls and their results — until the transcript approaches the model's
7
- * context window. This subsystem keeps the session usable by *condensing* older
8
- * history into a single structured summary message while keeping a verbatim
9
- * tail of the most-recent turns. It answers three questions:
10
- *
11
- * 1. **Budget** — *when* are we over budget? A {@link BudgetPolicy} carries
12
- * config-sourced thresholds (no magic literals); {@link isOverBudget}
13
- * decides from a real {@link TokenEstimate}.
14
- * 2. **Slice** — *where* do we cut? {@link planSlice} computes a
15
- * {@link CondensePlan} via a forward prefix-sum + binary search over a
16
- * cumulative-token array, never splitting a tool_call from its tool_result.
17
- * 3. **Condense** — *how* do we compress the dropped portion? A
18
- * {@link Condenser} flattens the dropped messages, asks an injectable model
19
- * completer for a structured {@link Summary}, and returns the rebuilt
20
- * transcript (summary + kept tail).
21
- *
22
- * This file declares *only* shapes plus the function-type seams — no behavior,
23
- * no I/O, no prompt strings. Every later window-budget module (the meter, the
24
- * slice planner, the condenser, the branch archivist, the prompt templates, and
25
- * the public barrel) is written against the names declared here.
26
- *
27
- * Design stance:
28
- * - Thresholds are **configuration, not constants**. {@link BudgetPolicy}
29
- * fields are supplied by the caller; this module bakes in no fixed token
30
- * fingerprints. Defaults, if any, live in the implementation and are
31
- * computed relative to the model's own context window.
32
- * - Branch-summarization is **not a separate engine**. It collapses into the
33
- * condenser behind a {@link CondenseScope} flag (`"session" | "branch"`),
34
- * so there is one prompt-assembly path, one token estimator, one slicer.
35
- * - The model completer is **injectable** ({@link CompleteFn}, default the
36
- * framework's `completeSimple`) so the condenser runs in tests with no
37
- * network.
38
- * - The produced condenser is **conductor-consumable**: a {@link Condenser}
39
- * is structurally a conductor `CondenseFn`
40
- * (`(messages: AgentMessage[]) => AgentMessage[] | Promise<AgentMessage[]>`),
41
- * so a {@link CondenserDeps}-built condenser plugs straight into the
42
- * conductor's auto-compaction seam.
43
- *
44
- * Framework anchors (all from the `indusagi` package — the sibling rebuilt
45
- * framework this app targets):
46
- * - `AgentMessage` ← `indusagi/agent`
47
- * - `Model`, `Usage`, `completeSimple` (and its `Api`/`AssistantMessage`/
48
- * `Context`/`SimpleStreamOptions`/`StreamLogger` shapes) ← `indusagi/ai`
49
- *
50
- * This module never re-declares these; it composes them.
51
- */
52
- import type { AgentMessage } from "indusagi/agent";
53
- import type { Api, AssistantMessage, Context, Model, SimpleStreamOptions, StreamLogger, Usage } from "indusagi/ai";
54
- /** Re-exported framework vocabulary window-budget consumers routinely need. */
55
- export type { AgentMessage, Model, Usage };
56
- /**
57
- * The config-sourced thresholds that govern when and how the transcript is
58
- * condensed. Every field is a *number the caller supplies* — there are no magic
59
- * token literals baked into this contract. An implementation may
60
- * provide defaults, but they are configuration values, not protected constants,
61
- * and deliberately differ from the legacy fingerprints.
62
- */
63
- export interface BudgetPolicy {
64
- /**
65
- * Fraction of the model's `contextWindow` at which condensing is triggered,
66
- * in `(0, 1]`. The meter is "over budget" once the estimated context tokens
67
- * cross `contextWindow * triggerRatio`. Expressing the trigger as a ratio
68
- * (rather than an absolute reserve) keeps it window-relative and free of
69
- * baked-in token counts.
70
- */
71
- readonly triggerRatio: number;
72
- /**
73
- * How much of the recent transcript to keep verbatim, measured in estimated
74
- * tokens. The slice planner preserves a tail of at least this many tokens
75
- * (snapped to a legal boundary) and condenses everything before it.
76
- */
77
- readonly keepRecent: number;
78
- /**
79
- * Optional token headroom to subtract from the window before the trigger is
80
- * evaluated — a safety margin so a condense fires *before* the very next turn
81
- * would overflow. When omitted, only {@link triggerRatio} governs the trigger.
82
- */
83
- readonly reserveTokens?: number;
84
- }
85
- /**
86
- * The outcome of measuring a transcript against a model's window. Anchors on the
87
- * provider's authoritative `usage` count when available (`anchored: true`) and
88
- * falls back to a rough char/role estimate otherwise; either way `contextTokens`
89
- * is the figure {@link isOverBudget} compares to `contextWindow`.
90
- */
91
- export interface TokenEstimate {
92
- /** Best estimate of tokens currently occupying the context window. */
93
- readonly contextTokens: number;
94
- /** The model's total context window, in tokens (`Model.contextWindow`). */
95
- readonly contextWindow: number;
96
- /**
97
- * `true` when {@link contextTokens} is anchored on a real provider `usage`
98
- * figure (only trailing, post-usage messages are estimated); `false` when the
99
- * whole figure is a heuristic estimate.
100
- */
101
- readonly anchored: boolean;
102
- }
103
- /**
104
- * The pre-computed result of {@link planSlice}: the chosen cut index and the
105
- * resulting partition of the transcript.
106
- *
107
- * The cut is found by a *forward* prefix-sum + binary search: build a cumulative
108
- * estimated-token array over the messages, binary-search for the boundary index
109
- * nearest `total - keepRecent`, then nudge to the closest *legal* boundary —
110
- * never landing between a `toolCall` and its `toolResult`.
111
- *
112
- * Invariants:
113
- * - `kept.length + dropped.length === messages.length`
114
- * - `dropped` is the prefix `messages[0 .. cut)` (the older slice to condense)
115
- * - `kept` is the suffix `messages[cut ..]` (the verbatim recent tail)
116
- * - `cut` is `0` when nothing is condensable (everything kept).
117
- */
118
- export interface CondensePlan {
119
- /** Index of the legal cut boundary: `dropped = messages.slice(0, cut)`. */
120
- readonly cut: number;
121
- /** The verbatim recent tail preserved as-is (`messages.slice(cut)`). */
122
- readonly kept: AgentMessage[];
123
- /** The older slice to be folded into a {@link Summary} (`messages.slice(0, cut)`). */
124
- readonly dropped: AgentMessage[];
125
- }
126
- /**
127
- * Which kind of condensing run this is — the flag that collapses
128
- * branch-summarization into the single condenser path:
129
- * - `"session"` — condense the *active* transcript in place (the trigger /
130
- * overflow path); keeps a recent tail, summarizes the head.
131
- * - `"branch"` — archive an *abandoned* branch into one summary message so its
132
- * context isn't lost on tree navigation; no verbatim tail is retained.
133
- */
134
- export type CondenseScope = "session" | "branch";
135
- /**
136
- * The structured result of summarizing a slice of dropped messages: a single
137
- * synthetic {@link AgentMessage} that stands in for the messages it covers.
138
- */
139
- export interface Summary {
140
- /** The synthetic summary message to splice into the rebuilt transcript. */
141
- readonly message: AgentMessage;
142
- /** How many source messages this summary replaces. */
143
- readonly coveredCount: number;
144
- }
145
- /**
146
- * The injectable model-completion function. Structurally identical to the
147
- * framework's `completeSimple`, so the real `completeSimple` is the drop-in
148
- * default and a test can pass a no-network stub of the same shape. The
149
- * condenser uses this single call to turn flattened transcript text into a
150
- * {@link Summary}.
151
- */
152
- export type CompleteFn = <TApi extends Api>(model: Model<TApi>, context: Context, options?: SimpleStreamOptions, logger?: StreamLogger) => Promise<AssistantMessage>;
153
- /**
154
- * A condenser: takes the active branch's messages and returns the rebuilt
155
- * transcript (condensed head + verbatim tail, or the input unchanged when there
156
- * is nothing to do).
157
- *
158
- * This type is **structurally compatible with the conductor's `CondenseFn`**
159
- * (`(messages: AgentMessage[]) => AgentMessage[] | Promise<AgentMessage[]>`), so
160
- * the result of the condenser factory plugs directly into the conductor's
161
- * auto-compaction seam with no adapter.
162
- */
163
- export type Condenser = (messages: AgentMessage[]) => AgentMessage[] | Promise<AgentMessage[]>;
164
- /**
165
- * Dependencies for building a {@link Condenser}. All fields are optional so a
166
- * bare `createCondenser()` yields a working, network-free-testable condenser:
167
- * - `complete` defaults to the framework's `completeSimple`.
168
- * - `policy` defaults to the implementation's config-sourced thresholds.
169
- * - `model` is the summarization model; when omitted the condenser may fall
170
- * back to a no-op (return input unchanged) rather than guess a model.
171
- */
172
- export interface CondenserDeps {
173
- /**
174
- * The injectable model completer (default: framework `completeSimple`). Inject
175
- * a stub of {@link CompleteFn} shape to run the condenser with no network.
176
- */
177
- readonly complete?: CompleteFn;
178
- /** The model used to write the summary. When omitted, condensing is a no-op. */
179
- readonly model?: Model<Api>;
180
- /** The config-sourced budget thresholds (default: implementation defaults). */
181
- readonly policy?: BudgetPolicy;
182
- }
@@ -1,17 +0,0 @@
1
- /**
2
- * Window-budget — public barrel.
3
- *
4
- * The context-window budgeting subsystem: token measurement, slice planning,
5
- * and transcript condensing (with branch-archival collapsed in behind a scope
6
- * flag). Re-exports the frozen contract types plus the live functions: the
7
- * budget math (estimateTokens / isOverBudget / planSlice), the summarization core
8
- * (summarize / condenseScope), and the conductor-consumable condenser factory
9
- * (createCondenser / condense).
10
- */
11
- export type { AgentMessage, BudgetPolicy, CompleteFn, CondensePlan, Condenser, CondenserDeps, CondenseScope, Model, Summary, TokenEstimate, Usage, } from "./contract.js";
12
- export { budgetLimit, estimateMessageTokens, estimateTokens, isOverBudget, planSlice, prefixTokens, } from "./budget/index.js";
13
- export { buildSummaryPrompt, CONDENSER_BRIEF, flattenTranscript, summarize, } from "./summarize/index.js";
14
- export type { SummarizeDeps } from "./summarize/index.js";
15
- export { AUTO_CONDENSE_POLICY, condense, condenseScope, createCondenser } from "./condenser.js";
16
- export { CLEARED_TOOL_RESULT, clearStaleToolResults, COMPACTABLE_TOOL_NAMES, } from "./microcompact.js";
17
- export { rehydrateRecentReads, RESTORED_FILE_PREFIX } from "./rehydrate.js";