@duetso/agent 0.2.2 → 0.2.3

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 (235) hide show
  1. package/README.md +19 -11
  2. package/dist/package.json +4 -4
  3. package/dist/src/cli/config.d.ts +10 -0
  4. package/dist/src/cli/config.d.ts.map +1 -0
  5. package/dist/src/cli/config.js +24 -0
  6. package/dist/src/cli/config.js.map +1 -0
  7. package/dist/src/cli/help.d.ts.map +1 -1
  8. package/dist/src/cli/help.js +11 -9
  9. package/dist/src/cli/help.js.map +1 -1
  10. package/dist/src/cli/inline-slash.d.ts +2 -1
  11. package/dist/src/cli/inline-slash.d.ts.map +1 -1
  12. package/dist/src/cli/inline-slash.js +14 -5
  13. package/dist/src/cli/inline-slash.js.map +1 -1
  14. package/dist/src/cli/memory-query.d.ts +1 -1
  15. package/dist/src/cli/model.d.ts +1 -1
  16. package/dist/src/cli/model.d.ts.map +1 -1
  17. package/dist/src/cli/model.js +1 -1
  18. package/dist/src/cli/model.js.map +1 -1
  19. package/dist/src/cli/route.d.ts +84 -0
  20. package/dist/src/cli/route.d.ts.map +1 -0
  21. package/dist/src/cli/route.js +261 -0
  22. package/dist/src/cli/route.js.map +1 -0
  23. package/dist/src/cli/rpc.d.ts +43 -2
  24. package/dist/src/cli/rpc.d.ts.map +1 -1
  25. package/dist/src/cli/rpc.js +176 -23
  26. package/dist/src/cli/rpc.js.map +1 -1
  27. package/dist/src/cli/run.d.ts +8 -1
  28. package/dist/src/cli/run.d.ts.map +1 -1
  29. package/dist/src/cli/run.js +24 -7
  30. package/dist/src/cli/run.js.map +1 -1
  31. package/dist/src/cli/shared.d.ts +4 -3
  32. package/dist/src/cli/shared.d.ts.map +1 -1
  33. package/dist/src/cli/shared.js +3 -4
  34. package/dist/src/cli/shared.js.map +1 -1
  35. package/dist/src/cli/shutdown.d.ts +4 -2
  36. package/dist/src/cli/shutdown.d.ts.map +1 -1
  37. package/dist/src/cli/shutdown.js +4 -2
  38. package/dist/src/cli/shutdown.js.map +1 -1
  39. package/dist/src/cli.d.ts +2 -0
  40. package/dist/src/cli.d.ts.map +1 -1
  41. package/dist/src/cli.js +12 -0
  42. package/dist/src/cli.js.map +1 -1
  43. package/dist/src/core/structured-output.d.ts +2 -0
  44. package/dist/src/core/structured-output.d.ts.map +1 -1
  45. package/dist/src/core/structured-output.js +1 -0
  46. package/dist/src/core/structured-output.js.map +1 -1
  47. package/dist/src/lib/system-reminder.d.ts +14 -0
  48. package/dist/src/lib/system-reminder.d.ts.map +1 -0
  49. package/dist/src/lib/system-reminder.js +53 -0
  50. package/dist/src/lib/system-reminder.js.map +1 -0
  51. package/dist/src/lib/walk-ancestors.d.ts +9 -0
  52. package/dist/src/lib/walk-ancestors.d.ts.map +1 -0
  53. package/dist/src/lib/walk-ancestors.js +28 -0
  54. package/dist/src/lib/walk-ancestors.js.map +1 -0
  55. package/dist/src/memory/observational-prompts.d.ts.map +1 -1
  56. package/dist/src/memory/observational-prompts.js +2 -1
  57. package/dist/src/memory/observational-prompts.js.map +1 -1
  58. package/dist/src/memory/observational.d.ts +31 -4
  59. package/dist/src/memory/observational.d.ts.map +1 -1
  60. package/dist/src/memory/observational.js +43 -4
  61. package/dist/src/memory/observational.js.map +1 -1
  62. package/dist/src/model-resolution/catalog.d.ts +2 -2
  63. package/dist/src/model-resolution/catalog.d.ts.map +1 -1
  64. package/dist/src/model-resolution/catalog.js +61 -33
  65. package/dist/src/model-resolution/catalog.js.map +1 -1
  66. package/dist/src/model-resolution/duet-gateway.d.ts +3 -3
  67. package/dist/src/model-resolution/duet-gateway.d.ts.map +1 -1
  68. package/dist/src/model-resolution/duet-gateway.js +119 -19
  69. package/dist/src/model-resolution/duet-gateway.js.map +1 -1
  70. package/dist/src/model-resolution/model-gateway.d.ts.map +1 -0
  71. package/dist/src/{cli → model-resolution}/model-gateway.js +10 -6
  72. package/dist/src/model-resolution/model-gateway.js.map +1 -0
  73. package/dist/src/model-resolution/resolver.d.ts +11 -4
  74. package/dist/src/model-resolution/resolver.d.ts.map +1 -1
  75. package/dist/src/model-resolution/resolver.js +39 -8
  76. package/dist/src/model-resolution/resolver.js.map +1 -1
  77. package/dist/src/model-routing/advisor-transcript.d.ts +36 -0
  78. package/dist/src/model-routing/advisor-transcript.d.ts.map +1 -0
  79. package/dist/src/model-routing/advisor-transcript.js +103 -0
  80. package/dist/src/model-routing/advisor-transcript.js.map +1 -0
  81. package/dist/src/model-routing/advisor.d.ts +27 -0
  82. package/dist/src/model-routing/advisor.d.ts.map +1 -0
  83. package/dist/src/model-routing/advisor.js +20 -0
  84. package/dist/src/model-routing/advisor.js.map +1 -0
  85. package/dist/src/model-routing/classifier.d.ts +57 -0
  86. package/dist/src/model-routing/classifier.d.ts.map +1 -0
  87. package/dist/src/model-routing/classifier.js +63 -0
  88. package/dist/src/model-routing/classifier.js.map +1 -0
  89. package/dist/src/model-routing/loader.d.ts +48 -0
  90. package/dist/src/model-routing/loader.d.ts.map +1 -0
  91. package/dist/src/model-routing/loader.js +79 -0
  92. package/dist/src/model-routing/loader.js.map +1 -0
  93. package/dist/src/model-routing/prompts.d.ts +22 -0
  94. package/dist/src/model-routing/prompts.d.ts.map +1 -0
  95. package/dist/src/model-routing/prompts.js +87 -0
  96. package/dist/src/model-routing/prompts.js.map +1 -0
  97. package/dist/src/model-routing/resolve.d.ts +40 -0
  98. package/dist/src/model-routing/resolve.d.ts.map +1 -0
  99. package/dist/src/model-routing/resolve.js +76 -0
  100. package/dist/src/model-routing/resolve.js.map +1 -0
  101. package/dist/src/model-routing/router.d.ts +149 -0
  102. package/dist/src/model-routing/router.d.ts.map +1 -0
  103. package/dist/src/model-routing/router.js +235 -0
  104. package/dist/src/model-routing/router.js.map +1 -0
  105. package/dist/src/model-routing/step-triggers.d.ts +27 -0
  106. package/dist/src/model-routing/step-triggers.d.ts.map +1 -0
  107. package/dist/src/model-routing/step-triggers.js +20 -0
  108. package/dist/src/model-routing/step-triggers.js.map +1 -0
  109. package/dist/src/model-routing/table.d.ts +126 -0
  110. package/dist/src/model-routing/table.d.ts.map +1 -0
  111. package/dist/src/model-routing/table.js +351 -0
  112. package/dist/src/model-routing/table.js.map +1 -0
  113. package/dist/src/session/session.d.ts +40 -23
  114. package/dist/src/session/session.d.ts.map +1 -1
  115. package/dist/src/session/session.js +173 -97
  116. package/dist/src/session/session.js.map +1 -1
  117. package/dist/src/tasks/quiescence.d.ts +13 -0
  118. package/dist/src/tasks/quiescence.d.ts.map +1 -0
  119. package/dist/src/tasks/quiescence.js +11 -0
  120. package/dist/src/tasks/quiescence.js.map +1 -0
  121. package/dist/src/tasks/task-manager.d.ts +101 -0
  122. package/dist/src/tasks/task-manager.d.ts.map +1 -0
  123. package/dist/src/tasks/task-manager.js +311 -0
  124. package/dist/src/tasks/task-manager.js.map +1 -0
  125. package/dist/src/tasks/types.d.ts +85 -0
  126. package/dist/src/tasks/types.d.ts.map +1 -0
  127. package/dist/src/tasks/types.js +2 -0
  128. package/dist/src/tasks/types.js.map +1 -0
  129. package/dist/src/tui/app.d.ts +1 -1
  130. package/dist/src/tui/app.d.ts.map +1 -1
  131. package/dist/src/tui/app.js +12 -2
  132. package/dist/src/tui/app.js.map +1 -1
  133. package/dist/src/tui/initial-prompt.d.ts.map +1 -1
  134. package/dist/src/tui/initial-prompt.js +0 -3
  135. package/dist/src/tui/initial-prompt.js.map +1 -1
  136. package/dist/src/tui/session-subscription.d.ts +3 -0
  137. package/dist/src/tui/session-subscription.d.ts.map +1 -1
  138. package/dist/src/tui/session-subscription.js +29 -5
  139. package/dist/src/tui/session-subscription.js.map +1 -1
  140. package/dist/src/tui/sidebar.d.ts +3 -0
  141. package/dist/src/tui/sidebar.d.ts.map +1 -1
  142. package/dist/src/tui/sidebar.js +19 -3
  143. package/dist/src/tui/sidebar.js.map +1 -1
  144. package/dist/src/tui/slash-commands.d.ts +12 -9
  145. package/dist/src/tui/slash-commands.d.ts.map +1 -1
  146. package/dist/src/tui/slash-commands.js +48 -10
  147. package/dist/src/tui/slash-commands.js.map +1 -1
  148. package/dist/src/tui/status-controller.d.ts +14 -9
  149. package/dist/src/tui/status-controller.d.ts.map +1 -1
  150. package/dist/src/tui/status-controller.js +26 -7
  151. package/dist/src/tui/status-controller.js.map +1 -1
  152. package/dist/src/tui/task-lane-renderer.d.ts +30 -0
  153. package/dist/src/tui/task-lane-renderer.d.ts.map +1 -0
  154. package/dist/src/tui/task-lane-renderer.js +93 -0
  155. package/dist/src/tui/task-lane-renderer.js.map +1 -0
  156. package/dist/src/tui/task-tree.d.ts +47 -0
  157. package/dist/src/tui/task-tree.d.ts.map +1 -0
  158. package/dist/src/tui/task-tree.js +190 -0
  159. package/dist/src/tui/task-tree.js.map +1 -0
  160. package/dist/src/tui/tool-formatters.js +3 -0
  161. package/dist/src/tui/tool-formatters.js.map +1 -1
  162. package/dist/src/turn-runner/agent-events.d.ts.map +1 -1
  163. package/dist/src/turn-runner/agent-events.js +1 -0
  164. package/dist/src/turn-runner/agent-events.js.map +1 -1
  165. package/dist/src/turn-runner/duration.d.ts +2 -2
  166. package/dist/src/turn-runner/duration.js +3 -3
  167. package/dist/src/turn-runner/duration.js.map +1 -1
  168. package/dist/src/turn-runner/prompts.d.ts +5 -1
  169. package/dist/src/turn-runner/prompts.d.ts.map +1 -1
  170. package/dist/src/turn-runner/prompts.js +30 -6
  171. package/dist/src/turn-runner/prompts.js.map +1 -1
  172. package/dist/src/turn-runner/runtime-clock.d.ts +20 -0
  173. package/dist/src/turn-runner/runtime-clock.d.ts.map +1 -0
  174. package/dist/src/turn-runner/runtime-clock.js +38 -0
  175. package/dist/src/turn-runner/runtime-clock.js.map +1 -0
  176. package/dist/src/turn-runner/shell-state-handle.d.ts +0 -3
  177. package/dist/src/turn-runner/shell-state-handle.d.ts.map +1 -1
  178. package/dist/src/turn-runner/shell-state-handle.js +5 -55
  179. package/dist/src/turn-runner/shell-state-handle.js.map +1 -1
  180. package/dist/src/turn-runner/skill-context.d.ts +6 -7
  181. package/dist/src/turn-runner/skill-context.d.ts.map +1 -1
  182. package/dist/src/turn-runner/skill-context.js +10 -10
  183. package/dist/src/turn-runner/skill-context.js.map +1 -1
  184. package/dist/src/turn-runner/skills.d.ts.map +1 -1
  185. package/dist/src/turn-runner/skills.js +2 -22
  186. package/dist/src/turn-runner/skills.js.map +1 -1
  187. package/dist/src/turn-runner/state-compaction.d.ts +7 -5
  188. package/dist/src/turn-runner/state-compaction.d.ts.map +1 -1
  189. package/dist/src/turn-runner/state-compaction.js +69 -10
  190. package/dist/src/turn-runner/state-compaction.js.map +1 -1
  191. package/dist/src/turn-runner/state-machine-decisions.d.ts +135 -0
  192. package/dist/src/turn-runner/state-machine-decisions.d.ts.map +1 -0
  193. package/dist/src/turn-runner/state-machine-decisions.js +443 -0
  194. package/dist/src/turn-runner/state-machine-decisions.js.map +1 -0
  195. package/dist/src/turn-runner/state-machine-session.d.ts +13 -28
  196. package/dist/src/turn-runner/state-machine-session.d.ts.map +1 -1
  197. package/dist/src/turn-runner/state-machine-session.js +18 -55
  198. package/dist/src/turn-runner/state-machine-session.js.map +1 -1
  199. package/dist/src/turn-runner/subagent.d.ts +156 -0
  200. package/dist/src/turn-runner/subagent.d.ts.map +1 -0
  201. package/dist/src/turn-runner/subagent.js +164 -0
  202. package/dist/src/turn-runner/subagent.js.map +1 -0
  203. package/dist/src/turn-runner/task-tools.d.ts +76 -0
  204. package/dist/src/turn-runner/task-tools.d.ts.map +1 -0
  205. package/dist/src/turn-runner/task-tools.js +370 -0
  206. package/dist/src/turn-runner/task-tools.js.map +1 -0
  207. package/dist/src/turn-runner/tools.d.ts +65 -17
  208. package/dist/src/turn-runner/tools.d.ts.map +1 -1
  209. package/dist/src/turn-runner/tools.js +173 -59
  210. package/dist/src/turn-runner/tools.js.map +1 -1
  211. package/dist/src/turn-runner/turn-runner.d.ts +198 -134
  212. package/dist/src/turn-runner/turn-runner.d.ts.map +1 -1
  213. package/dist/src/turn-runner/turn-runner.js +1302 -713
  214. package/dist/src/turn-runner/turn-runner.js.map +1 -1
  215. package/dist/src/turn-runner/usage-accounting.d.ts +4 -0
  216. package/dist/src/turn-runner/usage-accounting.d.ts.map +1 -1
  217. package/dist/src/turn-runner/usage-accounting.js +19 -0
  218. package/dist/src/turn-runner/usage-accounting.js.map +1 -1
  219. package/dist/src/types/config.d.ts +9 -1
  220. package/dist/src/types/config.d.ts.map +1 -1
  221. package/dist/src/types/config.js +2 -1
  222. package/dist/src/types/config.js.map +1 -1
  223. package/dist/src/types/protocol.d.ts +110 -30
  224. package/dist/src/types/protocol.d.ts.map +1 -1
  225. package/dist/src/types/state-machine.d.ts +10 -12
  226. package/dist/src/types/state-machine.d.ts.map +1 -1
  227. package/dist/src/types/state-machine.js.map +1 -1
  228. package/package.json +4 -4
  229. package/dist/src/cli/model-gateway.d.ts.map +0 -1
  230. package/dist/src/cli/model-gateway.js.map +0 -1
  231. package/dist/src/turn-runner/state-machine-controller.d.ts +0 -140
  232. package/dist/src/turn-runner/state-machine-controller.d.ts.map +0 -1
  233. package/dist/src/turn-runner/state-machine-controller.js +0 -501
  234. package/dist/src/turn-runner/state-machine-controller.js.map +0 -1
  235. /package/dist/src/{cli → model-resolution}/model-gateway.d.ts +0 -0
