frely-cli 0.13.0 → 0.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/app-install.d.ts +6 -3
- package/dist/agent/app-install.js +18 -6
- package/dist/agent/app-install.js.map +1 -1
- package/dist/agent/pi-node-supervisor.d.ts +59 -0
- package/dist/agent/pi-node-supervisor.js +250 -0
- package/dist/agent/pi-node-supervisor.js.map +1 -0
- package/dist/agent-help.d.ts +2 -86
- package/dist/agent-help.js +1 -8
- package/dist/agent-help.js.map +1 -1
- package/dist/app-manager.js +2 -2
- package/dist/app-manager.js.map +1 -1
- package/dist/device/protocol.d.ts +1 -1
- package/dist/device/protocol.js +1 -1
- package/dist/device/protocol.js.map +1 -1
- package/dist/device/relay-client.d.ts +1 -8
- package/dist/device/relay-client.js +8 -20
- package/dist/device/relay-client.js.map +1 -1
- package/dist/diagnostics.js +3 -5
- package/dist/diagnostics.js.map +1 -1
- package/dist/index.js +22 -84
- package/dist/index.js.map +1 -1
- package/dist/runtime/mcp.d.ts +0 -137
- package/dist/runtime/mcp.js +1 -23
- package/dist/runtime/mcp.js.map +1 -1
- package/dist/runtime/sandbox.js +9 -1
- package/dist/runtime/sandbox.js.map +1 -1
- package/dist/runtime/workspace-registry.d.ts +2 -0
- package/dist/runtime/workspace-registry.js +10 -0
- package/dist/runtime/workspace-registry.js.map +1 -1
- package/package.json +1 -1
- package/dist/agent/agent-service.d.ts +0 -77
- package/dist/agent/agent-service.js +0 -348
- package/dist/agent/agent-service.js.map +0 -1
- package/dist/agent/app-key.d.ts +0 -14
- package/dist/agent/app-key.js +0 -46
- package/dist/agent/app-key.js.map +0 -1
- package/dist/agent/compose.d.ts +0 -23
- package/dist/agent/compose.js +0 -42
- package/dist/agent/compose.js.map +0 -1
- package/dist/agent/ops-server.d.ts +0 -18
- package/dist/agent/ops-server.js +0 -175
- package/dist/agent/ops-server.js.map +0 -1
- package/dist/agent/ops-stdio.d.ts +0 -5
- package/dist/agent/ops-stdio.js +0 -47
- package/dist/agent/ops-stdio.js.map +0 -1
- package/dist/agent/ops.d.ts +0 -25
- package/dist/agent/ops.js +0 -82
- package/dist/agent/ops.js.map +0 -1
- package/dist/agent/protocol.d.ts +0 -72
- package/dist/agent/protocol.js +0 -195
- package/dist/agent/protocol.js.map +0 -1
- package/dist/agent/supervisor.d.ts +0 -80
- package/dist/agent/supervisor.js +0 -281
- package/dist/agent/supervisor.js.map +0 -1
- package/dist/agent/task-store.d.ts +0 -82
- package/dist/agent/task-store.js +0 -220
- package/dist/agent/task-store.js.map +0 -1
- package/dist/agent/tool-executor.d.ts +0 -28
- package/dist/agent/tool-executor.js +0 -113
- package/dist/agent/tool-executor.js.map +0 -1
- package/dist/agent/worktrees.d.ts +0 -35
- package/dist/agent/worktrees.js +0 -143
- package/dist/agent/worktrees.js.map +0 -1
- package/dist/runtime/relay-agent.d.ts +0 -25
- package/dist/runtime/relay-agent.js +0 -63
- package/dist/runtime/relay-agent.js.map +0 -1
package/dist/agent/ops-server.js
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Local GUI ops socket (plan §4.2 as amended for M4): a Unix domain socket
|
|
3
|
-
* bound to the current user (0600) exposing the shared agent-op surface plus
|
|
4
|
-
* `config_get`/`config_set`, and pushing `tasks_changed` notifications so the
|
|
5
|
-
* Frely App task panel stays live. The socket lives only as long as the
|
|
6
|
-
* serving process (`frely mcp serve`), which is also the process hosting
|
|
7
|
-
* agent task execution, so remote and GUI views share one task store.
|
|
8
|
-
*/
|
|
9
|
-
import { connect, createServer } from "node:net";
|
|
10
|
-
import { chmod, mkdir, rm } from "node:fs/promises";
|
|
11
|
-
import { dirname, join } from "node:path";
|
|
12
|
-
import { loadAgentConfig, saveAgentConfig } from "./agent-service.js";
|
|
13
|
-
import { AGENT_MAX_COST_USD_LIMIT, agentStateDir, TaskStore } from "./task-store.js";
|
|
14
|
-
import { VERSION } from "../version.js";
|
|
15
|
-
import { AGENT_OPS, dispatchAgentOp, isAgentOp } from "./ops.js";
|
|
16
|
-
const MAX_LINE_BYTES = 512 * 1024;
|
|
17
|
-
export async function startAgentOpsServer(agent, options) {
|
|
18
|
-
const env = options.env ?? process.env;
|
|
19
|
-
const socketPath = options.socketPath ?? join(agentStateDir(env), "ops.sock");
|
|
20
|
-
await mkdir(dirname(socketPath), { recursive: true, mode: 0o700 });
|
|
21
|
-
await rm(socketPath, { force: true });
|
|
22
|
-
const sockets = new Set();
|
|
23
|
-
const clients = new Set();
|
|
24
|
-
const store = TaskStore.open(undefined, env);
|
|
25
|
-
const server = createServer((socket) => {
|
|
26
|
-
sockets.add(socket);
|
|
27
|
-
socket.setEncoding("utf8");
|
|
28
|
-
const client = {
|
|
29
|
-
write: (line) => {
|
|
30
|
-
if (!socket.destroyed)
|
|
31
|
-
socket.write(`${line}\n`);
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
clients.add(client);
|
|
35
|
-
let buffer = "";
|
|
36
|
-
socket.on("data", (chunk) => {
|
|
37
|
-
buffer += chunk;
|
|
38
|
-
let newline = buffer.indexOf("\n");
|
|
39
|
-
while (newline >= 0) {
|
|
40
|
-
const line = buffer.slice(0, newline).trim();
|
|
41
|
-
buffer = buffer.slice(newline + 1);
|
|
42
|
-
if (line.length > 0)
|
|
43
|
-
void handleLine(line, client);
|
|
44
|
-
if (buffer.length > MAX_LINE_BYTES) {
|
|
45
|
-
client.write(JSON.stringify({ id: null, ok: false, error: { code: "request_too_large", message: "Request line exceeds the 512KB limit." } }));
|
|
46
|
-
socket.destroy();
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
newline = buffer.indexOf("\n");
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
socket.on("close", () => { clients.delete(client); sockets.delete(socket); });
|
|
53
|
-
socket.on("error", () => { clients.delete(client); sockets.delete(socket); });
|
|
54
|
-
// Greet the client with a task snapshot so it can render without a leading list call.
|
|
55
|
-
void store.list().then((tasks) => client.write(JSON.stringify({ push: "tasks_changed", tasks })), () => undefined);
|
|
56
|
-
});
|
|
57
|
-
await new Promise((resolve, reject) => {
|
|
58
|
-
server.once("error", reject);
|
|
59
|
-
server.listen(socketPath, () => resolve());
|
|
60
|
-
});
|
|
61
|
-
await chmod(socketPath, 0o600);
|
|
62
|
-
const pollIntervalMs = options.pollIntervalMs ?? 1000;
|
|
63
|
-
// Establish the baseline before accepting changes: any task created after
|
|
64
|
-
// startup (including between a client's welcome snapshot and the first
|
|
65
|
-
// poll tick) must eventually produce a push.
|
|
66
|
-
let fingerprint = fingerprintFor(await store.list());
|
|
67
|
-
const poll = setInterval(() => {
|
|
68
|
-
if (clients.size === 0)
|
|
69
|
-
return;
|
|
70
|
-
void store.list().then((tasks) => {
|
|
71
|
-
const next = fingerprintFor(tasks);
|
|
72
|
-
if (next === fingerprint)
|
|
73
|
-
return;
|
|
74
|
-
fingerprint = next;
|
|
75
|
-
broadcast(JSON.stringify({ push: "tasks_changed", tasks }));
|
|
76
|
-
}, (error) => options.log?.(`agent.ops.poll_failed ${error instanceof Error ? error.message : String(error)}`));
|
|
77
|
-
}, pollIntervalMs);
|
|
78
|
-
poll.unref?.();
|
|
79
|
-
async function handleLine(line, client) {
|
|
80
|
-
let request;
|
|
81
|
-
try {
|
|
82
|
-
const parsed = JSON.parse(line);
|
|
83
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
84
|
-
throw new Error("not an object");
|
|
85
|
-
request = parsed;
|
|
86
|
-
}
|
|
87
|
-
catch {
|
|
88
|
-
client.write(JSON.stringify({ id: null, ok: false, error: { code: "invalid_request", message: "Each line must be a JSON request object." } }));
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
const id = request.id ?? null;
|
|
92
|
-
try {
|
|
93
|
-
const result = await dispatch(request);
|
|
94
|
-
client.write(JSON.stringify({ id, ok: true, result }));
|
|
95
|
-
}
|
|
96
|
-
catch (error) {
|
|
97
|
-
const code = error instanceof Error && "code" in error && typeof error.code === "string" ? error.code : "internal";
|
|
98
|
-
client.write(JSON.stringify({ id, ok: false, error: { code, message: error instanceof Error ? error.message : String(error) } }));
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
async function dispatch(request) {
|
|
102
|
-
if (request.op === "ping")
|
|
103
|
-
return { pong: true, pid: process.pid, version: VERSION };
|
|
104
|
-
if (request.op === "config_get")
|
|
105
|
-
return { config: await loadAgentConfig(env) };
|
|
106
|
-
if (request.op === "config_set") {
|
|
107
|
-
const patch = (request.args && typeof request.args === "object" && !Array.isArray(request.args) ? request.args : {});
|
|
108
|
-
const current = await loadAgentConfig(env);
|
|
109
|
-
const next = {
|
|
110
|
-
schemaVersion: 1,
|
|
111
|
-
remoteControlEnabled: typeof patch.remoteControlEnabled === "boolean" ? patch.remoteControlEnabled : current.remoteControlEnabled,
|
|
112
|
-
defaultMaxCostUsd: typeof patch.defaultMaxCostUsd === "number" ? patch.defaultMaxCostUsd : current.defaultMaxCostUsd,
|
|
113
|
-
maxCostUsdLimit: clampCost(patch.maxCostUsdLimit, current.maxCostUsdLimit),
|
|
114
|
-
maxConcurrentTasks: clampConcurrency(patch.maxConcurrentTasks, current.maxConcurrentTasks),
|
|
115
|
-
};
|
|
116
|
-
await saveAgentConfig(next, env);
|
|
117
|
-
return { config: next };
|
|
118
|
-
}
|
|
119
|
-
if (typeof request.op === "string" && isAgentOp(request.op)) {
|
|
120
|
-
const args = (request.args && typeof request.args === "object" && !Array.isArray(request.args) ? request.args : {});
|
|
121
|
-
return dispatchAgentOp(request.op, args, agent, { workspace: options.workspace }, { source: { kind: "gui" }, approvedBy: "gui" });
|
|
122
|
-
}
|
|
123
|
-
throw Object.assign(new Error(`Unknown op. Supported: ping, config_get, config_set, and agent ops (${AGENT_OPS.join(", ")}).`), { code: "unknown_op" });
|
|
124
|
-
}
|
|
125
|
-
function broadcast(line) {
|
|
126
|
-
for (const client of clients)
|
|
127
|
-
client.write(line);
|
|
128
|
-
}
|
|
129
|
-
return {
|
|
130
|
-
path: socketPath,
|
|
131
|
-
close: async () => {
|
|
132
|
-
clearInterval(poll);
|
|
133
|
-
clients.clear();
|
|
134
|
-
for (const socket of sockets)
|
|
135
|
-
socket.destroy();
|
|
136
|
-
await new Promise((resolve) => server.close(() => resolve()));
|
|
137
|
-
await rm(socketPath, { force: true });
|
|
138
|
-
},
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
function clampCost(value, fallback) {
|
|
142
|
-
return typeof value === "number" && Number.isFinite(value) && value > 0 && value <= AGENT_MAX_COST_USD_LIMIT ? value : fallback;
|
|
143
|
-
}
|
|
144
|
-
function clampConcurrency(value, fallback) {
|
|
145
|
-
return typeof value === "number" && Number.isSafeInteger(value) && value >= 1 && value <= 4 ? value : fallback;
|
|
146
|
-
}
|
|
147
|
-
function fingerprintFor(tasks) {
|
|
148
|
-
return JSON.stringify(tasks.map((task) => [task.id, task.status, task.mergeStatus, task.usage.costUsd, task.updatedAt]));
|
|
149
|
-
}
|
|
150
|
-
export function pingAgentOpsSocket(socketPath, timeoutMs) {
|
|
151
|
-
return new Promise((resolvePing) => {
|
|
152
|
-
const socket = connect(socketPath);
|
|
153
|
-
const finish = (value) => {
|
|
154
|
-
socket.destroy();
|
|
155
|
-
clearTimeout(timer);
|
|
156
|
-
resolvePing(value);
|
|
157
|
-
};
|
|
158
|
-
const timer = setTimeout(() => finish({ running: false }), timeoutMs);
|
|
159
|
-
socket.on("connect", () => socket.write(`${JSON.stringify({ id: 1, op: "ping", args: {} })}\n`));
|
|
160
|
-
socket.on("data", (chunk) => {
|
|
161
|
-
for (const line of chunk.toString("utf8").split("\n")) {
|
|
162
|
-
if (line.trim().length === 0)
|
|
163
|
-
continue;
|
|
164
|
-
try {
|
|
165
|
-
const response = JSON.parse(line);
|
|
166
|
-
if (response.ok && response.result?.pong)
|
|
167
|
-
finish({ running: true, pid: response.result.pid, version: response.result.version });
|
|
168
|
-
}
|
|
169
|
-
catch { /* ignore partial lines */ }
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
socket.on("error", () => finish({ running: false }));
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
//# sourceMappingURL=ops-server.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ops-server.js","sourceRoot":"","sources":["../../src/agent/ops-server.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,OAAO,EAAE,YAAY,EAA4B,MAAM,UAAU,CAAC;AAC3E,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAG1C,OAAO,EAAE,eAAe,EAAE,eAAe,EAA2B,MAAM,oBAAoB,CAAC;AAE/F,OAAO,EAAE,wBAAwB,EAAE,aAAa,EAAE,SAAS,EAAwB,MAAM,iBAAiB,CAAC;AAC3G,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEjE,MAAM,cAAc,GAAG,GAAG,GAAG,IAAI,CAAC;AAiBlC,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,KAAmB,EAAE,OAA8B;IAC3F,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IACvC,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC,CAAC;IAC9E,MAAM,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACnE,MAAM,EAAE,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAEtC,MAAM,OAAO,GAA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I,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;QACjG,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE;YAClC,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBACtD,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC;oBAAE,SAAS;gBACvC,IAAI,CAAC;oBACH,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAkF,CAAC;oBACnH,IAAI,QAAQ,CAAC,EAAE,IAAI,QAAQ,CAAC,MAAM,EAAE,IAAI;wBAAE,MAAM,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;gBAClI,CAAC;gBAAC,MAAM,CAAC,CAAC,0BAA0B,CAAC,CAAC;YACxC,CAAC;QACH,CAAC,CAAC,CAAC;QACH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/agent/ops-stdio.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `frely app ops`: stdio bridge to the local agent ops socket.
|
|
3
|
-
*
|
|
4
|
-
* The Frely App GUI cannot open Unix domain sockets from Dart, so it spawns
|
|
5
|
-
* this command instead: the process connects to `<state>/agent/ops.sock`,
|
|
6
|
-
* bridges stdin -> socket and socket -> stdout line by line, and exits 1 with
|
|
7
|
-
* a stderr hint when no serving process is running. This keeps the socket's
|
|
8
|
-
* same-user permission boundary (the bridge runs as the current user) while
|
|
9
|
-
* giving the GUI a plain NDJSON stream with tasks_changed pushes.
|
|
10
|
-
*/
|
|
11
|
-
import { connect } from "node:net";
|
|
12
|
-
import { createInterface } from "node:readline";
|
|
13
|
-
import { agentStateDir } from "./task-store.js";
|
|
14
|
-
import { pingAgentOpsSocket } from "./ops-server.js";
|
|
15
|
-
export async function runAgentOpsStdioBridge(args) {
|
|
16
|
-
const socketPath = `${agentStateDir()}/ops.sock`;
|
|
17
|
-
const probe = await pingAgentOpsSocket(socketPath, 1000);
|
|
18
|
-
if (!probe.running) {
|
|
19
|
-
args.stderr.write(`Agent ops socket is not reachable at ${socketPath}. Start it with: frely mcp serve\n`);
|
|
20
|
-
return 1;
|
|
21
|
-
}
|
|
22
|
-
await new Promise((resolve) => {
|
|
23
|
-
let settled = false;
|
|
24
|
-
const finish = (code) => {
|
|
25
|
-
if (!settled) {
|
|
26
|
-
settled = true;
|
|
27
|
-
resolve(code);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
const socket = connect(socketPath);
|
|
31
|
-
socket.on("error", (error) => {
|
|
32
|
-
args.stderr.write(`Agent ops socket failed: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
33
|
-
finish(1);
|
|
34
|
-
});
|
|
35
|
-
socket.on("close", () => finish(0));
|
|
36
|
-
socket.pipe(args.stdout);
|
|
37
|
-
const lines = createInterface({ input: args.stdin });
|
|
38
|
-
lines.on("line", (line) => {
|
|
39
|
-
if (line.trim().length > 0 && !socket.destroyed)
|
|
40
|
-
socket.write(`${line}\n`);
|
|
41
|
-
});
|
|
42
|
-
args.stdin.on("close", () => socket.end());
|
|
43
|
-
args.stdin.on("end", () => socket.end());
|
|
44
|
-
});
|
|
45
|
-
return 0;
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=ops-stdio.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ops-stdio.js","sourceRoot":"","sources":["../../src/agent/ops-stdio.ts"],"names":[],"mappings":"AAAA;;;;;;;;;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C,CAAC,CAAC,CAAC,CAAC;QACpC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzB,MAAM,KAAK,GAAG,eAAe,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QACrD,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;YACxB,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS;gBAAE,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;QAC7E,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;QAC3C,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IACH,OAAO,CAAC,CAAC;AACX,CAAC"}
|
package/dist/agent/ops.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared agent-op dispatch (plan §5). The same op surface serves three
|
|
3
|
-
* transports: device-relay `method: "agent"` (remote web), the MCP frely-app
|
|
4
|
-
* toolset bridge, and the local GUI ops socket (M4). Each transport passes its
|
|
5
|
-
* own task `source` and merge `approvedBy` identity; only the ops socket gets
|
|
6
|
-
* the full task record (source, worktreePath, approval) because it never
|
|
7
|
-
* leaves the device.
|
|
8
|
-
*/
|
|
9
|
-
import type { AgentService } from "./agent-service.js";
|
|
10
|
-
import type { AgentTaskRecord, AgentTaskSource } from "./task-store.js";
|
|
11
|
-
export declare const AGENT_OPS: readonly ["agent_start_task", "agent_list_tasks", "agent_get_task", "agent_get_events", "agent_send_message", "agent_get_diff", "agent_request_merge", "agent_approve_merge", "agent_discard_task", "agent_cancel_task"];
|
|
12
|
-
export type AgentOp = (typeof AGENT_OPS)[number];
|
|
13
|
-
export declare class AgentOpError extends Error {
|
|
14
|
-
readonly code: string;
|
|
15
|
-
constructor(code: string, message?: string);
|
|
16
|
-
}
|
|
17
|
-
export type AgentOpIdentity = {
|
|
18
|
-
source: AgentTaskSource;
|
|
19
|
-
approvedBy: "gui" | "web";
|
|
20
|
-
};
|
|
21
|
-
export declare function isAgentOp(op: string): op is AgentOp;
|
|
22
|
-
export declare function dispatchAgentOp(op: AgentOp, args: Record<string, unknown>, agent: AgentService, defaults: {
|
|
23
|
-
workspace: string;
|
|
24
|
-
}, identity?: AgentOpIdentity): Promise<unknown>;
|
|
25
|
-
export type { AgentTaskRecord };
|
package/dist/agent/ops.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
export const AGENT_OPS = [
|
|
2
|
-
"agent_start_task",
|
|
3
|
-
"agent_list_tasks",
|
|
4
|
-
"agent_get_task",
|
|
5
|
-
"agent_get_events",
|
|
6
|
-
"agent_send_message",
|
|
7
|
-
"agent_get_diff",
|
|
8
|
-
"agent_request_merge",
|
|
9
|
-
"agent_approve_merge",
|
|
10
|
-
"agent_discard_task",
|
|
11
|
-
"agent_cancel_task",
|
|
12
|
-
];
|
|
13
|
-
export class AgentOpError extends Error {
|
|
14
|
-
code;
|
|
15
|
-
constructor(code, message) {
|
|
16
|
-
super(message ?? code);
|
|
17
|
-
this.code = code;
|
|
18
|
-
this.name = "AgentOpError";
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
export function isAgentOp(op) {
|
|
22
|
-
return AGENT_OPS.includes(op);
|
|
23
|
-
}
|
|
24
|
-
export async function dispatchAgentOp(op, args, agent, defaults, identity = { source: { kind: "web" }, approvedBy: "web" }) {
|
|
25
|
-
switch (op) {
|
|
26
|
-
case "agent_start_task": {
|
|
27
|
-
const task = await agent.startTask({
|
|
28
|
-
workspace: optionalString(args.workspace) ?? defaults.workspace,
|
|
29
|
-
goal: requiredString(args.goal, "goal"),
|
|
30
|
-
...(typeof args.model === "string" && args.model.length > 0 ? { model: args.model } : {}),
|
|
31
|
-
...(typeof args.maxCostUsd === "number" && Number.isFinite(args.maxCostUsd) ? { maxCostUsd: args.maxCostUsd } : {}),
|
|
32
|
-
source: identity.source,
|
|
33
|
-
});
|
|
34
|
-
return { task };
|
|
35
|
-
}
|
|
36
|
-
case "agent_list_tasks": {
|
|
37
|
-
const workspace = optionalString(args.workspace) ?? defaults.workspace;
|
|
38
|
-
return { tasks: await agent.listTasks(workspace) };
|
|
39
|
-
}
|
|
40
|
-
case "agent_get_task":
|
|
41
|
-
return { task: await agent.getTask(requiredTaskId(args)) };
|
|
42
|
-
case "agent_get_events": {
|
|
43
|
-
const cursor = optionalNumber(args.cursor) ?? 0;
|
|
44
|
-
const page = await agent.getEvents(requiredTaskId(args), Number.isSafeInteger(cursor) && cursor >= 0 ? cursor : 0);
|
|
45
|
-
return { events: page.events, nextCursor: page.nextCursor };
|
|
46
|
-
}
|
|
47
|
-
case "agent_send_message":
|
|
48
|
-
await agent.sendMessage(requiredTaskId(args), requiredString(args.message, "message"));
|
|
49
|
-
return { sent: true };
|
|
50
|
-
case "agent_get_diff": {
|
|
51
|
-
const result = await agent.getDiff(requiredTaskId(args), optionalString(args.path));
|
|
52
|
-
return { diff: result.diff, truncated: result.truncated };
|
|
53
|
-
}
|
|
54
|
-
case "agent_request_merge": {
|
|
55
|
-
const note = optionalString(args.note);
|
|
56
|
-
return { task: await agent.requestMerge(requiredTaskId(args), note) };
|
|
57
|
-
}
|
|
58
|
-
case "agent_approve_merge":
|
|
59
|
-
return { task: await agent.approveMerge(requiredTaskId(args), identity.approvedBy) };
|
|
60
|
-
case "agent_discard_task":
|
|
61
|
-
return { task: await agent.discardTask(requiredTaskId(args)) };
|
|
62
|
-
case "agent_cancel_task":
|
|
63
|
-
return { task: await agent.cancelTask(requiredTaskId(args)) };
|
|
64
|
-
default:
|
|
65
|
-
throw new AgentOpError("unknown_op", op);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
function requiredTaskId(args) {
|
|
69
|
-
return requiredString(args.taskId, "taskId");
|
|
70
|
-
}
|
|
71
|
-
function requiredString(value, name) {
|
|
72
|
-
if (typeof value !== "string" || value.length === 0)
|
|
73
|
-
throw new AgentOpError("invalid_args", `${name} must be a non-empty string.`);
|
|
74
|
-
return value;
|
|
75
|
-
}
|
|
76
|
-
function optionalString(value) {
|
|
77
|
-
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
78
|
-
}
|
|
79
|
-
function optionalNumber(value) {
|
|
80
|
-
return typeof value === "number" && Number.isFinite(value) ? value : undefined;
|
|
81
|
-
}
|
|
82
|
-
//# sourceMappingURL=ops.js.map
|
package/dist/agent/ops.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ops.js","sourceRoot":"","sources":["../../src/agent/ops.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,kBAAkB;IAClB,kBAAkB;IAClB,gBAAgB;IAChB,kBAAkB;IAClB,oBAAoB;IACpB,gBAAgB;IAChB,qBAAqB;IACrB,qBAAqB;IACrB,oBAAoB;IACpB,mBAAmB;CACX,CAAC;AAIX,MAAM,OAAO,YAAa,SAAQ,KAAK;IAChB;IAArB,YAAqB,IAAY,EAAE,OAAgB;QACjD,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC;QADJ,SAAI,GAAJ,IAAI,CAAQ;QAE/B,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AAID,MAAM,UAAU,SAAS,CAAC,EAAU;IAClC,OAAQ,SAA+B,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,EAAW,EACX,IAA6B,EAC7B,KAAmB,EACnB,QAA+B,EAC/B,WAA4B,EAAE,MAAM,EAAE,EAAE,IAA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K,oBAAoB;YACvB,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC,WAAW,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;QACjE,KAAK,mBAAmB;YACtB,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;QAChE;YACE,MAAM,IAAI,YAAY,CAAC,YAAY,EAAE,EAAkB,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC;AAED,SAAS,cAAc,CAAC,IAA6B;IACnD,OAAO,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,cAAc,CAAC,KAAc,EAAE,IAAY;IAClD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,YAAY,CAAC,cAAc,EAAE,GAAG,IAAI,8BAA8B,CAAC,CAAC;IACnI,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,cAAc,CAAC,KAAc;IACpC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3E,CAAC;AAED,SAAS,cAAc,CAAC,KAAc;IACpC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACjF,CAAC"}
|
package/dist/agent/protocol.d.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
export declare const AGENT_HOST_PROTOCOL = "frely.agent-host.v1";
|
|
2
|
-
export declare const AGENT_HOST_PROTOCOL_VERSION = 1;
|
|
3
|
-
export declare const AGENT_HOST_MAX_FRAME_BYTES: number;
|
|
4
|
-
export declare const AGENT_HOST_CONNECTION_KEY_ENV = "FRELY_AGENT_HOST_KEY";
|
|
5
|
-
export type AgentHostTaskStatus = "running" | "waiting_input" | "completed" | "failed" | "cancelled";
|
|
6
|
-
export type AgentHostTaskEvent = {
|
|
7
|
-
type: "status";
|
|
8
|
-
status: AgentHostTaskStatus;
|
|
9
|
-
detail?: string;
|
|
10
|
-
} | {
|
|
11
|
-
type: "message";
|
|
12
|
-
role: "assistant" | "user" | "system";
|
|
13
|
-
text: string;
|
|
14
|
-
partial?: boolean;
|
|
15
|
-
} | {
|
|
16
|
-
type: "tool_call";
|
|
17
|
-
tool: string;
|
|
18
|
-
summary: string;
|
|
19
|
-
state: "started" | "finished" | "failed";
|
|
20
|
-
} | {
|
|
21
|
-
type: "usage";
|
|
22
|
-
inputTokens: number;
|
|
23
|
-
outputTokens: number;
|
|
24
|
-
costUsd: number;
|
|
25
|
-
} | {
|
|
26
|
-
type: "log";
|
|
27
|
-
text: string;
|
|
28
|
-
};
|
|
29
|
-
export type JsonRpcId = number | string;
|
|
30
|
-
export type JsonRpcRequest = {
|
|
31
|
-
jsonrpc: "2.0";
|
|
32
|
-
id?: JsonRpcId;
|
|
33
|
-
method: string;
|
|
34
|
-
params?: Record<string, unknown>;
|
|
35
|
-
};
|
|
36
|
-
export type JsonRpcResponse = {
|
|
37
|
-
jsonrpc: "2.0";
|
|
38
|
-
id: JsonRpcId;
|
|
39
|
-
result?: unknown;
|
|
40
|
-
error?: {
|
|
41
|
-
code: number;
|
|
42
|
-
message: string;
|
|
43
|
-
data?: unknown;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
export type JsonRpcMessage = JsonRpcRequest | JsonRpcResponse | {
|
|
47
|
-
jsonrpc: "2.0";
|
|
48
|
-
method: string;
|
|
49
|
-
params?: Record<string, unknown>;
|
|
50
|
-
};
|
|
51
|
-
export declare class AgentHostProtocolError extends Error {
|
|
52
|
-
readonly code: "frame_invalid" | "frame_too_large" | "handshake_rejected" | "unexpected_frame";
|
|
53
|
-
constructor(code: "frame_invalid" | "frame_too_large" | "handshake_rejected" | "unexpected_frame");
|
|
54
|
-
}
|
|
55
|
-
export declare function newConnectionKey(): string;
|
|
56
|
-
export declare function isValidTaskId(id: string): boolean;
|
|
57
|
-
export declare function newTaskId(): string;
|
|
58
|
-
/** Encode one NDJSON frame. */
|
|
59
|
-
export declare function encodeAgentHostFrame(message: JsonRpcMessage): string;
|
|
60
|
-
/** Decode one NDJSON frame (without the trailing newline). */
|
|
61
|
-
export declare function decodeAgentHostFrame(line: Buffer | string): JsonRpcMessage;
|
|
62
|
-
/** Validate and normalize a `task.event` notification params object. */
|
|
63
|
-
export declare function decodeTaskEvent(params: unknown): {
|
|
64
|
-
taskId: string;
|
|
65
|
-
event: AgentHostTaskEvent;
|
|
66
|
-
};
|
|
67
|
-
export declare function isToolMethod(method: string): boolean;
|
|
68
|
-
/** Validate params of a `tool.*` request from the host. Returns normalized args. */
|
|
69
|
-
export declare function decodeToolParams(method: string, params: unknown): {
|
|
70
|
-
taskId: string;
|
|
71
|
-
args: Record<string, unknown>;
|
|
72
|
-
};
|
package/dist/agent/protocol.js
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* frely.agent-host.v1 — wire contract between the CLI (supervisor) and the
|
|
3
|
-
* Pi Node agent host. See docs/agent-host.md for the public description.
|
|
4
|
-
*/
|
|
5
|
-
import { randomBytes } from "node:crypto";
|
|
6
|
-
export const AGENT_HOST_PROTOCOL = "frely.agent-host.v1";
|
|
7
|
-
export const AGENT_HOST_PROTOCOL_VERSION = 1;
|
|
8
|
-
export const AGENT_HOST_MAX_FRAME_BYTES = 1024 * 1024;
|
|
9
|
-
export const AGENT_HOST_CONNECTION_KEY_ENV = "FRELY_AGENT_HOST_KEY";
|
|
10
|
-
export class AgentHostProtocolError extends Error {
|
|
11
|
-
code;
|
|
12
|
-
constructor(code) {
|
|
13
|
-
super(code);
|
|
14
|
-
this.code = code;
|
|
15
|
-
this.name = "AgentHostProtocolError";
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
export function newConnectionKey() {
|
|
19
|
-
return randomBytes(32).toString("base64url");
|
|
20
|
-
}
|
|
21
|
-
export function isValidTaskId(id) {
|
|
22
|
-
return /^at_[a-z0-9]{24}$/u.test(id);
|
|
23
|
-
}
|
|
24
|
-
export function newTaskId() {
|
|
25
|
-
return `at_${randomBytes(12).toString("hex")}`;
|
|
26
|
-
}
|
|
27
|
-
/** Encode one NDJSON frame. */
|
|
28
|
-
export function encodeAgentHostFrame(message) {
|
|
29
|
-
const line = JSON.stringify(message);
|
|
30
|
-
if (Buffer.byteLength(line) > AGENT_HOST_MAX_FRAME_BYTES)
|
|
31
|
-
throw new AgentHostProtocolError("frame_too_large");
|
|
32
|
-
return `${line}\n`;
|
|
33
|
-
}
|
|
34
|
-
/** Decode one NDJSON frame (without the trailing newline). */
|
|
35
|
-
export function decodeAgentHostFrame(line) {
|
|
36
|
-
if (Buffer.byteLength(line) > AGENT_HOST_MAX_FRAME_BYTES)
|
|
37
|
-
throw new AgentHostProtocolError("frame_too_large");
|
|
38
|
-
let value;
|
|
39
|
-
try {
|
|
40
|
-
value = JSON.parse(Buffer.isBuffer(line) ? line.toString("utf8") : line);
|
|
41
|
-
}
|
|
42
|
-
catch {
|
|
43
|
-
throw new AgentHostProtocolError("frame_invalid");
|
|
44
|
-
}
|
|
45
|
-
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
46
|
-
throw new AgentHostProtocolError("frame_invalid");
|
|
47
|
-
const record = value;
|
|
48
|
-
if (record.jsonrpc !== "2.0")
|
|
49
|
-
throw new AgentHostProtocolError("frame_invalid");
|
|
50
|
-
if ("method" in record) {
|
|
51
|
-
if (typeof record.method !== "string" || record.method.length === 0)
|
|
52
|
-
throw new AgentHostProtocolError("frame_invalid");
|
|
53
|
-
if ("id" in record && record.id !== null && typeof record.id !== "number" && typeof record.id !== "string") {
|
|
54
|
-
throw new AgentHostProtocolError("frame_invalid");
|
|
55
|
-
}
|
|
56
|
-
if ("params" in record && record.params !== undefined && (typeof record.params !== "object" || record.params === null)) {
|
|
57
|
-
throw new AgentHostProtocolError("frame_invalid");
|
|
58
|
-
}
|
|
59
|
-
return value;
|
|
60
|
-
}
|
|
61
|
-
if (typeof record.id !== "number" && typeof record.id !== "string")
|
|
62
|
-
throw new AgentHostProtocolError("frame_invalid");
|
|
63
|
-
if (!("result" in record) && !("error" in record))
|
|
64
|
-
throw new AgentHostProtocolError("frame_invalid");
|
|
65
|
-
if ("error" in record && record.error !== undefined) {
|
|
66
|
-
const error = record.error;
|
|
67
|
-
if (!error || typeof error !== "object" || typeof error.code !== "number" || typeof error.message !== "string") {
|
|
68
|
-
throw new AgentHostProtocolError("frame_invalid");
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return value;
|
|
72
|
-
}
|
|
73
|
-
/** Validate and normalize a `task.event` notification params object. */
|
|
74
|
-
export function decodeTaskEvent(params) {
|
|
75
|
-
if (!params || typeof params !== "object")
|
|
76
|
-
throw new AgentHostProtocolError("frame_invalid");
|
|
77
|
-
const record = params;
|
|
78
|
-
if (typeof record.taskId !== "string" || !isValidTaskId(record.taskId))
|
|
79
|
-
throw new AgentHostProtocolError("frame_invalid");
|
|
80
|
-
const event = record.event;
|
|
81
|
-
if (!event || typeof event !== "object")
|
|
82
|
-
throw new AgentHostProtocolError("frame_invalid");
|
|
83
|
-
const item = event;
|
|
84
|
-
switch (item.type) {
|
|
85
|
-
case "status":
|
|
86
|
-
if (item.status !== "running" && item.status !== "waiting_input" && item.status !== "completed" && item.status !== "failed" && item.status !== "cancelled") {
|
|
87
|
-
throw new AgentHostProtocolError("frame_invalid");
|
|
88
|
-
}
|
|
89
|
-
if (item.detail !== undefined && typeof item.detail !== "string")
|
|
90
|
-
throw new AgentHostProtocolError("frame_invalid");
|
|
91
|
-
return { taskId: record.taskId, event: item };
|
|
92
|
-
case "message":
|
|
93
|
-
if (item.role !== "assistant" && item.role !== "user" && item.role !== "system")
|
|
94
|
-
throw new AgentHostProtocolError("frame_invalid");
|
|
95
|
-
if (typeof item.text !== "string" || item.text.length > 64 * 1024)
|
|
96
|
-
throw new AgentHostProtocolError("frame_invalid");
|
|
97
|
-
if (item.partial !== undefined && typeof item.partial !== "boolean")
|
|
98
|
-
throw new AgentHostProtocolError("frame_invalid");
|
|
99
|
-
return { taskId: record.taskId, event: item };
|
|
100
|
-
case "tool_call":
|
|
101
|
-
if (typeof item.tool !== "string" || typeof item.summary !== "string" || item.summary.length > 2048)
|
|
102
|
-
throw new AgentHostProtocolError("frame_invalid");
|
|
103
|
-
if (item.state !== "started" && item.state !== "finished" && item.state !== "failed")
|
|
104
|
-
throw new AgentHostProtocolError("frame_invalid");
|
|
105
|
-
return { taskId: record.taskId, event: item };
|
|
106
|
-
case "usage": {
|
|
107
|
-
for (const key of ["inputTokens", "outputTokens", "costUsd"]) {
|
|
108
|
-
const value = item[key];
|
|
109
|
-
if (typeof value !== "number" || !Number.isFinite(value) || value < 0)
|
|
110
|
-
throw new AgentHostProtocolError("frame_invalid");
|
|
111
|
-
}
|
|
112
|
-
return { taskId: record.taskId, event: item };
|
|
113
|
-
}
|
|
114
|
-
case "log":
|
|
115
|
-
if (typeof item.text !== "string" || item.text.length > 4096)
|
|
116
|
-
throw new AgentHostProtocolError("frame_invalid");
|
|
117
|
-
return { taskId: record.taskId, event: item };
|
|
118
|
-
default:
|
|
119
|
-
throw new AgentHostProtocolError("frame_invalid");
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
const TOOL_METHODS = new Set(["tool.read", "tool.write", "tool.edit", "tool.bash", "tool.grep", "tool.find", "tool.ls"]);
|
|
123
|
-
export function isToolMethod(method) {
|
|
124
|
-
return TOOL_METHODS.has(method);
|
|
125
|
-
}
|
|
126
|
-
/** Validate params of a `tool.*` request from the host. Returns normalized args. */
|
|
127
|
-
export function decodeToolParams(method, params) {
|
|
128
|
-
if (!params || typeof params !== "object")
|
|
129
|
-
throw new AgentHostProtocolError("frame_invalid");
|
|
130
|
-
const record = params;
|
|
131
|
-
if (typeof record.taskId !== "string" || !isValidTaskId(record.taskId))
|
|
132
|
-
throw new AgentHostProtocolError("frame_invalid");
|
|
133
|
-
const { taskId, ...args } = record;
|
|
134
|
-
switch (method) {
|
|
135
|
-
case "tool.read":
|
|
136
|
-
requireString(args, "path");
|
|
137
|
-
break;
|
|
138
|
-
case "tool.write":
|
|
139
|
-
requireString(args, "path");
|
|
140
|
-
if (typeof args.content !== "string")
|
|
141
|
-
throw new AgentHostProtocolError("frame_invalid");
|
|
142
|
-
optionalBoolean(args, "overwrite");
|
|
143
|
-
break;
|
|
144
|
-
case "tool.edit":
|
|
145
|
-
requireString(args, "path");
|
|
146
|
-
if (!Array.isArray(args.edits) || args.edits.length === 0)
|
|
147
|
-
throw new AgentHostProtocolError("frame_invalid");
|
|
148
|
-
break;
|
|
149
|
-
case "tool.bash":
|
|
150
|
-
requireString(args, "command");
|
|
151
|
-
optionalString(args, "cwd");
|
|
152
|
-
if (args.timeoutMs !== undefined && (typeof args.timeoutMs !== "number" || !Number.isSafeInteger(args.timeoutMs) || args.timeoutMs < 100 || args.timeoutMs > 120_000)) {
|
|
153
|
-
throw new AgentHostProtocolError("frame_invalid");
|
|
154
|
-
}
|
|
155
|
-
break;
|
|
156
|
-
case "tool.grep":
|
|
157
|
-
requireString(args, "query");
|
|
158
|
-
optionalString(args, "path");
|
|
159
|
-
optionalBoolean(args, "regex");
|
|
160
|
-
optionalBoolean(args, "caseSensitive");
|
|
161
|
-
optionalInteger(args, "maxResults", 1, 200);
|
|
162
|
-
optionalInteger(args, "contextLines", 0, 5);
|
|
163
|
-
break;
|
|
164
|
-
case "tool.find":
|
|
165
|
-
requireString(args, "pattern");
|
|
166
|
-
optionalString(args, "path");
|
|
167
|
-
optionalInteger(args, "maxResults", 1, 500);
|
|
168
|
-
break;
|
|
169
|
-
case "tool.ls":
|
|
170
|
-
optionalString(args, "path");
|
|
171
|
-
break;
|
|
172
|
-
default:
|
|
173
|
-
throw new AgentHostProtocolError("frame_invalid");
|
|
174
|
-
}
|
|
175
|
-
return { taskId, args };
|
|
176
|
-
}
|
|
177
|
-
function requireString(args, key) {
|
|
178
|
-
if (typeof args[key] !== "string" || args[key].length === 0)
|
|
179
|
-
throw new AgentHostProtocolError("frame_invalid");
|
|
180
|
-
}
|
|
181
|
-
function optionalString(args, key) {
|
|
182
|
-
if (args[key] !== undefined && typeof args[key] !== "string")
|
|
183
|
-
throw new AgentHostProtocolError("frame_invalid");
|
|
184
|
-
}
|
|
185
|
-
function optionalBoolean(args, key) {
|
|
186
|
-
if (args[key] !== undefined && typeof args[key] !== "boolean")
|
|
187
|
-
throw new AgentHostProtocolError("frame_invalid");
|
|
188
|
-
}
|
|
189
|
-
function optionalInteger(args, key, min, max) {
|
|
190
|
-
const value = args[key];
|
|
191
|
-
if (value !== undefined && (typeof value !== "number" || !Number.isSafeInteger(value) || value < min || value > max)) {
|
|
192
|
-
throw new AgentHostProtocolError("frame_invalid");
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
//# sourceMappingURL=protocol.js.map
|