local-commander-agent 0.3.2 → 0.3.3
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 +17 -1
- package/bin/localcommander.mjs +33 -0
- package/package.json +2 -2
- package/runtime/JobHost.exe +0 -0
- package/runtime/LocalCommanderAgent.exe +0 -0
- package/runtime/OwnerBridge.exe +0 -0
- package/runtime/agent.mjs +191 -189
package/README.md
CHANGED
|
@@ -24,6 +24,22 @@ npx local-commander-agent@latest approve-workspace
|
|
|
24
24
|
npx local-commander-agent@latest uninstall
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
+
## Workspace permissions
|
|
28
|
+
|
|
29
|
+
A newly approved workspace is read-only. Only the person at this PC can widen it; the AI client, MCP calls and the cloud cannot.
|
|
30
|
+
|
|
31
|
+
```powershell
|
|
32
|
+
npx local-commander-agent@latest workspaces # list workspaceGrantId and permissions
|
|
33
|
+
npx local-commander-agent@latest allow-write <workspaceGrantId>
|
|
34
|
+
npx local-commander-agent@latest allow-command <workspaceGrantId> node "C:\Program Files\nodejs\node.exe"
|
|
35
|
+
npx local-commander-agent@latest allow-localhost <workspaceGrantId> 3000
|
|
36
|
+
npx local-commander-agent@latest deny-write <workspaceGrantId>
|
|
37
|
+
npx local-commander-agent@latest deny-command <workspaceGrantId> node
|
|
38
|
+
npx local-commander-agent@latest deny-localhost <workspaceGrantId> 3000
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
`allow-command` takes the command name the AI will use and the absolute path of that executable. A running agent restarts automatically to apply the change.
|
|
42
|
+
|
|
27
43
|
To also remove the protected Local Commander enrollment/state during uninstall:
|
|
28
44
|
|
|
29
45
|
```powershell
|
|
@@ -34,7 +50,7 @@ Uninstall never removes user project files.
|
|
|
34
50
|
|
|
35
51
|
## Control plane
|
|
36
52
|
|
|
37
|
-
The package defaults to `https://localcmd.
|
|
53
|
+
The package defaults to `https://localcmd.app`. A staging or self-hosted control plane can be selected only at first pairing with:
|
|
38
54
|
|
|
39
55
|
```powershell
|
|
40
56
|
$env:LC_CONTROL_PLANE_ORIGIN="https://your-control-plane.example"
|
package/bin/localcommander.mjs
CHANGED
|
@@ -236,6 +236,26 @@ async function approveWorkspace(runtimeDir) {
|
|
|
236
236
|
if (result.status !== 0) fail(result.stderr.trim() || "WORKSPACE_APPROVAL_FAILED");
|
|
237
237
|
process.stdout.write(result.stdout || "Workspace selection finished.\n");
|
|
238
238
|
}
|
|
239
|
+
// Owner-only local permission surface. These run the installed runtime's own
|
|
240
|
+
// commands on this PC; the cloud, the AI client and MCP calls cannot reach them.
|
|
241
|
+
const PERMISSION_COMMANDS = { "allow-write": 1, "deny-write": 1, "allow-command": 3, "deny-command": 2, "allow-localhost": 2, "deny-localhost": 2 };
|
|
242
|
+
async function listWorkspaces(runtimeDir) {
|
|
243
|
+
const result = execAgent(runtimeDir, ["list-workspaces"], 15_000);
|
|
244
|
+
if (result.status !== 0) fail(result.stderr.trim() || "WORKSPACE_LIST_FAILED");
|
|
245
|
+
try { process.stdout.write(JSON.stringify(JSON.parse(result.stdout.trim() || "[]"), null, 2) + "\n"); }
|
|
246
|
+
catch { fail("WORKSPACE_LIST_INVALID"); }
|
|
247
|
+
}
|
|
248
|
+
async function changePermission(runtimeDir, command, args) {
|
|
249
|
+
if (args.length !== PERMISSION_COMMANDS[command]) fail("ARGUMENT_INVALID");
|
|
250
|
+
const result = execAgent(runtimeDir, [command, ...args], 30_000);
|
|
251
|
+
if (result.status !== 0) fail(result.stderr.trim() || "PERMISSION_UPDATE_FAILED");
|
|
252
|
+
const record = await readProcessRecord();
|
|
253
|
+
if (record && pidAlive(record.pid)) {
|
|
254
|
+
await stopAgent();
|
|
255
|
+
await startAgent();
|
|
256
|
+
process.stdout.write("Permission updated; Local Commander restarted.\n");
|
|
257
|
+
} else process.stdout.write("Permission updated.\n");
|
|
258
|
+
}
|
|
239
259
|
function pidAlive(pid) {
|
|
240
260
|
if (!Number.isInteger(pid) || pid <= 0) return false;
|
|
241
261
|
try { process.kill(pid, 0); return true; }
|
|
@@ -356,6 +376,11 @@ function help() {
|
|
|
356
376
|
" npx local-commander-agent@latest restart restart background agent",
|
|
357
377
|
" npx local-commander-agent@latest update install this package version and restart",
|
|
358
378
|
" npx local-commander-agent@latest approve-workspace",
|
|
379
|
+
" npx local-commander-agent@latest workspaces list approved workspaces and permissions",
|
|
380
|
+
" npx local-commander-agent@latest allow-write <workspaceGrantId>",
|
|
381
|
+
" npx local-commander-agent@latest allow-command <workspaceGrantId> <name> <absolute-executable-path>",
|
|
382
|
+
" npx local-commander-agent@latest allow-localhost <workspaceGrantId> <port>",
|
|
383
|
+
" npx local-commander-agent@latest deny-write|deny-command|deny-localhost ...",
|
|
359
384
|
" npx local-commander-agent@latest uninstall [--purge-state]",
|
|
360
385
|
""
|
|
361
386
|
].join("\n");
|
|
@@ -410,6 +435,14 @@ async function main() {
|
|
|
410
435
|
await approveWorkspace(current.runtimeDir);
|
|
411
436
|
return;
|
|
412
437
|
}
|
|
438
|
+
if (command === "workspaces" || Object.hasOwn(PERMISSION_COMMANDS, command)) {
|
|
439
|
+
if (command === "workspaces" && args.length) fail("ARGUMENT_INVALID");
|
|
440
|
+
const current = await readCurrent();
|
|
441
|
+
if (!current) fail("AGENT_NOT_INSTALLED");
|
|
442
|
+
if (command === "workspaces") await listWorkspaces(current.runtimeDir);
|
|
443
|
+
else await changePermission(current.runtimeDir, command, args);
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
413
446
|
if (command === "uninstall") {
|
|
414
447
|
if (args.length > 1 || (args.length === 1 && args[0] !== "--purge-state")) fail("ARGUMENT_INVALID");
|
|
415
448
|
await uninstall(args[0] === "--purge-state");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "local-commander-agent",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "One-command Windows bootstrap for the Local Commander agent.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -36,6 +36,6 @@
|
|
|
36
36
|
"windows"
|
|
37
37
|
],
|
|
38
38
|
"localCommander": {
|
|
39
|
-
"controlPlaneOrigin": "https://localcmd.
|
|
39
|
+
"controlPlaneOrigin": "https://localcmd.app"
|
|
40
40
|
}
|
|
41
41
|
}
|
package/runtime/JobHost.exe
CHANGED
|
Binary file
|
|
Binary file
|
package/runtime/OwnerBridge.exe
CHANGED
|
Binary file
|
package/runtime/agent.mjs
CHANGED
|
@@ -24295,8 +24295,145 @@ var ActionEvidenceSchema = external_exports.object({
|
|
|
24295
24295
|
errorCode: external_exports.string().regex(/^[A-Z][A-Z0-9_]{0,63}$/).optional()
|
|
24296
24296
|
}).strict();
|
|
24297
24297
|
|
|
24298
|
-
// packages/contracts/src/
|
|
24298
|
+
// packages/contracts/src/index.ts
|
|
24299
|
+
var protocolVersion = 1;
|
|
24300
|
+
var MAX_FILE_WRITE_BYTES = 1024 * 1024;
|
|
24301
|
+
var MAX_RELAY_FRAME_BYTES = 8 * 1024 * 1024;
|
|
24299
24302
|
var uuid5 = external_exports.string().uuid().toLowerCase();
|
|
24303
|
+
var nonEmpty = external_exports.string().trim().min(1);
|
|
24304
|
+
var utcDateTime2 = external_exports.iso.datetime({ offset: false }).refine((value) => /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?Z$/.test(value), "Expected UTC timestamp with seconds");
|
|
24305
|
+
var units = external_exports.number().int().min(0).max(1e9);
|
|
24306
|
+
function validUsagePeriod(value) {
|
|
24307
|
+
const start = new Date(value.periodStartUtc);
|
|
24308
|
+
if (!Number.isFinite(start.getTime()) || start.getUTCDate() !== 1 || start.getUTCHours() !== 0 || start.getUTCMinutes() !== 0 || start.getUTCSeconds() !== 0 || start.getUTCMilliseconds() !== 0) return false;
|
|
24309
|
+
const end = new Date(start);
|
|
24310
|
+
end.setUTCMonth(end.getUTCMonth() + 1);
|
|
24311
|
+
return Date.parse(value.periodEndUtc) === end.getTime();
|
|
24312
|
+
}
|
|
24313
|
+
var PermissionScopeSchema = external_exports.enum([
|
|
24314
|
+
"devices:read",
|
|
24315
|
+
"sessions:manage",
|
|
24316
|
+
"files:read",
|
|
24317
|
+
"files:write",
|
|
24318
|
+
"commands:execute",
|
|
24319
|
+
"processes:control",
|
|
24320
|
+
"localhost:access"
|
|
24321
|
+
]);
|
|
24322
|
+
var OperationStateSchema = external_exports.enum([
|
|
24323
|
+
"queued",
|
|
24324
|
+
"prepared",
|
|
24325
|
+
"accepted",
|
|
24326
|
+
"running",
|
|
24327
|
+
"finished",
|
|
24328
|
+
"failed",
|
|
24329
|
+
"cancel_requested",
|
|
24330
|
+
"cancelled",
|
|
24331
|
+
"rejected",
|
|
24332
|
+
"unknown"
|
|
24333
|
+
]);
|
|
24334
|
+
var ErrorCodeSchema = external_exports.enum([
|
|
24335
|
+
"AUTH_REQUIRED",
|
|
24336
|
+
"GRANT_REVOKED",
|
|
24337
|
+
"DEVICE_OFFLINE",
|
|
24338
|
+
"SETUP_REQUIRED",
|
|
24339
|
+
"DEVICE_NOT_OWNED",
|
|
24340
|
+
"SESSION_EXPIRED",
|
|
24341
|
+
"LOCAL_PERMISSION_REQUIRED",
|
|
24342
|
+
"QUOTA_EXHAUSTED",
|
|
24343
|
+
"CAPACITY_BUSY",
|
|
24344
|
+
"RESOURCE_BUSY",
|
|
24345
|
+
"POLICY_DENIED",
|
|
24346
|
+
"TOOL_MISSING",
|
|
24347
|
+
"TIMEOUT",
|
|
24348
|
+
"CANCEL_REQUESTED",
|
|
24349
|
+
"EXECUTION_UNKNOWN",
|
|
24350
|
+
"OUTPUT_EXPIRED",
|
|
24351
|
+
"INFRA_UNAVAILABLE",
|
|
24352
|
+
"IDEMPOTENCY_CONFLICT"
|
|
24353
|
+
]);
|
|
24354
|
+
var LedgerEventKindSchema = external_exports.enum(["reserve", "charge", "release", "credit"]);
|
|
24355
|
+
var TrustedPrincipalSchema = external_exports.object({
|
|
24356
|
+
protocolVersion: external_exports.literal(protocolVersion),
|
|
24357
|
+
accountId: uuid5,
|
|
24358
|
+
tenantId: uuid5,
|
|
24359
|
+
grantId: uuid5,
|
|
24360
|
+
scopes: external_exports.array(PermissionScopeSchema).min(1).max(32),
|
|
24361
|
+
authenticatedAt: utcDateTime2,
|
|
24362
|
+
expiresAt: utcDateTime2
|
|
24363
|
+
}).strict().refine((value) => Date.parse(value.authenticatedAt) < Date.parse(value.expiresAt), { path: ["expiresAt"], message: "Expiry must follow authentication" });
|
|
24364
|
+
var ExecutionSessionSchema = external_exports.object({
|
|
24365
|
+
protocolVersion: external_exports.literal(protocolVersion),
|
|
24366
|
+
executionSessionId: uuid5,
|
|
24367
|
+
tenantId: uuid5,
|
|
24368
|
+
grantId: uuid5,
|
|
24369
|
+
deviceId: uuid5,
|
|
24370
|
+
workspaceGrantId: uuid5.optional(),
|
|
24371
|
+
policyVersion: external_exports.string().trim().min(1).max(64),
|
|
24372
|
+
openedAt: utcDateTime2,
|
|
24373
|
+
expiresAt: utcDateTime2,
|
|
24374
|
+
state: external_exports.enum(["open", "closing", "closed", "expired"])
|
|
24375
|
+
}).strict().refine((value) => Date.parse(value.openedAt) < Date.parse(value.expiresAt), { path: ["expiresAt"], message: "Expiry must follow session creation" });
|
|
24376
|
+
var ChildCommandSchema = external_exports.object({
|
|
24377
|
+
childExecutionId: uuid5,
|
|
24378
|
+
executable: nonEmpty.max(260),
|
|
24379
|
+
argv: external_exports.array(external_exports.string().max(8192)).max(128).default([]),
|
|
24380
|
+
cwd: external_exports.string().trim().min(1).max(2048).optional(),
|
|
24381
|
+
deadlineAt: utcDateTime2.optional()
|
|
24382
|
+
}).strict();
|
|
24383
|
+
var ClientCommandRequestSchema = external_exports.object({
|
|
24384
|
+
protocolVersion: external_exports.literal(protocolVersion),
|
|
24385
|
+
executionSessionId: uuid5,
|
|
24386
|
+
operationId: uuid5,
|
|
24387
|
+
idempotencyKey: external_exports.string().trim().min(8).max(128),
|
|
24388
|
+
children: external_exports.array(ChildCommandSchema).min(2).max(32)
|
|
24389
|
+
}).strict().superRefine((value, ctx) => {
|
|
24390
|
+
const seen = /* @__PURE__ */ new Set();
|
|
24391
|
+
value.children.forEach((child, index) => {
|
|
24392
|
+
if (seen.has(child.childExecutionId)) {
|
|
24393
|
+
ctx.addIssue({ code: "custom", path: ["children", index, "childExecutionId"], message: "childExecutionId must be unique within a batch" });
|
|
24394
|
+
}
|
|
24395
|
+
seen.add(child.childExecutionId);
|
|
24396
|
+
});
|
|
24397
|
+
});
|
|
24398
|
+
var ControlOperationSchema = external_exports.object({
|
|
24399
|
+
protocolVersion: external_exports.literal(protocolVersion),
|
|
24400
|
+
executionSessionId: uuid5,
|
|
24401
|
+
operationId: uuid5,
|
|
24402
|
+
kind: external_exports.enum(["status", "output", "cancel"]),
|
|
24403
|
+
cursor: external_exports.string().trim().min(1).max(512).optional()
|
|
24404
|
+
}).strict();
|
|
24405
|
+
var LedgerEventSchema = external_exports.object({
|
|
24406
|
+
protocolVersion: external_exports.literal(protocolVersion),
|
|
24407
|
+
tenantId: uuid5,
|
|
24408
|
+
executionId: uuid5,
|
|
24409
|
+
eventKind: LedgerEventKindSchema,
|
|
24410
|
+
units: external_exports.literal(1),
|
|
24411
|
+
periodStartUtc: utcDateTime2,
|
|
24412
|
+
periodEndUtc: utcDateTime2,
|
|
24413
|
+
occurredAt: utcDateTime2,
|
|
24414
|
+
adjustmentId: uuid5.optional()
|
|
24415
|
+
}).strict().refine(validUsagePeriod, { path: ["periodEndUtc"], message: "Expected one UTC calendar month" }).refine((value) => value.eventKind !== "credit" || value.adjustmentId !== void 0, { path: ["adjustmentId"], message: "Credit requires a unique adjustment ID" });
|
|
24416
|
+
var UsageCountersSchema = external_exports.object({
|
|
24417
|
+
protocolVersion: external_exports.literal(protocolVersion),
|
|
24418
|
+
tenantId: uuid5,
|
|
24419
|
+
periodStartUtc: utcDateTime2,
|
|
24420
|
+
periodEndUtc: utcDateTime2,
|
|
24421
|
+
limitUnits: units,
|
|
24422
|
+
reservedUnits: units,
|
|
24423
|
+
consumedUnits: units,
|
|
24424
|
+
creditedUnits: units
|
|
24425
|
+
}).strict().refine(validUsagePeriod, { path: ["periodEndUtc"], message: "Expected one UTC calendar month" });
|
|
24426
|
+
var OperationErrorSchema = external_exports.object({
|
|
24427
|
+
protocolVersion: external_exports.literal(protocolVersion),
|
|
24428
|
+
code: ErrorCodeSchema,
|
|
24429
|
+
message: external_exports.string().trim().min(1).max(512),
|
|
24430
|
+
retryable: external_exports.boolean(),
|
|
24431
|
+
dispatched: external_exports.boolean(),
|
|
24432
|
+
quotaEffect: external_exports.enum(["none", "reserved", "charged", "released", "credited", "unknown"])
|
|
24433
|
+
}).strict();
|
|
24434
|
+
|
|
24435
|
+
// packages/contracts/src/device-protocol.ts
|
|
24436
|
+
var uuid8 = external_exports.string().uuid().toLowerCase();
|
|
24300
24437
|
var hash2 = external_exports.string().regex(/^[a-f0-9]{64}$/);
|
|
24301
24438
|
var epoch = external_exports.string().regex(/^[1-9]\d{0,18}$/).refine((v) => BigInt(v) <= 9223372036854775807n);
|
|
24302
24439
|
var text = external_exports.string().max(32767).refine((v) => !v.includes("\0"));
|
|
@@ -24306,7 +24443,7 @@ var ToolCallSchema = external_exports.discriminatedUnion("name", [
|
|
|
24306
24443
|
external_exports.object({ name: external_exports.literal("fs_list"), args: external_exports.object({ path: path.optional(), recursive: external_exports.boolean().default(false), maxDepth: external_exports.number().int().min(0).max(8).default(3), maxEntries: external_exports.number().int().min(1).max(1e3).default(200) }).strict() }).strict(),
|
|
24307
24444
|
external_exports.object({ name: external_exports.literal("fs_read"), args: external_exports.object({ path, startLine: external_exports.number().int().min(1).max(1e6).optional(), endLine: external_exports.number().int().min(1).max(1e6).optional() }).strict() }).strict(),
|
|
24308
24445
|
external_exports.object({ name: external_exports.literal("fs_search"), args: external_exports.object({ path: path.optional(), query: external_exports.string().min(1).max(1e3), caseSensitive: external_exports.boolean().default(false), maxResults: external_exports.number().int().min(1).max(300).default(100) }).strict() }).strict(),
|
|
24309
|
-
external_exports.object({ name: external_exports.literal("fs_write"), args: external_exports.object({ path, content: external_exports.string().max(
|
|
24446
|
+
external_exports.object({ name: external_exports.literal("fs_write"), args: external_exports.object({ path, content: external_exports.string().max(MAX_FILE_WRITE_BYTES).refine((value) => Buffer.byteLength(value, "utf8") <= MAX_FILE_WRITE_BYTES, "fs_write content exceeds 1 MiB UTF-8"), overwrite: external_exports.boolean().default(false), expectedSha256: hash2.optional() }).strict() }).strict(),
|
|
24310
24447
|
external_exports.object({ name: external_exports.literal("fs_replace"), args: external_exports.object({ path, oldText: external_exports.string().min(1).max(6e4), newText: external_exports.string().max(6e4), replaceAll: external_exports.boolean().default(false), expectedSha256: hash2.optional() }).strict() }).strict(),
|
|
24311
24448
|
external_exports.object({ name: external_exports.literal("git_status"), args: external_exports.object({ path: path.optional() }).strict() }).strict(),
|
|
24312
24449
|
external_exports.object({ name: external_exports.literal("git_diff"), args: external_exports.object({ path: path.optional(), file: path.optional(), staged: external_exports.boolean().default(false) }).strict() }).strict(),
|
|
@@ -24320,32 +24457,32 @@ function scopeForTool(call) {
|
|
|
24320
24457
|
if (call.name === "localhost_request") return "localhost:access";
|
|
24321
24458
|
return call.name === "fs_write" || call.name === "fs_replace" ? "files:write" : "files:read";
|
|
24322
24459
|
}
|
|
24323
|
-
var ExecutionBindingSchema = external_exports.object({ tenantId:
|
|
24460
|
+
var ExecutionBindingSchema = external_exports.object({ tenantId: uuid8, accountId: uuid8.optional(), deviceId: uuid8, grantId: uuid8, sessionId: uuid8, operationId: uuid8, executionId: uuid8, connectionEpoch: epoch, workspaceGrantId: uuid8, policyVersion: external_exports.number().int().min(1).max(2147483647), payloadHash: hash2, deadlineAt: timestamp }).strict();
|
|
24324
24461
|
var EfficiencyNoticeSchema = external_exports.object({ message: external_exports.string().min(1).max(160), estimatedSavedTokens: external_exports.number().int().min(1).max(1e12), savedBytes: external_exports.number().int().min(1).max(1e12), sessionCalls: external_exports.number().int().min(20).max(1e9) }).strict();
|
|
24325
24462
|
var ResultSchema = external_exports.object({ exitCode: external_exports.number().int().min(-2147483648).max(4294967295).nullable(), timedOut: external_exports.boolean(), cancelled: external_exports.boolean(), treeTerminated: external_exports.boolean(), stdout: external_exports.string().max(196608), stderr: external_exports.string().max(196608), stdoutTruncated: external_exports.boolean(), stderrTruncated: external_exports.boolean(), resultCode: external_exports.string().regex(/^[A-Z0-9_]{1,40}$/), efficiencyNotice: EfficiencyNoticeSchema.optional() }).strict();
|
|
24326
24463
|
var ServerFrameSchema = external_exports.discriminatedUnion("type", [
|
|
24327
|
-
external_exports.object({ type: external_exports.literal("hello"), version: external_exports.literal(1), tenantId:
|
|
24464
|
+
external_exports.object({ type: external_exports.literal("hello"), version: external_exports.literal(1), tenantId: uuid8, deviceId: uuid8, connectionEpoch: epoch, serverTime: timestamp }).strict(),
|
|
24328
24465
|
external_exports.object({ type: external_exports.literal("prepare"), version: external_exports.literal(1), binding: ExecutionBindingSchema, tool: ToolCallSchema }).strict(),
|
|
24329
24466
|
external_exports.object({ type: external_exports.literal("execute"), version: external_exports.literal(1), binding: ExecutionBindingSchema }).strict(),
|
|
24330
|
-
external_exports.object({ type: external_exports.literal("control"), version: external_exports.literal(1), requestId:
|
|
24467
|
+
external_exports.object({ type: external_exports.literal("control"), version: external_exports.literal(1), requestId: uuid8, binding: ExecutionBindingSchema, action: external_exports.enum(["status", "output", "cancel"]) }).strict(),
|
|
24331
24468
|
external_exports.object({ type: external_exports.literal("heartbeat_ack"), version: external_exports.literal(1), connectionEpoch: epoch, leaseExpiresAt: timestamp }).strict(),
|
|
24332
|
-
external_exports.object({ type: external_exports.literal("workspace_ack"), version: external_exports.literal(1), requestId:
|
|
24469
|
+
external_exports.object({ type: external_exports.literal("workspace_ack"), version: external_exports.literal(1), requestId: uuid8, workspaceGrantId: uuid8, accepted: external_exports.boolean(), code: external_exports.string().max(64).optional() }).strict(),
|
|
24333
24470
|
external_exports.object({ type: external_exports.literal("revoke"), version: external_exports.literal(1), reason: external_exports.enum(["device_revoked", "account_revoked", "server_shutdown", "connection_replaced"]) }).strict()
|
|
24334
24471
|
]);
|
|
24335
24472
|
var ClientFrameSchema = external_exports.discriminatedUnion("type", [
|
|
24336
24473
|
external_exports.object({ type: external_exports.literal("ready"), version: external_exports.literal(1), safeSlots: external_exports.number().int().min(1).max(128), platform: external_exports.literal("win32"), agentVersion: external_exports.string().regex(/^[A-Za-z0-9._+-]{1,64}$/), supervisor: external_exports.boolean() }).strict(),
|
|
24337
24474
|
external_exports.object({ type: external_exports.literal("heartbeat"), version: external_exports.literal(1), connectionEpoch: epoch }).strict(),
|
|
24338
|
-
external_exports.object({ type: external_exports.literal("workspace_grant"), version: external_exports.literal(1), requestId:
|
|
24339
|
-
external_exports.object({ type: external_exports.literal("workspace_revoke"), version: external_exports.literal(1), requestId:
|
|
24475
|
+
external_exports.object({ type: external_exports.literal("workspace_grant"), version: external_exports.literal(1), requestId: uuid8, workspaceGrantId: uuid8, rootHash: hash2, displayName: external_exports.string().min(1).max(120), policyVersion: external_exports.number().int().min(1).max(2147483647) }).strict(),
|
|
24476
|
+
external_exports.object({ type: external_exports.literal("workspace_revoke"), version: external_exports.literal(1), requestId: uuid8, workspaceGrantId: uuid8 }).strict(),
|
|
24340
24477
|
external_exports.object({ type: external_exports.literal("prepared"), version: external_exports.literal(1), binding: ExecutionBindingSchema }).strict(),
|
|
24341
24478
|
external_exports.object({ type: external_exports.literal("accepted"), version: external_exports.literal(1), binding: ExecutionBindingSchema }).strict(),
|
|
24342
24479
|
external_exports.object({ type: external_exports.literal("running"), version: external_exports.literal(1), binding: ExecutionBindingSchema, pid: external_exports.number().int().positive().optional() }).strict(),
|
|
24343
24480
|
external_exports.object({ type: external_exports.literal("result"), version: external_exports.literal(1), binding: ExecutionBindingSchema, result: ResultSchema }).strict(),
|
|
24344
24481
|
external_exports.object({ type: external_exports.literal("not_accepted"), version: external_exports.literal(1), binding: ExecutionBindingSchema, code: external_exports.string().regex(/^[A-Z0-9_]{1,40}$/), provedNotStarted: external_exports.boolean() }).strict(),
|
|
24345
|
-
external_exports.object({ type: external_exports.literal("control_result"), version: external_exports.literal(1), requestId:
|
|
24482
|
+
external_exports.object({ type: external_exports.literal("control_result"), version: external_exports.literal(1), requestId: uuid8, binding: ExecutionBindingSchema, state: external_exports.enum(["prepared", "accepted", "running", "finished", "failed", "cancelled", "rejected", "unknown", "missing"]), result: ResultSchema.optional() }).strict()
|
|
24346
24483
|
]);
|
|
24347
|
-
var TerminalEventSchema = external_exports.object({ type: external_exports.literal("executionResult"), protocolVersion: external_exports.literal(1), requestId:
|
|
24348
|
-
var TerminalEventAckSchema = external_exports.object({ type: external_exports.literal("executionResultAck"), protocolVersion: external_exports.literal(1), requestId:
|
|
24484
|
+
var TerminalEventSchema = external_exports.object({ type: external_exports.literal("executionResult"), protocolVersion: external_exports.literal(1), requestId: uuid8, tenantId: uuid8, deviceId: uuid8, connectionEpoch: epoch, binding: ExecutionBindingSchema, state: external_exports.enum(["finished", "failed", "cancelled", "unknown"]), resultCode: external_exports.string().regex(/^[A-Z0-9_]{1,40}$/) }).strict();
|
|
24485
|
+
var TerminalEventAckSchema = external_exports.object({ type: external_exports.literal("executionResultAck"), protocolVersion: external_exports.literal(1), requestId: uuid8, ok: external_exports.boolean() }).strict();
|
|
24349
24486
|
function canonicalJson(value) {
|
|
24350
24487
|
function canonical2(v) {
|
|
24351
24488
|
if (Array.isArray(v)) return v.map(canonical2);
|
|
@@ -24378,16 +24515,16 @@ var guardAdapter = AdapterDescriptorSchema.parse({
|
|
|
24378
24515
|
detectsNativeBypass: false
|
|
24379
24516
|
}
|
|
24380
24517
|
});
|
|
24381
|
-
var
|
|
24518
|
+
var uuid9 = external_exports.string().uuid().toLowerCase();
|
|
24382
24519
|
var GuardSettingsSchema = external_exports.object({
|
|
24383
24520
|
policyId: external_exports.string().regex(/^[a-z][a-z0-9._-]{0,63}$/),
|
|
24384
24521
|
keys: external_exports.array(external_exports.object({ keyId: external_exports.string().regex(/^[a-z][a-z0-9._-]{0,63}$/), publicKeyPem: external_exports.string().max(1024) }).strict()).min(1).max(8),
|
|
24385
24522
|
environment: EnvironmentContextSchema
|
|
24386
24523
|
}).strict();
|
|
24387
24524
|
var GuardConfigurationSchema = GuardSettingsSchema.extend({
|
|
24388
|
-
tenantId:
|
|
24389
|
-
deviceId:
|
|
24390
|
-
ownerAccountId:
|
|
24525
|
+
tenantId: uuid9,
|
|
24526
|
+
deviceId: uuid9,
|
|
24527
|
+
ownerAccountId: uuid9,
|
|
24391
24528
|
ownerSid: external_exports.string().regex(/^S-1-(?:[0-9]+-)+[0-9]+$/).max(184)
|
|
24392
24529
|
}).strict();
|
|
24393
24530
|
function guardHash(value) {
|
|
@@ -24468,14 +24605,14 @@ var GuardEventSchema = external_exports.object({
|
|
|
24468
24605
|
previousHash: hash3,
|
|
24469
24606
|
hash: hash3
|
|
24470
24607
|
}).strict();
|
|
24471
|
-
var
|
|
24608
|
+
var uuid10 = external_exports.string().uuid().toLowerCase();
|
|
24472
24609
|
var GuardEvidenceRecordSchema = external_exports.object({
|
|
24473
|
-
tenantId:
|
|
24474
|
-
deviceId:
|
|
24475
|
-
accountId:
|
|
24476
|
-
sessionId:
|
|
24477
|
-
operationId:
|
|
24478
|
-
executionId:
|
|
24610
|
+
tenantId: uuid10,
|
|
24611
|
+
deviceId: uuid10,
|
|
24612
|
+
accountId: uuid10.optional(),
|
|
24613
|
+
sessionId: uuid10,
|
|
24614
|
+
operationId: uuid10,
|
|
24615
|
+
executionId: uuid10,
|
|
24479
24616
|
state: external_exports.enum(["prepared", "accepted", "running", "finished", "failed", "cancelled", "rejected", "unknown"]),
|
|
24480
24617
|
events: external_exports.array(GuardEventSchema).min(1).max(12)
|
|
24481
24618
|
}).strict();
|
|
@@ -24494,8 +24631,8 @@ function appendGuardEvent(events, input2) {
|
|
|
24494
24631
|
}
|
|
24495
24632
|
var ExportSchema = external_exports.object({
|
|
24496
24633
|
formatVersion: external_exports.literal(1),
|
|
24497
|
-
tenantId:
|
|
24498
|
-
deviceId:
|
|
24634
|
+
tenantId: uuid10,
|
|
24635
|
+
deviceId: uuid10,
|
|
24499
24636
|
records: external_exports.array(GuardEvidenceRecordSchema).max(1e3)
|
|
24500
24637
|
}).strict();
|
|
24501
24638
|
var HeaderSchema = external_exports.object({ alg: external_exports.literal("EdDSA"), typ: external_exports.literal("lc-guard-evidence+jws"), kid: hash3 }).strict();
|
|
@@ -24538,7 +24675,7 @@ async function signGuardEvidence(records, identity) {
|
|
|
24538
24675
|
}
|
|
24539
24676
|
|
|
24540
24677
|
// agent/src/journal.ts
|
|
24541
|
-
var
|
|
24678
|
+
var uuid11 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
24542
24679
|
var hash4 = /^[0-9a-f]{64}$/;
|
|
24543
24680
|
var bindingKeys = ["executionId", "operationId", "sessionId", "tenantId", "grantId", "deviceId", "connectionEpoch", "payloadHash", "deadlineAt", "workspaceGrantId", "policyVersion", "accountId"];
|
|
24544
24681
|
var terminal = /* @__PURE__ */ new Set(["finished", "failed", "cancelled", "rejected"]);
|
|
@@ -24558,10 +24695,10 @@ function canonicalTime(value) {
|
|
|
24558
24695
|
}
|
|
24559
24696
|
function validateInput(value) {
|
|
24560
24697
|
if (!value || typeof value !== "object" || Object.keys(value).some((k) => !bindingKeys.includes(k))) throw failure2("JOURNAL_INPUT_INVALID");
|
|
24561
|
-
for (const name of bindingKeys.slice(0, 6)) if (typeof value[name] !== "string" || !
|
|
24562
|
-
if (value.accountId !== void 0 && !
|
|
24698
|
+
for (const name of bindingKeys.slice(0, 6)) if (typeof value[name] !== "string" || !uuid11.test(value[name])) throw failure2("JOURNAL_INPUT_INVALID");
|
|
24699
|
+
if (value.accountId !== void 0 && !uuid11.test(value.accountId)) throw failure2("JOURNAL_INPUT_INVALID");
|
|
24563
24700
|
if (typeof value.connectionEpoch !== "string" || !/^[1-9]\d{0,18}$/.test(value.connectionEpoch) || BigInt(value.connectionEpoch) > 9223372036854775807n || typeof value.payloadHash !== "string" || !hash4.test(value.payloadHash) || !canonicalTime(value.deadlineAt)) throw failure2("JOURNAL_INPUT_INVALID");
|
|
24564
|
-
if (value.workspaceGrantId === void 0 !== (value.policyVersion === void 0) || value.workspaceGrantId !== void 0 && (!
|
|
24701
|
+
if (value.workspaceGrantId === void 0 !== (value.policyVersion === void 0) || value.workspaceGrantId !== void 0 && (!uuid11.test(value.workspaceGrantId) || !Number.isInteger(value.policyVersion) || value.policyVersion < 1 || value.policyVersion > 2147483647)) throw failure2("JOURNAL_INPUT_INVALID");
|
|
24565
24702
|
}
|
|
24566
24703
|
function clone2(value) {
|
|
24567
24704
|
return structuredClone(value);
|
|
@@ -24660,7 +24797,7 @@ var NativeJournal = class _NativeJournal {
|
|
|
24660
24797
|
return path2.join(this.dir, id + ".entry");
|
|
24661
24798
|
}
|
|
24662
24799
|
need(id) {
|
|
24663
|
-
if (!
|
|
24800
|
+
if (!uuid11.test(id)) throw failure2("JOURNAL_INPUT_INVALID");
|
|
24664
24801
|
const e = this.entries.get(id);
|
|
24665
24802
|
if (!e) throw failure2("EXECUTION_UNKNOWN");
|
|
24666
24803
|
return clone2(e);
|
|
@@ -24683,7 +24820,7 @@ var NativeJournal = class _NativeJournal {
|
|
|
24683
24820
|
for (const name of names) {
|
|
24684
24821
|
if (!name.endsWith(".entry")) continue;
|
|
24685
24822
|
const id = name.slice(0, -6);
|
|
24686
|
-
if (!
|
|
24823
|
+
if (!uuid11.test(id)) throw failure2("JOURNAL_CORRUPT");
|
|
24687
24824
|
const envelope = await this.readOwned(id);
|
|
24688
24825
|
this.totalBytes += envelope.length;
|
|
24689
24826
|
if (this.totalBytes > this.options.maxBytes || this.entries.size >= this.options.maxEntries) throw failure2("JOURNAL_CAPACITY_EXCEEDED");
|
|
@@ -24830,7 +24967,7 @@ var NativeJournal = class _NativeJournal {
|
|
|
24830
24967
|
}
|
|
24831
24968
|
get(id) {
|
|
24832
24969
|
return this.enqueue(async () => {
|
|
24833
|
-
if (!
|
|
24970
|
+
if (!uuid11.test(id)) throw failure2("JOURNAL_INPUT_INVALID");
|
|
24834
24971
|
const e = this.entries.get(id);
|
|
24835
24972
|
return e ? clone2(e) : null;
|
|
24836
24973
|
});
|
|
@@ -25072,7 +25209,7 @@ import { createHash as createHash5, KeyObject as KeyObject2 } from "node:crypto"
|
|
|
25072
25209
|
// packages/policy/src/evaluator.ts
|
|
25073
25210
|
import { createHash as createHash4 } from "node:crypto";
|
|
25074
25211
|
import { isDeepStrictEqual } from "node:util";
|
|
25075
|
-
var
|
|
25212
|
+
var uuid12 = external_exports.string().uuid().toLowerCase();
|
|
25076
25213
|
var slug2 = external_exports.string().regex(/^[a-z][a-z0-9._-]{0,63}$/);
|
|
25077
25214
|
var utc = external_exports.iso.datetime({ offset: false });
|
|
25078
25215
|
var risk = external_exports.enum(["low", "moderate", "high", "critical"]);
|
|
@@ -25097,7 +25234,7 @@ var PolicyRuleSchema = external_exports.object({
|
|
|
25097
25234
|
}
|
|
25098
25235
|
});
|
|
25099
25236
|
var PolicySnapshotSchema = external_exports.object({
|
|
25100
|
-
tenantId:
|
|
25237
|
+
tenantId: uuid12,
|
|
25101
25238
|
policyId: slug2,
|
|
25102
25239
|
policyVersion: external_exports.string().trim().min(1).max(64),
|
|
25103
25240
|
issuedAt: utc,
|
|
@@ -25211,14 +25348,14 @@ async function verifySignedPolicyBundle(candidate, authority, checkpointInput, n
|
|
|
25211
25348
|
|
|
25212
25349
|
// packages/policy/src/approvals.ts
|
|
25213
25350
|
import { createHash as createHash6, randomUUID as randomUUID2 } from "node:crypto";
|
|
25214
|
-
var
|
|
25351
|
+
var uuid13 = TrustedActionBindingSchema.shape.tenantId;
|
|
25215
25352
|
var utc3 = TrustedActionBindingSchema.shape.expiresAt;
|
|
25216
25353
|
var digest3 = ResourceRefSchema.shape.locatorFingerprint;
|
|
25217
25354
|
var requirement = PolicyDecisionSchema.shape.approval.unwrap();
|
|
25218
25355
|
var ApprovalActionSchema = external_exports.object({ request: BoundActionRequestSchema, payloadHash: digest3 }).strict();
|
|
25219
25356
|
var ApprovalAuthoritySchema = external_exports.object({
|
|
25220
|
-
tenantId:
|
|
25221
|
-
accountId:
|
|
25357
|
+
tenantId: uuid13,
|
|
25358
|
+
accountId: uuid13,
|
|
25222
25359
|
approvalClass: requirement.shape.approvalClass,
|
|
25223
25360
|
authenticatedAt: utc3,
|
|
25224
25361
|
expiresAt: utc3
|
|
@@ -25230,11 +25367,11 @@ var ContextSchema = external_exports.object({
|
|
|
25230
25367
|
policyExpiresAt: utc3
|
|
25231
25368
|
}).strict();
|
|
25232
25369
|
var GrantSchema = external_exports.object({
|
|
25233
|
-
approvalId:
|
|
25234
|
-
requestId:
|
|
25235
|
-
decisionId:
|
|
25370
|
+
approvalId: uuid13,
|
|
25371
|
+
requestId: uuid13,
|
|
25372
|
+
decisionId: uuid13,
|
|
25236
25373
|
bindingHash: digest3,
|
|
25237
|
-
approverAccountId:
|
|
25374
|
+
approverAccountId: uuid13,
|
|
25238
25375
|
approvalClass: requirement.shape.approvalClass,
|
|
25239
25376
|
scope: requirement.shape.scope,
|
|
25240
25377
|
issuedAt: utc3,
|
|
@@ -25243,8 +25380,8 @@ var GrantSchema = external_exports.object({
|
|
|
25243
25380
|
uses: external_exports.number().int().min(0).max(Number.MAX_SAFE_INTEGER)
|
|
25244
25381
|
}).strict().refine((value) => Date.parse(value.issuedAt) < Date.parse(value.expiresAt) && (value.scope === "once" ? value.uses === (value.state === "consumed" ? 1 : 0) : value.state !== "consumed"));
|
|
25245
25382
|
var ApprovalLedgerSchema = external_exports.object({
|
|
25246
|
-
tenantId:
|
|
25247
|
-
deviceId:
|
|
25383
|
+
tenantId: uuid13,
|
|
25384
|
+
deviceId: uuid13,
|
|
25248
25385
|
lastChangedAt: utc3,
|
|
25249
25386
|
grants: external_exports.array(GrantSchema).max(128)
|
|
25250
25387
|
}).strict().refine((value) => new Set(value.grants.map((grant) => grant.approvalId)).size === value.grants.length && new Set(value.grants.map((grant) => grant.requestId)).size === value.grants.length && value.grants.every((grant) => Date.parse(grant.issuedAt) <= Date.parse(value.lastChangedAt)));
|
|
@@ -25321,7 +25458,7 @@ function issueApproval(ledgerInput, context, authorityInput, now, expiresAt) {
|
|
|
25321
25458
|
}
|
|
25322
25459
|
function consumeApproval(ledgerInput, context, approvalId, now) {
|
|
25323
25460
|
try {
|
|
25324
|
-
const ledger = current(ledgerInput, now), bound = binding(ledger, context, now), id =
|
|
25461
|
+
const ledger = current(ledgerInput, now), bound = binding(ledger, context, now), id = uuid13.parse(approvalId);
|
|
25325
25462
|
const grant = ledger.grants.find((candidate) => candidate.approvalId === id);
|
|
25326
25463
|
if (!grant || grant.state !== "active" || grant.bindingHash !== bound.bindingHash || grant.uses === Number.MAX_SAFE_INTEGER || Date.parse(now) < Date.parse(grant.issuedAt) || grant.scope === "once" && (grant.requestId !== bound.request.requestId || grant.decisionId !== bound.decision.decisionId)) throw Error();
|
|
25327
25464
|
const consumed = { ...grant, uses: grant.uses + 1, state: grant.scope === "once" ? "consumed" : "active" };
|
|
@@ -25332,7 +25469,7 @@ function consumeApproval(ledgerInput, context, approvalId, now) {
|
|
|
25332
25469
|
}
|
|
25333
25470
|
function revokeApproval(ledgerInput, approvalId, now) {
|
|
25334
25471
|
try {
|
|
25335
|
-
const ledger = current(ledgerInput, now), id =
|
|
25472
|
+
const ledger = current(ledgerInput, now), id = uuid13.parse(approvalId);
|
|
25336
25473
|
return { ...ledger, grants: ledger.grants.map((grant) => grant.approvalId === id && grant.state === "active" ? { ...grant, state: "revoked" } : grant) };
|
|
25337
25474
|
} catch {
|
|
25338
25475
|
throw Error("APPROVAL_INVALID");
|
|
@@ -26470,7 +26607,7 @@ var NativeTools = class {
|
|
|
26470
26607
|
contents = pieces.join(call.args.newText);
|
|
26471
26608
|
}
|
|
26472
26609
|
const bytes3 = Buffer.from(contents, "utf8");
|
|
26473
|
-
if (bytes3.length >
|
|
26610
|
+
if (bytes3.length > MAX_FILE_WRITE_BYTES) fail2("FILE_WRITE_LIMIT");
|
|
26474
26611
|
const temp = path7.join(path7.dirname(target), ".lc-write-" + randomUUID4() + ".tmp");
|
|
26475
26612
|
const handle = await open4(temp, constants3.O_CREAT | constants3.O_EXCL | constants3.O_WRONLY, 384);
|
|
26476
26613
|
try {
|
|
@@ -27183,17 +27320,17 @@ function unshapedResultTelemetry(result2) {
|
|
|
27183
27320
|
|
|
27184
27321
|
// packages/optimization/src/live-telemetry.ts
|
|
27185
27322
|
var LIVE_EFFICIENCY_EVENT_VERSION = 1;
|
|
27186
|
-
var
|
|
27323
|
+
var uuid14 = external_exports.string().uuid().toLowerCase();
|
|
27187
27324
|
var bytes2 = external_exports.number().int().min(0).max(1e9);
|
|
27188
27325
|
var utc4 = external_exports.iso.datetime({ offset: false });
|
|
27189
27326
|
var LiveEfficiencyEventSchema = external_exports.object({
|
|
27190
27327
|
version: external_exports.literal(LIVE_EFFICIENCY_EVENT_VERSION),
|
|
27191
27328
|
occurredAt: utc4,
|
|
27192
|
-
tenantId:
|
|
27193
|
-
accountId:
|
|
27194
|
-
sessionId:
|
|
27195
|
-
operationId:
|
|
27196
|
-
executionId:
|
|
27329
|
+
tenantId: uuid14,
|
|
27330
|
+
accountId: uuid14.nullable(),
|
|
27331
|
+
sessionId: uuid14,
|
|
27332
|
+
operationId: uuid14,
|
|
27333
|
+
executionId: uuid14,
|
|
27197
27334
|
toolName: external_exports.string().trim().min(1).max(120),
|
|
27198
27335
|
outcome: external_exports.enum(["success", "failed", "timed_out", "cancelled", "unknown"]),
|
|
27199
27336
|
parserId: external_exports.string().trim().min(1).max(120).nullable(),
|
|
@@ -27706,141 +27843,6 @@ var import_websocket = __toESM(require_websocket(), 1);
|
|
|
27706
27843
|
var import_websocket_server = __toESM(require_websocket_server(), 1);
|
|
27707
27844
|
var wrapper_default = import_websocket.default;
|
|
27708
27845
|
|
|
27709
|
-
// packages/contracts/src/index.ts
|
|
27710
|
-
var protocolVersion = 1;
|
|
27711
|
-
var uuid14 = external_exports.string().uuid().toLowerCase();
|
|
27712
|
-
var nonEmpty = external_exports.string().trim().min(1);
|
|
27713
|
-
var utcDateTime2 = external_exports.iso.datetime({ offset: false }).refine((value) => /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?Z$/.test(value), "Expected UTC timestamp with seconds");
|
|
27714
|
-
var units = external_exports.number().int().min(0).max(1e9);
|
|
27715
|
-
function validUsagePeriod(value) {
|
|
27716
|
-
const start = new Date(value.periodStartUtc);
|
|
27717
|
-
if (!Number.isFinite(start.getTime()) || start.getUTCDate() !== 1 || start.getUTCHours() !== 0 || start.getUTCMinutes() !== 0 || start.getUTCSeconds() !== 0 || start.getUTCMilliseconds() !== 0) return false;
|
|
27718
|
-
const end = new Date(start);
|
|
27719
|
-
end.setUTCMonth(end.getUTCMonth() + 1);
|
|
27720
|
-
return Date.parse(value.periodEndUtc) === end.getTime();
|
|
27721
|
-
}
|
|
27722
|
-
var PermissionScopeSchema = external_exports.enum([
|
|
27723
|
-
"devices:read",
|
|
27724
|
-
"sessions:manage",
|
|
27725
|
-
"files:read",
|
|
27726
|
-
"files:write",
|
|
27727
|
-
"commands:execute",
|
|
27728
|
-
"processes:control",
|
|
27729
|
-
"localhost:access"
|
|
27730
|
-
]);
|
|
27731
|
-
var OperationStateSchema = external_exports.enum([
|
|
27732
|
-
"queued",
|
|
27733
|
-
"prepared",
|
|
27734
|
-
"accepted",
|
|
27735
|
-
"running",
|
|
27736
|
-
"finished",
|
|
27737
|
-
"failed",
|
|
27738
|
-
"cancel_requested",
|
|
27739
|
-
"cancelled",
|
|
27740
|
-
"rejected",
|
|
27741
|
-
"unknown"
|
|
27742
|
-
]);
|
|
27743
|
-
var ErrorCodeSchema = external_exports.enum([
|
|
27744
|
-
"AUTH_REQUIRED",
|
|
27745
|
-
"GRANT_REVOKED",
|
|
27746
|
-
"DEVICE_OFFLINE",
|
|
27747
|
-
"SETUP_REQUIRED",
|
|
27748
|
-
"DEVICE_NOT_OWNED",
|
|
27749
|
-
"SESSION_EXPIRED",
|
|
27750
|
-
"LOCAL_PERMISSION_REQUIRED",
|
|
27751
|
-
"QUOTA_EXHAUSTED",
|
|
27752
|
-
"CAPACITY_BUSY",
|
|
27753
|
-
"RESOURCE_BUSY",
|
|
27754
|
-
"POLICY_DENIED",
|
|
27755
|
-
"TOOL_MISSING",
|
|
27756
|
-
"TIMEOUT",
|
|
27757
|
-
"CANCEL_REQUESTED",
|
|
27758
|
-
"EXECUTION_UNKNOWN",
|
|
27759
|
-
"OUTPUT_EXPIRED",
|
|
27760
|
-
"INFRA_UNAVAILABLE",
|
|
27761
|
-
"IDEMPOTENCY_CONFLICT"
|
|
27762
|
-
]);
|
|
27763
|
-
var LedgerEventKindSchema = external_exports.enum(["reserve", "charge", "release", "credit"]);
|
|
27764
|
-
var TrustedPrincipalSchema = external_exports.object({
|
|
27765
|
-
protocolVersion: external_exports.literal(protocolVersion),
|
|
27766
|
-
accountId: uuid14,
|
|
27767
|
-
tenantId: uuid14,
|
|
27768
|
-
grantId: uuid14,
|
|
27769
|
-
scopes: external_exports.array(PermissionScopeSchema).min(1).max(32),
|
|
27770
|
-
authenticatedAt: utcDateTime2,
|
|
27771
|
-
expiresAt: utcDateTime2
|
|
27772
|
-
}).strict().refine((value) => Date.parse(value.authenticatedAt) < Date.parse(value.expiresAt), { path: ["expiresAt"], message: "Expiry must follow authentication" });
|
|
27773
|
-
var ExecutionSessionSchema = external_exports.object({
|
|
27774
|
-
protocolVersion: external_exports.literal(protocolVersion),
|
|
27775
|
-
executionSessionId: uuid14,
|
|
27776
|
-
tenantId: uuid14,
|
|
27777
|
-
grantId: uuid14,
|
|
27778
|
-
deviceId: uuid14,
|
|
27779
|
-
workspaceGrantId: uuid14.optional(),
|
|
27780
|
-
policyVersion: external_exports.string().trim().min(1).max(64),
|
|
27781
|
-
openedAt: utcDateTime2,
|
|
27782
|
-
expiresAt: utcDateTime2,
|
|
27783
|
-
state: external_exports.enum(["open", "closing", "closed", "expired"])
|
|
27784
|
-
}).strict().refine((value) => Date.parse(value.openedAt) < Date.parse(value.expiresAt), { path: ["expiresAt"], message: "Expiry must follow session creation" });
|
|
27785
|
-
var ChildCommandSchema = external_exports.object({
|
|
27786
|
-
childExecutionId: uuid14,
|
|
27787
|
-
executable: nonEmpty.max(260),
|
|
27788
|
-
argv: external_exports.array(external_exports.string().max(8192)).max(128).default([]),
|
|
27789
|
-
cwd: external_exports.string().trim().min(1).max(2048).optional(),
|
|
27790
|
-
deadlineAt: utcDateTime2.optional()
|
|
27791
|
-
}).strict();
|
|
27792
|
-
var ClientCommandRequestSchema = external_exports.object({
|
|
27793
|
-
protocolVersion: external_exports.literal(protocolVersion),
|
|
27794
|
-
executionSessionId: uuid14,
|
|
27795
|
-
operationId: uuid14,
|
|
27796
|
-
idempotencyKey: external_exports.string().trim().min(8).max(128),
|
|
27797
|
-
children: external_exports.array(ChildCommandSchema).min(2).max(32)
|
|
27798
|
-
}).strict().superRefine((value, ctx) => {
|
|
27799
|
-
const seen = /* @__PURE__ */ new Set();
|
|
27800
|
-
value.children.forEach((child, index) => {
|
|
27801
|
-
if (seen.has(child.childExecutionId)) {
|
|
27802
|
-
ctx.addIssue({ code: "custom", path: ["children", index, "childExecutionId"], message: "childExecutionId must be unique within a batch" });
|
|
27803
|
-
}
|
|
27804
|
-
seen.add(child.childExecutionId);
|
|
27805
|
-
});
|
|
27806
|
-
});
|
|
27807
|
-
var ControlOperationSchema = external_exports.object({
|
|
27808
|
-
protocolVersion: external_exports.literal(protocolVersion),
|
|
27809
|
-
executionSessionId: uuid14,
|
|
27810
|
-
operationId: uuid14,
|
|
27811
|
-
kind: external_exports.enum(["status", "output", "cancel"]),
|
|
27812
|
-
cursor: external_exports.string().trim().min(1).max(512).optional()
|
|
27813
|
-
}).strict();
|
|
27814
|
-
var LedgerEventSchema = external_exports.object({
|
|
27815
|
-
protocolVersion: external_exports.literal(protocolVersion),
|
|
27816
|
-
tenantId: uuid14,
|
|
27817
|
-
executionId: uuid14,
|
|
27818
|
-
eventKind: LedgerEventKindSchema,
|
|
27819
|
-
units: external_exports.literal(1),
|
|
27820
|
-
periodStartUtc: utcDateTime2,
|
|
27821
|
-
periodEndUtc: utcDateTime2,
|
|
27822
|
-
occurredAt: utcDateTime2,
|
|
27823
|
-
adjustmentId: uuid14.optional()
|
|
27824
|
-
}).strict().refine(validUsagePeriod, { path: ["periodEndUtc"], message: "Expected one UTC calendar month" }).refine((value) => value.eventKind !== "credit" || value.adjustmentId !== void 0, { path: ["adjustmentId"], message: "Credit requires a unique adjustment ID" });
|
|
27825
|
-
var UsageCountersSchema = external_exports.object({
|
|
27826
|
-
protocolVersion: external_exports.literal(protocolVersion),
|
|
27827
|
-
tenantId: uuid14,
|
|
27828
|
-
periodStartUtc: utcDateTime2,
|
|
27829
|
-
periodEndUtc: utcDateTime2,
|
|
27830
|
-
limitUnits: units,
|
|
27831
|
-
reservedUnits: units,
|
|
27832
|
-
consumedUnits: units,
|
|
27833
|
-
creditedUnits: units
|
|
27834
|
-
}).strict().refine(validUsagePeriod, { path: ["periodEndUtc"], message: "Expected one UTC calendar month" });
|
|
27835
|
-
var OperationErrorSchema = external_exports.object({
|
|
27836
|
-
protocolVersion: external_exports.literal(protocolVersion),
|
|
27837
|
-
code: ErrorCodeSchema,
|
|
27838
|
-
message: external_exports.string().trim().min(1).max(512),
|
|
27839
|
-
retryable: external_exports.boolean(),
|
|
27840
|
-
dispatched: external_exports.boolean(),
|
|
27841
|
-
quotaEffect: external_exports.enum(["none", "reserved", "charged", "released", "credited", "unknown"])
|
|
27842
|
-
}).strict();
|
|
27843
|
-
|
|
27844
27846
|
// agent/src/relay-client.ts
|
|
27845
27847
|
var RelayClientError = class extends Error {
|
|
27846
27848
|
constructor(code) {
|
|
@@ -27853,7 +27855,7 @@ var RelayClientError = class extends Error {
|
|
|
27853
27855
|
var DEFAULT_PROTOCOL_VERSION = 1;
|
|
27854
27856
|
var DEFAULT_CONNECT_TIMEOUT_MS = 1e4;
|
|
27855
27857
|
var DEFAULT_REQUEST_TIMEOUT_MS = 3e4;
|
|
27856
|
-
var DEFAULT_MAX_FRAME_BYTES =
|
|
27858
|
+
var DEFAULT_MAX_FRAME_BYTES = MAX_RELAY_FRAME_BYTES;
|
|
27857
27859
|
var UUID2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
27858
27860
|
var EPOCH = /^[1-9]\d{0,18}$/;
|
|
27859
27861
|
var AGENT_VERSION = /^[A-Za-z0-9._+-]{1,64}$/;
|
|
@@ -28070,7 +28072,7 @@ async function connectOnce(options) {
|
|
|
28070
28072
|
if (!Number.isInteger(protocolVersion2) || protocolVersion2 < 1 || protocolVersion2 > 100) fail3("RELAY_PROTOCOL_INVALID");
|
|
28071
28073
|
const connectTimeoutMs = boundedNumber(options.connectTimeoutMs, DEFAULT_CONNECT_TIMEOUT_MS, 100, 6e4, "CONNECT_TIMEOUT_INVALID");
|
|
28072
28074
|
const requestTimeoutMs = boundedNumber(options.requestTimeoutMs, DEFAULT_REQUEST_TIMEOUT_MS, 100, 30 * 6e4, "REQUEST_TIMEOUT_INVALID");
|
|
28073
|
-
const maxFrameBytes = boundedNumber(options.maxFrameBytes, DEFAULT_MAX_FRAME_BYTES, 1024,
|
|
28075
|
+
const maxFrameBytes = boundedNumber(options.maxFrameBytes, DEFAULT_MAX_FRAME_BYTES, 1024, MAX_RELAY_FRAME_BYTES, "FRAME_LIMIT_INVALID");
|
|
28074
28076
|
agentVersion(options.agentVersion);
|
|
28075
28077
|
if (typeof options.handleRequest !== "function") fail3("HANDLER_INVALID");
|
|
28076
28078
|
const identity = await options.store.load();
|
|
@@ -28975,7 +28977,7 @@ var OptimizationLedger = class _OptimizationLedger {
|
|
|
28975
28977
|
};
|
|
28976
28978
|
|
|
28977
28979
|
// agent/src/main.ts
|
|
28978
|
-
var AGENT_VERSION2 = true ? "0.3.
|
|
28980
|
+
var AGENT_VERSION2 = true ? "0.3.3" : "0.3.2";
|
|
28979
28981
|
function processAlive(pid) {
|
|
28980
28982
|
if (!Number.isInteger(pid) || pid <= 0) return false;
|
|
28981
28983
|
try {
|