@mastra/core 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/CHANGELOG.md +386 -0
  2. package/dist/agent/index.cjs +13 -13
  3. package/dist/agent/index.js +2 -2
  4. package/dist/agent/message-list/adapters/AIV5Adapter.d.ts.map +1 -1
  5. package/dist/agent/message-list/conversion/output-converter.d.ts.map +1 -1
  6. package/dist/agent/message-list/index.cjs +18 -18
  7. package/dist/agent/message-list/index.js +1 -1
  8. package/dist/agent/workflows/prepare-stream/index.d.ts +7 -7
  9. package/dist/agent/workflows/prepare-stream/prepare-memory-step.d.ts +7 -7
  10. package/dist/agent/workflows/prepare-stream/schema.d.ts +11 -11
  11. package/dist/{chunk-CQ4Z6ZAV.cjs → chunk-3U3XFMGJ.cjs} +7 -7
  12. package/dist/{chunk-CQ4Z6ZAV.cjs.map → chunk-3U3XFMGJ.cjs.map} +1 -1
  13. package/dist/{chunk-D57U4II4.js → chunk-4WG5K4CK.js} +9 -8
  14. package/dist/chunk-4WG5K4CK.js.map +1 -0
  15. package/dist/{chunk-UZFGMMKU.js → chunk-5K45E5VE.js} +37 -3
  16. package/dist/chunk-5K45E5VE.js.map +1 -0
  17. package/dist/{chunk-OQ5LZ6OV.cjs → chunk-5VQPSWPG.cjs} +149 -61
  18. package/dist/chunk-5VQPSWPG.cjs.map +1 -0
  19. package/dist/{chunk-AIRMLZ43.js → chunk-7EXW4AAG.js} +4 -4
  20. package/dist/{chunk-AIRMLZ43.js.map → chunk-7EXW4AAG.js.map} +1 -1
  21. package/dist/{chunk-S4VVZI4E.cjs → chunk-AYHSPIT6.cjs} +326 -5
  22. package/dist/chunk-AYHSPIT6.cjs.map +1 -0
  23. package/dist/{chunk-YW54RH77.cjs → chunk-DB7U2C5B.cjs} +12 -5
  24. package/dist/chunk-DB7U2C5B.cjs.map +1 -0
  25. package/dist/{chunk-DST75PA4.js → chunk-DGS2KGDI.js} +4 -4
  26. package/dist/{chunk-DST75PA4.js.map → chunk-DGS2KGDI.js.map} +1 -1
  27. package/dist/{chunk-YIN5F7VO.js → chunk-EEU5NHHU.js} +4254 -3958
  28. package/dist/chunk-EEU5NHHU.js.map +1 -0
  29. package/dist/{chunk-A6EWCOGA.cjs → chunk-H5S4PS44.cjs} +197 -27
  30. package/dist/chunk-H5S4PS44.cjs.map +1 -0
  31. package/dist/{chunk-3YMDR4OL.cjs → chunk-HTAUP7ER.cjs} +4 -4
  32. package/dist/{chunk-3YMDR4OL.cjs.map → chunk-HTAUP7ER.cjs.map} +1 -1
  33. package/dist/{chunk-OHLVZVIK.js → chunk-IC5OUWKJ.js} +12 -5
  34. package/dist/chunk-IC5OUWKJ.js.map +1 -0
  35. package/dist/{chunk-MZIMV2BB.js → chunk-IHDE4CJV.js} +244 -213
  36. package/dist/chunk-IHDE4CJV.js.map +1 -0
  37. package/dist/{chunk-3KJW4EMO.js → chunk-IHEYJDJP.js} +3 -3
  38. package/dist/{chunk-3KJW4EMO.js.map → chunk-IHEYJDJP.js.map} +1 -1
  39. package/dist/{chunk-CXVMDV2B.js → chunk-IOY7Y5GV.js} +197 -27
  40. package/dist/chunk-IOY7Y5GV.js.map +1 -0
  41. package/dist/{chunk-MDC6VYA6.cjs → chunk-KAVAKMOQ.cjs} +4 -8
  42. package/dist/chunk-KAVAKMOQ.cjs.map +1 -0
  43. package/dist/{chunk-7WC7ALDW.cjs → chunk-LNKS4TJ6.cjs} +6 -6
  44. package/dist/{chunk-7WC7ALDW.cjs.map → chunk-LNKS4TJ6.cjs.map} +1 -1
  45. package/dist/{chunk-R3364RAL.js → chunk-MWGGSA5Q.js} +4 -4
  46. package/dist/{chunk-R3364RAL.js.map → chunk-MWGGSA5Q.js.map} +1 -1
  47. package/dist/{chunk-QSN5KQXZ.cjs → chunk-O7PZ4VOO.cjs} +11 -11
  48. package/dist/{chunk-QSN5KQXZ.cjs.map → chunk-O7PZ4VOO.cjs.map} +1 -1
  49. package/dist/chunk-OQDRPRKM.cjs +46 -0
  50. package/dist/chunk-OQDRPRKM.cjs.map +1 -0
  51. package/dist/{chunk-YV2YGQRY.js → chunk-RHKNKJNM.js} +101 -13
  52. package/dist/chunk-RHKNKJNM.js.map +1 -0
  53. package/dist/{chunk-TPDMP7OD.js → chunk-RHYZ6CQN.js} +4 -8
  54. package/dist/chunk-RHYZ6CQN.js.map +1 -0
  55. package/dist/{chunk-G5JVVFIG.cjs → chunk-RZNHRIM7.cjs} +9 -9
  56. package/dist/{chunk-G5JVVFIG.cjs.map → chunk-RZNHRIM7.cjs.map} +1 -1
  57. package/dist/{chunk-JZ6TH4HQ.cjs → chunk-TL2TTA4X.cjs} +4260 -3962
  58. package/dist/chunk-TL2TTA4X.cjs.map +1 -0
  59. package/dist/{chunk-KNXZ7KYL.cjs → chunk-TVPANHLE.cjs} +40 -2
  60. package/dist/chunk-TVPANHLE.cjs.map +1 -0
  61. package/dist/{chunk-7S6LA43E.cjs → chunk-VJWRJWSC.cjs} +278 -248
  62. package/dist/chunk-VJWRJWSC.cjs.map +1 -0
  63. package/dist/chunk-X2HAI3OX.js +39 -0
  64. package/dist/chunk-X2HAI3OX.js.map +1 -0
  65. package/dist/{chunk-FZ5DRHKE.js → chunk-XB3DA67Q.js} +325 -5
  66. package/dist/chunk-XB3DA67Q.js.map +1 -0
  67. package/dist/{chunk-NUV3BLRH.cjs → chunk-XWZAKKFT.cjs} +17 -16
  68. package/dist/chunk-XWZAKKFT.cjs.map +1 -0
  69. package/dist/{chunk-4GB2GS4S.js → chunk-YM6245EM.js} +5 -5
  70. package/dist/{chunk-4GB2GS4S.js.map → chunk-YM6245EM.js.map} +1 -1
  71. package/dist/datasets/index.cjs +17 -17
  72. package/dist/datasets/index.js +2 -2
  73. package/dist/docs/SKILL.md +2 -1
  74. package/dist/docs/assets/SOURCE_MAP.json +417 -391
  75. package/dist/docs/references/docs-memory-observational-memory.md +2 -0
  76. package/dist/docs/references/docs-streaming-tool-streaming.md +6 -0
  77. package/dist/docs/references/docs-workspace-filesystem.md +21 -1
  78. package/dist/docs/references/reference-harness-harness-class.md +645 -0
  79. package/dist/docs/references/reference-memory-memory-class.md +1 -1
  80. package/dist/docs/references/reference-memory-observational-memory.md +1 -0
  81. package/dist/docs/references/reference-workspace-local-filesystem.md +25 -0
  82. package/dist/docs/references/reference-workspace-workspace-class.md +1 -24
  83. package/dist/docs/references/reference.md +1 -0
  84. package/dist/editor/types.d.ts +20 -1
  85. package/dist/editor/types.d.ts.map +1 -1
  86. package/dist/evals/base.d.ts.map +1 -1
  87. package/dist/evals/index.cjs +20 -20
  88. package/dist/evals/index.js +3 -3
  89. package/dist/evals/scoreTraces/index.cjs +5 -5
  90. package/dist/evals/scoreTraces/index.js +2 -2
  91. package/dist/events/index.cjs +6 -2
  92. package/dist/events/index.d.ts +1 -0
  93. package/dist/events/index.d.ts.map +1 -1
  94. package/dist/events/index.js +1 -1
  95. package/dist/harness/harness.d.ts +105 -35
  96. package/dist/harness/harness.d.ts.map +1 -1
  97. package/dist/harness/index.cjs +472 -64
  98. package/dist/harness/index.cjs.map +1 -1
  99. package/dist/harness/index.d.ts +2 -1
  100. package/dist/harness/index.d.ts.map +1 -1
  101. package/dist/harness/index.js +468 -62
  102. package/dist/harness/index.js.map +1 -1
  103. package/dist/harness/tools.d.ts +38 -0
  104. package/dist/harness/tools.d.ts.map +1 -1
  105. package/dist/harness/types.d.ts +64 -9
  106. package/dist/harness/types.d.ts.map +1 -1
  107. package/dist/index.cjs +2 -2
  108. package/dist/index.js +1 -1
  109. package/dist/llm/index.cjs +12 -12
  110. package/dist/llm/index.js +3 -3
  111. package/dist/llm/model/gateways/models-dev.d.ts.map +1 -1
  112. package/dist/loop/index.cjs +12 -12
  113. package/dist/loop/index.js +1 -1
  114. package/dist/loop/network/index.d.ts +6 -6
  115. package/dist/loop/network/index.d.ts.map +1 -1
  116. package/dist/loop/test-utils/options.d.ts.map +1 -1
  117. package/dist/loop/workflows/agentic-execution/index.d.ts +21 -21
  118. package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +14 -14
  119. package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts.map +1 -1
  120. package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts +7 -7
  121. package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts.map +1 -1
  122. package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts.map +1 -1
  123. package/dist/loop/workflows/agentic-loop/index.d.ts +21 -21
  124. package/dist/loop/workflows/agentic-loop/index.d.ts.map +1 -1
  125. package/dist/loop/workflows/schema.d.ts +30 -30
  126. package/dist/loop/workflows/stream.d.ts +0 -13
  127. package/dist/loop/workflows/stream.d.ts.map +1 -1
  128. package/dist/mastra/index.cjs +2 -2
  129. package/dist/mastra/index.js +1 -1
  130. package/dist/memory/index.cjs +14 -14
  131. package/dist/memory/index.js +1 -1
  132. package/dist/models-dev-6P4CM74H.js +3 -0
  133. package/dist/{models-dev-MDI5E2YA.js.map → models-dev-6P4CM74H.js.map} +1 -1
  134. package/dist/models-dev-CLLSNT5L.cjs +12 -0
  135. package/dist/{models-dev-BW2GAM3K.cjs.map → models-dev-CLLSNT5L.cjs.map} +1 -1
  136. package/dist/processor-provider/index.cjs +256 -0
  137. package/dist/processor-provider/index.cjs.map +1 -0
  138. package/dist/processor-provider/index.d.ts +5 -0
  139. package/dist/processor-provider/index.d.ts.map +1 -0
  140. package/dist/processor-provider/index.js +243 -0
  141. package/dist/processor-provider/index.js.map +1 -0
  142. package/dist/processor-provider/phase-filtered-processor.d.ts +22 -0
  143. package/dist/processor-provider/phase-filtered-processor.d.ts.map +1 -0
  144. package/dist/processor-provider/providers/index.d.ts +12 -0
  145. package/dist/processor-provider/providers/index.d.ts.map +1 -0
  146. package/dist/processor-provider/types.d.ts +65 -0
  147. package/dist/processor-provider/types.d.ts.map +1 -0
  148. package/dist/processors/index.cjs +41 -41
  149. package/dist/processors/index.js +1 -1
  150. package/dist/processors/memory/message-history.d.ts.map +1 -1
  151. package/dist/processors/step-schema.d.ts +14 -14
  152. package/dist/provider-registry-HMTFO5FV.cjs +40 -0
  153. package/dist/{provider-registry-4PH2JPIA.cjs.map → provider-registry-HMTFO5FV.cjs.map} +1 -1
  154. package/dist/provider-registry-TTZ2WN2P.js +3 -0
  155. package/dist/{provider-registry-VEJ3PN4S.js.map → provider-registry-TTZ2WN2P.js.map} +1 -1
  156. package/dist/relevance/index.cjs +3 -3
  157. package/dist/relevance/index.js +1 -1
  158. package/dist/storage/base.d.ts +2 -1
  159. package/dist/storage/base.d.ts.map +1 -1
  160. package/dist/storage/constants.cjs +68 -52
  161. package/dist/storage/constants.d.ts +6 -2
  162. package/dist/storage/constants.d.ts.map +1 -1
  163. package/dist/storage/constants.js +1 -1
  164. package/dist/storage/domains/index.d.ts +1 -0
  165. package/dist/storage/domains/index.d.ts.map +1 -1
  166. package/dist/storage/domains/inmemory-db.d.ts +4 -1
  167. package/dist/storage/domains/inmemory-db.d.ts.map +1 -1
  168. package/dist/storage/domains/mcp-servers/base.d.ts +47 -0
  169. package/dist/storage/domains/mcp-servers/base.d.ts.map +1 -0
  170. package/dist/storage/domains/mcp-servers/index.d.ts +3 -0
  171. package/dist/storage/domains/mcp-servers/index.d.ts.map +1 -0
  172. package/dist/storage/domains/mcp-servers/inmemory.d.ts +31 -0
  173. package/dist/storage/domains/mcp-servers/inmemory.d.ts.map +1 -0
  174. package/dist/storage/domains/memory/inmemory.d.ts.map +1 -1
  175. package/dist/storage/domains/observability/types.d.ts +44 -44
  176. package/dist/storage/domains/operations/inmemory.d.ts.map +1 -1
  177. package/dist/storage/index.cjs +178 -154
  178. package/dist/storage/index.js +2 -2
  179. package/dist/storage/mock.d.ts.map +1 -1
  180. package/dist/storage/types.d.ts +220 -6
  181. package/dist/storage/types.d.ts.map +1 -1
  182. package/dist/stream/MastraAgentNetworkStream.d.ts +1 -1
  183. package/dist/stream/MastraWorkflowStream.d.ts +1 -1
  184. package/dist/stream/aisdk/v5/input.d.ts.map +1 -1
  185. package/dist/stream/base/input.d.ts +19 -0
  186. package/dist/stream/base/input.d.ts.map +1 -1
  187. package/dist/stream/base/output.d.ts.map +1 -1
  188. package/dist/stream/index.cjs +11 -11
  189. package/dist/stream/index.js +2 -2
  190. package/dist/tool-loop-agent/index.cjs +4 -4
  191. package/dist/tool-loop-agent/index.js +1 -1
  192. package/dist/vector/index.cjs +9 -9
  193. package/dist/vector/index.js +2 -2
  194. package/dist/workflows/evented/execution-engine.d.ts.map +1 -1
  195. package/dist/workflows/evented/index.cjs +10 -10
  196. package/dist/workflows/evented/index.js +1 -1
  197. package/dist/workflows/evented/step-executor.d.ts.map +1 -1
  198. package/dist/workflows/evented/workflow-event-processor/index.d.ts.map +1 -1
  199. package/dist/workflows/index.cjs +25 -25
  200. package/dist/workflows/index.js +1 -1
  201. package/dist/workflows/step.d.ts.map +1 -1
  202. package/dist/workspace/constants/index.d.ts +1 -0
  203. package/dist/workspace/constants/index.d.ts.map +1 -1
  204. package/dist/workspace/index.cjs +64 -64
  205. package/dist/workspace/index.js +1 -1
  206. package/dist/workspace/tools/ast-edit.d.ts +97 -0
  207. package/dist/workspace/tools/ast-edit.d.ts.map +1 -0
  208. package/dist/workspace/tools/search.d.ts +1 -1
  209. package/dist/workspace/tools/tools.d.ts.map +1 -1
  210. package/package.json +12 -11
  211. package/processor-provider.d.ts +1 -0
  212. package/dist/chunk-4D4KB75Y.cjs +0 -9
  213. package/dist/chunk-4D4KB75Y.cjs.map +0 -1
  214. package/dist/chunk-7S6LA43E.cjs.map +0 -1
  215. package/dist/chunk-A6EWCOGA.cjs.map +0 -1
  216. package/dist/chunk-BVUMKER5.js +0 -7
  217. package/dist/chunk-BVUMKER5.js.map +0 -1
  218. package/dist/chunk-CXVMDV2B.js.map +0 -1
  219. package/dist/chunk-D57U4II4.js.map +0 -1
  220. package/dist/chunk-FZ5DRHKE.js.map +0 -1
  221. package/dist/chunk-JZ6TH4HQ.cjs.map +0 -1
  222. package/dist/chunk-KNXZ7KYL.cjs.map +0 -1
  223. package/dist/chunk-MDC6VYA6.cjs.map +0 -1
  224. package/dist/chunk-MZIMV2BB.js.map +0 -1
  225. package/dist/chunk-NUV3BLRH.cjs.map +0 -1
  226. package/dist/chunk-OHLVZVIK.js.map +0 -1
  227. package/dist/chunk-OQ5LZ6OV.cjs.map +0 -1
  228. package/dist/chunk-S4VVZI4E.cjs.map +0 -1
  229. package/dist/chunk-TPDMP7OD.js.map +0 -1
  230. package/dist/chunk-UZFGMMKU.js.map +0 -1
  231. package/dist/chunk-YIN5F7VO.js.map +0 -1
  232. package/dist/chunk-YV2YGQRY.js.map +0 -1
  233. package/dist/chunk-YW54RH77.cjs.map +0 -1
  234. package/dist/models-dev-BW2GAM3K.cjs +0 -12
  235. package/dist/models-dev-MDI5E2YA.js +0 -3
  236. package/dist/provider-registry-4PH2JPIA.cjs +0 -40
  237. package/dist/provider-registry-VEJ3PN4S.js +0 -3
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunk7S6LA43E_cjs = require('../chunk-7S6LA43E.cjs');
4
- var chunkS4VVZI4E_cjs = require('../chunk-S4VVZI4E.cjs');
3
+ var chunkVJWRJWSC_cjs = require('../chunk-VJWRJWSC.cjs');
4
+ var chunkAYHSPIT6_cjs = require('../chunk-AYHSPIT6.cjs');
5
5
  var chunkEAZ6YDCQ_cjs = require('../chunk-EAZ6YDCQ.cjs');