@@ -0,0 +1,370 @@
1
+ import { Type } from "typebox";
2
+ import { systemReminder } from "../lib/system-reminder.js";
3
+ export const spawnAgentSchema = Type.Object({
4
+ prompt: Type.String({ description: "The task for the child agent." }),
5
+ fork_context: Type.Optional(Type.Boolean({ description: "Seed the child with a copy of the caller's transcript." })),
6
+ cwd: Type.Optional(Type.String({ description: "Working directory for the child." })),
7
+ allowed_skills: Type.Optional(Type.Array(Type.String(), { description: "Skill names the child may use." })),
8
+ run_in_background: Type.Optional(Type.Boolean({ description: "Start the child in the background and return immediately." })),
9
+ timeout: Type.Optional(Type.Number({
10
+ minimum: 0,
11
+ description: "Foreground wait budget in seconds. Expiry moves the child to the background; it does not stop it.",
12
+ })),
13
+ });
14
+ /** Create the restricted public spawn_agent surface on the shared task rails. */
15
+ export function createSpawnAgentTool(deps) {
16
+ return {
17
+ name: "spawn_agent",
18
+ label: "Spawn agent",
19
+ description: "Run a subagent as a tool call and return its final report. Children may spawn tasks and agents within the depth limit.",
20
+ parameters: spawnAgentSchema,
21
+ async execute(_toolCallId, params) {
22
+ const ownerScopeId = deps.ownerScopeId();
23
+ const spec = {
24
+ prompt: params.prompt,
25
+ ...(params.fork_context ? { forkContext: true } : {}),
26
+ ...(params.cwd ? { cwd: params.cwd } : {}),
27
+ ...(params.allowed_skills ? { allowedSkills: params.allowed_skills } : {}),
28
+ };
29
+ let handle;
30
+ handle = deps.taskManager.start({
31
+ kind: "subagent",
32
+ name: "spawn_agent",
33
+ label: params.prompt,
34
+ ownerScopeId,
35
+ execute: async ({ signal, onOutput }) => {
36
+ const childScopeId = `task:${handle.id}`;
37
+ try {
38
+ deps.taskManager.openScope(childScopeId, ownerScopeId);
39
+ }
40
+ catch (error) {
41
+ if (error instanceof RangeError) {
42
+ throw new Error(`spawn_agent depth limit: ${error.message}`);
43
+ }
44
+ throw error;
45
+ }
46
+ let run;
47
+ const interrupt = () => run?.interrupt(String(signal.reason ?? "Interrupted"));
48
+ signal.addEventListener("abort", interrupt, { once: true });
49
+ try {
50
+ run = await deps.createRun({ spec, taskId: handle.id, ownerScopeId, childScopeId });
51
+ if (signal.aborted)
52
+ run.interrupt(String(signal.reason ?? "Interrupted"));
53
+ const result = await run.prompt();
54
+ const report = subagentResultText(result);
55
+ if (report)
56
+ onOutput(report);
57
+ if (result.type === "failed")
58
+ throw new Error(result.error);
59
+ if (result.type === "interrupted") {
60
+ throw new Error(run.interruptedReason() ?? "Subagent interrupted.");
61
+ }
62
+ return textResult(report || "Subagent completed without a report.");
63
+ }
64
+ finally {
65
+ signal.removeEventListener("abort", interrupt);
66
+ await deps.taskManager.closeScope(childScopeId, String(signal.reason ?? "Subagent scope closed."));
67
+ await deps.dropScratch?.(handle.id);
68
+ }
69
+ },
70
+ });
71
+ deps.onTaskStarted?.(handle.id, !params.run_in_background);
72
+ if (params.run_in_background) {
73
+ const snapshot = deps.taskManager.output(handle.id);
74
+ if (!snapshot)
75
+ throw new Error(`Task ${handle.id} disappeared after start.`);
76
+ return textResult(startedInBackgroundNotice(snapshot));
77
+ }
78
+ const budgetMs = params.timeout === undefined ? deps.defaultWaitBudgetMs : params.timeout * 1_000;
79
+ const foreground = await deps.taskManager.raceForeground(handle, budgetMs);
80
+ if (foreground.kind === "settled") {
81
+ deps.onForegroundResult?.(handle.id, false);
82
+ if (foreground.settlement.status === "completed") {
83
+ return foreground.settlement.result;
84
+ }
85
+ if (foreground.settlement.status === "stopped") {
86
+ throw new Error(`Task ${handle.id} stopped: ${foreground.settlement.reason}`);
87
+ }
88
+ if (foreground.settlement.status === "failed")
89
+ throw foreground.settlement.error;
90
+ throw new Error(`Task ${handle.id} was lost.`);
91
+ }
92
+ deps.onForegroundResult?.(handle.id, true);
93
+ return textResult(stillRunningNotice(foreground.task, deps.clock.now()));
94
+ },
95
+ };
96
+ }
97
+ function subagentResultText(result) {
98
+ if (result.type === "complete")
99
+ return result.result ?? "";
100
+ if (result.type === "failed")
101
+ return result.error;
102
+ if (result.type === "interrupted")
103
+ return "Subagent interrupted.";
104
+ return "Spawned agent attempted to ask the user a question.";
105
+ }
106
+ const MAX_INLINE_SETTLEMENT_CHARS = 2_000;
107
+ const taskOutputSchema = Type.Object({
108
+ id: Type.Optional(Type.String({ description: "Task id, such as t3. Omit to list all tasks." })),
109
+ wait: Type.Optional(Type.Number({
110
+ minimum: 0,
111
+ description: "Seconds to wait for this task to settle before returning its current output.",
112
+ })),
113
+ });
114
+ const taskStopSchema = Type.Object({
115
+ id: Type.String({ description: "Task id to stop, such as t3." }),
116
+ });
117
+ /**
118
+ * Turn a normal pi tool into task-backed work. The wrapped tool always executes under the
119
+ * task's AbortSignal; a foreground budget expiry changes only its delivery mode, never its
120
+ * lifetime.
121
+ */
122
+ export function wrapBackgroundable(tool, deps) {
123
+ const baseProperties = "properties" in tool.parameters
124
+ ? tool.parameters.properties
125
+ : {};
126
+ const parameters = Type.Object({
127
+ ...baseProperties,
128
+ timeout: Type.Optional(Type.Number({
129
+ minimum: 0,
130
+ description: "Foreground wait budget in seconds. Expiry moves the command to the background; it does not kill it.",
131
+ })),
132
+ run_in_background: Type.Optional(Type.Boolean({
133
+ description: "Start the command in the background and return immediately.",
134
+ })),
135
+ });
136
+ return {
137
+ ...tool,
138
+ // Foreground task calls carry ordering semantics: each result is delivered
139
+ // before the next command starts. Callers that want concurrency use the
140
+ // explicit run_in_background path, which returns immediately.
141
+ executionMode: "sequential",
142
+ parameters,
143
+ description: `${tool.description} The timeout is a foreground wait budget, not a kill timeout. Use run_in_background to return immediately.`,
144
+ async execute(toolCallId, rawParams, outerSignal, onUpdate) {
145
+ if (outerSignal?.aborted)
146
+ throw new Error("Tool call aborted before task start.");
147
+ const params = rawParams;
148
+ const { timeout, run_in_background: runInBackground, ...innerParams } = params;
149
+ let lastOutput = "";
150
+ const handle = deps.taskManager.start({
151
+ kind: "tool",
152
+ name: tool.name,
153
+ label: deps.label(params),
154
+ ownerScopeId: deps.ownerScopeId(),
155
+ execute: async ({ signal, onOutput }) => {
156
+ const unregisterReaper = deps.taskManager.registerReaper(async (reason) => {
157
+ if (!signal.aborted) {
158
+ // stop() owns the AbortController and resolves only after the child process group
159
+ // has unwound, so reapAll is a real shutdown barrier rather than a fire-and-forget.
160
+ await deps.taskManager.stop(handle.id, reason);
161
+ }
162
+ });
163
+ try {
164
+ const result = await tool.execute(toolCallId, innerParams, signal, (partial) => {
165
+ const text = resultText(partial);
166
+ const delta = text.startsWith(lastOutput) ? text.slice(lastOutput.length) : text;
167
+ lastOutput = text;
168
+ if (delta)
169
+ onOutput(delta);
170
+ onUpdate?.(partial);
171
+ });
172
+ const text = resultText(result);
173
+ const delta = text.startsWith(lastOutput) ? text.slice(lastOutput.length) : text;
174
+ if (delta)
175
+ onOutput(delta);
176
+ return result;
177
+ }
178
+ finally {
179
+ unregisterReaper();
180
+ }
181
+ },
182
+ });
183
+ deps.onTaskStarted?.(handle.id, !runInBackground);
184
+ if (runInBackground) {
185
+ const snapshot = deps.taskManager.output(handle.id);
186
+ if (!snapshot)
187
+ throw new Error(`Task ${handle.id} disappeared after start.`);
188
+ return textResult(startedInBackgroundNotice(snapshot));
189
+ }
190
+ const budgetMs = timeout === undefined ? deps.defaultWaitBudgetMs : timeout * 1_000;
191
+ const foreground = await deps.taskManager.raceForeground(handle, budgetMs);
192
+ if (foreground.kind === "settled") {
193
+ deps.onForegroundResult?.(handle.id, false);
194
+ if (foreground.settlement.status === "completed") {
195
+ return foreground.settlement.result;
196
+ }
197
+ if (foreground.settlement.status === "stopped") {
198
+ throw new Error(`Task ${handle.id} stopped: ${foreground.settlement.reason}`);
199
+ }
200
+ if (foreground.settlement.status === "failed") {
201
+ throw foreground.settlement.error;
202
+ }
203
+ throw new Error(`Task ${handle.id} was lost.`);
204
+ }
205
+ deps.onForegroundResult?.(handle.id, true);
206
+ return textResult(stillRunningNotice(foreground.task, deps.clock.now()));
207
+ },
208
+ };
209
+ }
210
+ /** B1: the only source for foreground wait-budget conversion wording. */
211
+ export function stillRunningNotice(snapshot, now = Date.now()) {
212
+ const recent = recentOutput(snapshot);
213
+ return systemReminder([
214
+ `Task ${snapshot.descriptor.id} is still running (${taskDescription(snapshot)}, ${formatElapsed(snapshot, now)} elapsed).`,
215
+ "Recent output:",
216
+ recent ? indent(recent) : " (no output yet)",
217
+ `It continues in the background. Check it with task_output("${snapshot.descriptor.id}", {wait: 60}),`,
218
+ `stop it with task_stop("${snapshot.descriptor.id}"), or keep working and you'll be nudged when it settles.`,
219
+ ].join("\n"));
220
+ }
221
+ /** B2: the only source for explicit background-start wording. */
222
+ export function startedInBackgroundNotice(snapshot) {
223
+ return systemReminder([
224
+ `Started background task ${snapshot.descriptor.id} (${taskDescription(snapshot)}).`,
225
+ `You'll be nudged when it settles; task_output("${snapshot.descriptor.id}") shows live progress.`,
226
+ ].join("\n"));
227
+ }
228
+ /** B3: the only source for batched settlement nudges and idle re-prompts. */
229
+ export function settlementNotice(settlements) {
230
+ const lines = settlements.map((snapshot) => {
231
+ const settlement = snapshot.settlement;
232
+ if (!settlement)
233
+ return `- ${snapshot.descriptor.id} (${taskDescription(snapshot)}) is running.`;
234
+ const status = settlement.status === "failed" ? "failed" : settlement.status;
235
+ const inline = settlementInline(snapshot);
236
+ return `- ${snapshot.descriptor.id} (${taskDescription(snapshot)}) ${status}${inline ? ` — ${inline}` : ""}. Full output: task_output("${snapshot.descriptor.id}")`;
237
+ });
238
+ return systemReminder([
239
+ "<system-reminder>",
240
+ `${settlements.length} ${settlements.length === 1 ? "task" : "tasks"} settled while you were working:`,
241
+ ...lines,
242
+ "Act on these or continue; your turn stays open while tasks run.",
243
+ "</system-reminder>",
244
+ ].join("\n"));
245
+ }
246
+ /** One-shot parent context for executors that could not survive process recovery. */
247
+ export function lostTaskRecoveryReminder(tasks) {
248
+ const lines = tasks.flatMap((snapshot) => {
249
+ const descriptor = snapshot.descriptor;
250
+ const output = snapshot.output.length > 0 ? snapshot.output.slice(-3) : ["<no buffered output>"];
251
+ return [
252
+ `- ${descriptor.id} (${taskDescription(snapshot)}) was interrupted when the previous process exited. It was not restarted.`,
253
+ ...output.map((chunk) => ` Last output: ${chunk}`),
254
+ ];
255
+ });
256
+ return systemReminder([
257
+ "<system-reminder>",
258
+ `${tasks.length} ${tasks.length === 1 ? "task was" : "tasks were"} lost during session recovery:`,
259
+ ...lines,
260
+ "Treat these executors as stopped. Inspect or restart the work explicitly if it is still needed.",
261
+ "</system-reminder>",
262
+ ].join("\n"));
263
+ }
264
+ /** Create the sequential admin lane. These tools only inspect existing tasks. */
265
+ export function createTaskAdminTools(input) {
266
+ return [createTaskOutputTool(input), createTaskStopTool(input.taskManager)];
267
+ }
268
+ function createTaskOutputTool(input) {
269
+ return {
270
+ name: "task_output",
271
+ label: "Task output",
272
+ executionMode: "sequential",
273
+ description: "List all tasks, or inspect one task's retained output. Optionally wait for that task to settle.",
274
+ parameters: taskOutputSchema,
275
+ async execute(...args) {
276
+ const params = args[1];
277
+ if (!params.id) {
278
+ const tasks = input.taskManager.list();
279
+ const text = tasks.length
280
+ ? tasks
281
+ .map((task) => `${task.id}\t${task.kind}\t${task.label}\t${task.status}\t${formatDuration(Math.max(0, input.clock.now() - task.startedAt))}`)
282
+ .join("\n")
283
+ : "No tasks.";
284
+ return textResult(text);
285
+ }
286
+ const id = params.id;
287
+ if (params.wait !== undefined) {
288
+ await input.taskManager.waitForSettlement(id, params.wait * 1_000);
289
+ }
290
+ const snapshot = input.taskManager.output(id);
291
+ if (!snapshot)
292
+ throw new Error(`Unknown task ${params.id}`);
293
+ return textResult(formatTaskOutput(snapshot));
294
+ },
295
+ };
296
+ }
297
+ function createTaskStopTool(taskManager) {
298
+ return {
299
+ name: "task_stop",
300
+ label: "Stop task",
301
+ executionMode: "sequential",
302
+ description: "Stop one running or scheduled task and return its final retained output.",
303
+ parameters: taskStopSchema,
304
+ async execute(...args) {
305
+ const params = args[1];
306
+ const snapshot = await taskManager.stop(params.id, "Stopped by task_stop.");
307
+ if (!snapshot)
308
+ throw new Error(`Unknown task ${params.id}`);
309
+ return textResult(formatTaskOutput(snapshot));
310
+ },
311
+ };
312
+ }
313
+ function formatTaskOutput(snapshot) {
314
+ const output = snapshot.output.join("");
315
+ const settlement = snapshot.settlement
316
+ ? `\nStatus: ${snapshot.settlement.status}`
317
+ : `\nStatus: ${snapshot.descriptor.status}`;
318
+ return `${output || "(no output)"}${settlement}`;
319
+ }
320
+ function resultText(result) {
321
+ return result.content
322
+ .filter((item) => item.type === "text")
323
+ .map((item) => item.text)
324
+ .join("\n");
325
+ }
326
+ function textResult(text) {
327
+ return { content: [{ type: "text", text }], details: undefined };
328
+ }
329
+ function taskDescription(snapshot) {
330
+ return `${snapshot.descriptor.name}: \`${snapshot.descriptor.label}\``;
331
+ }
332
+ function formatElapsed(snapshot, now) {
333
+ const end = snapshot.settlement?.settledAt ?? now;
334
+ return formatDuration(Math.max(0, end - snapshot.descriptor.startedAt));
335
+ }
336
+ function formatDuration(ms) {
337
+ const seconds = Math.floor(ms / 1_000);
338
+ const minutes = Math.floor(seconds / 60);
339
+ return minutes > 0 ? `${minutes}m${seconds % 60}s` : `${seconds}s`;
340
+ }
341
+ function recentOutput(snapshot) {
342
+ return snapshot.output.join("").trim().slice(-1_500);
343
+ }
344
+ function settlementInline(snapshot) {
345
+ if (!snapshot.settlement)
346
+ return "";
347
+ if (snapshot.settlement.status === "completed") {
348
+ const result = snapshot.settlement.result;
349
+ const text = isAgentToolResult(result) ? resultText(result) : String(result ?? "completed");
350
+ return text.trim().slice(0, MAX_INLINE_SETTLEMENT_CHARS);
351
+ }
352
+ if (snapshot.settlement.status === "failed")
353
+ return String(snapshot.settlement.error);
354
+ if (snapshot.settlement.status === "stopped")
355
+ return snapshot.settlement.reason;
356
+ return "task was lost";
357
+ }
358
+ function isAgentToolResult(value) {
359
+ return Boolean(value &&
360
+ typeof value === "object" &&
361
+ "content" in value &&
362
+ Array.isArray(value.content));
363
+ }
364
+ function indent(text) {
365
+ return text
366
+ .split("\n")
367
+ .map((line) => ` ${line}`)
368
+ .join("\n");
369
+ }
370
+ //# sourceMappingURL=task-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-tools.js","sourceRoot":"","sources":["../../../src/turn-runner/task-tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAA6B,MAAM,SAAS,CAAC;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAK3D,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC;IAC1C,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;IACrE,YAAY,EAAE,IAAI,CAAC,QAAQ,CACzB,IAAI,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,wDAAwD,EAAE,CAAC,CACxF;IACD,GAAG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+ import type { ThinkingLevel } from "@earendil-works/pi-ai";
2
3
  import { type BashOperations, type Skill } from "@earendil-works/pi-coding-agent";
