@oyasmi/pipiclaw 0.9.5-beta.2 → 0.9.5-beta.4

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 (272) hide show
  1. package/README.en.md +9 -11
  2. package/README.md +9 -11
  3. package/dist/agent/channel-runner.d.ts +12 -24
  4. package/dist/agent/channel-runner.js +74 -30
  5. package/dist/agent/maintenance-context.d.ts +2 -0
  6. package/dist/agent/maintenance-context.js +15 -0
  7. package/dist/agent/prompt/sections.js +8 -6
  8. package/dist/agent/prompt/types.d.ts +1 -1
  9. package/dist/agent/runner-factory.js +1 -1
  10. package/dist/agent/session/command-extension.js +11 -0
  11. package/dist/agent/session/compaction-summary.js +6 -2
  12. package/dist/agent/session/execution-trace.d.ts +14 -0
  13. package/dist/agent/session/execution-trace.js +57 -0
  14. package/dist/agent/session/session-events.d.ts +2 -7
  15. package/dist/agent/session/session-events.js +35 -12
  16. package/dist/agent/session/session-host.d.ts +12 -22
  17. package/dist/agent/session/session-host.js +46 -65
  18. package/dist/agent/turn/task-digest.d.ts +1 -2
  19. package/dist/agent/turn/task-digest.js +33 -33
  20. package/dist/agent/turn/turn-context.d.ts +1 -1
  21. package/dist/agent/turn/turn-context.js +1 -1
  22. package/dist/agent/turn/turn-finish.d.ts +2 -2
  23. package/dist/agent/turn/turn-finish.js +3 -2
  24. package/dist/agent/turn/turn-pipeline.d.ts +4 -2
  25. package/dist/agent/turn/turn-pipeline.js +33 -5
  26. package/dist/agent/types.d.ts +64 -14
  27. package/dist/agent/types.js +3 -0
  28. package/dist/app/home.js +3 -4
  29. package/dist/channel/channel-event.d.ts +4 -12
  30. package/dist/channel/ingress.d.ts +1 -9
  31. package/dist/channel/store.d.ts +1 -1
  32. package/dist/commands/catalog.js +25 -19
  33. package/dist/commands/router.d.ts +5 -2
  34. package/dist/commands/router.js +9 -4
  35. package/dist/config/settings.d.ts +5 -12
  36. package/dist/config/settings.js +0 -7
  37. package/dist/config/tools.d.ts +2 -2
  38. package/dist/config/tools.js +2 -2
  39. package/dist/dingtalk/bot.d.ts +2 -0
  40. package/dist/dingtalk/bot.js +4 -0
  41. package/dist/dingtalk/cards.d.ts +7 -0
  42. package/dist/dingtalk/cards.js +32 -2
  43. package/dist/dingtalk/delivery.d.ts +4 -1
  44. package/dist/dingtalk/delivery.js +104 -191
  45. package/dist/dingtalk/progress.d.ts +41 -6
  46. package/dist/dingtalk/progress.js +173 -16
  47. package/dist/file-store.d.ts +4 -0
  48. package/dist/file-store.js +6 -1
  49. package/dist/jobs/completion-observer.d.ts +20 -0
  50. package/dist/jobs/completion-observer.js +107 -0
  51. package/dist/jobs/completion-signal.d.ts +9 -0
  52. package/dist/jobs/completion-signal.js +32 -0
  53. package/dist/jobs/completion-wake.d.ts +1 -1
  54. package/dist/jobs/completion-wake.js +2 -13
  55. package/dist/jobs/manager.d.ts +11 -29
  56. package/dist/jobs/manager.js +103 -176
  57. package/dist/jobs/probe.d.ts +3 -0
  58. package/dist/jobs/probe.js +42 -0
  59. package/dist/jobs/record.d.ts +3 -6
  60. package/dist/jobs/runtime.d.ts +28 -0
  61. package/dist/jobs/runtime.js +69 -0
  62. package/dist/memory/boundary-work.d.ts +2 -0
  63. package/dist/memory/boundary-work.js +79 -37
  64. package/dist/memory/commands.js +4 -1
  65. package/dist/memory/index-budget.js +18 -15
  66. package/dist/memory/journal.js +2 -1
  67. package/dist/memory/lifecycle.d.ts +4 -8
  68. package/dist/memory/lifecycle.js +21 -51
  69. package/dist/memory/reflect-job.d.ts +0 -6
  70. package/dist/memory/reflect-job.js +13 -34
  71. package/dist/memory/reflect.d.ts +4 -0
  72. package/dist/memory/reflect.js +32 -5
  73. package/dist/memory/review-log.d.ts +13 -0
  74. package/dist/memory/review-log.js +49 -0
  75. package/dist/memory/search.js +7 -4
  76. package/dist/memory/source-window.d.ts +18 -1
  77. package/dist/memory/source-window.js +59 -9
  78. package/dist/memory/store.d.ts +2 -0
  79. package/dist/memory/store.js +45 -13
  80. package/dist/playbooks/agent-delegation.md +10 -4
  81. package/dist/playbooks/background-jobs.md +4 -4
  82. package/dist/playbooks/event-scheduling.md +2 -2
  83. package/dist/playbooks/memory-and-learning.md +3 -3
  84. package/dist/playbooks/outbound-media.md +2 -2
  85. package/dist/playbooks/runtime-orientation.md +10 -6
  86. package/dist/playbooks/task-lead.md +54 -33
  87. package/dist/runtime/bootstrap.d.ts +11 -24
  88. package/dist/runtime/bootstrap.js +92 -59
  89. package/dist/runtime/channel-queue.d.ts +2 -0
  90. package/dist/runtime/channel-queue.js +5 -1
  91. package/dist/runtime/durable-dispatch.d.ts +7 -0
  92. package/dist/runtime/durable-dispatch.js +66 -7
  93. package/dist/runtime/ingress-busy.d.ts +1 -2
  94. package/dist/runtime/ingress-busy.js +2 -35
  95. package/dist/runtime/ingress-commands.d.ts +1 -1
  96. package/dist/runtime/ingress-commands.js +28 -20
  97. package/dist/runtime/ingress-deps.d.ts +4 -7
  98. package/dist/runtime/ingress.js +23 -13
  99. package/dist/runtime/shutdown.d.ts +1 -1
  100. package/dist/runtime/shutdown.js +2 -2
  101. package/dist/runtime/task-close.d.ts +4 -0
  102. package/dist/runtime/task-close.js +102 -0
  103. package/dist/runtime/task-control.d.ts +34 -0
  104. package/dist/runtime/task-control.js +225 -0
  105. package/dist/runtime/task-input.d.ts +13 -0
  106. package/dist/runtime/task-input.js +129 -0
  107. package/dist/runtime/task-lane-types.d.ts +123 -0
  108. package/dist/runtime/task-lane-types.js +14 -0
  109. package/dist/runtime/task-lane.d.ts +99 -0
  110. package/dist/runtime/task-lane.js +703 -0
  111. package/dist/runtime/task-pending.d.ts +8 -0
  112. package/dist/runtime/task-pending.js +40 -0
  113. package/dist/runtime/task-spawn.d.ts +4 -4
  114. package/dist/runtime/task-spawn.js +4 -4
  115. package/dist/runtime/task-step.d.ts +32 -0
  116. package/dist/runtime/task-step.js +276 -0
  117. package/dist/runtime/turn-run.d.ts +4 -16
  118. package/dist/runtime/turn-run.js +17 -155
  119. package/dist/runtime/wake-coalescing.d.ts +1 -3
  120. package/dist/runtime/wake-coalescing.js +2 -4
  121. package/dist/shared/format.d.ts +0 -6
  122. package/dist/shared/format.js +0 -17
  123. package/dist/shared/host-process.d.ts +2 -0
  124. package/dist/shared/host-process.js +16 -1
  125. package/dist/shared/jsonl-appender.d.ts +5 -0
  126. package/dist/shared/jsonl-appender.js +25 -2
  127. package/dist/skills/catalog.d.ts +9 -0
  128. package/dist/skills/catalog.js +34 -0
  129. package/dist/skills/commands.d.ts +3 -12
  130. package/dist/skills/commands.js +36 -22
  131. package/dist/skills/loader.d.ts +2 -31
  132. package/dist/skills/loader.js +101 -68
  133. package/dist/skills/roots.d.ts +12 -0
  134. package/dist/skills/roots.js +18 -0
  135. package/dist/skills/types.d.ts +24 -0
  136. package/dist/skills/types.js +1 -0
  137. package/dist/subagents/completion-wake.js +0 -10
  138. package/dist/subagents/discovery.d.ts +1 -1
  139. package/dist/subagents/discovery.js +10 -16
  140. package/dist/subagents/dispatch.js +8 -16
  141. package/dist/subagents/external/cursor-cli.d.ts +2 -0
  142. package/dist/subagents/external/cursor-cli.js +256 -0
  143. package/dist/subagents/external/harness.d.ts +5 -5
  144. package/dist/subagents/external/reconciliation.d.ts +7 -0
  145. package/dist/subagents/external/reconciliation.js +105 -0
  146. package/dist/subagents/external/recovery.d.ts +20 -0
  147. package/dist/subagents/external/recovery.js +71 -0
  148. package/dist/subagents/external/registry.js +2 -0
  149. package/dist/subagents/external/role-warnings.d.ts +17 -0
  150. package/dist/subagents/external/role-warnings.js +42 -0
  151. package/dist/subagents/external/run.js +18 -22
  152. package/dist/subagents/format.d.ts +1 -1
  153. package/dist/subagents/format.js +1 -1
  154. package/dist/subagents/grace.d.ts +2 -2
  155. package/dist/subagents/grace.js +3 -3
  156. package/dist/subagents/internal/run.js +7 -5
  157. package/dist/subagents/internal/worker.js +31 -2
  158. package/dist/subagents/result.js +2 -3
  159. package/dist/subagents/run-record.d.ts +4 -7
  160. package/dist/subagents/run-record.js +2 -2
  161. package/dist/subagents/runs.d.ts +33 -46
  162. package/dist/subagents/runs.js +126 -245
  163. package/dist/subagents/task-settlement.d.ts +3 -0
  164. package/dist/subagents/task-settlement.js +20 -0
  165. package/dist/subagents/types.d.ts +1 -2
  166. package/dist/subagents/workspace-summary.js +5 -1
  167. package/dist/tasks/archive.d.ts +11 -0
  168. package/dist/tasks/archive.js +141 -0
  169. package/dist/tasks/board.d.ts +5 -12
  170. package/dist/tasks/board.js +4 -30
  171. package/dist/tasks/bound-work.d.ts +12 -6
  172. package/dist/tasks/bound-work.js +37 -24
  173. package/dist/tasks/brief.d.ts +38 -14
  174. package/dist/tasks/brief.js +128 -70
  175. package/dist/tasks/budget.d.ts +3 -3
  176. package/dist/tasks/budget.js +9 -4
  177. package/dist/tasks/commands.d.ts +14 -9
  178. package/dist/tasks/commands.js +190 -121
  179. package/dist/tasks/completion.d.ts +12 -0
  180. package/dist/tasks/completion.js +35 -0
  181. package/dist/tasks/contract.d.ts +8 -17
  182. package/dist/tasks/contract.js +41 -43
  183. package/dist/tasks/control.d.ts +138 -0
  184. package/dist/tasks/control.js +1 -0
  185. package/dist/tasks/create.d.ts +1 -1
  186. package/dist/tasks/create.js +3 -3
  187. package/dist/tasks/delivery.d.ts +24 -0
  188. package/dist/tasks/delivery.js +221 -0
  189. package/dist/tasks/file-mutation.d.ts +5 -0
  190. package/dist/tasks/file-mutation.js +38 -0
  191. package/dist/tasks/frontmatter.d.ts +43 -28
  192. package/dist/tasks/frontmatter.js +83 -40
  193. package/dist/tasks/input-receipts.d.ts +7 -0
  194. package/dist/tasks/input-receipts.js +60 -0
  195. package/dist/tasks/loop-log.d.ts +147 -28
  196. package/dist/tasks/loop-log.js +239 -28
  197. package/dist/tasks/receipts.d.ts +19 -0
  198. package/dist/tasks/receipts.js +48 -0
  199. package/dist/tasks/state.d.ts +93 -0
  200. package/dist/tasks/state.js +156 -0
  201. package/dist/tasks/store.d.ts +81 -49
  202. package/dist/tasks/store.js +244 -147
  203. package/dist/tools/bash.d.ts +3 -5
  204. package/dist/tools/bash.js +8 -22
  205. package/dist/tools/contract/details.d.ts +6 -6
  206. package/dist/tools/contract/details.js +6 -6
  207. package/dist/tools/contract/execution-trace.d.ts +4 -0
  208. package/dist/tools/contract/execution-trace.js +23 -0
  209. package/dist/tools/contract/presentation.js +6 -2
  210. package/dist/tools/edit.d.ts +1 -0
  211. package/dist/tools/edit.js +45 -42
  212. package/dist/tools/index.d.ts +8 -12
  213. package/dist/tools/index.js +16 -6
  214. package/dist/tools/memory-manage.js +8 -1
  215. package/dist/tools/registry.d.ts +7 -11
  216. package/dist/tools/registry.js +52 -25
  217. package/dist/tools/skill.d.ts +2 -2
  218. package/dist/tools/skill.js +24 -10
  219. package/dist/tools/subagent-manage.js +7 -4
  220. package/dist/tools/subagent.d.ts +0 -2
  221. package/dist/tools/subagent.js +2 -7
  222. package/dist/tools/task-manage/control-tools.d.ts +4 -0
  223. package/dist/tools/task-manage/control-tools.js +65 -0
  224. package/dist/tools/task-manage/create.js +2 -1
  225. package/dist/tools/task-manage/factory.d.ts +12 -6
  226. package/dist/tools/task-manage/factory.js +72 -57
  227. package/dist/tools/task-manage/lifecycle.d.ts +7 -12
  228. package/dist/tools/task-manage/lifecycle.js +118 -66
  229. package/dist/tools/task-manage/log-view.js +8 -5
  230. package/dist/tools/task-manage/schema.d.ts +21 -26
  231. package/dist/tools/task-manage/schema.js +29 -35
  232. package/dist/tools/task-manage/shared.d.ts +8 -39
  233. package/dist/tools/task-manage/shared.js +19 -68
  234. package/dist/tools/task-manage/step-tools.d.ts +5 -0
  235. package/dist/tools/task-manage/step-tools.js +103 -0
  236. package/dist/tools/task-manage/types.d.ts +25 -18
  237. package/dist/tools/write-content.d.ts +1 -0
  238. package/dist/tools/write-content.js +6 -1
  239. package/dist/tools/write.d.ts +1 -0
  240. package/dist/tools/write.js +1 -0
  241. package/dist/usage/ledger.d.ts +4 -4
  242. package/dist/usage/render.js +2 -2
  243. package/dist/web/search-providers.js +0 -33
  244. package/dist/webapi/request-policy.js +1 -1
  245. package/examples/sub-agents/README.md +23 -16
  246. package/examples/sub-agents/agents/claude-high.md +1 -1
  247. package/examples/sub-agents/agents/claude-main.md +1 -1
  248. package/examples/sub-agents/agents/codex-flash.md +1 -1
  249. package/examples/sub-agents/agents/codex-high.md +1 -1
  250. package/examples/sub-agents/agents/codex-main.md +4 -4
  251. package/examples/sub-agents/agents/cursor-high.md +22 -0
  252. package/examples/sub-agents/agents/cursor-main.md +22 -0
  253. package/examples/sub-agents/agents/glm-flash.md +1 -1
  254. package/examples/sub-agents/agents/glm-high.md +2 -2
  255. package/examples/sub-agents/agents/scout.md +30 -0
  256. package/package.json +6 -6
  257. package/dist/runtime/task-driver.d.ts +0 -116
  258. package/dist/runtime/task-driver.js +0 -443
  259. package/dist/runtime/task-wake.d.ts +0 -48
  260. package/dist/runtime/task-wake.js +0 -32
  261. package/dist/shared/wake-claim.d.ts +0 -23
  262. package/dist/shared/wake-claim.js +0 -26
  263. package/dist/skills/validation.d.ts +0 -8
  264. package/dist/skills/validation.js +0 -91
  265. package/dist/skills/workspace.d.ts +0 -33
  266. package/dist/skills/workspace.js +0 -116
  267. package/dist/tasks/steer.d.ts +0 -8
  268. package/dist/tasks/steer.js +0 -81
  269. package/dist/tasks/ticket.d.ts +0 -71
  270. package/dist/tasks/ticket.js +0 -138
  271. package/dist/tools/task-manage/step-end.d.ts +0 -11
  272. package/dist/tools/task-manage/step-end.js +0 -117
