@hover-dev/core 0.17.0 → 0.18.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.
Files changed (106) hide show
  1. package/dist/engine.d.ts +14 -39
  2. package/dist/engine.d.ts.map +1 -1
  3. package/dist/engine.js +16 -67
  4. package/dist/specs/pageObjectManifest.d.ts.map +1 -1
  5. package/dist/specs/pageObjectManifest.js +11 -10
  6. package/dist/specs/replayGrounded.d.ts.map +1 -1
  7. package/package.json +5 -22
  8. package/dist/agents/argv.d.ts +0 -11
  9. package/dist/agents/argv.d.ts.map +0 -1
  10. package/dist/agents/argv.js +0 -23
  11. package/dist/agents/claude.d.ts +0 -3
  12. package/dist/agents/claude.d.ts.map +0 -1
  13. package/dist/agents/claude.js +0 -220
  14. package/dist/agents/codex.d.ts +0 -19
  15. package/dist/agents/codex.d.ts.map +0 -1
  16. package/dist/agents/codex.js +0 -231
  17. package/dist/agents/detect.d.ts +0 -46
  18. package/dist/agents/detect.d.ts.map +0 -1
  19. package/dist/agents/detect.js +0 -80
  20. package/dist/agents/gemini.d.ts +0 -17
  21. package/dist/agents/gemini.d.ts.map +0 -1
  22. package/dist/agents/gemini.js +0 -186
  23. package/dist/agents/index.d.ts +0 -6
  24. package/dist/agents/index.d.ts.map +0 -1
  25. package/dist/agents/index.js +0 -5
  26. package/dist/agents/invoke.d.ts +0 -12
  27. package/dist/agents/invoke.d.ts.map +0 -1
  28. package/dist/agents/invoke.js +0 -93
  29. package/dist/agents/qwen.d.ts +0 -17
  30. package/dist/agents/qwen.d.ts.map +0 -1
  31. package/dist/agents/qwen.js +0 -172
  32. package/dist/agents/registry.d.ts +0 -19
  33. package/dist/agents/registry.d.ts.map +0 -1
  34. package/dist/agents/registry.js +0 -30
  35. package/dist/agents/shared.d.ts +0 -28
  36. package/dist/agents/shared.d.ts.map +0 -1
  37. package/dist/agents/shared.js +0 -35
  38. package/dist/agents/types.d.ts +0 -194
  39. package/dist/agents/types.d.ts.map +0 -1
  40. package/dist/agents/types.js +0 -23
  41. package/dist/index.d.ts +0 -3
  42. package/dist/index.d.ts.map +0 -1
  43. package/dist/index.js +0 -2
  44. package/dist/mcp/actuateServer.d.ts +0 -3
  45. package/dist/mcp/actuateServer.d.ts.map +0 -1
  46. package/dist/mcp/actuateServer.js +0 -594
  47. package/dist/mcp/sourceFence.d.ts +0 -23
  48. package/dist/mcp/sourceFence.d.ts.map +0 -1
  49. package/dist/mcp/sourceFence.js +0 -79
  50. package/dist/mcp/sourceServer.d.ts +0 -3
  51. package/dist/mcp/sourceServer.d.ts.map +0 -1
  52. package/dist/mcp/sourceServer.js +0 -191
  53. package/dist/modes.d.ts +0 -39
  54. package/dist/modes.d.ts.map +0 -1
  55. package/dist/modes.js +0 -34
  56. package/dist/playwright/cdpStatus.d.ts +0 -14
  57. package/dist/playwright/cdpStatus.d.ts.map +0 -1
  58. package/dist/playwright/cdpStatus.js +0 -52
  59. package/dist/playwright/preflight.d.ts +0 -31
  60. package/dist/playwright/preflight.d.ts.map +0 -1
  61. package/dist/playwright/preflight.js +0 -82
  62. package/dist/playwright/preflightCache.d.ts +0 -27
  63. package/dist/playwright/preflightCache.d.ts.map +0 -1
  64. package/dist/playwright/preflightCache.js +0 -21
  65. package/dist/playwright/resolveMcpConfig.d.ts +0 -61
  66. package/dist/playwright/resolveMcpConfig.d.ts.map +0 -1
  67. package/dist/playwright/resolveMcpConfig.js +0 -84
  68. package/dist/plugin-api.d.ts +0 -237
  69. package/dist/plugin-api.d.ts.map +0 -1
  70. package/dist/plugin-api.js +0 -52
  71. package/dist/qa/classify.d.ts +0 -38
  72. package/dist/qa/classify.d.ts.map +0 -1
  73. package/dist/qa/classify.js +0 -138
  74. package/dist/runSession.d.ts +0 -53
  75. package/dist/runSession.d.ts.map +0 -1
  76. package/dist/runSession.js +0 -96
  77. package/dist/service/cdpHandlers.d.ts +0 -24
  78. package/dist/service/cdpHandlers.d.ts.map +0 -1
  79. package/dist/service/cdpHandlers.js +0 -50
  80. package/dist/service/cdpHint.d.ts +0 -41
  81. package/dist/service/cdpHint.d.ts.map +0 -1
  82. package/dist/service/cdpHint.js +0 -158
  83. package/dist/service/conventions.d.ts +0 -8
  84. package/dist/service/conventions.d.ts.map +0 -1
  85. package/dist/service/conventions.js +0 -42
  86. package/dist/service/relayHandlers.d.ts +0 -28
  87. package/dist/service/relayHandlers.d.ts.map +0 -1
  88. package/dist/service/relayHandlers.js +0 -105
  89. package/dist/service/saveHandlers.d.ts +0 -50
  90. package/dist/service/saveHandlers.d.ts.map +0 -1
  91. package/dist/service/saveHandlers.js +0 -77
  92. package/dist/service/types.d.ts +0 -158
  93. package/dist/service/types.d.ts.map +0 -1
  94. package/dist/service/types.js +0 -26
  95. package/dist/service.d.ts +0 -54
  96. package/dist/service.d.ts.map +0 -1
  97. package/dist/service.js +0 -1772
  98. package/dist/specs/businessMap.d.ts +0 -29
  99. package/dist/specs/businessMap.d.ts.map +0 -1
  100. package/dist/specs/businessMap.js +0 -95
  101. package/dist/specs/extractPageObjects.d.ts +0 -18
  102. package/dist/specs/extractPageObjects.d.ts.map +0 -1
  103. package/dist/specs/extractPageObjects.js +0 -98
  104. package/dist/specs/optimizeSpecWithAgent.d.ts +0 -9
  105. package/dist/specs/optimizeSpecWithAgent.d.ts.map +0 -1
  106. package/dist/specs/optimizeSpecWithAgent.js +0 -39
