instavm 0.16.0 → 0.17.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/README.md +86 -9
- package/dist/InstaVM-DjkmUcaP.d.mts +1393 -0
- package/dist/InstaVM-DjkmUcaP.d.ts +1393 -0
- package/dist/_instavmToolsCore-34H4iqVZ.d.mts +26 -0
- package/dist/_instavmToolsCore-BuaJyxXB.d.ts +26 -0
- package/dist/cli.js +5821 -2296
- package/dist/cli.js.map +1 -1
- package/dist/index.d.mts +12 -919
- package/dist/index.d.ts +12 -919
- package/dist/index.js +1464 -140
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1449 -135
- package/dist/index.mjs.map +1 -1
- package/dist/integrations/azure-openai.d.mts +18 -0
- package/dist/integrations/azure-openai.d.ts +18 -0
- package/dist/integrations/azure-openai.js +332 -0
- package/dist/integrations/azure-openai.js.map +1 -0
- package/dist/integrations/azure-openai.mjs +299 -0
- package/dist/integrations/azure-openai.mjs.map +1 -0
- package/dist/integrations/langchain.d.mts +7 -0
- package/dist/integrations/langchain.d.ts +7 -0
- package/dist/integrations/langchain.js +364 -0
- package/dist/integrations/langchain.js.map +1 -0
- package/dist/integrations/langchain.mjs +327 -0
- package/dist/integrations/langchain.mjs.map +1 -0
- package/dist/integrations/llamaindex.d.mts +11 -0
- package/dist/integrations/llamaindex.d.ts +11 -0
- package/dist/integrations/llamaindex.js +415 -0
- package/dist/integrations/llamaindex.js.map +1 -0
- package/dist/integrations/llamaindex.mjs +378 -0
- package/dist/integrations/llamaindex.mjs.map +1 -0
- package/dist/integrations/ollama.d.mts +35 -0
- package/dist/integrations/ollama.d.ts +35 -0
- package/dist/integrations/ollama.js +421 -0
- package/dist/integrations/ollama.js.map +1 -0
- package/dist/integrations/ollama.mjs +391 -0
- package/dist/integrations/ollama.mjs.map +1 -0
- package/dist/integrations/openai.d.mts +19 -0
- package/dist/integrations/openai.d.ts +19 -0
- package/dist/integrations/openai.js +302 -0
- package/dist/integrations/openai.js.map +1 -0
- package/dist/integrations/openai.mjs +272 -0
- package/dist/integrations/openai.mjs.map +1 -0
- package/package.json +44 -3
- package/dist/integrations/openai/index.d.mts +0 -16
- package/dist/integrations/openai/index.d.ts +0 -16
- package/dist/integrations/openai/index.js +0 -38
- package/dist/integrations/openai/index.js.map +0 -1
- package/dist/integrations/openai/index.mjs +0 -12
- package/dist/integrations/openai/index.mjs.map +0 -1
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/integrations/ollama/index.ts
|
|
21
|
+
var ollama_exports = {};
|
|
22
|
+
__export(ollama_exports, {
|
|
23
|
+
OllamaAgent: () => OllamaAgent,
|
|
24
|
+
executeOllamaTool: () => executeOllamaTool,
|
|
25
|
+
getOllamaTools: () => getOllamaTools,
|
|
26
|
+
get_ollama_tools: () => get_ollama_tools
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(ollama_exports);
|
|
29
|
+
|
|
30
|
+
// src/integrations/_instavmToolsCore.ts
|
|
31
|
+
var INSTAVM_OPENAI_TOOLS = [
|
|
32
|
+
{
|
|
33
|
+
type: "function",
|
|
34
|
+
function: {
|
|
35
|
+
name: "create_browser_session",
|
|
36
|
+
description: "Create a new browser session for web automation",
|
|
37
|
+
parameters: {
|
|
38
|
+
type: "object",
|
|
39
|
+
properties: {
|
|
40
|
+
width: { type: "integer", description: "Browser width", default: 1920 },
|
|
41
|
+
height: { type: "integer", description: "Browser height", default: 1080 }
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
type: "function",
|
|
48
|
+
function: {
|
|
49
|
+
name: "navigate_to_url",
|
|
50
|
+
description: "Navigate browser to URL",
|
|
51
|
+
parameters: {
|
|
52
|
+
type: "object",
|
|
53
|
+
properties: { url: { type: "string", description: "URL to navigate to" } },
|
|
54
|
+
required: ["url"]
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
type: "function",
|
|
60
|
+
function: {
|
|
61
|
+
name: "extract_page_content",
|
|
62
|
+
description: "Extract text content from page",
|
|
63
|
+
parameters: {
|
|
64
|
+
type: "object",
|
|
65
|
+
properties: {
|
|
66
|
+
selector: { type: "string", description: "CSS selector", default: "body" },
|
|
67
|
+
max_length: { type: "integer", description: "Max content length", default: 1e4 }
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
type: "function",
|
|
74
|
+
function: {
|
|
75
|
+
name: "extract_elements",
|
|
76
|
+
description: "Extract elements using CSS selector",
|
|
77
|
+
parameters: {
|
|
78
|
+
type: "object",
|
|
79
|
+
properties: {
|
|
80
|
+
selector: { type: "string", description: "CSS selector" },
|
|
81
|
+
attributes: {
|
|
82
|
+
type: "array",
|
|
83
|
+
items: { type: "string" },
|
|
84
|
+
description: "Attributes to extract",
|
|
85
|
+
default: ["text"]
|
|
86
|
+
},
|
|
87
|
+
max_results: { type: "integer", description: "Max results", default: 10 }
|
|
88
|
+
},
|
|
89
|
+
required: ["selector"]
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
type: "function",
|
|
95
|
+
function: {
|
|
96
|
+
name: "click_element",
|
|
97
|
+
description: "Click a page element",
|
|
98
|
+
parameters: {
|
|
99
|
+
type: "object",
|
|
100
|
+
properties: {
|
|
101
|
+
selector: { type: "string", description: "CSS selector" },
|
|
102
|
+
timeout: { type: "integer", description: "Timeout ms", default: 1e4 }
|
|
103
|
+
},
|
|
104
|
+
required: ["selector"]
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
type: "function",
|
|
110
|
+
function: {
|
|
111
|
+
name: "take_screenshot",
|
|
112
|
+
description: "Take page screenshot",
|
|
113
|
+
parameters: {
|
|
114
|
+
type: "object",
|
|
115
|
+
properties: {
|
|
116
|
+
full_page: { type: "boolean", description: "Full page capture", default: true }
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
type: "function",
|
|
123
|
+
function: {
|
|
124
|
+
name: "execute_python_code",
|
|
125
|
+
description: "Execute Python code. Use !command for bash (e.g., !pip install pandas)",
|
|
126
|
+
parameters: {
|
|
127
|
+
type: "object",
|
|
128
|
+
properties: { code: { type: "string", description: "Python/bash code to execute" } },
|
|
129
|
+
required: ["code"]
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
type: "function",
|
|
135
|
+
function: {
|
|
136
|
+
name: "scroll_page",
|
|
137
|
+
description: "Scroll page",
|
|
138
|
+
parameters: {
|
|
139
|
+
type: "object",
|
|
140
|
+
properties: {
|
|
141
|
+
x: { type: "integer", default: 0 },
|
|
142
|
+
y: { type: "integer", default: 500 }
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
type: "function",
|
|
149
|
+
function: {
|
|
150
|
+
name: "wait_for_element",
|
|
151
|
+
description: "Wait for element to appear",
|
|
152
|
+
parameters: {
|
|
153
|
+
type: "object",
|
|
154
|
+
properties: {
|
|
155
|
+
selector: { type: "string", description: "CSS selector" },
|
|
156
|
+
timeout: { type: "integer", default: 1e4 }
|
|
157
|
+
},
|
|
158
|
+
required: ["selector"]
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
];
|
|
163
|
+
function serializeExecution(result) {
|
|
164
|
+
return {
|
|
165
|
+
stdout: result.stdout,
|
|
166
|
+
stderr: result.stderr,
|
|
167
|
+
success: result.success,
|
|
168
|
+
executionTime: result.executionTime,
|
|
169
|
+
cpuTime: result.cpuTime,
|
|
170
|
+
sessionId: result.sessionId,
|
|
171
|
+
error: result.error
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function parseArgs(raw) {
|
|
175
|
+
if (!raw || !raw.trim()) return {};
|
|
176
|
+
try {
|
|
177
|
+
const v = JSON.parse(raw);
|
|
178
|
+
return v && typeof v === "object" && !Array.isArray(v) ? v : {};
|
|
179
|
+
} catch {
|
|
180
|
+
return {};
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
async function executeInstavmToolCall(instavm, toolCall, browserSession) {
|
|
184
|
+
const functionName = toolCall.function.name;
|
|
185
|
+
const arguments_ = parseArgs(toolCall.function.arguments);
|
|
186
|
+
try {
|
|
187
|
+
if (functionName === "create_browser_session") {
|
|
188
|
+
const width = Number(arguments_.width ?? 1920);
|
|
189
|
+
const height = Number(arguments_.height ?? 1080);
|
|
190
|
+
const session = await instavm.browser.createSession({ viewportWidth: width, viewportHeight: height });
|
|
191
|
+
return {
|
|
192
|
+
success: true,
|
|
193
|
+
session_id: session.sessionId,
|
|
194
|
+
session,
|
|
195
|
+
message: `Created browser session ${session.sessionId}`
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
if (functionName === "navigate_to_url") {
|
|
199
|
+
if (!browserSession) {
|
|
200
|
+
return { success: false, error: "No browser session. Create one first." };
|
|
201
|
+
}
|
|
202
|
+
const url = String(arguments_.url ?? "");
|
|
203
|
+
const result = await browserSession.navigate(url);
|
|
204
|
+
return { success: true, message: `Navigated to ${url}`, result };
|
|
205
|
+
}
|
|
206
|
+
if (functionName === "extract_page_content") {
|
|
207
|
+
if (!browserSession) {
|
|
208
|
+
return { success: false, error: "No browser session active" };
|
|
209
|
+
}
|
|
210
|
+
const selector = String(arguments_.selector ?? "body");
|
|
211
|
+
const maxLength = Number(arguments_.max_length ?? 1e4);
|
|
212
|
+
const elements = await browserSession.extractElements(selector, ["text"]);
|
|
213
|
+
if (elements?.length) {
|
|
214
|
+
const first = elements[0];
|
|
215
|
+
const text = String(first.text ?? first.content ?? "").slice(0, maxLength);
|
|
216
|
+
return { success: true, content: text, length: text.length };
|
|
217
|
+
}
|
|
218
|
+
return { success: false, error: "No content found" };
|
|
219
|
+
}
|
|
220
|
+
if (functionName === "extract_elements") {
|
|
221
|
+
if (!browserSession) {
|
|
222
|
+
return { success: false, error: "No browser session active" };
|
|
223
|
+
}
|
|
224
|
+
const selector = String(arguments_.selector ?? "");
|
|
225
|
+
const attributes = arguments_.attributes ?? ["text"];
|
|
226
|
+
const maxResults = Number(arguments_.max_results ?? 10);
|
|
227
|
+
const elements = await browserSession.extractElements(selector, attributes);
|
|
228
|
+
const list = Array.isArray(elements) ? elements : [];
|
|
229
|
+
return { success: true, elements: list.slice(0, maxResults), count: list.length };
|
|
230
|
+
}
|
|
231
|
+
if (functionName === "click_element") {
|
|
232
|
+
if (!browserSession) {
|
|
233
|
+
return { success: false, error: "No browser session active" };
|
|
234
|
+
}
|
|
235
|
+
const selector = String(arguments_.selector ?? "");
|
|
236
|
+
const timeout = Number(arguments_.timeout ?? 1e4);
|
|
237
|
+
await browserSession.click(selector, { timeout });
|
|
238
|
+
return { success: true, message: `Clicked ${selector}` };
|
|
239
|
+
}
|
|
240
|
+
if (functionName === "take_screenshot") {
|
|
241
|
+
if (!browserSession) {
|
|
242
|
+
return { success: false, error: "No browser session active" };
|
|
243
|
+
}
|
|
244
|
+
const fullPage = arguments_.full_page !== false;
|
|
245
|
+
const screenshot = await browserSession.screenshot({ fullPage });
|
|
246
|
+
return { success: true, screenshot_length: screenshot.length, screenshot };
|
|
247
|
+
}
|
|
248
|
+
if (functionName === "execute_python_code") {
|
|
249
|
+
const code = String(arguments_.code ?? "");
|
|
250
|
+
const result = await instavm.execute(code, { language: "python" });
|
|
251
|
+
return { success: true, output: serializeExecution(result) };
|
|
252
|
+
}
|
|
253
|
+
if (functionName === "scroll_page") {
|
|
254
|
+
if (!browserSession) {
|
|
255
|
+
return { success: false, error: "No browser session active" };
|
|
256
|
+
}
|
|
257
|
+
const x = Number(arguments_.x ?? 0);
|
|
258
|
+
const y = Number(arguments_.y ?? 500);
|
|
259
|
+
await browserSession.scroll({ x, y });
|
|
260
|
+
return { success: true, message: `Scrolled to (${x}, ${y})` };
|
|
261
|
+
}
|
|
262
|
+
if (functionName === "wait_for_element") {
|
|
263
|
+
if (!browserSession) {
|
|
264
|
+
return { success: false, error: "No browser session active" };
|
|
265
|
+
}
|
|
266
|
+
const selector = String(arguments_.selector ?? "");
|
|
267
|
+
const timeout = Number(arguments_.timeout ?? 1e4);
|
|
268
|
+
const result = await browserSession.waitFor("visible", selector, timeout);
|
|
269
|
+
return { success: true, message: `Element ${selector} visible`, result };
|
|
270
|
+
}
|
|
271
|
+
return { success: false, error: `Unknown function: ${functionName}` };
|
|
272
|
+
} catch (e) {
|
|
273
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
274
|
+
return { success: false, error: `Function ${functionName} failed: ${msg}` };
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
var INSTAVM_OLLAMA_TOOLS = INSTAVM_OPENAI_TOOLS.filter(
|
|
278
|
+
(t) => ["create_browser_session", "navigate_to_url", "extract_page_content", "extract_elements", "execute_python_code", "take_screenshot"].includes(
|
|
279
|
+
t.function.name
|
|
280
|
+
)
|
|
281
|
+
);
|
|
282
|
+
async function executeOllamaStyleTool(instavm, functionName, arguments_, browserSession) {
|
|
283
|
+
return executeInstavmToolCall(
|
|
284
|
+
instavm,
|
|
285
|
+
{ function: { name: functionName, arguments: JSON.stringify(arguments_ || {}) } },
|
|
286
|
+
browserSession
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// src/integrations/ollama/index.ts
|
|
291
|
+
function getOllamaTools() {
|
|
292
|
+
return INSTAVM_OLLAMA_TOOLS;
|
|
293
|
+
}
|
|
294
|
+
var get_ollama_tools = getOllamaTools;
|
|
295
|
+
async function executeOllamaTool(instavm, functionName, arguments_, browserSession) {
|
|
296
|
+
return executeOllamaStyleTool(instavm, functionName, arguments_, browserSession);
|
|
297
|
+
}
|
|
298
|
+
var DEFAULT_SYSTEM = `You are a web automation assistant with access to browser and code execution tools.
|
|
299
|
+
Be systematic and help the user accomplish their web automation tasks.`;
|
|
300
|
+
var OllamaAgent = class {
|
|
301
|
+
constructor(instavm, ollamaBaseUrl = "http://localhost:11434", model = "llama2", preferFunctionCalling = true) {
|
|
302
|
+
this.instavm = instavm;
|
|
303
|
+
this.ollamaBaseUrl = ollamaBaseUrl;
|
|
304
|
+
this.model = model;
|
|
305
|
+
this.preferFunctionCalling = preferFunctionCalling;
|
|
306
|
+
this.browserSession = null;
|
|
307
|
+
}
|
|
308
|
+
async chat(message, systemPrompt, useFunctionCalling = true) {
|
|
309
|
+
const system = systemPrompt ?? DEFAULT_SYSTEM;
|
|
310
|
+
try {
|
|
311
|
+
if (useFunctionCalling && this.preferFunctionCalling) {
|
|
312
|
+
return await this.chatWithFunctionCalling(message, system);
|
|
313
|
+
}
|
|
314
|
+
return await this.chatPlain(message, system);
|
|
315
|
+
} catch (e) {
|
|
316
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
317
|
+
if (useFunctionCalling && this.preferFunctionCalling) {
|
|
318
|
+
try {
|
|
319
|
+
return await this.chatPlain(message, system);
|
|
320
|
+
} catch (e2) {
|
|
321
|
+
return { error: `Ollama chat failed: ${e2 instanceof Error ? e2.message : String(e2)}` };
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
return { error: `Ollama chat failed: ${msg}` };
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
async chatPlain(message, system) {
|
|
328
|
+
const url = `${this.ollamaBaseUrl.replace(/\/$/, "")}/api/chat`;
|
|
329
|
+
const res = await fetch(url, {
|
|
330
|
+
method: "POST",
|
|
331
|
+
headers: { "Content-Type": "application/json" },
|
|
332
|
+
body: JSON.stringify({
|
|
333
|
+
model: this.model,
|
|
334
|
+
messages: [
|
|
335
|
+
{ role: "system", content: system },
|
|
336
|
+
{ role: "user", content: message }
|
|
337
|
+
],
|
|
338
|
+
stream: false
|
|
339
|
+
})
|
|
340
|
+
});
|
|
341
|
+
if (!res.ok) {
|
|
342
|
+
return { error: `Ollama HTTP ${res.status}: ${await res.text()}` };
|
|
343
|
+
}
|
|
344
|
+
const data = await res.json();
|
|
345
|
+
const content = data.message?.content ?? "";
|
|
346
|
+
return { response: typeof content === "string" ? content : JSON.stringify(content) };
|
|
347
|
+
}
|
|
348
|
+
async chatWithFunctionCalling(message, system) {
|
|
349
|
+
const url = `${this.ollamaBaseUrl.replace(/\/$/, "")}/api/chat`;
|
|
350
|
+
const tools = getOllamaTools();
|
|
351
|
+
const res = await fetch(url, {
|
|
352
|
+
method: "POST",
|
|
353
|
+
headers: { "Content-Type": "application/json" },
|
|
354
|
+
body: JSON.stringify({
|
|
355
|
+
model: this.model,
|
|
356
|
+
messages: [
|
|
357
|
+
{ role: "system", content: system },
|
|
358
|
+
{ role: "user", content: message }
|
|
359
|
+
],
|
|
360
|
+
tools,
|
|
361
|
+
stream: false
|
|
362
|
+
})
|
|
363
|
+
});
|
|
364
|
+
if (!res.ok) {
|
|
365
|
+
return { error: `Ollama HTTP ${res.status}: ${await res.text()}` };
|
|
366
|
+
}
|
|
367
|
+
const data = await res.json();
|
|
368
|
+
const ollamaMessage = data.message;
|
|
369
|
+
const toolCalls = ollamaMessage?.tool_calls;
|
|
370
|
+
if (toolCalls?.length) {
|
|
371
|
+
const toolCall = toolCalls[0];
|
|
372
|
+
const functionName = toolCall.function.name;
|
|
373
|
+
let arguments_ = {};
|
|
374
|
+
try {
|
|
375
|
+
arguments_ = JSON.parse(toolCall.function.arguments || "{}");
|
|
376
|
+
} catch {
|
|
377
|
+
arguments_ = {};
|
|
378
|
+
}
|
|
379
|
+
const toolResult = await executeOllamaTool(this.instavm, functionName, arguments_, this.browserSession);
|
|
380
|
+
if (toolResult.session) {
|
|
381
|
+
this.browserSession = toolResult.session;
|
|
382
|
+
}
|
|
383
|
+
const follow = await fetch(url, {
|
|
384
|
+
method: "POST",
|
|
385
|
+
headers: { "Content-Type": "application/json" },
|
|
386
|
+
body: JSON.stringify({
|
|
387
|
+
model: this.model,
|
|
388
|
+
messages: [
|
|
389
|
+
{ role: "system", content: system },
|
|
390
|
+
{ role: "user", content: message },
|
|
391
|
+
{
|
|
392
|
+
role: "assistant",
|
|
393
|
+
content: ollamaMessage?.content ?? "",
|
|
394
|
+
tool_calls: toolCalls
|
|
395
|
+
},
|
|
396
|
+
{ role: "tool", content: JSON.stringify(toolResult), name: functionName }
|
|
397
|
+
],
|
|
398
|
+
tools,
|
|
399
|
+
stream: false
|
|
400
|
+
})
|
|
401
|
+
});
|
|
402
|
+
if (follow.ok) {
|
|
403
|
+
const final = await follow.json();
|
|
404
|
+
return {
|
|
405
|
+
response: final.message?.content ?? "",
|
|
406
|
+
tool_used: functionName,
|
|
407
|
+
tool_result: toolResult
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
return { response: ollamaMessage?.content ?? JSON.stringify(ollamaMessage ?? {}) };
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
415
|
+
0 && (module.exports = {
|
|
416
|
+
OllamaAgent,
|
|
417
|
+
executeOllamaTool,
|
|
418
|
+
getOllamaTools,
|
|
419
|
+
get_ollama_tools
|
|
420
|
+
});
|
|
421
|
+
//# sourceMappingURL=ollama.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/integrations/ollama/index.ts","../../src/integrations/_instavmToolsCore.ts"],"sourcesContent":["import type { InstaVM } from '../../client/InstaVM';\nimport type { BrowserSession } from '../../client/BrowserSession';\nimport {\n INSTAVM_OLLAMA_TOOLS,\n executeOllamaStyleTool,\n type InstaVMOpenAITool,\n} from '../_instavmToolsCore';\n\nexport type { InstaVMOpenAITool };\n\n/** Tool definitions for Ollama `/api/chat` (subset matching Python `get_ollama_tools`). */\nexport function getOllamaTools(): InstaVMOpenAITool[] {\n return INSTAVM_OLLAMA_TOOLS;\n}\n\nexport const get_ollama_tools = getOllamaTools;\n\n/** Execute one Ollama tool by name (Python `execute_ollama_tool`). */\nexport async function executeOllamaTool(\n instavm: InstaVM,\n functionName: string,\n arguments_: Record<string, unknown>,\n browserSession?: BrowserSession | null,\n) {\n return executeOllamaStyleTool(instavm, functionName, arguments_, browserSession);\n}\n\nconst DEFAULT_SYSTEM = `You are a web automation assistant with access to browser and code execution tools.\nBe systematic and help the user accomplish their web automation tasks.`;\n\nexport type OllamaChatResult =\n | { response: string; tool_used?: string; tool_result?: Record<string, unknown> }\n | { error: string };\n\n/**\n * Minimal Ollama + InstaVM agent using HTTP `/api/chat` (no required `ollama` npm package).\n */\nexport class OllamaAgent {\n private browserSession: BrowserSession | null = null;\n\n constructor(\n private readonly instavm: InstaVM,\n private readonly ollamaBaseUrl: string = 'http://localhost:11434',\n private readonly model: string = 'llama2',\n private readonly preferFunctionCalling: boolean = true,\n ) {}\n\n async chat(\n message: string,\n systemPrompt?: string,\n useFunctionCalling: boolean = true,\n ): Promise<OllamaChatResult> {\n const system = systemPrompt ?? DEFAULT_SYSTEM;\n try {\n if (useFunctionCalling && this.preferFunctionCalling) {\n return await this.chatWithFunctionCalling(message, system);\n }\n return await this.chatPlain(message, system);\n } catch (e) {\n const msg = e instanceof Error ? e.message : String(e);\n if (useFunctionCalling && this.preferFunctionCalling) {\n try {\n return await this.chatPlain(message, system);\n } catch (e2) {\n return { error: `Ollama chat failed: ${e2 instanceof Error ? e2.message : String(e2)}` };\n }\n }\n return { error: `Ollama chat failed: ${msg}` };\n }\n }\n\n private async chatPlain(message: string, system: string): Promise<OllamaChatResult> {\n const url = `${this.ollamaBaseUrl.replace(/\\/$/, '')}/api/chat`;\n const res = await fetch(url, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n model: this.model,\n messages: [\n { role: 'system', content: system },\n { role: 'user', content: message },\n ],\n stream: false,\n }),\n });\n if (!res.ok) {\n return { error: `Ollama HTTP ${res.status}: ${await res.text()}` };\n }\n const data = (await res.json()) as { message?: { content?: string } };\n const content = data.message?.content ?? '';\n return { response: typeof content === 'string' ? content : JSON.stringify(content) };\n }\n\n private async chatWithFunctionCalling(message: string, system: string): Promise<OllamaChatResult> {\n const url = `${this.ollamaBaseUrl.replace(/\\/$/, '')}/api/chat`;\n const tools = getOllamaTools();\n\n const res = await fetch(url, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n model: this.model,\n messages: [\n { role: 'system', content: system },\n { role: 'user', content: message },\n ],\n tools,\n stream: false,\n }),\n });\n if (!res.ok) {\n return { error: `Ollama HTTP ${res.status}: ${await res.text()}` };\n }\n\n const data = (await res.json()) as {\n message?: { content?: string; tool_calls?: Array<{ function: { name: string; arguments: string } }> };\n };\n const ollamaMessage = data.message;\n const toolCalls = ollamaMessage?.tool_calls;\n if (toolCalls?.length) {\n const toolCall = toolCalls[0];\n const functionName = toolCall.function.name;\n let arguments_: Record<string, unknown> = {};\n try {\n arguments_ = JSON.parse(toolCall.function.arguments || '{}') as Record<string, unknown>;\n } catch {\n arguments_ = {};\n }\n\n const toolResult = await executeOllamaTool(this.instavm, functionName, arguments_, this.browserSession);\n if (toolResult.session) {\n this.browserSession = toolResult.session;\n }\n\n const follow = await fetch(url, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n model: this.model,\n messages: [\n { role: 'system', content: system },\n { role: 'user', content: message },\n {\n role: 'assistant',\n content: ollamaMessage?.content ?? '',\n tool_calls: toolCalls,\n },\n { role: 'tool', content: JSON.stringify(toolResult), name: functionName },\n ],\n tools,\n stream: false,\n }),\n });\n\n if (follow.ok) {\n const final = (await follow.json()) as { message?: { content?: string } };\n return {\n response: final.message?.content ?? '',\n tool_used: functionName,\n tool_result: toolResult as Record<string, unknown>,\n };\n }\n }\n\n return { response: ollamaMessage?.content ?? JSON.stringify(ollamaMessage ?? {}) };\n }\n}\n","import type { InstaVM } from '../client/InstaVM';\nimport type { BrowserSession } from '../client/BrowserSession';\nimport type { ExecutionResult } from '../types/execution';\n\n/** OpenAI / Azure / Ollama–compatible function tool schema. */\nexport type InstaVMOpenAITool = {\n type: 'function';\n function: {\n name: string;\n description: string;\n parameters: Record<string, unknown>;\n };\n};\n\nexport function getInstavmOpenAITools(): InstaVMOpenAITool[] {\n return INSTAVM_OPENAI_TOOLS;\n}\n\nconst INSTAVM_OPENAI_TOOLS: InstaVMOpenAITool[] = [\n {\n type: 'function',\n function: {\n name: 'create_browser_session',\n description: 'Create a new browser session for web automation',\n parameters: {\n type: 'object',\n properties: {\n width: { type: 'integer', description: 'Browser width', default: 1920 },\n height: { type: 'integer', description: 'Browser height', default: 1080 },\n },\n },\n },\n },\n {\n type: 'function',\n function: {\n name: 'navigate_to_url',\n description: 'Navigate browser to URL',\n parameters: {\n type: 'object',\n properties: { url: { type: 'string', description: 'URL to navigate to' } },\n required: ['url'],\n },\n },\n },\n {\n type: 'function',\n function: {\n name: 'extract_page_content',\n description: 'Extract text content from page',\n parameters: {\n type: 'object',\n properties: {\n selector: { type: 'string', description: 'CSS selector', default: 'body' },\n max_length: { type: 'integer', description: 'Max content length', default: 10000 },\n },\n },\n },\n },\n {\n type: 'function',\n function: {\n name: 'extract_elements',\n description: 'Extract elements using CSS selector',\n parameters: {\n type: 'object',\n properties: {\n selector: { type: 'string', description: 'CSS selector' },\n attributes: {\n type: 'array',\n items: { type: 'string' },\n description: 'Attributes to extract',\n default: ['text'],\n },\n max_results: { type: 'integer', description: 'Max results', default: 10 },\n },\n required: ['selector'],\n },\n },\n },\n {\n type: 'function',\n function: {\n name: 'click_element',\n description: 'Click a page element',\n parameters: {\n type: 'object',\n properties: {\n selector: { type: 'string', description: 'CSS selector' },\n timeout: { type: 'integer', description: 'Timeout ms', default: 10000 },\n },\n required: ['selector'],\n },\n },\n },\n {\n type: 'function',\n function: {\n name: 'take_screenshot',\n description: 'Take page screenshot',\n parameters: {\n type: 'object',\n properties: {\n full_page: { type: 'boolean', description: 'Full page capture', default: true },\n },\n },\n },\n },\n {\n type: 'function',\n function: {\n name: 'execute_python_code',\n description: 'Execute Python code. Use !command for bash (e.g., !pip install pandas)',\n parameters: {\n type: 'object',\n properties: { code: { type: 'string', description: 'Python/bash code to execute' } },\n required: ['code'],\n },\n },\n },\n {\n type: 'function',\n function: {\n name: 'scroll_page',\n description: 'Scroll page',\n parameters: {\n type: 'object',\n properties: {\n x: { type: 'integer', default: 0 },\n y: { type: 'integer', default: 500 },\n },\n },\n },\n },\n {\n type: 'function',\n function: {\n name: 'wait_for_element',\n description: 'Wait for element to appear',\n parameters: {\n type: 'object',\n properties: {\n selector: { type: 'string', description: 'CSS selector' },\n timeout: { type: 'integer', default: 10000 },\n },\n required: ['selector'],\n },\n },\n },\n];\n\nfunction serializeExecution(result: ExecutionResult): Record<string, unknown> {\n return {\n stdout: result.stdout,\n stderr: result.stderr,\n success: result.success,\n executionTime: result.executionTime,\n cpuTime: result.cpuTime,\n sessionId: result.sessionId,\n error: result.error,\n };\n}\n\nexport type ToolCallLike = {\n function: {\n name: string;\n arguments: string;\n };\n};\n\nfunction parseArgs(raw: string): Record<string, unknown> {\n if (!raw || !raw.trim()) return {};\n try {\n const v = JSON.parse(raw) as unknown;\n return v && typeof v === 'object' && !Array.isArray(v) ? (v as Record<string, unknown>) : {};\n } catch {\n return {};\n }\n}\n\n/**\n * Execute a single OpenAI-style tool call (parity with Python `execute_tool`).\n * Returns a dict; when a new browser session is created, `session` holds the `BrowserSession` instance.\n */\nexport async function executeInstavmToolCall(\n instavm: InstaVM,\n toolCall: ToolCallLike,\n browserSession?: BrowserSession | null,\n): Promise<Record<string, unknown> & { session?: BrowserSession }> {\n const functionName = toolCall.function.name;\n const arguments_ = parseArgs(toolCall.function.arguments);\n\n try {\n if (functionName === 'create_browser_session') {\n const width = Number(arguments_.width ?? 1920);\n const height = Number(arguments_.height ?? 1080);\n const session = await instavm.browser.createSession({ viewportWidth: width, viewportHeight: height });\n return {\n success: true,\n session_id: session.sessionId,\n session,\n message: `Created browser session ${session.sessionId}`,\n };\n }\n\n if (functionName === 'navigate_to_url') {\n if (!browserSession) {\n return { success: false, error: 'No browser session. Create one first.' };\n }\n const url = String(arguments_.url ?? '');\n const result = await browserSession.navigate(url);\n return { success: true, message: `Navigated to ${url}`, result };\n }\n\n if (functionName === 'extract_page_content') {\n if (!browserSession) {\n return { success: false, error: 'No browser session active' };\n }\n const selector = String(arguments_.selector ?? 'body');\n const maxLength = Number(arguments_.max_length ?? 10000);\n const elements = await browserSession.extractElements(selector, ['text']);\n if (elements?.length) {\n const first = elements[0] as Record<string, unknown>;\n const text = String(first.text ?? first.content ?? '').slice(0, maxLength);\n return { success: true, content: text, length: text.length };\n }\n return { success: false, error: 'No content found' };\n }\n\n if (functionName === 'extract_elements') {\n if (!browserSession) {\n return { success: false, error: 'No browser session active' };\n }\n const selector = String(arguments_.selector ?? '');\n const attributes = (arguments_.attributes as string[] | undefined) ?? ['text'];\n const maxResults = Number(arguments_.max_results ?? 10);\n const elements = await browserSession.extractElements(selector, attributes);\n const list = Array.isArray(elements) ? elements : [];\n return { success: true, elements: list.slice(0, maxResults), count: list.length };\n }\n\n if (functionName === 'click_element') {\n if (!browserSession) {\n return { success: false, error: 'No browser session active' };\n }\n const selector = String(arguments_.selector ?? '');\n const timeout = Number(arguments_.timeout ?? 10000);\n await browserSession.click(selector, { timeout });\n return { success: true, message: `Clicked ${selector}` };\n }\n\n if (functionName === 'take_screenshot') {\n if (!browserSession) {\n return { success: false, error: 'No browser session active' };\n }\n const fullPage = arguments_.full_page !== false;\n const screenshot = await browserSession.screenshot({ fullPage });\n return { success: true, screenshot_length: screenshot.length, screenshot };\n }\n\n if (functionName === 'execute_python_code') {\n const code = String(arguments_.code ?? '');\n const result = await instavm.execute(code, { language: 'python' });\n return { success: true, output: serializeExecution(result) };\n }\n\n if (functionName === 'scroll_page') {\n if (!browserSession) {\n return { success: false, error: 'No browser session active' };\n }\n const x = Number(arguments_.x ?? 0);\n const y = Number(arguments_.y ?? 500);\n await browserSession.scroll({ x, y });\n return { success: true, message: `Scrolled to (${x}, ${y})` };\n }\n\n if (functionName === 'wait_for_element') {\n if (!browserSession) {\n return { success: false, error: 'No browser session active' };\n }\n const selector = String(arguments_.selector ?? '');\n const timeout = Number(arguments_.timeout ?? 10000);\n const result = await browserSession.waitFor('visible', selector, timeout);\n return { success: true, message: `Element ${selector} visible`, result };\n }\n\n return { success: false, error: `Unknown function: ${functionName}` };\n } catch (e) {\n const msg = e instanceof Error ? e.message : String(e);\n return { success: false, error: `Function ${functionName} failed: ${msg}` };\n }\n}\n\n/** Subset of tools used by Ollama example in Python SDK. */\nexport const INSTAVM_OLLAMA_TOOLS: InstaVMOpenAITool[] = INSTAVM_OPENAI_TOOLS.filter((t) =>\n ['create_browser_session', 'navigate_to_url', 'extract_page_content', 'extract_elements', 'execute_python_code', 'take_screenshot'].includes(\n t.function.name,\n ),\n);\n\nexport async function executeOllamaStyleTool(\n instavm: InstaVM,\n functionName: string,\n arguments_: Record<string, unknown>,\n browserSession?: BrowserSession | null,\n): Promise<Record<string, unknown> & { session?: BrowserSession }> {\n return executeInstavmToolCall(\n instavm,\n { function: { name: functionName, arguments: JSON.stringify(arguments_ || {}) } },\n browserSession,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACkBA,IAAM,uBAA4C;AAAA,EAChD;AAAA,IACE,MAAM;AAAA,IACN,UAAU;AAAA,MACR,MAAM;AAAA,MACN,aAAa;AAAA,MACb,YAAY;AAAA,QACV,MAAM;AAAA,QACN,YAAY;AAAA,UACV,OAAO,EAAE,MAAM,WAAW,aAAa,iBAAiB,SAAS,KAAK;AAAA,UACtE,QAAQ,EAAE,MAAM,WAAW,aAAa,kBAAkB,SAAS,KAAK;AAAA,QAC1E;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,UAAU;AAAA,MACR,MAAM;AAAA,MACN,aAAa;AAAA,MACb,YAAY;AAAA,QACV,MAAM;AAAA,QACN,YAAY,EAAE,KAAK,EAAE,MAAM,UAAU,aAAa,qBAAqB,EAAE;AAAA,QACzE,UAAU,CAAC,KAAK;AAAA,MAClB;AAAA,IACF;AAAA,EACF;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,UAAU;AAAA,MACR,MAAM;AAAA,MACN,aAAa;AAAA,MACb,YAAY;AAAA,QACV,MAAM;AAAA,QACN,YAAY;AAAA,UACV,UAAU,EAAE,MAAM,UAAU,aAAa,gBAAgB,SAAS,OAAO;AAAA,UACzE,YAAY,EAAE,MAAM,WAAW,aAAa,sBAAsB,SAAS,IAAM;AAAA,QACnF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,UAAU;AAAA,MACR,MAAM;AAAA,MACN,aAAa;AAAA,MACb,YAAY;AAAA,QACV,MAAM;AAAA,QACN,YAAY;AAAA,UACV,UAAU,EAAE,MAAM,U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