6
6
  var chunkVDKWYUGC_cjs = require('../chunk-VDKWYUGC.cjs');
7
7
  var zod = require('zod');
@@ -38,9 +38,12 @@ var askUserTool = chunkEAZ6YDCQ_cjs.createTool({
38
38
  }
39
39
  const onAbort = () => reject(new DOMException("Aborted", "AbortError"));
40
40
  signal?.addEventListener("abort", onAbort, { once: true });
41
- harnessCtx.registerQuestion(questionId, (answer2) => {
42
- signal?.removeEventListener("abort", onAbort);
43
- resolve(answer2);
41
+ harnessCtx.registerQuestion({
42
+ questionId,
43
+ resolve: (answer2) => {
44
+ signal?.removeEventListener("abort", onAbort);
45
+ resolve(answer2);
46
+ }
44
47
  });
45
48
  harnessCtx.emitEvent({
46
49
  type: "ask_question",
@@ -85,9 +88,12 @@ ${plan}`,
85
88
  }
86
89
  const onAbort = () => reject(new DOMException("Aborted", "AbortError"));
87
90
  signal?.addEventListener("abort", onAbort, { once: true });
88
- harnessCtx.registerPlanApproval(planId, (res) => {
89
- signal?.removeEventListener("abort", onAbort);
90
- resolve(res);
91
+ harnessCtx.registerPlanApproval({
92
+ planId,
93
+ resolve: (res) => {
94
+ signal?.removeEventListener("abort", onAbort);
95
+ resolve(res);
96
+ }
91
97
  });
92
98
  harnessCtx.emitEvent({
93
99
  type: "plan_approval_required",
@@ -117,6 +123,135 @@ Please revise the plan based on the feedback and submit again with submit_plan.`
117
123
  }
118
124
  }
119
125
  });
126
+ var taskItemSchema = zod.z.object({
127
+ content: zod.z.string().min(1).describe("Task description in imperative form (e.g., 'Fix authentication bug')"),
128
+ status: zod.z.enum(["pending", "in_progress", "completed"]).describe("Current task status"),
129
+ activeForm: zod.z.string().min(1).describe("Present continuous form shown during execution (e.g., 'Fixing authentication bug')")
130
+ });
131
+ var taskWriteTool = chunkEAZ6YDCQ_cjs.createTool({
132
+ id: "task_write",
133
+ description: `Create and manage a structured task list for your current coding session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user.
134
+
135
+ Usage:
136
+ - Pass the FULL task list each time (replaces previous list)
137
+ - Each task has: content (imperative), status (pending|in_progress|completed), activeForm (present continuous)
138
+ - Mark tasks in_progress BEFORE starting work (only ONE at a time)
139
+ - Mark tasks completed IMMEDIATELY after finishing
140
+ - Use this for multi-step tasks requiring 3+ distinct actions
141
+
142
+ States:
143
+ - pending: Not yet started
144
+ - in_progress: Currently working on (limit to ONE)
145
+ - completed: Finished successfully`,
146
+ inputSchema: zod.z.object({
147
+ tasks: zod.z.array(taskItemSchema).describe("The complete updated task list")
148
+ }),
149
+ execute: async ({ tasks }, context) => {
150
+ try {
151
+ const harnessCtx = context?.requestContext?.get("harness");
152
+ if (harnessCtx) {
153
+ await harnessCtx.setState({ tasks });
154
+ harnessCtx.emitEvent?.({
155
+ type: "task_updated",
156
+ tasks
157
+ });
158
+ }
159
+ const completed = tasks.filter((t) => t.status === "completed").length;
160
+ const inProgress = tasks.find((t) => t.status === "in_progress");
161
+ const total = tasks.length;
162
+ let summary = `Tasks updated: [${completed}/${total} completed]`;
163
+ if (inProgress) {
164
+ summary += `
165
+ Currently: ${inProgress.activeForm}`;
166
+ }
167
+ return {
168
+ content: summary,
169
+ isError: false
170
+ };
171
+ } catch (error) {
172
+ const msg = error instanceof Error ? error.message : "Unknown error";
173
+ return {
174
+ content: `Failed to update tasks: ${msg}`,
175
+ isError: true
176
+ };
177
+ }
178
+ }
179
+ });
180
+ var taskCheckTool = chunkEAZ6YDCQ_cjs.createTool({
181
+ id: "task_check",
182
+ description: `Check the completion status of your current task list. Use this before deciding to end work on a task to ensure all tasks are completed.
183
+
184
+ Returns:
185
+ - Total number of tasks
186
+ - Number of completed, in progress, and pending tasks
187
+ - List of incomplete tasks (if any)
188
+ - Boolean indicating if all tasks are done`,
189
+ inputSchema: zod.z.object({}),
190
+ // No input needed
191
+ execute: async ({}, context) => {
192
+ try {
193
+ const harnessCtx = context?.requestContext?.get("harness");
194
+ if (!harnessCtx) {
195
+ return {
196
+ content: "Unable to access task list (no harness context)",
197
+ isError: true
198
+ };
199
+ }
200
+ const state = harnessCtx.getState ? harnessCtx.getState() : harnessCtx.state;
201
+ const typedState = state;
202
+ const tasks = typedState.tasks || [];
203
+ if (tasks.length === 0) {
204
+ return {
205
+ content: "No tasks found. Consider using task_write to create a task list for complex work.",
206
+ isError: false
207
+ };
208
+ }
209
+ const completed = tasks.filter((t) => t.status === "completed");
210
+ const inProgress = tasks.filter((t) => t.status === "in_progress");
211
+ const pending = tasks.filter((t) => t.status === "pending");
212
+ const incomplete = [...inProgress, ...pending];
213
+ const allDone = incomplete.length === 0;
214
+ let response = `Task Status: [${completed.length}/${tasks.length} completed]
215
+ `;
216
+ response += `- Completed: ${completed.length}
217
+ `;
218
+ response += `- In Progress: ${inProgress.length}
219
+ `;
220
+ response += `- Pending: ${pending.length}
221
+ `;
222
+ response += `
223
+ All tasks completed: ${allDone ? "\u2713 YES" : "\u2717 NO"}`;
224
+ if (!allDone) {
225
+ response += "\n\nIncomplete tasks:";
226
+ if (inProgress.length > 0) {
227
+ response += "\n\nIn Progress:";
228
+ inProgress.forEach((t) => {
229
+ response += `
230
+ - ${t.content}`;
231
+ });
232
+ }
233
+ if (pending.length > 0) {
234
+ response += "\n\nPending:";
235
+ pending.forEach((t) => {
236
+ response += `
237
+ - ${t.content}`;
238
+ });
239
+ }
240
+ response += "\n\nContinue working on these tasks before ending.";
241
+ }
242
+ return {
243
+ content: response,
244
+ isError: false
245
+ };
246
+ } catch (error) {
247
+ const msg = error instanceof Error ? error.message : "Unknown error";
248
+ return {
249
+ content: `Failed to check tasks: ${msg}`,
250
+ isError: true
251
+ };
252
+ }
253
+ }
254
+ });
120
255
  function createSubagentTool(opts) {
121
256
  const { subagents, resolveModel, harnessTools, fallbackModelId } = opts;
122
257
  const subagentIds = subagents.map((s) => s.id);
@@ -160,7 +295,7 @@ Use this tool when:
160
295
  }
161
296
  }