@@ -1,93 +0,0 @@
1
- // cross-spawn is a drop-in for child_process.spawn that fixes Windows behaviour
2
- // around `.cmd`/`.bat` shims (e.g. npm-installed `claude.cmd`). The return type
3
- // is identical to node:child_process so call sites are unchanged.
4
- import spawn from 'cross-spawn';
5
- import { createInterface } from 'node:readline';
6
- import { buildArgv } from './argv.js';
7
- import { resolveBinForAgent } from './detect.js';
8
- import { getAgent } from './registry.js';
9
- import { AgentNotInstalledError, UnsupportedAgentProtocolError, } from './types.js';
10
- /**
11
- * Spawn an agent and yield normalized InvokeEvents as they arrive.
12
- *
13
- * Lifecycle: the generator owns the child process. Iterating to completion
14
- * drains stdout; breaking early (e.g. WS disconnect) runs the finally block
15
- * which closes readline and SIGTERMs the child, so we never leak orphan
16
- * agent processes that would keep driving the browser (and burning tokens)
17
- * after the user has navigated away.
18
- */
19
- export async function* invokeAgent(opts) {
20
- const descriptor = getAgent(opts.agentId);
21
- if (!descriptor) {
22
- throw new UnsupportedAgentProtocolError(`Unknown agent: ${opts.agentId}`);
23
- }
24
- const bin = await resolveBinForAgent(descriptor);
25
- if (!bin)
26
- throw new AgentNotInstalledError(opts.agentId);
27
- const argv = buildArgv(descriptor, opts);
28
- const usesStdinPrompt = descriptor.protocol === 'stdin';
29
- const child = spawn(bin, argv, {
30
- stdio: [usesStdinPrompt ? 'pipe' : 'ignore', 'pipe', 'inherit'],
31
- cwd: opts.cwd,
32
- // Clear CLAUDECODE so spawning `claude` from inside a Claude Code session
33
- // doesn't trip the nested-session guard. Harmless for other agents.
34
- // The CLI authenticates via its own logged-in subscription (or inherits any
35
- // key already in process.env); opts.env carries the Local LLM endpoint vars.
36
- env: {
37
- ...process.env,
38
- CLAUDECODE: '',
39
- ...(opts.env ?? {}),
40
- },
41
- });
42
- const onAbort = () => {
43
- if (!child.killed)
44
- child.kill('SIGTERM');
45
- };
46
- if (opts.signal) {
47
- if (opts.signal.aborted)
48
- onAbort();
49
- else
50
- opts.signal.addEventListener('abort', onAbort, { once: true });
51
- }
52
- if (usesStdinPrompt && child.stdin) {
53
- child.stdin.write(opts.prompt);
54
- child.stdin.end();
55
- }
56
- const rl = createInterface({ input: child.stdout });
57
- const exitPromise = new Promise(res => child.on('exit', c => res(c ?? -1)));
58
- const state = {};
59
- let sawSessionEnd = false;
60
- try {
61
- for await (const line of rl) {
62
- for (const ev of descriptor.parseEvent(line, state)) {
63
- if (ev.kind === 'session_end')
64
- sawSessionEnd = true;
65
- yield ev;
66
- }
67
- }
68
- const code = await exitPromise;
69
- if (!sawSessionEnd && !opts.signal?.aborted) {
70
- // Give the descriptor a chance to synthesize its own terminator from
71
- // accumulated state (codex does this — its stream never emits a
72
- // session_end). Falls back to a generic error session_end if the
73
- // descriptor declines and the child exited non-zero.
74
- const synthetic = descriptor.onStreamEnd?.(code, state);
75
- if (synthetic) {
76
- yield synthetic;
77
- }
78
- else if (code !== 0) {
79
- yield {
80
- kind: 'session_end',
81
- isError: true,
82
- summary: `agent exited with code ${code}`,
83
- };
84
- }
85
- }
86
- }
87
- finally {
88
- rl.close();
89
- if (!child.killed)
90
- child.kill('SIGTERM');
91
- opts.signal?.removeEventListener('abort', onAbort);
92
- }
93
- }
@@ -1,17 +0,0 @@
1
- import type { AgentDescriptor, ParserState } from './types.js';
2
- export declare const qwenAgent: AgentDescriptor;
3
- /**
4
- * Test-only escape hatches, same pattern as cursor.ts / codex.ts.
5
- */
6
- export declare const __testing: {
7
- freshState: () => ParserState;
8
- resetCounters: (state: ParserState) => void;
9
- getState: (state: ParserState) => {
10
- runningTurns: number;
11
- runningSessionId: string | undefined;
12
- runningModel: string | undefined;
13
- lastAssistantText: string | undefined;
14
- sawErrorEvent: boolean;
15
- };
16
- };
17
- //# sourceMappingURL=qwen.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"qwen.d.ts","sourceRoot":"","sources":["../../src/agents/qwen.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAA8B,WAAW,EAAE,MAAM,YAAY,CAAC;AAoJ3F,eAAO,MAAM,SAAS,EAAE,eAqJvB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS;sBACJ,WAAW;2BACJ,WAAW;sBAChB,WAAW;;;;;;;CAU9B,CAAC"}
@@ -1,172 +0,0 @@
1
- import { HOVER_PROMPT_PREFACE, stripMcpPrefix } from './shared.js';
2
- function qwenState(state) {
3
- if (typeof state.runningTurns !== 'number') {
4
- state.runningTurns = 0;
5
- state.runningSessionId = undefined;
6
- state.runningModel = undefined;
7
- state.lastAssistantText = undefined;
8
- state.sawErrorEvent = false;
9
- state.toolNameByUseId = new Map();
10
- }
11
- return state;
12
- }
13
- function resetQwenCounters(s) {
14
- s.runningTurns = 0;
15
- s.runningSessionId = undefined;
16
- s.runningModel = undefined;
17
- s.lastAssistantText = undefined;
18
- s.sawErrorEvent = false;
19
- s.toolNameByUseId.clear();
20
- }
21
- export const qwenAgent = {
22
- id: 'qwen',
23
- binName: 'qwen',
24
- protocol: 'argv',
25
- streamFormat: 'json-lines',
26
- sandboxStrength: 'soft',
27
- display: {
28
- label: 'Qwen Code',
29
- tagline: 'Qwen Code — soft sandbox (no built-in tool deny-list)',
30
- homepage: 'https://github.com/QwenLM/qwen-code',
31
- installHint: 'npm install -g @qwen-code/qwen-code@latest',
32
- },
33
- buildArgs(opts) {
34
- const args = ['-p', opts.prompt];
35
- // NDJSON streaming output.
36
- args.push('--output-format', 'stream-json');
37
- // Auto-approve all tool calls so the run doesn't hang. The newer
38
- // canonical form is --approval-mode=yolo; --yolo is deprecated but
39
- // still works in 2026-05. We use the modern form.
40
- args.push('--approval-mode', 'yolo');
41
- if (opts.model) {
42
- args.push('--model', opts.model);
43
- }
44
- if (opts.sessionId) {
45
- // --resume <sessionId> is the documented headless form. --continue
46
- // (no arg) picks the most recent — NOT what we want when a specific
47
- // session was passed.
48
- args.push('--resume', opts.sessionId);
49
- }
50
- // Qwen has a real --append-system-prompt flag — use it instead of
51
- // prepending to the user prompt. Concatenate the standing Hover-mode
52
- // preface with whatever the caller appended.
53
- const sysPrompt = opts.appendSystemPrompt && opts.appendSystemPrompt.trim().length > 0
54
- ? `${HOVER_PROMPT_PREFACE} ${opts.appendSystemPrompt}`
55
- : HOVER_PROMPT_PREFACE;
56
- args.push('--append-system-prompt', sysPrompt);
57
- // MCP servers configured in ~/.qwen/settings.json — no per-invocation
58
- // --mcp-config equivalent. Same constraint as cursor / codex.
59
- // No equivalent for --max-budget-usd or --allowedTools / --disallowedTools.
60
- return args;
61
- },
62
- parseEvent(line, state = {}) {
63
- if (!line.trim())
64
- return [];
65
- let ev;
66
- try {
67
- ev = JSON.parse(line);
68
- }
69
- catch {
70
- return [{ kind: 'raw', line }];
71
- }
72
- const s = qwenState(state);
73
- const out = [];
74
- if (ev.type === 'system' && ev.subtype === 'session_start') {
75
- resetQwenCounters(s);
76
- s.runningModel = ev.model;
77
- if (ev.session_id) {
78
- s.runningSessionId = ev.session_id;
79
- out.push({ kind: 'session_start', sessionId: ev.session_id, model: ev.model });
80
- }
81
- return out;
82
- }
83
- if (ev.type === 'assistant' && ev.message) {
84
- s.runningTurns += 1;
85
- // Emit a usage event so the widget can advance its turn counter.
86
- // costUsd intentionally omitted — qwen doesn't publish $ in stream.
87
- out.push({ kind: 'usage', turns: s.runningTurns });
88
- for (const block of ev.message.content ?? []) {
89
- if (block.type === 'text') {
90
- const text = block.text?.trim();
91
- if (text) {
92
- s.lastAssistantText = text;
93
- out.push({ kind: 'text', text });
94
- }
95
- }
96
- else if (block.type === 'tool_use') {
97
- const rawName = block.name ?? '';
98
- const tool = stripMcpPrefix(rawName);
99
- if (block.id)
100
- s.toolNameByUseId.set(block.id, tool);
101
- out.push({ kind: 'tool_use', tool, input: block.input });
102
- }
103
- }
104
- return out;
105
- }
106
- // tool_result blocks are wrapped in `user` messages (Anthropic Messages
107
- // convention). We surface them as tool_result events.
108
- if (ev.type === 'user' && ev.message) {
109
- for (const block of ev.message.content ?? []) {
110
- if (block.type === 'tool_result') {
111
- const isError = block.is_error === true;
112
- out.push({ kind: 'tool_result', isError });
113
- }
114
- }
115
- return out;
116
- }
117
- if (ev.type === 'result') {
118
- const isError = ev.is_error === true ||
119
- (typeof ev.subtype === 'string' && /error|fail/i.test(ev.subtype));
120
- if (isError)
121
- s.sawErrorEvent = true;
122
- out.push({
123
- kind: 'session_end',
124
- turns: s.runningTurns,
125
- // costUsd intentionally undefined — qwen doesn't publish $.
126
- isError,
127
- summary: ev.result ?? s.lastAssistantText,
128
- });
129
- return out;
130
- }
131
- // Qwen emits various error envelopes mid-stream; surface them as text.
132
- if (ev.type && /error/i.test(ev.type)) {
133
- s.sawErrorEvent = true;
134
- const msg = ev.error?.message ?? ev.text ?? ev.result ?? `[qwen] ${ev.type}`;
135
- out.push({ kind: 'text', text: msg });
136
- return out;
137
- }
138
- return [];
139
- },
140
- /**
141
- * Qwen's `result` event already produces a session_end via parseEvent;
142
- * this fallback is for the case where the child exits without emitting a
143
- * `result` (e.g. crash, signal). Mirrors codex.ts / cursor.ts shape.
144
- */
145
- onStreamEnd(exitCode, state = {}) {
146
- const s = qwenState(state);
147
- return {
148
- kind: 'session_end',
149
- turns: s.runningTurns,
150
- // costUsd intentionally undefined — see parseEvent note.
151
- isError: s.sawErrorEvent || (exitCode != null && exitCode !== 0),
152
- summary: s.lastAssistantText,
153
- };
154
- },
155
- };
156
- /**
157
- * Test-only escape hatches, same pattern as cursor.ts / codex.ts.
158
- */
159
- export const __testing = {
160
- freshState: () => ({}),
161
- resetCounters: (state) => resetQwenCounters(qwenState(state)),
162
- getState: (state) => {
163
- const s = qwenState(state);
164
- return {
165
- runningTurns: s.runningTurns,
166
- runningSessionId: s.runningSessionId,
167
- runningModel: s.runningModel,
168
- lastAssistantText: s.lastAssistantText,
169
- sawErrorEvent: s.sawErrorEvent,
170
- };
171
- },
172
- };
@@ -1,19 +0,0 @@
1
- import type { AgentDescriptor } from './types.js';
2
- /**
3
- * Registry of agents Hover can drive.
4
- *
5
- * To add support for another agent (e.g. cline, continue, kilo), implement
6
- * its AgentDescriptor in its own file and register it here. The rest of the
7
- * system — detect, argv, invoke, service, widget — works without further
8
- * changes.
9
- *
10
- * Insertion order is the order shown in the widget's agent dropdown, so put
11
- * the recommended primary first. The two hard-sandbox / first-party agents
12
- * (claude, codex) lead; the soft-sandbox third-party agents follow in the
13
- * order they were added.
14
- */
15
- export declare const AGENTS: Record<string, AgentDescriptor>;
16
- export declare function getAgent(id: string): AgentDescriptor | undefined;
17
- /** Stable, insertion-ordered list of all registered agents. */
18
- export declare function listAgents(): AgentDescriptor[];
19
- //# sourceMappingURL=registry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/agents/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAMlD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAKlD,CAAC;AAEF,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAEhE;AAED,+DAA+D;AAC/D,wBAAgB,UAAU,IAAI,eAAe,EAAE,CAE9C"}
@@ -1,30 +0,0 @@
1
- import { claudeAgent } from './claude.js';
2
- import { codexAgent } from './codex.js';
3
- import { geminiAgent } from './gemini.js';
4
- import { qwenAgent } from './qwen.js';
5
- /**
6
- * Registry of agents Hover can drive.
7
- *
8
- * To add support for another agent (e.g. cline, continue, kilo), implement
9
- * its AgentDescriptor in its own file and register it here. The rest of the
10
- * system — detect, argv, invoke, service, widget — works without further
11
- * changes.
12
- *
13
- * Insertion order is the order shown in the widget's agent dropdown, so put
14
- * the recommended primary first. The two hard-sandbox / first-party agents
15
- * (claude, codex) lead; the soft-sandbox third-party agents follow in the
16
- * order they were added.
17
- */
18
- export const AGENTS = {
19
- [claudeAgent.id]: claudeAgent,
20
- [codexAgent.id]: codexAgent,
21
- [geminiAgent.id]: geminiAgent,
22
- [qwenAgent.id]: qwenAgent,
23
- };
24
- export function getAgent(id) {
25
- return AGENTS[id];
26
- }
27
- /** Stable, insertion-ordered list of all registered agents. */
28
- export function listAgents() {
29
- return Object.values(AGENTS);
30
- }
@@ -1,28 +0,0 @@
1
- /**
2
- * Cross-agent helpers shared by the soft-sandbox descriptors
3
- * (codex / cursor / gemini / qwen / aider).
4
- *
5
- * These agents all need the same two things:
6
- * 1. A standing "HOVER-mode" instruction preface that tells the agent to
7
- * drive the browser via the Playwright MCP tools only and not to touch
8
- * its built-in shell / file-edit tools. Each agent injects it through a
9
- * different channel (cursor / gemini / aider prepend it to the prompt,
10
- * qwen passes it via --append-system-prompt, codex via
11
- * `-c developer_instructions=`), so this module owns only the *text*, not
12
- * the injection.
13
- * 2. Normalising the `mcp__playwright__` / `mcp__hover-playwright__` prefix
14
- * off a raw tool name so the emitted tool names line up across agents.
15
- *
16
- * codex deliberately does NOT use HOVER_PROMPT_PREFACE — it keeps its own
17
- * wording ("Do NOT call …", "emit a short agent_message summary …") that is
18
- * tuned to codex's event vocabulary. See codex.ts.
19
- */
20
- /**
21
- * The standing HOVER-mode instruction shared by cursor / gemini / qwen / aider.
22
- * codex carries a near-identical but intentionally different variant inline.
23
- */
24
- export declare const HOVER_PROMPT_PREFACE: string;
25
- /** Strip the `mcp__playwright__` / `mcp__hover-playwright__` prefix so tool
26
- * names match the normalised names every agent emits. */
27
- export declare function stripMcpPrefix(raw: string): string;
28
- //# sourceMappingURL=shared.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/agents/shared.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;GAGG;AACH,eAAO,MAAM,oBAAoB,QAMtB,CAAC;AAEZ;0DAC0D;AAC1D,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAElD"}
@@ -1,35 +0,0 @@
1
- /**
2
- * Cross-agent helpers shared by the soft-sandbox descriptors
3
- * (codex / cursor / gemini / qwen / aider).
4
- *
5
- * These agents all need the same two things:
6
- * 1. A standing "HOVER-mode" instruction preface that tells the agent to
7
- * drive the browser via the Playwright MCP tools only and not to touch
8
- * its built-in shell / file-edit tools. Each agent injects it through a
9
- * different channel (cursor / gemini / aider prepend it to the prompt,
10
- * qwen passes it via --append-system-prompt, codex via
11
- * `-c developer_instructions=`), so this module owns only the *text*, not
12
- * the injection.
13
- * 2. Normalising the `mcp__playwright__` / `mcp__hover-playwright__` prefix
14
- * off a raw tool name so the emitted tool names line up across agents.
15
- *
16
- * codex deliberately does NOT use HOVER_PROMPT_PREFACE — it keeps its own
17
- * wording ("Do NOT call …", "emit a short agent_message summary …") that is
18
- * tuned to codex's event vocabulary. See codex.ts.
19
- */
20
- /**
21
- * The standing HOVER-mode instruction shared by cursor / gemini / qwen / aider.
22
- * codex carries a near-identical but intentionally different variant inline.
23
- */
24
- export const HOVER_PROMPT_PREFACE = [
25
- 'You are operating in Hover, a browser-testing tool.',
26
- 'Use ONLY the MCP playwright tools (prefixed `mcp__playwright__` / `mcp__hover-playwright__`) to drive the browser.',
27
- 'Do NOT use shell, file-edit, web-search, or any other built-in tool.',
28
- 'Do NOT navigate to a URL the user is already on; check the page state via `browser_snapshot` first.',
29
- 'When the task is complete, emit a short summary and stop.',
30
- ].join(' ');
31
- /** Strip the `mcp__playwright__` / `mcp__hover-playwright__` prefix so tool
32
- * names match the normalised names every agent emits. */
33
- export function stripMcpPrefix(raw) {
34
- return raw.replace(/^mcp__playwright__/, '').replace(/^mcp__hover-playwright__/, '');
35
- }
@@ -1,194 +0,0 @@
1
- /**
2
- * Local CLI Agent First — agent abstraction layer.
3
- *
4
- * Hover does not bundle any AI runtime. It spawns whatever coding-agent CLI the
5
- * user has on PATH (`claude`, `codex`, `cursor`, `aider`, ...) and treats it as
6
- * a strategy implementation behind this interface.
7
- *
8
- * To add a new agent: write an AgentDescriptor and register it in registry.ts.
9
- */
10
- export type AgentProtocol = 'argv' | 'stdin' | 'acp' | 'pi-rpc';
11
- export type StreamFormat = 'stream-json' | 'sse' | 'plain-text' | 'json-lines';
12
- export declare class UnsupportedAgentProtocolError extends Error {
13
- constructor(message: string);
14
- }
15
- export declare class AgentNotInstalledError extends Error {
16
- readonly agentId: string;
17
- constructor(agentId: string);
18
- }
19
- export interface InvokeOptions {
20
- agentId: string;
21
- prompt: string;
22
- mcpConfig?: string;
23
- allowedTools?: string[];
24
- disallowedTools?: string[];
25
- maxBudgetUsd?: number;
26
- /** Hard ceiling on agent turns (~steps) — claude `--max-turns`. Used by QA
27
- * intensity to bound an exploratory run by step count. */
28
- maxTurns?: number;
29
- model?: string;
30
- /** Reasoning-effort level for the run. claude → `--effort <level>` (low /
31
- * medium / high / xhigh / max); codex → `-c model_reasoning_effort=<level>`
32
- * (minimal / low / medium / high / xhigh). The caller is responsible for
33
- * passing a level the chosen model actually supports. */
34
- effort?: string;
35
- cwd?: string;
36
- sessionId?: string;
37
- /** Extra text appended to the agent's system prompt (claude: via
38
- * --append-system-prompt). Used to inject session-specific context like
39
- * "the user's current Chrome tab is already on http://localhost:5173/,
40
- * don't browser_navigate there". */
41
- appendSystemPrompt?: string;
42
- /** Extra environment variables for the spawned CLI (merged over process.env).
43
- * Used for the "Local LLM" path: qwen-code reads OPENAI_BASE_URL /
44
- * OPENAI_API_KEY to target a user's self-hosted OpenAI-compatible endpoint. */
45
- env?: Record<string, string>;
46
- /** Aborts the spawned child if signaled. Used to stop an orphan run when
47
- * the WebSocket caller disconnects (e.g. user reloads the dev page). */
48
- signal?: AbortSignal;
49
- }
50
- /**
51
- * Normalized event emitted by every agent, regardless of its native wire format.
52
- * Each agent's `parseEvent` translates its own stream into these.
53
- */
54
- export type InvokeEvent = {
55
- kind: 'session_start';
56
- sessionId: string;
57
- model?: string;
58
- } | {
59
- kind: 'mcp_status';
60
- server: string;
61
- status: string;
62
- } | {
63
- kind: 'tool_use';
64
- tool: string;
65
- input: unknown;
66
- costUsdSnapshot?: number;
67
- tokensSnapshot?: number;
68
- } | {
69
- kind: 'tool_result';
70
- isError?: boolean;
71
- preview?: string;
72
- } | {
73
- kind: 'text';
74
- text: string;
75
- }
76
- /** Running cost / turn-count update emitted mid-session so the widget can
77
- * show a live $ counter without waiting for session_end. Claude Code's
78
- * stream-json includes `total_cost_usd` on intermediate result-ish events;
79
- * agents that don't surface running cost simply never emit this. */
80
- | {
81
- kind: 'usage';
82
- costUsd?: number;
83
- turns?: number;
84
- tokens?: number;
85
- }
86
- /** End-of-session event. Three terminal states the widget renders distinctly:
87
- *
88
- * - normal completion: `isError: false`, no `cancelled` flag
89
- * - agent / runtime failure: `isError: true`, no `cancelled` flag
90
- * - user-initiated stop: `cancelled: true` (and we leave `isError: false`
91
- * so downstream "did the agent fail?" predicates don't conflate
92
- * "user pressed Stop" with "agent crashed mid-run"). The widget
93
- * renders this as a neutral "Stopped" state, not a red Failed card.
94
- */
95
- | {
96
- kind: 'session_end';
97
- turns?: number;
98
- costUsd?: number;
99
- tokens?: number;
100
- isError?: boolean;
101
- cancelled?: boolean;
102
- summary?: string;
103
- } | {
104
- kind: 'raw';
105
- line: string;
106
- };
107
- /**
108
- * How tightly the agent's tool surface can be locked down per invocation.
109
- *
110
- * 'hard' — the agent CLI accepts a deny-list / allow-list that effectively
111
- * removes built-in tools (shell, file edit, etc.) so the only
112
- * callable surface is whatever MCP servers we configure. Claude
113
- * Code's `--strict-mcp-config` + `--allowedTools mcp__playwright`
114
- * + `--disallowedTools <every built-in>` is the canonical example.
115
- *
116
- * 'soft' — the agent CLI does not expose a way to disable its built-in
117
- * tools (shell, fs). We can constrain side-effects via OS-level
118
- * sandbox flags (e.g. codex's `--sandbox read-only`) and we lean
119
- * on a strict `developer_instructions` system-prompt to nudge the
120
- * agent toward MCP-only behavior, but a determined / hallucinating
121
- * agent COULD still try a built-in shell call. The widget should
122
- * mark this agent with a warning indicator.
123
- */
124
- export type SandboxStrength = 'hard' | 'soft';
125
- /**
126
- * Human-facing metadata for the widget's agent picker. None of these affect
127
- * agent invocation — they only shape how the agent is presented in the UI.
128
- */
129
- export interface AgentDisplay {
130
- /** Pretty name for the dropdown ("Claude Code", "OpenAI Codex"). */
131
- label: string;
132
- /** One-line tagline shown under the label. */
133
- tagline?: string;
134
- /** Vendor / source URL — clicking the agent name in the widget can open
135
- * this in a new tab when the agent isn't installed. */
136
- homepage?: string;
137
- /** Shell command the user can run to install (copy-paste from a tooltip
138
- * in the widget when the agent is listed but not on PATH). */
139
- installHint?: string;
140
- }
141
- /**
142
- * Per-invocation parser state. A fresh object is created by `invokeAgent`
143
- * for each spawn and passed to both `parseEvent` and `onStreamEnd`.
144
- *
145
- * Descriptors that need to accumulate state across lines (cost, turn count,
146
- * last agent message for synthesized session_end, etc.) read and write
147
- * their own keys on this object. There is no shared shape — each agent
148
- * uses whatever fields it needs.
149
- *
150
- * Why: module-level state in claude.ts / codex.ts worked only because the
151
- * service enforces one in-flight invocation per Node process. Two concurrent
152
- * agent runs (future: tests in parallel, in-process workers) would silently
153
- * smear their cost accumulators together. Threading the state object per
154
- * invocation removes that hazard at zero runtime cost.
155
- */
156
- export type ParserState = Record<string, unknown>;
157
- export interface AgentDescriptor {
158
- id: string;
159
- binName: string;
160
- protocol: AgentProtocol;
161
- streamFormat: StreamFormat;
162
- sandboxStrength: SandboxStrength;
163
- display: AgentDisplay;
164
- /** Hard-sandbox agents pass this list to `disallowedTools` when the
165
- * service-level allow/deny config isn't explicitly overridden. Lets the
166
- * per-CLI deny list live alongside its descriptor instead of as a magic
167
- * array in the service. Soft-sandbox agents leave this undefined. */
168
- defaultDisallowedTools?: readonly string[];
169
- /** A cheap/fast model id for non-interactive refinement work (the F7 optimize
170
- * pass) where the big model isn't worth the cost. Used when the user hasn't
171
- * set `hover.optimizeModel`; undefined → fall back to the session model. */
172
- cheapModel?: string;
173
- buildArgs(opts: InvokeOptions): string[];
174
- /**
175
- * Parse a single line of agent stdout into normalised InvokeEvents.
176
- * `state` is a per-invocation scratch pad (see ParserState). Optional
177
- * for callers that don't accumulate across lines (and for unit tests
178
- * that don't care about cost / turn carry-over) — descriptors that
179
- * DO accumulate must check / initialise the state object themselves.
180
- */
181
- parseEvent(line: string, state?: ParserState): InvokeEvent[];
182
- /**
183
- * Optional. Called once after the agent's stream closes, with the child's
184
- * exit code (or null if it was aborted). Lets agents whose protocol does
185
- * NOT emit an explicit session-terminating event synthesize one from
186
- * accumulated parser state. Returns `null` if the agent's own `parseEvent`
187
- * already emitted a `session_end` and nothing further is needed.
188
- *
189
- * Used by codex.ts (no native session_end). Claude does not implement
190
- * this — `result` events terminate naturally.
191
- */
192
- onStreamEnd?(exitCode: number | null, state?: ParserState): InvokeEvent | null;
193
- }
194
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/agents/types.ts"],"names":[],"mappings":"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"}
@@ -1,23 +0,0 @@
1
- /**
2
- * Local CLI Agent First — agent abstraction layer.
3
- *
4
- * Hover does not bundle any AI runtime. It spawns whatever coding-agent CLI the
5
- * user has on PATH (`claude`, `codex`, `cursor`, `aider`, ...) and treats it as
6
- * a strategy implementation behind this interface.
7
- *
8
- * To add a new agent: write an AgentDescriptor and register it in registry.ts.
9
- */
10
- export class UnsupportedAgentProtocolError extends Error {
11
- constructor(message) {
12
- super(message);
13
- this.name = 'UnsupportedAgentProtocolError';
14
- }
15
- }
16
- export class AgentNotInstalledError extends Error {
17
- agentId;
18
- constructor(agentId) {
19
- super(`Agent "${agentId}" is not installed (binary not found on PATH).`);
20
- this.agentId = agentId;
21
- this.name = 'AgentNotInstalledError';
22
- }
23
- }
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from './agents/index.js';
2
- export { connectAndListTabs } from './playwright/preflight.js';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC"}
package/dist/index.js DELETED
@@ -1,2 +0,0 @@
1
- export * from './agents/index.js';
2
- export { connectAndListTabs } from './playwright/preflight.js';
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
3
- //# sourceMappingURL=actuateServer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"actuateServer.d.ts","sourceRoot":"","sources":["../../src/mcp/actuateServer.ts"],"names":[],"mappings":""}