@byok-sdk/client 0.9.1 → 0.10.0

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.
@@ -6057,13 +6057,15 @@ var AuthManager = class {
6057
6057
  }
6058
6058
  const keyPair = existing ? { privateKey: importPrivateKeyPem(existing.devicePrivateKeyPem), publicKeyBase64Url: existing.devicePublicKey } : generateDeviceKeyPair();
6059
6059
  const url = new URL(BYOK_PAIR_PATH, toHttpBase(this.opts.serverUrl));
6060
+ const machineId = await this.opts.machineId?.();
6060
6061
  const res = await fetch(url, {
6061
6062
  method: "POST",
6062
6063
  headers: { "content-type": "application/json" },
6063
6064
  body: JSON.stringify({
6064
6065
  pairingCode,
6065
6066
  deviceName: this.opts.deviceName ?? os__default.hostname(),
6066
- devicePublicKey: keyPair.publicKeyBase64Url
6067
+ devicePublicKey: keyPair.publicKeyBase64Url,
6068
+ ...machineId === void 0 ? {} : { machineId }
6067
6069
  })
6068
6070
  });
6069
6071
  if (!res.ok) {
@@ -6372,6 +6374,67 @@ var BlobClient = class {
6372
6374
  throw lastFailure;
6373
6375
  }
6374
6376
  };
6377
+ var DEFAULT_TIMEOUT_MS2 = 2e3;
6378
+ var DARWIN_UUID_RE = /"IOPlatformUUID"\s*=\s*"([^"]+)"/u;
6379
+ var WIN32_GUID_RE = /MachineGuid\s+REG_SZ\s+(\S+)/u;
6380
+ var LINUX_MACHINE_ID_PATHS = ["/etc/machine-id", "/var/lib/dbus/machine-id"];
6381
+ async function probeDarwin(run) {
6382
+ const result = await run("ioreg", ["-rd1", "-c", "IOPlatformExpertDevice"]);
6383
+ if (result.exitCode !== 0) return void 0;
6384
+ return DARWIN_UUID_RE.exec(result.stdout)?.[1];
6385
+ }
6386
+ async function probeLinux(readFile3) {
6387
+ for (const path41 of LINUX_MACHINE_ID_PATHS) {
6388
+ try {
6389
+ const contents = (await readFile3(path41)).trim();
6390
+ if (contents.length > 0) return contents;
6391
+ } catch {
6392
+ }
6393
+ }
6394
+ return void 0;
6395
+ }
6396
+ async function probeWin32(run) {
6397
+ const result = await run("reg", [
6398
+ "query",
6399
+ "HKLM\\SOFTWARE\\Microsoft\\Cryptography",
6400
+ "/v",
6401
+ "MachineGuid"
6402
+ ]);
6403
+ if (result.exitCode !== 0) return void 0;
6404
+ return WIN32_GUID_RE.exec(result.stdout)?.[1];
6405
+ }
6406
+ async function withTimeout(probe, timeoutMs) {
6407
+ let timer;
6408
+ const expiry = new Promise((resolve) => {
6409
+ timer = setTimeout(() => resolve(void 0), timeoutMs);
6410
+ timer.unref?.();
6411
+ });
6412
+ try {
6413
+ return await Promise.race([probe, expiry]);
6414
+ } finally {
6415
+ if (timer !== void 0) clearTimeout(timer);
6416
+ }
6417
+ }
6418
+ async function resolveMachineId(options) {
6419
+ const platform = options.platform ?? process.platform;
6420
+ const run = options.run ?? runDeviceCommand;
6421
+ const readFile3 = options.readFile ?? ((path41) => fs12.readFile(path41, "utf8"));
6422
+ let probe;
6423
+ if (platform === "darwin") probe = probeDarwin(run);
6424
+ else if (platform === "linux") probe = probeLinux(readFile3);
6425
+ else if (platform === "win32") probe = probeWin32(run);
6426
+ if (probe === void 0) return void 0;
6427
+ let raw;
6428
+ try {
6429
+ raw = await withTimeout(probe, options.timeoutMs ?? DEFAULT_TIMEOUT_MS2);
6430
+ } catch {
6431
+ return void 0;
6432
+ }
6433
+ const trimmed = raw?.trim();
6434
+ if (trimmed === void 0 || trimmed.length === 0) return void 0;
6435
+ return createHash("sha256").update(`${options.productId}
6436
+ ${trimmed}`, "utf8").digest("hex");
6437
+ }
6375
6438
  var PRESENCE_HINTS_CAPABILITY = "presence.hints";