@@ -0,0 +1,57 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import * as log from "../../log.js";
3
+ import { isRecord } from "../../shared/type-guards.js";
4
+ /** Request, batch and runner identifiers shared by provider and tool execution logs. */
5
+ export class SessionExecutionTrace {
6
+ constructor(profile, context) {
7
+ this.profile = profile;
8
+ this.context = context;
9
+ this.generation = randomUUID();
10
+ this.request = 0;
11
+ this.startedAt = 0;
12
+ this.firstOutput = false;
13
+ }
14
+ fields() {
15
+ let seq;
16
+ if (this.profile.kind === "task") {
17
+ try {
18
+ seq = this.profile.session.seq();
19
+ }
20
+ catch {
21
+ // Tools may be built before a step begins or after it has stopped.
22
+ }
23
+ }
24
+ return {
25
+ ...this.context(),
26
+ generation: this.generation,
27
+ profile: this.profile.kind,
28
+ ...(this.profile.kind === "task" ? { taskId: this.profile.session.taskId, seq } : {}),
29
+ request: this.request,
30
+ batch: this.request,
31
+ };
32
+ }
33
+ startRequest() {
34
+ this.request++;
35
+ this.startedAt = Date.now();
36
+ this.firstOutput = false;
37
+ log.logEvent("debug", "agent.provider.started", "Provider request started", { fields: this.fields() });
38
+ }
39
+ observe(event) {
40
+ if (!isRecord(event))
41
+ return;
42
+ if (event.type === "tool_execution_start") {
43
+ log.logEvent("debug", "agent.tool.preparing", "Tool preparation started", {
44
+ fields: { ...this.fields(), toolCallId: event.toolCallId, tool: event.toolName },
45
+ });
46
+ }
47
+ if (!this.firstOutput &&
48
+ event.type === "message_update" &&
49
+ isRecord(event.assistantMessageEvent) &&
50
+ String(event.assistantMessageEvent.type).endsWith("_delta")) {
51
+ this.firstOutput = true;
52
+ log.logEvent("debug", "agent.provider.output", "Provider first output observed", {
53
+ fields: { ...this.fields(), elapsedMs: Date.now() - this.startedAt },
54
+ });
55
+ }
56
+ }
57
+ }
@@ -1,8 +1,3 @@
1
- /**
2
- * Translates SDK session events into the turn's structured output events (`TurnEvent`), usage
3
- * accounting and memory activity for the current turn. Nothing here decides how an event looks:
4
- * the channel's transport renders it.
5
- */
6
1
  import type { ChannelStore } from "../../channel/store.js";