162
297
  }
163
- const harnessModelId = harnessCtx?.getSubagentModelId?.(agentType) ?? void 0;
298
+ const harnessModelId = harnessCtx?.getSubagentModelId?.({ agentType }) ?? void 0;
164
299
  const resolvedModelId = modelId ?? harnessModelId ?? definition.defaultModelId ?? fallbackModelId;
165
300
  if (!resolvedModelId) {
166
301
  return { content: "No model ID available for subagent. Configure defaultModelId.", isError: true };
@@ -174,7 +309,7 @@ Use this tool when:
174
309
  isError: true
175
310
  };
176
311
  }
177
- const subagent = new chunk7S6LA43E_cjs.Agent({
312
+ const subagent = new chunkVJWRJWSC_cjs.Agent({
178
313
  id: `subagent-${definition.id}`,
179
314
  name: `${definition.name} Subagent`,
180
315
  instructions: definition.instructions,
@@ -334,7 +469,7 @@ var Harness = class {
334
469
  throw new Error("Harness requires at least one agent mode");
335
470
  }
336
471
  this.currentModeId = defaultMode.id;
337
- if (config.workspace instanceof chunkS4VVZI4E_cjs.Workspace) {
472
+ if (config.workspace instanceof chunkAYHSPIT6_cjs.Workspace) {
338
473
  this.workspace = config.workspace;
339
474
  } else if (typeof config.workspace === "function") {
340
475
  this.workspaceFn = config.workspace;
@@ -358,7 +493,7 @@ var Harness = class {
358
493
  if (this.config.workspace && !this.workspaceInitialized && !this.workspaceFn) {
359
494
  try {
360
495
  if (!this.workspace) {
361
- this.workspace = new chunkS4VVZI4E_cjs.Workspace(this.config.workspace);
496
+ this.workspace = new chunkAYHSPIT6_cjs.Workspace(this.config.workspace);
362
497
  }
363
498
  this.emit({ type: "workspace_status_changed", status: "initializing" });
364
499
  await this.workspace.init();
@@ -400,6 +535,7 @@ var Harness = class {
400
535
  }
401
536
  const sortedThreads = [...threads].sort((a, b) => b.updatedAt.getTime() - a.updatedAt.getTime());
402
537
  const mostRecent = sortedThreads[0];
538
+ this.config.threadLock?.acquire(mostRecent.id);
403
539
  this.currentThreadId = mostRecent.id;
404
540
  await this.loadThreadMetadata();
405
541
  return mostRecent;
@@ -459,7 +595,7 @@ var Harness = class {
459
595
  // ===========================================================================
460
596
  // Mode Management
461
597
  // ===========================================================================
462
- getModes() {
598
+ listModes() {
463
599
  return this.config.modes;
464
600
  }
465
601
  getCurrentModeId() {
@@ -476,7 +612,7 @@ var Harness = class {
476
612
  * Switch to a different mode.
477
613
  * Aborts any in-progress generation and switches to the mode's default model.
478
614
  */
479
- async switchMode(modeId) {
615
+ async switchMode({ modeId }) {
480
616
  const mode = this.config.modes.find((m) => m.id === modeId);
481
617
  if (!mode) {
482
618
  throw new Error(`Mode not found: ${modeId}`);
@@ -484,11 +620,11 @@ var Harness = class {
484
620
  this.abort();
485
621
  const currentModelId = this.getCurrentModelId();
486
622
  if (currentModelId) {
487
- await this.persistThreadSetting(`modeModelId_${this.currentModeId}`, currentModelId);
623
+ await this.setThreadSetting({ key: `modeModelId_${this.currentModeId}`, value: currentModelId });
488
624
  }
489
625
  const previousModeId = this.currentModeId;
490
626
  this.currentModeId = modeId;
491
- await this.persistThreadSetting("currentModeId", modeId);
627
+ await this.setThreadSetting({ key: "currentModeId", value: modeId });
492
628
  const modeModelId = await this.loadModeModelId(modeId);
493
629
  if (modeModelId) {
494
630
  void this.setState({ currentModelId: modeModelId });
@@ -543,13 +679,17 @@ var Harness = class {
543
679
  /**
544
680
  * Switch to a different model at runtime.
545
681
  */
546
- async switchModel(modelId, scope = "thread", modeId) {
682
+ async switchModel({
683
+ modelId,
684
+ scope = "thread",
685
+ modeId
686
+ }) {
547
687
  const targetModeId = modeId ?? this.currentModeId;
548
688
  if (targetModeId === this.currentModeId) {
549
689
  void this.setState({ currentModelId: modelId });
550
690
  }
551
691
  if (scope === "thread") {
552
- await this.persistThreadSetting(`modeModelId_${targetModeId}`, modelId);
692
+ await this.setThreadSetting({ key: `modeModelId_${targetModeId}`, value: modelId });
553
693
  }
554
694
  this.emit({ type: "model_changed", modelId, scope, modeId: targetModeId });
555
695
  }
@@ -577,7 +717,7 @@ var Harness = class {
577
717
  }
578
718
  }
579
719
  try {
580
- const { PROVIDER_REGISTRY } = await import('../provider-registry-4PH2JPIA.cjs');
720
+ const { PROVIDER_REGISTRY } = await import('../provider-registry-HMTFO5FV.cjs');
581
721
  const registry = PROVIDER_REGISTRY;
582
722
  const providerConfig = registry[provider];
583
723
  const envVars = providerConfig?.apiKeyEnvVar;
@@ -594,9 +734,9 @@ var Harness = class {
594
734
  * Get all available models from the provider registry with auth status.
595
735
  * Uses the optional `modelAuthChecker` and `modelUseCountProvider` hooks.
596
736
  */
597
- async getAvailableModels() {
737
+ async listAvailableModels() {
598
738
  try {
599
- const { PROVIDER_REGISTRY } = await import('../provider-registry-4PH2JPIA.cjs');
739
+ const { PROVIDER_REGISTRY } = await import('../provider-registry-HMTFO5FV.cjs');
600
740
  if (!PROVIDER_REGISTRY) return [];
601
741
  const registry = PROVIDER_REGISTRY;
602
742
  const providers = Object.keys(registry);
@@ -634,7 +774,7 @@ var Harness = class {
634
774
  }
635
775
  async getProviderApiKeyEnvVar(provider) {
636
776
  try {
637
- const { PROVIDER_REGISTRY } = await import('../provider-registry-4PH2JPIA.cjs');
777
+ const { PROVIDER_REGISTRY } = await import('../provider-registry-HMTFO5FV.cjs');
638
778
  const registry = PROVIDER_REGISTRY;
639
779
  const envVars = registry[provider]?.apiKeyEnvVar;
640
780
  return Array.isArray(envVars) ? envVars[0] : envVars;
@@ -651,11 +791,11 @@ var Harness = class {
651
791
  getResourceId() {
652
792
  return this.resourceId;
653
793
  }
654
- setResourceId(resourceId) {
794
+ setResourceId({ resourceId }) {
655
795
  this.resourceId = resourceId;
656
796
  this.currentThreadId = null;
657
797
  }
658
- async createThread(title) {
798
+ async createThread({ title } = {}) {
659
799
  const now = /* @__PURE__ */ new Date();
660
800
  const thread = {
661
801
  id: this.generateId(),
@@ -672,6 +812,10 @@ var Harness = class {
672
812
  metadata.currentModelId = modelId;
673
813
  metadata[`modeModelId_${this.currentModeId}`] = modelId;
674
814
  }
815
+ const projectPath = this.state.projectPath;
816
+ if (projectPath) {
817
+ metadata.projectPath = projectPath;
818
+ }
675
819
  if (this.config.storage) {
676
820
  const memoryStorage = await this.getMemoryStorage();
677
821
  await memoryStorage.saveThread({
@@ -685,6 +829,23 @@ var Harness = class {
685
829
  }
686
830
  });
687
831
  }
832
+ const oldThreadId = this.currentThreadId;
833
+ if (this.config.threadLock) {
834
+ try {
835
+ this.config.threadLock.acquire(thread.id);
836
+ } catch (err) {
837
+ if (oldThreadId) {
838
+ try {
839
+ this.config.threadLock.acquire(oldThreadId);
840
+ } catch {
841
+ }
842
+ }
843
+ throw err;
844
+ }
845
+ if (oldThreadId) {
846
+ this.config.threadLock.release(oldThreadId);
847
+ }
848
+ }
688
849
  this.currentThreadId = thread.id;
689
850
  if (modelId && !currentStateModel) {
690
851
  void this.setState({ currentModelId: modelId });
@@ -693,7 +854,7 @@ var Harness = class {
693
854
  this.emit({ type: "thread_created", thread });
694
855
  return thread;
695
856
  }
696
- async renameThread(title) {
857
+ async renameThread({ title }) {
697
858
  if (!this.currentThreadId || !this.config.storage) return;
698
859
  const memoryStorage = await this.getMemoryStorage();
699
860
  const thread = await memoryStorage.getThreadById({ threadId: this.currentThreadId });
@@ -703,7 +864,7 @@ var Harness = class {
703
864
  });
704
865
  }
705
866
  }
706
- async switchThread(threadId) {
867
+ async switchThread({ threadId }) {
707
868
  this.abort();
708
869
  if (this.config.storage) {
709
870
  const memoryStorage = await this.getMemoryStorage();
@@ -712,7 +873,11 @@ var Harness = class {
712
873
  throw new Error(`Thread not found: ${threadId}`);
713
874
  }
714
875
  }
876
+ this.config.threadLock?.acquire(threadId);
715
877
  const previousThreadId = this.currentThreadId;
878
+ if (previousThreadId) {
879
+ this.config.threadLock?.release(previousThreadId);
880
+ }
716
881
  this.currentThreadId = threadId;
717
882
  await this.loadThreadMetadata();
718
883
  this.emit({ type: "thread_changed", threadId, previousThreadId });
@@ -731,7 +896,7 @@ var Harness = class {
731
896
  metadata: thread.metadata
732
897
  }));
733
898
  }
734
- async persistThreadSetting(key, value) {
899
+ async setThreadSetting({ key, value }) {
735
900
  if (!this.currentThreadId || !this.config.storage) return;
736
901
  try {
737
902
  const memoryStorage = await this.getMemoryStorage();
@@ -748,7 +913,7 @@ var Harness = class {
748
913
  } catch {
749
914
  }
750
915
  }
751
- async removeThreadSetting(key) {
916
+ async deleteThreadSetting({ key }) {
752
917
  if (!this.currentThreadId || !this.config.storage) return;
753
918
  try {
754
919
  const memoryStorage = await this.getMemoryStorage();
@@ -959,10 +1124,26 @@ var Harness = class {
959
1124
  if (!modelId || !this.config.resolveModel) return void 0;
960
1125
  return this.config.resolveModel(modelId);
961
1126
  }
1127
+ /**
1128
+ * Switch the Observer model.
1129
+ */
1130
+ async switchObserverModel({ modelId }) {
1131
+ void this.setState({ observerModelId: modelId });
1132
+ await this.setThreadSetting({ key: "observerModelId", value: modelId });
1133
+ this.emit({ type: "om_model_changed", role: "observer", modelId });
1134
+ }
1135
+ /**
1136
+ * Switch the Reflector model.
1137
+ */
1138
+ async switchReflectorModel({ modelId }) {
1139
+ void this.setState({ reflectorModelId: modelId });
1140
+ await this.setThreadSetting({ key: "reflectorModelId", value: modelId });
1141
+ this.emit({ type: "om_model_changed", role: "reflector", modelId });
1142
+ }
962
1143
  // ===========================================================================
963
1144
  // Subagent Model Management
964
1145
  // ===========================================================================
965
- getSubagentModelId(agentType) {
1146
+ getSubagentModelId({ agentType } = {}) {
966
1147
  const state = this.state;
967
1148
  if (agentType) {
968
1149
  const perType = state[`subagentModelId_${agentType}`];
@@ -971,19 +1152,19 @@ var Harness = class {
971
1152
  const global = state.subagentModelId;
972
1153
  return typeof global === "string" ? global : null;
973
1154
  }
974
- async setSubagentModelId(modelId, agentType) {
1155
+ async setSubagentModelId({ modelId, agentType }) {
975
1156
  const key = agentType ? `subagentModelId_${agentType}` : "subagentModelId";
976
1157
  void this.setState({ [key]: modelId });
977
- await this.persistThreadSetting(key, modelId);
1158
+ await this.setThreadSetting({ key, value: modelId });
978
1159
  this.emit({ type: "subagent_model_changed", modelId, scope: "thread", agentType });
979
1160
  }
980
1161
  // ===========================================================================
981
1162
  // Permissions
982
1163
  // ===========================================================================
983
- grantSessionCategory(category) {
1164
+ grantSessionCategory({ category }) {
984
1165
  this.sessionGrantedCategories.add(category);
985
1166
  }
986
- grantSessionTool(toolName) {
1167
+ grantSessionTool({ toolName }) {
987
1168
  this.sessionGrantedTools.add(toolName);
988
1169
  }
989
1170
  getSessionGrants() {
@@ -992,15 +1173,15 @@ var Harness = class {
992
1173
  tools: [...this.sessionGrantedTools]
993
1174
  };
994
1175
  }
995
- getToolCategory(toolName) {
1176
+ getToolCategory({ toolName }) {
996
1177
  return this.config.toolCategoryResolver?.(toolName) ?? null;
997
1178
  }
998
- setPermissionCategory(category, policy) {
1179
+ setPermissionForCategory({ category, policy }) {
999
1180
  const rules = this.getPermissionRules();
1000
1181
  rules.categories[category] = policy;
1001
1182
  void this.setState({ permissionRules: rules });
1002
1183
  }
1003
- setPermissionTool(toolName, policy) {
1184
+ setPermissionForTool({ toolName, policy }) {
1004
1185
  const rules = this.getPermissionRules();
1005
1186
  rules.tools[toolName] = policy;
1006
1187
  void this.setState({ permissionRules: rules });
@@ -1022,7 +1203,7 @@ var Harness = class {
1022
1203
  const toolPolicy = rules.tools[toolName];
1023
1204
  if (toolPolicy) return toolPolicy;
1024
1205
  if (this.sessionGrantedTools.has(toolName)) return "allow";
1025
- const category = this.getToolCategory(toolName);
1206
+ const category = this.getToolCategory({ toolName });
1026
1207
  if (category) {
1027
1208
  if (this.sessionGrantedCategories.has(category)) return "allow";
1028
1209
  const categoryPolicy = rules.categories[category];
@@ -1037,7 +1218,10 @@ var Harness = class {
1037
1218
  * Send a message to the current agent.
1038
1219
  * Streams the response and emits events.
1039
1220
  */
1040
- async sendMessage(content, options) {
1221
+ async sendMessage({
1222
+ content,
1223
+ images
1224
+ }) {
1041
1225
  if (!this.currentThreadId) {
1042
1226
  const thread = await this.createThread();
1043
1227
  this.currentThreadId = thread.id;
@@ -1059,12 +1243,16 @@ var Harness = class {
1059
1243
  };
1060
1244
  streamOptions.toolsets = await this.buildToolsets(requestContext);
1061
1245
  let messageInput = content;
1062
- if (options?.images?.length) {
1246
+ if (images?.length) {
1063
1247
  messageInput = {
1064
1248
  role: "user",
1065
1249
  content: [
1066
1250
  { type: "text", text: content },
1067
- ...options.images.map((img) => ({ type: "file", data: img.data, mediaType: img.mimeType }))
1251
+ ...images.map((img) => ({
1252
+ type: "file",
1253
+ data: img.data,
1254
+ mediaType: img.mimeType
1255
+ }))
1068
1256
  ]
1069
1257
  };
1070
1258
  }
@@ -1101,18 +1289,17 @@ var Harness = class {
1101
1289
  }
1102
1290
  if (this.currentOperationId === operationId && this.followUpQueue.length > 0) {
1103
1291
  const next = this.followUpQueue.shift();
1104
- await this.sendMessage(next);
1292
+ await this.sendMessage({ content: next });
1105
1293
  }
1106
1294
  }
1107
1295
  }
1108
- async getMessages(options) {
1296
+ async listMessages(options) {
1109
1297
  if (!this.currentThreadId) return [];
1110
- return this.getMessagesForThread(this.currentThreadId, options);
1298
+ return this.listMessagesForThread({ threadId: this.currentThreadId, limit: options?.limit });
1111
1299
  }
1112
- async getMessagesForThread(threadId, options) {
1300
+ async listMessagesForThread({ threadId, limit }) {
1113
1301
  if (!this.config.storage) return [];
1114
1302
  const memoryStorage = await this.getMemoryStorage();
1115
- const limit = options?.limit;
1116
1303
  if (limit) {
1117
1304
  const result2 = await memoryStorage.listMessages({
1118
1305
  threadId,
@@ -1125,7 +1312,7 @@ var Harness = class {
1125
1312
  const result = await memoryStorage.listMessages({ threadId, perPage: false });
1126
1313
  return result.messages.map((msg) => this.convertToHarnessMessage(msg));
1127
1314
  }
1128
- async getFirstUserMessageForThread(threadId) {
1315
+ async getFirstUserMessageForThread({ threadId }) {
1129
1316
  if (!this.config.storage) return null;
1130
1317
  const memoryStorage = await this.getMemoryStorage();
1131
1318
  const result = await memoryStorage.listMessages({
@@ -1184,6 +1371,39 @@ var Harness = class {
1184
1371
  });
1185
1372
  }
1186
1373
  break;
1374
+ case "data-om-observation-start": {
1375
+ const data = part.data ?? {};
1376
+ content.push({
1377
+ type: "om_observation_start",
1378
+ tokensToObserve: data.tokensToObserve ?? 0,
1379
+ operationType: data.operationType ?? "observation"
1380
+ });
1381
+ break;
1382
+ }
1383
+ case "data-om-observation-end": {
1384
+ const data = part.data ?? {};
1385
+ content.push({
1386
+ type: "om_observation_end",
1387
+ tokensObserved: data.tokensObserved ?? 0,
1388
+ observationTokens: data.observationTokens ?? 0,
1389
+ durationMs: data.durationMs ?? 0,
1390
+ operationType: data.operationType ?? "observation",
1391
+ observations: data.observations ?? void 0,
1392
+ currentTask: data.currentTask ?? void 0,
1393
+ suggestedResponse: data.suggestedResponse ?? void 0
1394
+ });
1395
+ break;
1396
+ }
1397
+ case "data-om-observation-failed": {
1398
+ const data = part.data ?? {};
1399
+ content.push({
1400
+ type: "om_observation_failed",
1401
+ error: data.error ?? "Unknown error",
1402
+ tokensAttempted: data.tokensAttempted ?? 0,
1403
+ operationType: data.operationType ?? "observation"
1404
+ });
1405
+ break;
1406
+ }
1187
1407
  }
1188
1408
  }
1189
1409
  return { id: msg.id, role: msg.role, content, createdAt: msg.createdAt };
@@ -1243,6 +1463,21 @@ var Harness = class {
1243
1463
  }
1244
1464
  break;
1245
1465
  }
1466
+ case "tool-call-input-streaming-start": {
1467
+ const { toolCallId, toolName } = chunk.payload;
1468
+ this.emit({ type: "tool_input_start", toolCallId, toolName });
1469
+ break;
1470
+ }
1471
+ case "tool-call-delta": {
1472
+ const { toolCallId, argsTextDelta, toolName } = chunk.payload;
1473
+ this.emit({ type: "tool_input_delta", toolCallId, argsTextDelta, toolName });
1474
+ break;
1475
+ }
1476
+ case "tool-call-input-streaming-end": {
1477
+ const { toolCallId } = chunk.payload;
1478
+ this.emit({ type: "tool_input_end", toolCallId });
1479
+ break;
1480
+ }
1246
1481
  case "tool-call": {
1247
1482
  const toolCall = chunk.payload;
1248
1483
  currentMessage.content.push({
@@ -1345,6 +1580,169 @@ var Harness = class {
1345
1580
  }
1346
1581
  break;
1347
1582
  }
1583
+ // Observational Memory data parts
1584
+ // NOTE: OM data parts arrive as { type, data: { ... } } — NOT { type, payload }
1585
+ case "data-om-status": {
1586
+ const d = chunk.data;
1587
+ if (d?.windows) {
1588
+ const w = d.windows;
1589
+ const active = w.active ?? {};
1590
+ const msgs = active.messages ?? {};
1591
+ const obs = active.observations ?? {};
1592
+ const buffObs = w.buffered?.observations ?? {};
1593
+ const buffRef = w.buffered?.reflection ?? {};
1594
+ this.emit({
1595
+ type: "om_status",
1596
+ windows: {
1597
+ active: {
1598
+ messages: { tokens: msgs.tokens ?? 0, threshold: msgs.threshold ?? 0 },
1599
+ observations: { tokens: obs.tokens ?? 0, threshold: obs.threshold ?? 0 }
1600
+ },
1601
+ buffered: {
1602
+ observations: {
1603
+ status: buffObs.status ?? "idle",
1604
+ chunks: buffObs.chunks ?? 0,
1605
+ messageTokens: buffObs.messageTokens ?? 0,
1606
+ projectedMessageRemoval: buffObs.projectedMessageRemoval ?? 0,
1607
+ observationTokens: buffObs.observationTokens ?? 0
1608
+ },
1609
+ reflection: {
1610
+ status: buffRef.status ?? "idle",
1611
+ inputObservationTokens: buffRef.inputObservationTokens ?? 0,
1612
+ observationTokens: buffRef.observationTokens ?? 0
1613
+ }
1614
+ }
1615
+ },
1616
+ recordId: d.recordId ?? "",
1617
+ threadId: d.threadId ?? "",
1618
+ stepNumber: d.stepNumber ?? 0,
1619
+ generationCount: d.generationCount ?? 0
1620
+ });
1621
+ }
1622
+ break;
1623
+ }
1624
+ case "data-om-observation-start": {
1625
+ const payload = chunk.data;
1626
+ if (payload && payload.cycleId) {
1627
+ if (payload.operationType === "observation") {
1628
+ this.emit({
1629
+ type: "om_observation_start",
1630
+ cycleId: payload.cycleId,
1631
+ operationType: payload.operationType,
1632
+ tokensToObserve: payload.tokensToObserve ?? 0
1633
+ });
1634
+ } else if (payload.operationType === "reflection") {
1635
+ this.emit({
1636
+ type: "om_reflection_start",
1637
+ cycleId: payload.cycleId,
1638
+ tokensToReflect: payload.tokensToObserve ?? 0
1639
+ });
1640
+ }
1641
+ }
1642
+ break;
1643
+ }
1644
+ case "data-om-observation-end": {
1645
+ const payload = chunk.data;
1646
+ if (payload && payload.cycleId) {
1647
+ if (payload.operationType === "reflection") {
1648
+ this.emit({
1649
+ type: "om_reflection_end",
1650
+ cycleId: payload.cycleId,
1651
+ durationMs: payload.durationMs ?? 0,
1652
+ compressedTokens: payload.observationTokens ?? 0,
1653
+ observations: payload.observations
1654
+ });
1655
+ } else {
1656
+ this.emit({
1657
+ type: "om_observation_end",
1658
+ cycleId: payload.cycleId,
1659
+ durationMs: payload.durationMs ?? 0,
1660
+ tokensObserved: payload.tokensObserved ?? 0,
1661
+ observationTokens: payload.observationTokens ?? 0,
1662
+ observations: payload.observations,
1663
+ currentTask: payload.currentTask,
1664
+ suggestedResponse: payload.suggestedResponse
1665
+ });
1666
+ }
1667
+ }
1668
+ break;
1669
+ }
1670
+ case "data-om-observation-failed": {
1671
+ const payload = chunk.data;
1672
+ if (payload) {
1673
+ if (payload.operationType === "reflection") {
1674
+ this.emit({
1675
+ type: "om_reflection_failed",
1676
+ cycleId: payload.cycleId ?? "unknown",
1677
+ error: payload.error ?? "Unknown error",
1678
+ durationMs: payload.durationMs ?? 0
1679
+ });
1680
+ } else {
1681
+ this.emit({
1682
+ type: "om_observation_failed",
1683
+ cycleId: payload.cycleId ?? "unknown",
1684
+ error: payload.error ?? "Unknown error",
1685
+ durationMs: payload.durationMs ?? 0
1686
+ });
1687
+ }
1688
+ }
1689
+ break;
1690
+ }
1691
+ // Async buffering lifecycle
1692
+ case "data-om-buffering-start": {
1693
+ const payload = chunk.data;
1694
+ if (payload && payload.cycleId) {
1695
+ this.emit({
1696
+ type: "om_buffering_start",
1697
+ cycleId: payload.cycleId,
1698
+ operationType: payload.operationType ?? "observation",
1699
+ tokensToBuffer: payload.tokensToBuffer ?? 0
1700
+ });
1701
+ }
1702
+ break;
1703
+ }
1704
+ case "data-om-buffering-end": {
1705
+ const payload = chunk.data;
1706
+ if (payload && payload.cycleId) {
1707
+ this.emit({
1708
+ type: "om_buffering_end",
1709
+ cycleId: payload.cycleId,
1710
+ operationType: payload.operationType ?? "observation",
1711
+ tokensBuffered: payload.tokensBuffered ?? 0,
1712
+ bufferedTokens: payload.bufferedTokens ?? 0,
1713
+ observations: payload.observations
1714
+ });
1715
+ }
1716
+ break;
1717
+ }
1718
+ case "data-om-buffering-failed": {
1719
+ const payload = chunk.data;
1720
+ if (payload && payload.cycleId) {
1721
+ this.emit({
1722
+ type: "om_buffering_failed",
1723
+ cycleId: payload.cycleId,
1724
+ operationType: payload.operationType ?? "observation",
1725
+ error: payload.error ?? "Unknown error"
1726
+ });
1727
+ }
1728
+ break;
1729
+ }
1730
+ case "data-om-activation": {
1731
+ const payload = chunk.data;
1732
+ if (payload && payload.cycleId) {
1733
+ this.emit({
1734
+ type: "om_activation",
1735
+ cycleId: payload.cycleId,
1736
+ operationType: payload.operationType ?? "observation",
1737
+ chunksActivated: payload.chunksActivated ?? 0,
1738
+ tokensActivated: payload.tokensActivated ?? 0,
1739
+ observationTokens: payload.observationTokens ?? 0,
1740
+ messagesActivated: payload.messagesActivated ?? 0,
1741
+ generationCount: payload.generationCount ?? 0
1742
+ });
1743
+ }
1744
+ break;
1745
+ }
1348
1746
  }
1349
1747
  }
1350
1748
  this.emit({ type: "message_end", message: currentMessage });
@@ -1369,20 +1767,20 @@ var Harness = class {
1369
1767
  /**
1370
1768
  * Steer the agent mid-stream: aborts current run and sends a new message.
1371
1769
  */
1372
- async steer(content) {
1770
+ async steer({ content }) {
1373
1771
  this.abort();
1374
1772
  this.followUpQueue = [];
1375
- await this.sendMessage(content);
1773
+ await this.sendMessage({ content });
1376
1774
  }
1377
1775
  /**
1378
1776
  * Queue a follow-up message to be processed after the current operation completes.
1379
1777
  */
1380
- async followUp(content) {
1778
+ async followUp({ content }) {
1381
1779
  if (this.isRunning()) {
1382
1780
  this.followUpQueue.push(content);
1383
1781
  this.emit({ type: "follow_up_queued", count: this.followUpQueue.length });
1384
1782
  } else {
1385
- await this.sendMessage(content);
1783
+ await this.sendMessage({ content });
1386
1784
  }
1387
1785
  }
1388
1786
  getFollowUpCount() {
@@ -1398,14 +1796,14 @@ var Harness = class {
1398
1796
  * Respond to a pending tool approval from the UI.
1399
1797
  * "always_allow_category" grants the tool's category for the rest of the session, then approves.
1400
1798
  */
1401
- resolveToolApprovalDecision(decision) {
1799
+ respondToToolApproval({ decision }) {
1402
1800
  if (!this.pendingApprovalResolve) return;
1403
1801
  if (decision === "always_allow_category") {
1404
1802
  const tn = this.pendingApprovalToolName;
1405
1803
  if (tn) {
1406
- const category = this.getToolCategory(tn);
1804
+ const category = this.getToolCategory({ toolName: tn });
1407
1805
  if (category) {
1408
- this.grantSessionCategory(category);
1806
+ this.grantSessionCategory({ category });
1409
1807
  }
1410
1808
  }
1411
1809
  this.pendingApprovalResolve("approve");
@@ -1421,14 +1819,14 @@ var Harness = class {
1421
1819
  * Register a pending question resolver.
1422
1820
  * Called by agent tools (e.g., ask_user) to pause execution until the UI responds.
1423
1821
  */
1424
- registerQuestion(questionId, resolve) {
1822
+ registerQuestion({ questionId, resolve }) {
1425
1823
  this.pendingQuestions.set(questionId, resolve);
1426
1824
  }
1427
1825
  /**
1428
1826
  * Resolve a pending question with the user's answer.
1429
1827
  * Called by the UI when the user responds to a question dialog.
1430
1828
  */
1431
- respondToQuestion(questionId, answer) {
1829
+ respondToQuestion({ questionId, answer }) {
1432
1830
  const resolve = this.pendingQuestions.get(questionId);
1433
1831
  if (resolve) {
1434
1832
  this.pendingQuestions.delete(questionId);
@@ -1439,7 +1837,10 @@ var Harness = class {
1439
1837
  * Register a pending plan approval resolver.
1440
1838
  * Called by agent tools (e.g., submit_plan) to pause execution until approval.
1441
1839
  */
1442
- registerPlanApproval(planId, resolve) {
1840
+ registerPlanApproval({
1841
+ planId,
1842
+ resolve
1843
+ }) {
1443
1844
  this.pendingPlanApprovals.set(planId, resolve);
1444
1845
  }
1445
1846
  /**
@@ -1447,13 +1848,16 @@ var Harness = class {
1447
1848
  * On approval: switches to the default mode, then resolves the promise.
1448
1849
  * On rejection: resolves with feedback (stays in current mode).
1449
1850
  */
1450
- async respondToPlanApproval(planId, response) {
1851
+ async respondToPlanApproval({
1852
+ planId,
1853
+ response
1854
+ }) {
1451
1855
  const resolve = this.pendingPlanApprovals.get(planId);
1452
1856
  if (!resolve) return;
1453
1857
  if (response.action === "approved") {
1454
1858
  const defaultMode = this.config.modes.find((m) => m.default) ?? this.config.modes[0];
1455
1859
  if (defaultMode && defaultMode.id !== this.currentModeId) {
1456
- await this.switchMode(defaultMode.id);
1860
+ await this.switchMode({ modeId: defaultMode.id });
1457
1861
  }
1458
1862
  }
1459
1863
  this.pendingPlanApprovals.delete(planId);
@@ -1537,7 +1941,9 @@ var Harness = class {
1537
1941
  async buildToolsets(requestContext) {
1538
1942
  const builtInTools = {
1539
1943
  ask_user: askUserTool,
1540
- submit_plan: submitPlanTool
1944
+ submit_plan: submitPlanTool,
1945
+ task_write: taskWriteTool,
1946
+ task_check: taskCheckTool
1541
1947
  };
1542
1948
  let resolvedHarnessTools = void 0;
1543
1949
  if (this.config.tools) {
@@ -1576,9 +1982,9 @@ var Harness = class {
1576
1982
  abortSignal: this.abortController?.signal,
1577
1983
  workspace: this.workspace,
1578
1984
  emitEvent: (event) => this.emit(event),
1579
- registerQuestion: (questionId, resolve) => this.registerQuestion(questionId, resolve),
1580
- registerPlanApproval: (planId, resolve) => this.registerPlanApproval(planId, resolve),
1581
- getSubagentModelId: (agentType) => this.getSubagentModelId(agentType)
1985
+ registerQuestion: (params) => this.registerQuestion(params),
1986
+ registerPlanApproval: (params) => this.registerPlanApproval(params),
1987
+ getSubagentModelId: (params) => this.getSubagentModelId(params)
1582
1988
  };
1583
1989
  const requestContext = new chunkVDKWYUGC_cjs.RequestContext([["harness", harnessContext]]);
1584
1990
  if (this.workspaceFn) {
@@ -1660,7 +2066,7 @@ var Harness = class {
1660
2066
  }
1661
2067
  }
1662
2068
  registerHeartbeat(handler) {
1663
- void this.removeHeartbeat(handler.id);
2069
+ void this.removeHeartbeat({ id: handler.id });
1664
2070
  const run = async () => {
1665
2071
  try {
1666
2072
  await handler.handler();
@@ -1675,7 +2081,7 @@ var Harness = class {
1675
2081
  timer.unref();
1676
2082
  this.heartbeatTimers.set(handler.id, { timer, shutdown: handler.shutdown });
1677
2083
  }
1678
- async removeHeartbeat(id) {
2084
+ async removeHeartbeat({ id }) {
1679
2085
  const entry = this.heartbeatTimers.get(id);
1680
2086
  if (entry) {
1681
2087
  clearInterval(entry.timer);
@@ -1724,5 +2130,7 @@ exports.Harness = Harness;
1724
2130
  exports.askUserTool = askUserTool;
1725
2131
  exports.parseSubagentMeta = parseSubagentMeta;
1726
2132
  exports.submitPlanTool = submitPlanTool;
2133
+ exports.taskCheckTool = taskCheckTool;
2134
+ exports.taskWriteTool = taskWriteTool;
1727
2135
  //# sourceMappingURL=index.cjs.map
1728
2136
  //# sourceMappingURL=index.cjs.map