@hmharness/agent 0.8.4 → 0.9.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/dist/runner.js +43 -1
- package/package.json +3 -3
package/dist/runner.js
CHANGED
|
@@ -10,7 +10,8 @@ import { brief, createTrajectoryRecorder } from '@hmharness/observability';
|
|
|
10
10
|
import { readFile } from 'node:fs/promises';
|
|
11
11
|
import { readFileSync, writeFileSync } from 'node:fs';
|
|
12
12
|
import { join, dirname } from 'node:path';
|
|
13
|
-
import {
|
|
13
|
+
import { extractFeatures, routeDecision, recordRoutingOutcome } from '@hmharness/kernel';
|
|
14
|
+
import { appendMemory, listSkills, readInsights, readNotes, recentInsights, recordInsight, redactSecrets, retrieveMemory, skillsToPrompt, sessionGetsCanary, canaryWatermark, listCanary, workspaceForCwd } from '@hmharness/evolution';
|
|
14
15
|
import { harmonyTools } from '@hmharness/domain-harmony';
|
|
15
16
|
import { opsTools } from '@hmharness/domain-ops';
|
|
16
17
|
import * as readline from 'node:readline/promises';
|
|
@@ -238,6 +239,26 @@ export async function runAgentTask(opts) {
|
|
|
238
239
|
// are swallowed inside the recorder and can never fail the task itself.
|
|
239
240
|
const traj = createTrajectoryRecorder(ctx.home, { task: opts.task, model: cfg.provider.model, cwd: ctx.cwd });
|
|
240
241
|
traj.emit('run.started', 'user', { task: brief(opts.task, 400) });
|
|
242
|
+
// V2 M10 shadow router: log what the adaptive router WOULD pick vs the live
|
|
243
|
+
// static route - data for a later, gated switch (never steers traffic now)
|
|
244
|
+
{
|
|
245
|
+
const routing = cfg.routing ?? {};
|
|
246
|
+
const features = extractFeatures(opts.task);
|
|
247
|
+
const sug = routeDecision(features, {
|
|
248
|
+
actual: routing.chat ?? 'default',
|
|
249
|
+
harmonyRoute: routing['chat-harmony'],
|
|
250
|
+
heavyRoute: routing['chat-heavy'],
|
|
251
|
+
defaultRoute: routing.chat ?? 'default',
|
|
252
|
+
});
|
|
253
|
+
void recordRoutingOutcome(ctx.home, {
|
|
254
|
+
time: new Date().toISOString(),
|
|
255
|
+
task: redactSecrets(opts.task).slice(0, 400),
|
|
256
|
+
features: sug.features,
|
|
257
|
+
actual: sug.actual,
|
|
258
|
+
suggested: sug.suggested,
|
|
259
|
+
reason: sug.reason,
|
|
260
|
+
}).catch(() => undefined);
|
|
261
|
+
}
|
|
241
262
|
// workspace scoping + optional embedding hybrid for memory retrieval.
|
|
242
263
|
// Embeddings only when routing.embedding is EXPLICITLY set - an inherited
|
|
243
264
|
// chat route would 404 on /embeddings once per task for nothing.
|
|
@@ -355,6 +376,27 @@ export async function runAgentTask(opts) {
|
|
|
355
376
|
throw err;
|
|
356
377
|
});
|
|
357
378
|
traj.finish({ success: result.reason === 'final', reason: result.reason }, { turns: result.turns, toolUses: result.toolUses, promptTokens: result.usage.promptTokens, completionTokens: result.usage.completionTokens });
|
|
379
|
+
// routing.outcome backfill: did the ACTUAL route succeed? (shadow stats)
|
|
380
|
+
{
|
|
381
|
+
const routing = cfg.routing ?? {};
|
|
382
|
+
const features = extractFeatures(opts.task);
|
|
383
|
+
const sug = routeDecision(features, {
|
|
384
|
+
actual: routing.chat ?? 'default',
|
|
385
|
+
harmonyRoute: routing['chat-harmony'],
|
|
386
|
+
heavyRoute: routing['chat-heavy'],
|
|
387
|
+
defaultRoute: routing.chat ?? 'default',
|
|
388
|
+
});
|
|
389
|
+
void recordRoutingOutcome(ctx.home, {
|
|
390
|
+
time: new Date().toISOString(),
|
|
391
|
+
task: redactSecrets(opts.task).slice(0, 400),
|
|
392
|
+
features: sug.features,
|
|
393
|
+
actual: sug.actual,
|
|
394
|
+
suggested: sug.suggested,
|
|
395
|
+
reason: sug.reason,
|
|
396
|
+
outcome: result.reason === 'final' ? 'ok' : result.reason,
|
|
397
|
+
tokens: result.usage.promptTokens + result.usage.completionTokens,
|
|
398
|
+
}).catch(() => undefined);
|
|
399
|
+
}
|
|
358
400
|
// ---- instant feedback: learn from THIS task's mistakes, not 8 tasks later ----
|
|
359
401
|
// Tier 1 (always, zero cost): raw error pattern → memory self-note. Lowered
|
|
360
402
|
// to 1 failure for system-level patterns (shell incompat, auth, missing
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hmharness/agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
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",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@hmharness/domain-harmony": "0.8.0",
|
|
19
19
|
"@hmharness/domain-ops": "0.8.0",
|
|
20
|
-
"@hmharness/evolution": "0.
|
|
21
|
-
"@hmharness/kernel": "0.
|
|
20
|
+
"@hmharness/evolution": "0.9.0",
|
|
21
|
+
"@hmharness/kernel": "0.9.0",
|
|
22
22
|
"@hmharness/observability": "0.7.0",
|
|
23
23
|
"@hmharness/sandbox": "0.8.0"
|
|
24
24
|
},
|