@hmharness/agent 0.19.1 → 0.19.2
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/cognitive-tools.d.ts +11 -0
- package/dist/cognitive-tools.js +53 -0
- package/dist/tools.js +2 -0
- package/package.json +8 -8
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hmharness/agent - cognitive query tool (blueprint §18/UX-004 seed)
|
|
3
|
+
*
|
|
4
|
+
* Gives the LIVE model read access to its own accumulated world model:
|
|
5
|
+
* which tool types historically succeed, how calibrated its predictions
|
|
6
|
+
* are, and what the diagnosis layer thinks is worth learning. Read-only by
|
|
7
|
+
* design — the model cannot write beliefs; those update only from real
|
|
8
|
+
* trajectories (no self-grading channel).
|
|
9
|
+
*/
|
|
10
|
+
import type { Tool } from '@hmharness/kernel';
|
|
11
|
+
export declare const cognitiveQueryTool: Tool;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export const cognitiveQueryTool = {
|
|
2
|
+
name: 'cognitive_query',
|
|
3
|
+
description: 'Query the cognitive layer\'s accumulated knowledge about past runs: which action/tool types historically succeed (belief table with confidence and evidence counts), prediction calibration, planner-trusted action types, learning opportunities, and memory contradictions. Read-only. Args: focus=beliefs|calibration|diagnosis|memory (optional; omit for a summary).',
|
|
4
|
+
parameters: {
|
|
5
|
+
type: 'object',
|
|
6
|
+
properties: {
|
|
7
|
+
focus: { type: 'string', description: 'beliefs | calibration | diagnosis | memory (optional)' },
|
|
8
|
+
},
|
|
9
|
+
},
|
|
10
|
+
async execute(args, ctx) {
|
|
11
|
+
const focus = String(args.focus ?? 'summary');
|
|
12
|
+
try {
|
|
13
|
+
const { analyzeWorldModel, diagnoseOpportunities, CognitiveMemory } = await import('@hmharness/cognitive');
|
|
14
|
+
const lines = [];
|
|
15
|
+
if (focus === 'summary' || focus === 'beliefs') {
|
|
16
|
+
const wm = await analyzeWorldModel(ctx.home);
|
|
17
|
+
lines.push(`world model (${wm.trajectoriesReplayed} trajectories, ${wm.stepsReplayed} steps replayed):`);
|
|
18
|
+
if (wm.beliefs.length === 0)
|
|
19
|
+
lines.push(' (no beliefs yet — run a few tasks first)');
|
|
20
|
+
for (const b of wm.beliefs.slice(0, 12)) {
|
|
21
|
+
lines.push(` ${b.actionType.padEnd(24)} conf=${b.confidence.toFixed(2)} n=${b.evidenceCount}`);
|
|
22
|
+
}
|
|
23
|
+
if (focus === 'beliefs') {
|
|
24
|
+
lines.push(`planner gate: trusted=[${wm.plannerGate.trusted.join(',')}] untrusted=[${wm.plannerGate.untrusted.join(',')}] unknown=[${wm.plannerGate.unknown.join(',')}]`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (focus === 'summary' || focus === 'calibration') {
|
|
28
|
+
const wm = await analyzeWorldModel(ctx.home);
|
|
29
|
+
const cal = wm.calibration;
|
|
30
|
+
lines.push(`calibration: ${cal.resolved} resolved predictions${cal.meanError !== undefined ? `, mean |error|=${cal.meanError}` : ' (no predictions recorded yet — steps carry no confidence)'}`);
|
|
31
|
+
}
|
|
32
|
+
if (focus === 'summary' || focus === 'diagnosis') {
|
|
33
|
+
const d = await diagnoseOpportunities(ctx.home);
|
|
34
|
+
lines.push(`diagnosis (${d.trajectories} trajectories):`);
|
|
35
|
+
if (d.opportunities.length === 0)
|
|
36
|
+
lines.push(' (no learning opportunity meets the evidence threshold yet)');
|
|
37
|
+
for (const o of d.opportunities.slice(0, 6)) {
|
|
38
|
+
lines.push(` [${o.suggestedTargets.join('/')}] ${o.signal}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (focus === 'summary' || focus === 'memory') {
|
|
42
|
+
const mem = new CognitiveMemory(ctx.home);
|
|
43
|
+
await mem.load();
|
|
44
|
+
const stats = mem.stats();
|
|
45
|
+
lines.push(`memory: working:${stats.working} episodic:${stats.episodic} semantic:${stats.semantic} procedural:${stats.procedural} world:${stats.world}, contradictions pending: ${mem.detectContradictions().length}`);
|
|
46
|
+
}
|
|
47
|
+
return { output: lines.join('\n') };
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
return { output: 'cognitive_query failed: ' + String(err).slice(0, 200), isError: true };
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
};
|
package/dist/tools.js
CHANGED
|
@@ -9,6 +9,7 @@ import { copyFile, readFile, readdir, writeFile } from 'node:fs/promises';
|
|
|
9
9
|
import { isAbsolute, join, resolve } from 'node:path';
|
|
10
10
|
import { promisify } from 'node:util';
|
|
11
11
|
import { chatVision, homeDir, isBareProbe, isVisionRefusal, loadConfig, visionProviderChain } from '@hmharness/kernel';
|
|
12
|
+
import { cognitiveQueryTool } from "./cognitive-tools.js";
|
|
12
13
|
const execCb = promisify(exec);
|
|
13
14
|
const DENY_PATTERNS = [
|
|
14
15
|
// recursive deletes aimed at ROOT/HOME/SYSTEM targets only - relative
|
|
@@ -662,4 +663,5 @@ export const seeImageTool = {
|
|
|
662
663
|
export const baseTools = [
|
|
663
664
|
readFileTool, editFileTool, writeFileTool, listDirTool, runCommandTool, rememberTool, seeImageTool,
|
|
664
665
|
webSearchTool, webFetchTool, browserOpenTool, desktopScreenshotTool, desktopClickTool, desktopTypeTool, sshRunTool,
|
|
666
|
+
cognitiveQueryTool,
|
|
665
667
|
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hmharness/agent",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.2",
|
|
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.2",
|
|
19
|
+
"@hmharness/domain-harmony": "0.19.2",
|
|
20
|
+
"@hmharness/domain-ops": "0.19.2",
|
|
21
|
+
"@hmharness/evolution": "0.19.2",
|
|
22
|
+
"@hmharness/kernel": "0.19.2",
|
|
23
|
+
"@hmharness/observability": "0.19.2",
|
|
24
|
+
"@hmharness/sandbox": "0.19.2"
|
|
25
25
|
},
|
|
26
26
|
"files": [
|
|
27
27
|
"dist"
|