@sipher.dev/agents 0.1.0 → 0.1.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/connector-platforms.json +14 -0
- package/connector-runtime.json +4 -0
- package/dist/index.js +319 -3400
- package/dist/local-control-DKnrc-X8.d.ts +27 -0
- package/dist/local-control-Dm6FcXAi.js +429 -0
- package/dist/local-control-server.d.ts +18 -0
- package/dist/local-control-server.js +149 -0
- package/dist/local-control.d.ts +355 -0
- package/dist/local-control.js +2 -0
- package/dist/local-machine-controller-CjOyllJj.js +453 -0
- package/dist/release-resolver-PnPDodU9.js +5828 -0
- package/dist/src-ghbvDJyd.js +731 -0
- package/package.json +32 -23
- package/release-trust-anchor.json +11 -0
- package/dist/local-machine-controller-Dtiash-C.js +0 -2129
- package/dist/local-machine.d.ts +0 -177
- package/dist/local-machine.js +0 -2
|
@@ -0,0 +1,731 @@
|
|
|
1
|
+
const MAX_MACHINE_TERMINAL_HISTORY_BYTES = 512 * 1024;
|
|
2
|
+
const utf8$2 = new TextEncoder();
|
|
3
|
+
function isTerminalRpcRequest(value) {
|
|
4
|
+
if (!isRecord$5(value) || value.type !== "rpc/request" || !isNonEmptyString$3(value.id)) return false;
|
|
5
|
+
if (value.method === "terminal/open") {
|
|
6
|
+
const params = value.params;
|
|
7
|
+
return isRecord$5(params) && isMachineTerminalId(params.terminalId) && optionalNonEmptyString$2(params.cwd) && optionalPositiveBoundedSafeInteger$1(params.cols, 1e3) && optionalPositiveBoundedSafeInteger$1(params.rows, 500);
|
|
8
|
+
}
|
|
9
|
+
if (value.method === "terminal/write") {
|
|
10
|
+
const params = value.params;
|
|
11
|
+
return isRecord$5(params) && isMachineTerminalId(params.terminalId) && isNonEmptyRawString(params.data) && utf8$2.encode(params.data).byteLength <= 65536;
|
|
12
|
+
}
|
|
13
|
+
if (value.method === "terminal/resize") {
|
|
14
|
+
const params = value.params;
|
|
15
|
+
return isRecord$5(params) && isMachineTerminalId(params.terminalId) && isPositiveBoundedSafeInteger(params.cols, 1e3) && isPositiveBoundedSafeInteger(params.rows, 500);
|
|
16
|
+
}
|
|
17
|
+
if (value.method === "terminal/close") {
|
|
18
|
+
const params = value.params;
|
|
19
|
+
return isRecord$5(params) && isMachineTerminalId(params.terminalId);
|
|
20
|
+
}
|
|
21
|
+
if (value.method === "terminal/clear") {
|
|
22
|
+
const params = value.params;
|
|
23
|
+
return isRecord$5(params) && isMachineTerminalId(params.terminalId);
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
function optionalNonEmptyString$2(value) {
|
|
28
|
+
return value === void 0 || isNonEmptyString$3(value);
|
|
29
|
+
}
|
|
30
|
+
function optionalPositiveBoundedSafeInteger$1(value, max) {
|
|
31
|
+
return value === void 0 || typeof value === "number" && Number.isSafeInteger(value) && value > 0 && value <= max;
|
|
32
|
+
}
|
|
33
|
+
function isPositiveBoundedSafeInteger(value, max) {
|
|
34
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value > 0 && value <= max;
|
|
35
|
+
}
|
|
36
|
+
function isMachineTerminalId(value) {
|
|
37
|
+
return isNonEmptyString$3(value) && value.length <= 128;
|
|
38
|
+
}
|
|
39
|
+
function isNonEmptyString$3(value) {
|
|
40
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
41
|
+
}
|
|
42
|
+
function isNonEmptyRawString(value) {
|
|
43
|
+
return typeof value === "string" && value.length > 0;
|
|
44
|
+
}
|
|
45
|
+
function isRecord$5(value) {
|
|
46
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region ../machine-protocol/src/local-control.ts
|
|
50
|
+
function negotiateLocalControlVersion(client, supervisor) {
|
|
51
|
+
if (!isVersionRange(client) || !isVersionRange(supervisor)) return void 0;
|
|
52
|
+
const version = Math.min(client.maxVersion, supervisor.maxVersion);
|
|
53
|
+
return version >= Math.max(client.minVersion, supervisor.minVersion) ? version : void 0;
|
|
54
|
+
}
|
|
55
|
+
function isLocalControlHello(value) {
|
|
56
|
+
return isRecord$4(value) && value.type === "local-control/hello" && typeof value.secret === "string" && value.secret.length > 0 && isVersionRange(value);
|
|
57
|
+
}
|
|
58
|
+
function isLocalControlCommand(value) {
|
|
59
|
+
if (!isRecord$4(value) || value.type !== "local-control/request" || typeof value.id !== "string" || !value.id) return false;
|
|
60
|
+
if (value.command === "status" || value.command === "ensure-installed" || value.command === "start" || value.command === "restart") return !("capability" in value);
|
|
61
|
+
return (value.command === "retry" || value.command === "force") && isLocalControlCapability(value.capability);
|
|
62
|
+
}
|
|
63
|
+
function isLocalControlCapability(value) {
|
|
64
|
+
return isRecord$4(value) && [
|
|
65
|
+
"token",
|
|
66
|
+
"ownerUserId",
|
|
67
|
+
"deploymentId",
|
|
68
|
+
"machineId",
|
|
69
|
+
"candidateVersion",
|
|
70
|
+
"policyDigest",
|
|
71
|
+
"expiresAt"
|
|
72
|
+
].every((key) => typeof value[key] === "string" && value[key].length > 0) && Number.isSafeInteger(value.lifecycleGeneration) && Number.isSafeInteger(value.connectionGeneration) && Number.isSafeInteger(value.activityGeneration);
|
|
73
|
+
}
|
|
74
|
+
function isVersionRange(value) {
|
|
75
|
+
return isRecord$4(value) && Number.isSafeInteger(value.minVersion) && Number.isSafeInteger(value.maxVersion) && value.minVersion > 0 && value.maxVersion >= value.minVersion;
|
|
76
|
+
}
|
|
77
|
+
function isRecord$4(value) {
|
|
78
|
+
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
79
|
+
}
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region ../machine-protocol/src/mcp.ts
|
|
82
|
+
const utf8$1 = new TextEncoder();
|
|
83
|
+
const MACHINE_MCP_TAG = "mcp:";
|
|
84
|
+
const MACHINE_MCP_MAX_FRAME_BYTES = 6 * 1024 * 1024;
|
|
85
|
+
const MACHINE_MCP_MAX_STDERR_BYTES = 64 * 1024;
|
|
86
|
+
const MACHINE_MCP_MAX_ERROR_MESSAGE_BYTES = 4 * 1024;
|
|
87
|
+
const CONNECTOR_MAX_WEBSOCKET_PAYLOAD_BYTES = 32 * 1024 * 1024;
|
|
88
|
+
var MachineMcpValidationError = class extends Error {
|
|
89
|
+
code;
|
|
90
|
+
constructor(code, message) {
|
|
91
|
+
super(message);
|
|
92
|
+
this.code = code;
|
|
93
|
+
this.name = "MachineMcpValidationError";
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
function utf8Bytes(value) {
|
|
97
|
+
return utf8$1.encode(value).byteLength;
|
|
98
|
+
}
|
|
99
|
+
function serializedBytes(value) {
|
|
100
|
+
return utf8Bytes(JSON.stringify(value));
|
|
101
|
+
}
|
|
102
|
+
function validateMachineMcpLaunchSpec(value) {
|
|
103
|
+
if (!isRecord$3(value)) invalid("Invalid MCP launch specification.");
|
|
104
|
+
const launch = value;
|
|
105
|
+
if (!hasOnlyKeys(launch, [
|
|
106
|
+
"definitionId",
|
|
107
|
+
"configVersion",
|
|
108
|
+
"catalogRevision",
|
|
109
|
+
"catalogFingerprint",
|
|
110
|
+
"command",
|
|
111
|
+
"args",
|
|
112
|
+
"cwdMode",
|
|
113
|
+
"projectRoot"
|
|
114
|
+
]) || !isBoundedString(launch.definitionId, 256, true) || !isPositiveInteger(launch.configVersion) || !isNonNegativeInteger(launch.catalogRevision) || launch.catalogFingerprint !== void 0 && (typeof launch.catalogFingerprint !== "string" || !/^[a-f0-9]{64}$/.test(launch.catalogFingerprint)) || !isBoundedString(launch.command, 4096, true) || !Array.isArray(launch.args) || launch.args.length > 64 || !launch.args.every((arg) => typeof arg === "string" && utf8Bytes(arg) <= 4096) || launch.args.reduce((total, arg) => total + (typeof arg === "string" ? utf8Bytes(arg) : 0), 0) > 65536 || launch.cwdMode !== "project_root" && launch.cwdMode !== "home" || !isAbsoluteHostPath$1(launch.projectRoot)) invalid("Invalid MCP launch specification.");
|
|
115
|
+
if (utf8Bytes(launch.projectRoot) > 32768) throw new MachineMcpValidationError("project_root_too_large", "Project root is too large.");
|
|
116
|
+
if (serializedBytes(value) > 131072) throw new MachineMcpValidationError("launch_request_too_large", "MCP launch request is too large.");
|
|
117
|
+
if (serializedBytes({
|
|
118
|
+
...launch,
|
|
119
|
+
args: launch.args.map((arg) => arg === "{projectRoot}" ? launch.projectRoot : arg),
|
|
120
|
+
cwd: launch.projectRoot
|
|
121
|
+
}) > 131072) throw new MachineMcpValidationError("launch_request_too_large", "Expanded MCP launch request is too large.");
|
|
122
|
+
return value;
|
|
123
|
+
}
|
|
124
|
+
function validateMachineMcpRequest(value) {
|
|
125
|
+
if (!isRecord$3(value) || value.type !== "mcp/request" || !isBoundedString(value.id, 256, true)) invalid("Invalid MCP request.");
|
|
126
|
+
if (!isRecord$3(value.params)) invalid("Invalid MCP request parameters.");
|
|
127
|
+
if (!hasOnlyKeys(value, [
|
|
128
|
+
"type",
|
|
129
|
+
"id",
|
|
130
|
+
"method",
|
|
131
|
+
"params"
|
|
132
|
+
])) invalid("Invalid MCP request.");
|
|
133
|
+
if (value.method === "mcp/probe") {
|
|
134
|
+
if (!hasOnlyKeys(value.params, ["launch", "timeoutMs"])) invalid("Invalid MCP probe parameters.");
|
|
135
|
+
validateMachineMcpLaunchSpec(value.params.launch);
|
|
136
|
+
if (!isBoundedTimeout(value.params.timeoutMs)) invalid("Invalid MCP timeout.");
|
|
137
|
+
} else if (value.method === "mcp/call") {
|
|
138
|
+
if (!hasOnlyKeys(value.params, [
|
|
139
|
+
"launch",
|
|
140
|
+
"toolName",
|
|
141
|
+
"arguments",
|
|
142
|
+
"timeoutMs"
|
|
143
|
+
])) invalid("Invalid MCP call parameters.");
|
|
144
|
+
validateMachineMcpCallRequestSize(value);
|
|
145
|
+
if (!validateMachineMcpLaunchSpec(value.params.launch).catalogFingerprint) invalid("MCP calls require an accepted catalog fingerprint.");
|
|
146
|
+
if (!isBoundedString(value.params.toolName, 256, true)) invalid("Invalid MCP tool name.");
|
|
147
|
+
if (!isRecord$3(value.params.arguments)) invalid("Invalid MCP tool arguments.");
|
|
148
|
+
if (serializedBytes(value.params.arguments) > 262144) throw new MachineMcpValidationError("arguments_too_large", "MCP tool arguments are too large.");
|
|
149
|
+
if (!isBoundedTimeout(value.params.timeoutMs)) invalid("Invalid MCP timeout.");
|
|
150
|
+
} else if (value.method === "mcp/stop") {
|
|
151
|
+
if (!hasOnlyKeys(value.params, [
|
|
152
|
+
"definitionId",
|
|
153
|
+
"configVersion",
|
|
154
|
+
"projectRoot"
|
|
155
|
+
]) || !isBoundedString(value.params.definitionId, 256, true) || value.params.configVersion !== void 0 && !isPositiveInteger(value.params.configVersion) || value.params.projectRoot !== void 0 && (!isAbsoluteHostPath$1(value.params.projectRoot) || utf8Bytes(value.params.projectRoot) > 32768)) invalid("Invalid MCP stop request.");
|
|
156
|
+
} else if (value.method === "mcp/cancel") {
|
|
157
|
+
if (!hasOnlyKeys(value.params, ["requestId"]) || !isBoundedString(value.params.requestId, 256, true)) invalid("Invalid MCP cancel request.");
|
|
158
|
+
} else invalid("Unknown MCP request method.");
|
|
159
|
+
return value;
|
|
160
|
+
}
|
|
161
|
+
function validateMachineMcpCallRequestSize(value) {
|
|
162
|
+
if (serializedBytes(value) > 524288) throw new MachineMcpValidationError("launch_request_too_large", "MCP call request is too large.");
|
|
163
|
+
}
|
|
164
|
+
function encodeMachineMcpFrame(message) {
|
|
165
|
+
const frame = `${MACHINE_MCP_TAG}${JSON.stringify(message)}`;
|
|
166
|
+
if (utf8Bytes(frame) > 6291456) throw new MachineMcpValidationError("frame_too_large", "MCP connector frame is too large.");
|
|
167
|
+
return frame;
|
|
168
|
+
}
|
|
169
|
+
function validateMachineMcpResult(result) {
|
|
170
|
+
if (serializedBytes(result) > 5242880) throw new MachineMcpValidationError("result_too_large", "MCP result is too large.");
|
|
171
|
+
return result;
|
|
172
|
+
}
|
|
173
|
+
function sanitizeMachineMcpCatalog(input) {
|
|
174
|
+
const serverInfo = sanitizeServerInfo(input.serverInfo);
|
|
175
|
+
if (!Array.isArray(input.tools) || input.tools.length > 500) throw new MachineMcpValidationError("catalog_overflow", "MCP catalog has too many tools.");
|
|
176
|
+
let catalogValues = 0;
|
|
177
|
+
const tools = input.tools.map((tool) => {
|
|
178
|
+
if (!isRecord$3(tool) || typeof tool.name !== "string") throw new MachineMcpValidationError("catalog_structure_overflow", "Invalid MCP tool name.");
|
|
179
|
+
const name = tool.name.trim();
|
|
180
|
+
if (!isBoundedString(name, 256, true)) throw new MachineMcpValidationError("catalog_structure_overflow", "Invalid MCP tool name.");
|
|
181
|
+
let toolValues = 0;
|
|
182
|
+
const countValues = (count) => {
|
|
183
|
+
toolValues += count;
|
|
184
|
+
catalogValues += count;
|
|
185
|
+
if (toolValues > 1e4) structureError();
|
|
186
|
+
if (catalogValues > 1e5) structureError();
|
|
187
|
+
};
|
|
188
|
+
const sanitized = {
|
|
189
|
+
name,
|
|
190
|
+
inputSchema: isRecord$3(tool.inputSchema) ? sanitizeObject(tool.inputSchema, countValues) : { type: "object" }
|
|
191
|
+
};
|
|
192
|
+
if (typeof tool.title === "string") {
|
|
193
|
+
if (utf8Bytes(tool.title) > 16384) structureError();
|
|
194
|
+
sanitized.title = tool.title;
|
|
195
|
+
}
|
|
196
|
+
if (typeof tool.description === "string") {
|
|
197
|
+
if (utf8Bytes(tool.description) > 16384) structureError();
|
|
198
|
+
sanitized.description = tool.description.trim();
|
|
199
|
+
}
|
|
200
|
+
if (isRecord$3(tool.outputSchema)) sanitized.outputSchema = sanitizeObject(tool.outputSchema, countValues);
|
|
201
|
+
if (isRecord$3(tool.annotations)) sanitized.annotations = sanitizeObject(tool.annotations, countValues);
|
|
202
|
+
if (catalogValues > 1e5) structureError();
|
|
203
|
+
if (serializedBytes(sanitized) > 262144) throw new MachineMcpValidationError("catalog_overflow", "MCP tool is too large.");
|
|
204
|
+
return sanitized;
|
|
205
|
+
}).sort((a, b) => compareCodeUnits(a.name, b.name));
|
|
206
|
+
if (new Set(tools.map((tool) => tool.name)).size !== tools.length) throw new MachineMcpValidationError("catalog_structure_overflow", "MCP tool names must be unique.");
|
|
207
|
+
const catalog = {
|
|
208
|
+
serverInfo,
|
|
209
|
+
tools
|
|
210
|
+
};
|
|
211
|
+
if (serializedBytes(catalog) > 1048576) throw new MachineMcpValidationError("catalog_overflow", "MCP catalog is too large.");
|
|
212
|
+
return catalog;
|
|
213
|
+
}
|
|
214
|
+
function sanitizeAndCanonicalizeMachineMcpCatalog(input) {
|
|
215
|
+
const catalog = sanitizeMachineMcpCatalog(input);
|
|
216
|
+
return {
|
|
217
|
+
catalog,
|
|
218
|
+
canonicalJson: canonicalizeSanitizedMachineMcpCatalog(catalog)
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
function canonicalizeSanitizedMachineMcpCatalog(catalog) {
|
|
222
|
+
return canonicalJson(catalog.tools);
|
|
223
|
+
}
|
|
224
|
+
function substituteMachineMcpLaunch(launch, platform = processPlatform(), homeRoot = launch.projectRoot) {
|
|
225
|
+
const root = platform === "windows" ? launch.projectRoot.replaceAll("/", "\\") : launch.projectRoot.replaceAll("\\", "/");
|
|
226
|
+
const command = launch.command;
|
|
227
|
+
const args = launch.args.map((argument) => argument === "{projectRoot}" ? root : argument);
|
|
228
|
+
const cwd = launch.cwdMode === "project_root" ? root : homeRoot;
|
|
229
|
+
const resolved = {
|
|
230
|
+
command,
|
|
231
|
+
args,
|
|
232
|
+
cwd
|
|
233
|
+
};
|
|
234
|
+
if (serializedBytes({
|
|
235
|
+
...launch,
|
|
236
|
+
command,
|
|
237
|
+
args,
|
|
238
|
+
...cwd ? { cwd } : {}
|
|
239
|
+
}) > 131072) throw new MachineMcpValidationError("launch_request_too_large", "Resolved MCP launch request is too large.");
|
|
240
|
+
return resolved;
|
|
241
|
+
}
|
|
242
|
+
function sanitizeServerInfo(value) {
|
|
243
|
+
if (!isRecord$3(value) || !isBoundedString(value.name, 256, true)) structureError("Invalid MCP server info.");
|
|
244
|
+
if (value.version !== void 0 && !isBoundedString(value.version, 256, true)) structureError("Invalid MCP server version.");
|
|
245
|
+
return {
|
|
246
|
+
name: value.name,
|
|
247
|
+
...value.version ? { version: value.version } : {}
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
function sanitizeObject(value, addToCatalog) {
|
|
251
|
+
if (!isRecord$3(value)) structureError();
|
|
252
|
+
const output = {};
|
|
253
|
+
const stack = [{
|
|
254
|
+
source: value,
|
|
255
|
+
target: output,
|
|
256
|
+
depth: 1
|
|
257
|
+
}];
|
|
258
|
+
let values = 0;
|
|
259
|
+
while (stack.length > 0) {
|
|
260
|
+
const item = stack.pop();
|
|
261
|
+
if (item.depth > 32) structureError();
|
|
262
|
+
const entries = Array.isArray(item.source) ? item.source.map((entry, index) => [String(index), entry]) : Object.entries(item.source).sort(([a], [b]) => compareCodeUnits(a, b));
|
|
263
|
+
if (Array.isArray(item.source) && entries.length > 4096) structureError();
|
|
264
|
+
if (!Array.isArray(item.source) && entries.length > 1024) structureError();
|
|
265
|
+
for (const [key, child] of entries) {
|
|
266
|
+
values += 1;
|
|
267
|
+
if (values > 1e4) structureError();
|
|
268
|
+
if (utf8Bytes(key) > 65536) structureError();
|
|
269
|
+
let next;
|
|
270
|
+
if (typeof child === "string") {
|
|
271
|
+
if (utf8Bytes(child) > 65536) structureError();
|
|
272
|
+
next = child;
|
|
273
|
+
} else if (child === null || typeof child === "boolean" || typeof child === "number") {
|
|
274
|
+
if (typeof child === "number" && !Number.isFinite(child)) structureError();
|
|
275
|
+
next = child;
|
|
276
|
+
} else if (Array.isArray(child)) {
|
|
277
|
+
next = [];
|
|
278
|
+
stack.push({
|
|
279
|
+
source: child,
|
|
280
|
+
target: next,
|
|
281
|
+
depth: item.depth + 1
|
|
282
|
+
});
|
|
283
|
+
} else if (isRecord$3(child)) {
|
|
284
|
+
next = {};
|
|
285
|
+
stack.push({
|
|
286
|
+
source: child,
|
|
287
|
+
target: next,
|
|
288
|
+
depth: item.depth + 1
|
|
289
|
+
});
|
|
290
|
+
} else structureError();
|
|
291
|
+
if (Array.isArray(item.target)) item.target.push(next);
|
|
292
|
+
else Object.defineProperty(item.target, key, {
|
|
293
|
+
configurable: true,
|
|
294
|
+
enumerable: true,
|
|
295
|
+
value: next,
|
|
296
|
+
writable: true
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
addToCatalog(values);
|
|
301
|
+
return output;
|
|
302
|
+
}
|
|
303
|
+
function canonicalJson(value) {
|
|
304
|
+
const output = [];
|
|
305
|
+
const stack = [{
|
|
306
|
+
kind: "value",
|
|
307
|
+
value
|
|
308
|
+
}];
|
|
309
|
+
while (stack.length > 0) {
|
|
310
|
+
const task = stack.pop();
|
|
311
|
+
if (task.kind === "text") {
|
|
312
|
+
output.push(task.value);
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
const item = task.value;
|
|
316
|
+
if (Array.isArray(item)) {
|
|
317
|
+
stack.push({
|
|
318
|
+
kind: "text",
|
|
319
|
+
value: "]"
|
|
320
|
+
});
|
|
321
|
+
for (let index = item.length - 1; index >= 0; index -= 1) {
|
|
322
|
+
stack.push({
|
|
323
|
+
kind: "value",
|
|
324
|
+
value: item[index]
|
|
325
|
+
});
|
|
326
|
+
if (index > 0) stack.push({
|
|
327
|
+
kind: "text",
|
|
328
|
+
value: ","
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
stack.push({
|
|
332
|
+
kind: "text",
|
|
333
|
+
value: "["
|
|
334
|
+
});
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
if (isRecord$3(item)) {
|
|
338
|
+
const keys = Object.keys(item).sort(compareCodeUnits);
|
|
339
|
+
stack.push({
|
|
340
|
+
kind: "text",
|
|
341
|
+
value: "}"
|
|
342
|
+
});
|
|
343
|
+
for (let index = keys.length - 1; index >= 0; index -= 1) {
|
|
344
|
+
const key = keys[index];
|
|
345
|
+
stack.push({
|
|
346
|
+
kind: "value",
|
|
347
|
+
value: item[key]
|
|
348
|
+
});
|
|
349
|
+
stack.push({
|
|
350
|
+
kind: "text",
|
|
351
|
+
value: `${JSON.stringify(key)}:`
|
|
352
|
+
});
|
|
353
|
+
if (index > 0) stack.push({
|
|
354
|
+
kind: "text",
|
|
355
|
+
value: ","
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
stack.push({
|
|
359
|
+
kind: "text",
|
|
360
|
+
value: "{"
|
|
361
|
+
});
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
const encoded = JSON.stringify(item);
|
|
365
|
+
if (encoded === void 0) structureError();
|
|
366
|
+
output.push(encoded);
|
|
367
|
+
}
|
|
368
|
+
return output.join("");
|
|
369
|
+
}
|
|
370
|
+
function compareCodeUnits(left, right) {
|
|
371
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
372
|
+
}
|
|
373
|
+
function isBoundedString(value, maxBytes, nonBlank) {
|
|
374
|
+
return typeof value === "string" && (!nonBlank || value.trim().length > 0) && utf8Bytes(value) <= maxBytes;
|
|
375
|
+
}
|
|
376
|
+
function isAbsoluteHostPath$1(value) {
|
|
377
|
+
return isNonEmptyString$2(value) && !value.includes("\0") && (value.startsWith("/") || value.startsWith("\\\\") || /^[A-Za-z]:[\\/]/.test(value));
|
|
378
|
+
}
|
|
379
|
+
function isNonEmptyString$2(value) {
|
|
380
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
381
|
+
}
|
|
382
|
+
function isRecord$3(value) {
|
|
383
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
384
|
+
}
|
|
385
|
+
function isPositiveInteger(value) {
|
|
386
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
387
|
+
}
|
|
388
|
+
function isNonNegativeInteger(value) {
|
|
389
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
390
|
+
}
|
|
391
|
+
function isBoundedTimeout(value) {
|
|
392
|
+
return isPositiveInteger(value) && value <= 12e4;
|
|
393
|
+
}
|
|
394
|
+
function hasOnlyKeys(value, allowed) {
|
|
395
|
+
return Object.keys(value).every((key) => allowed.includes(key));
|
|
396
|
+
}
|
|
397
|
+
function invalid(message) {
|
|
398
|
+
throw new MachineMcpValidationError("invalid_request", message);
|
|
399
|
+
}
|
|
400
|
+
function structureError(message = "MCP catalog structure is too large or invalid.") {
|
|
401
|
+
throw new MachineMcpValidationError("catalog_structure_overflow", message);
|
|
402
|
+
}
|
|
403
|
+
function processPlatform() {
|
|
404
|
+
return typeof process !== "undefined" && process.platform === "win32" ? "windows" : "posix";
|
|
405
|
+
}
|
|
406
|
+
//#endregion
|
|
407
|
+
//#region ../machine-protocol/src/deployment.ts
|
|
408
|
+
function normalizeDeploymentPolicy(input, options = {}) {
|
|
409
|
+
if (!isDeploymentUuid(input.deploymentId)) throw new Error("DEPLOYMENT_ID must be a UUID.");
|
|
410
|
+
const canonicalOrigin = normalizeDeploymentOrigin(input.canonicalOrigin, options);
|
|
411
|
+
const aliases = [...new Set(input.aliases.map((origin) => normalizeDeploymentOrigin(origin, options)))].filter((origin) => origin !== canonicalOrigin).sort();
|
|
412
|
+
if (input.connectorChannel !== "latest" && input.connectorChannel !== "next") throw new Error("CONNECTOR_CHANNEL must be latest or next.");
|
|
413
|
+
if (!isAllowedConnectorCaretRange(input.connectorVersionRange)) throw new Error("CONNECTOR_VERSION_RANGE must be a non-prerelease caret range and cannot use ^0.0.Z.");
|
|
414
|
+
return {
|
|
415
|
+
deploymentId: input.deploymentId.toLowerCase(),
|
|
416
|
+
canonicalOrigin,
|
|
417
|
+
aliases,
|
|
418
|
+
connectorChannel: input.connectorChannel,
|
|
419
|
+
connectorVersionRange: input.connectorVersionRange
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
function normalizeDeploymentOrigin(value, options = {}) {
|
|
423
|
+
const url = new URL(value);
|
|
424
|
+
const httpAllowed = url.protocol === "http:" && (options.allowHttp === true || options.allowHttp === "loopback" && isLoopbackHost(url.hostname));
|
|
425
|
+
if (url.protocol !== "https:" && !httpAllowed) throw new Error("Connector origins must use HTTPS outside development and test.");
|
|
426
|
+
if (url.username || url.password || url.search || url.hash || url.pathname && url.pathname !== "/") throw new Error("Connector origins must not include credentials, paths, queries, or fragments.");
|
|
427
|
+
return url.origin.toLowerCase();
|
|
428
|
+
}
|
|
429
|
+
function canonicalDeploymentPolicyJson(policy) {
|
|
430
|
+
return JSON.stringify({
|
|
431
|
+
aliases: [...policy.aliases].sort(),
|
|
432
|
+
canonicalOrigin: policy.canonicalOrigin,
|
|
433
|
+
connectorChannel: policy.connectorChannel,
|
|
434
|
+
connectorVersionRange: policy.connectorVersionRange,
|
|
435
|
+
deploymentId: policy.deploymentId
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
function isAllowedConnectorCaretRange(value) {
|
|
439
|
+
const component = "(?:0|[1-9]\\d*)";
|
|
440
|
+
const match = new RegExp(`^\\^(${component})\\.(${component})\\.(${component})$`).exec(value);
|
|
441
|
+
return Boolean(match && !(match[1] === "0" && match[2] === "0"));
|
|
442
|
+
}
|
|
443
|
+
function isDeploymentUuid(value) {
|
|
444
|
+
return /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value);
|
|
445
|
+
}
|
|
446
|
+
function isConnectorReady(value) {
|
|
447
|
+
return isRecord$2(value) && value.type === "connector/ready" && value.version === 1 && isNonEmptyString$1(value.deploymentId) && isNonEmptyString$1(value.machineId) && Number.isSafeInteger(value.connectionGeneration) && value.connectionGeneration > 0 && optionalNonEmptyString$1(value.candidateAttemptId) && optionalNonEmptyString$1(value.activationReceipt) && (value.candidateAttemptId === void 0 && value.activationReceipt === void 0 || isNonEmptyString$1(value.candidateAttemptId) && isNonEmptyString$1(value.activationReceipt));
|
|
448
|
+
}
|
|
449
|
+
function isConnectorActivated(value) {
|
|
450
|
+
return isRecord$2(value) && value.type === "connector/activated" && isNonEmptyString$1(value.candidateAttemptId) && isNonEmptyString$1(value.activationReceipt) && Number.isSafeInteger(value.statusRevision) && value.statusRevision > 0;
|
|
451
|
+
}
|
|
452
|
+
function optionalNonEmptyString$1(value) {
|
|
453
|
+
return value === void 0 || isNonEmptyString$1(value);
|
|
454
|
+
}
|
|
455
|
+
function isNonEmptyString$1(value) {
|
|
456
|
+
return typeof value === "string" && value.length > 0;
|
|
457
|
+
}
|
|
458
|
+
function isLoopbackHost(hostname) {
|
|
459
|
+
return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "[::1]";
|
|
460
|
+
}
|
|
461
|
+
function isRecord$2(value) {
|
|
462
|
+
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
463
|
+
}
|
|
464
|
+
//#endregion
|
|
465
|
+
//#region ../machine-protocol/src/connector-release.ts
|
|
466
|
+
function canonicalSignedConnectorReleaseTuple(tuple) {
|
|
467
|
+
return JSON.stringify({
|
|
468
|
+
arch: tuple.arch,
|
|
469
|
+
integrity: tuple.integrity,
|
|
470
|
+
manifestDigest: tuple.manifestDigest,
|
|
471
|
+
packageName: tuple.packageName,
|
|
472
|
+
platform: tuple.platform,
|
|
473
|
+
releaseId: tuple.releaseId,
|
|
474
|
+
runtimeVersion: tuple.runtimeVersion,
|
|
475
|
+
tarballUrl: tuple.tarballUrl
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
//#endregion
|
|
479
|
+
//#region ../machine-protocol/src/rpc-activity.ts
|
|
480
|
+
function classifyServerRpcActivity(request) {
|
|
481
|
+
switch (request.method) {
|
|
482
|
+
case "shell/exec":
|
|
483
|
+
case "shell/job_start":
|
|
484
|
+
case "file/read":
|
|
485
|
+
case "file/read_text":
|
|
486
|
+
case "file/read_patch_source":
|
|
487
|
+
case "file/write":
|
|
488
|
+
case "file/delete":
|
|
489
|
+
case "file/move":
|
|
490
|
+
case "file/search_entries":
|
|
491
|
+
case "terminal/open":
|
|
492
|
+
case "terminal/write":
|
|
493
|
+
case "terminal/resize": return "work";
|
|
494
|
+
case "shell/close":
|
|
495
|
+
case "shell/job_get":
|
|
496
|
+
case "shell/job_kill":
|
|
497
|
+
case "terminal/clear":
|
|
498
|
+
case "terminal/close": return "control";
|
|
499
|
+
case "connector/update_preflight":
|
|
500
|
+
case "connector/update_retry":
|
|
501
|
+
case "connector/update_force": return "update_control";
|
|
502
|
+
default: return assertNever$1(request);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
function classifyMachineMcpActivity(request) {
|
|
506
|
+
switch (request.method) {
|
|
507
|
+
case "mcp/probe":
|
|
508
|
+
case "mcp/call": return "work";
|
|
509
|
+
case "mcp/stop":
|
|
510
|
+
case "mcp/cancel": return "control";
|
|
511
|
+
default: return assertNever$1(request);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
function assertNever$1(value) {
|
|
515
|
+
throw new Error(`Unhandled connector RPC: ${JSON.stringify(value)}`);
|
|
516
|
+
}
|
|
517
|
+
//#endregion
|
|
518
|
+
//#region ../machine-protocol/src/update.ts
|
|
519
|
+
const connectorUpdateStates = [
|
|
520
|
+
"unreported",
|
|
521
|
+
"unchecked",
|
|
522
|
+
"up_to_date",
|
|
523
|
+
"available",
|
|
524
|
+
"waiting_for_idle",
|
|
525
|
+
"updating",
|
|
526
|
+
"blocked",
|
|
527
|
+
"error"
|
|
528
|
+
];
|
|
529
|
+
const connectorUpdateErrorCodes = [
|
|
530
|
+
"download_failed",
|
|
531
|
+
"integrity_failed",
|
|
532
|
+
"manifest_invalid",
|
|
533
|
+
"incompatible",
|
|
534
|
+
"candidate_start_failed",
|
|
535
|
+
"candidate_exited",
|
|
536
|
+
"readiness_timeout",
|
|
537
|
+
"attempt_timed_out",
|
|
538
|
+
"rollback_failed",
|
|
539
|
+
"active_work_termination_failed"
|
|
540
|
+
];
|
|
541
|
+
const retryableConnectorUpdateErrors = [
|
|
542
|
+
"download_failed",
|
|
543
|
+
"integrity_failed",
|
|
544
|
+
"manifest_invalid",
|
|
545
|
+
"candidate_start_failed",
|
|
546
|
+
"candidate_exited",
|
|
547
|
+
"readiness_timeout"
|
|
548
|
+
];
|
|
549
|
+
function canRetryConnectorUpdate(status) {
|
|
550
|
+
return status.state === "blocked" && status.errorCode !== null && retryableConnectorUpdateErrors.includes(status.errorCode);
|
|
551
|
+
}
|
|
552
|
+
function canForceConnectorUpdate(status) {
|
|
553
|
+
return status.state === "available" || status.state === "waiting_for_idle" || status.state === "error" && status.errorCode === "active_work_termination_failed";
|
|
554
|
+
}
|
|
555
|
+
function isConnectorUpdateAccepted(value) {
|
|
556
|
+
return isRecord$1(value) && value.type === "connector/update-accepted" && typeof value.reportSequence === "number" && Number.isSafeInteger(value.reportSequence) && value.reportSequence > 0 && typeof value.statusRevision === "number" && Number.isSafeInteger(value.statusRevision) && value.statusRevision > 0;
|
|
557
|
+
}
|
|
558
|
+
function isConnectorUpdateResponse(value) {
|
|
559
|
+
if (isConnectorUpdateAccepted(value)) return true;
|
|
560
|
+
if (!isRecord$1(value) || value.type !== "connector/update-reconcile" || !Number.isSafeInteger(value.reportSequence) || value.reportSequence < 1 || !Number.isSafeInteger(value.serverReportSequence) || value.serverReportSequence < 0 || !Number.isSafeInteger(value.statusRevision) || value.statusRevision < 1 || value.attemptId !== null && !nonEmptyString(value.attemptId)) return false;
|
|
561
|
+
const installedVersion = nullableString(value.installedVersion);
|
|
562
|
+
const availableVersion = nullableString(value.availableVersion);
|
|
563
|
+
const channel = nullableChannel(value.channel);
|
|
564
|
+
return installedVersion !== void 0 && availableVersion !== void 0 && channel !== void 0 && connectorUpdateStates.includes(value.state) && (value.errorCode === null || connectorUpdateErrorCodes.includes(value.errorCode)) && validateConnectorUpdateStatus({
|
|
565
|
+
installedVersion,
|
|
566
|
+
availableVersion,
|
|
567
|
+
channel,
|
|
568
|
+
state: value.state,
|
|
569
|
+
errorCode: value.errorCode
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
function isConnectorForceConsumeResult(value) {
|
|
573
|
+
return isRecord$1(value) && value.type === "connector/force-consume-result" && nonEmptyString(value.requestId) && typeof value.accepted === "boolean";
|
|
574
|
+
}
|
|
575
|
+
function validateConnectorUpdateStatus(input) {
|
|
576
|
+
const { installedVersion, availableVersion, channel, state, errorCode } = input;
|
|
577
|
+
const installed = isRuntimeVersion(installedVersion);
|
|
578
|
+
const available = isRuntimeVersion(availableVersion);
|
|
579
|
+
const noError = errorCode === null;
|
|
580
|
+
const candidateError = errorCode === "download_failed" || errorCode === "integrity_failed" || errorCode === "manifest_invalid" || errorCode === "candidate_start_failed" || errorCode === "candidate_exited" || errorCode === "readiness_timeout";
|
|
581
|
+
if (channel !== null && channel !== "latest" && channel !== "next") return false;
|
|
582
|
+
switch (state) {
|
|
583
|
+
case "unreported": return installedVersion === null && availableVersion === null && channel === null && noError;
|
|
584
|
+
case "unchecked":
|
|
585
|
+
case "up_to_date": return installed && availableVersion === null && channel !== null && noError;
|
|
586
|
+
case "available":
|
|
587
|
+
case "waiting_for_idle":
|
|
588
|
+
case "updating": return installed && available && installedVersion !== availableVersion && channel !== null && noError;
|
|
589
|
+
case "blocked": return installed && available && installedVersion !== availableVersion && channel !== null && candidateError;
|
|
590
|
+
case "error":
|
|
591
|
+
if (errorCode === "incompatible") return availableVersion === null && channel !== null;
|
|
592
|
+
if (errorCode === "active_work_termination_failed") return installed && available && installedVersion !== availableVersion && channel !== null;
|
|
593
|
+
if (errorCode === "attempt_timed_out") return channel !== null;
|
|
594
|
+
if (errorCode === "rollback_failed") return available && channel !== null;
|
|
595
|
+
return false;
|
|
596
|
+
default: return assertNever(state);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
function nullableString(value) {
|
|
600
|
+
return value === null || typeof value === "string" ? value : void 0;
|
|
601
|
+
}
|
|
602
|
+
function nullableChannel(value) {
|
|
603
|
+
return value === null || value === "latest" || value === "next" ? value : void 0;
|
|
604
|
+
}
|
|
605
|
+
function isRuntimeVersion(value) {
|
|
606
|
+
return typeof value === "string" && /^\d+\.\d+\.\d+$/.test(value);
|
|
607
|
+
}
|
|
608
|
+
function nonEmptyString(value) {
|
|
609
|
+
return typeof value === "string" && value.length > 0;
|
|
610
|
+
}
|
|
611
|
+
function isRecord$1(value) {
|
|
612
|
+
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
613
|
+
}
|
|
614
|
+
function assertNever(value) {
|
|
615
|
+
throw new Error(`Unhandled connector update state: ${String(value)}`);
|
|
616
|
+
}
|
|
617
|
+
//#endregion
|
|
618
|
+
//#region ../machine-protocol/src/index.ts
|
|
619
|
+
const DEFAULT_MACHINE_EXEC_TIMEOUT_MS = 6e4;
|
|
620
|
+
const MAX_MACHINE_EXEC_TIMEOUT_MS = 12e4;
|
|
621
|
+
const DEFAULT_MACHINE_EXEC_OUTPUT_BYTES = 512e3;
|
|
622
|
+
const MAX_MACHINE_EXEC_OUTPUT_BYTES = 1048576;
|
|
623
|
+
const DEFAULT_MACHINE_FILE_READ_BYTES = 20 * 1024 * 1024;
|
|
624
|
+
const MAX_MACHINE_FILE_READ_BYTES = 20 * 1024 * 1024;
|
|
625
|
+
const DEFAULT_TEXT_FILE_READ_BYTES = 50 * 1024;
|
|
626
|
+
const MAX_TEXT_FILE_READ_BYTES = 50 * 1024;
|
|
627
|
+
const DEFAULT_TEXT_FILE_READ_LINES = 2e3;
|
|
628
|
+
const MAX_TEXT_FILE_READ_LINES = 2e3;
|
|
629
|
+
const MAX_MACHINE_JOB_OUTPUT_BYTES = 512 * 1024;
|
|
630
|
+
const MAX_PATCH_SOURCE_FILE_BYTES = 5 * 1024 * 1024;
|
|
631
|
+
const MAX_TEXT_FILE_WRITE_BYTES = 5 * 1024 * 1024;
|
|
632
|
+
const MAX_MACHINE_FILE_SEARCH_PATH_LENGTH = 4096;
|
|
633
|
+
const utf8 = new TextEncoder();
|
|
634
|
+
function isServerRpcRequest(value) {
|
|
635
|
+
if (!isRecord(value)) return false;
|
|
636
|
+
if (value.type !== "rpc/request" || !isNonEmptyString(value.id)) return false;
|
|
637
|
+
if (isTerminalRpcRequest(value)) return true;
|
|
638
|
+
if (value.method === "shell/exec") {
|
|
639
|
+
const params = value.params;
|
|
640
|
+
return isRecord(params) && isNonEmptyString(params.shellId) && isNonEmptyString(params.command) && optionalString(params.cwd) && optionalNumber(params.timeoutMs) && optionalNumber(params.maxOutputBytes);
|
|
641
|
+
}
|
|
642
|
+
if (value.method === "shell/close") {
|
|
643
|
+
const params = value.params;
|
|
644
|
+
return isRecord(params) && isNonEmptyString(params.shellId);
|
|
645
|
+
}
|
|
646
|
+
if (value.method === "shell/job_start") {
|
|
647
|
+
const params = value.params;
|
|
648
|
+
return isRecord(params) && isNonEmptyString(params.command) && optionalNonEmptyString(params.cwd);
|
|
649
|
+
}
|
|
650
|
+
if (value.method === "shell/job_get") {
|
|
651
|
+
const params = value.params;
|
|
652
|
+
return isRecord(params) && isBoundedNonEmptyString(params.jobId, 128) && optionalNonNegativeSafeInteger(params.cursor);
|
|
653
|
+
}
|
|
654
|
+
if (value.method === "shell/job_kill") {
|
|
655
|
+
const params = value.params;
|
|
656
|
+
return isRecord(params) && isBoundedNonEmptyString(params.jobId, 128);
|
|
657
|
+
}
|
|
658
|
+
if (value.method === "file/read") {
|
|
659
|
+
const params = value.params;
|
|
660
|
+
return isRecord(params) && isNonEmptyString(params.path) && optionalPositiveBoundedSafeInteger(params.maxBytes, 20971520);
|
|
661
|
+
}
|
|
662
|
+
if (value.method === "file/read_text") {
|
|
663
|
+
const params = value.params;
|
|
664
|
+
return isRecord(params) && isNonEmptyString(params.path) && (params.mode === void 0 || params.mode === "offset" || params.mode === "tail") && !(params.mode === "tail" && params.offset !== void 0) && optionalPositiveSafeInteger(params.offset) && optionalPositiveBoundedSafeInteger(params.limit, 2e3) && optionalPositiveBoundedSafeInteger(params.maxBytes, 51200);
|
|
665
|
+
}
|
|
666
|
+
if (value.method === "file/read_patch_source") {
|
|
667
|
+
const params = value.params;
|
|
668
|
+
return isRecord(params) && isNonEmptyString(params.path) && optionalPositiveBoundedSafeInteger(params.maxBytes, 5242880);
|
|
669
|
+
}
|
|
670
|
+
if (value.method === "file/write") {
|
|
671
|
+
const params = value.params;
|
|
672
|
+
return isRecord(params) && isNonEmptyString(params.path) && typeof params.content === "string" && utf8.encode(params.content).byteLength <= 5242880;
|
|
673
|
+
}
|
|
674
|
+
if (value.method === "file/delete") {
|
|
675
|
+
const params = value.params;
|
|
676
|
+
return isRecord(params) && isNonEmptyString(params.path);
|
|
677
|
+
}
|
|
678
|
+
if (value.method === "file/move") {
|
|
679
|
+
const params = value.params;
|
|
680
|
+
return isRecord(params) && isNonEmptyString(params.sourcePath) && isNonEmptyString(params.targetPath);
|
|
681
|
+
}
|
|
682
|
+
if (value.method === "file/search_entries") {
|
|
683
|
+
const params = value.params;
|
|
684
|
+
return isRecord(params) && isAbsoluteHostPath(params.rootPath) && typeof params.query === "string" && optionalPositiveBoundedSafeInteger(params.limit, 100);
|
|
685
|
+
}
|
|
686
|
+
if (value.method === "connector/update_preflight" || value.method === "connector/update_retry") {
|
|
687
|
+
const params = value.params;
|
|
688
|
+
return isRecord(params) && /^\d+\.\d+\.\d+$/.test(String(params.candidateVersion)) && Number.isSafeInteger(params.statusRevision) && params.statusRevision >= 0;
|
|
689
|
+
}
|
|
690
|
+
if (value.method === "connector/update_force") return isRecord(value.params) && isLocalControlCapability(value.params.capability);
|
|
691
|
+
return false;
|
|
692
|
+
}
|
|
693
|
+
function optionalString(value) {
|
|
694
|
+
return value === void 0 || typeof value === "string";
|
|
695
|
+
}
|
|
696
|
+
function optionalNonEmptyString(value) {
|
|
697
|
+
return value === void 0 || isNonEmptyString(value);
|
|
698
|
+
}
|
|
699
|
+
function isBoundedNonEmptyString(value, maxLength) {
|
|
700
|
+
return isNonEmptyString(value) && value.length <= maxLength;
|
|
701
|
+
}
|
|
702
|
+
function optionalNumber(value) {
|
|
703
|
+
return value === void 0 || typeof value === "number" && Number.isFinite(value);
|
|
704
|
+
}
|
|
705
|
+
function optionalPositiveBoundedSafeInteger(value, max) {
|
|
706
|
+
return value === void 0 || typeof value === "number" && Number.isSafeInteger(value) && value > 0 && value <= max;
|
|
707
|
+
}
|
|
708
|
+
function optionalPositiveSafeInteger(value) {
|
|
709
|
+
return value === void 0 || isPositiveSafeInteger(value);
|
|
710
|
+
}
|
|
711
|
+
function optionalNonNegativeSafeInteger(value) {
|
|
712
|
+
return value === void 0 || isNonNegativeSafeInteger(value);
|
|
713
|
+
}
|
|
714
|
+
function isPositiveSafeInteger(value) {
|
|
715
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
716
|
+
}
|
|
717
|
+
function isNonNegativeSafeInteger(value) {
|
|
718
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
719
|
+
}
|
|
720
|
+
function isAbsoluteHostPath(value) {
|
|
721
|
+
if (!isNonEmptyString(value) || value.includes("\0")) return false;
|
|
722
|
+
return value.startsWith("/") || value.startsWith("\\\\") || /^[A-Za-z]:[\\/]/.test(value);
|
|
723
|
+
}
|
|
724
|
+
function isNonEmptyString(value) {
|
|
725
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
726
|
+
}
|
|
727
|
+
function isRecord(value) {
|
|
728
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
729
|
+
}
|
|
730
|
+
//#endregion
|
|
731
|
+
export { CONNECTOR_MAX_WEBSOCKET_PAYLOAD_BYTES as A, validateMachineMcpLaunchSpec as B, canonicalSignedConnectorReleaseTuple as C, isDeploymentUuid as D, isConnectorReady as E, MachineMcpValidationError as F, negotiateLocalControlVersion as G, validateMachineMcpResult as H, encodeMachineMcpFrame as I, MAX_MACHINE_TERMINAL_HISTORY_BYTES as K, sanitizeAndCanonicalizeMachineMcpCatalog as L, MACHINE_MCP_MAX_FRAME_BYTES as M, MACHINE_MCP_MAX_STDERR_BYTES as N, normalizeDeploymentOrigin as O, MACHINE_MCP_TAG as P, substituteMachineMcpLaunch as R, classifyServerRpcActivity as S, isConnectorActivated as T, isLocalControlCommand as U, validateMachineMcpRequest as V, isLocalControlHello as W, canRetryConnectorUpdate as _, DEFAULT_TEXT_FILE_READ_LINES as a, validateConnectorUpdateStatus as b, MAX_MACHINE_FILE_READ_BYTES as c, MAX_PATCH_SOURCE_FILE_BYTES as d, MAX_TEXT_FILE_READ_BYTES as f, canForceConnectorUpdate as g, isServerRpcRequest as h, DEFAULT_TEXT_FILE_READ_BYTES as i, MACHINE_MCP_MAX_ERROR_MESSAGE_BYTES as j, normalizeDeploymentPolicy as k, MAX_MACHINE_FILE_SEARCH_PATH_LENGTH as l, MAX_TEXT_FILE_WRITE_BYTES as m, DEFAULT_MACHINE_EXEC_TIMEOUT_MS as n, MAX_MACHINE_EXEC_OUTPUT_BYTES as o, MAX_TEXT_FILE_READ_LINES as p, DEFAULT_MACHINE_FILE_READ_BYTES as r, MAX_MACHINE_EXEC_TIMEOUT_MS as s, DEFAULT_MACHINE_EXEC_OUTPUT_BYTES as t, MAX_MACHINE_JOB_OUTPUT_BYTES as u, isConnectorForceConsumeResult as v, canonicalDeploymentPolicyJson as w, classifyMachineMcpActivity as x, isConnectorUpdateResponse as y, utf8Bytes as z };
|