@kenkaiiii/gg-engine 0.0.0-stage → 7.0.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 (850) hide show
  1. package/LICENSE +661 -0
  2. package/NOTICE +43 -0
  3. package/README.md +53 -2
  4. package/assets/skills/bulletproof/SKILL.md +132 -0
  5. package/assets/skills/bulletproof/references/agent-surface.md +113 -0
  6. package/assets/skills/bulletproof/references/attack-classes.md +226 -0
  7. package/assets/skills/bulletproof/references/audit-protocol.md +232 -0
  8. package/assets/skills/bulletproof/references/platform-playbooks.md +196 -0
  9. package/assets/skills/bulletproof/references/provenance.md +146 -0
  10. package/assets/skills/bulletproof/references/secure-defaults.md +137 -0
  11. package/assets/skills/bulletproof/references/supply-chain.md +84 -0
  12. package/assets/skills/bulletproof/references/threat-landscape.md +66 -0
  13. package/assets/skills/bulletproof/references/verification.md +74 -0
  14. package/assets/skills/compliance-guard/SKILL.md +115 -0
  15. package/assets/skills/compliance-guard/references/artifacts.md +199 -0
  16. package/assets/skills/compliance-guard/references/eu-uk.md +162 -0
  17. package/assets/skills/compliance-guard/references/exposure-triage.md +177 -0
  18. package/assets/skills/compliance-guard/references/full-review.md +155 -0
  19. package/assets/skills/compliance-guard/references/lawsuit-vectors.md +153 -0
  20. package/assets/skills/compliance-guard/references/provenance.md +135 -0
  21. package/assets/skills/compliance-guard/references/sector-gates.md +187 -0
  22. package/assets/skills/compliance-guard/references/security-baseline.md +117 -0
  23. package/assets/skills/compliance-guard/references/trigger-map.md +177 -0
  24. package/assets/skills/compliance-guard/references/us.md +194 -0
  25. package/assets/skills/durable/SKILL.md +114 -0
  26. package/assets/skills/durable/references/agent-db-safety.md +76 -0
  27. package/assets/skills/durable/references/backups-and-runtime.md +93 -0
  28. package/assets/skills/durable/references/migrations-and-schema.md +87 -0
  29. package/assets/skills/gg-guide/SKILL.md +43 -0
  30. package/assets/skills/gg-guide/references/chat-motion-goals.md +217 -0
  31. package/assets/skills/gg-guide/references/checklist-and-safety.md +177 -0
  32. package/assets/skills/gg-guide/references/code-mode.md +269 -0
  33. package/assets/skills/gg-guide/references/getting-started.md +290 -0
  34. package/assets/skills/gg-guide/references/ken-and-autopilot.md +172 -0
  35. package/assets/skills/gg-guide/references/mcp-and-skills.md +204 -0
  36. package/assets/skills/gg-guide/references/models-and-sign-in.md +200 -0
  37. package/assets/skills/gg-guide/references/sessions-and-history.md +213 -0
  38. package/assets/skills/gg-guide/references/settings.md +193 -0
  39. package/assets/skills/gg-guide/references/troubleshooting-and-data.md +186 -0
  40. package/assets/skills/lean/SKILL.md +117 -0
  41. package/assets/skills/lean/references/memory-and-processes.md +99 -0
  42. package/assets/skills/lean/references/playbooks.md +134 -0
  43. package/dist/app-error.d.ts +22 -0
  44. package/dist/app-error.js +41 -0
  45. package/dist/app-error.js.map +1 -0
  46. package/dist/config.d.ts +90 -0
  47. package/dist/config.js +240 -0
  48. package/dist/config.js.map +1 -0
  49. package/dist/core/acceptance-checks.d.ts +48 -0
  50. package/dist/core/acceptance-checks.js +151 -0
  51. package/dist/core/acceptance-checks.js.map +1 -0
  52. package/dist/core/action-threats.d.ts +68 -0
  53. package/dist/core/action-threats.js +894 -0
  54. package/dist/core/action-threats.js.map +1 -0
  55. package/dist/core/agent-notifications.d.ts +79 -0
  56. package/dist/core/agent-notifications.js +125 -0
  57. package/dist/core/agent-notifications.js.map +1 -0
  58. package/dist/core/agent-session/helpers.d.ts +26 -0
  59. package/dist/core/agent-session/helpers.js +47 -0
  60. package/dist/core/agent-session/helpers.js.map +1 -0
  61. package/dist/core/agent-session/mcp-tools.d.ts +87 -0
  62. package/dist/core/agent-session/mcp-tools.js +227 -0
  63. package/dist/core/agent-session/mcp-tools.js.map +1 -0
  64. package/dist/core/agent-session/run-loop-monitor.d.ts +63 -0
  65. package/dist/core/agent-session/run-loop-monitor.js +164 -0
  66. package/dist/core/agent-session/run-loop-monitor.js.map +1 -0
  67. package/dist/core/agent-session/transcript-markers.d.ts +57 -0
  68. package/dist/core/agent-session/transcript-markers.js +166 -0
  69. package/dist/core/agent-session/transcript-markers.js.map +1 -0
  70. package/dist/core/agent-session/verification-tracker.d.ts +71 -0
  71. package/dist/core/agent-session/verification-tracker.js +295 -0
  72. package/dist/core/agent-session/verification-tracker.js.map +1 -0
  73. package/dist/core/agent-session.d.ts +1401 -0
  74. package/dist/core/agent-session.js +5160 -0
  75. package/dist/core/agent-session.js.map +1 -0
  76. package/dist/core/agents.d.ts +63 -0
  77. package/dist/core/agents.js +160 -0
  78. package/dist/core/agents.js.map +1 -0
  79. package/dist/core/ask-user.d.ts +163 -0
  80. package/dist/core/ask-user.js +178 -0
  81. package/dist/core/ask-user.js.map +1 -0
  82. package/dist/core/auto-update.d.ts +32 -0
  83. package/dist/core/auto-update.js +218 -0
  84. package/dist/core/auto-update.js.map +1 -0
  85. package/dist/core/autopilot-cycle.d.ts +127 -0
  86. package/dist/core/autopilot-cycle.js +182 -0
  87. package/dist/core/autopilot-cycle.js.map +1 -0
  88. package/dist/core/autopilot-gate.d.ts +106 -0
  89. package/dist/core/autopilot-gate.js +192 -0
  90. package/dist/core/autopilot-gate.js.map +1 -0
  91. package/dist/core/autopilot-verdict.d.ts +55 -0
  92. package/dist/core/autopilot-verdict.js +226 -0
  93. package/dist/core/autopilot-verdict.js.map +1 -0
  94. package/dist/core/blocked-packages-file.d.ts +33 -0
  95. package/dist/core/blocked-packages-file.js +274 -0
  96. package/dist/core/blocked-packages-file.js.map +1 -0
  97. package/dist/core/bundled-agents.d.ts +2 -0
  98. package/dist/core/bundled-agents.js +253 -0
  99. package/dist/core/bundled-agents.js.map +1 -0
  100. package/dist/core/cache-diagnostics.d.ts +72 -0
  101. package/dist/core/cache-diagnostics.js +200 -0
  102. package/dist/core/cache-diagnostics.js.map +1 -0
  103. package/dist/core/cache-expiry.d.ts +89 -0
  104. package/dist/core/cache-expiry.js +117 -0
  105. package/dist/core/cache-expiry.js.map +1 -0
  106. package/dist/core/checklist-detection.d.ts +8 -0
  107. package/dist/core/checklist-detection.js +238 -0
  108. package/dist/core/checklist-detection.js.map +1 -0
  109. package/dist/core/checklist-git.d.ts +19 -0
  110. package/dist/core/checklist-git.js +54 -0
  111. package/dist/core/checklist-git.js.map +1 -0
  112. package/dist/core/checklist-items.d.ts +182 -0
  113. package/dist/core/checklist-items.js +228 -0
  114. package/dist/core/checklist-items.js.map +1 -0
  115. package/dist/core/checklist-prompt.d.ts +14 -0
  116. package/dist/core/checklist-prompt.js +64 -0
  117. package/dist/core/checklist-prompt.js.map +1 -0
  118. package/dist/core/checklist-snapshot.d.ts +7 -0
  119. package/dist/core/checklist-snapshot.js +46 -0
  120. package/dist/core/checklist-snapshot.js.map +1 -0
  121. package/dist/core/checklist-store.d.ts +45 -0
  122. package/dist/core/checklist-store.js +278 -0
  123. package/dist/core/checklist-store.js.map +1 -0
  124. package/dist/core/checkout-record.d.ts +22 -0
  125. package/dist/core/checkout-record.js +68 -0
  126. package/dist/core/checkout-record.js.map +1 -0
  127. package/dist/core/checkpoint-store.d.ts +109 -0
  128. package/dist/core/checkpoint-store.js +260 -0
  129. package/dist/core/checkpoint-store.js.map +1 -0
  130. package/dist/core/claude-code/complete.d.ts +35 -0
  131. package/dist/core/claude-code/complete.js +125 -0
  132. package/dist/core/claude-code/complete.js.map +1 -0
  133. package/dist/core/claude-code/events.d.ts +67 -0
  134. package/dist/core/claude-code/events.js +460 -0
  135. package/dist/core/claude-code/events.js.map +1 -0
  136. package/dist/core/claude-code/live-session.d.ts +94 -0
  137. package/dist/core/claude-code/live-session.js +525 -0
  138. package/dist/core/claude-code/live-session.js.map +1 -0
  139. package/dist/core/claude-code/loop.d.ts +9 -0
  140. package/dist/core/claude-code/loop.js +15 -0
  141. package/dist/core/claude-code/loop.js.map +1 -0
  142. package/dist/core/claude-code/session-sync.d.ts +28 -0
  143. package/dist/core/claude-code/session-sync.js +53 -0
  144. package/dist/core/claude-code/session-sync.js.map +1 -0
  145. package/dist/core/claude-code/tool-bridge.d.ts +49 -0
  146. package/dist/core/claude-code/tool-bridge.js +352 -0
  147. package/dist/core/claude-code/tool-bridge.js.map +1 -0
  148. package/dist/core/claude-code/transcripts.d.ts +39 -0
  149. package/dist/core/claude-code/transcripts.js +195 -0
  150. package/dist/core/claude-code/transcripts.js.map +1 -0
  151. package/dist/core/code-retrieval-chunkers.d.ts +26 -0
  152. package/dist/core/code-retrieval-chunkers.js +264 -0
  153. package/dist/core/code-retrieval-chunkers.js.map +1 -0
  154. package/dist/core/code-retrieval.d.ts +18 -0
  155. package/dist/core/code-retrieval.js +124 -0
  156. package/dist/core/code-retrieval.js.map +1 -0
  157. package/dist/core/codex-request-shape.d.ts +7 -0
  158. package/dist/core/codex-request-shape.js +19 -0
  159. package/dist/core/codex-request-shape.js.map +1 -0
  160. package/dist/core/compaction/active-context.d.ts +16 -0
  161. package/dist/core/compaction/active-context.js +20 -0
  162. package/dist/core/compaction/active-context.js.map +1 -0
  163. package/dist/core/compaction/compactor.d.ts +281 -0
  164. package/dist/core/compaction/compactor.js +1451 -0
  165. package/dist/core/compaction/compactor.js.map +1 -0
  166. package/dist/core/compaction/plan-step-policy.d.ts +46 -0
  167. package/dist/core/compaction/plan-step-policy.js +57 -0
  168. package/dist/core/compaction/plan-step-policy.js.map +1 -0
  169. package/dist/core/compaction/policy.d.ts +36 -0
  170. package/dist/core/compaction/policy.js +144 -0
  171. package/dist/core/compaction/policy.js.map +1 -0
  172. package/dist/core/compaction/query-aware-selector.d.ts +32 -0
  173. package/dist/core/compaction/query-aware-selector.js +202 -0
  174. package/dist/core/compaction/query-aware-selector.js.map +1 -0
  175. package/dist/core/compaction/token-estimator.d.ts +36 -0
  176. package/dist/core/compaction/token-estimator.js +180 -0
  177. package/dist/core/compaction/token-estimator.js.map +1 -0
  178. package/dist/core/compaction/tool-result-pruner.d.ts +90 -0
  179. package/dist/core/compaction/tool-result-pruner.js +238 -0
  180. package/dist/core/compaction/tool-result-pruner.js.map +1 -0
  181. package/dist/core/completion-review.d.ts +24 -0
  182. package/dist/core/completion-review.js +2 -0
  183. package/dist/core/completion-review.js.map +1 -0
  184. package/dist/core/context-files.d.ts +8 -0
  185. package/dist/core/context-files.js +46 -0
  186. package/dist/core/context-files.js.map +1 -0
  187. package/dist/core/context-limits.d.ts +40 -0
  188. package/dist/core/context-limits.js +43 -0
  189. package/dist/core/context-limits.js.map +1 -0
  190. package/dist/core/custom-commands.d.ts +18 -0
  191. package/dist/core/custom-commands.js +57 -0
  192. package/dist/core/custom-commands.js.map +1 -0
  193. package/dist/core/destructive-git-guard.d.ts +113 -0
  194. package/dist/core/destructive-git-guard.js +874 -0
  195. package/dist/core/destructive-git-guard.js.map +1 -0
  196. package/dist/core/display-items.d.ts +8 -0
  197. package/dist/core/display-items.js +2 -0
  198. package/dist/core/display-items.js.map +1 -0
  199. package/dist/core/encode-cwd.d.ts +41 -0
  200. package/dist/core/encode-cwd.js +53 -0
  201. package/dist/core/encode-cwd.js.map +1 -0
  202. package/dist/core/env-delta.d.ts +34 -0
  203. package/dist/core/env-delta.js +84 -0
  204. package/dist/core/env-delta.js.map +1 -0
  205. package/dist/core/event-bus.d.ts +178 -0
  206. package/dist/core/event-bus.js +171 -0
  207. package/dist/core/event-bus.js.map +1 -0
  208. package/dist/core/extensions/loader.d.ts +7 -0
  209. package/dist/core/extensions/loader.js +68 -0
  210. package/dist/core/extensions/loader.js.map +1 -0
  211. package/dist/core/extensions/plugin-bundles.d.ts +13 -0
  212. package/dist/core/extensions/plugin-bundles.js +45 -0
  213. package/dist/core/extensions/plugin-bundles.js.map +1 -0
  214. package/dist/core/extensions/types.d.ts +18 -0
  215. package/dist/core/extensions/types.js +2 -0
  216. package/dist/core/extensions/types.js.map +1 -0
  217. package/dist/core/foreign-session-import.d.ts +119 -0
  218. package/dist/core/foreign-session-import.js +598 -0
  219. package/dist/core/foreign-session-import.js.map +1 -0
  220. package/dist/core/foreign-transcript-blocks.d.ts +50 -0
  221. package/dist/core/foreign-transcript-blocks.js +151 -0
  222. package/dist/core/foreign-transcript-blocks.js.map +1 -0
  223. package/dist/core/frontmatter.d.ts +22 -0
  224. package/dist/core/frontmatter.js +90 -0
  225. package/dist/core/frontmatter.js.map +1 -0
  226. package/dist/core/goal-run-marker.d.ts +32 -0
  227. package/dist/core/goal-run-marker.js +178 -0
  228. package/dist/core/goal-run-marker.js.map +1 -0
  229. package/dist/core/goal-summary.d.ts +15 -0
  230. package/dist/core/goal-summary.js +110 -0
  231. package/dist/core/goal-summary.js.map +1 -0
  232. package/dist/core/goals-store.d.ts +208 -0
  233. package/dist/core/goals-store.js +577 -0
  234. package/dist/core/goals-store.js.map +1 -0
  235. package/dist/core/hashline.d.ts +51 -0
  236. package/dist/core/hashline.js +76 -0
  237. package/dist/core/hashline.js.map +1 -0
  238. package/dist/core/idle-wake.d.ts +62 -0
  239. package/dist/core/idle-wake.js +103 -0
  240. package/dist/core/idle-wake.js.map +1 -0
  241. package/dist/core/index.d.ts +15 -0
  242. package/dist/core/index.js +15 -0
  243. package/dist/core/index.js.map +1 -0
  244. package/dist/core/injection-detect.d.ts +39 -0
  245. package/dist/core/injection-detect.js +241 -0
  246. package/dist/core/injection-detect.js.map +1 -0
  247. package/dist/core/installed-threats.d.ts +23 -0
  248. package/dist/core/installed-threats.js +71 -0
  249. package/dist/core/installed-threats.js.map +1 -0
  250. package/dist/core/internal-diagnostics.d.ts +159 -0
  251. package/dist/core/internal-diagnostics.js +495 -0
  252. package/dist/core/internal-diagnostics.js.map +1 -0
  253. package/dist/core/keep-awake.d.ts +88 -0
  254. package/dist/core/keep-awake.js +251 -0
  255. package/dist/core/keep-awake.js.map +1 -0
  256. package/dist/core/ken-ask-answer.d.ts +24 -0
  257. package/dist/core/ken-ask-answer.js +96 -0
  258. package/dist/core/ken-ask-answer.js.map +1 -0
  259. package/dist/core/ken-context.d.ts +119 -0
  260. package/dist/core/ken-context.js +447 -0
  261. package/dist/core/ken-context.js.map +1 -0
  262. package/dist/core/ken-model.d.ts +45 -0
  263. package/dist/core/ken-model.js +26 -0
  264. package/dist/core/ken-model.js.map +1 -0
  265. package/dist/core/ken-prompt.d.ts +21 -0
  266. package/dist/core/ken-prompt.js +370 -0
  267. package/dist/core/ken-prompt.js.map +1 -0
  268. package/dist/core/language-detector.d.ts +41 -0
  269. package/dist/core/language-detector.js +293 -0
  270. package/dist/core/language-detector.js.map +1 -0
  271. package/dist/core/live-preview.d.ts +26 -0
  272. package/dist/core/live-preview.js +80 -0
  273. package/dist/core/live-preview.js.map +1 -0
  274. package/dist/core/local-endpoint-store.d.ts +53 -0
  275. package/dist/core/local-endpoint-store.js +221 -0
  276. package/dist/core/local-endpoint-store.js.map +1 -0
  277. package/dist/core/logger.d.ts +21 -0
  278. package/dist/core/logger.js +94 -0
  279. package/dist/core/logger.js.map +1 -0
  280. package/dist/core/loop-breaker.d.ts +89 -0
  281. package/dist/core/loop-breaker.js +204 -0
  282. package/dist/core/loop-breaker.js.map +1 -0
  283. package/dist/core/lsp/client.d.ts +206 -0
  284. package/dist/core/lsp/client.js +685 -0
  285. package/dist/core/lsp/client.js.map +1 -0
  286. package/dist/core/lsp/edit-telemetry.d.ts +26 -0
  287. package/dist/core/lsp/edit-telemetry.js +52 -0
  288. package/dist/core/lsp/edit-telemetry.js.map +1 -0
  289. package/dist/core/lsp/format.d.ts +11 -0
  290. package/dist/core/lsp/format.js +30 -0
  291. package/dist/core/lsp/format.js.map +1 -0
  292. package/dist/core/lsp/jsonrpc.d.ts +68 -0
  293. package/dist/core/lsp/jsonrpc.js +153 -0
  294. package/dist/core/lsp/jsonrpc.js.map +1 -0
  295. package/dist/core/lsp/manager.d.ts +188 -0
  296. package/dist/core/lsp/manager.js +576 -0
  297. package/dist/core/lsp/manager.js.map +1 -0
  298. package/dist/core/lsp/pool.d.ts +114 -0
  299. package/dist/core/lsp/pool.js +259 -0
  300. package/dist/core/lsp/pool.js.map +1 -0
  301. package/dist/core/lsp/project-root.d.ts +9 -0
  302. package/dist/core/lsp/project-root.js +75 -0
  303. package/dist/core/lsp/project-root.js.map +1 -0
  304. package/dist/core/lsp/reference-project.d.ts +6 -0
  305. package/dist/core/lsp/reference-project.js +110 -0
  306. package/dist/core/lsp/reference-project.js.map +1 -0
  307. package/dist/core/lsp/servers.d.ts +44 -0
  308. package/dist/core/lsp/servers.js +289 -0
  309. package/dist/core/lsp/servers.js.map +1 -0
  310. package/dist/core/lsp/test-support.d.ts +17 -0
  311. package/dist/core/lsp/test-support.js +27 -0
  312. package/dist/core/lsp/test-support.js.map +1 -0
  313. package/dist/core/mcp/catalog-cache.d.ts +64 -0
  314. package/dist/core/mcp/catalog-cache.js +166 -0
  315. package/dist/core/mcp/catalog-cache.js.map +1 -0
  316. package/dist/core/mcp/client.d.ts +317 -0
  317. package/dist/core/mcp/client.js +1168 -0
  318. package/dist/core/mcp/client.js.map +1 -0
  319. package/dist/core/mcp/content.d.ts +23 -0
  320. package/dist/core/mcp/content.js +194 -0
  321. package/dist/core/mcp/content.js.map +1 -0
  322. package/dist/core/mcp/defaults.d.ts +26 -0
  323. package/dist/core/mcp/defaults.js +81 -0
  324. package/dist/core/mcp/defaults.js.map +1 -0
  325. package/dist/core/mcp/deferred-catalog.d.ts +53 -0
  326. package/dist/core/mcp/deferred-catalog.js +117 -0
  327. package/dist/core/mcp/deferred-catalog.js.map +1 -0
  328. package/dist/core/mcp/elicitation-bridge.d.ts +40 -0
  329. package/dist/core/mcp/elicitation-bridge.js +36 -0
  330. package/dist/core/mcp/elicitation-bridge.js.map +1 -0
  331. package/dist/core/mcp/index.d.ts +16 -0
  332. package/dist/core/mcp/index.js +10 -0
  333. package/dist/core/mcp/index.js.map +1 -0
  334. package/dist/core/mcp/loopback.d.ts +26 -0
  335. package/dist/core/mcp/loopback.js +66 -0
  336. package/dist/core/mcp/loopback.js.map +1 -0
  337. package/dist/core/mcp/oauth-provider.d.ts +55 -0
  338. package/dist/core/mcp/oauth-provider.js +106 -0
  339. package/dist/core/mcp/oauth-provider.js.map +1 -0
  340. package/dist/core/mcp/oauth-store.d.ts +44 -0
  341. package/dist/core/mcp/oauth-store.js +76 -0
  342. package/dist/core/mcp/oauth-store.js.map +1 -0
  343. package/dist/core/mcp/parse-add-command.d.ts +50 -0
  344. package/dist/core/mcp/parse-add-command.js +391 -0
  345. package/dist/core/mcp/parse-add-command.js.map +1 -0
  346. package/dist/core/mcp/resolve-stdio.d.ts +77 -0
  347. package/dist/core/mcp/resolve-stdio.js +359 -0
  348. package/dist/core/mcp/resolve-stdio.js.map +1 -0
  349. package/dist/core/mcp/shared-pool.d.ts +157 -0
  350. package/dist/core/mcp/shared-pool.js +236 -0
  351. package/dist/core/mcp/shared-pool.js.map +1 -0
  352. package/dist/core/mcp/store.d.ts +100 -0
  353. package/dist/core/mcp/store.js +202 -0
  354. package/dist/core/mcp/store.js.map +1 -0
  355. package/dist/core/mcp/tool-guard.d.ts +58 -0
  356. package/dist/core/mcp/tool-guard.js +215 -0
  357. package/dist/core/mcp/tool-guard.js.map +1 -0
  358. package/dist/core/mcp/types.d.ts +57 -0
  359. package/dist/core/mcp/types.js +2 -0
  360. package/dist/core/mcp/types.js.map +1 -0
  361. package/dist/core/message-images.d.ts +11 -0
  362. package/dist/core/message-images.js +52 -0
  363. package/dist/core/message-images.js.map +1 -0
  364. package/dist/core/model-unavailable.d.ts +14 -0
  365. package/dist/core/model-unavailable.js +23 -0
  366. package/dist/core/model-unavailable.js.map +1 -0
  367. package/dist/core/network-guard.d.ts +28 -0
  368. package/dist/core/network-guard.js +251 -0
  369. package/dist/core/network-guard.js.map +1 -0
  370. package/dist/core/node-debugger.d.ts +148 -0
  371. package/dist/core/node-debugger.js +642 -0
  372. package/dist/core/node-debugger.js.map +1 -0
  373. package/dist/core/opencode-catalog-store.d.ts +20 -0
  374. package/dist/core/opencode-catalog-store.js +82 -0
  375. package/dist/core/opencode-catalog-store.js.map +1 -0
  376. package/dist/core/openrouter-catalog-store.d.ts +24 -0
  377. package/dist/core/openrouter-catalog-store.js +140 -0
  378. package/dist/core/openrouter-catalog-store.js.map +1 -0
  379. package/dist/core/package-cooldown.d.ts +69 -0
  380. package/dist/core/package-cooldown.js +297 -0
  381. package/dist/core/package-cooldown.js.map +1 -0
  382. package/dist/core/package-threats.d.ts +92 -0
  383. package/dist/core/package-threats.js +1339 -0
  384. package/dist/core/package-threats.js.map +1 -0
  385. package/dist/core/parked-requests.d.ts +43 -0
  386. package/dist/core/parked-requests.js +34 -0
  387. package/dist/core/parked-requests.js.map +1 -0
  388. package/dist/core/persistent-shell.d.ts +81 -0
  389. package/dist/core/persistent-shell.js +452 -0
  390. package/dist/core/persistent-shell.js.map +1 -0
  391. package/dist/core/plan-delta.d.ts +23 -0
  392. package/dist/core/plan-delta.js +36 -0
  393. package/dist/core/plan-delta.js.map +1 -0
  394. package/dist/core/plan-handoff.d.ts +38 -0
  395. package/dist/core/plan-handoff.js +21 -0
  396. package/dist/core/plan-handoff.js.map +1 -0
  397. package/dist/core/plan-submission-gate.d.ts +28 -0
  398. package/dist/core/plan-submission-gate.js +27 -0
  399. package/dist/core/plan-submission-gate.js.map +1 -0
  400. package/dist/core/platform-clis.d.ts +15 -0
  401. package/dist/core/platform-clis.js +299 -0
  402. package/dist/core/platform-clis.js.map +1 -0
  403. package/dist/core/process-gate.d.ts +61 -0
  404. package/dist/core/process-gate.js +103 -0
  405. package/dist/core/process-gate.js.map +1 -0
  406. package/dist/core/process-manager.d.ts +242 -0
  407. package/dist/core/process-manager.js +902 -0
  408. package/dist/core/process-manager.js.map +1 -0
  409. package/dist/core/progress/engine.d.ts +22 -0
  410. package/dist/core/progress/engine.js +131 -0
  411. package/dist/core/progress/engine.js.map +1 -0
  412. package/dist/core/progress/git-xp.d.ts +15 -0
  413. package/dist/core/progress/git-xp.js +100 -0
  414. package/dist/core/progress/git-xp.js.map +1 -0
  415. package/dist/core/progress/ranks.d.ts +31 -0
  416. package/dist/core/progress/ranks.js +310 -0
  417. package/dist/core/progress/ranks.js.map +1 -0
  418. package/dist/core/progress/rebuild.d.ts +8 -0
  419. package/dist/core/progress/rebuild.js +125 -0
  420. package/dist/core/progress/rebuild.js.map +1 -0
  421. package/dist/core/progress/store.d.ts +34 -0
  422. package/dist/core/progress/store.js +200 -0
  423. package/dist/core/progress/store.js.map +1 -0
  424. package/dist/core/progress/types.d.ts +56 -0
  425. package/dist/core/progress/types.js +2 -0
  426. package/dist/core/progress/types.js.map +1 -0
  427. package/dist/core/project-discovery.d.ts +64 -0
  428. package/dist/core/project-discovery.js +908 -0
  429. package/dist/core/project-discovery.js.map +1 -0
  430. package/dist/core/project-files.d.ts +15 -0
  431. package/dist/core/project-files.js +37 -0
  432. package/dist/core/project-files.js.map +1 -0
  433. package/dist/core/project-health-scan.d.ts +109 -0
  434. package/dist/core/project-health-scan.js +673 -0
  435. package/dist/core/project-health-scan.js.map +1 -0
  436. package/dist/core/project-health-score.d.ts +41 -0
  437. package/dist/core/project-health-score.js +257 -0
  438. package/dist/core/project-health-score.js.map +1 -0
  439. package/dist/core/prompt-command-expansion.d.ts +13 -0
  440. package/dist/core/prompt-command-expansion.js +48 -0
  441. package/dist/core/prompt-command-expansion.js.map +1 -0
  442. package/dist/core/prompt-commands.d.ts +13 -0
  443. package/dist/core/prompt-commands.js +370 -0
  444. package/dist/core/prompt-commands.js.map +1 -0
  445. package/dist/core/radio-players.d.ts +28 -0
  446. package/dist/core/radio-players.js +132 -0
  447. package/dist/core/radio-players.js.map +1 -0
  448. package/dist/core/radio.d.ts +42 -0
  449. package/dist/core/radio.js +499 -0
  450. package/dist/core/radio.js.map +1 -0
  451. package/dist/core/regrounding.d.ts +37 -0
  452. package/dist/core/regrounding.js +89 -0
  453. package/dist/core/regrounding.js.map +1 -0
  454. package/dist/core/resolve-start.d.ts +28 -0
  455. package/dist/core/resolve-start.js +35 -0
  456. package/dist/core/resolve-start.js.map +1 -0
  457. package/dist/core/run-claim.d.ts +36 -0
  458. package/dist/core/run-claim.js +46 -0
  459. package/dist/core/run-claim.js.map +1 -0
  460. package/dist/core/run-lifecycle.d.ts +58 -0
  461. package/dist/core/run-lifecycle.js +104 -0
  462. package/dist/core/run-lifecycle.js.map +1 -0
  463. package/dist/core/run-status.d.ts +17 -0
  464. package/dist/core/run-status.js +28 -0
  465. package/dist/core/run-status.js.map +1 -0
  466. package/dist/core/runtime-mode.d.ts +21 -0
  467. package/dist/core/runtime-mode.js +43 -0
  468. package/dist/core/runtime-mode.js.map +1 -0
  469. package/dist/core/sandbox-domains.d.ts +13 -0
  470. package/dist/core/sandbox-domains.js +76 -0
  471. package/dist/core/sandbox-domains.js.map +1 -0
  472. package/dist/core/sandbox-feedback.d.ts +21 -0
  473. package/dist/core/sandbox-feedback.js +69 -0
  474. package/dist/core/sandbox-feedback.js.map +1 -0
  475. package/dist/core/sandbox.d.ts +106 -0
  476. package/dist/core/sandbox.js +383 -0
  477. package/dist/core/sandbox.js.map +1 -0
  478. package/dist/core/semantic-loop-check.d.ts +58 -0
  479. package/dist/core/semantic-loop-check.js +103 -0
  480. package/dist/core/semantic-loop-check.js.map +1 -0
  481. package/dist/core/session-compaction.d.ts +23 -0
  482. package/dist/core/session-compaction.js +54 -0
  483. package/dist/core/session-compaction.js.map +1 -0
  484. package/dist/core/session-export.d.ts +97 -0
  485. package/dist/core/session-export.js +368 -0
  486. package/dist/core/session-export.js.map +1 -0
  487. package/dist/core/session-history.d.ts +160 -0
  488. package/dist/core/session-history.js +467 -0
  489. package/dist/core/session-history.js.map +1 -0
  490. package/dist/core/session-manager.d.ts +510 -0
  491. package/dist/core/session-manager.js +1368 -0
  492. package/dist/core/session-manager.js.map +1 -0
  493. package/dist/core/session-preview.d.ts +12 -0
  494. package/dist/core/session-preview.js +58 -0
  495. package/dist/core/session-preview.js.map +1 -0
  496. package/dist/core/session-storage.d.ts +78 -0
  497. package/dist/core/session-storage.js +659 -0
  498. package/dist/core/session-storage.js.map +1 -0
  499. package/dist/core/session-summary-index.d.ts +51 -0
  500. package/dist/core/session-summary-index.js +192 -0
  501. package/dist/core/session-summary-index.js.map +1 -0
  502. package/dist/core/settings-manager.d.ts +113 -0
  503. package/dist/core/settings-manager.js +281 -0
  504. package/dist/core/settings-manager.js.map +1 -0
  505. package/dist/core/shared-checkout-guard.d.ts +78 -0
  506. package/dist/core/shared-checkout-guard.js +219 -0
  507. package/dist/core/shared-checkout-guard.js.map +1 -0
  508. package/dist/core/shell-path.d.ts +13 -0
  509. package/dist/core/shell-path.js +175 -0
  510. package/dist/core/shell-path.js.map +1 -0
  511. package/dist/core/shell-threats-popular-packages.d.ts +11 -0
  512. package/dist/core/shell-threats-popular-packages.js +675 -0
  513. package/dist/core/shell-threats-popular-packages.js.map +1 -0
  514. package/dist/core/shell-threats.d.ts +21 -0
  515. package/dist/core/shell-threats.js +235 -0
  516. package/dist/core/shell-threats.js.map +1 -0
  517. package/dist/core/shell.d.ts +54 -0
  518. package/dist/core/shell.js +99 -0
  519. package/dist/core/shell.js.map +1 -0
  520. package/dist/core/shutdown.d.ts +70 -0
  521. package/dist/core/shutdown.js +144 -0
  522. package/dist/core/shutdown.js.map +1 -0
  523. package/dist/core/skill-scan.d.ts +112 -0
  524. package/dist/core/skill-scan.js +781 -0
  525. package/dist/core/skill-scan.js.map +1 -0
  526. package/dist/core/skills.d.ts +80 -0
  527. package/dist/core/skills.js +270 -0
  528. package/dist/core/skills.js.map +1 -0
  529. package/dist/core/slash-commands.d.ts +58 -0
  530. package/dist/core/slash-commands.js +242 -0
  531. package/dist/core/slash-commands.js.map +1 -0
  532. package/dist/core/steering.d.ts +47 -0
  533. package/dist/core/steering.js +65 -0
  534. package/dist/core/steering.js.map +1 -0
  535. package/dist/core/steroids.d.ts +66 -0
  536. package/dist/core/steroids.js +243 -0
  537. package/dist/core/steroids.js.map +1 -0
  538. package/dist/core/stream-diag-level.d.ts +3 -0
  539. package/dist/core/stream-diag-level.js +24 -0
  540. package/dist/core/stream-diag-level.js.map +1 -0
  541. package/dist/core/stream-rules.d.ts +30 -0
  542. package/dist/core/stream-rules.js +151 -0
  543. package/dist/core/stream-rules.js.map +1 -0
  544. package/dist/core/subagent-manager.d.ts +239 -0
  545. package/dist/core/subagent-manager.js +1059 -0
  546. package/dist/core/subagent-manager.js.map +1 -0
  547. package/dist/core/subagent-policy.d.ts +9 -0
  548. package/dist/core/subagent-policy.js +41 -0
  549. package/dist/core/subagent-policy.js.map +1 -0
  550. package/dist/core/subagent-receipt.d.ts +54 -0
  551. package/dist/core/subagent-receipt.js +274 -0
  552. package/dist/core/subagent-receipt.js.map +1 -0
  553. package/dist/core/subagent-store.d.ts +41 -0
  554. package/dist/core/subagent-store.js +284 -0
  555. package/dist/core/subagent-store.js.map +1 -0
  556. package/dist/core/subagent-turn-record.d.ts +18 -0
  557. package/dist/core/subagent-turn-record.js +82 -0
  558. package/dist/core/subagent-turn-record.js.map +1 -0
  559. package/dist/core/tasks-store.d.ts +31 -0
  560. package/dist/core/tasks-store.js +97 -0
  561. package/dist/core/tasks-store.js.map +1 -0
  562. package/dist/core/telegram-config.d.ts +20 -0
  563. package/dist/core/telegram-config.js +52 -0
  564. package/dist/core/telegram-config.js.map +1 -0
  565. package/dist/core/telegram.d.ts +114 -0
  566. package/dist/core/telegram.js +275 -0
  567. package/dist/core/telegram.js.map +1 -0
  568. package/dist/core/temp-paths.d.ts +5 -0
  569. package/dist/core/temp-paths.js +50 -0
  570. package/dist/core/temp-paths.js.map +1 -0
  571. package/dist/core/test-impact.d.ts +73 -0
  572. package/dist/core/test-impact.js +467 -0
  573. package/dist/core/test-impact.js.map +1 -0
  574. package/dist/core/threat-feed.d.ts +65 -0
  575. package/dist/core/threat-feed.js +334 -0
  576. package/dist/core/threat-feed.js.map +1 -0
  577. package/dist/core/trophies/catalog-more.d.ts +2 -0
  578. package/dist/core/trophies/catalog-more.js +837 -0
  579. package/dist/core/trophies/catalog-more.js.map +1 -0
  580. package/dist/core/trophies/catalog.d.ts +4 -0
  581. package/dist/core/trophies/catalog.js +649 -0
  582. package/dist/core/trophies/catalog.js.map +1 -0
  583. package/dist/core/trophies/engine.d.ts +70 -0
  584. package/dist/core/trophies/engine.js +347 -0
  585. package/dist/core/trophies/engine.js.map +1 -0
  586. package/dist/core/trophies/store.d.ts +17 -0
  587. package/dist/core/trophies/store.js +113 -0
  588. package/dist/core/trophies/store.js.map +1 -0
  589. package/dist/core/trophies/types.d.ts +87 -0
  590. package/dist/core/trophies/types.js +74 -0
  591. package/dist/core/trophies/types.js.map +1 -0
  592. package/dist/core/ui-adoption.d.ts +32 -0
  593. package/dist/core/ui-adoption.js +302 -0
  594. package/dist/core/ui-adoption.js.map +1 -0
  595. package/dist/core/ui-compatibility.d.ts +10 -0
  596. package/dist/core/ui-compatibility.js +51 -0
  597. package/dist/core/ui-compatibility.js.map +1 -0
  598. package/dist/core/ui-registry.d.ts +101 -0
  599. package/dist/core/ui-registry.js +292 -0
  600. package/dist/core/ui-registry.js.map +1 -0
  601. package/dist/core/user-shell-context.d.ts +8 -0
  602. package/dist/core/user-shell-context.js +12 -0
  603. package/dist/core/user-shell-context.js.map +1 -0
  604. package/dist/core/verification-evidence.d.ts +49 -0
  605. package/dist/core/verification-evidence.js +816 -0
  606. package/dist/core/verification-evidence.js.map +1 -0
  607. package/dist/core/verification-gate.d.ts +77 -0
  608. package/dist/core/verification-gate.js +504 -0
  609. package/dist/core/verification-gate.js.map +1 -0
  610. package/dist/core/verification-snapshot.d.ts +7 -0
  611. package/dist/core/verification-snapshot.js +109 -0
  612. package/dist/core/verification-snapshot.js.map +1 -0
  613. package/dist/core/verify-commands.d.ts +34 -0
  614. package/dist/core/verify-commands.js +203 -0
  615. package/dist/core/verify-commands.js.map +1 -0
  616. package/dist/core/voice-transcriber.d.ts +32 -0
  617. package/dist/core/voice-transcriber.js +114 -0
  618. package/dist/core/voice-transcriber.js.map +1 -0
  619. package/dist/core/workspace-guard.d.ts +56 -0
  620. package/dist/core/workspace-guard.js +334 -0
  621. package/dist/core/workspace-guard.js.map +1 -0
  622. package/dist/index.d.ts +15 -0
  623. package/dist/index.js +21 -0
  624. package/dist/index.js.map +1 -0
  625. package/dist/session.d.ts +44 -0
  626. package/dist/session.js +105 -0
  627. package/dist/session.js.map +1 -0
  628. package/dist/system-prompt.d.ts +104 -0
  629. package/dist/system-prompt.js +480 -0
  630. package/dist/system-prompt.js.map +1 -0
  631. package/dist/test-support/fake-home.d.ts +19 -0
  632. package/dist/test-support/fake-home.js +37 -0
  633. package/dist/test-support/fake-home.js.map +1 -0
  634. package/dist/test-support/keep-alive.d.ts +14 -0
  635. package/dist/test-support/keep-alive.js +17 -0
  636. package/dist/test-support/keep-alive.js.map +1 -0
  637. package/dist/test-support/slow-git.d.ts +1 -0
  638. package/dist/test-support/slow-git.js +21 -0
  639. package/dist/test-support/slow-git.js.map +1 -0
  640. package/dist/test-support/system-tools.d.ts +6 -0
  641. package/dist/test-support/system-tools.js +36 -0
  642. package/dist/test-support/system-tools.js.map +1 -0
  643. package/dist/tools/ask-user.d.ts +34 -0
  644. package/dist/tools/ask-user.js +99 -0
  645. package/dist/tools/ask-user.js.map +1 -0
  646. package/dist/tools/background-watch-lint.d.ts +18 -0
  647. package/dist/tools/background-watch-lint.js +102 -0
  648. package/dist/tools/background-watch-lint.js.map +1 -0
  649. package/dist/tools/bash-read-evidence.d.ts +23 -0
  650. package/dist/tools/bash-read-evidence.js +180 -0
  651. package/dist/tools/bash-read-evidence.js.map +1 -0
  652. package/dist/tools/bash.d.ts +64 -0
  653. package/dist/tools/bash.js +552 -0
  654. package/dist/tools/bash.js.map +1 -0
  655. package/dist/tools/browser-api.d.ts +27 -0
  656. package/dist/tools/browser-api.js +449 -0
  657. package/dist/tools/browser-api.js.map +1 -0
  658. package/dist/tools/browser-sandbox.d.ts +16 -0
  659. package/dist/tools/browser-sandbox.js +158 -0
  660. package/dist/tools/browser-sandbox.js.map +1 -0
  661. package/dist/tools/browser-session.d.ts +84 -0
  662. package/dist/tools/browser-session.js +304 -0
  663. package/dist/tools/browser-session.js.map +1 -0
  664. package/dist/tools/browser-snapshot.d.ts +19 -0
  665. package/dist/tools/browser-snapshot.js +109 -0
  666. package/dist/tools/browser-snapshot.js.map +1 -0
  667. package/dist/tools/browser.d.ts +11 -0
  668. package/dist/tools/browser.js +106 -0
  669. package/dist/tools/browser.js.map +1 -0
  670. package/dist/tools/checklist.d.ts +49 -0
  671. package/dist/tools/checklist.js +154 -0
  672. package/dist/tools/checklist.js.map +1 -0
  673. package/dist/tools/compress.d.ts +56 -0
  674. package/dist/tools/compress.js +226 -0
  675. package/dist/tools/compress.js.map +1 -0
  676. package/dist/tools/debug.d.ts +54 -0
  677. package/dist/tools/debug.js +230 -0
  678. package/dist/tools/debug.js.map +1 -0
  679. package/dist/tools/document-text.d.ts +6 -0
  680. package/dist/tools/document-text.js +154 -0
  681. package/dist/tools/document-text.js.map +1 -0
  682. package/dist/tools/edit-diff.d.ts +123 -0
  683. package/dist/tools/edit-diff.js +476 -0
  684. package/dist/tools/edit-diff.js.map +1 -0
  685. package/dist/tools/edit-targets.d.ts +10 -0
  686. package/dist/tools/edit-targets.js +31 -0
  687. package/dist/tools/edit-targets.js.map +1 -0
  688. package/dist/tools/edit.d.ts +38 -0
  689. package/dist/tools/edit.js +695 -0
  690. package/dist/tools/edit.js.map +1 -0
  691. package/dist/tools/enter-plan.d.ts +7 -0
  692. package/dist/tools/enter-plan.js +20 -0
  693. package/dist/tools/enter-plan.js.map +1 -0
  694. package/dist/tools/exit-plan.d.ts +7 -0
  695. package/dist/tools/exit-plan.js +51 -0
  696. package/dist/tools/exit-plan.js.map +1 -0
  697. package/dist/tools/find.d.ts +17 -0
  698. package/dist/tools/find.js +100 -0
  699. package/dist/tools/find.js.map +1 -0
  700. package/dist/tools/generate-image.d.ts +83 -0
  701. package/dist/tools/generate-image.js +625 -0
  702. package/dist/tools/generate-image.js.map +1 -0
  703. package/dist/tools/grep-scan.d.ts +96 -0
  704. package/dist/tools/grep-scan.js +283 -0
  705. package/dist/tools/grep-scan.js.map +1 -0
  706. package/dist/tools/grep.d.ts +48 -0
  707. package/dist/tools/grep.js +1013 -0
  708. package/dist/tools/grep.js.map +1 -0
  709. package/dist/tools/html-extract.d.ts +57 -0
  710. package/dist/tools/html-extract.js +130 -0
  711. package/dist/tools/html-extract.js.map +1 -0
  712. package/dist/tools/index.d.ts +198 -0
  713. package/dist/tools/index.js +216 -0
  714. package/dist/tools/index.js.map +1 -0
  715. package/dist/tools/live-preview.d.ts +23 -0
  716. package/dist/tools/live-preview.js +41 -0
  717. package/dist/tools/live-preview.js.map +1 -0
  718. package/dist/tools/ls.d.ts +9 -0
  719. package/dist/tools/ls.js +59 -0
  720. package/dist/tools/ls.js.map +1 -0
  721. package/dist/tools/operations.d.ts +86 -0
  722. package/dist/tools/operations.js +117 -0
  723. package/dist/tools/operations.js.map +1 -0
  724. package/dist/tools/overflow.d.ts +17 -0
  725. package/dist/tools/overflow.js +68 -0
  726. package/dist/tools/overflow.js.map +1 -0
  727. package/dist/tools/path-utils.d.ts +30 -0
  728. package/dist/tools/path-utils.js +74 -0
  729. package/dist/tools/path-utils.js.map +1 -0
  730. package/dist/tools/pdf-extract.d.ts +17 -0
  731. package/dist/tools/pdf-extract.js +43 -0
  732. package/dist/tools/pdf-extract.js.map +1 -0
  733. package/dist/tools/prompt-hints.d.ts +46 -0
  734. package/dist/tools/prompt-hints.js +171 -0
  735. package/dist/tools/prompt-hints.js.map +1 -0
  736. package/dist/tools/read-only-bash.d.ts +31 -0
  737. package/dist/tools/read-only-bash.js +338 -0
  738. package/dist/tools/read-only-bash.js.map +1 -0
  739. package/dist/tools/read-tracker.d.ts +43 -0
  740. package/dist/tools/read-tracker.js +120 -0
  741. package/dist/tools/read-tracker.js.map +1 -0
  742. package/dist/tools/read.d.ts +18 -0
  743. package/dist/tools/read.js +316 -0
  744. package/dist/tools/read.js.map +1 -0
  745. package/dist/tools/redaction-guard.d.ts +10 -0
  746. package/dist/tools/redaction-guard.js +55 -0
  747. package/dist/tools/redaction-guard.js.map +1 -0
  748. package/dist/tools/routine-output.d.ts +39 -0
  749. package/dist/tools/routine-output.js +281 -0
  750. package/dist/tools/routine-output.js.map +1 -0
  751. package/dist/tools/safe-env.d.ts +1 -0
  752. package/dist/tools/safe-env.js +79 -0
  753. package/dist/tools/safe-env.js.map +1 -0
  754. package/dist/tools/session-stats.d.ts +26 -0
  755. package/dist/tools/session-stats.js +51 -0
  756. package/dist/tools/session-stats.js.map +1 -0
  757. package/dist/tools/side-web-search.d.ts +34 -0
  758. package/dist/tools/side-web-search.js +146 -0
  759. package/dist/tools/side-web-search.js.map +1 -0
  760. package/dist/tools/skill.d.ts +12 -0
  761. package/dist/tools/skill.js +94 -0
  762. package/dist/tools/skill.js.map +1 -0
  763. package/dist/tools/source-path.d.ts +8 -0
  764. package/dist/tools/source-path.js +135 -0
  765. package/dist/tools/source-path.js.map +1 -0
  766. package/dist/tools/steroids.d.ts +44 -0
  767. package/dist/tools/steroids.js +356 -0
  768. package/dist/tools/steroids.js.map +1 -0
  769. package/dist/tools/subagent-control.d.ts +5 -0
  770. package/dist/tools/subagent-control.js +211 -0
  771. package/dist/tools/subagent-control.js.map +1 -0
  772. package/dist/tools/subagent-shared.d.ts +115 -0
  773. package/dist/tools/subagent-shared.js +182 -0
  774. package/dist/tools/subagent-shared.js.map +1 -0
  775. package/dist/tools/subagent.d.ts +37 -0
  776. package/dist/tools/subagent.js +406 -0
  777. package/dist/tools/subagent.js.map +1 -0
  778. package/dist/tools/task-output.d.ts +10 -0
  779. package/dist/tools/task-output.js +74 -0
  780. package/dist/tools/task-output.js.map +1 -0
  781. package/dist/tools/task-send.d.ts +11 -0
  782. package/dist/tools/task-send.js +36 -0
  783. package/dist/tools/task-send.js.map +1 -0
  784. package/dist/tools/task-stop.d.ts +8 -0
  785. package/dist/tools/task-stop.js +15 -0
  786. package/dist/tools/task-stop.js.map +1 -0
  787. package/dist/tools/tasks.d.ts +15 -0
  788. package/dist/tools/tasks.js +94 -0
  789. package/dist/tools/tasks.js.map +1 -0
  790. package/dist/tools/tool-search.d.ts +26 -0
  791. package/dist/tools/tool-search.js +81 -0
  792. package/dist/tools/tool-search.js.map +1 -0
  793. package/dist/tools/tool-tiers.d.ts +65 -0
  794. package/dist/tools/tool-tiers.js +121 -0
  795. package/dist/tools/tool-tiers.js.map +1 -0
  796. package/dist/tools/truncate.d.ts +39 -0
  797. package/dist/tools/truncate.js +242 -0
  798. package/dist/tools/truncate.js.map +1 -0
  799. package/dist/tools/ui-adopt.d.ts +16 -0
  800. package/dist/tools/ui-adopt.js +66 -0
  801. package/dist/tools/ui-adopt.js.map +1 -0
  802. package/dist/tools/ui-registry.d.ts +15 -0
  803. package/dist/tools/ui-registry.js +39 -0
  804. package/dist/tools/ui-registry.js.map +1 -0
  805. package/dist/tools/verification-review.d.ts +2 -0
  806. package/dist/tools/verification-review.js +41 -0
  807. package/dist/tools/verification-review.js.map +1 -0
  808. package/dist/tools/web-fetch.d.ts +52 -0
  809. package/dist/tools/web-fetch.js +986 -0
  810. package/dist/tools/web-fetch.js.map +1 -0
  811. package/dist/tools/web-search.d.ts +35 -0
  812. package/dist/tools/web-search.js +926 -0
  813. package/dist/tools/web-search.js.map +1 -0
  814. package/dist/tools/write.d.ts +16 -0
  815. package/dist/tools/write.js +196 -0
  816. package/dist/tools/write.js.map +1 -0
  817. package/dist/types.d.ts +44 -0
  818. package/dist/types.js +2 -0
  819. package/dist/types.js.map +1 -0
  820. package/dist/utils/commit-message.d.ts +25 -0
  821. package/dist/utils/commit-message.js +72 -0
  822. package/dist/utils/commit-message.js.map +1 -0
  823. package/dist/utils/git.d.ts +102 -0
  824. package/dist/utils/git.js +325 -0
  825. package/dist/utils/git.js.map +1 -0
  826. package/dist/utils/github-ci.d.ts +9 -0
  827. package/dist/utils/github-ci.js +138 -0
  828. package/dist/utils/github-ci.js.map +1 -0
  829. package/dist/utils/github.d.ts +19 -0
  830. package/dist/utils/github.js +67 -0
  831. package/dist/utils/github.js.map +1 -0
  832. package/dist/utils/image.d.ts +166 -0
  833. package/dist/utils/image.js +673 -0
  834. package/dist/utils/image.js.map +1 -0
  835. package/dist/utils/open-browser.d.ts +13 -0
  836. package/dist/utils/open-browser.js +31 -0
  837. package/dist/utils/open-browser.js.map +1 -0
  838. package/dist/utils/plan-steps.d.ts +90 -0
  839. package/dist/utils/plan-steps.js +209 -0
  840. package/dist/utils/plan-steps.js.map +1 -0
  841. package/dist/utils/process.d.ts +48 -0
  842. package/dist/utils/process.js +175 -0
  843. package/dist/utils/process.js.map +1 -0
  844. package/dist/utils/prompt-enhancer.d.ts +34 -0
  845. package/dist/utils/prompt-enhancer.js +178 -0
  846. package/dist/utils/prompt-enhancer.js.map +1 -0
  847. package/dist/utils/text.d.ts +61 -0
  848. package/dist/utils/text.js +68 -0
  849. package/dist/utils/text.js.map +1 -0
  850. package/package.json +87 -3
