@oyasmi/pipiclaw 0.9.3 → 0.9.4-beta.2

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 (336) hide show
  1. package/dist/agent/builtin-commands.d.ts +19 -0
  2. package/dist/agent/builtin-commands.js +80 -0
  3. package/dist/agent/channel-runner.d.ts +20 -208
  4. package/dist/agent/channel-runner.js +167 -1188
  5. package/dist/agent/maintenance-context.d.ts +1 -1
  6. package/dist/agent/maintenance-context.js +1 -1
  7. package/dist/agent/prompt/manifest.d.ts +6 -1
  8. package/dist/agent/prompt/manifest.js +45 -64
  9. package/dist/agent/prompt/resources.d.ts +3 -0
  10. package/dist/agent/prompt/resources.js +11 -2
  11. package/dist/agent/runner-factory.d.ts +1 -43
  12. package/dist/agent/{command-extension.d.ts → session/command-extension.d.ts} +4 -0
  13. package/dist/agent/{command-extension.js → session/command-extension.js} +48 -35
  14. package/dist/agent/{type-guards.d.ts → session/event-guards.d.ts} +2 -2
  15. package/dist/agent/{type-guards.js → session/event-guards.js} +5 -1
  16. package/dist/agent/session/model-selection.d.ts +47 -0
  17. package/dist/agent/session/model-selection.js +99 -0
  18. package/dist/agent/{session-adapter.d.ts → session/session-adapter.d.ts} +21 -1
  19. package/dist/agent/session/session-adapter.js +159 -0
  20. package/dist/agent/{session-events.d.ts → session/session-events.d.ts} +9 -5
  21. package/dist/agent/{session-events.js → session/session-events.js} +24 -13
  22. package/dist/agent/session/session-host.d.ts +200 -0
  23. package/dist/agent/session/session-host.js +621 -0
  24. package/dist/agent/{session-resource-gate.js → session/session-resource-gate.js} +5 -3
  25. package/dist/agent/status-render.d.ts +0 -1
  26. package/dist/agent/status-render.js +4 -16
  27. package/dist/agent/{context-budget.js → turn/context-budget.js} +5 -1
  28. package/dist/agent/{progress-formatter.d.ts → turn/progress-formatter.d.ts} +4 -1
  29. package/dist/agent/{run-queue.d.ts → turn/run-queue.d.ts} +1 -1
  30. package/dist/agent/{run-queue.js → turn/run-queue.js} +10 -5
  31. package/dist/{memory → agent/turn}/task-digest.js +4 -4
  32. package/dist/agent/turn/turn-context.d.ts +14 -0
  33. package/dist/agent/turn/turn-context.js +64 -0
  34. package/dist/agent/turn/turn-error.d.ts +31 -0
  35. package/dist/agent/turn/turn-error.js +68 -0
  36. package/dist/agent/turn/turn-finish.d.ts +50 -0
  37. package/dist/agent/turn/turn-finish.js +188 -0
  38. package/dist/agent/turn/turn-input.d.ts +43 -0
  39. package/dist/agent/turn/turn-input.js +79 -0
  40. package/dist/agent/turn/turn-pipeline.d.ts +68 -0
  41. package/dist/agent/turn/turn-pipeline.js +257 -0
  42. package/dist/agent/{turn-prompt.d.ts → turn/turn-prompt.d.ts} +2 -2
  43. package/dist/agent/{turn-prompt.js → turn/turn-prompt.js} +6 -2
  44. package/dist/agent/{turn-recovery.js → turn/turn-recovery.js} +1 -1
  45. package/dist/agent/{turn-state.d.ts → turn/turn-state.d.ts} +1 -1
  46. package/dist/agent/types.d.ts +43 -2
  47. package/dist/agent/types.js +1 -1
  48. package/dist/{models/auth-cli.d.ts → app/auth-command.d.ts} +1 -1
  49. package/dist/{models/auth-cli.js → app/auth-command.js} +14 -10
  50. package/dist/{runtime/app-home.d.ts → app/home.d.ts} +6 -2
  51. package/dist/{runtime/app-home.js → app/home.js} +22 -75
  52. package/dist/{runtime → app}/proxy.js +4 -2
  53. package/dist/{app-services.d.ts → app/services.d.ts} +5 -5
  54. package/dist/{app-services.js → app/services.js} +17 -14
  55. package/dist/channel/channel-context.d.ts +12 -2
  56. package/dist/channel/channel-context.js +29 -2
  57. package/dist/channel/channel-event.d.ts +10 -2
  58. package/dist/channel/channel-event.js +1 -1
  59. package/dist/channel/channel-index.js +4 -1
  60. package/dist/{runtime/project-commands.d.ts → channel/commands.d.ts} +1 -1
  61. package/dist/{runtime/project-commands.js → channel/commands.js} +17 -16
  62. package/dist/channel/project-scope-store.js +1 -1
  63. package/dist/channel/store.js +4 -0
  64. package/dist/commands/catalog.d.ts +24 -7
  65. package/dist/commands/catalog.js +91 -44
  66. package/dist/commands/reply-limits.d.ts +6 -0
  67. package/dist/commands/reply-limits.js +24 -0
  68. package/dist/{runtime/report-commands.d.ts → commands/router.d.ts} +10 -3
  69. package/dist/{runtime/report-commands.js → commands/router.js} +6 -6
  70. package/dist/{settings.d.ts → config/settings.d.ts} +10 -10
  71. package/dist/{settings.js → config/settings.js} +11 -11
  72. package/dist/{tools/config.d.ts → config/tools.d.ts} +1 -2
  73. package/dist/{tools/config.js → config/tools.js} +5 -2
  74. package/dist/dingtalk/access-token.d.ts +12 -0
  75. package/dist/dingtalk/access-token.js +51 -0
  76. package/dist/dingtalk/api.d.ts +19 -0
  77. package/dist/dingtalk/api.js +67 -0
  78. package/dist/dingtalk/bot.d.ts +97 -0
  79. package/dist/dingtalk/bot.js +389 -0
  80. package/dist/dingtalk/cards.d.ts +56 -0
  81. package/dist/dingtalk/cards.js +318 -0
  82. package/dist/{runtime → dingtalk}/channel-queue.js +4 -1
  83. package/dist/dingtalk/config.d.ts +19 -0
  84. package/dist/dingtalk/config.js +95 -0
  85. package/dist/dingtalk/connection.d.ts +57 -0
  86. package/dist/dingtalk/connection.js +356 -0
  87. package/dist/dingtalk/conversation-meta.d.ts +16 -0
  88. package/dist/dingtalk/conversation-meta.js +77 -0
  89. package/dist/{runtime → dingtalk}/delivery.d.ts +6 -2
  90. package/dist/{runtime → dingtalk}/delivery.js +29 -15
  91. package/dist/dingtalk/handler.d.ts +90 -0
  92. package/dist/dingtalk/handler.js +1 -0
  93. package/dist/dingtalk/inbound.d.ts +66 -0
  94. package/dist/dingtalk/inbound.js +137 -0
  95. package/dist/dingtalk/media.d.ts +66 -0
  96. package/dist/dingtalk/media.js +214 -0
  97. package/dist/events/{event-commands.js → commands.js} +99 -45
  98. package/dist/events/parse.d.ts +14 -0
  99. package/dist/events/parse.js +114 -0
  100. package/dist/events/types.d.ts +93 -0
  101. package/dist/events/types.js +1 -0
  102. package/dist/events/{event-validation.d.ts → validation.d.ts} +14 -3
  103. package/dist/events/{event-validation.js → validation.js} +17 -9
  104. package/dist/events/watcher.d.ts +67 -0
  105. package/dist/events/{events.js → watcher.js} +63 -121
  106. package/dist/executor.js +2 -2
  107. package/dist/index.d.ts +6 -4
  108. package/dist/index.js +2 -2
  109. package/dist/jobs/launch.d.ts +42 -0
  110. package/dist/jobs/launch.js +118 -0
  111. package/dist/{agent/job-manager.d.ts → jobs/manager.d.ts} +1 -67
  112. package/dist/{agent/job-manager.js → jobs/manager.js} +34 -157
  113. package/dist/jobs/record.d.ts +55 -0
  114. package/dist/jobs/record.js +36 -0
  115. package/dist/log.d.ts +12 -2
  116. package/dist/log.js +26 -34
  117. package/dist/main.js +3 -3
  118. package/dist/memory/commands.js +29 -23
  119. package/dist/memory/lifecycle.js +26 -5
  120. package/dist/memory/maintenance-gates.d.ts +2 -2
  121. package/dist/memory/maintenance-state.js +4 -1
  122. package/dist/memory/maintenance-tuning.d.ts +15 -0
  123. package/dist/memory/maintenance-tuning.js +3 -0
  124. package/dist/memory/reflect-job.d.ts +2 -2
  125. package/dist/memory/reflect-job.js +4 -2
  126. package/dist/memory/scheduler.d.ts +3 -3
  127. package/dist/memory/scheduler.js +5 -2
  128. package/dist/memory/sidecar-worker.js +1 -1
  129. package/dist/memory/transcript.js +1 -1
  130. package/dist/{agent/model-fallback.d.ts → models/fallback.d.ts} +6 -6
  131. package/dist/{agent/model-fallback.js → models/fallback.js} +15 -28
  132. package/dist/models/login-identity.d.ts +2 -0
  133. package/dist/models/login-identity.js +83 -0
  134. package/dist/models/provider-login.d.ts +3 -1
  135. package/dist/models/provider-login.js +8 -2
  136. package/dist/models/reference.d.ts +20 -0
  137. package/dist/models/{utils.js → reference.js} +0 -48
  138. package/dist/models/{utils.d.ts → runtime.d.ts} +1 -16
  139. package/dist/models/runtime.js +52 -0
  140. package/dist/paths.d.ts +2 -0
  141. package/dist/paths.js +9 -0
  142. package/dist/playbooks/agent-delegation.md +2 -2
  143. package/dist/playbooks/catalog.d.ts +6 -2
  144. package/dist/playbooks/catalog.js +9 -6
  145. package/dist/runtime/bootstrap.d.ts +7 -17
  146. package/dist/runtime/bootstrap.js +70 -659
  147. package/dist/runtime/durable-dispatch.d.ts +43 -4
  148. package/dist/runtime/durable-dispatch.js +153 -3
  149. package/dist/runtime/inbound-images.d.ts +18 -0
  150. package/dist/runtime/inbound-images.js +51 -0
  151. package/dist/runtime/shutdown.d.ts +39 -0
  152. package/dist/runtime/shutdown.js +120 -0
  153. package/dist/runtime/stop-watchdog.d.ts +16 -0
  154. package/dist/runtime/stop-watchdog.js +32 -0
  155. package/dist/runtime/task-driver.d.ts +6 -4
  156. package/dist/runtime/task-driver.js +58 -23
  157. package/dist/runtime/task-migration.js +25 -8
  158. package/dist/runtime/task-spawn.d.ts +1 -1
  159. package/dist/runtime/task-spawn.js +13 -6
  160. package/dist/runtime/turn-handler.d.ts +47 -0
  161. package/dist/runtime/turn-handler.js +318 -0
  162. package/dist/runtime/turn-run.d.ts +52 -0
  163. package/dist/runtime/turn-run.js +318 -0
  164. package/dist/runtime/wake-coalescing.d.ts +18 -0
  165. package/dist/runtime/wake-coalescing.js +29 -0
  166. package/dist/security/block-message.d.ts +22 -1
  167. package/dist/security/block-message.js +66 -1
  168. package/dist/security/command-guard.js +4 -0
  169. package/dist/security/network.d.ts +2 -1
  170. package/dist/security/network.js +7 -2
  171. package/dist/security/path-guard-check.js +2 -2
  172. package/dist/security/path-guard.js +4 -0
  173. package/dist/security/types.d.ts +1 -2
  174. package/dist/security/types.js +1 -2
  175. package/dist/shared/exact-keys.d.ts +1 -1
  176. package/dist/shared/format.d.ts +12 -0
  177. package/dist/shared/format.js +37 -0
  178. package/dist/shared/host-process.js +16 -4
  179. package/dist/shared/wake-claim.d.ts +1 -1
  180. package/dist/shared/with-timeout.d.ts +3 -2
  181. package/dist/shared/with-timeout.js +14 -3
  182. package/dist/{runtime/skill-commands.d.ts → skills/commands.d.ts} +2 -2
  183. package/dist/{runtime/skill-commands.js → skills/commands.js} +18 -11
  184. package/dist/{agent/workspace-resources.js → skills/loader.js} +1 -1
  185. package/dist/{tools/skill-security.js → skills/validation.js} +4 -0
  186. package/dist/skills/workspace.d.ts +33 -0
  187. package/dist/skills/workspace.js +116 -0
  188. package/dist/{runtime/subagent-commands.d.ts → subagents/commands.d.ts} +9 -7
  189. package/dist/{runtime/subagent-commands.js → subagents/commands.js} +116 -77
  190. package/dist/subagents/completion-wake.d.ts +17 -0
  191. package/dist/subagents/completion-wake.js +76 -0
  192. package/dist/subagents/detached-discovery.js +1 -1
  193. package/dist/subagents/discovery.d.ts +1 -1
  194. package/dist/subagents/discovery.js +2 -2
  195. package/dist/subagents/dispatch.d.ts +33 -0
  196. package/dist/subagents/dispatch.js +190 -0
  197. package/dist/subagents/external/claude-code.js +23 -1
  198. package/dist/subagents/external/dispatch.d.ts +25 -0
  199. package/dist/subagents/external/dispatch.js +90 -0
  200. package/dist/subagents/external/harness.d.ts +1 -1
  201. package/dist/subagents/external/progress-tail.d.ts +18 -1
  202. package/dist/subagents/external/progress-tail.js +64 -17
  203. package/dist/subagents/external/run.d.ts +5 -1
  204. package/dist/subagents/external/run.js +23 -9
  205. package/dist/subagents/external/settlement.d.ts +4 -1
  206. package/dist/subagents/external/settlement.js +1 -1
  207. package/dist/subagents/format.d.ts +1 -1
  208. package/dist/subagents/grace.d.ts +24 -0
  209. package/dist/subagents/grace.js +57 -0
  210. package/dist/subagents/internal/outcome.d.ts +24 -0
  211. package/dist/subagents/internal/outcome.js +149 -0
  212. package/dist/subagents/internal/provider-retry.d.ts +19 -0
  213. package/dist/subagents/internal/provider-retry.js +83 -0
  214. package/dist/subagents/internal/run.d.ts +31 -0
  215. package/dist/subagents/internal/run.js +240 -0
  216. package/dist/subagents/internal/state.d.ts +43 -0
  217. package/dist/subagents/internal/state.js +48 -0
  218. package/dist/subagents/internal/worker.d.ts +51 -0
  219. package/dist/subagents/internal/worker.js +167 -0
  220. package/dist/subagents/result.d.ts +62 -0
  221. package/dist/subagents/result.js +103 -0
  222. package/dist/subagents/run-record.d.ts +222 -0
  223. package/dist/subagents/run-record.js +101 -0
  224. package/dist/subagents/run-registry.d.ts +9 -0
  225. package/dist/subagents/run-registry.js +125 -0
  226. package/dist/subagents/runs.d.ts +16 -232
  227. package/dist/subagents/runs.js +132 -310
  228. package/dist/subagents/task-envelope.d.ts +36 -0
  229. package/dist/subagents/task-envelope.js +168 -0
  230. package/dist/subagents/types.d.ts +154 -0
  231. package/dist/subagents/types.js +1 -0
  232. package/dist/subagents/verification-outcome.d.ts +1 -1
  233. package/dist/subagents/workspace-summary.d.ts +16 -4
  234. package/dist/subagents/workspace-summary.js +74 -18
  235. package/dist/tasks/board.d.ts +10 -3
  236. package/dist/tasks/board.js +38 -3
  237. package/dist/tasks/{work-log.d.ts → bound-work.d.ts} +1 -1
  238. package/dist/tasks/{work-log.js → bound-work.js} +1 -1
  239. package/dist/tasks/brief.js +1 -1
  240. package/dist/{runtime/task-commands.d.ts → tasks/commands.d.ts} +1 -1
  241. package/dist/{runtime/task-commands.js → tasks/commands.js} +117 -67
  242. package/dist/tasks/contract-input.d.ts +1 -1
  243. package/dist/tasks/contract-input.js +1 -1
  244. package/dist/tasks/create.js +1 -1
  245. package/dist/tasks/frontmatter.d.ts +5 -0
  246. package/dist/tasks/frontmatter.js +8 -0
  247. package/dist/tasks/{log.d.ts → loop-log.d.ts} +11 -1
  248. package/dist/tasks/{log.js → loop-log.js} +59 -3
  249. package/dist/tasks/mutation-lock.js +1 -1
  250. package/dist/tasks/session-path.js +1 -1
  251. package/dist/tasks/steer.js +1 -1
  252. package/dist/tasks/store.js +6 -4
  253. package/dist/tasks/ticket.d.ts +3 -1
  254. package/dist/tasks/ticket.js +19 -1
  255. package/dist/tools/bash.d.ts +1 -1
  256. package/dist/tools/bash.js +2 -2
  257. package/dist/tools/{tool-details.d.ts → contract/details.d.ts} +11 -3
  258. package/dist/tools/{tool-details.js → contract/details.js} +42 -5
  259. package/dist/tools/{presentation.js → contract/presentation.js} +3 -3
  260. package/dist/tools/event-manage.d.ts +1 -1
  261. package/dist/tools/event-manage.js +4 -4
  262. package/dist/tools/index.d.ts +5 -3
  263. package/dist/tools/index.js +8 -6
  264. package/dist/tools/job.d.ts +1 -1
  265. package/dist/tools/memory-manage.js +4 -1
  266. package/dist/tools/registry.d.ts +7 -7
  267. package/dist/tools/registry.js +6 -6
  268. package/dist/tools/session-search.d.ts +1 -1
  269. package/dist/tools/skill.d.ts +2 -34
  270. package/dist/tools/skill.js +8 -116
  271. package/dist/tools/subagent-manage.d.ts +1 -1
  272. package/dist/tools/subagent-manage.js +19 -13
  273. package/dist/tools/subagent.d.ts +46 -0
  274. package/dist/tools/subagent.js +127 -0
  275. package/dist/tools/{task-manage.d.ts → task-manage/factory.d.ts} +7 -3
  276. package/dist/tools/{task-manage.js → task-manage/factory.js} +7 -7
  277. package/dist/tools/task-manage/lifecycle.js +2 -2
  278. package/dist/tools/task-manage/log-view.js +2 -2
  279. package/dist/tools/task-manage/shared.js +3 -3
  280. package/dist/tools/task-manage/step-end.js +7 -4
  281. package/dist/tools/task-manage/types.d.ts +1 -1
  282. package/dist/tools/web-fetch.d.ts +1 -1
  283. package/dist/tools/web-search.d.ts +1 -1
  284. package/dist/tui/app.d.ts +1 -1
  285. package/dist/tui/app.js +6 -6
  286. package/dist/tui/cli.d.ts +1 -1
  287. package/dist/tui/cli.js +3 -3
  288. package/dist/tui/commands.js +4 -4
  289. package/dist/tui/frontend.d.ts +44 -0
  290. package/dist/tui/frontend.js +13 -0
  291. package/dist/tui/pitui-frontend.d.ts +1 -1
  292. package/dist/tui/pitui-frontend.js +1 -1
  293. package/dist/tui/plain-frontend.d.ts +1 -1
  294. package/dist/tui/renderer.d.ts +3 -42
  295. package/dist/tui/renderer.js +3 -2
  296. package/dist/tui/terminal-context.d.ts +2 -2
  297. package/dist/tui/terminal-media-sender.d.ts +1 -1
  298. package/dist/tui/turn-controller.d.ts +3 -1
  299. package/dist/tui/turn-controller.js +36 -21
  300. package/dist/usage/ledger.js +7 -1
  301. package/dist/usage/render.js +3 -1
  302. package/dist/{shared/types.d.ts → usage/totals.d.ts} +3 -0
  303. package/dist/web/client.d.ts +5 -1
  304. package/dist/web/client.js +4 -0
  305. package/dist/web/config.d.ts +1 -1
  306. package/dist/web/fetch.d.ts +1 -1
  307. package/dist/web/search-providers.d.ts +1 -1
  308. package/dist/web/search.d.ts +1 -1
  309. package/package.json +9 -7
  310. package/dist/agent/session-adapter.js +0 -77
  311. package/dist/events/events.d.ts +0 -159
  312. package/dist/runtime/dingtalk.d.ts +0 -272
  313. package/dist/runtime/dingtalk.js +0 -1416
  314. package/dist/subagents/tool.d.ts +0 -206
  315. package/dist/subagents/tool.js +0 -1088
  316. /package/dist/{runtime → agent/prompt}/workspace-templates.d.ts +0 -0
  317. /package/dist/{runtime → agent/prompt}/workspace-templates.js +0 -0
  318. /package/dist/agent/{session-resource-gate.d.ts → session/session-resource-gate.d.ts} +0 -0
  319. /package/dist/agent/{context-budget.d.ts → turn/context-budget.d.ts} +0 -0
  320. /package/dist/agent/{progress-formatter.js → turn/progress-formatter.js} +0 -0
  321. /package/dist/{memory → agent/turn}/task-digest.d.ts +0 -0
  322. /package/dist/agent/{turn-recovery.d.ts → turn/turn-recovery.d.ts} +0 -0
  323. /package/dist/agent/{turn-state.js → turn/turn-state.js} +0 -0
  324. /package/dist/{runtime → app}/proxy.d.ts +0 -0
  325. /package/dist/{runtime → dingtalk}/channel-queue.d.ts +0 -0
  326. /package/dist/{runtime → dingtalk}/inbound-media.d.ts +0 -0
  327. /package/dist/{runtime → dingtalk}/inbound-media.js +0 -0
  328. /package/dist/events/{event-commands.d.ts → commands.d.ts} +0 -0
  329. /package/dist/{agent/workspace-resources.d.ts → skills/loader.d.ts} +0 -0
  330. /package/dist/{tools/skill-security.d.ts → skills/validation.d.ts} +0 -0
  331. /package/dist/tasks/{ledger.d.ts → contract.d.ts} +0 -0
  332. /package/dist/tasks/{ledger.js → contract.js} +0 -0
  333. /package/dist/tools/{subagent-tool-names.d.ts → contract/names.d.ts} +0 -0
  334. /package/dist/tools/{subagent-tool-names.js → contract/names.js} +0 -0
  335. /package/dist/tools/{presentation.d.ts → contract/presentation.d.ts} +0 -0
  336. /package/dist/{shared/types.js → usage/totals.js} +0 -0