7
2
  import type { MemoryLifecycle } from "../../memory/lifecycle.js";
8
3
  import type { UsageLedger } from "../../usage/ledger.js";
@@ -19,7 +14,7 @@ export interface SessionEventHandlerContext {
19
14
  ledger: UsageLedger;
20
15
  isModelCostKnown?: (modelReference: string) => boolean;
21
16
  refreshSessionResources?: () => Promise<void>;
22
- /** Absolute path to `<workspaceDir>/skills` — see `isWorkspaceSkillWrite`. */
23
- skillsDir?: string;
17
+ /** Both absolute skill roots; resolve them again after writes (they may have been created). */
18
+ skillsDirs?: string[];
24
19
  }
25
20
  export declare function handleSessionEvent(event: unknown, context: SessionEventHandlerContext): Promise<void>;
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Translates SDK session events into the turn's structured output events (`TurnEvent`), usage
3
+ * accounting and memory activity for the current turn. Nothing here decides how an event looks:
4
+ * the channel's transport renders it.
5
+ */
6
+ import { realpathSync } from "node:fs";
1
7
  import * as log from "../../log.js";
2
8
  import { renderGuardBlockForUser } from "../../security/block-message.js";
3
9
  import { truncate } from "../../shared/text-utils.js";
@@ -9,19 +15,31 @@ import { extractToolResultText } from "../turn/progress-formatter.js";
9
15
  import { renderCompactionFailure } from "../turn/turn-error.js";
