@byok-sdk/client 0.9.1 → 0.10.1

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;
@@ -12776,6 +12839,7 @@ var TaskRunner = class {
12776
12839
  gitLease,
12777
12840
  gitBaseline,
12778
12841
  summaryParts: [],
12842
+ finalTextParts: [],
12779
12843
  batcher: new ProgressBatcher(
12780
12844
  (seq, events) => {
12781
12845
  const projected = active.egressEnabled ? this.deps.agentEgress?.projectLatestValue({
@@ -13081,6 +13145,9 @@ var TaskRunner = class {
13081
13145
  if (event.type === "usage") {
13082
13146
  active.lastUsage = event;
13083
13147
  }
13148
+ if (event.type === "tool_use" || event.type === "tool_result" || event.type === "needs_approval") {
13149
+ active.finalTextParts.length = 0;
13150
+ }
13084
13151
  if (event.type === "needs_approval") {
13085
13152
  active.batcher.flush();
13086
13153
  const { taskId } = active;
@@ -13114,7 +13181,8 @@ var TaskRunner = class {
13114
13181
  this.sendAgentMessageRecord(outbox, record);
13115
13182
  return;
13116
13183
  }
13117
- const body = finalOutput.trim();
13184
+ const finalTextRun = active.finalTextParts.join("").trim();
13185
+ const body = finalTextRun !== "" ? finalTextRun : finalOutput.trim();
13118
13186
  if (outbox === void 0 || active.agentRef === void 0) {
13119
13187
  active.pendingMessageCompletion = void 0;
13120
13188
  await this.fail(active.taskId, "required Agent message lane is unavailable for this task", false);
@@ -13158,6 +13226,7 @@ var TaskRunner = class {
13158
13226
  }
13159
13227
  if (event.type === "progress") {
13160
13228
  active.summaryParts.push(event.text);
13229
+ active.finalTextParts.push(event.text);
13161
13230
  }
13162
13231
  if (event.type === "artifact") {
13163
13232
  if (active.agentRef !== void 0 && this.deps.agentEgress !== void 0) {
@@ -16242,6 +16311,7 @@ function buildDaemonWithAdapters(config, adapters, overrides = {}, assertionProb
16242
16311
  serverUrl: config.serverUrl,
16243
16312
  store,
16244
16313
  deviceName: config.deviceName,
16314
+ machineId: config.machineId ?? (() => resolveMachineId({ productId: config.productId })),
16245
16315
  onRevoked: () => {
16246
16316
  connectionState = "revoked";
16247
16317
  }
@@ -17540,7 +17610,7 @@ function connectAndHandshake(endpoint, token, opts) {
17540
17610
  });
17541
17611
  });
17542
17612
  }
17543
- function withTimeout(promise, ms, message) {
17613
+ function withTimeout2(promise, ms, message) {
17544
17614
  return new Promise((resolve, reject) => {
17545
17615
  const timer = setTimeout(() => reject(new Error(message)), ms);
17546
17616
  timer.unref?.();
@@ -17619,7 +17689,7 @@ function createControlClient(socket, reader, opts) {
17619
17689
  async request(method, params) {
17620
17690
  if (closed) throw new Error("control connection is closed");
17621
17691
  const { promise } = send(method, params);
17622
- const result = await withTimeout(promise, opts.requestTimeoutMs ?? 1e4, `control request "${method}" timed out`);
17692
+ const result = await withTimeout2(promise, opts.requestTimeoutMs ?? 1e4, `control request "${method}" timed out`);
17623
17693
  return result;
17624
17694
  },
17625
17695
  subscribe(method, params, onEvent) {
@@ -17729,7 +17799,7 @@ ${args.map((a) => ` ${plistString(a)}`).join("\n")}
17729
17799
  }
17730
17800
  function createLaunchdLifecycle(def, deps = {}) {
17731
17801
  const run = deps.run ?? defaultRunner;
17732
- const fs30 = deps.fs ?? promises;
17802
+ const fs31 = deps.fs ?? promises;
17733
17803
  const homedir = deps.homedir ?? (() => os__default.homedir());
17734
17804
  const getuid = deps.getuid ?? (() => {
17735
17805
  if (typeof process.getuid !== "function") {
@@ -17743,7 +17813,7 @@ function createLaunchdLifecycle(def, deps = {}) {
17743
17813
  const serviceTarget = () => `${domainTarget()}/${label}`;
17744
17814
  async function fileExists(p) {
17745
17815
  try {
17746
- await fs30.stat(p);
17816
+ await fs31.stat(p);
17747
17817
  return true;
17748
17818
  } catch {
17749
17819
  return false;
@@ -17751,9 +17821,9 @@ function createLaunchdLifecycle(def, deps = {}) {
17751
17821
  }
17752
17822
  async function writePlist(program) {
17753
17823
  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");
17824
+ await fs31.mkdir(path3__default.dirname(plistPath()), { recursive: true });
17825
+ await fs31.mkdir(def.logDir, { recursive: true });
17826
+ await fs31.writeFile(plistPath(), xml, "utf8");
17757
17827
  }
17758
17828
  async function install(opts = {}) {
17759
17829
  await writePlist(opts.program ?? def.program);
@@ -17764,7 +17834,7 @@ function createLaunchdLifecycle(def, deps = {}) {
17764
17834
  }
17765
17835
  async function uninstall() {
17766
17836
  await runIdempotent(run, "launchctl", ["bootout", serviceTarget()], "launchctl bootout", LAUNCHD_NOT_LOADED);
17767
- await fs30.rm(plistPath(), { force: true });
17837
+ await fs31.rm(plistPath(), { force: true });
17768
17838
  }
17769
17839
  async function start() {
17770
17840
  if (!await fileExists(plistPath())) {
@@ -17848,14 +17918,14 @@ WantedBy=default.target
17848
17918
  }
17849
17919
  function createSystemdLifecycle(def, deps = {}) {
17850
17920
  const run = deps.run ?? defaultRunner;
17851
- const fs30 = deps.fs ?? promises;
17921
+ const fs31 = deps.fs ?? promises;
17852
17922
  const homedir = deps.homedir ?? (() => os__default.homedir());
17853
17923
  const name = sanitizeServiceName(def.name);
17854
17924
  const unitName = `${name}.service`;
17855
17925
  const unitPath = () => path3__default.join(homedir(), ".config", "systemd", "user", unitName);
17856
17926
  async function fileExists(p) {
17857
17927
  try {
17858
- await fs30.stat(p);
17928
+ await fs31.stat(p);
17859
17929
  return true;
17860
17930
  } catch {
17861
17931
  return false;
@@ -17863,9 +17933,9 @@ function createSystemdLifecycle(def, deps = {}) {
17863
17933
  }
17864
17934
  async function writeUnit(program) {
17865
17935
  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");
17936
+ await fs31.mkdir(path3__default.dirname(unitPath()), { recursive: true });
17937
+ await fs31.mkdir(def.logDir, { recursive: true });
17938
+ await fs31.writeFile(unitPath(), unit, "utf8");
17869
17939
  }
17870
17940
  async function install(opts = {}) {
17871
17941
  await writeUnit(opts.program ?? def.program);
@@ -17874,7 +17944,7 @@ function createSystemdLifecycle(def, deps = {}) {
17874
17944
  }
17875
17945
  async function uninstall() {
17876
17946
  await runIdempotent(run, "systemctl", ["--user", "disable", "--now", unitName], "systemctl disable --now", SYSTEMD_NOT_LOADED);
17877
- await fs30.rm(unitPath(), { force: true });
17947
+ await fs31.rm(unitPath(), { force: true });
17878
17948
  await run("systemctl", ["--user", "daemon-reload"]);
17879
17949
  }
17880
17950
  async function start() {
@@ -17937,7 +18007,7 @@ ${argXml}${cwdXml}
17937
18007
  }
17938
18008
  function createWinswLifecycle(def, deps = {}) {
17939
18009
  const run = deps.run ?? defaultRunner;
17940
- const fs30 = deps.fs ?? promises;
18010
+ const fs31 = deps.fs ?? promises;
17941
18011
  const windows = def.windows;
17942
18012
  if (!windows) {
17943
18013
  throw new Error("WinSW service lifecycle requires `ServiceDefinition.windows.winswBin` (the product-bundled WinSW executable path)");
@@ -17949,7 +18019,7 @@ function createWinswLifecycle(def, deps = {}) {
17949
18019
  const xmlPath = path3__default.join(installDir, `${id}.xml`);
17950
18020
  async function fileExists(p) {
17951
18021
  try {
17952
- await fs30.stat(p);
18022
+ await fs31.stat(p);
17953
18023
  return true;
17954
18024
  } catch {
17955
18025
  return false;
@@ -17957,10 +18027,10 @@ function createWinswLifecycle(def, deps = {}) {
17957
18027
  }
17958
18028
  async function writeFiles(program) {
17959
18029
  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");
18030
+ await fs31.mkdir(installDir, { recursive: true });
18031
+ await fs31.mkdir(def.logDir, { recursive: true });
18032
+ await fs31.copyFile(winswBin, exePath);
18033
+ await fs31.writeFile(xmlPath, xml, "utf8");
17964
18034
  }
17965
18035
  async function install(opts = {}) {
17966
18036
  await writeFiles(opts.program ?? def.program);
@@ -17970,8 +18040,8 @@ function createWinswLifecycle(def, deps = {}) {
17970
18040
  async function uninstall() {
17971
18041
  await runIdempotent(run, exePath, ["stop"], "winsw stop", WINSW_NOT_INSTALLED);
17972
18042
  await runIdempotent(run, exePath, ["uninstall"], "winsw uninstall", WINSW_NOT_INSTALLED);
17973
- await fs30.rm(exePath, { force: true });
17974
- await fs30.rm(xmlPath, { force: true });
18043
+ await fs31.rm(exePath, { force: true });
18044
+ await fs31.rm(xmlPath, { force: true });
17975
18045
  }
17976
18046
  async function start() {
17977
18047
  if (!await fileExists(xmlPath)) {
@@ -18016,7 +18086,7 @@ function createServiceLifecycle(def, opts = {}) {
18016
18086
 
18017
18087
  // src/bin/official-release.ts
18018
18088
  var OFFICIAL_LOCAL_AGENT_RELEASE = resolveLocalAgentReleaseIdentity({
18019
- version: "0.9.1"
18089
+ version: "0.10.1"
18020
18090
  });
18021
18091
 
18022
18092
  // src/bin/config.ts