@intentic/machine 1.244.0 → 1.246.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/README.md +27 -18
- package/dist/app.js +1 -1
- package/dist/app.js.map +1 -1
- package/dist/autostart.js +1 -1
- package/dist/autostart.js.map +1 -1
- package/dist/commands.d.ts +1 -1
- package/dist/commands.js +5 -5
- package/dist/commands.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/device/audit.d.ts.map +1 -0
- package/dist/device/audit.js.map +1 -0
- package/dist/{computer → device}/auto-prepare.d.ts +3 -3
- package/dist/device/auto-prepare.d.ts.map +1 -0
- package/dist/device/auto-prepare.js.map +1 -0
- package/dist/{computer → device}/commands.d.ts +2 -2
- package/dist/device/commands.d.ts.map +1 -0
- package/dist/{computer → device}/commands.js +19 -19
- package/dist/device/commands.js.map +1 -0
- package/dist/device/config.d.ts.map +1 -0
- package/dist/{computer → device}/config.js +1 -1
- package/dist/device/config.js.map +1 -0
- package/dist/{computer → device}/connection.d.ts +2 -5
- package/dist/device/connection.d.ts.map +1 -0
- package/dist/device/connection.js +37 -0
- package/dist/device/connection.js.map +1 -0
- package/dist/device/mcp.d.ts +11 -0
- package/dist/device/mcp.d.ts.map +1 -0
- package/dist/{computer → device}/mcp.js +36 -84
- package/dist/device/mcp.js.map +1 -0
- package/dist/device/policy.d.ts.map +1 -0
- package/dist/{computer → device}/policy.js +5 -5
- package/dist/device/policy.js.map +1 -0
- package/dist/{computer → device}/router.d.ts +35 -0
- package/dist/device/router.d.ts.map +1 -0
- package/dist/{computer → device}/router.js +7 -3
- package/dist/device/router.js.map +1 -0
- package/dist/device/testing.d.ts +10 -0
- package/dist/device/testing.d.ts.map +1 -0
- package/dist/device/testing.js +51 -0
- package/dist/device/testing.js.map +1 -0
- package/dist/device/tools/agent.d.ts +4 -0
- package/dist/device/tools/agent.d.ts.map +1 -0
- package/dist/device/tools/agent.js +46 -0
- package/dist/device/tools/agent.js.map +1 -0
- package/dist/device/tools/apps.d.ts.map +1 -0
- package/dist/{computer → device}/tools/apps.js +3 -3
- package/dist/device/tools/apps.js.map +1 -0
- package/dist/device/tools/browser.d.ts.map +1 -0
- package/dist/device/tools/browser.js.map +1 -0
- package/dist/device/tools/describe.d.ts.map +1 -0
- package/dist/{computer → device}/tools/describe.js +22 -8
- package/dist/device/tools/describe.js.map +1 -0
- package/dist/{computer/tools/computer.d.ts → device/tools/device.d.ts} +6 -6
- package/dist/device/tools/device.d.ts.map +1 -0
- package/dist/{computer/tools/computer.js → device/tools/device.js} +2 -2
- package/dist/device/tools/device.js.map +1 -0
- package/dist/device/tools/files.d.ts.map +1 -0
- package/dist/device/tools/files.js.map +1 -0
- package/dist/{computer → device}/tools/sandboxes.d.ts +7 -3
- package/dist/device/tools/sandboxes.d.ts.map +1 -0
- package/dist/{computer → device}/tools/sandboxes.js +98 -8
- package/dist/device/tools/sandboxes.js.map +1 -0
- package/dist/device/tools/shell.d.ts.map +1 -0
- package/dist/{computer → device}/tools/shell.js +6 -4
- package/dist/device/tools/shell.js.map +1 -0
- package/dist/resident.js +6 -6
- package/dist/resident.js.map +1 -1
- package/dist/status.d.ts +9 -9
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +28 -23
- package/dist/status.js.map +1 -1
- package/dist/sync/commands.js +4 -4
- package/dist/sync/commands.js.map +1 -1
- package/dist/sync/mirror.js +4 -4
- package/dist/sync/mirror.js.map +1 -1
- package/dist/sync/report.d.ts +4 -4
- package/dist/sync/report.d.ts.map +1 -1
- package/dist/sync/report.js +5 -6
- package/dist/sync/report.js.map +1 -1
- package/package.json +10 -10
- package/dist/computer/audit.d.ts.map +0 -1
- package/dist/computer/audit.js.map +0 -1
- package/dist/computer/auto-prepare.d.ts.map +0 -1
- package/dist/computer/auto-prepare.js.map +0 -1
- package/dist/computer/commands.d.ts.map +0 -1
- package/dist/computer/commands.js.map +0 -1
- package/dist/computer/config.d.ts.map +0 -1
- package/dist/computer/config.js.map +0 -1
- package/dist/computer/connection.d.ts.map +0 -1
- package/dist/computer/connection.js +0 -72
- package/dist/computer/connection.js.map +0 -1
- package/dist/computer/mcp.d.ts +0 -3
- package/dist/computer/mcp.d.ts.map +0 -1
- package/dist/computer/mcp.js.map +0 -1
- package/dist/computer/policy.d.ts.map +0 -1
- package/dist/computer/policy.js.map +0 -1
- package/dist/computer/router.d.ts.map +0 -1
- package/dist/computer/router.js.map +0 -1
- package/dist/computer/tools/apps.d.ts.map +0 -1
- package/dist/computer/tools/apps.js.map +0 -1
- package/dist/computer/tools/browser.d.ts.map +0 -1
- package/dist/computer/tools/browser.js.map +0 -1
- package/dist/computer/tools/computer.d.ts.map +0 -1
- package/dist/computer/tools/computer.js.map +0 -1
- package/dist/computer/tools/describe.d.ts.map +0 -1
- package/dist/computer/tools/describe.js.map +0 -1
- package/dist/computer/tools/files.d.ts.map +0 -1
- package/dist/computer/tools/files.js.map +0 -1
- package/dist/computer/tools/sandboxes.d.ts.map +0 -1
- package/dist/computer/tools/sandboxes.js.map +0 -1
- package/dist/computer/tools/shell.d.ts.map +0 -1
- package/dist/computer/tools/shell.js.map +0 -1
- /package/dist/{computer → device}/audit.d.ts +0 -0
- /package/dist/{computer → device}/audit.js +0 -0
- /package/dist/{computer → device}/auto-prepare.js +0 -0
- /package/dist/{computer → device}/config.d.ts +0 -0
- /package/dist/{computer → device}/policy.d.ts +0 -0
- /package/dist/{computer → device}/tools/apps.d.ts +0 -0
- /package/dist/{computer → device}/tools/browser.d.ts +0 -0
- /package/dist/{computer → device}/tools/browser.js +0 -0
- /package/dist/{computer → device}/tools/describe.d.ts +0 -0
- /package/dist/{computer → device}/tools/files.d.ts +0 -0
- /package/dist/{computer → device}/tools/files.js +0 -0
- /package/dist/{computer → device}/tools/shell.d.ts +0 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { errorMessage } from "@intentic/base/errors";
|
|
2
2
|
import { browser } from "@intentic/browser";
|
|
3
3
|
import { desktop, pngSize } from "@intentic/desktop";
|
|
4
|
-
import {
|
|
4
|
+
import { SandboxResourcesAskFieldsSchema } from "@intentic/sandbox-contract";
|
|
5
|
+
import { createMcpServer, textResult, tool } from "@intentic/sandbox-contract/peer-mcp-server";
|
|
5
6
|
import { z } from "zod";
|
|
6
7
|
import { audit } from "./audit.js";
|
|
7
8
|
import { assertScope, ScopeError } from "./policy.js";
|
|
@@ -9,23 +10,10 @@ import { describeText } from "./tools/describe.js";
|
|
|
9
10
|
import { listDirectory, readTextFile, trashFile, writeTextFile } from "./tools/files.js";
|
|
10
11
|
import { focusWindow, listWindows, openTarget, readClipboard, writeClipboard } from "./tools/apps.js";
|
|
11
12
|
import { clickElement, fillElement, listTabs, openPage, pressKey, readPage, selectTab, snapshotPage } from "./tools/browser.js";
|
|
12
|
-
import { act, describeAction, settle } from "./tools/
|
|
13
|
-
import { DEFAULT_LOG_LINES, listSandboxes, manageSandbox, MAX_LOG_LINES, removeSandbox, SandboxOpSchema, SandboxSwapSchema, sandboxLogs, swapSandbox, } from "./tools/sandboxes.js";
|
|
13
|
+
import { act, describeAction, settle } from "./tools/device.js";
|
|
14
|
+
import { DEFAULT_LOG_LINES, listSandboxes, manageSandbox, MAX_LOG_LINES, removeSandbox, reshapeSandbox, SandboxOpSchema, SandboxSwapSchema, sandboxLogs, swapSandbox, } from "./tools/sandboxes.js";
|
|
14
15
|
import { DEFAULT_TIMEOUT_MS, describeResult, MAX_TIMEOUT_MS, runCommand } from "./tools/shell.js";
|
|
15
16
|
import { MACHINE_VERSION } from "../version.js";
|
|
16
|
-
const textResult = (text, isError = false) => ({ content: [{ type: "text", text }], isError });
|
|
17
|
-
const tool = (spec) => {
|
|
18
|
-
const { $schema: _dialect, ...inputSchema } = z.toJSONSchema(spec.input, { io: "input" });
|
|
19
|
-
return {
|
|
20
|
-
name: spec.name,
|
|
21
|
-
description: spec.description,
|
|
22
|
-
inputSchema,
|
|
23
|
-
call: async (args, scopes) => {
|
|
24
|
-
const parsed = spec.input.safeParse(args);
|
|
25
|
-
return parsed.success ? await spec.run(parsed.data, scopes) : textResult(z.prettifyError(parsed.error), true);
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
17
|
const NO_ARGS = z.object({});
|
|
30
18
|
const screenshotResult = async (scopes) => {
|
|
31
19
|
assertScope(scopes, "screen");
|
|
@@ -34,7 +22,7 @@ const screenshotResult = async (scopes) => {
|
|
|
34
22
|
const { width, height } = pngSize(png);
|
|
35
23
|
return {
|
|
36
24
|
content: [
|
|
37
|
-
{ type: "text", text: `Screen is ${width}×${height}. Coordinates for the
|
|
25
|
+
{ type: "text", text: `Screen is ${width}×${height}. Coordinates for the device tool are pixels in this image.` },
|
|
38
26
|
{ type: "image", data: png.toString("base64"), mimeType: "image/png" },
|
|
39
27
|
],
|
|
40
28
|
isError: false,
|
|
@@ -47,13 +35,13 @@ const required = z.string().min(1);
|
|
|
47
35
|
const TOOLS = [
|
|
48
36
|
tool({
|
|
49
37
|
name: "describe",
|
|
50
|
-
description: "What this
|
|
38
|
+
description: "What this device is: OS and version, CPU architecture, the exact shell run_command uses, the home directory, the folders you may touch, and which permissions are on. Call this once before your first command here, it is the difference between writing for this machine and guessing.",
|
|
51
39
|
input: NO_ARGS,
|
|
52
40
|
run: async (_args, scopes) => textResult(await describeText(scopes)),
|
|
53
41
|
}),
|
|
54
42
|
tool({
|
|
55
43
|
name: "run_command",
|
|
56
|
-
description: "Run a command on this
|
|
44
|
+
description: "Run a command on this device and get back its exit code, stdout and stderr. The shell is PowerShell on Windows and the user's login shell elsewhere (see describe). There is no terminal for anyone to type into: a command that prompts will fail rather than wait. Commands that DELETE (a recursive delete, a formatted disk, a removed Docker volume) need this device's \"Run destructive commands\" switch, which is off unless its owner turned it on: they are refused with a message naming the switch, so ask the owner to turn it on rather than looking for a spelling that gets past it. Prefer one script that does the whole job over many small calls, every call is a network round trip to somebody's laptop.",
|
|
57
45
|
input: z.object({
|
|
58
46
|
command: required.describe("The command line to run, in this machine's shell."),
|
|
59
47
|
cwd: required.optional().describe("Working directory. Must be inside the allowed folders. Defaults to the first allowed folder."),
|
|
@@ -71,7 +59,7 @@ const TOOLS = [
|
|
|
71
59
|
}),
|
|
72
60
|
tool({
|
|
73
61
|
name: "read_file",
|
|
74
|
-
description: "Read a text file on this
|
|
62
|
+
description: "Read a text file on this device. Bounded by the folders this machine allows.",
|
|
75
63
|
input: z.object({ path: required }),
|
|
76
64
|
run: async ({ path }, scopes) => textResult(await readTextFile(path, scopes)),
|
|
77
65
|
}),
|
|
@@ -95,7 +83,7 @@ const TOOLS = [
|
|
|
95
83
|
}),
|
|
96
84
|
tool({
|
|
97
85
|
name: "list_windows",
|
|
98
|
-
description: "Every window open on this
|
|
86
|
+
description: "Every window open on this device: its app, title, size, position, and which one has focus. Call this before any GUI work, it is how you find the application you were asked about, and how you know where your typing will land. Requires the 'See the screen' permission.",
|
|
99
87
|
input: NO_ARGS,
|
|
100
88
|
run: async (_args, scopes) => textResult(await listWindows(desktop(), scopes)),
|
|
101
89
|
}),
|
|
@@ -107,13 +95,13 @@ const TOOLS = [
|
|
|
107
95
|
}),
|
|
108
96
|
tool({
|
|
109
97
|
name: "open",
|
|
110
|
-
description: "Start an application, or open a URL or file with whatever this
|
|
98
|
+
description: "Start an application, or open a URL or file with whatever this device has registered for it: the usual first step of a task ('open the browser at this page'). Use this rather than working out the platform's own incantation. Requires the 'Run commands' permission.",
|
|
111
99
|
input: z.object({ target: required.describe("An application name, a file path, or a URL.") }),
|
|
112
100
|
run: async ({ target }, scopes) => textResult(await openTarget(desktop(), target, scopes)),
|
|
113
101
|
}),
|
|
114
102
|
tool({
|
|
115
103
|
name: "clipboard",
|
|
116
|
-
description: "Read or replace this
|
|
104
|
+
description: "Read or replace this device's clipboard: the reliable way to move text between applications, and often easier than reading it off a screenshot. Reading needs 'See the screen'; writing needs 'Use the mouse and keyboard'.",
|
|
117
105
|
input: z
|
|
118
106
|
.object({
|
|
119
107
|
action: z.enum(["read", "write"]),
|
|
@@ -129,7 +117,7 @@ const TOOLS = [
|
|
|
129
117
|
}),
|
|
130
118
|
tool({
|
|
131
119
|
name: "browser_open",
|
|
132
|
-
description: "Open a page in a browser on this
|
|
120
|
+
description: "Open a page in a browser on this device and answer with what is on it: the page's title, its URL, and every element you can click or type into, each with a reference like [e12]. THIS IS THE RIGHT WAY TO USE A WEBSITE, act on elements by reference, never by clicking pixels, because references survive scrolling, resizing and re-rendering. The browser is a separate instance with its own profile, so the user's own tabs and session are untouched; the first time it opens they may need to sign in. Requires the 'Run commands' permission.",
|
|
133
121
|
input: z.object({ url: required.describe("The page to open. A bare host like example.com is fine.") }),
|
|
134
122
|
run: async ({ url }, scopes) => textResult(await openPage(web(), url, scopes)),
|
|
135
123
|
}),
|
|
@@ -174,8 +162,8 @@ const TOOLS = [
|
|
|
174
162
|
run: async ({ select }, scopes) => textResult(select === undefined ? await listTabs(web(), scopes) : await selectTab(web(), select, scopes)),
|
|
175
163
|
}),
|
|
176
164
|
tool({
|
|
177
|
-
name: "
|
|
178
|
-
description: "Use this
|
|
165
|
+
name: "device",
|
|
166
|
+
description: "Use this device's mouse and keyboard: click what is on the screen, type into the focused window, press a key combination, scroll, drag. Coordinates are PIXELS IN THE LAST SCREENSHOT, take one first and read them off it. Every action answers with a fresh screenshot so you can see what happened. Requires the 'Use the mouse and keyboard' permission, which is OFF unless the user turned it on. Prefer a command over the GUI when both would work: a command is exact, and a click is a guess about where something is.",
|
|
179
167
|
input: z.object({
|
|
180
168
|
action: z.enum([
|
|
181
169
|
"mouse_move",
|
|
@@ -199,7 +187,7 @@ const TOOLS = [
|
|
|
199
187
|
run: async (input, scopes) => {
|
|
200
188
|
await act(desktop(), input, scopes);
|
|
201
189
|
if (scopes.screen !== "on") {
|
|
202
|
-
return textResult(`${describeAction(input)} (No screenshot: "See the screen" is off for this
|
|
190
|
+
return textResult(`${describeAction(input)} (No screenshot: "See the screen" is off for this device.)`);
|
|
203
191
|
}
|
|
204
192
|
await settle();
|
|
205
193
|
const shot = await screenshotResult(scopes);
|
|
@@ -208,25 +196,25 @@ const TOOLS = [
|
|
|
208
196
|
}),
|
|
209
197
|
tool({
|
|
210
198
|
name: "screenshot",
|
|
211
|
-
description: "Capture what is on this
|
|
199
|
+
description: "Capture what is on this device's screen right now, as an image. Use it to read a dialog, check on a window, or see what the user is describing. Requires the 'See the screen' permission.",
|
|
212
200
|
input: NO_ARGS,
|
|
213
201
|
run: async (_args, scopes) => await screenshotResult(scopes),
|
|
214
202
|
}),
|
|
215
203
|
tool({
|
|
216
204
|
name: "list_sandboxes",
|
|
217
|
-
description: "The Intentic sandboxes on this
|
|
205
|
+
description: "The Intentic sandboxes on this device, as JSON: each one's slug, whether it is running, whether its tunnel is up, and its share of this machine under `resources` (memory cap in bytes, CPU cap, privileged, GPU, and which of those the approved environment demands versus the owner asked for). Only sandbox containers; nothing else on the machine is listed. Requires 'Run commands' or 'Manage sandboxes on this device'.",
|
|
218
206
|
input: NO_ARGS,
|
|
219
207
|
run: async (_args, scopes) => textResult(await listSandboxes(scopes)),
|
|
220
208
|
}),
|
|
221
209
|
tool({
|
|
222
210
|
name: "manage_sandbox",
|
|
223
|
-
description: "Start, stop or restart one Intentic sandbox on this
|
|
211
|
+
description: "Start, stop or restart one Intentic sandbox on this device, by its slug from list_sandboxes. Stopping one interrupts whoever is working in it, and stopping the sandbox you are calling from severs your own connection. Requires the 'Manage sandboxes on this device' permission, which is OFF unless the user turned it on.",
|
|
224
212
|
input: z.object({ op: SandboxOpSchema, slug: required.describe("The sandbox's slug, from list_sandboxes.") }),
|
|
225
213
|
run: async ({ op, slug }, scopes) => textResult(await manageSandbox(op, slug, scopes)),
|
|
226
214
|
}),
|
|
227
215
|
tool({
|
|
228
216
|
name: "swap_sandbox",
|
|
229
|
-
description: "Move one Intentic sandbox on this
|
|
217
|
+
description: "Move one Intentic sandbox on this device onto a different image: 'update' pulls the newest image of its release channel, 'rollback' returns it to the image it ran before its last update, and 'rebuild' rebuilds the owner-approved environment overlay. Files (/work) and history are kept in all three. Takes MINUTES, it pulls an image and recreates the container, and the sandbox is down while it happens. 'prepare' is the exception and the one to reach for first: it does the downloading and building of the next update WITHOUT touching the container, so the sandbox keeps running throughout and the 'update' that follows is a restart of seconds instead of a wait of minutes. Requires the 'Manage sandboxes on this device' permission.",
|
|
230
218
|
input: z.object({
|
|
231
219
|
op: SandboxSwapSchema,
|
|
232
220
|
slug: required.describe("The sandbox's slug, from list_sandboxes."),
|
|
@@ -234,15 +222,21 @@ const TOOLS = [
|
|
|
234
222
|
}),
|
|
235
223
|
run: async ({ op, slug, hash }, scopes) => textResult(await swapSandbox(op, slug, hash, scopes, () => { })),
|
|
236
224
|
}),
|
|
225
|
+
tool({
|
|
226
|
+
name: "reshape_sandbox",
|
|
227
|
+
description: "Change how much of this device one Intentic sandbox may use, or its privileges: a memory cap in whole GiB, a CPU cap in whole cores, whether the container runs privileged, and whether this device's NVIDIA GPUs are passed through. Give only what should change; `null` for a cap means back to the default (the memory share derived from this machine; every core). The sandbox RESTARTS onto the same image — about a minute, whoever is working in it is interrupted, and reshaping the sandbox you are calling from severs your own connection until it is back — and the new values live on the container, surviving every later update. A privilege the sandbox's approved environment demands (the Docker capability's --privileged) cannot be withdrawn here, only the owner's own ask. Requires the 'Manage sandboxes on this device' permission.",
|
|
228
|
+
input: SandboxResourcesAskFieldsSchema.extend({ slug: required.describe("The sandbox's slug, from list_sandboxes.") }),
|
|
229
|
+
run: async ({ slug, ...ask }, scopes) => textResult(await reshapeSandbox(slug, ask, scopes, () => { })),
|
|
230
|
+
}),
|
|
237
231
|
tool({
|
|
238
232
|
name: "remove_sandbox",
|
|
239
|
-
description: "Delete one Intentic sandbox from this
|
|
233
|
+
description: "Delete one Intentic sandbox from this device: its container, its network, and the volumes holding its files and its history. THIS CANNOT BE UNDONE and is not what stopping it does, confirm with the user before calling it. Requires the 'Remove sandboxes from this device' permission, which is separate from managing them and OFF unless the user turned it on.",
|
|
240
234
|
input: z.object({ slug: required.describe("The sandbox's slug, from list_sandboxes.") }),
|
|
241
235
|
run: async ({ slug }, scopes) => textResult(await removeSandbox(slug, scopes, () => { })),
|
|
242
236
|
}),
|
|
243
237
|
tool({
|
|
244
238
|
name: "sandbox_logs",
|
|
245
|
-
description: "The tail of one Intentic sandbox's container log on this
|
|
239
|
+
description: "The tail of one Intentic sandbox's container log on this device: how you find out why it will not start or what it did before it stopped. Requires 'Run commands' or 'Manage sandboxes on this device'.",
|
|
246
240
|
input: z.object({
|
|
247
241
|
slug: required.describe("The sandbox's slug, from list_sandboxes."),
|
|
248
242
|
lines: z
|
|
@@ -255,59 +249,17 @@ const TOOLS = [
|
|
|
255
249
|
run: async ({ slug, lines }, scopes) => textResult(await sandboxLogs(slug, lines, scopes)),
|
|
256
250
|
}),
|
|
257
251
|
];
|
|
258
|
-
const BY_NAME = new Map(TOOLS.map((entry) => [entry.name, entry]));
|
|
259
252
|
const auditDetail = (name, args) => {
|
|
260
|
-
const redact = (name === "
|
|
253
|
+
const redact = (name === "device" && args["action"] === "type") || (name === "clipboard" && args["action"] === "write") || name === "browser_fill";
|
|
261
254
|
const safe = redact ? { ...args, text: `<${String(args["text"] ?? "").length} characters>` } : args;
|
|
262
255
|
return JSON.stringify(safe).slice(0, 500);
|
|
263
256
|
};
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
return undefined;
|
|
273
|
-
}
|
|
274
|
-
const reply = (result) => ({ jsonrpc: "2.0", id, result });
|
|
275
|
-
if (method === "initialize") {
|
|
276
|
-
return reply({
|
|
277
|
-
protocolVersion: MCP_PROTOCOL_VERSION,
|
|
278
|
-
capabilities: { tools: {} },
|
|
279
|
-
serverInfo: { name: "intentic-machine", version: MACHINE_VERSION },
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
if (method === "ping") {
|
|
283
|
-
return reply({});
|
|
284
|
-
}
|
|
285
|
-
if (method === "tools/list") {
|
|
286
|
-
return reply({ tools: TOOLS.map(({ name, description, inputSchema }) => ({ name, description, inputSchema })) });
|
|
287
|
-
}
|
|
288
|
-
if (method === "tools/call") {
|
|
289
|
-
const params = isRecord(message["params"]) ? message["params"] : {};
|
|
290
|
-
const name = typeof params["name"] === "string" ? params["name"] : "";
|
|
291
|
-
const args = isRecord(params["arguments"]) ? params["arguments"] : {};
|
|
292
|
-
const found = BY_NAME.get(name);
|
|
293
|
-
if (found === undefined) {
|
|
294
|
-
return reply(textResult(`This computer has no tool called "${name}".`, true));
|
|
295
|
-
}
|
|
296
|
-
try {
|
|
297
|
-
const result = await found.call(args, scopes());
|
|
298
|
-
void audit({ tool: name, ok: result["isError"] !== true, detail: auditDetail(name, args) });
|
|
299
|
-
return reply(result);
|
|
300
|
-
}
|
|
301
|
-
catch (error) {
|
|
302
|
-
const refused = error instanceof ScopeError;
|
|
303
|
-
void audit({
|
|
304
|
-
tool: name,
|
|
305
|
-
ok: false,
|
|
306
|
-
detail: `${refused ? "refused" : "failed"}: ${errorMessage(error)}`,
|
|
307
|
-
});
|
|
308
|
-
return reply(textResult(errorMessage(error), true));
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
return { jsonrpc: "2.0", id, error: { code: -32601, message: `method "${String(method)}" is not supported` } };
|
|
312
|
-
};
|
|
257
|
+
export const handleMcpMessage = createMcpServer({
|
|
258
|
+
serverInfo: () => ({ name: "intentic-machine", version: MACHINE_VERSION }),
|
|
259
|
+
tools: TOOLS,
|
|
260
|
+
noSuchTool: (name) => `This device has no tool called "${name}".`,
|
|
261
|
+
refused: (error) => error instanceof ScopeError,
|
|
262
|
+
errorMessage,
|
|
263
|
+
audit: ({ tool: name, args, ok, failure }) => audit({ tool: name, ok, detail: failure === undefined ? auditDetail(name, args) : `${failure.refused ? "refused" : "failed"}: ${failure.message}` }),
|
|
264
|
+
});
|
|
313
265
|
//# sour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aAAa,KAChG,IAcF,CAAC"}
|
|
@@ -19,8 +19,8 @@ export const withinRoots = (path, roots) => {
|
|
|
19
19
|
export const assertPath = (path, scopes, intent) => {
|
|
20
20
|
const roots = rootsOf(scopes);
|
|
21
21
|
if (!withinRoots(path, roots)) {
|
|
22
|
-
throw new ScopeError(`Refused to ${intent} "${path}": it is outside the folders this
|
|
23
|
-
`Widen "Folders it may touch" on this
|
|
22
|
+
throw new ScopeError(`Refused to ${intent} "${path}": it is outside the folders this device allows (${roots.join(", ")}). ` +
|
|
23
|
+
`Widen "Folders it may touch" on this device's capability card to change that.`);
|
|
24
24
|
}
|
|
25
25
|
return resolve(path);
|
|
26
26
|
};
|
|
@@ -33,10 +33,10 @@ export const assertScope = (scopes, scope) => {
|
|
|
33
33
|
write: "Create and change files",
|
|
34
34
|
screen: "See the screen",
|
|
35
35
|
control: "Use the mouse and keyboard",
|
|
36
|
-
sandboxes: "Manage sandboxes on this
|
|
37
|
-
sandboxRemove: "Remove sandboxes from this
|
|
36
|
+
sandboxes: "Manage sandboxes on this device",
|
|
37
|
+
sandboxRemove: "Remove sandboxes from this device",
|
|
38
38
|
destructive: "Run destructive commands",
|
|
39
39
|
}[scope];
|
|
40
|
-
throw new ScopeError(`Refused: "${label}" is switched off for this
|
|
40
|
+
throw new ScopeError(`Refused: "${label}" is switched off for this device. Turn it on in its capability card to allow this.`);
|
|
41
41
|
};
|
|
42
42
|
//# sourceMappingURL=policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../../src/device/policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAc3D,MAAM,OAAO,UAAW,SAAQ,KAAK;CAAG;AAIxC,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,MAAkB,EAAY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,MAAkB,EAAE,MAAc,EAAU,EAAE;IACnF,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC9B,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,UAAU,CAChB,cAAc,MAAM,KAAK,IAAI,oDAAoD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK;YAClG,+EAA+E,CACtF,CAAC;IACN,CAAC;IACD,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC,CAAC;AAIF,MAAM,CAAC,MAAM,WAAW,GAAG,CACvB,MAAkB,EAClB,KAA+F,EAC3F,EAAE;IACN,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;QACzB,OAAO;IACX,CAAC;IACD,MAAM,KAAK,GAAG;QACV,KAAK,EAAE,cAAc;QACrB,KAAK,EAAE,yBAAyB;QAChC,MAAM,EAAE,gBAAgB;QACxB,OAAO,EAAE,4BAA4B;QACrC,SAAS,EAAE,iCAAiC;QAC5C,aAAa,EAAE,mCAAmC;QAClD,WAAW,EAAE,0BAA0B;KAC1C,CAAC,KAAK,CAAC,CAAC;IACT,MAAM,IAAI,UAAU,CAAC,aAAa,KAAK,qFAAqF,CAAC,CAAC;AAClI,CAAC,CAAC"}
|
|
@@ -11,6 +11,10 @@ export declare const createHostRouter: (runtime: HostRuntime) => {
|
|
|
11
11
|
shell: import("zod").ZodString;
|
|
12
12
|
home: import("zod").ZodString;
|
|
13
13
|
roots: import("zod").ZodArray<import("zod").ZodString>;
|
|
14
|
+
engine: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
15
|
+
memoryBytes: import("zod").ZodNumber;
|
|
16
|
+
cpus: import("zod").ZodNumber;
|
|
17
|
+
}, import("zod/v4/core").$strip>>;
|
|
14
18
|
}, import("zod/v4/core").$strip>, import("@orpc/server").MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
15
19
|
setScopes: import("@orpc/server").Procedure<import("@orpc/server").MergedInitialContext<Record<never, never>, Record<never, never>, Record<never, never>>, Record<never, never>, import("zod").ZodObject<{
|
|
16
20
|
shell: import("zod").ZodDefault<import("zod").ZodEnum<{
|
|
@@ -55,6 +59,7 @@ export declare const createHostRouter: (runtime: HostRuntime) => {
|
|
|
55
59
|
prepare: "prepare";
|
|
56
60
|
rebuild: "rebuild";
|
|
57
61
|
remove: "remove";
|
|
62
|
+
reshape: "reshape";
|
|
58
63
|
restart: "restart";
|
|
59
64
|
rollback: "rollback";
|
|
60
65
|
"runner-remove": "runner-remove";
|
|
@@ -65,6 +70,12 @@ export declare const createHostRouter: (runtime: HostRuntime) => {
|
|
|
65
70
|
}>;
|
|
66
71
|
slug: import("zod").ZodString;
|
|
67
72
|
hash: import("zod").ZodOptional<import("zod").ZodString>;
|
|
73
|
+
resources: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
74
|
+
memoryGib: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodInt>>;
|
|
75
|
+
cpus: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodInt>>;
|
|
76
|
+
privileged: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
77
|
+
gpu: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
78
|
+
}, import("zod/v4/core").$strip>>;
|
|
68
79
|
parentUrl: import("zod").ZodOptional<import("zod").ZodString>;
|
|
69
80
|
pair: import("zod").ZodOptional<import("zod").ZodString>;
|
|
70
81
|
definition: import("zod").ZodOptional<import("zod").ZodString>;
|
|
@@ -89,5 +100,29 @@ export declare const createHostRouter: (runtime: HostRuntime) => {
|
|
|
89
100
|
kind: "error";
|
|
90
101
|
message: string;
|
|
91
102
|
}, unknown, void>>, import("@orpc/server").MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
103
|
+
runAgentFlow: import("@orpc/server").Procedure<import("@orpc/server").MergedInitialContext<Record<never, never>, Record<never, never>, Record<never, never>>, Record<never, never>, import("zod").ZodObject<{
|
|
104
|
+
op: import("zod").ZodEnum<{
|
|
105
|
+
restart: "restart";
|
|
106
|
+
upgrade: "upgrade";
|
|
107
|
+
}>;
|
|
108
|
+
}, import("zod/v4/core").$strip>, import("@orpc/server").Schema<AsyncIteratorObject<{
|
|
109
|
+
kind: "line";
|
|
110
|
+
text: string;
|
|
111
|
+
} | {
|
|
112
|
+
kind: "result";
|
|
113
|
+
message: string;
|
|
114
|
+
} | {
|
|
115
|
+
kind: "error";
|
|
116
|
+
message: string;
|
|
117
|
+
}, unknown, void>, import("@orpc/server").AsyncIteratorClass<{
|
|
118
|
+
kind: "line";
|
|
119
|
+
text: string;
|
|
120
|
+
} | {
|
|
121
|
+
kind: "result";
|
|
122
|
+
message: string;
|
|
123
|
+
} | {
|
|
124
|
+
kind: "error";
|
|
125
|
+
message: string;
|
|
126
|
+
}, unknown, void>>, import("@orpc/server").MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
92
127
|
};
|
|
93
128
|
//# sourceMappingURL=router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/device/router.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAA6D,MAAM,4BAA4B,CAAC;AAgBxH,MAAM,WAAW,WAAW;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,UAAU,CAAC;IAClC,QAAQ,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IACjD,QAAQ,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3C;AAiGD,eAAO,MAAM,gBAAgB,YAAa,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwBpD,CAAC"}
|
|
@@ -3,7 +3,8 @@ import { hostContract } from "@intentic/sandbox-contract";
|
|
|
3
3
|
import { implement } from "@orpc/server";
|
|
4
4
|
import { handleMcpMessage } from "./mcp.js";
|
|
5
5
|
import { hostFacts } from "./tools/describe.js";
|
|
6
|
-
import {
|
|
6
|
+
import { runAgentOp } from "./tools/agent.js";
|
|
7
|
+
import { manageSandbox, removeSandbox, reshapeSandbox, runnerFlow, swapSandbox, tailSandboxLogs } from "./tools/sandboxes.js";
|
|
7
8
|
async function* streamFlow(run) {
|
|
8
9
|
const queued = [];
|
|
9
10
|
let wake;
|
|
@@ -41,10 +42,12 @@ async function* streamFlow(run) {
|
|
|
41
42
|
? { kind: "result", message: settled.message }
|
|
42
43
|
: { kind: "error", message: settled?.message ?? "The operation stopped without saying why." };
|
|
43
44
|
}
|
|
44
|
-
const flowFor = ({ op, slug, hash, parentUrl, pair, definition, overlay, overlayHash }, scopes) => {
|
|
45
|
+
const flowFor = ({ op, slug, hash, resources, parentUrl, pair, definition, overlay, overlayHash }, scopes) => {
|
|
45
46
|
switch (op) {
|
|
46
47
|
case "remove":
|
|
47
48
|
return (onLine) => removeSandbox(slug, scopes, onLine);
|
|
49
|
+
case "reshape":
|
|
50
|
+
return (onLine) => reshapeSandbox(slug, resources, scopes, onLine);
|
|
48
51
|
case "runner-up":
|
|
49
52
|
case "runner-remove":
|
|
50
53
|
return (onLine) => runnerFlow(op, slug, parentUrl, pair, {
|
|
@@ -73,8 +76,9 @@ export const createHostRouter = (runtime) => {
|
|
|
73
76
|
return { ok: true };
|
|
74
77
|
}),
|
|
75
78
|
ping: os.ping.handler(() => ({ ok: true })),
|
|
76
|
-
mcp: os.mcp.handler(async ({ input }) => await handleMcpMessage(input, runtime.scopes)),
|
|
79
|
+
mcp: os.mcp.handler(async ({ input }) => await handleMcpMessage(input, runtime.scopes())),
|
|
77
80
|
runSandboxFlow: os.runSandboxFlow.handler(({ input }) => streamFlow(flowFor(input, runtime.scopes()))),
|
|
81
|
+
runAgentFlow: os.runAgentFlow.handler(({ input }) => streamFlow((onLine) => runAgentOp(input.op, runtime.scopes(), onLine))),
|
|
78
82
|
});
|
|
79
83
|
};
|
|
80
84
|
//# sourceMappingURL=router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../src/device/router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAgE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AACxH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AA0B9H,KAAK,SAAS,CAAC,CAAC,UAAU,CAAC,GAAwD;IAC/E,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,IAA8B,CAAC;IACnC,MAAM,KAAK,GAAG,GAAS,EAAE;QACrB,MAAM,OAAO,GAAG,IAAI,CAAC;QACrB,IAAI,GAAG,SAAS,CAAC;QACjB,OAAO,EAAE,EAAE,CAAC;IAChB,CAAC,CAAC;IACF,IAAI,OAAuE,CAAC;IAG5E,MAAM,QAAQ,GAAG,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAC1B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClB,KAAK,EAAE,CAAC;IACZ,CAAC,CAAC;SACG,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;SAC1C,KAA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} from "@intentic/desktop";
|
|
2
|
+
export interface FakeDesktop {
|
|
3
|
+
readonly desktop: Desktop;
|
|
4
|
+
readonly calls: string[];
|
|
5
|
+
windows: WindowInfo[];
|
|
6
|
+
clipboard: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const fakeWindow: (overrides?: Partial<WindowInfo>) => WindowInfo;
|
|
9
|
+
export declare const fakeDesktop: () => FakeDesktop;
|
|
10
|
+
//# sourceMappingURL=testing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../src/device/testing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAuC,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAUlG,MAAM,WAAW,WAAW;IACxB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;IAEzB,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,UAAU,eAAe,OAAO,CAAC,UAAU,CAAC,KAAQ,UAO/D,CAAC;AAEH,eAAO,MAAM,WAAW,QAAO,WA2C9B,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export const fakeWindow = (overrides = {}) => ({
|
|
2
|
+
id: "1",
|
|
3
|
+
title: "Untitled",
|
|
4
|
+
app: "app",
|
|
5
|
+
bounds: { x: 0, y: 0, width: 800, height: 600 },
|
|
6
|
+
focused: false,
|
|
7
|
+
...overrides,
|
|
8
|
+
});
|
|
9
|
+
export const fakeDesktop = () => {
|
|
10
|
+
const calls = [];
|
|
11
|
+
const state = { windows: [], clipboard: "" };
|
|
12
|
+
const desktop = {
|
|
13
|
+
frame: async () => ({ width: 1920, height: 1080, origin: { x: 0, y: 0 } }),
|
|
14
|
+
capture: async () => Buffer.alloc(0),
|
|
15
|
+
move: async (to) => void calls.push(`move ${to.x},${to.y}`),
|
|
16
|
+
click: async (at, button) => void calls.push(`click ${button} ${at.x},${at.y}`),
|
|
17
|
+
doubleClick: async (at) => void calls.push(`double ${at.x},${at.y}`),
|
|
18
|
+
drag: async (from, to) => void calls.push(`drag ${from.x},${from.y}->${to.x},${to.y}`),
|
|
19
|
+
type: async (text) => void calls.push(`type ${text}`),
|
|
20
|
+
key: async (combo) => void calls.push(`key ${combo}`),
|
|
21
|
+
scroll: async (at, direction, amount) => void calls.push(`scroll ${direction} ${amount} @${at.x},${at.y}`),
|
|
22
|
+
windows: async () => state.windows,
|
|
23
|
+
focusWindow: async (id) => {
|
|
24
|
+
calls.push(`focus ${id}`);
|
|
25
|
+
state.windows = state.windows.map((window) => ({ ...window, focused: window.id === id }));
|
|
26
|
+
},
|
|
27
|
+
launch: async (target) => void calls.push(`launch ${target}`),
|
|
28
|
+
readClipboard: async () => state.clipboard,
|
|
29
|
+
writeClipboard: async (text) => {
|
|
30
|
+
calls.push(`clipboard ${text}`);
|
|
31
|
+
state.clipboard = text;
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
return {
|
|
35
|
+
desktop,
|
|
36
|
+
calls,
|
|
37
|
+
get windows() {
|
|
38
|
+
return state.windows;
|
|
39
|
+
},
|
|
40
|
+
set windows(next) {
|
|
41
|
+
state.windows = next;
|
|
42
|
+
},
|
|
43
|
+
get clipboard() {
|
|
44
|
+
return state.clipboard;
|
|
45
|
+
},
|
|
46
|
+
set clipboard(next) {
|
|
47
|
+
state.clipboard = next;
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=testing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.js","sourceRoot":"","sources":["../../src/device/testing.ts"],"names":[],"mappings":"AAmBA,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,SAAS,GAAwB,EAAE,EAAc,EAAE,CAAC,CAAC;IAC5E,EAAE,EAAE,GAAG;IACP,K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C;KACJ,CAAC;IACF,OAAO;QACH,OAAO;QACP,KAAK;QACL,IAAI,OAAO;YACP,OAAO,KAAK,CAAC,OAAO,CAAC;QACzB,CAAC;QACD,IAAI,OAAO,CAAC,IAAkB;YAC1B,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;QACzB,CAAC;QACD,IAAI,SAAS;YACT,OAAO,KAAK,CAAC,SAAS,CAAC;QAC3B,CAAC;QACD,IAAI,SAAS,CAAC,IAAY;YACtB,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC;QAC3B,CAAC;KACJ,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DeviceAgentOp, HostScopes } from "@intentic/sandbox-contract";
|
|
2
|
+
export declare const AGENT_VERB: Record<DeviceAgentOp, string>;
|
|
3
|
+
export declare const runAgentOp: (op: DeviceAgentOp, scopes: HostScopes, onLine: (line: string) => void) => Promise<string>;
|
|
4
|
+
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../../src/device/tools/agent.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAqC5E,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,aAAa,EAAE,MAAM,CAA0C,CAAC;AA4BhG,eAAO,MAAM,UAAU,OAAc,aAAa,UAAU,UAAU,UAAU,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,KAAG,OAAO,CAAC,MAAM,CAoCtH,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { setTimeout as sleep } from "node:timers/promises";
|
|
3
|
+
import { isProcessAlive, spawnDetached } from "@intentic/local-agent";
|
|
4
|
+
import { agentLogPath } from "../../config.js";
|
|
5
|
+
import { installedBuild } from "../../installed.js";
|
|
6
|
+
import { machineLauncher } from "../../resident.js";
|
|
7
|
+
import { assertScope } from "../policy.js";
|
|
8
|
+
export const AGENT_VERB = { upgrade: "upgrade", restart: "run" };
|
|
9
|
+
const DRAIN_MS = 1_500;
|
|
10
|
+
const POLL_MS = 250;
|
|
11
|
+
const WATCH_TIMEOUT_MS = 20 * 60 * 1000;
|
|
12
|
+
const readFrom = async (path, from) => {
|
|
13
|
+
const raw = await readFile(path, "utf8").catch(() => "");
|
|
14
|
+
return { text: raw.slice(from), at: raw.length };
|
|
15
|
+
};
|
|
16
|
+
export const runAgentOp = async (op, scopes, onLine) => {
|
|
17
|
+
assertScope(scopes, "shell");
|
|
18
|
+
const installed = installedBuild();
|
|
19
|
+
onLine(op === "upgrade"
|
|
20
|
+
? `Updating the agent on this device${installed === undefined ? "" : ` (currently ${installed})`}. Its background loop restarts, so this connection drops while that happens.`
|
|
21
|
+
: `Restarting this device's agent loop. This connection drops while that happens.`);
|
|
22
|
+
const start = (await readFrom(agentLogPath, 0)).at;
|
|
23
|
+
const pid = await spawnDetached(agentLogPath, machineLauncher(), [AGENT_VERB[op]]);
|
|
24
|
+
onLine(`Started ${AGENT_VERB[op]} (pid ${pid}), detached from this connection so it finishes either way. Log: ${agentLogPath}`);
|
|
25
|
+
let at = start;
|
|
26
|
+
const deadline = Date.now() + WATCH_TIMEOUT_MS;
|
|
27
|
+
let goneAt;
|
|
28
|
+
while (Date.now() < deadline) {
|
|
29
|
+
const { text, at: next } = await readFrom(agentLogPath, at);
|
|
30
|
+
at = next;
|
|
31
|
+
for (const line of text.split(/\r?\n/).filter((one) => one.trim() !== "")) {
|
|
32
|
+
onLine(line);
|
|
33
|
+
}
|
|
34
|
+
if (!isProcessAlive(pid)) {
|
|
35
|
+
goneAt ??= Date.now();
|
|
36
|
+
if (Date.now() - goneAt > DRAIN_MS) {
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
await sleep(POLL_MS);
|
|
41
|
+
}
|
|
42
|
+
return op === "upgrade"
|
|
43
|
+
? `The update ran on this device. Whether the new agent is the one serving shows in its version, which this view re-reads on its own.`
|
|
44
|
+
: `The agent loop was restarted on this device.`;
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../../src/device/tools/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAiC3C,MAAM,CAAC,MAAM,UAAU,GAAkC,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAKhG,MAAM,QAAQ,GAAG,KAAK,CAAC;AACvB,MAAM,OAAO,GAAG,GAAG,CAAC;AAKpB,MAAM,gBAAgB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAIxC,MAAM,QAAQ,GAAG,KAAK,EAAE,IAAY,EAAE,IAAY,EAAyC,EAAE;IACzF,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;IACzD,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC;AACrD,CAAC,CAAC;AAUF,MAAM,CAAC,MAAM,UAAU,GA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,GAAG,CAAC,EAAE,CAAC;YACvB,MAAM,KAAK,IAAI,CAAC,GAAG,EAAE,CAAC;YACtB,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,GAAG,QAAQ,EAAE,CAAC;gBACjC,MAAM;YACV,CAAC;QACL,CAAC;QAED,MAAM,KAAK,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,EAAE,KAAK,SAAS;QACnB,CAAC,CAAC,oIAAoI;QACtI,CAAC,CAAC,8CAA8C,CAAC;AACzD,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apps.d.ts","sourceRoot":"","sources":["../../../src/device/tools/apps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAmB7D,eAAO,MAAM,eAAe,YAAa,SAAS,UAAU,EAAE,KAAG,MAShE,CAAC;AAEF,eAAO,MAAM,WAAW,WAAkB,OAAO,UAAU,UAAU,KAAG,OAAO,CAAC,MAAM,CAGrF,CAAC;AAKF,eAAO,MAAM,WAAW,WAAkB,OAAO,MAAM,MAAM,UAAU,UAAU,KAAG,OAAO,CAAC,MAAM,CAQjG,CAAC;AAEF,eAAO,MAAM,UAAU,WAAkB,OAAO,UAAU,MAAM,UAAU,UAAU,KAAG,OAAO,CAAC,MAAM,CAQpG,CAAC;AAIF,eAAO,MAAM,aAAa,WAAkB,OAAO,UAAU,UAAU,KAAG,OAAO,CAAC,MAAM,CAIvF,CAAC;AAEF,eAAO,MAAM,cAAc,WAAkB,OAAO,QAAQ,MAAM,UAAU,UAAU,KAAG,OAAO,CAAC,MAAM,CAItG,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { DesktopError } from "@intentic/desktop";
|
|
|
2
2
|
import { assertScope } from "../policy.js";
|
|
3
3
|
export const describeWindows = (windows) => {
|
|
4
4
|
if (windows.length === 0) {
|
|
5
|
-
return "No windows are open on this
|
|
5
|
+
return "No windows are open on this device.";
|
|
6
6
|
}
|
|
7
7
|
const rows = windows.map((window) => `${window.focused ? "* " : " "}[${window.id}] ${window.app}, ${window.title} (${window.bounds.width}×${window.bounds.height} at ${window.bounds.x},${window.bounds.y})`);
|
|
8
8
|
return [`${windows.length} window${windows.length === 1 ? "" : "s"} (* = focused). Pass the id in brackets to focus_window.`, ...rows].join("\n");
|
|
@@ -18,7 +18,7 @@ export const focusWindow = async (screen, id, scopes) => {
|
|
|
18
18
|
}
|
|
19
19
|
await screen.focusWindow(id);
|
|
20
20
|
const focused = (await screen.windows().catch(() => [])).find((window) => window.focused);
|
|
21
|
-
return focused === undefined ? `Asked this
|
|
21
|
+
return focused === undefined ? `Asked this device to focus window ${id}.` : `Focused: ${focused.app}, ${focused.title}. Typing now goes here.`;
|
|
22
22
|
};
|
|
23
23
|
export const openTarget = async (screen, target, scopes) => {
|
|
24
24
|
assertScope(scopes, "shell");
|
|
@@ -36,6 +36,6 @@ export const readClipboard = async (screen, scopes) => {
|
|
|
36
36
|
export const writeClipboard = async (screen, text, scopes) => {
|
|
37
37
|
assertScope(scopes, "control");
|
|
38
38
|
await screen.writeClipboard(text);
|
|
39
|
-
return `Put ${text.length} characters on this
|
|
39
|
+
return `Put ${text.length} characters on this device's clipboard.`;
|
|
40
40
|
};
|
|
41
41
|
//# sourceMappingURL=apps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apps.js","sourceRoot":"","sources":["../../../src/device/tools/apps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,YAAY,EAAmB,MAAM,mBAAmB,CAAC;AAEhF,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAkB3C,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAA8B,EAAU,EAAE;IACtE,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACv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