3
4
  import { Type, type Static } from "typebox";
4
5
  import type { TurnMode, TurnQuestion, TurnTodo } from "../types/protocol.js";
5
- import type { StateMachineSession, StateMachineSessionEvent, StateMachineAgentState, StateMachineDefinition, StateMachinePollState, StateMachineProgress, StateMachineScriptState, StateMachineState, StateMachineTimerState, StateMachineTerminalResult } from "../types/state-machine.js";
6
+ import type { StateMachineSession, StateMachineSessionEvent, StateMachineAgentState, StateMachineDefinition, StateMachinePollState, StateMachineParkState, StateMachineProgress, StateMachineScriptState, StateMachineTimerState, StateMachineTerminalResult } from "../types/state-machine.js";
6
7
  import type { EmbedFn } from "../memory/embedding.js";
8
+ import { type AdvisorResult, type CallAdvisorInput } from "../model-routing/advisor.js";
9
+ import type { LanguageModelUsage } from "ai";
10
+ import type { AdvisorGate } from "../model-routing/router.js";
7
11
  import type { MemorySession } from "../memory/session.js";
8
- import type { ActiveStateOutput } from "./state-machine-controller.js";
9
- /**
10
- * Default cap (in seconds) applied to bash tool invocations that omit an
11
- * explicit timeout. Upstream's bash tool ships with no default timeout, so
12
- * stray commands like `find /` could otherwise run for many minutes before
13
- * anything intervenes. The model can still pass a larger `timeout` argument
14
- * for legitimate long-running work.
15
- */
16
- export declare const DEFAULT_BASH_TIMEOUT_SECONDS = 600;
12
+ export type ActiveStateOutput = {
13
+ state?: string;
14
+ kind: "agent";
15
+ output?: {
16
+ assistantText?: string;
17
+ };
18
+ } | {
19
+ state: string;
20
+ kind: "script" | "poll";
21
+ output?: ShellPartialOutput;
22
+ };
23
+ import { type RuntimeClock } from "./runtime-clock.js";
24
+ import type { ShellPartialOutput } from "./shell-state-handle.js";
17
25
  /**
18
- * Wrap a `BashOperations` implementation so any `exec` call without an
19
- * explicit `timeout` uses `defaultTimeoutSeconds`. Calls that already specify
20
- * a timeout (the model passed one) are forwarded unchanged.
26
+ * Remove pi's kill-timeout input at the execution boundary. The public bash
27
+ * `timeout` field is consumed by the task wrapper as a foreground wait budget;
28
+ * only explicit task_stop, interrupt, or scope closure may abort the command.
21
29
  */