@@ -1,7 +1,11 @@
1
+ /**
2
+ * Adapters over the SDK session where Pipiclaw needs compatibility behaviour: the settings-manager
3
+ * shim and thinking-level preservation when a model changes.
4
+ */
1
5
  import type { Agent, AgentTool, ThinkingLevel } from "@earendil-works/pi-agent-core";
2
6
  import type { Api, Model } from "@earendil-works/pi-ai";
3
7
  import { type AgentSession, SettingsManager as SDKSettingsManager, type SessionManager } from "@earendil-works/pi-coding-agent";
4
- import type { PipiclawSettingsManager } from "../settings.js";
8
+ import type { PipiclawSettingsManager } from "../../config/settings.js";
5
9
  export declare function asSdkSettingsManager(manager: PipiclawSettingsManager): SDKSettingsManager;
6
10
  export declare const DEFAULT_MAIN_THINKING_LEVEL: ThinkingLevel;
7
11
  /** Apply the pi 0.83 source-model thinking compatibility branch to one real AgentSession. */
@@ -17,3 +21,19 @@ export declare function initializeThinkingLevelCompat(agent: Agent, model: Model
17
21
  * silently leaving stale tools in place. Replace with a public setter once upstream adds one.
18
22
  */
19
23
  export declare function setSessionBaseToolsOverride(session: AgentSession, tools: AgentTool<any>[], channelId: string): void;
24
+ /** One prompt's origin. Raw entries establish safety; projection only decides what still needs omission. */
25
+ export declare class SessionRetryAttempt<T extends Pick<AgentSession, "sessionManager" | "refreshContext"> = AgentSession> {
26
+ readonly session: T;
27
+ private readonly manager;
28
+ private readonly sessionId;
29
+ private readonly prefix;
30
+ private retryBranch;
31
+ constructor(session: T);
32
+ classify(): {
33
+ kind: "unsubmitted" | "failed-turn";
34
+ targets: string[];
35
+ } | null;
36
+ prepare(): ReturnType<SessionRetryAttempt<T>["classify"]>;
37
+ /** Caller holds the host resource window and must quarantine this session on any exception. */
38
+ omitFailedContext(): boolean;
39
+ }
@@ -0,0 +1,159 @@
1
+ import { clampThinkingLevel } from "@earendil-works/pi-ai/compat";
2
+ import { SettingsManager as SDKSettingsManager, } from "@earendil-works/pi-coding-agent";
3
+ import * as log from "../../log.js";
4
+ export function asSdkSettingsManager(manager) {
5
+ // The upstream session needs its broad interactive SettingsManager surface, while
6
+ // Pipiclaw deliberately owns a small runtime-specific settings contract. Build a
7
+ // real upstream manager from that contract instead of making PipiclawSettingsManager
8
+ // pretend to implement dozens of unrelated no-op UI preferences.
9
+ return SDKSettingsManager.inMemory({
10
+ defaultProvider: manager.getDefaultProvider(),
11
+ defaultModel: manager.getDefaultModel(),
12
+ defaultThinkingLevel: manager.getDefaultThinkingLevel() ?? DEFAULT_MAIN_THINKING_LEVEL,
13
+ compaction: manager.getCompactionSettings(),
14
+ retry: manager.getRetrySettings(),
15
+ });
16
+ }
17
+ export const DEFAULT_MAIN_THINKING_LEVEL = "medium";
18
+ /** Apply the pi 0.83 source-model thinking compatibility branch to one real AgentSession. */
19
+ export async function setModelWithThinkingPreservation(session, manager, model) {
20
+ const source = session.model;
21
+ if (!source?.reasoning) {
22
+ await session.setModel(model);
23
+ return;
24
+ }
25
+ const previousDefault = manager.getDefaultThinkingLevel();
26
+ manager.setDefaultThinkingLevel(session.thinkingLevel);
27
+ try {
28
+ await session.setModel(model);
29
+ }
30
+ finally {
31
+ manager.setDefaultThinkingLevel(previousDefault ?? DEFAULT_MAIN_THINKING_LEVEL);
32
+ }
33
+ }
34
+ export function setThinkingLevelWithConditionalPersist(session, level) {
35
+ const before = session.thinkingLevel;
36
+ session.setThinkingLevel(level);
37
+ const effective = session.thinkingLevel;
38
+ if (effective === before)
39
+ return;
40
+ if (!session.model?.reasoning && effective === "off")
41
+ return;
42
+ session.setThinkingLevel(effective, { persist: true });
43
+ }
44
+ export function cycleThinkingLevelWithConditionalPersist(session) {
45
+ const before = session.thinkingLevel;
46
+ const next = session.cycleThinkingLevel();
47
+ const effective = session.thinkingLevel;
48
+ if (next && effective !== before && (session.model?.reasoning || effective !== "off")) {
49
+ session.setThinkingLevel(effective, { persist: true });
50
+ }
51
+ return next;
52
+ }
53
+ export function initializeThinkingLevelCompat(agent, model, sessionManager, configuredDefault) {
54
+ const branch = sessionManager.getBranch();
55
+ const hasThinkingEntry = branch.some((entry) => entry.type === "thinking_level_change");
56
+ const historical = sessionManager.buildSessionContext().thinkingLevel;
57
+ const requested = hasThinkingEntry ? historical : (configuredDefault ?? DEFAULT_MAIN_THINKING_LEVEL);
58
+ const effective = clampThinkingLevel(model, requested);
59
+ agent.state.thinkingLevel = effective;
60
+ if (!hasThinkingEntry)
61
+ sessionManager.appendThinkingLevelChange(effective);
62
+ return effective;
63
+ }
64
+ /**
65
+ * Overwrite the SDK session's `baseToolsOverride` map so a resource reload swaps in
66
+ * freshly-built tools. The SDK exposes no public setter for this, so we reach into the
67
+ * private `_baseToolsOverride` field. This is the single, isolated point of that coupling:
68
+ * if a future SDK renames or removes the field, the guard below warns loudly instead of
69
+ * silently leaving stale tools in place. Replace with a public setter once upstream adds one.
70
+ */
71
+ export function setSessionBaseToolsOverride(session, tools, channelId) {
72
+ const target = session;
73
+ if (!("_baseToolsOverride" in target)) {
74
+ log.logWarn("agent.session.sdk_drift", "AgentSession no longer exposes _baseToolsOverride; tool reloads may use stale tools", { channelId: channelId });
75
+ }
76
+ target._baseToolsOverride = Object.fromEntries(tools.map((tool) => [tool.name, tool]));
77
+ }
78
+ /** One prompt's origin. Raw entries establish safety; projection only decides what still needs omission. */
79
+ export class SessionRetryAttempt {
80
+ constructor(session) {
81
+ this.session = session;
82
+ this.manager = session.sessionManager;
83
+ this.sessionId = session.sessionManager.getSessionId();
84
+ this.prefix = session.sessionManager.getBranch().map((entry) => entry.id);
85
+ }
86
+ classify() {
87
+ const manager = this.session.sessionManager;
88
+ if (manager !== this.manager || manager.getSessionId() !== this.sessionId)
89
+ return null;
90
+ const branch = manager.getBranch();
91
+ if (this.prefix.some((id, index) => branch[index]?.id !== id))
92
+ return null;
93
+ if (this.retryBranch) {
94
+ if (this.retryBranch.some((id, index) => branch[index]?.id !== id))
95
+ return null;
96
+ // Once prepared, a new interaction or rewinding the failed branch invalidates the plan.
97
+ if (branch
98
+ .slice(this.retryBranch.length)
99
+ .some((entry) => entry.type === "message" && entry.message.role !== "system"))
100
+ return null;
101
+ }
102
+ const delta = branch.slice(this.prefix.length);
103
+ const users = [];
104
+ const errors = [];
105
+ for (const entry of delta) {
106
+ if (entry.type === "message") {
107
+ const message = entry.message;
108
+ if (message.role === "system")
109
+ continue;
110
+ if (message.role === "user" && errors.length === 0)
111
+ users.push(entry.id);
112
+ else if (message.role === "assistant" && users.length === 1 && message.stopReason === "error") {
113
+ if (message.content.some((part) => part.type === "toolCall" || (part.type === "text" && part.text.trim()))) {
114
+ return null;
115
+ }
116
+ errors.push(entry.id);
117
+ }
118
+ else
119
+ return null;
120
+ }
121
+ else if (entry.type === "context_edit") {
122
+ // Only omissions of this attempt's failed messages are understood (including SDK retries).
123
+ if (entry.replacement !== null || ![...users, ...errors].includes(entry.targetId))
124
+ return null;
125
+ }
126
+ else if (!["model_change", "thinking_level_change", "usage"].includes(entry.type))
127
+ return null;
128
+ }
129
+ if (users.length === 0 && errors.length === 0)
130
+ return { kind: "unsubmitted", targets: [] };
131
+ if (users.length !== 1 || errors.length === 0)
132
+ return null;
133
+ const targets = [...users, ...errors];
134
+ const projection = manager.buildSessionProjection();
135
+ // Even an already omitted entry must have identifiable provenance.
136
+ if (targets.some((id) => !projection.entries.some((entry) => entry.sourceEntry.id === id)))
137
+ return null;
138
+ return {
139
+ kind: "failed-turn",
140
+ targets: targets.filter((id) => projection.entries.some((entry) => entry.sourceEntry.id === id && entry.messages.length)),
141
+ };
142
+ }
143
+ prepare() {
144
+ const plan = this.classify();
145
+ if (plan)
146
+ this.retryBranch ??= this.manager.getBranch().map((entry) => entry.id);
147
+ return plan;
148
+ }
149
+ /** Caller holds the host resource window and must quarantine this session on any exception. */
150
+ omitFailedContext() {
151
+ const plan = this.prepare();
152
+ if (!plan)
153
+ return false;
154
+ for (const id of plan.targets)
155
+ this.session.sessionManager.appendContextEdit(id, null);
156
+ this.session.refreshContext();
157
+ return true;
158
+ }
159
+ }
@@ -1,8 +1,12 @@
1
- import type { ChannelContext } from "../channel/channel-context.js";
2
- import type { ChannelStore } from "../channel/store.js";
3
- import type { MemoryLifecycle } from "../memory/lifecycle.js";
4
- import type { UsageLedger } from "../usage/ledger.js";
5
- import type { PendingTool, RunLogContext, RunQueue, RunState } from "./types.js";
1
+ /**
2
+ * Translates SDK session events into progress and AI-Card updates, usage accounting and memory
3
+ * activity for the current turn.
4
+ */
5
+ import type { ChannelContext } from "../../channel/channel-context.js";
6
+ import type { ChannelStore } from "../../channel/store.js";
7
+ import type { MemoryLifecycle } from "../../memory/lifecycle.js";
8
+ import type { UsageLedger } from "../../usage/ledger.js";
9
+ import type { PendingTool, RunLogContext, RunQueue, RunState } from "../types.js";
6
10
  export interface SessionEventHandlerContext {
7
11
  ctx: ChannelContext;
8
12
  logCtx: RunLogContext;
@@ -1,11 +1,13 @@
1
- import * as log from "../log.js";
2
- import { truncate } from "../shared/text-utils.js";
3
- import { isRecord } from "../shared/type-guards.js";
4
- import { addUsage } from "../shared/types.js";
5
- import { describeToolCall } from "../tools/presentation.js";
6
- import { isArgumentValidationFailure, isRecoverableRejection, toolResultDetails, } from "../tools/tool-details.js";
7
- import { extractToolResultText, formatProgressEntry } from "./progress-formatter.js";
8
- import { extractCustomCommandResultText, isAssistantEventMessage, isAutoCompactionEndEvent, isAutoCompactionStartEvent, isAutoRetryStartEvent, isMessageEndEvent, isMessageStartEvent, isSubAgentToolDetails, isTextPart, isThinkingPart, isToolExecutionEndEvent, isToolExecutionStartEvent, isToolExecutionUpdateEvent, isTurnEndEvent, } from "./type-guards.js";
1
+ import * as log from "../../log.js";
2
+ import { renderGuardBlockForUser } from "../../security/block-message.js";
3
+ import { truncate } from "../../shared/text-utils.js";
4
+ import { isRecord } from "../../shared/type-guards.js";
5
+ import { isArgumentValidationFailure, isRecoverableRejection, takeGuardBlock, toolResultDetails, } from "../../tools/contract/details.js";
6
+ import { describeToolCall } from "../../tools/contract/presentation.js";
7
+ import { addUsage } from "../../usage/totals.js";
8
+ import { extractToolResultText, formatProgressEntry } from "../turn/progress-formatter.js";
9
+ import { renderCompactionFailure } from "../turn/turn-error.js";
10
+ import { extractCustomCommandResultText, isAssistantEventMessage, isAutoCompactionEndEvent, isAutoCompactionStartEvent, isAutoRetryStartEvent, isMessageEndEvent, isMessageStartEvent, isSubAgentToolDetails, isTextPart, isThinkingPart, isToolExecutionEndEvent, isToolExecutionStartEvent, isToolExecutionUpdateEvent, isTurnEndEvent, } from "./event-guards.js";
9
11
  /**
10
12
  * A `write`/`edit` result whose resolved target landed inside the workspace `skills/` tree. The
11
13
  * `skill` tool is read-only (spec 045); authoring a workspace skill goes through the generic file
@@ -21,6 +23,9 @@ function isWorkspaceSkillWrite(toolName, details, skillsDir) {
21
23
  }
22
24
  return details.path === skillsDir || details.path.startsWith(`${skillsDir}/`);
23
25
  }
26
+ function firstLine(text) {
27
+ return text.trim().split("\n", 1)[0] ?? "";
28
+ }
24
29
  function mergeSubAgentUsage(totalUsage, details) {
25
30
  addUsage(totalUsage, details.usage);
26
31
  }
@@ -89,7 +94,7 @@ export async function handleSessionEvent(event, context) {
89
94
  context.refreshSessionResources &&
90
95
  isWorkspaceSkillWrite(event.toolName, details, context.skillsDir)) {
91
96
  queue.enqueue(() => context.refreshSessionResources?.() ?? Promise.resolve(), "refresh skills");
92
- queue.enqueue(() => ctx.respondInThread("已沉淀:workspace skill 已更新,下一轮生效。"), "skill notice");
97
+ queue.enqueue(() => ctx.respondInThread("已更新 workspace skill,下一条消息起生效。"), "skill notice");
93
98
  }
94
99
  // A recoverable rejection (bad arguments, unmet precondition the model can fix) is not a
95
100
  // fault: the model normally corrects it on the next call. It is logged so the retry is
@@ -116,8 +121,14 @@ export async function handleSessionEvent(event, context) {
116
121
  if (!treatAsError && !rejected && event.toolName !== "task_step_end") {
117
122
  runState.toolsUsed.push(event.toolName);
118
123
  }
124
+ // Claimed on every error, shown or not, so the parked refusal never outlives its call.
125
+ const blocked = event.isError ? takeGuardBlock(event.toolCallId, resultStr) : undefined;
119
126
  if (treatAsError && showProgress) {
120
- queue.enqueue(() => ctx.respond(formatProgressEntry("error", truncate(resultStr, 200)), false), "tool error");
127
+ // The tool's error text is written for the model (spec 053, D2): a guard refusal is shown
128
+ // from its structured form; anything else as its first line only — the full text is in
129
+ // the log (`agent.tool.failed`).
130
+ const line = blocked ? renderGuardBlockForUser(blocked) : truncate(firstLine(resultStr), 120);
131
+ queue.enqueue(() => ctx.respond(formatProgressEntry("error", line), false), "tool error");
121
132
  }
122
133
  return;
123
134
  }
@@ -236,7 +247,7 @@ export async function handleSessionEvent(event, context) {
236
247
  return;
237
248
  }
238
249
  if (isAutoCompactionStartEvent(event)) {
239
- const label = "Compacting context...";
250
+ const label = "正在压缩上下文…";
240
251
  log.logEvent("info", "agent.compaction.started", "Compaction started", {
241
252
  ctx: logCtx,
242
253
  fields: { reason: event.reason },
@@ -264,7 +275,7 @@ export async function handleSessionEvent(event, context) {
264
275
  fields: { error: event.errorMessage },
265
276
  });
266
277
  if (showProgress) {
267
- queue.enqueue(() => ctx.respond(formatProgressEntry("error", truncate(event.errorMessage ?? "Compaction failed", 200)), false), "compaction error");
278
+ queue.enqueue(() => ctx.respond(formatProgressEntry("error", renderCompactionFailure(event.errorMessage ?? "")), false), "compaction error");
268
279
  }
269
280
  }
270
281
  return;
@@ -275,7 +286,7 @@ export async function handleSessionEvent(event, context) {
275
286
  fields: { attempt: event.attempt, maxAttempts: event.maxAttempts, error: event.errorMessage },
276
287
  });
277
288
  if (showProgress) {
278
- queue.enqueue(() => ctx.respond(formatProgressEntry("assistant", `Retrying (${event.attempt}/${event.maxAttempts})...`), false), "retry");
289
+ queue.enqueue(() => ctx.respond(formatProgressEntry("assistant", `模型请求失败,正在重试(${event.attempt}/${event.maxAttempts})…`), false), "retry");
279
290
  }
280
291
  }
281
292
  }
@@ -0,0 +1,200 @@
1
+ /**
2
+ * The SDK session of one channel: building and rebuilding it (resource loader, tools, system prompt,
3
+ * extensions), subscribing to its events, binding it to a task's own session or back to the chat
4
+ * session, and tearing it down. Owns the session-side state — the session itself, the model
5
+ * runtime and registry, the current tools and skills, the last prompt build — and nothing about
6
+ * turns; `ChannelRunner` drives turns through it.
7
+ */
8
+ import { Agent, type AgentTool } from "@earendil-works/pi-agent-core";
9
+ import { AgentSession, type ModelRegistry, type SettingsManager as SDKSettingsManager, type SessionManager } from "@earendil-works/pi-coding-agent";
10
+ import type { MediaSender } from "../../channel/channel-context.js";
11
+ import type { PipiclawSettingsManager } from "../../config/settings.js";
12
+ import type { Executor } from "../../executor.js";
13
+ import type { FileStore } from "../../file-store.js";
14
+ import type { ChannelJobManager } from "../../jobs/manager.js";
15
+ import type { MemoryLifecycle } from "../../memory/lifecycle.js";
16
+ import type { LoadedSecurityConfig } from "../../security/config.js";
17
+ import type { ProjectScope } from "../../security/project-scope.js";
18
+ import { type PipiclawSkillsResult } from "../../skills/loader.js";
19
+ import { type SubAgentDiscoveryResult } from "../../subagents/discovery.js";
20
+ import type { SubAgentRunManager } from "../../subagents/runs.js";
21
+ import type { UsageLedger } from "../../usage/ledger.js";
22
+ import { type WorkspacePromptResources } from "../prompt/resources.js";
23
+ import type { PromptBuildResult } from "../prompt/types.js";
24
+ import type { RunState } from "../types.js";
25
+ import type { ModelSelection } from "./model-selection.js";
26
+ /** Surface settings.json load errors (once drained) as warnings; shared by construction and reload. */
27
+ export declare function reportSettingsDiagnostics(settingsManager: PipiclawSettingsManager, channelId: string, appHomeDir: string): void;
28
+ export interface SessionHostDeps {
29
+ channelId: string;
30
+ channelDir: string;
31
+ workspaceDir: string;
32
+ appHomeDir: string;
33
+ authConfigPath: string;
34
+ modelsConfigPath: string;
35
+ onSessionEvent?: (event: unknown, channelId: string) => void;
36
+ mediaSender?: MediaSender;
37
+ /**
38
+ * Frozen for the lifetime of this runner generation (spec 043, D4.2): AgentSession, the
39
+ * ResourceLoader, and every tool closure built here (session-topology rebuilds only rebind the
40
+ * session, never the scope) all read this same value.
41
+ */
42
+ projectScope: ProjectScope;
43
+ settingsManager: PipiclawSettingsManager;
44
+ /** Re-read per use, not captured once: an edited security.json takes effect without a restart. */
45
+ loadSecurityConfig: () => LoadedSecurityConfig;
46
+ executor: Executor;
47
+ fileStore: FileStore;
48
+ jobManager: ChannelJobManager;
49
+ runManager: SubAgentRunManager;
50
+ memoryLifecycle: MemoryLifecycle;
51
+ models: ModelSelection;
52
+ ledger: UsageLedger;
53
+ /** Skill summaries loaded at construction, before the session exists. */
54
+ initialSkills: PipiclawSkillsResult;
55
+ /** The current run's state (replaced by the runner at the start of every run). */
56
+ getRunState: () => RunState;
57
+ /** The agent loop started streaming: steer is now accepted into the session. */
58
+ markStreaming: () => void;
59
+ }
60
+ export declare class SessionHost {
61
+ private readonly deps;
62
+ private readonly channelId;
63
+ private readonly channelDir;
64
+ private readonly workspaceDir;
65
+ private readonly appHomeDir;
66
+ private readonly authConfigPath;
67
+ private readonly modelsConfigPath;
68
+ private readonly onSessionEvent?;
69
+ private readonly mediaSender?;
70
+ private readonly projectScope;
71
+ private readonly settingsManager;
72
+ private readonly loadSecurityConfig;
73
+ private readonly executor;
74
+ private readonly fileStore;
75
+ private readonly jobManager;
76
+ private readonly runManager;
77
+ private readonly memoryLifecycle;
78
+ private readonly models;
79
+ private readonly ledger;
80
+ session: AgentSession;
81
+ /** Settings manager owned by the currently bound AgentSession. */
82
+ sessionSettingsManager: SDKSettingsManager;
83
+ private modelRuntime;
84
+ modelRegistry: ModelRegistry;
85
+ /** Mutual exclusion between prompt submission and session-resource reloads. */
86
+ private readonly sessionResourceGate;
87
+ sessionReady: Promise<void>;
88
+ /**
89
+ * Flips true only once `initializeSession` has fully assigned `this.session`
90
+ * and loaded its resources. Synchronous dispatch-path callers (`isKnownSlashCommand`)
91
+ * must not touch `this.session` before this — the model runtime takes hundreds
92
+ * of ms to build and the first message can arrive first (spec 048 F2).
93
+ */
94
+ sessionInitialized: boolean;
95
+ private sessionRuntime;
96
+ sessionUnsubscribe?: () => void;
97
+ subAgentDiscovery: SubAgentDiscoveryResult;
98
+ currentSkills: PipiclawSkillsResult;
99
+ /** Last built system prompt (spec 025): feeds the boundary footer, /context and the debug manifest. */
100
+ lastPromptBuild?: PromptBuildResult;
101
+ /** SOUL/AGENTS as resolved for the last build, for the `/context` independent-budget lines. */
102
+ lastWorkspaceResources?: WorkspacePromptResources;
103
+ /** The exact system prompt the provider last received (our prompt + pi's tail + footer). */
104
+ lastFinalPrompt?: string;
105
+ currentTools: AgentTool<any>[];
106
+ firstTurnMemoryBootstrapPending: boolean;
107
+ /** Mirror of `tools.tasks.enabled` from the last tools-config load (see buildRuntimeTools). */
108
+ tasksEnabled: boolean;
109
+ /**
110
+ * Set while this runner is bound to a task's own session (spec 051, D3). Turns are serialized
111
+ * per channel, so one runner can carry both surfaces by swapping which session file it is
112
+ * bound to between turns — which keeps busy state, `/stop`, steering and turn recovery with
113
+ * their existing single owner instead of splitting them across two runner instances.
114
+ */
115
+ taskLoop?: {
116
+ taskId: string;
117
+ };
118
+ constructor(deps: SessionHostDeps);
119
+ private get runState();
120
+ get agent(): Agent;
121
+ get sessionManager(): SessionManager;
122
+ /** Kick off asynchronous session construction. The first message can arrive before it settles. */
123
+ start(sessionManager: SessionManager): void;
124
+ private readonly contextFaults;
125
+ markContextFault(session: AgentSession, error: unknown): Error;
126
+ assertContextHealthy(): void;
127
+ /** Run a prompt (or steer) with the resource gate and the context-fault guard. */
128
+ runPrompt<T>(fn: () => Promise<T>): Promise<T>;
129
+ /** Stop listening to the live session and dispose it (no-op error handling is the caller's). */
130
+ retireLiveSession(): void;
131
+ /**
132
+ * Release the session once idle. Guards a dispose() racing construction: initializeSession
133
+ * assigns `this.session` asynchronously, so a runner disposed the instant after creation may
134
+ * not have one yet.
135
+ */
136
+ disposeSession(): Promise<void>;
137
+ refreshSessionResources(): Promise<void>;
138
+ private initializeSession;
139
+ private reloadSessionResources;
140
+ private bindSessionExtensions;
141
+ ensureSessionReady(): Promise<void>;
142
+ private refreshSubAgentDiscovery;
143
+ private reportSettingsDiagnostics;
144
+ private reportConfigDiagnostics;
145
+ /**
146
+ * Build the Pipiclaw-owned system prompt (spec 025). This replaces pi's default
147
+ * base prompt entirely: identity, execution contract, hard invariants, the tool
148
+ * catalog and the workspace files are ours. pi still appends its tail (skills,
149
+ * date, cwd), and the boundary footer is appended after that by the prompt
150
+ * extension.
151
+ *
152
+ * Nothing channel-specific enters this text — that is what lets two channels in
153
+ * one workspace share a cached prompt prefix. Channel facts ride the turn.
154
+ */
155
+ buildSystemPrompt(): PromptBuildResult;
156
+ private createResourceLoader;
157
+ private createAgentSessionServices;
158
+ /**
159
+ * Load a freshly constructed ResourceLoader before an `AgentSession` is built on top of it.
160
+ *
161
+ * `AgentSession` reads `resourceLoader.getExtensions()` in its constructor, and a loader that
162
+ * has never been loaded answers with an *empty* set. Skipping this leaves a replacement session
163
+ * with no extensions at all — no command extension (so `/model`, `/thinking`, `/session`,
164
+ * `/compact` and `/memory` fall through to the model as plain text), no memory lifecycle, no
165
+ * prompt-boundary footer, and no prompt templates. Tolerated on failure the same way
166
+ * `reloadSessionResources` tolerates a stuck reload: a degraded session still answers chat.
167
+ */
168
+ private loadSessionResources;
169
+ /**
170
+ * Resolve the initial thinking level using the same precedence as pi's SDK:
171
+ * session history, configured default, then medium. The effective value is
172
+ * clamped to the selected model before the session starts.
173
+ */
174
+ private initializeThinkingLevel;
175
+ private createSessionRuntime;
176
+ /**
177
+ * Bind this runner to a task cycle's own session (spec 051, D3/INV-5).
178
+ *
179
+ * Task work must not accumulate in the channel's chat transcript: the one real channel on the
180
+ * author's machine had grown to 7.4 MB and been compacted six times because chat and two daily
181
+ * tasks shared it, so every compaction damaged all three at once. Swapping the bound session
182
+ * per turn gives each task its own bounded context while leaving turn state, `/stop`, and
183
+ * delivery exactly where they already are.
184
+ */
185
+ bindTaskSession(taskId: string): Promise<void>;
186
+ /** Return to the channel's chat session after a task step. Safe to call when already bound. */
187
+ bindChatSession(): Promise<void>;
188
+ /** Bootstrap presence follows canonical context, including omissions and compaction.
189
+ * Returning from a task or restarting must neither duplicate a visible bootstrap nor
190
+ * mistake an omitted failed input for one. Raw messages remain available to memory/recovery.
191
+ */
192
+ private syncMemoryBootstrapPendingFromSession;
193
+ /** Which task loop this runner is currently bound to, if any. */
194
+ getTaskLoop(): {
195
+ taskId: string;
196
+ } | undefined;
197
+ private buildRuntimeTools;
198
+ private rebuildSessionTools;
199
+ private subscribeToSessionEvents;
200
+ }