@agentknight/client 0.9.56 → 0.9.59

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.
@@ -13,7 +13,6 @@ import { join, resolve } from "node:path";
13
13
  import { z } from "zod";
14
14
  import { DataDirectoryLease } from "@agentknight/sdk/runtime";
15
15
  import {
16
- PEER_CHAT_TIMEOUT_MS,
17
16
  PeerChatRequestSchema,
18
17
  PeerChatResultSchema
19
18
  } from "@agentknight/sdk/runtime";
@@ -54,7 +53,6 @@ var ResponseSchema = z.discriminatedUnion("ok", [
54
53
  var MAX_MESSAGE_BYTES = 32 * 1024;
55
54
  var MAX_PEER_REQUEST_BYTES = 128 * 1024;
56
55
  var MAX_PEER_RESPONSE_BYTES = 2 * 1024 * 1024;
57
- var PEER_RESPONSE_BUFFER_MS = 5e3;
58
56
  var MAX_SOCKET_PATH_BYTES = 103;
59
57
  var RuntimeCommandError = class extends Error {
60
58
  };
@@ -90,7 +88,7 @@ async function requestPeerChat(descriptor, request, signal) {
90
88
  return exchangeRuntime(descriptor, { token: descriptor.token, command: "peer-chat", payload: payload.data }, (response) => {
91
89
  if (response.reply === void 0) throw new Error("Agent returned no peer-chat reply.");
92
90
  return response.reply;
93
- }, PEER_CHAT_TIMEOUT_MS + PEER_RESPONSE_BUFFER_MS, MAX_PEER_RESPONSE_BYTES, signal);
91
+ }, 0, MAX_PEER_RESPONSE_BYTES, signal);
94
92
  }