22
- export declare function withDefaultBashTimeout(base: BashOperations, defaultTimeoutSeconds?: number): BashOperations;
30
+ export declare function withoutBashKillTimeout(base: BashOperations): BashOperations;
23
31
  declare const askUserQuestionSchema: Type.TObject<{
24
32
  questions: Type.TArray<Type.TObject<{
25
33
  question: Type.TString;
@@ -48,6 +56,7 @@ export type StateMachineAgentStateOverride = Partial<Pick<StateMachineAgentState
48
56
  export type StateMachineScriptStateOverride = Partial<Pick<StateMachineScriptState, "command" | "cwd" | "timeoutMs" | "successCodes" | "inputSchema">>;
49
57
  export type StateMachinePollStateOverride = Partial<Pick<StateMachinePollState, "intervalMs" | "timeoutMs" | "command" | "cwd" | "successCodes" | "inputSchema">>;
50
58
  export type StateMachineTimerStateOverride = Partial<Pick<StateMachineTimerState, "wakeAt" | "wakeAfterMs" | "inputSchema">>;
59
+ export type StateMachineParkStateOverride = Partial<Pick<StateMachineParkState, "inputSchema">>;
51
60
  export type StateMachineStateOverride = {
52
61
  kind: "agent";
53
62
  state: StateMachineAgentStateOverride;
@@ -60,6 +69,9 @@ export type StateMachineStateOverride = {
60
69
  } | {
61
70
  kind: "timer";
62
71
  state: StateMachineTimerStateOverride;
72
+ } | {
73
+ kind: "park";
74
+ state: StateMachineParkStateOverride;
63
75
  };
64
76
  declare const createDefinitionSchema: Type.TObject<{
65
77
  definition: Type.TObject<{
@@ -101,6 +113,11 @@ declare const createDefinitionSchema: Type.TObject<{
101
113
  name: Type.TString;
102
114
  when: Type.TOptional<Type.TString>;
103
115
  inputSchema: Type.TOptional<Type.TRecord<"^.*$", Type.TAny>>;
116
+ }>, Type.TObject<{
117
+ kind: Type.TLiteral<"park">;
118
+ name: Type.TString;
119
+ when: Type.TOptional<Type.TString>;
120
+ inputSchema: Type.TOptional<Type.TRecord<"^.*$", Type.TAny>>;
104
121
  }>, Type.TObject<{
105
122
  kind: Type.TLiteral<"terminal">;
106
123
  status: Type.TUnion<[Type.TLiteral<"completed">, Type.TLiteral<"failed">, Type.TLiteral<"cancelled">]>;
@@ -163,6 +180,9 @@ interface TurnRunnerToolsInput {
163
180
  getActiveStateOutput?: () => ActiveStateOutput | undefined;
164
181
  skills?: readonly Skill[];
165
182
  recallStorage?: RecallMemoryToolStorage;
183
+ advisorStorage?: AskAdvisorToolStorage;
184
+ clock?: RuntimeClock;
185
+ minimumScheduledDelayMs?: number;
166
186
  }
167
187
  export interface RecallMemoryToolStorage {
168
188
  /**
@@ -190,9 +210,36 @@ export interface RecallMemoryToolStorage {
190
210
  */
191
211
  expansionModel?: string;
192
212
  }
193
- export declare function createDefaultTurnRunnerTools(cwd: string, todoStorage: TodoWriteToolStorage, recallStorage?: RecallMemoryToolStorage): AgentTool[];
213
+ /** Lazy runtime inputs and router actions used by the parent-only advisor tool. */
214
+ export interface AskAdvisorToolStorage {
215
+ /** Current parent transcript, read only when the tool executes. */
216
+ getMessages: () => readonly AgentMessage[];
217
+ /** Fully resolved executor prompt quoted into transcript content. */
218
+ getSystemPrompt: () => string;
219
+ /** Live local-session observation contents; empty when memory is disabled. */
220
+ getObservations: () => Promise<readonly string[]>;
221
+ /** Uniform transcript budget selected by the routed tier. */
222
+ budgetTokens: number;
223
+ /** Gateway-native advisor id, or a callback that resolves it lazily at tool execution. */
224
+ modelName: string | (() => string);
225
+ /** Reasoning effort selected by the routed tier. */
226
+ thinkingLevel: ThinkingLevel;
227
+ /** Atomically checks the floor and reserves the router's advisor slot when allowed. */
228
+ advisorGate: () => AdvisorGate;
229
+ /** Releases the reserved slot; false never stamps the floor or requests classification. */
230
+ noteAdvisorConsult: (success?: boolean) => void;
231
+ /** Attributes a completed advisor request to the running turn before the tool returns. */
232
+ recordUsage: (usage: LanguageModelUsage) => void;
233
+ /** Reports accounting failures without discarding advice the provider already returned. */
234
+ onUsageError?: (error: unknown) => void;
235
+ /** Network seam for deterministic tool tests; production uses callAdvisor. */
236
+ callAdvisor?: (input: CallAdvisorInput) => Promise<AdvisorResult>;
237
+ }
238
+ export declare function createDefaultTurnRunnerTools(cwd: string, todoStorage: TodoWriteToolStorage, recallStorage?: RecallMemoryToolStorage, advisorStorage?: AskAdvisorToolStorage): AgentTool[];
194
239
  export declare function createTurnRunnerTools(input: TurnRunnerToolsInput): AgentTool[];
195
- export declare function applyStateOverride(state: StateMachineState, override: StateMachineStateOverride | undefined): StateMachineState;
240
+ declare const askAdvisorSchema: Type.TObject<{}>;
241
+ /** Build the no-parameter, non-terminating advisor consultation tool. */
242
+ export declare function createAskAdvisorTool(storage: AskAdvisorToolStorage): AgentTool<typeof askAdvisorSchema>;
196
243
  export declare function createTodoWriteTool(storage: TodoWriteToolStorage): AgentTool<typeof todoWriteSchema>;
197
244
  /**
198
245
  * Build the prompt body delivered to the parent on its acknowledgment
@@ -218,5 +265,6 @@ export declare function formatStateMachineTerminalAcknowledgmentPrompt(input: {
218
265
  }): string;
219
266
  export declare function formatCarriedTodosReminder(todos: TurnTodo[] | undefined): string | undefined;
220
267
  export declare function resolveStateCwd(cwd: string | undefined, baseCwd: string): string;
268
+ export declare const MINIMUM_STATE_MACHINE_DELAY_MS: number;
221
269
  export {};
222
270
  //# sourceMappingURL=tools.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/turn-runner/tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EACL,KAAK,cAAc,EAGnB,KAAK,KAAK,EACX,MAAM,iCAAiC,CAAC;AAKzC,OAAO,EAAE,IAAI,EAAE,KAAK,MAAM,EAAE,MAAM,SAAS,CAAC;AAI5C,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EACxB,sBAAsB,EACtB,sBAA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