local-commander-agent 0.3.4 → 0.3.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "local-commander-agent",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "Windows companion for Local Commander: connect AI clients to local files, approved commands and localhost. Requires https://localcmd.app.",
5
5
  "type": "module",
6
6
  "bin": {
Binary file
Binary file
Binary file
package/runtime/agent.mjs CHANGED
@@ -24481,7 +24481,9 @@ var ClientFrameSchema = external_exports.discriminatedUnion("type", [
24481
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(),
24482
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()
24483
24483
  ]);
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();
24484
+ var TerminalMetricsSchema = external_exports.object({ stdoutBytes: external_exports.number().int().min(0).max(4194304), stderrBytes: external_exports.number().int().min(0).max(4194304), outputTruncated: external_exports.boolean() }).strict();
24485
+ var TERMINAL_METRICS_CAPABILITY = "terminalMetrics";
24486
+ 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}$/), metrics: TerminalMetricsSchema.optional() }).strict();
24485
24487
  var TerminalEventAckSchema = external_exports.object({ type: external_exports.literal("executionResultAck"), protocolVersion: external_exports.literal(1), requestId: uuid8, ok: external_exports.boolean() }).strict();
24486
24488
  function canonicalJson(value) {
24487
24489
  function canonical2(v) {
@@ -26920,9 +26922,7 @@ var NativeTools = class {
26920
26922
  }
26921
26923
  if (call.name === "command_run") {
26922
26924
  const cwd2 = await resolve(call.args.cwd, true), program = this.resolveProgram(call.args.command, workspace);
26923
- const common2 = await this.gitCommonDir(cwd2, workspace, guard);
26924
- const claims2 = writeClaim(workspace.root);
26925
- if (common2) claims2.push({ path: common2, namespace: "git", mode: "write" });
26925
+ const claims2 = writeClaim(cwd2);
26926
26926
  return { call, claims: claims2, execution: { executable: program.executable, args: [...program.prefixArgs ?? [], ...call.args.args], cwd: cwd2 }, run: async (signal, onStarted, onOutput) => {
26927
26927
  const r = await runSupervised(this.options.helperPath, { executable: program.executable, args: [...program.prefixArgs ?? [], ...call.args.args], cwd: cwd2, timeoutMs: call.args.timeoutMs, maxProcesses: 32 }, { signal, maxOutputBytes: 9e4, onStarted, onOutput });
26928
26928
  const { pid: _pid, ...output2 } = r;
@@ -27947,6 +27947,11 @@ var controlPayload = external_exports.object({ binding: ExecutionBindingSchema }
27947
27947
  function failure3(code) {
27948
27948
  return Object.assign(new Error(code), { code });
27949
27949
  }
27950
+ var MAX_METRIC_BYTES = 4194304;
27951
+ function terminalMetrics(result2) {
27952
+ if (!result2) return void 0;
27953
+ return { stdoutBytes: Math.min(Buffer.byteLength(result2.stdout, "utf8"), MAX_METRIC_BYTES), stderrBytes: Math.min(Buffer.byteLength(result2.stderr, "utf8"), MAX_METRIC_BYTES), outputTruncated: result2.stdoutTruncated || result2.stderrTruncated };
27954
+ }
27950
27955
  var NativeRelayBridge = class {
27951
27956
  constructor(runtime, sendTerminal, journal) {
27952
27957
  this.runtime = runtime;
@@ -27982,7 +27987,7 @@ var NativeRelayBridge = class {
27982
27987
  try {
27983
27988
  const binding2 = { tenantId: event.tenantId, deviceId: event.deviceId, grantId: event.grantId, sessionId: event.sessionId, operationId: event.operationId, executionId: id, connectionEpoch: event.connectionEpoch, workspaceGrantId: event.workspaceGrantId, policyVersion: event.policyVersion, payloadHash: event.payloadHash, deadlineAt: event.deadlineAt, ...event.accountId ? { accountId: event.accountId } : {} };
27984
27989
  if (!["finished", "failed", "cancelled", "unknown"].includes(event.state)) continue;
27985
- await this.sendTerminal(binding2, event.state, event.resultCode);
27990
+ await this.sendTerminal(binding2, event.state, event.resultCode, terminalMetrics(event.result));
27986
27991
  await this.journal.markReported(id, event.resultCode);
27987
27992
  } catch {
27988
27993
  } finally {
@@ -28239,7 +28244,8 @@ function validateReady(frame, enrollment, expectedProtocol) {
28239
28244
  protocol(frame.protocolVersion, expectedProtocol);
28240
28245
  if (uuid16(frame.tenantId, "RELAY_HANDSHAKE_INVALID") !== enrollment.tenantId.toLowerCase()) fail3("RELAY_ID_MISMATCH");
28241
28246
  if (uuid16(frame.deviceId, "RELAY_HANDSHAKE_INVALID") !== enrollment.deviceId.toLowerCase()) fail3("RELAY_ID_MISMATCH");
28242
- return epoch2(frame.connectionEpoch);
28247
+ const terminalMetrics2 = Array.isArray(frame.capabilities) && frame.capabilities.includes(TERMINAL_METRICS_CAPABILITY);
28248
+ return { connectionEpoch: epoch2(frame.connectionEpoch), terminalMetrics: terminalMetrics2 };
28243
28249
  }
28244
28250
  function validateRequest(frame, enrollment, expectedProtocol, connectionEpoch) {
28245
28251
  if (frame.type !== "relayFrame") fail3("RELAY_REQUEST_INVALID");
@@ -28332,7 +28338,7 @@ async function connectOnce(options) {
28332
28338
  nonce: challenge.nonce,
28333
28339
  signature
28334
28340
  }, maxFrameBytes);
28335
- const connectionEpoch = validateReady(await waitForMessage(socket, maxFrameBytes, connectTimeoutMs, "RELAY_HANDSHAKE_TIMEOUT"), enrollment, protocolVersion2);
28341
+ const { connectionEpoch, terminalMetrics: terminalMetrics2 } = validateReady(await waitForMessage(socket, maxFrameBytes, connectTimeoutMs, "RELAY_HANDSHAKE_TIMEOUT"), enrollment, protocolVersion2);
28336
28342
  socket.off("message", bufferDuringReady);
28337
28343
  if (handshakeOverflow) fail3("RELAY_FRAME_TOO_LARGE");
28338
28344
  handshakeBuffer.shift();
@@ -28417,10 +28423,10 @@ async function connectOnce(options) {
28417
28423
  heartbeat: () => {
28418
28424
  if (socket.readyState !== wrapper_default.OPEN) fail3("RELAY_SOCKET_CLOSED");
28419
28425
  },
28420
- sendTerminal: (binding2, state, resultCode) => {
28426
+ sendTerminal: (binding2, state, resultCode, metrics) => {
28421
28427
  if (pendingTerminal.size >= 64) return Promise.reject(new RelayClientError("RELAY_PENDING_LIMIT"));
28422
28428
  const requestId = randomUUID5();
28423
- const event = { type: "executionResult", protocolVersion: 1, requestId, tenantId, deviceId, connectionEpoch, binding: binding2, state, resultCode };
28429
+ const event = { type: "executionResult", protocolVersion: 1, requestId, tenantId, deviceId, connectionEpoch, binding: binding2, state, resultCode, ...terminalMetrics2 && metrics ? { metrics } : {} };
28424
28430
  return new Promise((resolve, reject) => {
28425
28431
  const timer = setTimeout(() => {
28426
28432
  pendingTerminal.delete(requestId);
@@ -29195,7 +29201,7 @@ var OptimizationLedger = class _OptimizationLedger {
29195
29201
  };
29196
29202
 
29197
29203
  // agent/src/main.ts
29198
- var AGENT_VERSION2 = true ? "0.3.4" : "0.3.2";
29204
+ var AGENT_VERSION2 = true ? "0.3.5" : "0.3.2";
29199
29205
  function processAlive(pid) {
29200
29206
  if (!Number.isInteger(pid) || pid <= 0) return false;
29201
29207
  try {
@@ -29263,9 +29269,9 @@ async function runAgent(options) {
29263
29269
  }
29264
29270
  const runtime = new NativeRuntime({ journal: options.journal, tools: options.tools, scheduler: new NativeScheduler(), workspaces: () => options.store.loadWorkspaces(Boolean(options.guard)), guard: options.guard, efficiencyLedger: options.efficiencyLedger });
29265
29271
  let connection = null;
29266
- const bridge = new NativeRelayBridge(runtime, (binding2, state, code) => {
29272
+ const bridge = new NativeRelayBridge(runtime, (binding2, state, code, metrics) => {
29267
29273
  if (!connection) throw Error("RELAY_SOCKET_CLOSED");
29268
- return connection.sendTerminal(binding2, state, code);
29274
+ return connection.sendTerminal(binding2, state, code, metrics);
29269
29275
  }, options.journal);
29270
29276
  const connect = options.connect ?? ((connectionOptions) => connectOnce(connectionOptions));
29271
29277
  try {