@autohq/cli 0.1.340 → 0.1.342

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.
@@ -19426,6 +19426,49 @@ function date4(params) {
19426
19426
  // ../../node_modules/zod/v4/classic/external.js
19427
19427
  config(en_default());
19428
19428
 
19429
+ // ../../packages/protocol/src/content-sanitizer.ts
19430
+ function sanitizeUnstorableStrings(value2) {
19431
+ return sanitizeValue(value2);
19432
+ }
19433
+ var UNSTORABLE_STRING_CONTENT = (
19434
+ // biome-ignore lint/suspicious/noControlCharactersInRegex: matching NUL is the point
19435
+ /\u0000|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g
19436
+ );
19437
+ var REPLACEMENT_CHARACTER = "\uFFFD";
19438
+ function sanitizeString(value2) {
19439
+ UNSTORABLE_STRING_CONTENT.lastIndex = 0;
19440
+ if (!UNSTORABLE_STRING_CONTENT.test(value2)) {
19441
+ return value2;
19442
+ }
19443
+ return value2.replace(UNSTORABLE_STRING_CONTENT, REPLACEMENT_CHARACTER);
19444
+ }
19445
+ function sanitizeValue(value2) {
19446
+ if (typeof value2 === "string") {
19447
+ return sanitizeString(value2);
19448
+ }
19449
+ if (Array.isArray(value2)) {
19450
+ let changed = false;
19451
+ const next = value2.map((item) => {
19452
+ const sanitized = sanitizeValue(item);
19453
+ changed ||= sanitized !== item;
19454
+ return sanitized;
19455
+ });
19456
+ return changed ? next : value2;
19457
+ }
19458
+ if (typeof value2 === "object" && value2 !== null) {
19459
+ let changed = false;
19460
+ const next = {};
19461
+ for (const [key, item] of Object.entries(value2)) {
19462
+ const sanitizedKey = sanitizeString(key);
19463
+ const sanitizedItem = sanitizeValue(item);
19464
+ changed ||= sanitizedKey !== key || sanitizedItem !== item;
19465
+ next[sanitizedKey] = sanitizedItem;
19466
+ }
19467
+ return changed ? next : value2;
19468
+ }
19469
+ return value2;
19470
+ }
19471
+
19429
19472
  // ../../packages/protocol/src/index.ts
19430
19473
  var OpaqueIdSchema = external_exports.string().trim().min(1);
19431
19474
  var SessionIdSchema = OpaqueIdSchema.brand();
@@ -19797,6 +19840,9 @@ var RuntimeBridgeOutputEnvelopeSchema = external_exports.union([
19797
19840
  RuntimeBridgeOutputUiMessagePartEnvelopeSchema,
19798
19841
  RuntimeBridgeOutputUiMessageCompletedEnvelopeSchema
19799
19842
  ]);
19843
+ function isLiveOnlyRuntimeOutputEnvelope(envelope) {
19844
+ return envelope.type === "ui.message.chunk" || envelope.type === "conversation.delta";
19845
+ }
19800
19846
  function legacyRuntimeTurnStatus(entry, sessionStatusAfter) {
19801
19847
  if (sessionStatusAfter === "failed" || entry.status === "failed") {
19802
19848
  return "failed";
@@ -23434,7 +23480,7 @@ Object.assign(lookup, {
23434
23480
  // package.json
23435
23481
  var package_default = {
23436
23482
  name: "@autohq/cli",
23437
- version: "0.1.340",
23483
+ version: "0.1.342",
23438
23484
  license: "SEE LICENSE IN README.md",
23439
23485
  publishConfig: {
23440
23486
  access: "public"
@@ -44776,6 +44822,16 @@ var AgentBridgeOutputBuffer = class {
44776
44822
  return;
44777
44823
  } catch (error51) {
44778
44824
  if (!(error51 instanceof AgentBridgeOutputAckTimeoutError)) {
44825
+ this.input.runtimeLogger?.error(
44826
+ "agent_bridge_output_buffer_emit_rejected_definitively",
44827
+ this.outputLogContext(output, {
44828
+ error: error51 instanceof Error ? error51.message : String(error51),
44829
+ socket_cycle: this.input.cycleSocket ? "requested" : "unavailable",
44830
+ pending_count: this.pendingOutputs.size
44831
+ })
44832
+ );
44833
+ this.quarantineAfterRepeatedExhausts(output);
44834
+ this.input.cycleSocket?.();
44779
44835
  throw error51;
44780
44836
  }
44781
44837
  const backoffMs = AGENT_BRIDGE_OUTPUT_ACK_RETRY_BACKOFF_MS[attempt];
@@ -44851,7 +44907,16 @@ var AgentBridgeOutputBuffer = class {
44851
44907
  await this.drainPendingOutputs();
44852
44908
  }
44853
44909
  enqueueOutput(output) {
44854
- const bounded = boundOutputEnvelope(output);
44910
+ const sanitized = isLiveOnlyRuntimeOutputEnvelope(output) ? output : sanitizeUnstorableStrings(output);
44911
+ if (sanitized !== output) {
44912
+ this.input.runtimeLogger?.warn(
44913
+ "agent_bridge_output_envelope_sanitized",
44914
+ this.outputLogContext(sanitized, {
44915
+ pending_count: this.pendingOutputs.size
44916
+ })
44917
+ );
44918
+ }
44919
+ const bounded = boundOutputEnvelope(sanitized);
44855
44920
  if (bounded.truncated) {
44856
44921
  this.input.runtimeLogger?.warn(
44857
44922
  "agent_bridge_output_envelope_truncated",
package/dist/index.js CHANGED
@@ -30499,7 +30499,7 @@ var init_package = __esm({
30499
30499
  "package.json"() {
30500
30500
  package_default = {
30501
30501
  name: "@autohq/cli",
30502
- version: "0.1.340",
30502
+ version: "0.1.342",
30503
30503
  license: "SEE LICENSE IN README.md",
30504
30504
  publishConfig: {
30505
30505
  access: "public"
@@ -40350,6 +40350,51 @@ async function readStream(stream) {
40350
40350
 
40351
40351
  // ../../packages/protocol/src/index.ts
40352
40352
  init_zod();
40353
+
40354
+ // ../../packages/protocol/src/content-sanitizer.ts
40355
+ function sanitizeUnstorableStrings(value) {
40356
+ return sanitizeValue(value);
40357
+ }
40358
+ var UNSTORABLE_STRING_CONTENT = (
40359
+ // biome-ignore lint/suspicious/noControlCharactersInRegex: matching NUL is the point
40360
+ /\u0000|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g
40361
+ );
40362
+ var REPLACEMENT_CHARACTER = "\uFFFD";
40363
+ function sanitizeString(value) {
40364
+ UNSTORABLE_STRING_CONTENT.lastIndex = 0;
40365
+ if (!UNSTORABLE_STRING_CONTENT.test(value)) {
40366
+ return value;
40367
+ }
40368
+ return value.replace(UNSTORABLE_STRING_CONTENT, REPLACEMENT_CHARACTER);
40369
+ }
40370
+ function sanitizeValue(value) {
40371
+ if (typeof value === "string") {
40372
+ return sanitizeString(value);
40373
+ }
40374
+ if (Array.isArray(value)) {
40375
+ let changed = false;
40376
+ const next = value.map((item) => {
40377
+ const sanitized = sanitizeValue(item);
40378
+ changed ||= sanitized !== item;
40379
+ return sanitized;
40380
+ });
40381
+ return changed ? next : value;
40382
+ }
40383
+ if (typeof value === "object" && value !== null) {
40384
+ let changed = false;
40385
+ const next = {};
40386
+ for (const [key, item] of Object.entries(value)) {
40387
+ const sanitizedKey = sanitizeString(key);
40388
+ const sanitizedItem = sanitizeValue(item);
40389
+ changed ||= sanitizedKey !== key || sanitizedItem !== item;
40390
+ next[sanitizedKey] = sanitizedItem;
40391
+ }
40392
+ return changed ? next : value;
40393
+ }
40394
+ return value;
40395
+ }
40396
+
40397
+ // ../../packages/protocol/src/index.ts
40353
40398
  var OpaqueIdSchema2 = external_exports.string().trim().min(1);
40354
40399
  var SessionIdSchema2 = OpaqueIdSchema2.brand();
40355
40400
  var SessionCommandIdSchema2 = OpaqueIdSchema2.brand();
@@ -40720,6 +40765,9 @@ var RuntimeBridgeOutputEnvelopeSchema = external_exports.union([
40720
40765
  RuntimeBridgeOutputUiMessagePartEnvelopeSchema,
40721
40766
  RuntimeBridgeOutputUiMessageCompletedEnvelopeSchema
40722
40767
  ]);
40768
+ function isLiveOnlyRuntimeOutputEnvelope(envelope) {
40769
+ return envelope.type === "ui.message.chunk" || envelope.type === "conversation.delta";
40770
+ }
40723
40771
  function legacyRuntimeTurnStatus(entry, sessionStatusAfter) {
40724
40772
  if (sessionStatusAfter === "failed" || entry.status === "failed") {
40725
40773
  return "failed";
@@ -41990,6 +42038,16 @@ var AgentBridgeOutputBuffer = class {
41990
42038
  return;
41991
42039
  } catch (error51) {
41992
42040
  if (!(error51 instanceof AgentBridgeOutputAckTimeoutError)) {
42041
+ this.input.runtimeLogger?.error(
42042
+ "agent_bridge_output_buffer_emit_rejected_definitively",
42043
+ this.outputLogContext(output, {
42044
+ error: error51 instanceof Error ? error51.message : String(error51),
42045
+ socket_cycle: this.input.cycleSocket ? "requested" : "unavailable",
42046
+ pending_count: this.pendingOutputs.size
42047
+ })
42048
+ );
42049
+ this.quarantineAfterRepeatedExhausts(output);
42050
+ this.input.cycleSocket?.();
41993
42051
  throw error51;
41994
42052
  }
41995
42053
  const backoffMs = AGENT_BRIDGE_OUTPUT_ACK_RETRY_BACKOFF_MS[attempt];
@@ -42065,7 +42123,16 @@ var AgentBridgeOutputBuffer = class {
42065
42123
  await this.drainPendingOutputs();
42066
42124
  }
42067
42125
  enqueueOutput(output) {
42068
- const bounded = boundOutputEnvelope(output);
42126
+ const sanitized = isLiveOnlyRuntimeOutputEnvelope(output) ? output : sanitizeUnstorableStrings(output);
42127
+ if (sanitized !== output) {
42128
+ this.input.runtimeLogger?.warn(
42129
+ "agent_bridge_output_envelope_sanitized",
42130
+ this.outputLogContext(sanitized, {
42131
+ pending_count: this.pendingOutputs.size
42132
+ })
42133
+ );
42134
+ }
42135
+ const bounded = boundOutputEnvelope(sanitized);
42069
42136
  if (bounded.truncated) {
42070
42137
  this.input.runtimeLogger?.warn(
42071
42138
  "agent_bridge_output_envelope_truncated",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autohq/cli",
3
- "version": "0.1.340",
3
+ "version": "0.1.342",
4
4
  "license": "SEE LICENSE IN README.md",
5
5
  "publishConfig": {
6
6
  "access": "public"