95
93
  function exchangeRuntime(descriptor, request, select, timeoutMs, maxResponseBytes, signal) {
96
94
  signal?.throwIfAborted();
@@ -99,7 +97,6 @@ function exchangeRuntime(descriptor, request, select, timeoutMs, maxResponseByte
99
97
  let data = "";
100
98
  let completed = false;
101
99
  const cleanup = () => {
102
- clearTimeout(timeout);
103
100
  signal?.removeEventListener("abort", abort);
104
101
  };
105
102
  const fail = (error) => {
@@ -111,8 +108,7 @@ function exchangeRuntime(descriptor, request, select, timeoutMs, maxResponseByte
111
108
  };
112
109
  const abort = () => fail(signal?.reason instanceof Error ? signal.reason : new Error("Peer chat cancelled."));
113
110
  const onTimeout = () => fail(new Error(`Agent ${request.command} request timed out.`));
114
- const timeout = request.command === "peer-chat" ? setTimeout(onTimeout, timeoutMs) : void 0;
115
- if (request.command !== "peer-chat") socket.setTimeout(timeoutMs, onTimeout);
111
+ socket.setTimeout(timeoutMs, onTimeout);
116
112
  signal?.addEventListener("abort", abort, { once: true });
117
113
  socket.on("error", fail);
118
114
  socket.on("connect", () => socket.write(`${JSON.stringify(request)}
@@ -155,14 +151,12 @@ async function runPeerChat(handler, request, controller) {
155
151
  abort = () => reject(signal.reason);
156
152
  signal.addEventListener("abort", abort, { once: true });
157
153
  });
158
- const timeout = setTimeout(() => controller.abort(new Error("Peer chat timed out.")), PEER_CHAT_TIMEOUT_MS);
159
154
  try {
160
155
  return await Promise.race([Promise.resolve().then(() => {
161
156
  signal.throwIfAborted();
162
157
  return handler(request, signal);
163
158
  }), cancelled]);
164
159
  } finally {
165
- clearTimeout(timeout);
166
160
  signal.removeEventListener("abort", abort);
167
161
  }
168
162
  }
@@ -240,7 +234,7 @@ async function startRuntimeControl(options) {
240
234
  if (options.runPeerChat === void 0) throw new Error("Peer chat is not available on this Agent.");
241
235
  const controller = new AbortController();
242
236
  peerConnections.set(socket, controller);
243
- socket.setTimeout(PEER_CHAT_TIMEOUT_MS + PEER_RESPONSE_BUFFER_MS);
237
+ socket.setTimeout(0);
244
238
  try {
245
239
  reply = PeerChatResultSchema.parse(await runPeerChat(options.runPeerChat, request.payload, controller));
246
240
  } finally {
@@ -5,7 +5,7 @@ import {
5
5
  PcEnrollmentIdSchema,
6
6
  PcEnrollmentStartRequestSchema,
7
7
  PcEnrollmentVerifierRequestSchema
8
- } from "./chunk-KW4VLCH7.js";
8
+ } from "./chunk-UVAF42HQ.js";
9
9
 
10
10
  // src/aad-relay-login.ts
11
11
  import { createHash as createHash2 } from "node:crypto";
@@ -18,11 +18,12 @@ import { brotliCompressSync, brotliDecompressSync } from "node:zlib";
18
18
  import { z } from "zod";
19
19
  var STORE_MESSAGES = {
20
20
  unavailable: "Unlock your operating system credential store and restart AgentKnight. No file-based credential fallback is available.",
21
+ linuxUnavailable: "Start or unlock a Secret Service keyring (such as GNOME Keyring) in the same user's D-Bus session, then retry. No file-based or in-memory credential fallback is available.",
21
22
  invalid: "The saved Relay credential is invalid. Recover it in your operating system credential manager before signing in.",
22
23
  conflict: "A different Relay account or enrollment is already saved for this PC. Resolve it before signing in again.",
23
24
  verification: "The operating system credential store did not retain the credential. Unlock it and restart AgentKnight.",
24
25
  address: "Use an HTTPS Relay origin without a path, credentials, query, or fragment. HTTP is allowed only for literal loopback addresses.",
25
- unsupported: "Microsoft sign-in requires Windows Credential Manager or macOS Keychain. This operating system is not supported.",
26
+ unsupported: "Microsoft sign-in requires Windows Credential Manager, macOS Keychain, or Linux Secret Service. This operating system is not supported.",
26
27
  tooLarge: "The Relay credential exceeds the operating system credential store capacity. Existing credentials were not changed. Contact your Relay administrator."
27
28
  };
28
29
  var MAX_RECORD_BYTES = 32 * 1024;
@@ -36,6 +37,9 @@ var RelayCredentialStoreError = class extends Error {
36
37
  }
37
38
  code;
38
39
  };
40
+ function unavailableStoreError() {
41
+ return new RelayCredentialStoreError(platform() === "linux" ? "linuxUnavailable" : "unavailable");
42
+ }
39
43
  function normalizeRelayOrigin(value) {
40
44
  try {
41
45
  const url = new URL(value);
@@ -136,7 +140,7 @@ var OsRelayCredentialStore = class {
136
140
  }
137
141
  return validateRelayCredentialSlots(value, this.relayUrl, this.machineId);
138
142
  } catch (error) {
139
- throw error instanceof RelayCredentialStoreError ? error : new RelayCredentialStoreError("unavailable");
143
+ throw error instanceof RelayCredentialStoreError ? error : unavailableStoreError();
140
144
  }
141
145
  }
142
146
  savePending(credential) {
@@ -201,7 +205,7 @@ var OsRelayCredentialStore = class {
201
205
  try {
202
206
  return await action();
203
207
  } catch (error) {
204
- throw error instanceof RelayCredentialStoreError ? error : new RelayCredentialStoreError("unavailable");
208
+ throw error instanceof RelayCredentialStoreError ? error : unavailableStoreError();
205
209
  } finally {
206
210
  release();
207
211
  if (transactions.get(this.key) === completion) transactions.delete(this.key);
@@ -210,7 +214,7 @@ var OsRelayCredentialStore = class {
210
214
  };
211
215
  async function createRelayCredentialStore(relayUrl, machineId) {
212
216
  const os = platform();
213
- if (os !== "win32" && os !== "darwin") throw new RelayCredentialStoreError("unsupported");
217
+ if (os !== "win32" && os !== "darwin" && os !== "linux") throw new RelayCredentialStoreError("unsupported");
214
218
  const origin = normalizeRelayOrigin(relayUrl);
215
219
  if (!PcEnrollmentStartRequestSchema.shape.machineId.safeParse(machineId).success) {
216
220
  throw new RelayCredentialStoreError("invalid");
@@ -218,7 +222,7 @@ async function createRelayCredentialStore(relayUrl, machineId) {
218
222
  const username = createHash("sha256").update(JSON.stringify([origin, machineId])).digest("hex");
219
223
  try {
220
224
  const { AsyncEntry } = await import("@napi-rs/keyring");
221
- const entry = new AsyncEntry("AgentKnight Relay", username);
225
+ const entry = os === "linux" ? new AsyncEntry("AgentKnight Relay", username, { linux: { store: "secret-service" } }) : new AsyncEntry("AgentKnight Relay", username);
222
226
  return new OsRelayCredentialStore(
223
227
  entry,
224
228
  username,
@@ -227,7 +231,7 @@ async function createRelayCredentialStore(relayUrl, machineId) {
227
231
  os === "win32" ? WINDOWS_MAX_SECRET_BYTES : MAX_RECORD_BYTES
228
232
  );
229
233
  } catch {
230
- throw new RelayCredentialStoreError("unavailable");
234
+ throw unavailableStoreError();
231
235
  }
232
236
  }
233
237
 
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  SESSION_TIMELINE_PAGE_SIZE
4
- } from "./chunk-KW4VLCH7.js";
4
+ } from "./chunk-UVAF42HQ.js";
5
5
 
6
6
  // src/local-sessions.ts
7
7
  import { supportsAgentSelection, codingAgentPresentation } from "@agentknight/sdk";
@@ -7,7 +7,7 @@ import {
7
7
  requestPeerChat,
8
8
  requestRuntime,
9
9
  startRuntimeControl
10
- } from "./chunk-WZIU4HVH.js";
10
+ } from "./chunk-WMAAFZJ3.js";
11
11
  import "./chunk-SPZWIFFP.js";
12
12
  export {
13
13
  RuntimeCommandError,