6376
6439
  var CapabilityDiscoveryError = class extends Error {
6377
6440
  constructor(message, options) {
@@ -11005,7 +11068,7 @@ async function readPinnedFile(directory, fileName, maxBytes = AGENT_MEMORY_MAX_F
11005
11068
  });
11006
11069
  }
11007
11070
  }
11008
- async function readFile(context, relativePath, maxBytes = AGENT_MEMORY_MAX_FILE_BYTES) {
11071
+ async function readFile2(context, relativePath, maxBytes = AGENT_MEMORY_MAX_FILE_BYTES) {
11009
11072
  if (context.filesystem !== void 0) return context.filesystem.read(relativePath, maxBytes);
11010
11073
  return withMemoryParent(context, relativePath, (directory, fileName) => readPinnedFile(directory, fileName, maxBytes));
11011
11074
  }
@@ -11173,7 +11236,7 @@ var AgentMemoryService = class {
11173
11236
  const context = taskContext(this.input);
11174
11237
  const relativePath = validateAgentMemoryPath(input.path);
11175
11238
  if (input.ifRevision !== void 0 && !revision(input.ifRevision)) throw new AgentMemoryError("ifRevision must be a sha256 content revision");
11176
- const current = await readFile(context, relativePath);
11239
+ const current = await readFile2(context, relativePath);
11177
11240
  if (!current.exists) throw new AgentMemoryError("memory file does not exist");
11178
11241
  if (input.ifRevision !== void 0 && current.revision !== input.ifRevision) throw new AgentMemoryRevisionConflictError(input.ifRevision, current.revision);
11179
11242
  const auditWarning = await exclusiveAgentMemoryHome(context.canonicalHome, () => recordAuditWarning(context, "recall", {
@@ -11260,7 +11323,7 @@ async function captureAgentMemorySnapshot(input) {
11260
11323
  const files = [];
11261
11324
  let totalBytes = 0;
11262
11325
  for (const relativePath of paths) {
11263
- const current = await readFile(context, relativePath);
11326
+ const current = await readFile2(context, relativePath);
11264
11327
  if (!current.exists) {
11265
11328
  if (relativePath === "MEMORY.md") throw new AgentMemoryError("MEMORY.md disappeared before snapshot");
11266
11329
  continue;
@@ -16242,6 +16305,7 @@ function buildDaemonWithAdapters(config, adapters, overrides = {}, assertionProb
16242
16305
  serverUrl: config.serverUrl,
16243
16306
  store,
16244
16307
  deviceName: config.deviceName,
16308
+ machineId: config.machineId ?? (() => resolveMachineId({ productId: config.productId })),
16245
16309
  onRevoked: () => {
16246
16310
  connectionState = "revoked";
16247
16311
  }
@@ -17540,7 +17604,7 @@ function connectAndHandshake(endpoint, token, opts) {
17540
17604
  });
17541
17605
  });
17542
17606
  }
17543
- function withTimeout(promise, ms, message) {
17607
+ function withTimeout2(promise, ms, message) {
17544
17608
  return new Promise((resolve, reject) => {
17545
17609
  const timer = setTimeout(() => reject(new Error(message)), ms);
17546
17610
  timer.unref?.();
@@ -17619,7 +17683,7 @@ function createControlClient(socket, reader, opts) {
17619
17683
  async request(method, params) {
17620
17684
  if (closed) throw new Error("control connection is closed");
17621
17685
  const { promise } = send(method, params);
17622
- const result = await withTimeout(promise, opts.requestTimeoutMs ?? 1e4, `control request "${method}" timed out`);
17686
+ const result = await withTimeout2(promise, opts.requestTimeoutMs ?? 1e4, `control request "${method}" timed out`);
17623
17687
  return result;
17624
17688
  },
17625
17689
  subscribe(method, params, onEvent) {
@@ -17729,7 +17793,7 @@ ${args.map((a) => ` ${plistString(a)}`).join("\n")}
17729
17793
  }
17730
17794
  function createLaunchdLifecycle(def, deps = {}) {
17731
17795
  const run = deps.run ?? defaultRunner;
17732
- const fs30 = deps.fs ?? promises;
17796
+ const fs31 = deps.fs ?? promises;
17733
17797
  const homedir = deps.homedir ?? (() => os__default.homedir());
17734
17798
  const getuid = deps.getuid ?? (() => {
17735
17799
  if (typeof process.getuid !== "function") {
@@ -17743,7 +17807,7 @@ function createLaunchdLifecycle(def, deps = {}) {
17743
17807
  const serviceTarget = () => `${domainTarget()}/${label}`;
17744
17808
  async function fileExists(p) {
17745
17809
  try {
17746
- await fs30.stat(p);
17810
+ await fs31.stat(p);
17747
17811
  return true;
17748
17812
  } catch {
17749
17813
  return false;
@@ -17751,9 +17815,9 @@ function createLaunchdLifecycle(def, deps = {}) {
17751
17815
  }
17752
17816
  async function writePlist(program) {
17753
17817
  const xml = generateLaunchdPlist({ label, program, logDir: def.logDir });
17754
- await fs30.mkdir(path3__default.dirname(plistPath()), { recursive: true });
17755
- await fs30.mkdir(def.logDir, { recursive: true });
17756
- await fs30.writeFile(plistPath(), xml, "utf8");
17818
+ await fs31.mkdir(path3__default.dirname(plistPath()), { recursive: true });
17819
+ await fs31.mkdir(def.logDir, { recursive: true });
17820
+ await fs31.writeFile(plistPath(), xml, "utf8");
17757
17821
  }
17758
17822
  async function install(opts = {}) {
17759
17823
  await writePlist(opts.program ?? def.program);
@@ -17764,7 +17828,7 @@ function createLaunchdLifecycle(def, deps = {}) {
17764
17828
  }
17765
17829
  async function uninstall() {
17766
17830
  await runIdempotent(run, "launchctl", ["bootout", serviceTarget()], "launchctl bootout", LAUNCHD_NOT_LOADED);
17767
- await fs30.rm(plistPath(), { force: true });
17831
+ await fs31.rm(plistPath(), { force: true });
17768
17832
  }
17769
17833
  async function start() {
17770
17834
  if (!await fileExists(plistPath())) {
@@ -17848,14 +17912,14 @@ WantedBy=default.target
17848
17912
  }
17849
17913
  function createSystemdLifecycle(def, deps = {}) {
17850
17914
  const run = deps.run ?? defaultRunner;
17851
- const fs30 = deps.fs ?? promises;
17915
+ const fs31 = deps.fs ?? promises;
17852
17916
  const homedir = deps.homedir ?? (() => os__default.homedir());
17853
17917
  const name = sanitizeServiceName(def.name);
17854
17918
  const unitName = `${name}.service`;
17855
17919
  const unitPath = () => path3__default.join(homedir(), ".config", "systemd", "user", unitName);
17856
17920
  async function fileExists(p) {
17857
17921
  try {
17858
- await fs30.stat(p);
17922
+ await fs31.stat(p);
17859
17923
  return true;
17860
17924
  } catch {
17861
17925
  return false;
@@ -17863,9 +17927,9 @@ function createSystemdLifecycle(def, deps = {}) {
17863
17927
  }
17864
17928
  async function writeUnit(program) {
17865
17929
  const unit = generateSystemdUnit({ name, displayName: def.displayName ?? def.name, program, logDir: def.logDir });
17866
- await fs30.mkdir(path3__default.dirname(unitPath()), { recursive: true });
17867
- await fs30.mkdir(def.logDir, { recursive: true });
17868
- await fs30.writeFile(unitPath(), unit, "utf8");
17930
+ await fs31.mkdir(path3__default.dirname(unitPath()), { recursive: true });
17931
+ await fs31.mkdir(def.logDir, { recursive: true });
17932
+ await fs31.writeFile(unitPath(), unit, "utf8");
17869
17933
  }
17870
17934
  async function install(opts = {}) {
17871
17935
  await writeUnit(opts.program ?? def.program);
@@ -17874,7 +17938,7 @@ function createSystemdLifecycle(def, deps = {}) {
17874
17938
  }
17875
17939
  async function uninstall() {
17876
17940
  await runIdempotent(run, "systemctl", ["--user", "disable", "--now", unitName], "systemctl disable --now", SYSTEMD_NOT_LOADED);
17877
- await fs30.rm(unitPath(), { force: true });
17941
+ await fs31.rm(unitPath(), { force: true });
17878
17942
  await run("systemctl", ["--user", "daemon-reload"]);
17879
17943
  }
17880
17944
  async function start() {
@@ -17937,7 +18001,7 @@ ${argXml}${cwdXml}
17937
18001
  }
17938
18002
  function createWinswLifecycle(def, deps = {}) {
17939
18003
  const run = deps.run ?? defaultRunner;
17940
- const fs30 = deps.fs ?? promises;
18004
+ const fs31 = deps.fs ?? promises;
17941
18005
  const windows = def.windows;
17942
18006
  if (!windows) {
17943
18007
  throw new Error("WinSW service lifecycle requires `ServiceDefinition.windows.winswBin` (the product-bundled WinSW executable path)");
@@ -17949,7 +18013,7 @@ function createWinswLifecycle(def, deps = {}) {
17949
18013
  const xmlPath = path3__default.join(installDir, `${id}.xml`);
17950
18014
  async function fileExists(p) {
17951
18015
  try {
17952
- await fs30.stat(p);
18016
+ await fs31.stat(p);
17953
18017
  return true;
17954
18018
  } catch {
17955
18019
  return false;
@@ -17957,10 +18021,10 @@ function createWinswLifecycle(def, deps = {}) {
17957
18021
  }
17958
18022
  async function writeFiles(program) {
17959
18023
  const xml = generateWinswXml({ id, displayName: def.displayName ?? def.name, program, logDir: def.logDir });
17960
- await fs30.mkdir(installDir, { recursive: true });
17961
- await fs30.mkdir(def.logDir, { recursive: true });
17962
- await fs30.copyFile(winswBin, exePath);
17963
- await fs30.writeFile(xmlPath, xml, "utf8");
18024
+ await fs31.mkdir(installDir, { recursive: true });
18025
+ await fs31.mkdir(def.logDir, { recursive: true });
18026
+ await fs31.copyFile(winswBin, exePath);
18027
+ await fs31.writeFile(xmlPath, xml, "utf8");
17964
18028
  }
17965
18029
  async function install(opts = {}) {
17966
18030
  await writeFiles(opts.program ?? def.program);
@@ -17970,8 +18034,8 @@ function createWinswLifecycle(def, deps = {}) {
17970
18034
  async function uninstall() {
17971
18035
  await runIdempotent(run, exePath, ["stop"], "winsw stop", WINSW_NOT_INSTALLED);
17972
18036
  await runIdempotent(run, exePath, ["uninstall"], "winsw uninstall", WINSW_NOT_INSTALLED);
17973
- await fs30.rm(exePath, { force: true });
17974
- await fs30.rm(xmlPath, { force: true });
18037
+ await fs31.rm(exePath, { force: true });
18038
+ await fs31.rm(xmlPath, { force: true });
17975
18039
  }
17976
18040
  async function start() {
17977
18041
  if (!await fileExists(xmlPath)) {
@@ -18016,7 +18080,7 @@ function createServiceLifecycle(def, opts = {}) {
18016
18080
 
18017
18081
  // src/bin/official-release.ts
18018
18082
  var OFFICIAL_LOCAL_AGENT_RELEASE = resolveLocalAgentReleaseIdentity({
18019
- version: "0.9.1"
18083
+ version: "0.10.0"
18020
18084
  });
18021
18085
 
18022
18086
  // src/bin/config.ts