@hmharness/agent 0.1.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/i18n.d.ts ADDED
@@ -0,0 +1,105 @@
1
+ /**
2
+ * @hmharness/agent - i18n
3
+ * UI-chrome strings for both frontends (cli, web), keyed and bilingual.
4
+ * Locale comes from HmhConfig.locale (default zh). Tool descriptions and
5
+ * model output stay as-is: models answer in the user's language already.
6
+ */
7
+ export type Locale = 'zh' | 'en';
8
+ export interface Strings {
9
+ replHint: string;
10
+ sessionFooter: (id: string, turns: number, toolUses: number) => string;
11
+ approvalPrompt: (name: string, brief: string) => string;
12
+ approvalDeniedNoTty: (name: string, brief: string) => string;
13
+ approvalLabel: (name: string, granted: boolean) => string;
14
+ active: string;
15
+ drafts: string;
16
+ none: string;
17
+ pass: string;
18
+ fail: string;
19
+ promoted: string;
20
+ rejected: string;
21
+ errorLabel: string;
22
+ evolveCycle: (model: string, n: number) => string;
23
+ nextCycleIn: (min: number) => string;
24
+ webTitle: string;
25
+ idle: string;
26
+ running: string;
27
+ modeYolo: string;
28
+ modeAutoShort: string;
29
+ send: string;
30
+ approve: string;
31
+ deny: string;
32
+ approvalRequest: string;
33
+ skillsHeading: string;
34
+ sessionsHeading: string;
35
+ insightsHeading: string;
36
+ evolutionHeading: string;
37
+ inputPlaceholder: string;
38
+ done: (turns: number, toolUses: number, session: string) => string;
39
+ sessionEnd: (id: string) => string;
40
+ freshBelow: string;
41
+ noCycles: string;
42
+ alreadyRunning: string;
43
+ viewingNote: string;
44
+ tuiNeedsTty: string;
45
+ tuiWelcome: (model: string) => string;
46
+ tuiApproval: string;
47
+ tuiApprove: string;
48
+ tuiDeny: string;
49
+ tuiApprovalHint: string;
50
+ tuiHints: string;
51
+ /** live label while the model thinks (TUI) */
52
+ thinking: string;
53
+ /** final label after thinking folds away (TUI) */
54
+ thought: string;
55
+ /** busy spinner text, shown in the input-box status line (TUI) */
56
+ tuiRunning: string;
57
+ cmdModelHint: string;
58
+ /** palette footer key hint: how to drive the slash/model picker (TUI) */
59
+ panelHint: string;
60
+ cmdModelPreset: (name: string, envVar: string) => string;
61
+ cmdProvidersListed: string;
62
+ /** tail hint after a bare /providers listing (TUI) */
63
+ cmdProvidersScanHint: string;
64
+ /** streaming label in front of reasoning output (REPL one-shot) */
65
+ thinkingLabel: string;
66
+ cmdProvidersNone: string;
67
+ cmdProvidersAdded: (n: number, names: string) => string;
68
+ tuiScrolled: string;
69
+ tuiWebHint: string;
70
+ tuiRadarScanning: string;
71
+ tuiEvolveDone: (proposals: number, insights: number, notes: number) => string;
72
+ tuiPassRate: (pct: string) => string;
73
+ tuiStatus: (locale: string, skills: number, model: string) => string;
74
+ tuiSkills: string;
75
+ cmdHelp: string;
76
+ /** REPL feedback for a slash command that does not exist */
77
+ unknownCommand: (line: string) => string;
78
+ /** REPL /clear confirmation */
79
+ cmdClearDone: string;
80
+ cmdTools: string;
81
+ cmdSkills: string;
82
+ cmdModel: string;
83
+ cmdLang: string;
84
+ langSwitched: (locale: string) => string;
85
+ cmdYolo: string;
86
+ yoloOn: string;
87
+ yoloOff: string;
88
+ cmdProviders: string;
89
+ cmdOps: string;
90
+ cmdOpsScan: string;
91
+ cmdBench: string;
92
+ cmdEvolve: string;
93
+ cmdMcp: string;
94
+ cmdStatus: string;
95
+ cmdClear: string;
96
+ cmdWeb: string;
97
+ cmdExit: string;
98
+ helpAlias: string;
99
+ webStarted: (port: number, log: string) => string;
100
+ webStopped: string;
101
+ webNotRunning: string;
102
+ webRunning: (pid: number, port: number) => string;
103
+ tuiWebLinked: (port: number) => string;
104
+ }
105
+ export declare function strings(locale?: Locale): Strings;
package/dist/i18n.js ADDED
@@ -0,0 +1,181 @@
1
+ const zh = {
2
+ replHint: '输入任务,/exit 退出',
3
+ sessionFooter: (id, turns, uses) => `(会话 ${id} · ${turns} 轮 · ${uses} 次工具调用)`,
4
+ approvalPrompt: (name, brief) => ` [审批] ${name} ${brief} — 执行吗? [y/N] `,
5
+ approvalDeniedNoTty: (name, brief) => ` [审批] ${name} ${brief} — 已拒绝(非交互环境;用 --yes 允许)`,
6
+ approvalLabel: (name, granted) => ` [审批 ${name}: ${granted ? '已批准' : '已拒绝'}]`,
7
+ active: 'active',
8
+ drafts: 'drafts',
9
+ none: '(无)',
10
+ pass: '通过',
11
+ fail: '失败',
12
+ promoted: '已晋升',
13
+ rejected: '已拒绝',
14
+ errorLabel: '错误',
15
+ evolveCycle: (model, n) => `evolve · 模型 ${model} · 第 ${n} 轮`,
16
+ nextCycleIn: (min) => `下一轮将在 ${min} 分钟后( Ctrl-C 停止)`,
17
+ webTitle: 'hmh web',
18
+ idle: '空闲',
19
+ running: '运行中…',
20
+ modeYolo: '🔥 YOLO(全自动)',
21
+ modeAutoShort: '自动',
22
+ send: '运行',
23
+ approve: '批准',
24
+ deny: '拒绝',
25
+ approvalRequest: '审批请求:',
26
+ skillsHeading: '技能库',
27
+ sessionsHeading: '最近会话',
28
+ insightsHeading: '近期洞察',
29
+ evolutionHeading: '进化记录',
30
+ inputPlaceholder: '给 hmh 一个任务… (Enter 发送, Shift+Enter 换行)',
31
+ done: (turns, uses, session) => `(完成 · ${turns} 轮 · ${uses} 次工具调用 · 会话 ${session})`,
32
+ sessionEnd: (id) => `--- 会话结束: ${id} ---`,
33
+ freshBelow: '--- (以下新任务将开始全新对话) ---',
34
+ noCycles: '(尚无进化轮次)',
35
+ alreadyRunning: '已有一个任务在运行',
36
+ viewingNote: '正在查看历史会话',
37
+ tuiNeedsTty: 'hmh tui 需要交互终端(raw mode)。非交互环境请用:hmh "任务"(一次性)或 hmh web(浏览器)。',
38
+ tuiWelcome: (model) => `hmh tui · ${model} · 输入 / 查看命令 · 直接输入任务回车运行`,
39
+ tuiApproval: '⚠ 审批',
40
+ tuiApprove: '批准',
41
+ tuiDeny: '拒绝',
42
+ tuiApprovalHint: 'enter/y 批准 · esc/n 拒绝',
43
+ tuiHints: 'enter 发送 · 滚轮/↑↓ 翻页 · ^P/^N 历史 · esc 清空 · 拖选复制 · ^C 退出 · /help',
44
+ thinking: '思考中',
45
+ thought: '已完成思考',
46
+ tuiRunning: '运行中…',
47
+ cmdModelHint: '切换 chat 路由: /model <name>',
48
+ panelHint: '↑↓/滚轮/点击 选择 · Enter 确认 · Esc 关闭',
49
+ cmdModelPreset: (name, envVar) => `${name} 尚未配置 — 设置 ${envVar} 后运行 /providers scan 添加`,
50
+ cmdProvidersListed: '未探测到新的本地厂商(环境变量/opencode 配置)',
51
+ cmdProvidersScanHint: '/providers scan 将它们写入配置',
52
+ thinkingLabel: '[思考中] ',
53
+ cmdProvidersNone: '未探测到新的厂商;已配置: ',
54
+ cmdProvidersAdded: (n, names) => `已添加 ${n} 个厂商: ${names} — /model <name> 启用`,
55
+ tuiScrolled: '↑ 已上滚 · PgDn/End/滚轮 回底',
56
+ tuiWebHint: '浏览器界面: 在另一个终端运行 hmh web --port=7788',
57
+ tuiRadarScanning: '雷达扫描中…',
58
+ tuiEvolveDone: (p, i, n) => `evolve 完成: ${p} 提案 · 洞察 ${i} · 记忆 ${n}`,
59
+ tuiPassRate: (pct) => `pass rate: ${pct}`,
60
+ tuiStatus: (locale, skills, model) => `${locale} · ${skills} 技能 · ${model}`,
61
+ tuiSkills: '技能',
62
+ cmdHelp: '命令帮助',
63
+ unknownCommand: (l) => `未知命令: ${l} (/help 查看全部)`,
64
+ cmdClearDone: '✓ 对话已清空,下一条任务从全新上下文开始',
65
+ cmdTools: '已注册工具(gated 标记)',
66
+ cmdSkills: '技能库(启用 + 草稿)',
67
+ cmdModel: '切换模型路由(输入 /model 回车打开选择面板)',
68
+ cmdLang: '切换界面语言(/lang zh|en,省略则在中文/English 间切换)',
69
+ langSwitched: (l) => `界面语言 → ${l === 'zh' ? '中文' : 'English'}`,
70
+ cmdYolo: '切换全自动 YOLO(/yolo on|off;危险命令仍硬拒)',
71
+ yoloOn: '🔥 YOLO 已开启:后续任务全自动,不再弹审批(破坏性命令仍硬拒)',
72
+ yoloOff: '🔒 已回到审批询问模式',
73
+ cmdProviders: '探测本地密钥并自动添加厂商(/providers scan)',
74
+ cmdOps: '运维看板状态',
75
+ cmdOpsScan: '扫描生态雷达并生成简报',
76
+ cmdBench: '快速基准(非 loop 用例)',
77
+ cmdEvolve: '运行一轮自进化循环',
78
+ cmdMcp: '已配置 MCP 服务器',
79
+ cmdStatus: '刷新状态',
80
+ cmdClear: '清空转录',
81
+ cmdWeb: '提示启动浏览器界面',
82
+ cmdExit: '退出',
83
+ helpAlias: '? 同义',
84
+ webStarted: (port, log) => `hmh web 已后台启动 → http://127.0.0.1:${port}\n日志 ${log}\n状态 hmh web status · 停止 hmh web stop`,
85
+ webStopped: 'hmh web 已停止',
86
+ webNotRunning: 'hmh web 未在运行',
87
+ webRunning: (pid, port) => `hmh web 运行中 (pid ${pid}) → http://127.0.0.1:${port}`,
88
+ tuiWebLinked: (port) => `网页端已就绪 → http://127.0.0.1:${port}(本对话可在浏览器继续;hmh web stop 停止)`,
89
+ };
90
+ const en = {
91
+ replHint: 'type a task, or /exit to quit',
92
+ sessionFooter: (id, turns, uses) => `(session ${id} · ${turns} turns · ${uses} tool uses)`,
93
+ approvalPrompt: (name, brief) => ` [approval] ${name} ${brief} — run it? [y/N] `,
94
+ approvalDeniedNoTty: (name, brief) => ` [approval] ${name} ${brief} — denied (no TTY; use --yes to allow)`,
95
+ approvalLabel: (name, granted) => ` [approval ${name}: ${granted ? 'granted' : 'DENIED'}]`,
96
+ active: 'active',
97
+ drafts: 'drafts',
98
+ none: '(none)',
99
+ pass: 'PASS',
100
+ fail: 'FAIL',
101
+ promoted: 'PROMOTED',
102
+ rejected: 'REJECTED',
103
+ errorLabel: 'ERROR',
104
+ evolveCycle: (model, n) => `evolve · model ${model} · cycle ${n}`,
105
+ nextCycleIn: (min) => `next cycle in ${min} min (Ctrl-C to stop)`,
106
+ webTitle: 'hmh web',
107
+ idle: 'idle',
108
+ running: 'running…',
109
+ modeYolo: '🔥 YOLO (hands-free)',
110
+ modeAutoShort: 'auto',
111
+ send: 'Run',
112
+ approve: 'Approve',
113
+ deny: 'Deny',
114
+ approvalRequest: 'Approval request:',
115
+ skillsHeading: 'skills',
116
+ sessionsHeading: 'recent sessions',
117
+ insightsHeading: 'insights',
118
+ evolutionHeading: 'evolution',
119
+ inputPlaceholder: 'give hmh a task… (Enter to send, Shift+Enter for newline)',
120
+ done: (turns, uses, session) => `(done · ${turns} turns · ${uses} tool uses · session ${session})`,
121
+ sessionEnd: (id) => `--- end of session ${id} ---`,
122
+ freshBelow: '--- (new tasks below start a fresh conversation) ---',
123
+ noCycles: '(no cycles yet)',
124
+ alreadyRunning: 'a task is already running',
125
+ viewingNote: 'viewing a past session',
126
+ tuiNeedsTty: 'hmh tui needs an interactive terminal (raw mode). Non-interactive: use hmh "task" (one-shot) or hmh web (browser).',
127
+ tuiWelcome: (model) => `hmh tui · ${model} · type / for commands · type a task and press Enter to run`,
128
+ tuiApproval: '⚠ approval',
129
+ tuiApprove: 'Approve',
130
+ tuiDeny: 'Deny',
131
+ tuiApprovalHint: 'enter/y approve · esc/n deny',
132
+ tuiHints: 'enter send · wheel/arrows scroll · ^P/^N history · esc clear · drag to copy · ^C quit · /help',
133
+ thinking: 'thinking',
134
+ thought: 'thought (done)',
135
+ tuiRunning: 'running…',
136
+ cmdModelHint: 'switch chat route: /model <name>',
137
+ panelHint: '↑↓ / wheel / click to select · Enter confirms · Esc closes',
138
+ cmdModelPreset: (name, envVar) => `${name} not configured - set ${envVar}, then run /providers scan`,
139
+ cmdProvidersListed: 'no new local providers detected (env vars / opencode config)',
140
+ cmdProvidersScanHint: '/providers scan writes them into the config',
141
+ thinkingLabel: '[thinking] ',
142
+ cmdProvidersNone: 'no new providers found; configured: ',
143
+ cmdProvidersAdded: (n, names) => `added ${n} providers: ${names} - enable via /model <name>`,
144
+ tuiScrolled: '↑ scrolled up · PgDn/End/wheel back to bottom',
145
+ tuiWebHint: 'web UI: run hmh web --port=7788 in another terminal',
146
+ tuiRadarScanning: 'scanning radar…',
147
+ tuiEvolveDone: (p, i, n) => `evolve done: ${p} proposals · ${i} insights · ${n} notes`,
148
+ tuiPassRate: (pct) => `pass rate: ${pct}`,
149
+ tuiStatus: (locale, skills, model) => `${locale} · ${skills} skills · ${model}`,
150
+ tuiSkills: 'skills',
151
+ cmdHelp: 'command help',
152
+ unknownCommand: (l) => `unknown command: ${l} (/help lists all)`,
153
+ cmdClearDone: '✓ conversation cleared; the next task starts a fresh context',
154
+ cmdTools: 'registered tools (gated marked)',
155
+ cmdSkills: 'skill library (active + drafts)',
156
+ cmdModel: 'switch model route (type /model + Enter opens the picker)',
157
+ cmdLang: 'switch UI language (/lang zh|en; bare toggles)',
158
+ langSwitched: (l) => `UI language → ${l === 'zh' ? '中文' : 'English'}`,
159
+ cmdYolo: 'toggle hands-free YOLO (/yolo on|off; destructive hard-deny stays)',
160
+ yoloOn: '🔥 YOLO on: tasks run unattended, no approval cards (destructive hard-deny stays)',
161
+ yoloOff: '🔒 back to ask-approval mode',
162
+ cmdProviders: 'detect local keys and add providers (/providers scan)',
163
+ cmdOps: 'ops keeper status',
164
+ cmdOpsScan: 'scan the ecosystem radar and write a brief',
165
+ cmdBench: 'quick bench (non-loop cases)',
166
+ cmdEvolve: 'run one self-evolution cycle',
167
+ cmdMcp: 'configured MCP servers',
168
+ cmdStatus: 'refresh status',
169
+ cmdClear: 'clear the transcript',
170
+ cmdWeb: 'hint to launch the web UI',
171
+ cmdExit: 'quit',
172
+ helpAlias: '? alias',
173
+ webStarted: (port, log) => `hmh web started in the background -> http://127.0.0.1:${port}\nlog ${log}\nstatus: hmh web status · stop: hmh web stop`,
174
+ webStopped: 'hmh web stopped',
175
+ webNotRunning: 'hmh web is not running',
176
+ webRunning: (pid, port) => `hmh web running (pid ${pid}) -> http://127.0.0.1:${port}`,
177
+ tuiWebLinked: (port) => `web UI ready -> http://127.0.0.1:${port} (this conversation continues in the browser; hmh web stop to stop)`,
178
+ };
179
+ export function strings(locale = 'zh') {
180
+ return locale === 'en' ? en : zh;
181
+ }
@@ -0,0 +1,5 @@
1
+ export { baseTools, readFileTool, writeFileTool, listDirTool, runCommandTool, rememberTool, seeImageTool } from './tools.ts';
2
+ export { buildSystemPrompt } from './prompt.ts';
3
+ export { strings, type Locale, type Strings } from './i18n.ts';
4
+ export { makeSpawnTool, MAX_SPAWN_DEPTH, type SpawnBase } from './spawn.ts';
5
+ export { buildRegistry, contextPack, makeApproval, nativeRegistry, runAgentTask, spawnBase, toServerConfig, type AgentTaskOptions, type RunnerEvents, } from './runner.ts';
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export { baseTools, readFileTool, writeFileTool, listDirTool, runCommandTool, rememberTool, seeImageTool } from "./tools.js";
2
+ export { buildSystemPrompt } from "./prompt.js";
3
+ export { strings } from "./i18n.js";
4
+ export { makeSpawnTool, MAX_SPAWN_DEPTH } from "./spawn.js";
5
+ export { buildRegistry, contextPack, makeApproval, nativeRegistry, runAgentTask, spawnBase, toServerConfig, } from "./runner.js";
@@ -0,0 +1,9 @@
1
+ export declare function buildSystemPrompt(opts: {
2
+ cwd: string;
3
+ home: string;
4
+ memory: string;
5
+ skills: string;
6
+ insights: string;
7
+ model: string;
8
+ locale?: string;
9
+ }): string;
package/dist/prompt.js ADDED
@@ -0,0 +1,20 @@
1
+ import { homedir } from 'node:os';
2
+ export function buildSystemPrompt(opts) {
3
+ const parts = [];
4
+ const isWin = process.platform === 'win32';
5
+ parts.push(`You are hmh, a coding agent powered by ${opts.model}, running on hmharness - a self-evolving agent framework designed for the full HarmonyOS development lifecycle. Working directory: ${opts.cwd}.`, '', opts.locale === 'en'
6
+ ? 'Reply in the language the user writes in (English by default).'
7
+ : '回复语言跟随用户(默认使用中文)。', '', '## Host environment (facts - rely on these, do not guess)', `- OS: ${process.platform} (${process.arch}). The run_command tool executes through ${isWin ? 'cmd.exe (Windows cmd - NOT bash, NOT PowerShell)' : '/bin/sh'}.`, isWin
8
+ ? '- cmd.exe has NO grep/head/tail/ls/cat/$(...) and wmic may be absent. Use: findstr (search), "more" or node -e (head/text ops), dir /b (ls), type (cat), where (which). For anything richer: powershell -NoProfile -Command "..."'
9
+ : '- standard POSIX utilities are available.', `- npm workspaces monorepo; agent state lives in HMH_HOME (${opts.home}): config.json, memory, skills, insights, sessions.`, '- Investigate before asking the user: read environment variables (any *API_KEY), check listening ports (netstat -ano | findstr LISTENING) and probe http://127.0.0.1:<port>/v1/models to discover local services. Never scan a whole drive (dir /s /b from a root) - it times out; search specific directories instead.', '', '## Where tools and skills live on this machine (check these FIRST when asked "is X installed")', `Other agent frameworks share this machine; their skills/plugins/tools are at known paths under the home directory. When asked to check whether a tool/skill/package is installed, or to find/configure an existing one, probe these locations (in order) before concluding "not installed":`, `- ~/.zcode/skills/<name>/ (ZCode skills with SKILL.md, scripts/, .env)`, `- ~/.claude/skills/<name>/ (Claude Code skills with SKILL.md, scripts/)`, `- ~/.codex/skills/<name>/ (Codex skills with SKILL.md, scripts/)`, `- ~/.dsh/skills/<name>/ and ~/.dsh-hm/skills/<name>/ (deepseek-harness skills)`, `- ~/.jcode/skills/<name>/ (JCode skills)`, `- ~/.agent-reach-venv/ and ~/.agent-reach/tools/ (Agent Reach CLI + platform tools)`, `- ~/.local/bin/ (user-installed executables; PATH may not include it - check dir /b not just where)`, `Home directory: ${homedir()}`, 'When found, read the tool\'s SKILL.md or README.md for its usage; copy or reference its scripts rather than reinventing. If the user asks to "configure it for hmharness", check whether it exposes an MCP endpoint (add to config.json mcpServers), an HTTP API (add a provider), or a CLI (register as a skill via `hmh skills add <path>`).', '', 'HarmonyOS development is your home domain: DevEco Studio toolchain, hvigor builds, ohpm packages, hdc devices, ArkTS/ArkUI, OpenHarmony and Cangjie. When a task touches it, prefer the harmony_* tools and precise toolchain knowledge.', '', 'Working style: read before writing; prefer small focused commands; verify results; state tradeoffs briefly. For risky operations (deleting, overwriting, publishing) say what will happen first. When a command fails twice with the same error, switch strategy instead of repeating it. For multi-line/quoted logic, write a temp .cjs file and run it with node - never fight cmd.exe quoting with node -e one-liners.');
10
+ if (opts.memory.trim()) {
11
+ parts.push('', '## Long-term memory', opts.memory.trim());
12
+ }
13
+ if (opts.skills.trim()) {
14
+ parts.push('', '## Skill library', 'Read a skill file with read_file before applying it the first time.', opts.skills.trim());
15
+ }
16
+ if (opts.insights.trim()) {
17
+ parts.push('', '## Recent session outcomes (what worked / what failed)', opts.insights.trim());
18
+ }
19
+ return parts.join('\n');
20
+ }
@@ -0,0 +1,76 @@
1
+ /**
2
+ * @hmharness/agent - runner
3
+ * The shared agent-task execution layer. CLI maps its events to terminal
4
+ * output; the web frontend maps them to SSE - one behavior, two frontends.
5
+ * Also owns the native registry factory (spawn_agent recursion) and the
6
+ * approval gate construction.
7
+ */
8
+ import { Registry, type ChatMessage, type DeltaKind, type HmhConfig, type LoopApproval, type LoopResult, type McpClient, type McpServerConfig, type McpServerImport, type ToolContext } from '@hmharness/kernel';
9
+ import * as readline from 'node:readline/promises';
10
+ import { type SpawnBase } from './spawn.ts';
11
+ /** Flatten the config.json shape into the runtime discriminated union. */
12
+ export declare function toServerConfig(c: McpServerImport): McpServerConfig;
13
+ /**
14
+ * Current spawn base, set per task so a long-lived registry (REPL, web
15
+ * server) always routes sub-agents to the CURRENT session and gate.
16
+ */
17
+ export declare const spawnBase: {
18
+ current?: SpawnBase;
19
+ };
20
+ export declare function nativeRegistry(depth: number): Registry;
21
+ export declare function buildRegistry(opts?: {
22
+ mcp?: boolean;
23
+ announce?: boolean;
24
+ }): Promise<{
25
+ reg: Registry;
26
+ clients: McpClient[];
27
+ }>;
28
+ /** Retrieval-based context pack: task-relevant memories, not the whole file.
29
+ * P0 canary: ~20% of sessions (deterministic by session id) also receive
30
+ * the canary skill block, watermarked as experimental references - the
31
+ * impact loop compares these sessions against the rest. */
32
+ export declare function contextPack(task: string, sessionId?: string): Promise<{
33
+ memory: string;
34
+ skills: string;
35
+ insights: string;
36
+ skillsInjected: string[];
37
+ }>;
38
+ /**
39
+ * Terminal approval gate: auto mode passes everything; a TTY gets a y/N
40
+ * prompt (reusing a caller-provided readline); a pipe gets a safe deny.
41
+ * The kernel loop denies by default when no gate is wired at all.
42
+ */
43
+ export declare function makeApproval(cfg: HmhConfig, yes: boolean, sharedRl?: readline.Interface): LoopApproval;
44
+ export interface RunnerEvents {
45
+ onLine?(line: string): void;
46
+ onDelta?(kind: DeltaKind, chunk: string): void;
47
+ onToolCall?(name: string, args: Record<string, unknown>): void;
48
+ onToolResult?(name: string, output: string, isError: boolean): void;
49
+ onApproval?(name: string, args: Record<string, unknown>, granted: boolean): void;
50
+ onFinal?(r: {
51
+ text: string;
52
+ turns: number;
53
+ toolUses: number;
54
+ sessionId: string;
55
+ usage?: {
56
+ promptTokens: number;
57
+ completionTokens: number;
58
+ };
59
+ }): void;
60
+ }
61
+ export interface AgentTaskOptions {
62
+ task: string;
63
+ registry: Registry;
64
+ cfg?: HmhConfig;
65
+ ctx?: ToolContext;
66
+ yes?: boolean;
67
+ /** Overrides the terminal gate (web supplies a remote one). */
68
+ approvalAsk?: LoopApproval['ask'];
69
+ resumeMessages?: ChatMessage[];
70
+ events?: RunnerEvents;
71
+ }
72
+ /** Run one full agent task end-to-end; audit + insight recording included. */
73
+ export declare function runAgentTask(opts: AgentTaskOptions): Promise<LoopResult & {
74
+ sessionId: string;
75
+ toolsUsed: string[];
76
+ }>;