@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.
- package/CHANGELOG.md +386 -0
- package/dist/agent/index.cjs +13 -13
- package/dist/agent/index.js +2 -2
- package/dist/agent/message-list/adapters/AIV5Adapter.d.ts.map +1 -1
- package/dist/agent/message-list/conversion/output-converter.d.ts.map +1 -1
- package/dist/agent/message-list/index.cjs +18 -18
- package/dist/agent/message-list/index.js +1 -1
- package/dist/agent/workflows/prepare-stream/index.d.ts +7 -7
- package/dist/agent/workflows/prepare-stream/prepare-memory-step.d.ts +7 -7
- package/dist/agent/workflows/prepare-stream/schema.d.ts +11 -11
- package/dist/{chunk-CQ4Z6ZAV.cjs → chunk-3U3XFMGJ.cjs} +7 -7
- package/dist/{chunk-CQ4Z6ZAV.cjs.map → chunk-3U3XFMGJ.cjs.map} +1 -1
- package/dist/{chunk-D57U4II4.js → chunk-4WG5K4CK.js} +9 -8
- package/dist/chunk-4WG5K4CK.js.map +1 -0
- package/dist/{chunk-UZFGMMKU.js → chunk-5K45E5VE.js} +37 -3
- package/dist/chunk-5K45E5VE.js.map +1 -0
- package/dist/{chunk-OQ5LZ6OV.cjs → chunk-5VQPSWPG.cjs} +149 -61
- package/dist/chunk-5VQPSWPG.cjs.map +1 -0
- package/dist/{chunk-AIRMLZ43.js → chunk-7EXW4AAG.js} +4 -4
- package/dist/{chunk-AIRMLZ43.js.map → chunk-7EXW4AAG.js.map} +1 -1
- package/dist/{chunk-S4VVZI4E.cjs → chunk-AYHSPIT6.cjs} +326 -5
- package/dist/chunk-AYHSPIT6.cjs.map +1 -0
- package/dist/{chunk-YW54RH77.cjs → chunk-DB7U2C5B.cjs} +12 -5
- package/dist/chunk-DB7U2C5B.cjs.map +1 -0
- package/dist/{chunk-DST75PA4.js → chunk-DGS2KGDI.js} +4 -4
- package/dist/{chunk-DST75PA4.js.map → chunk-DGS2KGDI.js.map} +1 -1
- package/dist/{chunk-YIN5F7VO.js → chunk-EEU5NHHU.js} +4254 -3958
- package/dist/chunk-EEU5NHHU.js.map +1 -0
- package/dist/{chunk-A6EWCOGA.cjs → chunk-H5S4PS44.cjs} +197 -27
- package/dist/chunk-H5S4PS44.cjs.map +1 -0
- package/dist/{chunk-3YMDR4OL.cjs → chunk-HTAUP7ER.cjs} +4 -4
- package/dist/{chunk-3YMDR4OL.cjs.map → chunk-HTAUP7ER.cjs.map} +1 -1
- package/dist/{chunk-OHLVZVIK.js → chunk-IC5OUWKJ.js} +12 -5
- package/dist/chunk-IC5OUWKJ.js.map +1 -0
- package/dist/{chunk-MZIMV2BB.js → chunk-IHDE4CJV.js} +244 -213
- package/dist/chunk-IHDE4CJV.js.map +1 -0
- package/dist/{chunk-3KJW4EMO.js → chunk-IHEYJDJP.js} +3 -3
- package/dist/{chunk-3KJW4EMO.js.map → chunk-IHEYJDJP.js.map} +1 -1
- package/dist/{chunk-CXVMDV2B.js → chunk-IOY7Y5GV.js} +197 -27
- package/dist/chunk-IOY7Y5GV.js.map +1 -0
- package/dist/{chunk-MDC6VYA6.cjs → chunk-KAVAKMOQ.cjs} +4 -8
- package/dist/chunk-KAVAKMOQ.cjs.map +1 -0
- package/dist/{chunk-7WC7ALDW.cjs → chunk-LNKS4TJ6.cjs} +6 -6
- package/dist/{chunk-7WC7ALDW.cjs.map → chunk-LNKS4TJ6.cjs.map} +1 -1
- package/dist/{chunk-R3364RAL.js → chunk-MWGGSA5Q.js} +4 -4
- package/dist/{chunk-R3364RAL.js.map → chunk-MWGGSA5Q.js.map} +1 -1
- package/dist/{chunk-QSN5KQXZ.cjs → chunk-O7PZ4VOO.cjs} +11 -11
- package/dist/{chunk-QSN5KQXZ.cjs.map → chunk-O7PZ4VOO.cjs.map} +1 -1
- package/dist/chunk-OQDRPRKM.cjs +46 -0
- package/dist/chunk-OQDRPRKM.cjs.map +1 -0
- package/dist/{chunk-YV2YGQRY.js → chunk-RHKNKJNM.js} +101 -13
- package/dist/chunk-RHKNKJNM.js.map +1 -0
- package/dist/{chunk-TPDMP7OD.js → chunk-RHYZ6CQN.js} +4 -8
- package/dist/chunk-RHYZ6CQN.js.map +1 -0
- package/dist/{chunk-G5JVVFIG.cjs → chunk-RZNHRIM7.cjs} +9 -9
- package/dist/{chunk-G5JVVFIG.cjs.map → chunk-RZNHRIM7.cjs.map} +1 -1
- package/dist/{chunk-JZ6TH4HQ.cjs → chunk-TL2TTA4X.cjs} +4260 -3962
- package/dist/chunk-TL2TTA4X.cjs.map +1 -0
- package/dist/{chunk-KNXZ7KYL.cjs → chunk-TVPANHLE.cjs} +40 -2
- package/dist/chunk-TVPANHLE.cjs.map +1 -0
- package/dist/{chunk-7S6LA43E.cjs → chunk-VJWRJWSC.cjs} +278 -248
- package/dist/chunk-VJWRJWSC.cjs.map +1 -0
- package/dist/chunk-X2HAI3OX.js +39 -0
- package/dist/chunk-X2HAI3OX.js.map +1 -0
- package/dist/{chunk-FZ5DRHKE.js → chunk-XB3DA67Q.js} +325 -5
- package/dist/chunk-XB3DA67Q.js.map +1 -0
- package/dist/{chunk-NUV3BLRH.cjs → chunk-XWZAKKFT.cjs} +17 -16
- package/dist/chunk-XWZAKKFT.cjs.map +1 -0
- package/dist/{chunk-4GB2GS4S.js → chunk-YM6245EM.js} +5 -5
- package/dist/{chunk-4GB2GS4S.js.map → chunk-YM6245EM.js.map} +1 -1
- package/dist/datasets/index.cjs +17 -17
- package/dist/datasets/index.js +2 -2
- package/dist/docs/SKILL.md +2 -1
- package/dist/docs/assets/SOURCE_MAP.json +417 -391
- package/dist/docs/references/docs-memory-observational-memory.md +2 -0
- package/dist/docs/references/docs-streaming-tool-streaming.md +6 -0
- package/dist/docs/references/docs-workspace-filesystem.md +21 -1
- package/dist/docs/references/reference-harness-harness-class.md +645 -0
- package/dist/docs/references/reference-memory-memory-class.md +1 -1
- package/dist/docs/references/reference-memory-observational-memory.md +1 -0
- package/dist/docs/references/reference-workspace-local-filesystem.md +25 -0
- package/dist/docs/references/reference-workspace-workspace-class.md +1 -24
- package/dist/docs/references/reference.md +1 -0
- package/dist/editor/types.d.ts +20 -1
- package/dist/editor/types.d.ts.map +1 -1
- package/dist/evals/base.d.ts.map +1 -1
- package/dist/evals/index.cjs +20 -20
- package/dist/evals/index.js +3 -3
- package/dist/evals/scoreTraces/index.cjs +5 -5
- package/dist/evals/scoreTraces/index.js +2 -2
- package/dist/events/index.cjs +6 -2
- package/dist/events/index.d.ts +1 -0
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +1 -1
- package/dist/harness/harness.d.ts +105 -35
- package/dist/harness/harness.d.ts.map +1 -1
- package/dist/harness/index.cjs +472 -64
- package/dist/harness/index.cjs.map +1 -1
- package/dist/harness/index.d.ts +2 -1
- package/dist/harness/index.d.ts.map +1 -1
- package/dist/harness/index.js +468 -62
- package/dist/harness/index.js.map +1 -1
- package/dist/harness/tools.d.ts +38 -0
- package/dist/harness/tools.d.ts.map +1 -1
- package/dist/harness/types.d.ts +64 -9
- package/dist/harness/types.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/llm/index.cjs +12 -12
- package/dist/llm/index.js +3 -3
- package/dist/llm/model/gateways/models-dev.d.ts.map +1 -1
- package/dist/loop/index.cjs +12 -12
- package/dist/loop/index.js +1 -1
- package/dist/loop/network/index.d.ts +6 -6
- package/dist/loop/network/index.d.ts.map +1 -1
- package/dist/loop/test-utils/options.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/index.d.ts +21 -21
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +14 -14
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts +7 -7
- package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-loop/index.d.ts +21 -21
- package/dist/loop/workflows/agentic-loop/index.d.ts.map +1 -1
- package/dist/loop/workflows/schema.d.ts +30 -30
- package/dist/loop/workflows/stream.d.ts +0 -13
- package/dist/loop/workflows/stream.d.ts.map +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +14 -14
- package/dist/memory/index.js +1 -1
- package/dist/models-dev-6P4CM74H.js +3 -0
- package/dist/{models-dev-MDI5E2YA.js.map → models-dev-6P4CM74H.js.map} +1 -1
- package/dist/models-dev-CLLSNT5L.cjs +12 -0
- package/dist/{models-dev-BW2GAM3K.cjs.map → models-dev-CLLSNT5L.cjs.map} +1 -1
- package/dist/processor-provider/index.cjs +256 -0
- package/dist/processor-provider/index.cjs.map +1 -0
- package/dist/processor-provider/index.d.ts +5 -0
- package/dist/processor-provider/index.d.ts.map +1 -0
- package/dist/processor-provider/index.js +243 -0
- package/dist/processor-provider/index.js.map +1 -0
- package/dist/processor-provider/phase-filtered-processor.d.ts +22 -0
- package/dist/processor-provider/phase-filtered-processor.d.ts.map +1 -0
- package/dist/processor-provider/providers/index.d.ts +12 -0
- package/dist/processor-provider/providers/index.d.ts.map +1 -0
- package/dist/processor-provider/types.d.ts +65 -0
- package/dist/processor-provider/types.d.ts.map +1 -0
- package/dist/processors/index.cjs +41 -41
- package/dist/processors/index.js +1 -1
- package/dist/processors/memory/message-history.d.ts.map +1 -1
- package/dist/processors/step-schema.d.ts +14 -14
- package/dist/provider-registry-HMTFO5FV.cjs +40 -0
- package/dist/{provider-registry-4PH2JPIA.cjs.map → provider-registry-HMTFO5FV.cjs.map} +1 -1
- package/dist/provider-registry-TTZ2WN2P.js +3 -0
- package/dist/{provider-registry-VEJ3PN4S.js.map → provider-registry-TTZ2WN2P.js.map} +1 -1
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.js +1 -1
- package/dist/storage/base.d.ts +2 -1
- package/dist/storage/base.d.ts.map +1 -1
- package/dist/storage/constants.cjs +68 -52
- package/dist/storage/constants.d.ts +6 -2
- package/dist/storage/constants.d.ts.map +1 -1
- package/dist/storage/constants.js +1 -1
- package/dist/storage/domains/index.d.ts +1 -0
- package/dist/storage/domains/index.d.ts.map +1 -1
- package/dist/storage/domains/inmemory-db.d.ts +4 -1
- package/dist/storage/domains/inmemory-db.d.ts.map +1 -1
- package/dist/storage/domains/mcp-servers/base.d.ts +47 -0
- package/dist/storage/domains/mcp-servers/base.d.ts.map +1 -0
- package/dist/storage/domains/mcp-servers/index.d.ts +3 -0
- package/dist/storage/domains/mcp-servers/index.d.ts.map +1 -0
- package/dist/storage/domains/mcp-servers/inmemory.d.ts +31 -0
- package/dist/storage/domains/mcp-servers/inmemory.d.ts.map +1 -0
- package/dist/storage/domains/memory/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/observability/types.d.ts +44 -44
- package/dist/storage/domains/operations/inmemory.d.ts.map +1 -1
- package/dist/storage/index.cjs +178 -154
- package/dist/storage/index.js +2 -2
- package/dist/storage/mock.d.ts.map +1 -1
- package/dist/storage/types.d.ts +220 -6
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/stream/MastraAgentNetworkStream.d.ts +1 -1
- package/dist/stream/MastraWorkflowStream.d.ts +1 -1
- package/dist/stream/aisdk/v5/input.d.ts.map +1 -1
- package/dist/stream/base/input.d.ts +19 -0
- package/dist/stream/base/input.d.ts.map +1 -1
- package/dist/stream/base/output.d.ts.map +1 -1
- package/dist/stream/index.cjs +11 -11
- package/dist/stream/index.js +2 -2
- package/dist/tool-loop-agent/index.cjs +4 -4
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/vector/index.cjs +9 -9
- package/dist/vector/index.js +2 -2
- package/dist/workflows/evented/execution-engine.d.ts.map +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/evented/step-executor.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/index.d.ts.map +1 -1
- package/dist/workflows/index.cjs +25 -25
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/step.d.ts.map +1 -1
- package/dist/workspace/constants/index.d.ts +1 -0
- package/dist/workspace/constants/index.d.ts.map +1 -1
- package/dist/workspace/index.cjs +64 -64
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/tools/ast-edit.d.ts +97 -0
- package/dist/workspace/tools/ast-edit.d.ts.map +1 -0
- package/dist/workspace/tools/search.d.ts +1 -1
- package/dist/workspace/tools/tools.d.ts.map +1 -1
- package/package.json +12 -11
- package/processor-provider.d.ts +1 -0
- package/dist/chunk-4D4KB75Y.cjs +0 -9
- package/dist/chunk-4D4KB75Y.cjs.map +0 -1
- package/dist/chunk-7S6LA43E.cjs.map +0 -1
- package/dist/chunk-A6EWCOGA.cjs.map +0 -1
- package/dist/chunk-BVUMKER5.js +0 -7
- package/dist/chunk-BVUMKER5.js.map +0 -1
- package/dist/chunk-CXVMDV2B.js.map +0 -1
- package/dist/chunk-D57U4II4.js.map +0 -1
- package/dist/chunk-FZ5DRHKE.js.map +0 -1
- package/dist/chunk-JZ6TH4HQ.cjs.map +0 -1
- package/dist/chunk-KNXZ7KYL.cjs.map +0 -1
- package/dist/chunk-MDC6VYA6.cjs.map +0 -1
- package/dist/chunk-MZIMV2BB.js.map +0 -1
- package/dist/chunk-NUV3BLRH.cjs.map +0 -1
- package/dist/chunk-OHLVZVIK.js.map +0 -1
- package/dist/chunk-OQ5LZ6OV.cjs.map +0 -1
- package/dist/chunk-S4VVZI4E.cjs.map +0 -1
- package/dist/chunk-TPDMP7OD.js.map +0 -1
- package/dist/chunk-UZFGMMKU.js.map +0 -1
- package/dist/chunk-YIN5F7VO.js.map +0 -1
- package/dist/chunk-YV2YGQRY.js.map +0 -1
- package/dist/chunk-YW54RH77.cjs.map +0 -1
- package/dist/models-dev-BW2GAM3K.cjs +0 -12
- package/dist/models-dev-MDI5E2YA.js +0 -3
- package/dist/provider-registry-4PH2JPIA.cjs +0 -40
- package/dist/provider-registry-VEJ3PN4S.js +0 -3
package/dist/harness/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
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(
|
|
42
|
-
|
|
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(
|
|
89
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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(
|
|
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.
|
|
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-
|
|
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
|
|
737
|
+
async listAvailableModels() {
|
|
598
738
|
try {
|
|
599
|
-
const { PROVIDER_REGISTRY } = await import('../provider-registry-
|
|
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-
|
|
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
|
|
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
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
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 (
|
|
1246
|
+
if (images?.length) {
|
|
1063
1247
|
messageInput = {
|
|
1064
1248
|
role: "user",
|
|
1065
1249
|
content: [
|
|
1066
1250
|
{ type: "text", text: content },
|
|
1067
|
-
...
|
|
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
|
|
1296
|
+
async listMessages(options) {
|
|
1109
1297
|
if (!this.currentThreadId) return [];
|
|
1110
|
-
return this.
|
|
1298
|
+
return this.listMessagesForThread({ threadId: this.currentThreadId, limit: options?.limit });
|
|
1111
1299
|
}
|
|
1112
|
-
async
|
|
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
|
-
|
|
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(
|
|
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(
|
|
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: (
|
|
1580
|
-
registerPlanApproval: (
|
|
1581
|
-
getSubagentModelId: (
|
|
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
|