@@ -0,0 +1,1401 @@
1
+ import { type AgentTool, type ToolExecuteResult } from "@kenkaiiii/gg-agent";
2
+ import { type Message, type MessageProvenance, type Provider, type Usage, type ThinkingLevel, type TextContent, type ImageContent, type VideoContent } from "@kenkaiiii/gg-ai";
3
+ import { EventBus } from "./event-bus.js";
4
+ import { type InstalledThreat } from "./installed-threats.js";
5
+ import type { PackageCheckOptions } from "./package-threats.js";
6
+ import { type CompletionReview } from "./completion-review.js";
7
+ import { SlashCommandRegistry } from "./slash-commands.js";
8
+ import { type CustomCommand } from "./custom-commands.js";
9
+ import { type BranchInfo, type KenTurnPayload, type AutopilotMarkerPayload, type AppMarkerPayload, type RunOutcome, type TurnMetricPayload } from "./session-manager.js";
10
+ import { type BlockedSkill, type Skill } from "./skills.js";
11
+ import type { BackgroundProcess } from "./process-manager.js";
12
+ import { type ChildModelPick, type SubAgentSnapshot } from "./subagent-manager.js";
13
+ import type { MCPElicitHandler } from "./mcp/index.js";
14
+ import type { MCPServerConfig } from "./mcp/types.js";
15
+ import { type ContextLimits } from "./context-limits.js";
16
+ import { type ImportForeignTranscriptResult } from "./foreign-session-import.js";
17
+ import { type CacheExpiryStatus } from "./cache-expiry.js";
18
+ import { type AgentDefinition } from "./agents.js";
19
+ import { type EnhanceResult } from "../utils/prompt-enhancer.js";
20
+ import { type CommitMessage } from "../utils/commit-message.js";
21
+ import { type CheckoutRecord } from "./checkout-record.js";
22
+ import type { VerificationEvidence } from "./verification-evidence.js";
23
+ /**
24
+ * The output cap to send on a request. A model's output ceiling can equal its
25
+ * whole window (Kimi K2.7 Code: 262,144 of 262,144), and providers that count
26
+ * prompt + max_tokens against the window reject every request with a real
27
+ * prompt. Cap it at the room the model's TOTAL window leaves once the context
28
+ * reaches this session's compaction trigger — the largest prompt it lets build
29
+ * up. The total window, not the route's: the ChatGPT/Codex route's 272K
30
+ * window is an input budget, and GPT-6's 128K output sits outside it.
31
+ */
32
+ export declare function outputCapForRequest(options: {
33
+ provider: Provider;
34
+ model: string;
35
+ maxTokens: number;
36
+ threshold: number;
37
+ accountId?: string;
38
+ }): number;
39
+ /**
40
+ * Reply for chat bridges (Telegram, agent home) that have no confirmation step.
41
+ * Generic on purpose: every paid model (Claude fast mode, MiMo UltraSpeed) is
42
+ * refused here, so the reason must not name one of them.
43
+ */
44
+ export declare function paidModelRefusal(modelName: string): string;
45
+ /**
46
+ * Thrown by {@link AgentSession.switchModel} when the target model spends real
47
+ * money and the caller didn't pass the user's explicit confirmation.
48
+ */
49
+ export declare class PaidModelConfirmationError extends Error {
50
+ readonly modelName: string;
51
+ readonly detail: string;
52
+ constructor(modelName: string, detail: string);
53
+ }
54
+ /** A chat attachment (image / video / other file) prepared for the model. The
55
+ * raw base64 `data` rides native blocks; `path` (when persisted to disk) lets
56
+ * the agent's tools open the file directly. */
57
+ /** What applying one MCP config change did in a session. */
58
+ export interface McpServerChange {
59
+ name: string;
60
+ removed: boolean;
61
+ connected: boolean;
62
+ toolCount: number;
63
+ error?: string;
64
+ requiresAuth?: boolean;
65
+ }
66
+ export interface SessionAttachment {
67
+ kind: "image" | "video" | "file";
68
+ mediaType: string;
69
+ data: string;
70
+ name: string;
71
+ path?: string;
72
+ }
73
+ /** Per-prompt run controls. */
74
+ export interface PromptRunOptions {
75
+ /** Offer the model no tools for this prompt. */
76
+ disableTools?: boolean;
77
+ /** Hold reasoning effort at the plan-mode ceiling for this prompt. */
78
+ capThinking?: boolean;
79
+ }
80
+ export interface AgentSessionOptions {
81
+ provider: Provider;
82
+ model: string;
83
+ cwd: string;
84
+ baseUrl?: string;
85
+ /**
86
+ * Who else works in the git checkout rooted at a path: other app windows, or
87
+ * a worker's parent agent. Lets the bash tool refuse a branch switch that
88
+ * would move them too (core/shared-checkout-guard.ts). Unset in a lone CLI.
89
+ */
90
+ getCheckoutSharers?: (root: string) => Promise<string | null>;
91
+ /** Replaces the whole system prompt — nothing else is rendered. */
92
+ systemPrompt?: string;
93
+ /**
94
+ * A sub-agent definition's body, COMPOSED with the standard scaffolding
95
+ * (Tools, project context, return contract, Environment) instead of replacing
96
+ * it — see `buildSubAgentSystemPrompt`.
97
+ *
98
+ * Prefer this over `systemPrompt` for delegated children: a bare replacement
99
+ * leaves the child with no Tools section and no Environment facts, which is
100
+ * precisely how a sub-agent ends up misusing tools it was never told it had.
101
+ * Ignored when `systemPrompt` is set.
102
+ */
103
+ agentPrompt?: string;
104
+ /** Whether `agentPrompt` composition includes project instruction files. Default `"project"`. */
105
+ agentContext?: "project" | "none";
106
+ /**
107
+ * Who `agentPrompt` speaks to. `"subagent"` (default) appends the delegated
108
+ * child's return contract; `"primary"` is a user-facing specialist (Motion)
109
+ * that keeps the Tools/Environment scaffolding but answers the user directly.
110
+ */
111
+ agentRole?: "subagent" | "primary";
112
+ /** Synchronous volatile prompt suffix, refreshed immediately before every run. */
113
+ getSystemPromptTail?: () => string;
114
+ sessionId?: string;
115
+ continueRecent?: boolean;
116
+ maxTokens?: number;
117
+ maxTurns?: number;
118
+ /**
119
+ * How many times the turn budget may be extended when the agent is still
120
+ * making progress. Defaults to the agent-loop default (2); sub-agents pass a
121
+ * stricter cap because a child's extensions multiply against the parent's
122
+ * own budget.
123
+ */
124
+ maxTurnExtensions?: number;
125
+ thinkingLevel?: ThinkingLevel;
126
+ /**
127
+ * Whether Claude Code sessions return a readable summary of the model's
128
+ * thinking ("summarized") or none ("omitted", Claude Code's default). For
129
+ * hosts that show reasoning; GG Coder's own UI doesn't.
130
+ */
131
+ thinkingDisplay?: "summarized" | "omitted";
132
+ signal?: AbortSignal;
133
+ /** Prefix used for provider prompt-cache routing keys. */
134
+ promptCacheKeyPrefix?: string;
135
+ /**
136
+ * Explicit prompt-cache routing key. When set, overrides the
137
+ * `${promptCacheKeyPrefix}:${sessionId}` default so spawned sub-agents can
138
+ * inherit a stable parent-scoped key — without this, each sub-agent process
139
+ * generates a fresh sessionId and starts with a cold cache.
140
+ */
141
+ promptCacheKey?: string;
142
+ /**
143
+ * If true, this session does NOT create a `.jsonl` session file or persist
144
+ * any messages. Used by subagent spawns (`--json` mode) so their transcripts
145
+ * don't leak into `ggcoder continue` for the parent project. Subagent runs
146
+ * are one-shot, NDJSON-streamed to the parent over stdout, and have no
147
+ * resumable identity.
148
+ */
149
+ transient?: boolean;
150
+ /** Pre-open the provider connection at session start / model switch / prewarm.
151
+ * Default: on, except transient sessions and under the test runner. */
152
+ preconnect?: boolean;
153
+ /**
154
+ * Told when an agent loop starts (true) and when the outermost one ends
155
+ * (false), however it ended. Nested loops (a template prompt inside a run)
156
+ * don't repeat it. GG Goals uses it to tell other processes the goal is
157
+ * being worked on (`core/goal-run-marker.ts`). A throwing listener is
158
+ * ignored: it must never fail or wedge a run.
159
+ */
160
+ onRunActive?: (active: boolean) => void;
161
+ /**
162
+ * If true, `initialize()` returns WITHOUT waiting for MCP servers to connect —
163
+ * the connection runs in the background and tools are appended when ready.
164
+ * Hosts whose readiness is gated on `initialize()` (the gg-app sidecar, which
165
+ * can't emit its listening handshake until init resolves) set this so a slow
166
+ * or hanging stdio MCP server (e.g. a first-run `npx -y …` download) can't
167
+ * delay the session from becoming usable. Default (false) keeps the CLI's
168
+ * connect-before-ready behavior so MCP tools are present on the first turn.
169
+ */
170
+ backgroundMcpConnect?: boolean;
171
+ /**
172
+ * Handler for a server-initiated MCP `elicitation/create` — a request for user
173
+ * input in the middle of a tool call. Hosts that can render a form (the
174
+ * gg-app sidecar) supply this; without it the session declares no elicitation
175
+ * capability and servers fall back to their no-input behavior.
176
+ */
177
+ onMcpElicit?: MCPElicitHandler;
178
+ /**
179
+ * If true, an over-context restored session is NOT compacted inline during
180
+ * `loadExistingSession()` — the existing pre-run auto-compaction in
181
+ * `runLoop()` handles it on the first prompt instead (with proper
182
+ * compaction_start/_end events). The inline load compaction makes a summary
183
+ * LLM call with a 30s timeout, and hosts whose readiness is gated on
184
+ * `initialize()` (the gg-app sidecar: waitForReady blocks the whole webview)
185
+ * would freeze the UI for that entire call. Default (false) keeps the
186
+ * compact-on-load behavior for CLI resume/`ggcoder continue`.
187
+ */
188
+ deferLoadCompaction?: boolean;
189
+ /**
190
+ * Plan-mode callbacks. When provided, the `enter_plan`/`exit_plan` tools are
191
+ * registered and the session manages plan-mode restrictions + system-prompt
192
+ * rebuilds. Hosts (e.g. the gg-app sidecar) use these to surface plan-mode
193
+ * UI. Omitted by callers that don't want plan mode (CLI wires its own).
194
+ */
195
+ onEnterPlan?: (reason?: string) => void | Promise<void>;
196
+ /**
197
+ * Built-in tools to keep in the core set instead of the deferred
198
+ * tool_search catalog: for a specialist whose job is a deferred tool (GG
199
+ * Goals orchestrates with spawn_agent and friends). Fixed for the session.
200
+ */
201
+ coreTools?: readonly string[];
202
+ /**
203
+ * Default provider/model for the workers this session spawns, when their
204
+ * agent names no model of its own. Read at spawn time.
205
+ */
206
+ getChildModel?: () => ChildModelPick | undefined;
207
+ /**
208
+ * Wrap each built-in tool once, at registration. Must keep the tool's name,
209
+ * description and parameters (only `execute` may change), so the tool block
210
+ * stays prompt-cache stable. Used by GG Goals to gate its own editing.
211
+ */
212
+ wrapTool?: (tool: AgentTool) => AgentTool;
213
+ /**
214
+ * Built-in tools this session never has, removed at registration (before
215
+ * tiering) and left out of the system prompt's Tools section. Unlike
216
+ * `allowedTools`, the rest of the tool set and its tiering are untouched.
217
+ * Fixed for the session, so the cached tool block never changes. Used by
218
+ * GG Goals, which never edits or runs anything itself.
219
+ */
220
+ withoutTools?: readonly string[];
221
+ /**
222
+ * A fixed team of sub-agents, replacing agent discovery (project, global
223
+ * and bundled): the only agents spawn_agent and subagent can start. Used by
224
+ * GG Goals, whose workers follow their own rules (goals-agent/goal-team.ts).
225
+ */
226
+ subAgents?: readonly AgentDefinition[];
227
+ /**
228
+ * Start every spawned child with this session's extra workspace roots too
229
+ * (less the folder it works in), so it can read and change all of them.
230
+ * GG Goals' workers work across all of a goal's attached folders.
231
+ */
232
+ shareRootsWithSubAgents?: boolean;
233
+ /** The sub-agent a spawned child is when the spawn names none (one of `subAgents`). */
234
+ defaultSubAgent?: string;
235
+ onExitPlan?: (planPath: string) => Promise<ToolExecuteResult>;
236
+ /**
237
+ * If provided, the session's tool set is filtered to ONLY these tool names
238
+ * after `createTools()` runs, and the system prompt's Tools section lists only
239
+ * them. Used by read-only advisory sessions (e.g. the Ken mentor agent) to
240
+ * register a safe subset — excluded mutating tools (write/edit/bash/…) are
241
+ * never registered, so a hallucinated call can't change the repo. Default
242
+ * (undefined) = all tools, preserving every existing caller's behavior.
243
+ */
244
+ allowedTools?: string[];
245
+ /**
246
+ * MCP server names whose tools are allowed in an allow-listed session. Only
247
+ * meaningful alongside `allowedTools`. With it set, the session connects ONLY
248
+ * these named MCP servers (not the full configured set) and every tool they
249
+ * expose (`mcp__<server>__*`) passes the allow-list, so a read-only agent can
250
+ * be handed one research server while still being barred from every mutating
251
+ * tool. Empty/undefined → an allow-listed session skips
252
+ * MCP entirely (its dynamic tool names could never match a fixed allow-list).
253
+ */
254
+ allowedMcpServers?: string[];
255
+ /**
256
+ * Force 1-h prompt-cache TTL + pre-warm regardless of the user's global
257
+ * `speedProfile` setting. Bursty read-only advisory sessions (the Ken
258
+ * mentor + autopilot reviewer) call the same static system prompt on a
259
+ * schedule that routinely exceeds the default 5-min cache window — a
260
+ * dropped cache there resends the whole cached prefix at full price right
261
+ * when it matters most, independent of whatever the user picked for the
262
+ * main build session. Default (undefined) = follow `speedProfile`.
263
+ */
264
+ forceLongCacheRetention?: boolean;
265
+ /** Hidden persistent subagent workers omit the async orchestration tool suite. */
266
+ subagentWorker?: boolean;
267
+ /** Session storage root override. Chat agents use a dedicated namespace. */
268
+ sessionRootDir?: string;
269
+ /** Register GG Coder built-in/prompt/custom slash commands. Defaults to true. */
270
+ coderSlashCommands?: boolean;
271
+ /** Enable loop-break and re-grounding hooks. Defaults to true. */
272
+ selfCorrectionHooks?: boolean;
273
+ /** Override the semantic-loop judge LLM call (tests). Receives the finished
274
+ * prompt, returns the model's raw reply. Default: one-shot `stream()` call
275
+ * on the session's ACTIVE model. */
276
+ semanticLoopJudge?: (prompt: string) => Promise<string>;
277
+ /** Load project skills/agents and create local .gg directories. Defaults to true. */
278
+ projectCustomization?: boolean;
279
+ /**
280
+ * Use exactly this skill set instead of discovering bundled/global/project
281
+ * skills. A mode with a private skill bundle (Motion) passes its own list so
282
+ * its skills stay invisible to every other mode, and vice versa.
283
+ */
284
+ skills?: readonly Skill[];
285
+ /** Skills the caller's own discovery refused, shown alongside `skills`. */
286
+ blockedSkills?: readonly BlockedSkill[];
287
+ /**
288
+ * Background check of the project's lockfiles for packages flagged as
289
+ * malware after install. Default on, except under vitest.
290
+ */
291
+ installedPackageWatch?: boolean;
292
+ /** Delay before the first installed-package check (default 5 s). */
293
+ installedPackageWatchDelayMs?: number;
294
+ /** Options for the installed-package check (tests inject fetch/feed). */
295
+ installedPackageCheck?: PackageCheckOptions;
296
+ /**
297
+ * Record refused packages in the project's instruction file (AGENTS.md /
298
+ * CLAUDE.md) so later sessions know them. Default on for project sessions,
299
+ * except under vitest.
300
+ */
301
+ blockedPackagesFile?: boolean;
302
+ /**
303
+ * Mode-specific defaults for prompt byte budgets. The user's `contextLimits`
304
+ * setting still overrides these. Motion raises its skill-catalog budget
305
+ * because its skill set is a fixed, bundled one (never untrusted files).
306
+ */
307
+ contextLimits?: Partial<ContextLimits>;
308
+ /** Register global + bundled subagents without loading project customization. */
309
+ globalSubagents?: boolean;
310
+ /** Load GG Coder extensions. Defaults to true. */
311
+ loadExtensions?: boolean;
312
+ /** Inject GG Coder's model-specific subagent orchestration prompt. Defaults to true. */
313
+ orchestrationPrompt?: boolean;
314
+ /** Host-provided tools appended to this session only (for example, chat delegation). */
315
+ additionalTools?: AgentTool[];
316
+ /** Mode-owned completion policy; absent in Coder/chat/worker sessions. */
317
+ completionReview?: CompletionReview;
318
+ /** Remind the agent to submit its plan (exit_plan) when a run is about to
319
+ * stop still in plan mode. Desktop only: an unsubmitted plan there leaves
320
+ * nothing to review. See plan-submission-gate.ts. */
321
+ planSubmissionGate?: boolean;
322
+ }
323
+ export { resolveSessionToolResultCharLimit, resolveSessionTurnToolResultCharLimit, } from "./agent-session/helpers.js";
324
+ export interface AgentSessionState {
325
+ provider: Provider;
326
+ model: string;
327
+ cwd: string;
328
+ sessionId: string;
329
+ sessionPath: string;
330
+ messageCount: number;
331
+ planMode: boolean;
332
+ /** accountId from the most recently resolved credentials, if any — lets
333
+ * callers compute the transport-specific context window (e.g. OpenAI Codex
334
+ * OAuth) without re-resolving credentials. */
335
+ accountId?: string;
336
+ }
337
+ /** A prompt that asks for the live web (see AgentSession.attachWebSearchIfAsked). */
338
+ /** True when the transcript holds a native (server-side) `web_search` call. */
339
+ export declare function historyUsesNativeWebSearch(messages: readonly Message[]): boolean;
340
+ /** How long dispose waits for a post-turn compaction before aborting it. */
341
+ export declare const DISPOSE_COMPACTION_WAIT_MS = 2500;
342
+ /**
343
+ * A chat row's target: first line, no control or bidi-override characters
344
+ * (they could make a command look like another), at most 120 chars.
345
+ */
346
+ export declare function securityRowTarget(raw: string): string;
347
+ /** Not the home folder or a filesystem root (those are never a project). */
348
+ export declare function isScannableProjectDir(dir: string, home?: string): boolean;
349
+ export declare class AgentSession {
350
+ readonly eventBus: EventBus;
351
+ readonly slashCommands: SlashCommandRegistry;
352
+ private settingsManager;
353
+ private authStorage;
354
+ private sessionManager;
355
+ private extensionLoader;
356
+ private messages;
357
+ private readonly markers;
358
+ private readonly cacheDiagnostics;
359
+ /** Internal-only (GG_INTERNAL): live per-session cost/reliability recorder.
360
+ * Absent entirely in public builds — see core/internal-diagnostics.ts. */
361
+ private diagnosticsRecorder?;
362
+ private tools;
363
+ /** Rebuilds the read tool for a new model (video byte cap is baked in at
364
+ * creation). Called from switchModel so video-capable models get the
365
+ * read-tool's native-video path after a mid-session model change. */
366
+ private rebuildReadTool;
367
+ /** Forgets every file read; called whenever the conversation is replaced or
368
+ * rewound, so the model must re-read a file before changing it. */
369
+ private clearReadTracker;
370
+ private recordBashReads;
371
+ private skills;
372
+ /** Skills discovery refused to load (safety scan); shown to the user, named by the skill tool. */
373
+ private blockedSkills;
374
+ /** Lockfile entries now known to be malware (background check), for the app/CLI to show. */
375
+ private installedThreats;
376
+ private installedWatchStop;
377
+ private installedStamp;
378
+ private installedScanRunning;
379
+ private installedWatchStopped;
380
+ /** rule\0target of the security rows already shown this run. */
381
+ private securityRowsThisRun;
382
+ /** Project session (code mode): the only kind that writes the "don't install" list. */
383
+ private projectSession;
384
+ private cacheKeyLogged;
385
+ private readonly loopMonitor;
386
+ private regroundingInjected;
387
+ /**
388
+ * The environment as the cached system prompt currently describes it.
389
+ * Re-recorded on every prompt build, so a rebuild (e.g. `/add-dir`) needs no
390
+ * delta; anything that changes WITHOUT one is caught by the hook below.
391
+ */
392
+ private renderedEnvironment;
393
+ /** Project files as of the first prompt build (undefined until then). */
394
+ private projectFiles;
395
+ /** `git ls-files` started at the top of initialize(), overlapping the rest of setup. */
396
+ private projectFilesPending?;
397
+ /** Wall-clock start of the current run; scopes the background-process gate. */
398
+ private runStartedAt;
399
+ /** Gate injections spent this run, capped by MAX_PROCESS_GATE_INJECTIONS. */
400
+ private processGateInjected;
401
+ /** Plan-submission reminders spent this run (plan-submission-gate.ts). */
402
+ private planSubmissionNudges;
403
+ /** Verification evidence: code edited this run, and what has proved it since.
404
+ * Passive tracking only — it feeds run status and autopilot, never a turn. */
405
+ private readonly verificationGate;
406
+ /** Host-observed evidence (edited files, in-flight and background checks) feeding the gate. */
407
+ private readonly verificationTracker;
408
+ /** Mirror of the last `hook_armed` value, so the event fires only on an edge. */
409
+ private preFinalArmed;
410
+ private compactionOccurred;
411
+ /**
412
+ * Re-grounding carry-over for post-turn compaction. `resetHookState` clears
413
+ * `compactionOccurred` at run start — before the injection point — so a
414
+ * background compaction that finished after the final response parks its
415
+ * "re-ground next turn" signal here for pickup at the next run start.
416
+ */
417
+ private compactionArmedForNextRun;
418
+ /** In-flight post-turn (background) compaction, if any. */
419
+ private postTurnCompaction?;
420
+ /** Aborts the in-flight post-turn compaction (dispose caps its wait). */
421
+ private postTurnCompactionAbort?;
422
+ private lastCompactionCompacted;
423
+ private compactionRetryAfter;
424
+ /**
425
+ * SoL-Pi plan-step compaction bookkeeping (see compaction/plan-step-policy.ts).
426
+ * Step progress comes from `[DONE:n]` markers in assistant text — the same
427
+ * contract the approved-plan UI tracks.
428
+ */
429
+ private planStepState;
430
+ /** A restored oversized checkpoint must be canonicalized before its first prompt is persisted. */
431
+ private deferredCompactionPending;
432
+ /** Latest provider count, anchored to the assistant response it measured. */
433
+ private providerContext;
434
+ /** Where the last prune made history stable; becomes the cache anchor on the next step. */
435
+ private pendingCacheAnchor;
436
+ /** The message currently carrying `cacheAnchor` (see applyPendingCacheAnchor). */
437
+ private cacheAnchored;
438
+ /** See {@link toolDefinitionChars}. */
439
+ private toolCharsCache;
440
+ private originalRequest;
441
+ /** The user's own ask_user answers this run; they scope the pinned request. */
442
+ private runUserDecisions;
443
+ private userQueue;
444
+ private askAnswerSteering;
445
+ private deliveringQueue;
446
+ private queueSeq;
447
+ /** Monotonic count of human-originated prompts; idle-wake budgets reset on it. */
448
+ private humanPromptSeq;
449
+ /** Instant interrupt: the running loop's preempt listeners, fired on queueMessage. */
450
+ private steeringListeners;
451
+ private processManager?;
452
+ private lspManager?;
453
+ private debugManager?;
454
+ private browserManager?;
455
+ private subAgentManager?;
456
+ /**
457
+ * Out-of-band push notifications (finished children, background-process
458
+ * progress). Producers enqueue; `getHookSteeringMessages` drains into the
459
+ * live turn so the agent never has to spend a turn asking.
460
+ */
461
+ private readonly notifications;
462
+ private managerAbortSignal?;
463
+ private readonly managerAbortHandler;
464
+ /** MCP client, deferred tool_search catalog and cached-stub reconcile state. */
465
+ private readonly mcp;
466
+ /** Resolved prompt-injection byte budgets (contextLimits setting). */
467
+ private contextLimits;
468
+ /**
469
+ * Built-in tools held in the catalog instead of the live toolset. Their names
470
+ * still render as one-line hints in the prompt's Tools section, so the model
471
+ * can discover and promote them; a promoted name drops out of this list.
472
+ */
473
+ private deferredBuiltinToolNames;
474
+ /** Deferred built-ins in tier order, fixed at session start. Sent as the
475
+ * provider's on-demand catalog (see gg-ai `deferredTools`) so promoting one
476
+ * loads it through the transcript and the cached tools block stays put. */
477
+ private deferredToolCatalog;
478
+ private provider;
479
+ private model;
480
+ private cwd;
481
+ /** accountId from the most recently resolved credentials — cached so sync
482
+ * callers (e.g. the app-sidecar's context-window footer stat) can reflect
483
+ * transport-specific windows (e.g. OpenAI Codex OAuth's smaller window)
484
+ * without re-resolving credentials on every poll. */
485
+ private lastAccountId?;
486
+ /** The branch and checkout this conversation is on (core/checkout-record.ts). */
487
+ private checkoutRecord;
488
+ private baseUrl?;
489
+ private maxTokens;
490
+ private thinkingLevel?;
491
+ private readonly thinkingDisplay?;
492
+ private customSystemPrompt?;
493
+ /** Sub-agent definition body composed into the standard prompt scaffolding. */
494
+ private agentPrompt?;
495
+ /** Stable prompt prefix retained separately from the volatile uncached tail. */
496
+ private baseSystemPrompt;
497
+ /** Plan state rendered into the cached system prompt. */
498
+ private promptPlanState;
499
+ /** Plan state the model has been told (prompt or appended notice). */
500
+ private seenPlanState;
501
+ /** Plan notice waiting for the next request, with the state it describes. */
502
+ private pendingPlanNotice;
503
+ /** Latest plan notice appended — re-announced if compaction drops it. */
504
+ private lastPlanNotice;
505
+ /**
506
+ * Project languages whose verify commands are in the standard prompt.
507
+ * Only ever grows within a session (same policy as the terminal UI): a
508
+ * section disappearing mid-task would rewrite the cached prefix
509
+ * for no benefit.
510
+ */
511
+ private activeLanguages;
512
+ /** Languages the model has already been given guidance for, via the system
513
+ * prompt or an appended language update. */
514
+ private announcedLanguages;
515
+ /** Shared with the tool layer so plan-mode restrictions read live state. */
516
+ private planModeRef;
517
+ /** Path of the approved plan currently being implemented, or undefined. When
518
+ * set, the system prompt carries the `[DONE:n]` progress contract so the
519
+ * model emits step-completion markers the UI's plan-progress widget reads. */
520
+ private approvedPlanPath?;
521
+ /** Extra workspace roots added with `/add-dir` (resolved, de-duplicated). */
522
+ private additionalRoots;
523
+ private sessionId;
524
+ private checkpointGeneration;
525
+ /** Stable identity shared by compaction and approved-plan checkpoint files. */
526
+ private conversationId;
527
+ /** Original user-authored prompt, retained when internal messages replace history. */
528
+ private sessionPreview;
529
+ /** Runtime conversation identity for provider transport headers. Transient
530
+ * children need one even though they intentionally have no persisted session. */
531
+ private readonly transportSessionId;
532
+ private sessionPath;
533
+ private lastPersistedIndex;
534
+ /**
535
+ * The array `agentLoop` is currently mutating, while a run is in flight.
536
+ *
537
+ * Normally identical to `this.messages`, but a mid-loop compaction rebinds
538
+ * `this.messages` to the compacted result while the loop keeps appending to
539
+ * its own array. Step-boundary flushes must follow the loop's array or they
540
+ * would silently persist nothing for the rest of the run.
541
+ */
542
+ private activeLoopMessages;
543
+ /**
544
+ * Number of non-system messages guaranteed to be in the session file — the
545
+ * anchor base for transcript markers (Ken turns, autopilot verdicts, app
546
+ * markers). `this.messages` can run ahead of the file: the agent loop
547
+ * appends assistant/tool/steering messages in place but they are only
548
+ * persisted when the run SUCCEEDS, so after a failed run the in-memory list
549
+ * carries an unpersisted tail. Markers anchored against that tail point past
550
+ * their real position on resume — the row (notably an error) renders lower
551
+ * in the transcript than it happened, bunching at the bottom, or gets
552
+ * dropped as out-of-range. Anchoring to the persisted prefix keeps resume
553
+ * placement 1:1 with where the row appeared live.
554
+ */
555
+ /** Commands the user ran themselves, held until their next message. */
556
+ private pendingUserShell;
557
+ /** MCP servers the user added or removed mid-session, not yet told to the model. */
558
+ private pendingMcpNotices;
559
+ private persistedTranscriptCount;
560
+ /** Current leaf entry ID in the session DAG — used to chain parentIds for branching. */
561
+ private currentLeafId;
562
+ private opts;
563
+ constructor(options: AgentSessionOptions);
564
+ /**
565
+ * Derive the output-token cap for a model. Follows the active model's
566
+ * `maxOutputTokens` so a session booted on a large-output model (e.g. Kimi's
567
+ * 256K) doesn't carry that cap to a smaller one (e.g. Opus's 128K) after a
568
+ * model switch — that mismatch surfaces from the provider as
569
+ * `max_tokens: 262144 > 128000, which is the maximum allowed …`. An explicit
570
+ * `maxTokens` override is honored but clamped to the model's ceiling.
571
+ */
572
+ private resolveMaxTokens;
573
+ /** {@link outputCapForRequest} for this session's live model and settings. */
574
+ private requestMaxTokens;
575
+ initialize(): Promise<void>;
576
+ /**
577
+ * Whether a tool name is permitted for this session. With no `allowedTools`
578
+ * everything passes (default behavior). Otherwise a tool is allowed when its
579
+ * name is in `allowedTools`, OR it's an MCP tool (`mcp__<server>__<tool>`)
580
+ * whose `<server>` is in `allowedMcpServers`. The MCP-prefix rule lets a
581
+ * whitelisted research server expose all its tools
582
+ * without hard-coding each one, while every other tool stays blocked.
583
+ */
584
+ private isToolAllowed;
585
+ /**
586
+ * Connect all configured MCP servers and append their tools to `this.tools`.
587
+ * Resolves the GLM api key first (Z.AI's bundled servers need it). Never
588
+ * throws — a failed connect is logged and skipped — so it is safe to either
589
+ * `await` (CLI: tools ready before the first turn) or fire-and-forget
590
+ * (sidecar: `backgroundMcpConnect`, so a slow stdio server can't stall
591
+ * startup). Tools are pushed onto the live array the agent loop reads each
592
+ * turn, so background-connected servers become available on the next prompt.
593
+ */
594
+ private connectMcpServers;
595
+ /**
596
+ * The user added, changed or removed one MCP server mid-session: connect,
597
+ * reconnect or drop just that server, without a restart. `config` is its
598
+ * current effective config, or undefined when it is gone (or not allowed).
599
+ *
600
+ * Append-only for the prompt cache: new tools go into the tool_search
601
+ * catalog (or are appended when deferral is off), and the model learns about
602
+ * the change from a hidden note with the next message, never from a
603
+ * re-rendered system prompt. Returns null when nothing changed here.
604
+ */
605
+ applyMcpServerChange(name: string, config: MCPServerConfig | undefined): Promise<McpServerChange | null>;
606
+ private takeMcpNotice;
607
+ /** Persist `cwd` as a trusted project for project-scope MCP. Called by the
608
+ * sidecar's `/mcp/add` handler when a user adds a project-scope server via
609
+ * the MCP modal — the explicit add is itself the trust signal. The next
610
+ * session load connects its `.gg/mcp.json` servers. */
611
+ trustProject(cwd: string): Promise<void>;
612
+ /**
613
+ * Route freshly connected MCP tools: deferred into the tool_search catalog
614
+ * (default — keeps ~8k tokens of schema out of every cache-miss turn) or
615
+ * pushed eagerly when the user opted out.
616
+ * Allow-listed sessions (Ken) always get the eager path — their fixed tool
617
+ * expectations predate the catalog, and tool_search isn't allow-listed.
618
+ */
619
+ private addMcpTools;
620
+ /**
621
+ * Deferred follow-up tools whose need is certain once a trigger succeeds.
622
+ * `wait_agent` follows nearly every `spawn_agent`, and loading it through
623
+ * `tool_search` cost a whole turn (bench 41: ~6 s per fan-out). Likewise a
624
+ * background `bash` is always followed by `task_output` (and sometimes
625
+ * `task_send`/`task_stop`). Promote them as soon as the trigger succeeds: the
626
+ * tool list grows exactly as it would after that `tool_search`, one turn
627
+ * earlier, and sessions that never trigger keep the smaller prefix.
628
+ * Call before tier partitioning so a deferred trigger is wrapped too.
629
+ */
630
+ private promoteFollowUpTools;
631
+ /**
632
+ * Whether provider-native web search rides along with this request.
633
+ *
634
+ * Anthropic's `web_search_20250305` server tool costs ~2.5k prefix tokens on
635
+ * every request (count_tokens: 6,628 vs 4,098 for the GG prefix without it),
636
+ * yet web search is reached in ~6% of sessions — the reason the client tool
637
+ * is deferred everywhere else. So on a tiered Anthropic session it is only
638
+ * attached once the model has promoted `web_search` (tool_search or a direct
639
+ * call). The server tool is appended last, so the tool block stays
640
+ * append-only. Untiered sessions and other providers keep it always on.
641
+ */
642
+ private nativeWebSearchOn;
643
+ /**
644
+ * A human prompt that plainly asks for the web gets native web search from
645
+ * its first request. Without this, an on-demand web_search costs an extra
646
+ * round trip (tool_search or a client search) before the native tool is
647
+ * attached — slower than the always-on tool it replaced for exactly the
648
+ * sessions that need it. Conservative on purpose: a miss only costs that
649
+ * one discovery turn, a false hit only the ~2.5k-token schema.
650
+ */
651
+ private attachWebSearchIfAsked;
652
+ private runSideWebSearch;
653
+ private maybeCompactPreRun;
654
+ private compactionTransport;
655
+ /** One run on the Claude subscription route: Claude Code drives the loop with our prompt and tools. */
656
+ private runClaudeCodeLoop;
657
+ /**
658
+ * The Claude Code process for this run: the chat's live one when it holds
659
+ * exactly our history with the same settings, else a new one (the old one is
660
+ * closed first, so a chat never keeps two).
661
+ */
662
+ private claudeCodeLiveFor;
663
+ private closeClaudeCodeLive;
664
+ private recordClaudeCodeSession;
665
+ /** Claude Code settings when this session runs on a Claude subscription, else null. */
666
+ private claudeCodeProcess;
667
+ /** Append a deferred built-in to the live tool list (append-only). */
668
+ private promoteDeferredBuiltin;
669
+ private reloadUsedTools;
670
+ private wrapToPromote;
671
+ /**
672
+ * Publish cached tool definitions into the deferred catalog so `tool_search`
673
+ * answers correctly on turn 1 (see {@link McpToolRegistry.seedFromCache}).
674
+ */
675
+ private seedMcpCatalogFromCache;
676
+ /**
677
+ * Resolve a `/name [args]` input to the prompt template it expands into, or
678
+ * null when it isn't a prompt-template command for THIS session (an ordinary
679
+ * message, a registry/action command, or any slash input on a non-coder
680
+ * agent). Shared by {@link prompt} and {@link willExpandPromptTemplate} so
681
+ * callers can't drift from the expansion that actually happens.
682
+ */
683
+ private resolveSlashInput;
684
+ /**
685
+ * Whether {@link prompt} would expand this input into a template body and
686
+ * persist it as a user message. Hosts use it to record the typed `/name` for
687
+ * transcript restore — gating on anything looser risks tagging an unrelated
688
+ * message when the command turns out NOT to expand.
689
+ */
690
+ willExpandPromptTemplate(content: string): Promise<boolean>;
691
+ /**
692
+ * Process user input. Handles slash commands or runs agent loop.
693
+ * `capThinking` holds reasoning effort at the plan-mode ceiling for this
694
+ * prompt — for turns that must answer quickly from what is already known.
695
+ */
696
+ prompt(content: string, provenance?: MessageProvenance, options?: PromptRunOptions): Promise<void>;
697
+ /**
698
+ * Prompt with multimodal attachments (images / videos) alongside optional
699
+ * text. Images and videos become native content blocks the model can see;
700
+ * non-media files are surfaced as a text note with their saved path so the
701
+ * agent can open them with its tools. Slash-command parsing is skipped —
702
+ * attachments are always a direct conversational turn.
703
+ */
704
+ promptWithAttachments(text: string, attachments: SessionAttachment[]): Promise<void>;
705
+ /** A typed reply's attachments as blocks for the question it answers (ask_user). */
706
+ askReplyAttachmentParts(attachments: SessionAttachment[]): Array<TextContent | ImageContent | VideoContent>;
707
+ /**
708
+ * Build the native content blocks (text + image/video notes + file notes) for
709
+ * a user message with attachments. Shared by {@link promptWithAttachments} and
710
+ * the mid-run steering drain so queued media is delivered identically.
711
+ */
712
+ private buildAttachmentParts;
713
+ /**
714
+ * Reset per-run self-correction hook state. Mirrors the TUI's run_start
715
+ * resets so each run evaluates the hooks from a clean slate. `originalRequest`
716
+ * is the verbatim user ask, pinned for post-compaction re-grounding.
717
+ */
718
+ private resetHookState;
719
+ /** The context was just summarized: arm a fresh re-ground note, even if one already ran this run. */
720
+ private markCompacted;
721
+ /**
722
+ * Fold one agent event into the hook stat accumulators. Pure bookkeeping —
723
+ * the same signals the TUI's useAgentLoop collects, so loop-break decisions
724
+ * match across the CLI and the app.
725
+ */
726
+ private trackHookEvent;
727
+ /** Drop delivered queued messages and announce the new queue depth. */
728
+ private settleDeliveredMessages;
729
+ /**
730
+ * Count full-file `cat` output from the step that just finished as reads, so
731
+ * an edit after `cat` does not cost a second read. Uses the step's results as
732
+ * stored in the transcript (after per-turn trimming): only bytes the model
733
+ * actually received count.
734
+ */
735
+ private creditBashReads;
736
+ /**
737
+ * Append every message added since the last flush to the session file.
738
+ *
739
+ * Safe to call mid-run: `agentLoop` mutates its message array in place, so
740
+ * the slice from `lastPersistedIndex` is always exactly the new tail.
741
+ * Transient sessions (subagent spawns) have no session file and
742
+ * `persistMessage` no-ops for them.
743
+ *
744
+ * Persistence failures must never take down a live run — the post-loop flush
745
+ * retries the same range.
746
+ */
747
+ private flushPendingMessages;
748
+ /**
749
+ * Mid-loop steering hook: delivers pushed notifications and queued user
750
+ * steering, fires the loop-breaker when the agent looks stuck, then
751
+ * post-compaction re-grounding. At most one loop-break/re-grounding per run.
752
+ * Mirrors the TUI's getSteeringMessages ordering.
753
+ */
754
+ private getHookSteeringMessages;
755
+ /** Fire the semantic loop judge when deterministic evidence is suspicious but
756
+ * the deterministic breaker stayed quiet — the syntactic blind spot where
757
+ * every retry differs slightly and the run still makes no progress.
758
+ * Fire-and-forget: the call runs while the next turn streams, and a finished
759
+ * verdict is consumed by the NEXT steering poll — never blocking a turn. */
760
+ private maybeStartSemanticLoopCheck;
761
+ /** Fresh image-only critique context, using the active transport and auth routing. */
762
+ private callCompletionReviewer;
763
+ /** One-shot judge call on the session's ACTIVE model — deliberately not a
764
+ * cheaper routing: judging a model's own failure patterns with a weaker
765
+ * model swaps false negatives for false positives. */
766
+ private callSemanticLoopJudge;
767
+ /**
768
+ * Turn-budget extension gate. The loop consults this instead of stopping
769
+ * mid-task when it exhausts `maxTurns`. Grant ONLY on evidence of progress —
770
+ * handing more turns to a spinning agent just buys it more tokens to spin
771
+ * with — so reuse the same stuck signals that drive the loop-breaker.
772
+ */
773
+ private shouldExtendTurnBudget;
774
+ /** Would a stop right now inject a pre-final follow-up? Only queued LSP
775
+ * diagnostics (real errors injected below) or a mode-owned completion
776
+ * review can, so clients hold the candidate answer only then. */
777
+ private wouldInjectBeforeFinal;
778
+ /** Broadcast pre-final hook arming on change. Both edges matter: armed=false
779
+ * after the hook fires is what lets a client stream the final answer live
780
+ * again. Callable before `initialize()`, when no manager exists yet. */
781
+ private refreshHookArming;
782
+ /**
783
+ * Pre-stop follow-ups: LSP errors, unread child agents and background
784
+ * processes, and a mode-owned completion review. Verification evidence is
785
+ * tracked passively for run status; it never forces another turn.
786
+ */
787
+ private getHookFollowUpMessages;
788
+ /**
789
+ * The model often runs its tests inside a longer command (`npm test 2>&1 |
790
+ * tail; node -e '…'`) whose exit status belongs to a later part, so the
791
+ * tests can pass without counting. When the turn would end unverified that
792
+ * way, run that check once more on its own, through the same bash tool, and
793
+ * record its real exit status. No model turn and nothing in the transcript:
794
+ * only the run's verification status changes.
795
+ */
796
+ private rerunRefusedCheck;
797
+ /** Wraps the real run: cancels an in-flight cache prewarm and tracks run
798
+ * activity / last real request time for {@link prewarm}. */
799
+ private runLoop;
800
+ /** `opts.onRunActive`, never allowed to throw into the run. */
801
+ private notifyRunActive;
802
+ /** Auto-compact if needed, run agent loop with auth retry, and persist messages. */
803
+ private runLoopInner;
804
+ /**
805
+ * Switch the session's model. A model that spends real money (Claude fast
806
+ * mode bills usage credits) is refused unless `confirmPaid` carries the
807
+ * user's explicit yes, so no caller can switch onto one by accident: every
808
+ * path (app, CLI, editors, chat bridges, RPC) fails closed by default.
809
+ */
810
+ switchModel(provider: string, model: string, options?: {
811
+ confirmPaid?: boolean;
812
+ }): Promise<void>;
813
+ /**
814
+ * Record the switch as its own trailing message at the point it happened,
815
+ * rather than by rewriting the system prompt. Two reasons: the system prompt
816
+ * is the cached prefix and rewriting it costs a full cache write, and a
817
+ * resumed transcript can only attribute output to the right model if the
818
+ * switch sits in message order.
819
+ *
820
+ * Skipped before the conversation starts (nothing to disambiguate) and while
821
+ * an assistant turn has unresolved tool calls, where inserting a user message
822
+ * would break tool_use/tool_result pairing.
823
+ */
824
+ private appendModelSwitchNote;
825
+ private adoptCompactionCheckpoint;
826
+ /** Canonicalize a deferred restore before a new prompt can fork stale history. */
827
+ private adoptDeferredCheckpointBeforePrompt;
828
+ private persistCompactionCheckpoint;
829
+ /**
830
+ * Wait out any in-flight post-turn background compaction before a new
831
+ * entry point mutates `this.messages` (prompt, attachments, model switch).
832
+ * The background compact() snapshots and then REPLACES the array, so a
833
+ * message pushed while it runs would be silently dropped from the live
834
+ * history — the pre-run await in runLoop() sits after the push and cannot
835
+ * protect it.
836
+ */
837
+ private settlePostTurnCompaction;
838
+ /**
839
+ * Advance plan-step bookkeeping over the messages added since the last
840
+ * observation and, when a plan step was newly completed (`[DONE:n]`), run
841
+ * the SoL-Pi cost rule. Called between model steps (in-flight) and once
842
+ * after the run; `scanIndex` and `doneSteps` make each message and each
843
+ * step count once across both paths. Returns undefined when no step
844
+ * completed since the last observation.
845
+ */
846
+ private observePlanStepProgress;
847
+ /**
848
+ * Plan-step bookkeeping after ANY successful compaction (as in the bench:
849
+ * every compaction leaves a cache-write cost to be repaid by later savings).
850
+ */
851
+ private recordPlanStepCompaction;
852
+ /**
853
+ * Post-turn compaction: once the final response has been delivered, compact
854
+ * in the background while the user reads the answer, instead of making the
855
+ * next prompt pay the summarizer latency up front (the pre-run path stays as
856
+ * the backstop, so a skipped or failed attempt costs nothing). Mirrors the
857
+ * Codex `model_post_turn_compact_threshold_percent` guards: skip when user
858
+ * input is already queued (it would race the next turn), when the run was
859
+ * aborted, or during the failure cooldown — and never let a compaction
860
+ * error surface in the completed turn. Besides the size trigger, a newly
861
+ * completed approved-plan step may compact when the cache-cost rule in
862
+ * compaction/plan-step-policy.ts says the shrink pays for itself.
863
+ */
864
+ private maybeCompactPostTurn;
865
+ private withLiveAccessToken;
866
+ compact(existingCredentials?: {
867
+ accessToken: string;
868
+ accountId?: string;
869
+ baseUrl?: string;
870
+ }, mode?: "manual" | "automatic" | "forced",
871
+ /** User-stated focus (`/compact <focus>`): what must survive verbatim. */
872
+ focus?: string,
873
+ /** Extra abort source (post-turn compaction, cancelled by dispose). */
874
+ abortSignal?: AbortSignal): Promise<void>;
875
+ newSession(preserveConversation?: boolean): Promise<void>;
876
+ loadSession(sessionPath: string): Promise<void>;
877
+ /**
878
+ * Create a branch at a specific point in the conversation.
879
+ * Rewinds the message history to the given entry and sets the leaf
880
+ * so new messages fork from that point.
881
+ *
882
+ * @param stepsBack Number of messages to rewind (default: 2 — backs up past last assistant + tool)
883
+ */
884
+ branch(stepsBack?: number): Promise<{
885
+ branchedFrom: number;
886
+ messagesKept: number;
887
+ }>;
888
+ /**
889
+ * List all branches in the current session.
890
+ */
891
+ listBranches(): Promise<BranchInfo[]>;
892
+ /** The session's first user-authored prompt, or "" before there is one. */
893
+ getSessionPreview(): string;
894
+ /**
895
+ * Give the session a title of the user's choosing. Saved as a label entry
896
+ * (the newest wins over the first prompt) and kept for any checkpoint this
897
+ * session writes later.
898
+ */
899
+ renameSession(title: string): Promise<void>;
900
+ /** Skills the safety scan kept out of this session, for the app/CLI to show. */
901
+ getBlockedSkills(): readonly BlockedSkill[];
902
+ /** Installed packages (project lockfiles) now known to be malware. */
903
+ getInstalledThreats(): readonly InstalledThreat[];
904
+ /**
905
+ * Background check of the project's lockfiles for packages flagged as
906
+ * malware after they were installed: shortly after start, after each daily
907
+ * threat-feed update, and after a run that changed a lockfile. Never awaited
908
+ * by anything; a new hit is shown to the user once (security_notice) and told
909
+ * to the agent at its next turn. Off under vitest unless a test opts in.
910
+ */
911
+ private startInstalledPackageWatch;
912
+ private rescanIfLockfilesChanged;
913
+ /**
914
+ * A guard refused a tool call: a lasting chat row (live event + persisted
915
+ * marker, so a reopened session shows it too) and, for packages, an entry in
916
+ * the project's "don't install" list. All fire-and-forget; never blocks.
917
+ */
918
+ private recordSafetyBlock;
919
+ /**
920
+ * One row per distinct block per run: an agent retrying the same blocked
921
+ * install 30 times leaves one row, and a run hitting 100 blocks leaves at
922
+ * most MAX_SECURITY_ROWS_PER_RUN (the session file stays small).
923
+ */
924
+ private emitSecurityRow;
925
+ private recordBlockedList;
926
+ /** Exposed for tests; safe to call any time (one scan at a time, never throws). */
927
+ scanInstalledPackages(): Promise<void>;
928
+ getState(): AgentSessionState;
929
+ /**
930
+ * Tokens currently in context and the window they are measured against.
931
+ *
932
+ * Uses the same accounting as the compaction decision: authoritative provider
933
+ * usage when we have it (it includes the system prompt and tool schemas),
934
+ * plus a local estimate of anything appended after that sample. A client
935
+ * reading this right after a compaction sees the drop, because compaction
936
+ * clears the retained provider sample along with the messages it measured.
937
+ *
938
+ * `costUsd` is present only when EVERY recorded turn has an authoritative
939
+ * price; a partial sum would read as a full session cost and understate it.
940
+ */
941
+ getContextUsage(): {
942
+ used: number;
943
+ size: number;
944
+ costUsd?: number;
945
+ };
946
+ /**
947
+ * Whether the provider's prompt cache has likely lapsed since the last
948
+ * successful request, and how many tokens the next message would re-read at
949
+ * full price. Null when the route has no known TTL or the chat is empty.
950
+ */
951
+ getCacheExpiryStatus(now?: number): CacheExpiryStatus | null;
952
+ getPlanMode(): boolean;
953
+ /** Queue a user message (optionally with attachments) to be injected mid-run
954
+ * as steering. Returns the new queue length. No-op semantics are the caller's
955
+ * concern. */
956
+ queueMessage(text: string, attachments?: SessionAttachment[], opts?: {
957
+ answeredAsk?: boolean;
958
+ }): number;
959
+ /**
960
+ * Hold the output of a command the user ran themselves (`!cmd` in the app)
961
+ * so it reaches the agent with their next message: a prompt, or a message
962
+ * queued as steering. Never on its own, and never mid-run without one.
963
+ */
964
+ addUserShellContext(runId: string, text: string): void;
965
+ /** Run ids of user commands still waiting for the next message. */
966
+ getPendingUserShellRunIds(): string[];
967
+ private takeUserShellContext;
968
+ /** Persist pending user command output just ahead of the human message. */
969
+ private deliverUserShellContext;
970
+ /** Pending queued messages (id + text), oldest first, for client display.
971
+ * `delivering` ones are already with the agent and can no longer be cancelled. */
972
+ listQueuedMessages(): Array<{
973
+ id: string;
974
+ text: string;
975
+ delivering?: true;
976
+ }>;
977
+ /** Cancel one pending message by id. Returns true if it was still queued.
978
+ * A false return is the normal race rather than an error: the message drained
979
+ * into the run between the client rendering the cancel affordance and the
980
+ * click arriving. */
981
+ cancelQueuedMessage(id: string): boolean;
982
+ /** Number of messages currently queued. */
983
+ getQueuedCount(): number;
984
+ /** Remove and return the oldest queued message (text + attachments), or null.
985
+ * Used by the sidecar to run a message that queued while autopilot was
986
+ * reviewing (no run in flight to steer it into) — unlike {@link drainQueue},
987
+ * attachments survive so queued media isn't silently dropped. */
988
+ takeNextQueuedMessage(): {
989
+ text: string;
990
+ attachments: SessionAttachment[];
991
+ } | null;
992
+ /** Clear the queue, returning the combined text (to restore to the composer).
993
+ * Queued attachments are dropped on cancel — the composer only restores text. */
994
+ drainQueue(): string;
995
+ /**
996
+ * Tell the agent a new fact at its next turn, as a short hidden message
997
+ * appended after the cached prompt (the same channel as a finished worker),
998
+ * so a mid-session change reaches it without re-rendering the prompt. A
999
+ * later note with the same id replaces one not yet delivered.
1000
+ */
1001
+ notify(id: string, text: string): void;
1002
+ /**
1003
+ * Observe urgent background alerts — a background task failed or exited
1004
+ * non-zero, or a child agent finished — as they are queued. Hosts use this to
1005
+ * wake an idle session (see {@link continueFromNotifications}); a live run
1006
+ * already receives them at its next steering boundary. Returns unsubscribe.
1007
+ */
1008
+ onBackgroundAlert(listener: () => void): () => void;
1009
+ /**
1010
+ * Characters of the tool definitions sent with every request (name,
1011
+ * description, JSON schema), for estimator calibration. Cached by tool count:
1012
+ * the tool array is append-only.
1013
+ */
1014
+ private toolDefinitionChars;
1015
+ /** True while an urgent background alert is waiting to be delivered. */
1016
+ hasPendingBackgroundAlert(): boolean;
1017
+ /** Monotonic count of human-originated prompts this session has run. */
1018
+ getHumanPromptSeq(): number;
1019
+ /**
1020
+ * Start a run from pending background notifications, for a session that had
1021
+ * already finished its turn. The notifications become one hidden runtime
1022
+ * message (never shown as something the user typed), and the agent decides
1023
+ * whether they need action. Returns false, starting nothing, when no urgent
1024
+ * alert is pending — a live run may have delivered it in the meantime.
1025
+ */
1026
+ continueFromNotifications(): Promise<boolean>;
1027
+ /** This session's sub-agents (workers), newest-state, including ones restored after a restart. */
1028
+ listSubAgents(): SubAgentSnapshot[];
1029
+ /** Snapshot of background processes (bash run_in_background), newest-state. */
1030
+ listBackgroundProcesses(): BackgroundProcess[];
1031
+ /**
1032
+ * Start a background process on the host's behalf (a new worktree's setup),
1033
+ * listed with the agent's own background tasks. Null without a process manager.
1034
+ */
1035
+ startBackgroundProcess(command: string, cwd?: string): Promise<{
1036
+ id: string;
1037
+ pid: number;
1038
+ } | null>;
1039
+ /** Stop a background process by id. Returns a human-readable status string. */
1040
+ killBackgroundProcess(id: string): Promise<string>;
1041
+ /**
1042
+ * Force-stop every background process tree, synchronously. Background
1043
+ * commands run in their own process group, so the daemon's group kill on
1044
+ * quit never reaches them: this is the only thing that does. Callers on a
1045
+ * shutdown deadline run it before awaiting anything that can hang.
1046
+ */
1047
+ stopBackgroundProcesses(): void;
1048
+ /** Replace a host-owned system prompt in place without resetting conversation history. */
1049
+ setCustomSystemPrompt(systemPrompt: string, promptCacheKeyPrefix?: string): void;
1050
+ /**
1051
+ * Toggle plan mode: flips the shared ref (so tools enforce read-only
1052
+ * restrictions) and rebuilds the system prompt in place so the model is told
1053
+ * about the mode change on its next turn. No-op when a custom system prompt
1054
+ * is in force (the host owns the prompt then).
1055
+ */
1056
+ setPlanMode(active: boolean): Promise<void>;
1057
+ /**
1058
+ * Bake an approved plan into the system prompt so the model is told to emit
1059
+ * `[DONE:n]` markers as it completes each step (the contract the UI's
1060
+ * plan-progress widget reads). Pass `undefined` to clear it. No-op when a
1061
+ * custom system prompt is in force (the host owns the prompt then).
1062
+ */
1063
+ setApprovedPlan(approvedPlanPath: string | undefined): Promise<void>;
1064
+ /**
1065
+ * Before the conversation starts, render plan state into the prompt. After,
1066
+ * the prompt is a cached prefix: queue an appended notice instead, so the
1067
+ * cached bytes stay identical (a rebuild re-sent the whole history).
1068
+ */
1069
+ private applyPlanStateChange;
1070
+ /** The plan notice to append now, if any (pending, or a compacted-away one). */
1071
+ private takePlanNotice;
1072
+ /** Extra workspace roots added with `/add-dir`, in the order added. */
1073
+ getAdditionalRoots(): string[];
1074
+ /**
1075
+ * The custom `.gg/commands` slash commands this session can run: the
1076
+ * project's, then those of every added root (a goal's attached repos too).
1077
+ * Read fresh, so a new command file is picked up without a restart.
1078
+ */
1079
+ loadCustomCommands(): Promise<CustomCommand[]>;
1080
+ /**
1081
+ * Add another workspace root. Tools already accept absolute paths, so this
1082
+ * only widens the write guard and tells the model the root exists. Rebuilding
1083
+ * the system prompt costs one cache-miss turn — the alternative (an uncached
1084
+ * suffix) would drift from the tool behaviour it describes.
1085
+ *
1086
+ * @returns the resolved root, or an error message for the user.
1087
+ */
1088
+ addDirectory(dir: string): Promise<{
1089
+ ok: true;
1090
+ root: string;
1091
+ } | {
1092
+ ok: false;
1093
+ error: string;
1094
+ }>;
1095
+ /** Remove an exact root previously added with `/add-dir`. */
1096
+ removeDirectory(dir: string): Promise<{
1097
+ ok: true;
1098
+ root: string;
1099
+ } | {
1100
+ ok: false;
1101
+ error: string;
1102
+ }>;
1103
+ /**
1104
+ * Name a root change in the prompt only while there is no conversation yet.
1105
+ * Mid-conversation the env-delta note tells the model instead: the roots sit
1106
+ * in the Environment section, and rewriting it would invalidate every cached
1107
+ * message after it (a goal attaching a folder re-sent ~75k tokens).
1108
+ */
1109
+ private refreshPromptForRoots;
1110
+ /**
1111
+ * Names to advertise as available-on-demand. A tool the model already
1112
+ * promoted lives in `this.tools` and carries its own schema, so it drops out
1113
+ * of the index rather than being listed twice.
1114
+ */
1115
+ private deferredToolNamesForPrompt;
1116
+ /**
1117
+ * The environment about to be rendered into a prompt, remembered as the
1118
+ * truth the model has been told. Pairs with the env-delta hook: whatever the
1119
+ * prompt states, the model is only corrected when reality moves away from it.
1120
+ */
1121
+ private recordRenderedEnvironment;
1122
+ /** Environment facts that vary per session rather than per host. */
1123
+ private promptEnvironment;
1124
+ /**
1125
+ * Build the stable system-prompt prefix for the current tool set and state.
1126
+ *
1127
+ * Three modes, in precedence order: a full replacement (`systemPrompt`), a
1128
+ * composed sub-agent prompt (`agentPrompt` — agent body plus Tools, project
1129
+ * context, return contract and Environment), or the standard prompt.
1130
+ */
1131
+ private buildBasePrompt;
1132
+ /**
1133
+ * Bring the system prompt to the exact state the next provider request will
1134
+ * send. Shared by real runs and {@link prewarm} so both see one prefix.
1135
+ *
1136
+ * Languages are re-detected at each task boundary. Before the first reply
1137
+ * nothing is cached worth keeping, so a new language simply rebuilds the
1138
+ * prompt. After that the prompt is a cached prefix and is left alone: the
1139
+ * new language is announced by {@link announceNewLanguages} instead.
1140
+ */
1141
+ private prepareSystemPromptForRequest;
1142
+ private hasReply;
1143
+ /**
1144
+ * Give the model verify commands for languages that appeared after its prompt
1145
+ * was cached (e.g. the previous task scaffolded a TypeScript project), as a
1146
+ * hidden message appended to the history rather than a prompt re-render that
1147
+ * would throw away the whole cache. Runs just before a new user message is
1148
+ * added, so the user's request stays the last thing the model reads and the
1149
+ * update is saved in order with the rest of the conversation.
1150
+ */
1151
+ private announceNewLanguages;
1152
+ /**
1153
+ * Whether this session renders language packs: the standard prompt, and a
1154
+ * code-writing child (a sub-agent prompt with project context). A verbatim
1155
+ * custom prompt never does, nor do user-facing specialist agents (Motion,
1156
+ * goals) or recon children without project context.
1157
+ */
1158
+ private languagesApply;
1159
+ /** Add newly detected project languages. Returns true when the set grew. */
1160
+ private refreshActiveLanguages;
1161
+ /** Rebuild messages[0] from current plan-mode + approved-plan state. */
1162
+ private rebuildSystemPromptInPlace;
1163
+ /**
1164
+ * Compose the system message: stable prefix, then everything volatile behind
1165
+ * the `<!-- uncached -->` marker that providers split on for cache control.
1166
+ *
1167
+ * Anything that varies with the live model/provider/thinking level belongs in
1168
+ * the tail. Putting it in the prefix means every model switch rewrites cached
1169
+ * bytes and the next turn pays a full cache write instead of a read.
1170
+ */
1171
+ private withSystemPromptTail;
1172
+ /**
1173
+ * Sol/Terra async-orchestration guidance for the CURRENT model and thinking
1174
+ * level. Per-switch volatile by definition, so it is rendered as a tail part
1175
+ * rather than spliced into the cached prefix.
1176
+ */
1177
+ private orchestrationPolicyTail;
1178
+ /**
1179
+ * Re-render the uncached tail of messages[0] in place. The cached prefix is
1180
+ * byte-identical afterwards, so this is safe to call on every model /
1181
+ * thinking-level change.
1182
+ */
1183
+ private refreshSystemPromptTail;
1184
+ getMessages(): Message[];
1185
+ getTurnMetrics(): TurnMetricPayload[];
1186
+ private persistTurnMetric;
1187
+ /** Ken Kai (mentor) turns recorded against this session, in record order. Used
1188
+ * by the host to interleave Ken's advisory exchanges back into the transcript
1189
+ * on resume. Never part of the LLM message history. */
1190
+ getKenTurns(): KenTurnPayload[];
1191
+ /** Autopilot verdict markers recorded against this session, in record order.
1192
+ * Used by the host to interleave the auto-review loop's markers back into
1193
+ * the transcript on resume, mirroring `getKenTurns`. */
1194
+ getAutopilotMarkers(): AutopilotMarkerPayload[];
1195
+ /** Non-system messages that are actually on disk. Transcript markers anchor
1196
+ * against this (not the in-memory list, which can run ahead after a failed
1197
+ * run), so hosts computing marker-derived values must use the same base. */
1198
+ getPersistedTranscriptCount(): number;
1199
+ /**
1200
+ * Rebase every transcript anchor (Ken turns, autopilot verdicts, app markers)
1201
+ * onto a freshly compacted message list. Called right after `this.messages`
1202
+ * is replaced and before the markers are re-persisted into the continuation
1203
+ * file, so the new file carries positions that match its own transcript.
1204
+ */
1205
+ private remapMarkerAnchors;
1206
+ /**
1207
+ * Record one Ken Kai (mentor agent) turn against this build session: the
1208
+ * user's question + Ken's reply. Kept in memory for the live transcript and
1209
+ * persisted as a `custom` entry (parentId null, so it's never on the message
1210
+ * DAG and never seen by the LLM, and can't race the build session's leaf while
1211
+ * Ken runs concurrently). `afterMessageCount` anchors it among the messages so
1212
+ * the host can interleave it chronologically. No-op persistence for transient
1213
+ * sessions (kept in memory only). Best-effort: a write failure is swallowed by
1214
+ * appendEntry's own handling.
1215
+ */
1216
+ persistKenTurn(question: string, reply: string): Promise<void>;
1217
+ /**
1218
+ * Record one autopilot verdict marker (prompted / done / human / capped)
1219
+ * against this build session. Kept in memory for the live transcript and
1220
+ * persisted as a `custom` entry (parentId null, same as Ken turns) so a
1221
+ * resumed session renders the exact same Ken bubble the live run showed
1222
+ * instead of dropping the marker or falling back to a raw verdict string.
1223
+ * No-op persistence for transient sessions (kept in memory only).
1224
+ */
1225
+ getVerificationEvidence(): VerificationEvidence[];
1226
+ /** Current request activity, separate from persistent workspace verification debt. */
1227
+ getRunVerificationActivity(): {
1228
+ changed: boolean;
1229
+ checked: boolean;
1230
+ evidence: VerificationEvidence[];
1231
+ };
1232
+ getVerificationProblem(): string | null;
1233
+ private persistCompletionReviewState;
1234
+ /**
1235
+ * A chat row saying where this conversation now works ("Opened on branch x in
1236
+ * its own worktree"), live and on every later restore of the transcript.
1237
+ */
1238
+ noteCheckout(text: string): void;
1239
+ /** The branch and checkout this conversation last recorded, or null. */
1240
+ getCheckoutRecord(): CheckoutRecord | null;
1241
+ /**
1242
+ * Remember the branch this conversation is on, so resuming it later opens
1243
+ * that branch (see core/checkout-record.ts). Unchanged records write nothing.
1244
+ */
1245
+ recordCheckout(record: CheckoutRecord): Promise<void>;
1246
+ private persistCheckoutRecord;
1247
+ private persistVerificationState;
1248
+ persistAutopilotMarker(phase: AutopilotMarkerPayload["phase"], extra?: {
1249
+ reason?: string;
1250
+ body?: string;
1251
+ }): Promise<void>;
1252
+ /** App transcript markers recorded against this session, in record order.
1253
+ * Used by the host to interleave display-only rows (plan banner, task
1254
+ * header, errors, user-bubble hints) back into the transcript on resume. */
1255
+ getAppMarkers(): AppMarkerPayload[];
1256
+ /**
1257
+ * Record one app transcript marker (display-only row) against this session.
1258
+ * Same treatment as autopilot markers: kept in memory for the live
1259
+ * transcript, persisted as a `custom` entry (parentId null, never on the
1260
+ * message DAG) so a resumed session shows the identical row. `anchorOffset`
1261
+ * shifts the recorded `afterMessageCount` — pass +1 for a marker that should
1262
+ * attach to the user message about to be pushed by the imminent prompt.
1263
+ * No-op persistence for transient sessions.
1264
+ */
1265
+ persistAppMarker(kind: AppMarkerPayload["kind"], data: Record<string, unknown>, anchorOffset?: number): Promise<void>;
1266
+ /**
1267
+ * Open the run journal for one `RunLifecycle` generation.
1268
+ *
1269
+ * Never throws and never blocks the run: a session with no file (transient
1270
+ * children) writes nothing, and a write failure just means the run isn't
1271
+ * journalled — which is strictly better than failing the run over it.
1272
+ */
1273
+ persistRunStarted(generation: number): Promise<void>;
1274
+ /** Close the run journal. Its absence is what marks a run as crashed. */
1275
+ persistRunFinished(generation: number, outcome: RunOutcome): Promise<void>;
1276
+ /**
1277
+ * Rewrite a draft prompt into a tighter, terminology-correct version using
1278
+ * the ACTIVE provider/model. A stateless one-off LLM call (no agent loop, no
1279
+ * tools, no session mutation) — safe to run even mid-run. Returns the plain
1280
+ * enhanced text plus typed segments marking each corrected term. Errors throw
1281
+ * so the caller can surface them.
1282
+ */
1283
+ enhancePrompt(text: string): Promise<EnhanceResult>;
1284
+ /** A commit message for `diff`, on the active model (the Git panel's ship button). */
1285
+ writeCommitMessage(diff: string): Promise<CommitMessage>;
1286
+ /** Current reasoning/thinking level, or undefined when thinking is off. */
1287
+ getThinkingLevel(): ThinkingLevel | undefined;
1288
+ /** Set the reasoning/thinking level (undefined turns thinking off). Takes
1289
+ * effect on the next prompt, since the in-flight loop reads it at start. */
1290
+ setThinkingLevel(level: ThinkingLevel | undefined): void;
1291
+ /** Replace the abort signal (e.g. after cancellation). */
1292
+ setSignal(signal: AbortSignal): void;
1293
+ private bindManagerCancellation;
1294
+ private runLoopDepth;
1295
+ private lastRealRequestAt;
1296
+ private lastPrewarmAt;
1297
+ /** Last connection pre-open per provider origin (see {@link preconnect}). */
1298
+ private readonly preconnectedAt;
1299
+ /**
1300
+ * Fire-and-forget: open the TLS connection to the active provider before the
1301
+ * first request, through the shared keep-alive pool. Zero tokens — an
1302
+ * unauthenticated HEAD; skipped for local endpoints and throttled per origin.
1303
+ * Transient sessions (one-shot tools) and test runs never touch the network here.
1304
+ */
1305
+ private preconnect;
1306
+ private prewarmController;
1307
+ /** Claude Code session that has seen this history (Claude subscription route). */
1308
+ private claudeCodeSession;
1309
+ private releaseClaudeCodeTranscript;
1310
+ /** Keep the retention pass off the transcript this chat would resume. */
1311
+ private holdClaudeCodeTranscript;
1312
+ /** This chat's running Claude Code process, reused while `key` (its start settings) matches. */
1313
+ private claudeCodeLive;
1314
+ /**
1315
+ * Context size between runs: the last provider usage plus messages appended
1316
+ * after it, or undefined when there is no usable sample (callers estimate).
1317
+ * Same measurement the pre-run compaction check makes.
1318
+ */
1319
+ private idleActiveContextTokens;
1320
+ /**
1321
+ * Prune stale tool outputs in place once the context is big enough for the
1322
+ * freed tokens to be worth a cache rewrite (a larger share on a warm cache,
1323
+ * see pruneMinimumTokens). In-place mutation preserves usage anchors; the
1324
+ * retained usage is dropped since it counted the pruned content. Shared by
1325
+ * the in-flight context transform and prewarm so both send the same prefix.
1326
+ * Returns the freed tokens (0 when nothing was pruned).
1327
+ */
1328
+ private pruneToolOutputsIfDue;
1329
+ /**
1330
+ * Mark where the last prune made history stable (`Message.cacheAnchor`), so
1331
+ * the provider can keep a cache breakpoint there. Without it every prune on a
1332
+ * 5-min route re-sent everything after the last entry the tail's lookback
1333
+ * finds; in live sessions a prune freed ~24K tokens and re-wrote ~400K. gg-ai
1334
+ * decides per route whether the hint is used (not on 1-h routes). Returns
1335
+ * true when the anchor moved.
1336
+ */
1337
+ private applyPendingCacheAnchor;
1338
+ /**
1339
+ * Apply the next request's context policy before warming: report when its
1340
+ * pre-run check will compact, otherwise prune now exactly as its first model
1341
+ * step would. The cache is cold here (prewarm only runs once it has lapsed),
1342
+ * so the prune uses the cold-cache floor, as the request would without the
1343
+ * prewarm; afterwards the warm cache's larger floor keeps that request from
1344
+ * pruning again. Prewarm is Anthropic-only, so the cached account id never
1345
+ * changes the window.
1346
+ */
1347
+ private prepareContextForPrewarm;
1348
+ /**
1349
+ * Best-effort Anthropic prompt-cache prewarm before the user's next turn
1350
+ * (desktop app calls this on the first keystroke after opening a chat or an
1351
+ * idle pause). Sends the exact request prefix the next real turn will use —
1352
+ * same system/tools/thinking/cache options — with `max_tokens: 1`, so the
1353
+ * first real reply is a cache read instead of a cold write.
1354
+ */
1355
+ prewarm(signal?: AbortSignal): Promise<{
1356
+ ok: boolean;
1357
+ reason: string;
1358
+ usage?: Usage;
1359
+ }>;
1360
+ private codexShapeSetting;
1361
+ /** True when speedProfile is "optimized" (1-h cache TTL + pre-warm), or the
1362
+ * session was constructed with `forceLongCacheRetention` (Ken sessions). */
1363
+ private isSpeedOptimized;
1364
+ /**
1365
+ * Ordered auth-storage keys the current (provider, model) pair tries, first
1366
+ * match wins. Almost always just the provider id; Xiaomi models can prefer
1367
+ * one endpoint and fall back to another the user configured instead (e.g.
1368
+ * every MiMo model prefers the Token Plan, falls back to API Credits).
1369
+ */
1370
+ private currentAuthStorageKeys;
1371
+ private getPromptCacheKey;
1372
+ /** Stable cache-routing key for downstream sub-agent processes. */
1373
+ getCurrentCacheKey(): string | undefined;
1374
+ dispose(): Promise<void>;
1375
+ private setSessionPath;
1376
+ private createNewSession;
1377
+ private loadExistingSession;
1378
+ /**
1379
+ * Surface runs that died mid-flight, without resuming them.
1380
+ *
1381
+ * Deliberately NOT auto-resumed: the dead run's tools already wrote files,
1382
+ * ran commands and made commits. Replaying it would duplicate those effects.
1383
+ * The user gets a transcript row and decides.
1384
+ *
1385
+ * Each detected run is also closed as `aborted`, so reopening the session
1386
+ * reports it once rather than on every load.
1387
+ */
1388
+ private recordInterruptedRuns;
1389
+ private prepareDynamicContext;
1390
+ private persistMessage;
1391
+ private createSlashCommandContext;
1392
+ /**
1393
+ * Import a Claude Code / Codex / Cursor transcript as a resumable GG Coder
1394
+ * session in this session's sessions directory. Never throws — a bad path or
1395
+ * an unrecognized format comes back as `{ ok: false, error }` so both the CLI
1396
+ * and the desktop app can show it verbatim.
1397
+ */
1398
+ importForeignTranscript(filePath: string, opts?: {
1399
+ cwd?: string;
1400
+ }): Promise<ImportForeignTranscriptResult>;
1401
+ }