@byok-sdk/client 0.4.2 → 0.5.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.
package/README.md CHANGED
@@ -63,6 +63,24 @@ validated registry. Only those logical IDs are advertised in `conn.hello`
63
63
  and hosted presence; command, args, environment, headers, and credentials
64
64
  remain local.
65
65
 
66
+ Hosted deployments that enforce an activity-ingress byte ceiling should inject
67
+ the same ceiling into the daemon. The byte count is the UTF-8 length of
68
+ `JSON.stringify(events)`; it does not include envelope or transport overhead.
69
+ One event that cannot fit fails the task locally without truncation or network
70
+ delivery.
71
+
72
+ ```ts
73
+ createDaemon({
74
+ // ...normal device and transport configuration
75
+ progressBatch: {
76
+ maxBatchBytes: 64 * 1024,
77
+ },
78
+ });
79
+ ```
80
+
81
+ The value is intentionally host-owned and has no SDK default because it is a
82
+ deployment/read-model policy, not a frozen protocol limit.
83
+
66
84
  For a concrete private host composition, see the
67
85
  [`examples/salesko-connector-broker`](../../examples/salesko-connector-broker)
68
86
  reference. It keeps `@byok-sdk/client` credential-blind while combining
@@ -8275,6 +8275,11 @@ function createStatfsFreeBytesProvider(dir) {
8275
8275
  var BASE_PLATFORM_ALLOWLIST = [
8276
8276
  "PATH",
8277
8277
  "HOME",
8278
+ // macOS credential-store discovery used by subscription-authenticated
8279
+ // agent CLIs depends on the login account name as well as HOME. Omitting
8280
+ // USER makes `claude auth status` report logged out under the filtered
8281
+ // child environment even when the host CLI is logged in.
8282
+ "USER",
8278
8283
  "USERPROFILE",
8279
8284
  "TMPDIR",
8280
8285
  "TEMP",
@@ -8382,11 +8387,37 @@ function computeEffectivePolicy(offered, ceiling) {
8382
8387
  }
8383
8388
 
8384
8389
  // src/daemon/progress-batcher.ts
8390
+ var ProgressEventTooLargeError = class extends Error {
8391
+ constructor(actualBytes, maxBatchBytes) {
8392
+ super(`Progress event requires ${actualBytes} UTF-8 bytes, exceeding maxBatchBytes ${maxBatchBytes}.`);
8393
+ this.actualBytes = actualBytes;
8394
+ this.maxBatchBytes = maxBatchBytes;
8395
+ this.name = "ProgressEventTooLargeError";
8396
+ }
8397
+ actualBytes;
8398
+ maxBatchBytes;
8399
+ };
8400
+ var encoder = new TextEncoder();
8401
+ function assertPositiveSafeInteger(value, name) {
8402
+ if (value !== void 0 && (!Number.isSafeInteger(value) || value <= 0)) {
8403
+ throw new TypeError(`${name} must be a positive safe integer when configured.`);
8404
+ }
8405
+ }
8406
+ function validateProgressBatcherOptions(options = {}) {
8407
+ assertPositiveSafeInteger(options.maxBatchSize, "maxBatchSize");
8408
+ assertPositiveSafeInteger(options.flushIntervalMs, "flushIntervalMs");
8409
+ assertPositiveSafeInteger(options.maxBatchBytes, "maxBatchBytes");
8410
+ }
8411
+ function encodedEventsBytes(events) {
8412
+ return encoder.encode(JSON.stringify(events)).length;
8413
+ }
8385
8414
  var ProgressBatcher = class {
8386
8415
  constructor(emit, options = {}) {
8387
8416
  this.emit = emit;
8417
+ validateProgressBatcherOptions(options);
8388
8418
  this.maxBatchSize = options.maxBatchSize ?? 10;
8389
8419
  this.flushIntervalMs = options.flushIntervalMs ?? 250;
8420
+ this.maxBatchBytes = options.maxBatchBytes;
8390
8421
  }
8391
8422
  emit;
8392
8423
  buffer = [];
@@ -8394,7 +8425,17 @@ var ProgressBatcher = class {
8394
8425
  timer;
8395
8426
  maxBatchSize;
8396
8427
  flushIntervalMs;
8428
+ maxBatchBytes;
8397
8429
  push(event) {
8430
+ if (this.maxBatchBytes !== void 0) {
8431
+ const eventBytes = encodedEventsBytes([event]);
8432
+ if (eventBytes > this.maxBatchBytes) {
8433
+ throw new ProgressEventTooLargeError(eventBytes, this.maxBatchBytes);
8434
+ }
8435
+ if (this.buffer.length > 0 && encodedEventsBytes([...this.buffer, event]) > this.maxBatchBytes) {
8436
+ this.flush();
8437
+ }
8438
+ }
8398
8439
  this.buffer.push(event);
8399
8440
  if (this.buffer.length >= this.maxBatchSize) {
8400
8441
  this.flush();
@@ -8447,6 +8488,7 @@ var MAX_INLINE_ARTIFACT_BYTES = 64 * 1024;
8447
8488
  var MAX_TRACKED_TASK_IDS = 2e3;
8448
8489
  var MAX_DURATION_EXCEEDED_REASON_PREFIX = "resource limit exceeded: maxDurationMs";
8449
8490
  var MAX_OUTPUT_BYTES_EXCEEDED_REASON_PREFIX = "resource limit exceeded: maxTaskOutputBytes";
8491
+ var MAX_PROGRESS_BATCH_BYTES_EXCEEDED_REASON_PREFIX = "resource limit exceeded: progressBatch.maxBatchBytes";
8450
8492
  var RESULT_DOCUMENT_UNDELIVERABLE_REASON_PREFIX = "result document undeliverable";
8451
8493
  function resultDocumentRejectionDetail(check) {
8452
8494
  switch (check.reason) {
@@ -9303,6 +9345,13 @@ var TaskRunner = class {
9303
9345
  } catch (err) {
9304
9346
  if (this.tasks.get(active.taskId) !== active || active.beingTornDown) return;
9305
9347
  active.batcher.flush();
9348
+ if (err instanceof ProgressEventTooLargeError) {
9349
+ await this.failActiveTaskForResourceLimit(
9350
+ active.taskId,
9351
+ `${MAX_PROGRESS_BATCH_BYTES_EXCEEDED_REASON_PREFIX}: event requires ${err.actualBytes} UTF-8 bytes, exceeding the configured limit of ${err.maxBatchBytes} bytes`
9352
+ );
9353
+ return;
9354
+ }
9306
9355
  const failure = projectRuntimeBoundaryFailure(err, "run");
9307
9356
  if (failure.contractViolation) {
9308
9357
  console.error("[byok/client] runtime adapter events iterable returned an untyped failure", err);
@@ -10389,6 +10438,7 @@ function buildDaemonWithAdapters(config, adapters, overrides = {}, assertionProb
10389
10438
  `DaemonConfig.maxTaskOutputBytes must be a positive number (or omitted to use the ${DEFAULT_MAX_TASK_OUTPUT_BYTES}-byte default) \u2014 got ${config.maxTaskOutputBytes}. Pass Number.POSITIVE_INFINITY to explicitly disable the cap; 0 or a negative number is rejected rather than silently treated as "disabled".`
10390
10439
  );
10391
10440
  }
10441
+ validateProgressBatcherOptions(config.progressBatch);
10392
10442
  const presenceCadence = {
10393
10443
  intervalMs: config.presence?.intervalMs ?? DEFAULT_PRESENCE_HEARTBEAT_INTERVAL_MS,
10394
10444
  ttlMs: config.presence?.ttlMs ?? DEFAULT_PRESENCE_TTL_MS,
@@ -10674,7 +10724,7 @@ function buildDaemonWithAdapters(config, adapters, overrides = {}, assertionProb
10674
10724
  // untouched. See `observer.ts`'s module doc comment.
10675
10725
  send: sendEnvelope,
10676
10726
  blobClient,
10677
- batcherOptions: overrides.batch,
10727
+ batcherOptions: config.progressBatch,
10678
10728
  sessionWorkspaces,
10679
10729
  gitWorkspaceManager,
10680
10730
  gitWorkspaceStore,