mu-harness 0.16.3 → 0.16.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/harness/npm/src/agents/parser.js +1 -0
- package/esm/harness/npm/src/agents/registry.js +1 -0
- package/esm/harness/npm/src/agents/types.d.ts +1 -0
- package/esm/harness/npm/src/hooks/merge-hooks.js +6 -2
- package/esm/harness/npm/src/hooks/types.d.ts +2 -1
- package/esm/harness/npm/src/session/agent-session.js +2 -1
- package/package.json +3 -3
- package/script/harness/npm/src/agents/parser.js +1 -0
- package/script/harness/npm/src/agents/registry.js +1 -0
- package/script/harness/npm/src/agents/types.d.ts +1 -0
- package/script/harness/npm/src/hooks/merge-hooks.js +6 -2
- package/script/harness/npm/src/hooks/types.d.ts +2 -1
- package/script/harness/npm/src/session/agent-session.js +2 -1
|
@@ -10,12 +10,16 @@ export const mergeHooks = (list) => {
|
|
|
10
10
|
if (hooks.some((h) => h.prepareRequest)) {
|
|
11
11
|
merged.prepareRequest = async (req) => {
|
|
12
12
|
let current = req;
|
|
13
|
+
let extra;
|
|
13
14
|
for (const h of hooks) {
|
|
14
15
|
const next = await h.prepareRequest?.(current);
|
|
15
|
-
if (next)
|
|
16
|
+
if (next) {
|
|
16
17
|
current = { system: next.system ?? current.system, tools: next.tools ?? current.tools };
|
|
18
|
+
if (next.messages?.length)
|
|
19
|
+
extra = [...(extra ?? []), ...next.messages];
|
|
20
|
+
}
|
|
17
21
|
}
|
|
18
|
-
return current;
|
|
22
|
+
return extra ? { ...current, messages: extra } : current;
|
|
19
23
|
};
|
|
20
24
|
}
|
|
21
25
|
if (hooks.some((h) => h.beforeToolCall)) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { ContentPart, Tool } from 'mu-core';
|
|
1
|
+
import type { ContentPart, Message, Tool } from 'mu-core';
|
|
2
2
|
export interface PreparedRequest {
|
|
3
3
|
system?: string;
|
|
4
4
|
tools?: Tool[];
|
|
5
|
+
messages?: Message[];
|
|
5
6
|
}
|
|
6
7
|
export interface AgentSessionHooks {
|
|
7
8
|
sessionStart?(): void | Promise<void>;
|
|
@@ -44,7 +44,8 @@ export const createAgentSession = (config) => {
|
|
|
44
44
|
const toolBlock = callTools.map((tool) => tool.prompt?.trim()).filter(Boolean).join('\n');
|
|
45
45
|
const effectiveSystem = [baseSystem, toolBlock].filter(Boolean).join('\n\n');
|
|
46
46
|
const body = hasSystem ? messages.slice(1) : messages;
|
|
47
|
-
const
|
|
47
|
+
const withSystem = effectiveSystem ? [systemMessage(effectiveSystem), ...body] : body;
|
|
48
|
+
const callMessages = prepared?.messages?.length ? [...withSystem, ...prepared.messages] : withSystem;
|
|
48
49
|
const events = run({
|
|
49
50
|
provider,
|
|
50
51
|
model: config.model,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mu-harness",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.4",
|
|
4
4
|
"description": "Agent harness: createHarness wires mu-core into a host — XDG paths, model registry, plugins, disk-loaded agents & skills, sub-agents, sessions (JSONL + SQLite catalog), slash commands, permission/approval hooks, an optional scheduler, and a composable TUI chat app",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./script/index.js",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@swc/wasm-typescript": "^1.15.0",
|
|
18
18
|
"croner": "^9.0.0",
|
|
19
|
-
"mu-core": "^0.16.
|
|
20
|
-
"mu-tui": "^0.16.
|
|
19
|
+
"mu-core": "^0.16.4",
|
|
20
|
+
"mu-tui": "^0.16.4"
|
|
21
21
|
},
|
|
22
22
|
"_generatedBy": "dnt@dev"
|
|
23
23
|
}
|
|
@@ -13,12 +13,16 @@ const mergeHooks = (list) => {
|
|
|
13
13
|
if (hooks.some((h) => h.prepareRequest)) {
|
|
14
14
|
merged.prepareRequest = async (req) => {
|
|
15
15
|
let current = req;
|
|
16
|
+
let extra;
|
|
16
17
|
for (const h of hooks) {
|
|
17
18
|
const next = await h.prepareRequest?.(current);
|
|
18
|
-
if (next)
|
|
19
|
+
if (next) {
|
|
19
20
|
current = { system: next.system ?? current.system, tools: next.tools ?? current.tools };
|
|
21
|
+
if (next.messages?.length)
|
|
22
|
+
extra = [...(extra ?? []), ...next.messages];
|
|
23
|
+
}
|
|
20
24
|
}
|
|
21
|
-
return current;
|
|
25
|
+
return extra ? { ...current, messages: extra } : current;
|
|
22
26
|
};
|
|
23
27
|
}
|
|
24
28
|
if (hooks.some((h) => h.beforeToolCall)) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { ContentPart, Tool } from 'mu-core';
|
|
1
|
+
import type { ContentPart, Message, Tool } from 'mu-core';
|
|
2
2
|
export interface PreparedRequest {
|
|
3
3
|
system?: string;
|
|
4
4
|
tools?: Tool[];
|
|
5
|
+
messages?: Message[];
|
|
5
6
|
}
|
|
6
7
|
export interface AgentSessionHooks {
|
|
7
8
|
sessionStart?(): void | Promise<void>;
|
|
@@ -47,7 +47,8 @@ const createAgentSession = (config) => {
|
|
|
47
47
|
const toolBlock = callTools.map((tool) => tool.prompt?.trim()).filter(Boolean).join('\n');
|
|
48
48
|
const effectiveSystem = [baseSystem, toolBlock].filter(Boolean).join('\n\n');
|
|
49
49
|
const body = hasSystem ? messages.slice(1) : messages;
|
|
50
|
-
const
|
|
50
|
+
const withSystem = effectiveSystem ? [systemMessage(effectiveSystem), ...body] : body;
|
|
51
|
+
const callMessages = prepared?.messages?.length ? [...withSystem, ...prepared.messages] : withSystem;
|
|
51
52
|
const events = (0, mu_core_1.run)({
|
|
52
53
|
provider,
|
|
53
54
|
model: config.model,
|