@oyasmi/pipiclaw 0.9.4-beta.1 → 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 (291) 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 +148 -1245
  5. package/dist/agent/maintenance-context.d.ts +1 -1
  6. package/dist/agent/maintenance-context.js +1 -1
  7. package/dist/agent/prompt/resources.d.ts +3 -0
  8. package/dist/agent/prompt/resources.js +7 -1
  9. package/dist/agent/runner-factory.d.ts +1 -43
  10. package/dist/agent/{command-extension.d.ts → session/command-extension.d.ts} +4 -0
  11. package/dist/agent/{command-extension.js → session/command-extension.js} +5 -5
  12. package/dist/agent/{type-guards.d.ts → session/event-guards.d.ts} +2 -2
  13. package/dist/agent/{type-guards.js → session/event-guards.js} +5 -1
  14. package/dist/agent/session/model-selection.d.ts +47 -0
  15. package/dist/agent/session/model-selection.js +99 -0
  16. package/dist/agent/{session-adapter.d.ts → session/session-adapter.d.ts} +21 -1
  17. package/dist/agent/{session-adapter.js → session/session-adapter.js} +83 -1
  18. package/dist/agent/{session-events.d.ts → session/session-events.d.ts} +9 -5
  19. package/dist/agent/{session-events.js → session/session-events.js} +10 -10
  20. package/dist/agent/session/session-host.d.ts +200 -0
  21. package/dist/agent/session/session-host.js +621 -0
  22. package/dist/agent/{session-resource-gate.js → session/session-resource-gate.js} +2 -2
  23. package/dist/agent/{context-budget.js → turn/context-budget.js} +5 -1
  24. package/dist/agent/{progress-formatter.d.ts → turn/progress-formatter.d.ts} +4 -1
  25. package/dist/agent/{run-queue.d.ts → turn/run-queue.d.ts} +1 -1
  26. package/dist/agent/{run-queue.js → turn/run-queue.js} +3 -3
  27. package/dist/{memory → agent/turn}/task-digest.js +4 -4
  28. package/dist/agent/turn/turn-context.d.ts +14 -0
  29. package/dist/agent/turn/turn-context.js +64 -0
  30. package/dist/agent/turn/turn-finish.d.ts +50 -0
  31. package/dist/agent/turn/turn-finish.js +188 -0
  32. package/dist/agent/turn/turn-input.d.ts +43 -0
  33. package/dist/agent/turn/turn-input.js +79 -0
  34. package/dist/agent/turn/turn-pipeline.d.ts +68 -0
  35. package/dist/agent/turn/turn-pipeline.js +257 -0
  36. package/dist/agent/{turn-prompt.d.ts → turn/turn-prompt.d.ts} +2 -2
  37. package/dist/agent/{turn-prompt.js → turn/turn-prompt.js} +6 -2
  38. package/dist/agent/{turn-recovery.js → turn/turn-recovery.js} +1 -1
  39. package/dist/agent/{turn-state.d.ts → turn/turn-state.d.ts} +1 -1
  40. package/dist/agent/types.d.ts +43 -2
  41. package/dist/agent/types.js +1 -1
  42. package/dist/{models/auth-cli.d.ts → app/auth-command.d.ts} +1 -1
  43. package/dist/{models/auth-cli.js → app/auth-command.js} +11 -8
  44. package/dist/{runtime/app-home.d.ts → app/home.d.ts} +0 -2
  45. package/dist/{runtime/app-home.js → app/home.js} +4 -75
  46. package/dist/{app-services.d.ts → app/services.d.ts} +5 -5
  47. package/dist/{app-services.js → app/services.js} +10 -10
  48. package/dist/channel/channel-context.d.ts +12 -2
  49. package/dist/channel/channel-context.js +29 -2
  50. package/dist/channel/channel-event.d.ts +10 -2
  51. package/dist/channel/channel-event.js +1 -1
  52. package/dist/{runtime/project-commands.d.ts → channel/commands.d.ts} +1 -1
  53. package/dist/{runtime/project-commands.js → channel/commands.js} +1 -1
  54. package/dist/channel/store.js +4 -0
  55. package/dist/commands/catalog.d.ts +3 -3
  56. package/dist/commands/catalog.js +3 -3
  57. package/dist/{runtime/report-commands.d.ts → commands/router.d.ts} +10 -3
  58. package/dist/{runtime/report-commands.js → commands/router.js} +5 -5
  59. package/dist/{settings.d.ts → config/settings.d.ts} +7 -8
  60. package/dist/{settings.js → config/settings.js} +7 -10
  61. package/dist/{tools/config.d.ts → config/tools.d.ts} +1 -2
  62. package/dist/{tools/config.js → config/tools.js} +5 -2
  63. package/dist/dingtalk/access-token.d.ts +12 -0
  64. package/dist/dingtalk/access-token.js +51 -0
  65. package/dist/dingtalk/api.d.ts +19 -0
  66. package/dist/dingtalk/api.js +67 -0
  67. package/dist/dingtalk/bot.d.ts +97 -0
  68. package/dist/dingtalk/bot.js +389 -0
  69. package/dist/dingtalk/cards.d.ts +56 -0
  70. package/dist/dingtalk/cards.js +318 -0
  71. package/dist/{runtime → dingtalk}/channel-queue.js +3 -0
  72. package/dist/dingtalk/config.d.ts +19 -0
  73. package/dist/dingtalk/config.js +95 -0
  74. package/dist/dingtalk/connection.d.ts +57 -0
  75. package/dist/dingtalk/connection.js +356 -0
  76. package/dist/dingtalk/conversation-meta.d.ts +16 -0
  77. package/dist/dingtalk/conversation-meta.js +77 -0
  78. package/dist/{runtime → dingtalk}/delivery.d.ts +6 -2
  79. package/dist/dingtalk/handler.d.ts +90 -0
  80. package/dist/dingtalk/handler.js +1 -0
  81. package/dist/dingtalk/inbound.d.ts +66 -0
  82. package/dist/dingtalk/inbound.js +137 -0
  83. package/dist/dingtalk/media.d.ts +66 -0
  84. package/dist/dingtalk/media.js +214 -0
  85. package/dist/events/{event-commands.js → commands.js} +6 -2
  86. package/dist/events/parse.d.ts +14 -0
  87. package/dist/events/parse.js +114 -0
  88. package/dist/events/types.d.ts +93 -0
  89. package/dist/events/types.js +1 -0
  90. package/dist/events/{event-validation.d.ts → validation.d.ts} +1 -1
  91. package/dist/events/watcher.d.ts +67 -0
  92. package/dist/events/{events.js → watcher.js} +6 -109
  93. package/dist/index.d.ts +6 -4
  94. package/dist/index.js +2 -2
  95. package/dist/jobs/launch.d.ts +42 -0
  96. package/dist/jobs/launch.js +118 -0
  97. package/dist/{agent/job-manager.d.ts → jobs/manager.d.ts} +1 -67
  98. package/dist/{agent/job-manager.js → jobs/manager.js} +3 -146
  99. package/dist/jobs/record.d.ts +55 -0
  100. package/dist/jobs/record.js +36 -0
  101. package/dist/main.js +2 -2
  102. package/dist/memory/maintenance-gates.d.ts +2 -2
  103. package/dist/memory/maintenance-tuning.d.ts +15 -0
  104. package/dist/memory/maintenance-tuning.js +3 -0
  105. package/dist/memory/reflect-job.d.ts +2 -2
  106. package/dist/memory/reflect-job.js +4 -2
  107. package/dist/memory/scheduler.d.ts +3 -3
  108. package/dist/memory/scheduler.js +2 -1
  109. package/dist/memory/sidecar-worker.js +1 -1
  110. package/dist/memory/transcript.js +1 -1
  111. package/dist/{agent/model-fallback.d.ts → models/fallback.d.ts} +6 -6
  112. package/dist/{agent/model-fallback.js → models/fallback.js} +15 -28
  113. package/dist/models/login-identity.d.ts +2 -0
  114. package/dist/models/login-identity.js +83 -0
  115. package/dist/models/provider-login.d.ts +3 -1
  116. package/dist/models/provider-login.js +8 -2
  117. package/dist/models/reference.d.ts +20 -0
  118. package/dist/models/{utils.js → reference.js} +0 -48
  119. package/dist/models/{utils.d.ts → runtime.d.ts} +1 -16
  120. package/dist/models/runtime.js +52 -0
  121. package/dist/playbooks/catalog.d.ts +6 -2
  122. package/dist/playbooks/catalog.js +9 -6
  123. package/dist/runtime/bootstrap.d.ts +7 -17
  124. package/dist/runtime/bootstrap.js +37 -755
  125. package/dist/runtime/durable-dispatch.d.ts +17 -4
  126. package/dist/runtime/durable-dispatch.js +60 -18
  127. package/dist/runtime/inbound-images.d.ts +18 -0
  128. package/dist/runtime/inbound-images.js +51 -0
  129. package/dist/runtime/shutdown.d.ts +39 -0
  130. package/dist/runtime/shutdown.js +120 -0
  131. package/dist/runtime/stop-watchdog.d.ts +16 -0
  132. package/dist/runtime/stop-watchdog.js +32 -0
  133. package/dist/runtime/task-driver.d.ts +2 -2
  134. package/dist/runtime/task-driver.js +3 -3
  135. package/dist/runtime/task-migration.js +2 -2
  136. package/dist/runtime/task-spawn.d.ts +1 -1
  137. package/dist/runtime/task-spawn.js +1 -1
  138. package/dist/runtime/turn-handler.d.ts +47 -0
  139. package/dist/runtime/turn-handler.js +318 -0
  140. package/dist/runtime/turn-run.d.ts +52 -0
  141. package/dist/runtime/turn-run.js +318 -0
  142. package/dist/security/command-guard.js +4 -0
  143. package/dist/security/network.js +4 -0
  144. package/dist/security/path-guard.js +4 -0
  145. package/dist/security/types.d.ts +1 -2
  146. package/dist/security/types.js +1 -2
  147. package/dist/shared/exact-keys.d.ts +1 -1
  148. package/dist/shared/host-process.js +1 -1
  149. package/dist/shared/wake-claim.d.ts +1 -1
  150. package/dist/{runtime/skill-commands.d.ts → skills/commands.d.ts} +2 -2
  151. package/dist/{runtime/skill-commands.js → skills/commands.js} +1 -1
  152. package/dist/{agent/workspace-resources.js → skills/loader.js} +1 -1
  153. package/dist/{tools/skill-security.js → skills/validation.js} +4 -0
  154. package/dist/skills/workspace.d.ts +33 -0
  155. package/dist/skills/workspace.js +116 -0
  156. package/dist/{runtime/subagent-commands.d.ts → subagents/commands.d.ts} +4 -3
  157. package/dist/{runtime/subagent-commands.js → subagents/commands.js} +2 -2
  158. package/dist/subagents/completion-wake.d.ts +17 -0
  159. package/dist/subagents/completion-wake.js +76 -0
  160. package/dist/subagents/detached-discovery.js +1 -1
  161. package/dist/subagents/discovery.d.ts +1 -1
  162. package/dist/subagents/discovery.js +2 -2
  163. package/dist/subagents/dispatch.d.ts +33 -0
  164. package/dist/subagents/dispatch.js +190 -0
  165. package/dist/subagents/external/dispatch.d.ts +25 -0
  166. package/dist/subagents/external/dispatch.js +90 -0
  167. package/dist/subagents/external/harness.d.ts +1 -1
  168. package/dist/subagents/external/progress-tail.d.ts +1 -1
  169. package/dist/subagents/external/run.d.ts +2 -1
  170. package/dist/subagents/external/run.js +2 -2
  171. package/dist/subagents/external/settlement.d.ts +1 -1
  172. package/dist/subagents/format.d.ts +1 -1
  173. package/dist/subagents/grace.d.ts +24 -0
  174. package/dist/subagents/grace.js +57 -0
  175. package/dist/subagents/internal/outcome.d.ts +24 -0
  176. package/dist/subagents/internal/outcome.js +149 -0
  177. package/dist/subagents/internal/provider-retry.d.ts +19 -0
  178. package/dist/subagents/internal/provider-retry.js +83 -0
  179. package/dist/subagents/internal/run.d.ts +31 -0
  180. package/dist/subagents/internal/run.js +240 -0
  181. package/dist/subagents/internal/state.d.ts +43 -0
  182. package/dist/subagents/internal/state.js +48 -0
  183. package/dist/subagents/internal/worker.d.ts +51 -0
  184. package/dist/subagents/internal/worker.js +167 -0
  185. package/dist/subagents/result.d.ts +62 -0
  186. package/dist/subagents/result.js +103 -0
  187. package/dist/subagents/run-record.d.ts +222 -0
  188. package/dist/subagents/run-record.js +101 -0
  189. package/dist/subagents/run-registry.d.ts +9 -0
  190. package/dist/subagents/run-registry.js +125 -0
  191. package/dist/subagents/runs.d.ts +7 -243
  192. package/dist/subagents/runs.js +8 -291
  193. package/dist/subagents/task-envelope.d.ts +36 -0
  194. package/dist/subagents/task-envelope.js +168 -0
  195. package/dist/subagents/types.d.ts +154 -0
  196. package/dist/subagents/types.js +1 -0
  197. package/dist/subagents/verification-outcome.d.ts +1 -1
  198. package/dist/tasks/board.d.ts +2 -2
  199. package/dist/tasks/board.js +2 -2
  200. package/dist/tasks/{work-log.d.ts → bound-work.d.ts} +1 -1
  201. package/dist/tasks/{work-log.js → bound-work.js} +1 -1
  202. package/dist/tasks/brief.js +1 -1
  203. package/dist/{runtime/task-commands.d.ts → tasks/commands.d.ts} +1 -1
  204. package/dist/{runtime/task-commands.js → tasks/commands.js} +12 -8
  205. package/dist/tasks/contract-input.d.ts +1 -1
  206. package/dist/tasks/contract-input.js +1 -1
  207. package/dist/tasks/create.js +1 -1
  208. package/dist/tasks/{log.js → loop-log.js} +1 -1
  209. package/dist/tasks/mutation-lock.js +1 -1
  210. package/dist/tasks/session-path.js +1 -1
  211. package/dist/tasks/steer.js +1 -1
  212. package/dist/tasks/store.js +2 -2
  213. package/dist/tools/bash.d.ts +1 -1
  214. package/dist/tools/{tool-details.d.ts → contract/details.d.ts} +2 -2
  215. package/dist/tools/{tool-details.js → contract/details.js} +4 -4
  216. package/dist/tools/{presentation.js → contract/presentation.js} +3 -3
  217. package/dist/tools/event-manage.d.ts +1 -1
  218. package/dist/tools/event-manage.js +4 -4
  219. package/dist/tools/index.d.ts +3 -3
  220. package/dist/tools/index.js +7 -6
  221. package/dist/tools/job.d.ts +1 -1
  222. package/dist/tools/registry.d.ts +7 -7
  223. package/dist/tools/registry.js +6 -6
  224. package/dist/tools/session-search.d.ts +1 -1
  225. package/dist/tools/skill.d.ts +2 -34
  226. package/dist/tools/skill.js +8 -116
  227. package/dist/tools/subagent-manage.js +4 -3
  228. package/dist/tools/subagent.d.ts +46 -0
  229. package/dist/tools/subagent.js +127 -0
  230. package/dist/tools/{task-manage.d.ts → task-manage/factory.d.ts} +7 -3
  231. package/dist/tools/{task-manage.js → task-manage/factory.js} +7 -7
  232. package/dist/tools/task-manage/lifecycle.js +2 -2
  233. package/dist/tools/task-manage/log-view.js +2 -2
  234. package/dist/tools/task-manage/shared.js +3 -3
  235. package/dist/tools/task-manage/step-end.js +3 -3
  236. package/dist/tools/task-manage/types.d.ts +1 -1
  237. package/dist/tools/web-fetch.d.ts +1 -1
  238. package/dist/tools/web-search.d.ts +1 -1
  239. package/dist/tui/app.d.ts +1 -1
  240. package/dist/tui/app.js +6 -6
  241. package/dist/tui/cli.d.ts +1 -1
  242. package/dist/tui/cli.js +1 -1
  243. package/dist/tui/frontend.d.ts +44 -0
  244. package/dist/tui/frontend.js +13 -0
  245. package/dist/tui/pitui-frontend.d.ts +1 -1
  246. package/dist/tui/plain-frontend.d.ts +1 -1
  247. package/dist/tui/renderer.d.ts +3 -42
  248. package/dist/tui/terminal-context.d.ts +2 -2
  249. package/dist/tui/terminal-media-sender.d.ts +1 -1
  250. package/dist/tui/turn-controller.d.ts +1 -1
  251. package/dist/usage/ledger.js +4 -0
  252. package/dist/{shared/types.d.ts → usage/totals.d.ts} +3 -0
  253. package/dist/web/client.d.ts +5 -1
  254. package/dist/web/client.js +4 -0
  255. package/dist/web/config.d.ts +1 -1
  256. package/dist/web/fetch.d.ts +1 -1
  257. package/dist/web/search-providers.d.ts +1 -1
  258. package/dist/web/search.d.ts +1 -1
  259. package/package.json +9 -7
  260. package/dist/events/events.d.ts +0 -159
  261. package/dist/runtime/dingtalk.d.ts +0 -272
  262. package/dist/runtime/dingtalk.js +0 -1470
  263. package/dist/subagents/tool.d.ts +0 -213
  264. package/dist/subagents/tool.js +0 -1282
  265. /package/dist/{runtime → agent/prompt}/workspace-templates.d.ts +0 -0
  266. /package/dist/{runtime → agent/prompt}/workspace-templates.js +0 -0
  267. /package/dist/agent/{session-resource-gate.d.ts → session/session-resource-gate.d.ts} +0 -0
  268. /package/dist/agent/{context-budget.d.ts → turn/context-budget.d.ts} +0 -0
  269. /package/dist/agent/{progress-formatter.js → turn/progress-formatter.js} +0 -0
  270. /package/dist/{memory → agent/turn}/task-digest.d.ts +0 -0
  271. /package/dist/agent/{turn-error.d.ts → turn/turn-error.d.ts} +0 -0
  272. /package/dist/agent/{turn-error.js → turn/turn-error.js} +0 -0
  273. /package/dist/agent/{turn-recovery.d.ts → turn/turn-recovery.d.ts} +0 -0
  274. /package/dist/agent/{turn-state.js → turn/turn-state.js} +0 -0
  275. /package/dist/{runtime → app}/proxy.d.ts +0 -0
  276. /package/dist/{runtime → app}/proxy.js +0 -0
  277. /package/dist/{runtime → dingtalk}/channel-queue.d.ts +0 -0
  278. /package/dist/{runtime → dingtalk}/delivery.js +0 -0
  279. /package/dist/{runtime → dingtalk}/inbound-media.d.ts +0 -0
  280. /package/dist/{runtime → dingtalk}/inbound-media.js +0 -0
  281. /package/dist/events/{event-commands.d.ts → commands.d.ts} +0 -0
  282. /package/dist/events/{event-validation.js → validation.js} +0 -0
  283. /package/dist/{agent/workspace-resources.d.ts → skills/loader.d.ts} +0 -0
  284. /package/dist/{tools/skill-security.d.ts → skills/validation.d.ts} +0 -0
  285. /package/dist/tasks/{ledger.d.ts → contract.d.ts} +0 -0
  286. /package/dist/tasks/{ledger.js → contract.js} +0 -0
  287. /package/dist/tasks/{log.d.ts → loop-log.d.ts} +0 -0
  288. /package/dist/tools/{subagent-tool-names.d.ts → contract/names.d.ts} +0 -0
  289. /package/dist/tools/{subagent-tool-names.js → contract/names.js} +0 -0
  290. /package/dist/tools/{presentation.d.ts → contract/presentation.d.ts} +0 -0
  291. /package/dist/{shared/types.js → usage/totals.js} +0 -0
@@ -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
+ }