10
16
  import { extractCustomCommandResultText, isAssistantEventMessage, isAutoCompactionEndEvent, isAutoCompactionStartEvent, isAutoRetryStartEvent, isMessageEndEvent, isMessageStartEvent, isSubAgentToolDetails, isTextPart, isThinkingPart, isToolExecutionEndEvent, isToolExecutionStartEvent, isToolExecutionUpdateEvent, isTurnEndEvent, isUserEventMessage, } from "./event-guards.js";
11
17
  /**
12
- * A `write`/`edit` result whose resolved target landed inside the workspace `skills/` tree. The
18
+ * A `write`/`edit` result whose resolved target landed inside either skill tree. The
13
19
  * `skill` tool is read-only (spec 045); authoring a workspace skill goes through the generic file
14
20
  * tools, so this is the only way the runtime learns "the skill catalog may have changed" — no
15
21
  * per-tool `requiresResourceRefresh` flag to keep in sync any more.
16
22
  */
17
- function isWorkspaceSkillWrite(toolName, details, skillsDir) {
23
+ function isSkillWrite(toolName, details, skillsDirs) {
18
24
  if (toolName !== "write" && toolName !== "edit") {
19
25
  return false;
20
26
  }
21
27
  if (!isRecord(details) || typeof details.path !== "string") {
22
28
  return false;
23
29
  }
24
- return details.path === skillsDir || details.path.startsWith(`${skillsDir}/`);
30
+ const path = details.path;
31
+ return skillsDirs.some((root) => {
32
+ if (path === root || path.startsWith(`${root}/`))
33
+ return true;
34
+ let resolvedRoot;
35
+ try {
36
+ resolvedRoot = realpathSync(root);
37
+ }
38
+ catch {
39
+ return false;
40
+ }
41
+ return path === resolvedRoot || path.startsWith(`${resolvedRoot}/`);
42
+ });
25
43
  }
26
44
  /** How much of a tool's result a `tool.end` event carries; the full text stays in the log and the session. */
27
45
  const TOOL_EVENT_OUTPUT_CHARS = 4000;
@@ -86,12 +104,13 @@ export async function handleSessionEvent(event, context) {
86
104
  subAgentDetails.usage.cost.total > 0 || (context.isModelCostKnown?.(subAgentDetails.model) ?? false);
87
105
  }
88
106
  const details = toolResultDetails(event.result);
89
- if (context.skillsDir &&
107
+ if (!event.isError &&
108
+ context.skillsDirs &&
90
109
  context.refreshSessionResources &&
91
- isWorkspaceSkillWrite(event.toolName, details, context.skillsDir)) {
110
+ isSkillWrite(event.toolName, details, context.skillsDirs)) {
92
111
  queue.enqueue(() => context.refreshSessionResources?.() ?? Promise.resolve(), "refresh skills");
93
112
  queue.enqueue(async () => {
94
- ctx.emit({ type: "commentary", text: "已更新 workspace skill,下一条消息起生效。", level: "notice" });
113
+ ctx.emit({ type: "commentary", text: "已更新技能,下一条消息起生效。", level: "notice" });
95
114
  }, "skill notice");
96
115
  }
97
116
  // A recoverable rejection (bad arguments, unmet precondition the model can fix) is not a
@@ -114,9 +133,9 @@ export async function handleSessionEvent(event, context) {
114
133
  else {
115
134
  log.logToolSuccess(logCtx, event.toolName, durationMs, resultStr);
116
135
  }
117
- // The task loop's idle-step detector reads this: a step that completed no tool other than
118
- // its own `task_step_end` did nothing (spec 051, D6).
119
- if (!treatAsError && !rejected && event.toolName !== "task_step_end") {
136
+ // The task lane's idle-step detector reads this: a step that completed no tool did nothing
137
+ // (spec 051, D6; spec 064, D16).
138
+ if (!treatAsError && !rejected) {
120
139
  runState.toolsUsed.push(event.toolName);
121
140
  }
122
141
  // Claimed on every error, shown or not, so the parked refusal never outlives its call.
@@ -171,12 +190,14 @@ export async function handleSessionEvent(event, context) {
171
190
  if (assistantMsg.usage) {
172
191
  mergeAssistantUsage(runState, assistantMsg.usage);
173
192
  runState.usageSources++;
193
+ runState.assistantUsageSources++;
174
194
  const modelReference = assistantMsg.provider && assistantMsg.model
175
195
  ? `${assistantMsg.provider}/${assistantMsg.model}`
176
196
  : assistantMsg.model;
177
- runState.costKnown &&=
178
- assistantMsg.usage.cost.total > 0 ||
179
- (modelReference ? (context.isModelCostKnown?.(modelReference) ?? false) : false);
197
+ const costKnown = assistantMsg.usage.cost.total > 0 ||
198
+ (modelReference ? (context.isModelCostKnown?.(modelReference) ?? false) : false);
199
+ runState.costKnown &&= costKnown;
200
+ runState.assistantCostKnown &&= costKnown;
180
201
  }
181
202
  const thinkingParts = [];
182
203
  const textParts = [];
@@ -193,6 +214,8 @@ export async function handleSessionEvent(event, context) {
193
214
  }
194
215
  }
195
216
  const text = textParts.join("\n");
217
+ if (text.trim())
218
+ runState.lastAssistantText = text;
196
219
  for (const thinking of thinkingParts) {
197
220
  log.logThinking(logCtx, thinking);
198
221
  ctx.emit({ type: "reasoning", text: thinking });
@@ -16,17 +16,21 @@ import type { FileStore } from "../../file-store.js";
16
16
  import type { DeskJobManager } from "../../jobs/manager.js";
17
17
  import type { MemoryLifecycle } from "../../memory/lifecycle.js";
18
18
  import type { LoadedSecurityConfig } from "../../security/config.js";
19
- import { type PipiclawSkillsResult } from "../../skills/loader.js";
19
+ import type { PipiclawSkillsResult } from "../../skills/types.js";
20
20
  import { type SubAgentDiscoveryResult } from "../../subagents/discovery.js";
21
21
  import type { SubAgentRunManager } from "../../subagents/runs.js";
22
+ import type { TaskControl } from "../../tasks/control.js";
22
23
  import type { UsageLedger } from "../../usage/ledger.js";
23
24
  import { type WorkspacePromptResources } from "../prompt/resources.js";
24
25
  import type { PromptBuildResult } from "../prompt/types.js";
25
- import type { RunState } from "../types.js";
26
+ import type { RunnerProfile, RunState } from "../types.js";
26
27
  import { SessionCompaction } from "./compaction.js";
28
+ import { SessionExecutionTrace } from "./execution-trace.js";
27
29
  import type { ModelSelection } from "./model-selection.js";
28
30
  export interface SessionHostDeps {
29
- requestScoped?: boolean;
31
+ profile: RunnerProfile;
32
+ /** Chat only: resolves the task lane's control port when tools are (re)built. */
33
+ getTaskControl?: () => TaskControl | undefined;
30
34
  conversation: DeskConversation;
31
35
  workspaceDir: string;
32
36
  appHomeDir: string;
@@ -57,6 +61,7 @@ export interface SessionHostDeps {
57
61
  }
58
62
  export declare class SessionHost {
59
63
  private readonly deps;
64
+ readonly trace: SessionExecutionTrace;
60
65
  private readonly contextInput;
61
66
  private readonly conversation;
62
67
  private readonly channelId;
@@ -111,15 +116,6 @@ export declare class SessionHost {
111
116
  readonly compaction: SessionCompaction;
112
117
  /** Mirror of `tools.tasks.enabled` from the last tools-config load (see buildRuntimeTools). */
113
118
  tasksEnabled: boolean;
114
- /**
115
- * Set while this runner is bound to a task's own session (spec 051, D3). Turns are serialized
116
- * per channel, so one runner can carry both surfaces by swapping which session file it is
117
- * bound to between turns — which keeps busy state, `/stop`, steering and turn recovery with
118
- * their existing single owner instead of splitting them across two runner instances.
119
- */
120
- taskLoop?: {
121
- taskId: string;
122
- };
123
119
  constructor(deps: SessionHostDeps);
124
120
  private get runState();
125
121
  get agent(): Agent;
@@ -169,19 +165,13 @@ export declare class SessionHost {
169
165
  */
170
166
  private initializeThinkingLevel;
171
167
  private createSessionRuntime;
172
- /** Bind a task to its own transcript, keeping scheduled work out of the chat history. */
173
- bindTaskSession(taskId: string): Promise<void>;
174
- /** Return to the channel's chat session after a task step. Safe to call when already bound. */
175
- bindChatSession(): Promise<void>;
176
168
  /** Bootstrap presence follows canonical context, including omissions and compaction.
177
- * Returning from a task or restarting must neither duplicate a visible bootstrap nor
178
- * mistake an omitted failed input for one. Raw messages remain available to memory/recovery.
169
+ * Restarting must neither duplicate a visible bootstrap nor mistake an omitted failed input for
170
+ * one. Raw messages remain available to memory/recovery.
179
171
  */
180
172
  private syncMemoryBootstrapPendingFromSession;
181
- /** Which task loop this runner is currently bound to, if any. */
182
- getTaskLoop(): {
183
- taskId: string;
184
- } | undefined;
173
+ /** Whether any user message of the session's canonical context satisfies `matches` (spec 064, D15). */
174
+ contextIncludes(matches: (userText: string) => boolean): boolean;
185
175
  private buildRuntimeTools;
186
176
  private rebuildSessionTools;
187
177
  private subscribeToSessionEvents;
@@ -8,9 +8,7 @@
8
8
  import { Agent } from "@earendil-works/pi-agent-core";
9
9
  import { streamSimple } from "@earendil-works/pi-ai/compat";
10
10
  import { AgentSession, AgentSessionRuntime, DefaultResourceLoader, } from "@earendil-works/pi-coding-agent";
11
- import { mkdir } from "fs/promises";
12
- import { dirname, join } from "path";
13
- import { commitActiveSessionRef, resolveActiveSessionFile } from "../../channel/active-session-store.js";
11
+ import { commitActiveSessionRef } from "../../channel/active-session-store.js";
14
12
  import { loadToolsConfigWithDiagnostics } from "../../config/tools.js";
15
13
  import * as log from "../../log.js";
16
14
  import { handleMemoryCommand } from "../../memory/commands.js";
@@ -21,9 +19,10 @@ import { createModelRuntime, resolveInitialModel, wrapModelRegistry } from "../.
21
19
  import { errorMessage } from "../../shared/text-utils.js";
22
20
  import { isRecord } from "../../shared/type-guards.js";
23
21
  import { withTimeout } from "../../shared/with-timeout.js";
24
- import { loadPipiclawSkills, resolvePipiclawSkills } from "../../skills/loader.js";
22
+ import { loadPipiclawSkills } from "../../skills/loader.js";
23
+ import { getSkillRoots } from "../../skills/roots.js";
25
24
  import { discoverSubAgents } from "../../subagents/discovery.js";
26
- import { TASK_SESSIONS_DIRNAME, taskSessionPath } from "../../tasks/session-path.js";
25
+ import { withExecutionTrace } from "../../tools/contract/execution-trace.js";
27
26
  import { createPipiclawTools } from "../../tools/index.js";
28
27
  import { buildPipiclawSystemPrompt } from "../prompt/builder.js";
29
28
  import { createPromptBoundaryExtension } from "../prompt/extension.js";
@@ -33,6 +32,7 @@ import { createCommandExtension } from "./command-extension.js";
33
32
  import { SessionCompaction } from "./compaction.js";
34
33
  import { RequestContextInput } from "./context-input.js";
35
34
  import { getLastAssistantUsage, isAutoCompactionEndEvent } from "./event-guards.js";
35
+ import { SessionExecutionTrace } from "./execution-trace.js";
36
36
  import { requestTools } from "./request-tools.js";
37
37
  import { asSdkSettingsManager, DEFAULT_MAIN_THINKING_LEVEL, initializeThinkingLevelCompat, setSessionBaseToolsOverride, } from "./session-adapter.js";
38
38
  import { handleSessionEvent } from "./session-events.js";
@@ -51,10 +51,6 @@ function plainTextOf(content) {
51
51
  .map((part) => (isRecord(part) && part.type === "text" && typeof part.text === "string" ? part.text : ""))
52
52
  .join("\n");
53
53
  }
54
- /** Task sessions live under `<deskDir>/tasks/.sessions/`; nothing else may be mistaken for one. */
55
- function isTaskSessionPath(sessionFile) {
56
- return sessionFile?.replace(/\\/g, "/").includes(`/${TASK_SESSIONS_DIRNAME}/`) === true;
57
- }
58
54
  export class SessionHost {
59
55
  constructor(deps) {
60
56
  this.deps = deps;
@@ -76,6 +72,12 @@ export class SessionHost {
76
72
  this.channelId = deps.conversation.channelId;
77
73
  this.deskDir = deps.conversation.deskDir;
78
74
  this.conversationDir = deps.conversation.conversationDir;
75
+ this.trace = new SessionExecutionTrace(deps.profile, () => ({
76
+ desk: this.conversation.desk,
77
+ channelId: this.channelId,
78
+ conversation: this.conversationDir,
79
+ session: this.session?.sessionManager.getSessionId(),
80
+ }));
79
81
  this.workspaceDir = deps.workspaceDir;
80
82
  this.describeConversation = deps.describeConversation;
81
83
  this.appHomeDir = deps.appHomeDir;
@@ -208,10 +210,10 @@ export class SessionHost {
208
210
  // the pointer before we rebuild and rebind to it, so a crash between "SDK created
209
211
  // session" and "we finished rebinding" leaves the old ref (and old session)
210
212
  // authoritative rather than an orphaned new file (spec 043, D1.3).
211
- // A task session is not the channel's chat session: never repoint the active-session
212
- // ref at it, or `/new` and restart recovery would adopt a task's transcript as the
213
- // conversation (spec 051, D3).
214
- if (!isTaskSessionPath(sessionManager.getSessionFile())) {
213
+ // Only a chat owns an active-session ref: a task session or a request must never
214
+ // repoint it, or `/new` and restart recovery would adopt their transcript as the
215
+ // conversation (spec 051, D3; spec 064, D13).
216
+ if (this.deps.profile.kind === "chat") {
215
217
  await commitActiveSessionRef(this.conversationDir, sessionManager);
216
218
  }
217
219
  const next = await this.createSessionRuntime(sessionManager, sessionStartEvent);
@@ -246,8 +248,11 @@ export class SessionHost {
246
248
  return;
247
249
  this.settingsManager.reload();
248
250
  reportSettingsDiagnostics(this.settingsManager, this.channelId, this.appHomeDir);
249
- const skills = loadPipiclawSkills(this.workspaceDir);
250
- this.currentSkills = skills;
251
+ this.currentSkills = loadPipiclawSkills({
252
+ workspaceDir: this.workspaceDir,
253
+ securityConfig: this.loadSecurityConfig().config,
254
+ securityContext: { agentWorkspaceDir: this.workspaceDir, cwd: this.cwd },
255
+ });
251
256
  this.subAgentDiscovery = await this.refreshSubAgentDiscovery();
252
257
  if (this.retired)
253
258
  return;
@@ -384,9 +389,7 @@ export class SessionHost {
384
389
  // Manual /model switch redefines the preferred model and clears fallback state.
385
390
  this.models.clearFallbackState();
386
391
  },
387
- refreshSessionResources: async () => {
388
- await this.refreshSessionResources();
389
- },
392
+ refreshSessionResources: () => this.refreshSessionResources(),
390
393
  runMemoryCommand: async (args) => handleMemoryCommand({
391
394
  conversation: this.conversation,
392
395
  appHomeDir: this.appHomeDir,
@@ -401,18 +404,17 @@ export class SessionHost {
401
404
  // APPEND_SYSTEM.md, not a base append. SOUL/AGENTS are rendered as sections.
402
405
  appendSystemPromptOverride: () => [],
403
406
  agentsFilesOverride: () => ({ agentsFiles: [] }),
404
- // Skills stay in the ResourceLoader: they drive `/skill:name` and pi's
405
- // `<available_skills>` index together. Only the merge policy is ours.
406
- skillsOverride: (base) => {
407
- const merged = resolvePipiclawSkills(base, this.currentSkills);
408
- for (const diagnostic of merged.diagnostics) {
409
- log.logWarn("agent.skills.diagnostic", "Skill diagnostic", {
407
+ // SDK renders/expands skills; only our two-source catalog may enter the session.
408
+ noSkills: true,
409
+ skillsOverride: () => {
410
+ for (const diagnostic of this.currentSkills.diagnostics) {
411
+ log.logWarn("agent.skills.load", "Skill loading failed", {
410
412
  channelId: this.channelId,
411
413
  reason: diagnostic.message,
412
414
  fields: { type: diagnostic.type, path: diagnostic.path },
413
415
  });
414
416
  }
415
- return merged;
417
+ return this.currentSkills;
416
418
  },
417
419
  });
418
420
  }
@@ -469,7 +471,10 @@ export class SessionHost {
469
471
  },
470
472
  convertToLlm: (messages) => this.contextInput.convert(messages),
471
473
  getApiKey: async () => getApiKeyForModel(this.modelRegistry, this.models.activeModel),
472
- streamFn: streamSimple,
474
+ streamFn: (model, context, options) => {
475
+ this.trace.startRequest();
476
+ return streamSimple(model, context, options);
477
+ },
473
478
  });
474
479
  this.initializeThinkingLevel(agent, this.models.activeModel, sessionManager);
475
480
  const resourceLoader = this.createResourceLoader();
@@ -493,41 +498,21 @@ export class SessionHost {
493
498
  this.sessionSettingsManager = sessionSettingsManager;
494
499
  return { session, resourceLoader };
495
500
  }
496
- /** Bind a task to its own transcript, keeping scheduled work out of the chat history. */
497
- async bindTaskSession(taskId) {
498
- await this.sessionReady;
499
- if (this.retired)
500
- return;
501
- const path = taskSessionPath(this.deskDir, taskId);
502
- await mkdir(dirname(path), { recursive: true });
503
- this.taskLoop = { taskId };
504
- await this.sessionRuntime.switchSession(path);
505
- this.syncMemoryBootstrapPendingFromSession();
506
- }
507
- /** Return to the channel's chat session after a task step. Safe to call when already bound. */
508
- async bindChatSession() {
509
- if (this.retired || !this.taskLoop)
510
- return;
511
- this.taskLoop = undefined;
512
- await this.sessionRuntime.switchSession(join(this.conversationDir, resolveActiveSessionFile(this.conversationDir)));
513
- this.syncMemoryBootstrapPendingFromSession();
514
- }
515
501
  /** Bootstrap presence follows canonical context, including omissions and compaction.
516
- * Returning from a task or restarting must neither duplicate a visible bootstrap nor
517
- * mistake an omitted failed input for one. Raw messages remain available to memory/recovery.
502
+ * Restarting must neither duplicate a visible bootstrap nor mistake an omitted failed input for
503
+ * one. Raw messages remain available to memory/recovery.
518
504
  */
519
505
  syncMemoryBootstrapPendingFromSession() {
520
- const injected = this.sessionManager.buildSessionContext().messages.some((value) => {
506
+ this.firstTurnMemoryBootstrapPending = !this.contextIncludes((text) => hasMemoryBootstrapBlock(text));
507
+ }
508
+ /** Whether any user message of the session's canonical context satisfies `matches` (spec 064, D15). */
509
+ contextIncludes(matches) {
510
+ return this.sessionManager.buildSessionContext().messages.some((value) => {
521
511
  const message = value;
522
512
  if (!isRecord(message))
523
513
  return false;
524
- return message.role === "user" && hasMemoryBootstrapBlock(plainTextOf(message.content));
514
+ return message.role === "user" && matches(plainTextOf(message.content));
525
515
  });
526
- this.firstTurnMemoryBootstrapPending = !injected;
527
- }
528
- /** Which task loop this runner is currently bound to, if any. */
529
- getTaskLoop() {
530
- return this.taskLoop;
531
516
  }
532
517
  buildRuntimeTools() {
533
518
  const securityLoad = this.loadSecurityConfig();
@@ -555,13 +540,10 @@ export class SessionHost {
555
540
  securityConfig: securityLoad.config,
556
541
  toolsConfig: toolsLoad.config,
557
542
  sendMedia: this.sendMedia,
558
- taskLoop: this.taskLoop,
559
- getToolsUsed: () => this.runState.toolsUsed,
560
- // Assistant usage only: an internal sub-agent's cost is also in `totalUsage`, and a bound
561
- // one is already credited to the task when it settles.
562
- getStepCost: () => ({ usd: this.runState.assistantUsage.cost.total, estimated: !this.runState.costKnown }),
543
+ ...(this.deps.profile.kind === "task" ? { taskSession: this.deps.profile.session } : {}),
544
+ ...(this.deps.profile.kind === "chat" ? { taskControl: this.deps.getTaskControl?.() } : {}),
563
545
  });
564
- const active = this.deps.requestScoped ? requestTools(tools) : tools;
546
+ const active = this.deps.profile.kind === "request" ? requestTools(tools) : tools;
565
547
  this.currentTools = active;
566
548
  // Tool schemas are billed with the system prompt and, unlike it, nothing trims them.
567
549
  // Warn where the prompt's own budget diagnostics are reported, once per tool rebuild.
@@ -572,7 +554,7 @@ export class SessionHost {
572
554
  reason: toolSchemaBudgetWarning(schemas),
573
555
  });
574
556
  }
575
- return active;
557
+ return active.map((tool) => withExecutionTrace(tool, () => this.trace.fields()));
576
558
  }
577
559
  rebuildSessionTools() {
578
560
  const tools = this.buildRuntimeTools();
@@ -594,6 +576,7 @@ export class SessionHost {
594
576
  reason: errorMessage(err),
595
577
  });
596
578
  }
579
+ this.trace.observe(event);
597
580
  if (isRecord(event) && event.type === "message_start") {
598
581
  this.deps.markStreaming();
599
582
  }
@@ -623,10 +606,8 @@ export class SessionHost {
623
606
  const model = findExactModelReferenceMatch(reference, this.modelRegistry.getAvailable()).match;
624
607
  return model ? hasKnownModelPricing(model) : false;
625
608
  },
626
- refreshSessionResources: async () => {
627
- await this.refreshSessionResources();
628
- },
629
- skillsDir: join(this.workspaceDir, "skills"),
609
+ refreshSessionResources: () => this.refreshSessionResources(),
610
+ skillsDirs: getSkillRoots(this.workspaceDir).map(({ dir }) => dir),
630
611
  }).catch((err) => {
631
612
  log.logWarn("agent.session.handler_failed", "Session event handler failed", {
632
613
  channelId: this.channelId,
@@ -18,11 +18,10 @@ export interface TaskDigestOptions {
18
18
  maxChars: number;
19
19
  /** Runtime hard cap in prompt units (spec 026 §5.3); whichever of chars/units is hit first clips. */
20
20
  maxUnits?: number;
21
- now?: number;
22
21
  }
23
22
  /**
24
23
  * Render the in-flight task agenda, or `""` when there are no live tasks to show.
25
- * Parked and paused tasks stay visible so the model can distinguish dormant work from lost work
24
+ * Waiting and paused tasks stay visible so the model can distinguish dormant work from lost work
26
25
  * and tell the user what each one is waiting for.
27
26
  */
28
27
  export declare function buildTaskDigest(options: TaskDigestOptions): Promise<string>;
@@ -1,38 +1,37 @@
1
1
  import { join } from "node:path";
2
- import { parseLocalTime } from "../../shared/local-time.js";
3
2
  import { countPromptUnits } from "../../shared/prompt-units.js";
3
+ import { truncate } from "../../shared/text-utils.js";
4
+ import { taskCostSummary } from "../../tasks/budget.js";
4
5
  import { readActiveTasks } from "../../tasks/contract.js";
5
- import { describeTicket } from "../../tasks/ticket.js";
6
6
  /** Automatic-context share for the in-flight task agenda (spec 026 §5.3). */
7
7
  export const TASK_AGENDA_MAX_UNITS = 600;
8
- /** Relative time to a ticket's due/backstop moment, for a compact agenda line. */
9
- function relativeTime(atMs, now) {
10
- if (atMs === undefined || !Number.isFinite(atMs))
11
- return undefined;
12
- const diffMs = atMs - now;
13
- if (diffMs <= 0)
14
- return "due";
15
- const minutes = Math.round(diffMs / 60000);
16
- if (minutes < 60)
17
- return `${minutes}m`;
18
- const hours = Math.round(minutes / 60);
19
- if (hours < 24)
20
- return `${hours}h`;
21
- return `${Math.round(hours / 24)}d`;
8
+ /** Model-facing state words; the question a task waits on is shown so chat can pass the user's answer along (spec 064, D31). */
9
+ function describeState(fields) {
10
+ switch (fields.state) {
11
+ case "queued":
12
+ return "queued";
13
+ case "running":
14
+ return "running a step";
15
+ case "paused":
16
+ return `paused(${fields.paused?.by ?? "user"})`;
17
+ case "waiting": {
18
+ const waiting = fields.waiting;
19
+ if (waiting?.kind === "user")
20
+ return `waiting for the user: "${truncate(waiting.question.replace(/\s+/g, " "), 100)}"`;
21
+ if (waiting?.kind === "time")
22
+ return `waiting until ${waiting.until}`;
23
+ return "waiting for delegated work";
24
+ }
25
+ }
22
26
  }
23
- function renderLine(entry, now, channelId) {
24
- const parts = [`${entry.id} — ${entry.title}`, entry.readable ? entry.fields.state : "⚠ unreadable frontmatter"];
25
- if (entry.fields.paused)
26
- parts.push(`paused(${entry.fields.paused.by})`);
27
+ function renderLine(entry, channelId) {
28
+ const parts = [
29
+ `${entry.id} — ${entry.title}`,
30
+ entry.readable ? describeState(entry.fields) : "⚠ unreadable frontmatter",
31
+ ];
27
32
  if (channelId && entry.fields.channel !== channelId) {
28
33
  parts.push(entry.fields.channel ? `reports to ${entry.fields.channel}` : "no delivery channel (suspended)");
29
34
  }
30
- const ticket = entry.fields.ticket;
31
- if (ticket) {
32
- const due = relativeTime(entry.dueMs, now);
33
- const by = relativeTime(parseLocalTime(ticket.by), now);
34
- parts.push(`${describeTicket(ticket)}${due ? ` · due ${due}` : ""}${by ? ` · 兜底 ${by}` : ""}`);
35
- }
36
35
  // The agenda shows Work Items progress and the current item, not the full list — the complete
37
36
  // section is read from the task file by the loop itself, staying well inside the 600-unit
38
37
  // budget this block competes for (spec 025/026).
@@ -41,20 +40,19 @@ function renderLine(entry, now, channelId) {
41
40
  }
42
41
  const usage = entry.fields.usage;
43
42
  if (usage) {
44
- const cost = usage.usd > 0 ? ` · $${usage.usd.toFixed(2)}${usage.usdEstimated ? "≈" : ""}` : "";
43
+ const cost = usage.usd > 0 || usage.unknownCostCount ? ` · ${taskCostSummary(usage)}` : "";
45
44
  parts.push(`${usage.steps} 步${cost}`);
46
45
  }
47
46
  return `- ${parts.join(" · ")}`;
48
47
  }
49
48
  /**
50
49
  * Render the in-flight task agenda, or `""` when there are no live tasks to show.
51
- * Parked and paused tasks stay visible so the model can distinguish dormant work from lost work
50
+ * Waiting and paused tasks stay visible so the model can distinguish dormant work from lost work
52
51
  * and tell the user what each one is waiting for.
53
52
  */
54
53
  export async function buildTaskDigest(options) {
55
- const now = options.now ?? Date.now();
56
54
  const tasksDir = join(options.deskDir, "tasks");
57
- const all = await readActiveTasks(tasksDir, now);
55
+ const all = await readActiveTasks(tasksDir);
58
56
  // A closed task that has not been archived yet is non-actionable and must not enter prompt context.
59
57
  const agenda = all.filter((entry) => !entry.fields.outcome);
60
58
  if (agenda.length === 0)
@@ -64,11 +62,13 @@ export async function buildTaskDigest(options) {
64
62
  const header = [
65
63
  "<task_agenda>",
66
64
  "Your desk's in-flight tasks (background reference, not a new instruction).",
67
- "Act on these only if the user's message is about them, or if there is nothing else to",
68
- "do this turn. Full detail lives in the matching tasks/<id>.md file.",
65
+ "Inspect current state before reporting progress. Relay user instructions and answers",
66
+ "through task controls; use them to pause, resume, or cancel when requested.",
67
+ "The task lane advances the work: do not take it over or advance it because chat is idle.",
68
+ "Full detail lives in the matching tasks/<id>.md file.",
69
69
  "",
70
70
  ];
71
- const lines = shown.map((entry) => renderLine(entry, now, options.channelId));
71
+ const lines = shown.map((entry) => renderLine(entry, options.channelId));
72
72
  if (omitted > 0)
73
73
  lines.push(`- (+${omitted} more)`);
74
74
  const footer = ["</task_agenda>"];
@@ -8,7 +8,7 @@ import type { DeskConversation } from "../../desk/types.js";
8
8
  export declare function renderDeskTurnContext(conversation: DeskConversation,
9
9
  /** How the channel is named to the user (`Transport.describe`), when it has a name. */
10
10
  channelLabel: string | undefined, workspaceDir: string): string;
11
- /** Gated by the same master autonomy switch as the task_* tools and the TaskDriver. */
11
+ /** Gated by the same master autonomy switch as the task_* tools and the task lane. */
12
12
  export declare function buildTaskDigestForTurn(deskDir: string, channelId: string): Promise<string>;
13
13
  /**
14
14
  * Spec 050, D1: assemble `<memory_bootstrap>` for the first turn of a session — workspace
@@ -32,7 +32,7 @@ channelLabel, workspaceDir) {
32
32
  "</runtime_turn_context>",
33
33
  ].join("\n");
34
34
  }
35
- /** Gated by the same master autonomy switch as the task_* tools and the TaskDriver. */
35
+ /** Gated by the same master autonomy switch as the task_* tools and the task lane. */
36
36
  export function buildTaskDigestForTurn(deskDir, channelId) {
37
37
  return buildTaskDigest({
38
38
  deskDir,
@@ -2,12 +2,12 @@ import type { DeskConversation } from "../../desk/types.js";
2
2
  import type { UsageLedger } from "../../usage/ledger.js";
3
3
  import type { ModelSelection } from "../session/model-selection.js";
4
4
  import type { SessionHost } from "../session/session-host.js";
5
- import type { RunState } from "../types.js";
5
+ import type { RunnerProfile, RunState } from "../types.js";
6
6
  import type { createRunQueue } from "./run-queue.js";
7
7
  import type { TurnOutput } from "./turn-output.js";
8
8
  import type { TurnHandle, TurnStateMachine } from "./turn-state.js";
9
9
  export interface TurnFinisherDeps {
10
- requestScoped?: boolean;
10
+ profile: RunnerProfile;
11
11
  conversation: DeskConversation;
12
12
  host: SessionHost;
13
13
  models: ModelSelection;