@hmharness/agent 0.19.2 → 0.19.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/prompt.d.ts +3 -0
- package/dist/prompt.js +6 -0
- package/dist/runner.d.ts +1 -0
- package/dist/runner.js +9 -3
- package/package.json +8 -8
package/dist/prompt.d.ts
CHANGED
|
@@ -4,6 +4,9 @@ export declare function buildSystemPrompt(opts: {
|
|
|
4
4
|
memory: string;
|
|
5
5
|
skills: string;
|
|
6
6
|
insights: string;
|
|
7
|
+
/** world-model digest (trusted/flaky tools from run history; empty until
|
|
8
|
+
* enough evidence exists — blueprint M3 planner consumption) */
|
|
9
|
+
cognitive?: string;
|
|
7
10
|
model: string;
|
|
8
11
|
locale?: string;
|
|
9
12
|
agentsMd?: string;
|
package/dist/prompt.js
CHANGED
|
@@ -44,6 +44,12 @@ export function buildSystemPrompt(opts) {
|
|
|
44
44
|
if (opts.insights.trim()) {
|
|
45
45
|
parts.push('', '## Recent session outcomes (what worked / what failed)', opts.insights.trim());
|
|
46
46
|
}
|
|
47
|
+
// ---- Cognitive OS: world-model digest (blueprint M3) ----
|
|
48
|
+
// Statistical tool reliability from run history. Treat as evidence, not
|
|
49
|
+
// commands: a flaky tool deserves extra verification, not avoidance.
|
|
50
|
+
if (opts.cognitive?.trim()) {
|
|
51
|
+
parts.push('', '## Tool reliability (from run history)', opts.cognitive.trim());
|
|
52
|
+
}
|
|
47
53
|
// ---- Identity anchor (LAST — recency wins over 15K chars of instructions above;
|
|
48
54
|
// flash-class models have strong built-in identities that override a single
|
|
49
55
|
// "You are hmh" at the top. Repeating + anchoring at the end fixes it.) ----
|
package/dist/runner.d.ts
CHANGED
package/dist/runner.js
CHANGED
|
@@ -126,9 +126,9 @@ export async function contextPack(task, sessionId, opts = {}) {
|
|
|
126
126
|
// injection entirely — the model doesn't need them for "你好" and they add
|
|
127
127
|
// ~4K tokens of noise that dilutes the identity anchor
|
|
128
128
|
if (isTrivialTask(task)) {
|
|
129
|
-
return { memory: '', skills: '', insights: '', skillsInjected: [] };
|
|
129
|
+
return { memory: '', skills: '', insights: '', cognitive: '', skillsInjected: [] };
|
|
130
130
|
}
|
|
131
|
-
const [memory, skills, insights] = await Promise.all([
|
|
131
|
+
const [memory, skills, insights, cognitive] = await Promise.all([
|
|
132
132
|
retrieveMemory(home, task, { workspace: opts.workspace ?? undefined, embedding: opts.embedding }),
|
|
133
133
|
listSkills(home),
|
|
134
134
|
// 2026-09-27 plan A: experience retrieval - the K most RELEVANT past
|
|
@@ -138,6 +138,10 @@ export async function contextPack(task, sessionId, opts = {}) {
|
|
|
138
138
|
// Plan C: cross-project lessons stay retrievable but carry their
|
|
139
139
|
// origin stamp ([来自项目:X]) so the model can weigh them.
|
|
140
140
|
retrieveInsights(home, task, { workspace: opts.workspace ?? undefined }),
|
|
141
|
+
// blueprint M3: the world model feeds the planner — which tools history
|
|
142
|
+
// trusts/distrusts lands in the system prompt (empty until ≥3 steps of
|
|
143
|
+
// evidence exist, so cold starts see nothing)
|
|
144
|
+
import('@hmharness/cognitive').then((m) => m.buildContextDigest(home)).catch(() => ''),
|
|
141
145
|
]);
|
|
142
146
|
let canaryBlock = '';
|
|
143
147
|
let canaryNames = [];
|
|
@@ -148,7 +152,7 @@ export async function contextPack(task, sessionId, opts = {}) {
|
|
|
148
152
|
canaryBlock = canaryWatermark(canaryNames) + '\n' + skillsToPrompt(canary);
|
|
149
153
|
}
|
|
150
154
|
}
|
|
151
|
-
return { memory, skills: skillsToPrompt(skills) + (canaryBlock ? '\n' + canaryBlock : ''), insights, skillsInjected: [...skills.map((s) => s.name), ...canaryNames] };
|
|
155
|
+
return { memory, skills: skillsToPrompt(skills) + (canaryBlock ? '\n' + canaryBlock : ''), insights, cognitive, skillsInjected: [...skills.map((s) => s.name), ...canaryNames] };
|
|
152
156
|
}
|
|
153
157
|
export function loadApprovedRules(home) {
|
|
154
158
|
try {
|
|
@@ -302,6 +306,7 @@ export async function runAgentTask(opts) {
|
|
|
302
306
|
memory: pack.memory,
|
|
303
307
|
skills: pack.skills,
|
|
304
308
|
insights: pack.insights,
|
|
309
|
+
...(pack.cognitive ? { cognitive: pack.cognitive } : {}),
|
|
305
310
|
model: cfg.provider.model,
|
|
306
311
|
locale: cfg.locale,
|
|
307
312
|
agentsMd: agentsMd ?? undefined,
|
|
@@ -319,6 +324,7 @@ export async function runAgentTask(opts) {
|
|
|
319
324
|
memoryChars: pack.memory.length,
|
|
320
325
|
skills: pack.skills.length,
|
|
321
326
|
insights: pack.insights.length,
|
|
327
|
+
cognitiveChars: pack.cognitive.length,
|
|
322
328
|
});
|
|
323
329
|
await session.user(opts.task);
|
|
324
330
|
// YOLO fix: when yes=true the caller's approvalAsk (TUI dialog, web remote
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hmharness/agent",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.3",
|
|
4
4
|
"description": "hmharness agent execution layer: base tools, system prompt, sub-agent spawn, and the shared task runner that frontends (cli, web) drive.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -15,13 +15,13 @@
|
|
|
15
15
|
"build": "tsc -p tsconfig.build.json"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@hmharness/cognitive": "0.19.
|
|
19
|
-
"@hmharness/domain-harmony": "0.19.
|
|
20
|
-
"@hmharness/domain-ops": "0.19.
|
|
21
|
-
"@hmharness/evolution": "0.19.
|
|
22
|
-
"@hmharness/kernel": "0.19.
|
|
23
|
-
"@hmharness/observability": "0.19.
|
|
24
|
-
"@hmharness/sandbox": "0.19.
|
|
18
|
+
"@hmharness/cognitive": "0.19.3",
|
|
19
|
+
"@hmharness/domain-harmony": "0.19.3",
|
|
20
|
+
"@hmharness/domain-ops": "0.19.3",
|
|
21
|
+
"@hmharness/evolution": "0.19.3",
|
|
22
|
+
"@hmharness/kernel": "0.19.3",
|
|
23
|
+
"@hmharness/observability": "0.19.3",
|
|
24
|
+
"@hmharness/sandbox": "0.19.3"
|
|
25
25
|
},
|
|
26
26
|
"files": [
|
|
27
27
|
"dist"
|