@hmharness/agent 0.14.17 → 0.14.19

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/i18n.d.ts CHANGED
@@ -74,6 +74,7 @@ export interface Strings {
74
74
  cmdNewDone: string;
75
75
  cmdFork: string;
76
76
  cmdCopy: string;
77
+ cmdExport: string;
77
78
  cmdMouse: string;
78
79
  cmdMouseOn: string;
79
80
  cmdMouseOff: string;
package/dist/i18n.js CHANGED
@@ -58,6 +58,7 @@ const zh = {
58
58
  cmdNewDone: '✓ 新会话开始(旧转录可用 Ctrl+T 回看)',
59
59
  cmdFork: 'fork 当前会话为新线程(继承全部上下文)',
60
60
  cmdCopy: '复制最后一条 AI 输出到剪贴板',
61
+ cmdExport: '一键导出整个会话为 Markdown 文件(~/.hmharness/exports/)',
61
62
  cmdMouse: '切换全时鼠标捕获(仅无滚轮翻译的终端需要;默认 ?1007 已覆盖大多数终端)',
62
63
  cmdMouseOn: '🖱 全时鼠标捕获已开启(滚轮直读;原生划选复制请按住 Shift 再拖动)',
63
64
  cmdMouseOff: '🖱 全时鼠标捕获已关闭(滚轮走终端方向键翻译;划选复制恢复原生)',
@@ -207,6 +208,7 @@ const en = {
207
208
  cmdNewDone: '✓ new session (old transcript: Ctrl+T to replay)',
208
209
  cmdFork: 'fork this session to a new thread (inherits full context)',
209
210
  cmdCopy: 'copy the last AI output to the clipboard',
211
+ cmdExport: 'export the whole session to a Markdown file (~/.hmharness/exports/)',
210
212
  cmdMouse: 'toggle full-time mouse capture (only for terminals without wheel translation; ?1007 covers most)',
211
213
  cmdMouseOn: '🖱 full-time mouse capture ON (direct wheel; hold Shift to select natively)',
212
214
  cmdMouseOff: '🖱 full-time mouse capture OFF (wheel via terminal translation; native selection restored)',
package/dist/index.d.ts CHANGED
@@ -9,3 +9,4 @@ export { buildRegistry, contextPack, makeApproval, nativeRegistry, runAgentTask,
9
9
  export * from './skills-conformance.ts';
10
10
  export * from './acp.ts';
11
11
  export * from './topology.ts';
12
+ export * from './meta-harness.ts';
package/dist/index.js CHANGED
@@ -9,3 +9,4 @@ export { buildRegistry, contextPack, makeApproval, nativeRegistry, runAgentTask,
9
9
  export * from "./skills-conformance.js";
10
10
  export * from "./acp.js";
11
11
  export * from "./topology.js";
12
+ export * from "./meta-harness.js";
@@ -0,0 +1,72 @@
1
+ /**
2
+ * @hmharness/agent - Harness-of-Harness (P3-03)
3
+ *
4
+ * The audit: "一个 meta-agent 专门设计候选 Harness,再由 independent evaluator 验收"
5
+ *
6
+ * A meta-agent that designs candidate harness configurations (tool sets,
7
+ * prompt strategies, agent topologies) which are then validated by an
8
+ * independent evaluator. This is the self-referential optimization loop.
9
+ */
10
+ export interface HarnessCandidate {
11
+ id: string;
12
+ name: string;
13
+ description: string;
14
+ /** what tools are available */
15
+ tools: string[];
16
+ /** system prompt template */
17
+ systemPrompt: string;
18
+ /** agent topology (single/dual/team/pipeline) */
19
+ topology: 'single' | 'dual' | 'team' | 'pipeline';
20
+ /** max turns budget */
21
+ maxTurns: number;
22
+ /** approval policy */
23
+ approvalPolicy: 'ask' | 'auto' | 'yolo';
24
+ /** generation metadata */
25
+ generatedBy: string;
26
+ generation: number;
27
+ }
28
+ export interface HarnessEvaluation {
29
+ candidateId: string;
30
+ /** independent evaluator's score [0,1] */
31
+ score: number;
32
+ /** specific strengths */
33
+ strengths: string[];
34
+ /** specific weaknesses */
35
+ weaknesses: string[];
36
+ /** recommended action */
37
+ recommendation: 'adopt' | 'reject' | 'iterate';
38
+ evaluatorId: string;
39
+ evaluatedAt: string;
40
+ }
41
+ export interface MetaHarnessIteration {
42
+ iteration: number;
43
+ candidates: HarnessCandidate[];
44
+ evaluations: HarnessEvaluation[];
45
+ bestCandidate?: HarnessCandidate;
46
+ improvement: number;
47
+ }
48
+ /**
49
+ * Generate a candidate harness variation from a base.
50
+ * Pure - testable.
51
+ */
52
+ export declare function generateCandidate(base: HarnessCandidate, mutation: Partial<HarnessCandidate>, generation: number): HarnessCandidate;
53
+ /**
54
+ * Evaluate a candidate (simulated independent evaluator).
55
+ * Pure - testable.
56
+ */
57
+ export declare function evaluateCandidate(candidate: HarnessCandidate, metrics: {
58
+ passRate: number;
59
+ avgTurns: number;
60
+ avgTokens: number;
61
+ safetyScore: number;
62
+ }): HarnessEvaluation;
63
+ /**
64
+ * Select the best candidate from evaluations.
65
+ * Pure - testable.
66
+ */
67
+ export declare function selectBest(candidates: HarnessCandidate[], evaluations: HarnessEvaluation[]): HarnessCandidate | undefined;
68
+ /**
69
+ * Run one iteration of the meta-harness loop.
70
+ * Pure - testable.
71
+ */
72
+ export declare function runIteration(iteration: number, candidates: HarnessCandidate[], allEvaluations: HarnessEvaluation[], previousBestScore: number): MetaHarnessIteration;
@@ -0,0 +1,79 @@
1
+ /**
2
+ * @hmharness/agent - Harness-of-Harness (P3-03)
3
+ *
4
+ * The audit: "一个 meta-agent 专门设计候选 Harness,再由 independent evaluator 验收"
5
+ *
6
+ * A meta-agent that designs candidate harness configurations (tool sets,
7
+ * prompt strategies, agent topologies) which are then validated by an
8
+ * independent evaluator. This is the self-referential optimization loop.
9
+ */
10
+ /**
11
+ * Generate a candidate harness variation from a base.
12
+ * Pure - testable.
13
+ */
14
+ export function generateCandidate(base, mutation, generation) {
15
+ return {
16
+ ...base,
17
+ ...mutation,
18
+ id: `cand-${generation}-${Date.now().toString(36).slice(-4)}`,
19
+ generation,
20
+ generatedBy: `meta-agent-gen-${generation}`,
21
+ };
22
+ }
23
+ /**
24
+ * Evaluate a candidate (simulated independent evaluator).
25
+ * Pure - testable.
26
+ */
27
+ export function evaluateCandidate(candidate, metrics) {
28
+ const strengths = [];
29
+ const weaknesses = [];
30
+ if (metrics.passRate > 0.7)
31
+ strengths.push(`high pass rate (${(metrics.passRate * 100).toFixed(0)}%)`);
32
+ else
33
+ weaknesses.push(`low pass rate (${(metrics.passRate * 100).toFixed(0)}%)`);
34
+ if (metrics.avgTurns < 10)
35
+ strengths.push(`efficient (${metrics.avgTurns.toFixed(1)} avg turns)`);
36
+ else
37
+ weaknesses.push(`too many turns (${metrics.avgTurns.toFixed(1)} avg)`);
38
+ if (metrics.safetyScore > 0.9)
39
+ strengths.push('safe operation');
40
+ else
41
+ weaknesses.push(`safety concerns (${(metrics.safetyScore * 100).toFixed(0)}%)`);
42
+ const score = metrics.passRate * 0.5 + Math.max(0, 1 - metrics.avgTurns / 30) * 0.2 + metrics.safetyScore * 0.3;
43
+ const recommendation = score > 0.7 ? 'adopt' : score > 0.4 ? 'iterate' : 'reject';
44
+ return {
45
+ candidateId: candidate.id,
46
+ score: Math.round(score * 100) / 100,
47
+ strengths, weaknesses,
48
+ recommendation,
49
+ evaluatorId: 'independent-evaluator-v1',
50
+ evaluatedAt: new Date().toISOString(),
51
+ };
52
+ }
53
+ /**
54
+ * Select the best candidate from evaluations.
55
+ * Pure - testable.
56
+ */
57
+ export function selectBest(candidates, evaluations) {
58
+ const evalMap = new Map(evaluations.map(e => [e.candidateId, e]));
59
+ const scored = candidates
60
+ .map(c => ({ candidate: c, score: evalMap.get(c.id)?.score ?? 0 }))
61
+ .sort((a, b) => b.score - a.score);
62
+ return scored[0]?.candidate;
63
+ }
64
+ /**
65
+ * Run one iteration of the meta-harness loop.
66
+ * Pure - testable.
67
+ */
68
+ export function runIteration(iteration, candidates, allEvaluations, previousBestScore) {
69
+ const evaluations = allEvaluations.filter(e => candidates.some(c => c.id === e.candidateId));
70
+ const best = selectBest(candidates, evaluations);
71
+ const bestScore = evaluations.find(e => e.candidateId === best?.id)?.score ?? 0;
72
+ return {
73
+ iteration,
74
+ candidates,
75
+ evaluations,
76
+ bestCandidate: best,
77
+ improvement: Math.round((bestScore - previousBestScore) * 1000) / 1000,
78
+ };
79
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hmharness/agent",
3
- "version": "0.14.17",
3
+ "version": "0.14.19",
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",
@@ -18,7 +18,7 @@
18
18
  "@hmharness/domain-harmony": "0.13.5",
19
19
  "@hmharness/domain-ops": "0.8.0",
20
20
  "@hmharness/evolution": "0.14.9",
21
- "@hmharness/kernel": "0.9.1",
21
+ "@hmharness/kernel": "0.9.7",
22
22
  "@hmharness/observability": "0.7.0",
23
23
  "@hmharness/sandbox": "0.8.0"
24
24
  },