synabun 2026.3.31007 → 2026.4.1
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/CHANGELOG.md +51 -52
- package/hooks/claude-code/prompt-submit.mjs +6 -6
- package/mcp-server/dist/services/neural-interface.d.ts +20 -19
- package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
- package/mcp-server/dist/services/neural-interface.js +52 -45
- package/mcp-server/dist/services/neural-interface.js.map +1 -1
- package/mcp-server/dist/tools/browser-advanced.d.ts +4 -0
- package/mcp-server/dist/tools/browser-advanced.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-advanced.js +7 -4
- package/mcp-server/dist/tools/browser-advanced.js.map +1 -1
- package/mcp-server/dist/tools/browser-interact.d.ts +16 -0
- package/mcp-server/dist/tools/browser-interact.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-interact.js +25 -16
- package/mcp-server/dist/tools/browser-interact.js.map +1 -1
- package/mcp-server/dist/tools/browser-navigate.d.ts +8 -0
- package/mcp-server/dist/tools/browser-navigate.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-navigate.js +13 -8
- package/mcp-server/dist/tools/browser-navigate.js.map +1 -1
- package/mcp-server/dist/tools/browser-observe.d.ts +48 -0
- package/mcp-server/dist/tools/browser-observe.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-observe.js +74 -49
- package/mcp-server/dist/tools/browser-observe.js.map +1 -1
- package/mcp-server/dist/tools/leonardo-browser-tools.d.ts +20 -0
- package/mcp-server/dist/tools/leonardo-browser-tools.d.ts.map +1 -1
- package/mcp-server/dist/tools/leonardo-browser-tools.js +39 -34
- package/mcp-server/dist/tools/leonardo-browser-tools.js.map +1 -1
- package/mcp-server/src/services/neural-interface.ts +58 -46
- package/mcp-server/src/tools/browser-advanced.ts +10 -5
- package/mcp-server/src/tools/browser-interact.ts +34 -24
- package/mcp-server/src/tools/browser-navigate.ts +83 -77
- package/mcp-server/src/tools/browser-observe.ts +99 -73
- package/mcp-server/src/tools/leonardo-browser-tools.ts +47 -37
- package/neural-interface/public/shared/styles.css +49 -0
- package/neural-interface/public/shared/ui-automation-studio.js +71 -3
- package/neural-interface/public/shared/ui-claude-panel.js +29 -23
- package/neural-interface/public/shared/ui-settings.js +10 -10
- package/neural-interface/public/shared/ui-terminal.js +9 -7
- package/neural-interface/server.js +732 -386
- package/package.json +1 -1
|
@@ -2,6 +2,8 @@ import { z } from 'zod';
|
|
|
2
2
|
import * as ni from '../services/neural-interface.js';
|
|
3
3
|
import { text } from './response.js';
|
|
4
4
|
|
|
5
|
+
const tabIdField = z.string().optional().describe('Target a specific tab within the session. Auto-resolved from environment if omitted.');
|
|
6
|
+
|
|
5
7
|
function formatClickHints(result: Record<string, unknown>): string {
|
|
6
8
|
const hints = result.hints as Array<{ role: string; text: string; ariaLabel: string; placeholder: string }> | undefined;
|
|
7
9
|
if (!hints?.length) return '';
|
|
@@ -20,6 +22,7 @@ export const browserClickSchema = {
|
|
|
20
22
|
selector: z.string().describe('Playwright selector for the element to click. Use CSS selectors (e.g. "button.submit", "#login"), text selectors (e.g. \'text="Sign in"\'), or Playwright extensions like \'button:has-text("Retry")\'. NEVER use :contains() — use :has-text() instead.'),
|
|
21
23
|
nthMatch: z.coerce.number().int().min(0).optional().describe('If the selector matches multiple elements, click the Nth one (0-indexed). Facebook: composer trigger appears in sidebar + main — use nthMatch: 0 to click the first match.'),
|
|
22
24
|
sessionId: z.string().optional().describe('Browser session ID. If omitted, auto-selects the only open session.'),
|
|
25
|
+
tabId: tabIdField,
|
|
23
26
|
};
|
|
24
27
|
|
|
25
28
|
export const browserClickDescription =
|
|
@@ -73,11 +76,11 @@ export const browserClickDescription =
|
|
|
73
76
|
'Messaging compose: .msg-form__contenteditable — use browser_fill to type, then click .msg-form__send-button to send. ' +
|
|
74
77
|
'Nav: a[href*="/feed/"] (Home), a[href*="/mynetwork/"] (Network), a[href*="/jobs/"] (Jobs), a[href*="/messaging/"] (Messages), a[href*="/notifications/"] (Notifications).'
|
|
75
78
|
|
|
76
|
-
export async function handleBrowserClick(args: { selector: string; nthMatch?: number; sessionId?: string }) {
|
|
77
|
-
const resolved = await ni.resolveSession(args.sessionId);
|
|
79
|
+
export async function handleBrowserClick(args: { selector: string; nthMatch?: number; sessionId?: string; tabId?: string }) {
|
|
80
|
+
const resolved = await ni.resolveSession(args.sessionId, undefined, args.tabId);
|
|
78
81
|
if ('error' in resolved) return text(resolved.error);
|
|
79
82
|
|
|
80
|
-
const result = await ni.click(resolved.sessionId, args.selector, args.nthMatch);
|
|
83
|
+
const result = await ni.click(resolved.sessionId, args.selector, args.nthMatch, resolved.tabId);
|
|
81
84
|
if (result.error) return text(`Click failed: ${result.error}${formatClickHints(result)}`);
|
|
82
85
|
|
|
83
86
|
return text(`Clicked "${args.selector}" — now at ${result.url} "${result.title}"`);
|
|
@@ -90,17 +93,18 @@ export const browserFillSchema = {
|
|
|
90
93
|
value: z.string().describe('The text value to fill into the element. Clears existing content first.'),
|
|
91
94
|
nthMatch: z.coerce.number().int().min(0).optional().describe('If the selector matches multiple elements, fill the Nth one (0-indexed).'),
|
|
92
95
|
sessionId: z.string().optional().describe('Browser session ID. If omitted, auto-selects the only open session.'),
|
|
96
|
+
tabId: tabIdField,
|
|
93
97
|
};
|
|
94
98
|
|
|
95
99
|
export const browserFillDescription =
|
|
96
100
|
'Clear an input field and fill it with new text. Accepts Playwright selectors: CSS, text="...", :has-text("..."), [data-testid="..."]. Twitter/X: compose box is [data-testid="tweetTextarea_0"], search is [data-testid="SearchBox_Search_Input"]. TikTok search: [data-e2e="search-user-input"]. WhatsApp search: input[aria-label="Pesquisar ou começar uma nova conversa"]. ' +
|
|
97
101
|
'Instagram: comment box is textarea[aria-label="Adicione um comentário..."] (PT) / textarea[aria-label="Add a comment…"] (EN). Use browser_fill for comment text, then press Enter to submit.';
|
|
98
102
|
|
|
99
|
-
export async function handleBrowserFill(args: { selector: string; value: string; nthMatch?: number; sessionId?: string }) {
|
|
100
|
-
const resolved = await ni.resolveSession(args.sessionId);
|
|
103
|
+
export async function handleBrowserFill(args: { selector: string; value: string; nthMatch?: number; sessionId?: string; tabId?: string }) {
|
|
104
|
+
const resolved = await ni.resolveSession(args.sessionId, undefined, args.tabId);
|
|
101
105
|
if ('error' in resolved) return text(resolved.error);
|
|
102
106
|
|
|
103
|
-
const result = await ni.fill(resolved.sessionId, args.selector, args.value, args.nthMatch);
|
|
107
|
+
const result = await ni.fill(resolved.sessionId, args.selector, args.value, args.nthMatch, resolved.tabId);
|
|
104
108
|
if (result.error) return text(`Fill failed: ${result.error}${formatClickHints(result)}`);
|
|
105
109
|
|
|
106
110
|
const location = result.url ? ` — ${result.url} "${result.title}"` : '';
|
|
@@ -114,6 +118,7 @@ export const browserTypeSchema = {
|
|
|
114
118
|
text: z.string().describe('The text to type character by character (appends to existing content).'),
|
|
115
119
|
nthMatch: z.coerce.number().int().min(0).optional().describe('If the selector matches multiple elements, type into the Nth one (0-indexed). Twitter/X reply dialog has 2 tweetTextarea_0 elements — use nthMatch to disambiguate.'),
|
|
116
120
|
sessionId: z.string().optional().describe('Browser session ID. If omitted, auto-selects the only open session.'),
|
|
121
|
+
tabId: tabIdField,
|
|
117
122
|
};
|
|
118
123
|
|
|
119
124
|
export const browserTypeDescription =
|
|
@@ -127,11 +132,11 @@ export const browserTypeDescription =
|
|
|
127
132
|
'WhatsApp status text composer: .lexical-rich-text-input div[contenteditable="true"]. ' +
|
|
128
133
|
'Instagram: Comment on post pages uses a native textarea (NOT contenteditable) — use browser_fill instead of browser_type. For DMs, navigate to instagram.com/direct/inbox/ first. Search: click svg[aria-label="Pesquisa"] in sidebar to open search panel, then type in the input that appears.';
|
|
129
134
|
|
|
130
|
-
export async function handleBrowserType(args: { selector?: string; text: string; nthMatch?: number; sessionId?: string }) {
|
|
131
|
-
const resolved = await ni.resolveSession(args.sessionId);
|
|
135
|
+
export async function handleBrowserType(args: { selector?: string; text: string; nthMatch?: number; sessionId?: string; tabId?: string }) {
|
|
136
|
+
const resolved = await ni.resolveSession(args.sessionId, undefined, args.tabId);
|
|
132
137
|
if ('error' in resolved) return text(resolved.error);
|
|
133
138
|
|
|
134
|
-
const result = await ni.type(resolved.sessionId, args.selector ?? null, args.text, args.nthMatch);
|
|
139
|
+
const result = await ni.type(resolved.sessionId, args.selector ?? null, args.text, args.nthMatch, resolved.tabId);
|
|
135
140
|
if (result.error) return text(`Type failed: ${result.error}${formatClickHints(result)}`);
|
|
136
141
|
|
|
137
142
|
const target = args.selector ? `"${args.selector}"` : 'focused element';
|
|
@@ -145,16 +150,17 @@ export const browserHoverSchema = {
|
|
|
145
150
|
selector: z.string().describe('Playwright selector for the element to hover over (CSS, text="...", :has-text("...")).'),
|
|
146
151
|
nthMatch: z.coerce.number().int().min(0).optional().describe('If the selector matches multiple elements, hover over the Nth one (0-indexed).'),
|
|
147
152
|
sessionId: z.string().optional().describe('Browser session ID. If omitted, auto-selects the only open session.'),
|
|
153
|
+
tabId: tabIdField,
|
|
148
154
|
};
|
|
149
155
|
|
|
150
156
|
export const browserHoverDescription =
|
|
151
157
|
'Hover over an element. Useful for revealing dropdowns, tooltips, or hover-triggered content. Accepts Playwright selectors.';
|
|
152
158
|
|
|
153
|
-
export async function handleBrowserHover(args: { selector: string; nthMatch?: number; sessionId?: string }) {
|
|
154
|
-
const resolved = await ni.resolveSession(args.sessionId);
|
|
159
|
+
export async function handleBrowserHover(args: { selector: string; nthMatch?: number; sessionId?: string; tabId?: string }) {
|
|
160
|
+
const resolved = await ni.resolveSession(args.sessionId, undefined, args.tabId);
|
|
155
161
|
if ('error' in resolved) return text(resolved.error);
|
|
156
162
|
|
|
157
|
-
const result = await ni.hover(resolved.sessionId, args.selector, args.nthMatch);
|
|
163
|
+
const result = await ni.hover(resolved.sessionId, args.selector, args.nthMatch, resolved.tabId);
|
|
158
164
|
if (result.error) return text(`Hover failed: ${result.error}${formatClickHints(result)}`);
|
|
159
165
|
|
|
160
166
|
const location = result.url ? ` — ${result.url} "${result.title}"` : '';
|
|
@@ -168,16 +174,17 @@ export const browserSelectSchema = {
|
|
|
168
174
|
value: z.string().describe('The option value to select.'),
|
|
169
175
|
nthMatch: z.coerce.number().int().min(0).optional().describe('If the selector matches multiple elements, select from the Nth one (0-indexed).'),
|
|
170
176
|
sessionId: z.string().optional().describe('Browser session ID. If omitted, auto-selects the only open session.'),
|
|
177
|
+
tabId: tabIdField,
|
|
171
178
|
};
|
|
172
179
|
|
|
173
180
|
export const browserSelectDescription =
|
|
174
181
|
'Select an option from a <select> dropdown by CSS selector and option value.';
|
|
175
182
|
|
|
176
|
-
export async function handleBrowserSelect(args: { selector: string; value: string; nthMatch?: number; sessionId?: string }) {
|
|
177
|
-
const resolved = await ni.resolveSession(args.sessionId);
|
|
183
|
+
export async function handleBrowserSelect(args: { selector: string; value: string; nthMatch?: number; sessionId?: string; tabId?: string }) {
|
|
184
|
+
const resolved = await ni.resolveSession(args.sessionId, undefined, args.tabId);
|
|
178
185
|
if ('error' in resolved) return text(resolved.error);
|
|
179
186
|
|
|
180
|
-
const result = await ni.selectOption(resolved.sessionId, args.selector, args.value, args.nthMatch);
|
|
187
|
+
const result = await ni.selectOption(resolved.sessionId, args.selector, args.value, args.nthMatch, resolved.tabId);
|
|
181
188
|
if (result.error) return text(`Select failed: ${result.error}${formatClickHints(result)}`);
|
|
182
189
|
|
|
183
190
|
const location = result.url ? ` — ${result.url} "${result.title}"` : '';
|
|
@@ -189,16 +196,17 @@ export async function handleBrowserSelect(args: { selector: string; value: strin
|
|
|
189
196
|
export const browserPressSchema = {
|
|
190
197
|
key: z.string().describe('Key or key combo to press (e.g. "Enter", "Tab", "Control+A", "Escape", "ArrowDown").'),
|
|
191
198
|
sessionId: z.string().optional().describe('Browser session ID. If omitted, auto-selects the only open session.'),
|
|
199
|
+
tabId: tabIdField,
|
|
192
200
|
};
|
|
193
201
|
|
|
194
202
|
export const browserPressDescription =
|
|
195
203
|
'Press a keyboard key or key combination. Supports modifiers like Control+A, Shift+Enter, etc.';
|
|
196
204
|
|
|
197
|
-
export async function handleBrowserPress(args: { key: string; sessionId?: string }) {
|
|
198
|
-
const resolved = await ni.resolveSession(args.sessionId);
|
|
205
|
+
export async function handleBrowserPress(args: { key: string; sessionId?: string; tabId?: string }) {
|
|
206
|
+
const resolved = await ni.resolveSession(args.sessionId, undefined, args.tabId);
|
|
199
207
|
if ('error' in resolved) return text(resolved.error);
|
|
200
208
|
|
|
201
|
-
const result = await ni.pressKey(resolved.sessionId, args.key);
|
|
209
|
+
const result = await ni.pressKey(resolved.sessionId, args.key, resolved.tabId);
|
|
202
210
|
if (result.error) return text(`Press failed: ${result.error}`);
|
|
203
211
|
|
|
204
212
|
const location = result.url ? ` — ${result.url} "${result.title}"` : '';
|
|
@@ -212,6 +220,7 @@ export const browserScrollSchema = {
|
|
|
212
220
|
distance: z.coerce.number().optional().describe('Pixels to scroll (default: 500).'),
|
|
213
221
|
selector: z.string().optional().describe('Scroll within a specific element instead of the page. Twitter: [data-testid="primaryColumn"] for main feed. Facebook: [role="feed"] for group/page post feed. TikTok: [data-e2e="comment-list"] for comment panel, [data-tt="components_PostTable_Container"] for Studio content table. WhatsApp: [aria-label="Lista de conversas"] for chat list sidebar, [role="application"] or the main chat panel for message history.'),
|
|
214
222
|
sessionId: z.string().optional().describe('Browser session ID. If omitted, auto-selects the only open session.'),
|
|
223
|
+
tabId: tabIdField,
|
|
215
224
|
};
|
|
216
225
|
|
|
217
226
|
export const browserScrollDescription =
|
|
@@ -219,11 +228,11 @@ export const browserScrollDescription =
|
|
|
219
228
|
'Instagram: Home feed — scroll down 800–1200px to load more posts. Profile grid — scroll down to load more posts. Reels — scroll down 800px to advance to next reel. Post page comments — scroll within the comment panel to load older comments. Explore page — scroll down to load more grid posts. ' +
|
|
220
229
|
'LinkedIn: Feed — scroll down 800–1200px to load more posts. Profile — scroll down to load more sections. Notifications — scroll down for older notifications. Messaging conversations sidebar — scroll within .msg-conversations-container. Search results — scroll down for more results. My Network suggestions — scroll down for more people to follow/connect.';
|
|
221
230
|
|
|
222
|
-
export async function handleBrowserScroll(args: { direction: string; distance?: number; selector?: string; sessionId?: string }) {
|
|
223
|
-
const resolved = await ni.resolveSession(args.sessionId);
|
|
231
|
+
export async function handleBrowserScroll(args: { direction: string; distance?: number; selector?: string; sessionId?: string; tabId?: string }) {
|
|
232
|
+
const resolved = await ni.resolveSession(args.sessionId, undefined, args.tabId);
|
|
224
233
|
if ('error' in resolved) return text(resolved.error);
|
|
225
234
|
|
|
226
|
-
const result = await ni.scroll(resolved.sessionId, { direction: args.direction, distance: args.distance, selector: args.selector });
|
|
235
|
+
const result = await ni.scroll(resolved.sessionId, { direction: args.direction, distance: args.distance, selector: args.selector }, resolved.tabId);
|
|
227
236
|
if (result.error) return text(`Scroll failed: ${result.error}`);
|
|
228
237
|
|
|
229
238
|
const target = args.selector ? `"${args.selector}"` : 'page';
|
|
@@ -237,6 +246,7 @@ export const browserUploadSchema = {
|
|
|
237
246
|
filePaths: z.array(z.string()).describe('Absolute file paths to upload. Twitter supports up to 4 images or 1 video per tweet.'),
|
|
238
247
|
nthMatch: z.coerce.number().int().min(0).optional().describe('If the selector matches multiple file inputs, upload to the Nth one (0-indexed).'),
|
|
239
248
|
sessionId: z.string().optional().describe('Browser session ID. If omitted, auto-selects the only open session.'),
|
|
249
|
+
tabId: tabIdField,
|
|
240
250
|
};
|
|
241
251
|
|
|
242
252
|
export const browserUploadDescription =
|
|
@@ -244,11 +254,11 @@ export const browserUploadDescription =
|
|
|
244
254
|
'TikTok Studio: click button:has-text("Selecionar vídeo") first, then use selector \'input[type="file"]\' — supports a single video file. ' +
|
|
245
255
|
'Instagram: Click svg[aria-label="Novo post"] in sidebar to open the create dialog, then use browser_upload on the file input that appears. Supports images and videos.';
|
|
246
256
|
|
|
247
|
-
export async function handleBrowserUpload(args: { selector: string; filePaths: string[]; nthMatch?: number; sessionId?: string }) {
|
|
248
|
-
const resolved = await ni.resolveSession(args.sessionId);
|
|
257
|
+
export async function handleBrowserUpload(args: { selector: string; filePaths: string[]; nthMatch?: number; sessionId?: string; tabId?: string }) {
|
|
258
|
+
const resolved = await ni.resolveSession(args.sessionId, undefined, args.tabId);
|
|
249
259
|
if ('error' in resolved) return text(resolved.error);
|
|
250
260
|
|
|
251
|
-
const result = await ni.upload(resolved.sessionId, args.selector, args.filePaths, args.nthMatch);
|
|
261
|
+
const result = await ni.upload(resolved.sessionId, args.selector, args.filePaths, args.nthMatch, resolved.tabId);
|
|
252
262
|
if (result.error) return text(`Upload failed: ${result.error}${formatClickHints(result)}`);
|
|
253
263
|
|
|
254
264
|
return text(`Uploaded ${args.filePaths.length} file(s) via "${args.selector}" — now at ${result.url} "${result.title}"`);
|
|
@@ -1,77 +1,83 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import * as ni from '../services/neural-interface.js';
|
|
3
|
-
import { text } from './response.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
if (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
export const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import * as ni from '../services/neural-interface.js';
|
|
3
|
+
import { text } from './response.js';
|
|
4
|
+
|
|
5
|
+
const tabIdField = z.string().optional().describe('Target a specific tab within the session. Auto-resolved from environment if omitted.');
|
|
6
|
+
|
|
7
|
+
// ── browser_navigate ──
|
|
8
|
+
|
|
9
|
+
export const browserNavigateSchema = {
|
|
10
|
+
url: z.string().describe('The URL to navigate to.'),
|
|
11
|
+
sessionId: z.string().optional().describe('Browser session ID. If omitted, auto-selects the only open session or creates a new one.'),
|
|
12
|
+
tabId: tabIdField,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const browserNavigateDescription =
|
|
16
|
+
'Navigate the browser to a URL. If no browser session exists, one is created automatically.';
|
|
17
|
+
|
|
18
|
+
export async function handleBrowserNavigate(args: { url: string; sessionId?: string; tabId?: string }) {
|
|
19
|
+
const resolved = await ni.resolveSession(args.sessionId, { url: args.url }, args.tabId);
|
|
20
|
+
if ('error' in resolved) return text(resolved.error);
|
|
21
|
+
|
|
22
|
+
const result = await ni.navigate(resolved.sessionId, args.url, resolved.tabId);
|
|
23
|
+
if (result.error) return text(`Navigation failed: ${result.error}`);
|
|
24
|
+
|
|
25
|
+
return text(`Navigated to ${result.url} — "${result.title}"`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// ── browser_go_back ──
|
|
29
|
+
|
|
30
|
+
export const browserGoBackSchema = {
|
|
31
|
+
sessionId: z.string().optional().describe('Browser session ID. If omitted, auto-selects the only open session.'),
|
|
32
|
+
tabId: tabIdField,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const browserGoBackDescription = 'Go back to the previous page in browser history.';
|
|
36
|
+
|
|
37
|
+
export async function handleBrowserGoBack(args: { sessionId?: string; tabId?: string }) {
|
|
38
|
+
const resolved = await ni.resolveSession(args.sessionId, undefined, args.tabId);
|
|
39
|
+
if ('error' in resolved) return text(resolved.error);
|
|
40
|
+
|
|
41
|
+
const result = await ni.goBack(resolved.sessionId, resolved.tabId);
|
|
42
|
+
if (result.error) return text(`Go back failed: ${result.error}`);
|
|
43
|
+
|
|
44
|
+
return text(`Went back to ${result.url} — "${result.title}"`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// ── browser_go_forward ──
|
|
48
|
+
|
|
49
|
+
export const browserGoForwardSchema = {
|
|
50
|
+
sessionId: z.string().optional().describe('Browser session ID. If omitted, auto-selects the only open session.'),
|
|
51
|
+
tabId: tabIdField,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const browserGoForwardDescription = 'Go forward to the next page in browser history.';
|
|
55
|
+
|
|
56
|
+
export async function handleBrowserGoForward(args: { sessionId?: string; tabId?: string }) {
|
|
57
|
+
const resolved = await ni.resolveSession(args.sessionId, undefined, args.tabId);
|
|
58
|
+
if ('error' in resolved) return text(resolved.error);
|
|
59
|
+
|
|
60
|
+
const result = await ni.goForward(resolved.sessionId, resolved.tabId);
|
|
61
|
+
if (result.error) return text(`Go forward failed: ${result.error}`);
|
|
62
|
+
|
|
63
|
+
return text(`Went forward to ${result.url} — "${result.title}"`);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// ── browser_reload ──
|
|
67
|
+
|
|
68
|
+
export const browserReloadSchema = {
|
|
69
|
+
sessionId: z.string().optional().describe('Browser session ID. If omitted, auto-selects the only open session.'),
|
|
70
|
+
tabId: tabIdField,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const browserReloadDescription = 'Reload the current page. Useful after making changes or when content is stale.';
|
|
74
|
+
|
|
75
|
+
export async function handleBrowserReload(args: { sessionId?: string; tabId?: string }) {
|
|
76
|
+
const resolved = await ni.resolveSession(args.sessionId, undefined, args.tabId);
|
|
77
|
+
if ('error' in resolved) return text(resolved.error);
|
|
78
|
+
|
|
79
|
+
const result = await ni.reload(resolved.sessionId, resolved.tabId);
|
|
80
|
+
if (result.error) return text(`Reload failed: ${result.error}`);
|
|
81
|
+
|
|
82
|
+
return text(`Reloaded — now at ${result.url} "${result.title}"`);
|
|
83
|
+
}
|