@cydm/pie 2.7.1 → 2.7.3

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.
@@ -84,7 +84,7 @@ function computerUseOwnerFromEnv(env = process.env) {
84
84
 
85
85
  // vendor/computer-use-axi/src/broker-protocol.ts
86
86
  var BROKER_PROTOCOL_VERSION = 1;
87
- var BROKER_ENGINE_VERSION = 1;
87
+ var BROKER_ENGINE_VERSION = 2;
88
88
  var BROKER_PACKAGE_VERSION = "0.5.1-pie.1";
89
89
  var BROKER_MAX_FRAME_BYTES = 4 * 1024 * 1024;
90
90
  var BROKER_MAX_RESPONSE_BYTES = 8 * 1024 * 1024;
@@ -352,6 +352,7 @@ async function callBroker(options) {
352
352
  type: "request",
353
353
  protocolVersion: brokerProtocol,
354
354
  requestId: options.requestId,
355
+ generation: options.generation,
355
356
  ownerId: options.ownerId,
356
357
  executionId: options.executionId,
357
358
  command: options.command,
@@ -417,12 +418,14 @@ Commands:
417
418
  browser launch [--url U]
418
419
  browser navigate --state S --url U
419
420
  browser eval --state S --expr '<JavaScript>'
421
+ permissions setup|recheck macOS: register/open Settings, or restart helper and check
420
422
  status Show the local broker status (never starts one)
421
423
  stop Stop the local broker and release processes it owns
422
424
 
423
425
  Options:
424
426
  --json Print { content, details, isError } as JSON
425
- --request-id ID Reuse an id to retrieve the same result (at-most-once)
427
+ --request-id ID Retrieve the same result within its original broker generation
428
+ --generation G Pin request/result retrieval to a broker generation (use with reused IDs)
426
429
  --owner ID Opaque session identity (defaults to the standalone namespace)
427
430
  --help, -h Show this help
428
431
 
@@ -526,6 +529,11 @@ function buildCommand(args) {
526
529
  usageError(`unknown browser subcommand '${sub}' (expected launch | navigate | eval)`);
527
530
  }
528
531
  switch (args.command) {
532
+ case "permissions": {
533
+ const mode = args.rest[0];
534
+ if (mode !== "setup" && mode !== "recheck") usageError("permissions requires setup | recheck");
535
+ return { command: "permissions", params: { mode } };
536
+ }
529
537
  case "status":
530
538
  return { command: "status", params: {} };
531
539
  case "stop":
@@ -655,6 +663,7 @@ async function main() {
655
663
  ownerId: ownerId === COMPUTER_USE_STANDALONE_OWNER ? ownerId : ownerId,
656
664
  executionId,
657
665
  requestId,
666
+ generation: optionalFlag(args, "--generation"),
658
667
  cwd: process.cwd(),
659
668
  budgetMs,
660
669
  spawnIfMissing: !control
@@ -1890,6 +1890,10 @@ var NodeHttpClient = class {
1890
1890
  let tieredBodyByteSeen = false;
1891
1891
  let tierMarkBodyByte = null;
1892
1892
  let requestTimeoutError;
1893
+ const setTimeoutKind = (error, kind) => {
1894
+ if (!error) return;
1895
+ error.timeoutKind = kind;
1896
+ };
1893
1897
  const clearTieredFirstByteTimer = () => {
1894
1898
  if (tieredFirstByteTimer !== void 0) {
1895
1899
  clearTimeout(tieredFirstByteTimer);
@@ -1933,6 +1937,7 @@ var NodeHttpClient = class {
1933
1937
  res.on("timeout", () => {
1934
1938
  if (res.readableEnded || res.complete) return;
1935
1939
  requestTimeoutError = new Error(`Request timeout (stream idle) after ${tieredStreamIdleTimeoutMs}ms`);
1940
+ setTimeoutKind(requestTimeoutError, "stream_idle");
1936
1941
  logHttp("WARN", `Request [${reqTag}] stream idle timeout`, { idleTimeoutMs: tieredStreamIdleTimeoutMs });
1937
1942
  req.destroy(requestTimeoutError);
1938
1943
  });
@@ -2178,6 +2183,7 @@ var NodeHttpClient = class {
2178
2183
  if (!tieredStreamTimeout) {
2179
2184
  req.on("timeout", () => {
2180
2185
  requestTimeoutError = new Error("Request timeout");
2186
+ setTimeoutKind(requestTimeoutError, "total");
2181
2187
  logHttp("ERROR", `Request [${reqTag}] timeout`);
2182
2188
  req.destroy(requestTimeoutError);
2183
2189
  });
@@ -2186,6 +2192,7 @@ var NodeHttpClient = class {
2186
2192
  tieredFirstByteTimer = setTimeout(() => {
2187
2193
  tieredFirstByteTimer = void 0;
2188
2194
  requestTimeoutError = new Error(`Request timeout (first byte) after ${tieredFirstByteTimeoutMs}ms`);
2195
+ setTimeoutKind(requestTimeoutError, "first_byte");
2189
2196
  logHttp("WARN", `Request [${reqTag}] first byte timeout`, { firstByteTimeoutMs: tieredFirstByteTimeoutMs });
2190
2197
  req.destroy(requestTimeoutError);
2191
2198
  }, tieredFirstByteTimeoutMs);
@@ -3368,6 +3375,10 @@ function buildBaseOptions(model, options, apiKey) {
3368
3375
  sessionId: options?.sessionId,
3369
3376
  headers: options?.headers,
3370
3377
  timeoutMs: options?.timeoutMs,
3378
+ firstResponseTimeoutMs: options?.firstResponseTimeoutMs,
3379
+ streamIdleTimeoutMs: options?.streamIdleTimeoutMs,
3380
+ requestTimeoutMs: options?.requestTimeoutMs,
3381
+ connectionIdleTimeoutMs: options?.connectionIdleTimeoutMs,
3371
3382
  onPayload: options?.onPayload,
3372
3383
  onTransportDiagnostic: options?.onTransportDiagnostic,
3373
3384
  onTransportLifecycle: options?.onTransportLifecycle,
@@ -4887,7 +4898,10 @@ function getResponsesCompat(model) {
4887
4898
  supportsStore: compat.supportsStore ?? true,
4888
4899
  supportsReasoningEffort: compat.supportsReasoningEffort ?? true,
4889
4900
  supportsEncryptedReasoning: compat.supportsEncryptedReasoning ?? true,
4890
- responsesContinuation: compat.responsesContinuation ?? false
4901
+ responsesContinuation: compat.responsesContinuation ?? false,
4902
+ supportsReasoningSummary: compat.supportsReasoningSummary ?? false,
4903
+ reasoningSummary: compat.reasoningSummary ?? "auto",
4904
+ timeoutReplay: compat.timeoutReplay ?? false
4891
4905
  };
4892
4906
  }
4893
4907
 
@@ -5074,6 +5088,10 @@ function buildResponsesRequest(model, context, options, compat = getResponsesCom
5074
5088
  if (options?.reasoningEffort && model.reasoning && compat.supportsReasoningEffort) {
5075
5089
  params.reasoning = { effort: options.reasoningEffort };
5076
5090
  }
5091
+ if (model.reasoning && compat.supportsReasoningSummary && compat.reasoningSummary !== "none") {
5092
+ params.reasoning = params.reasoning ?? {};
5093
+ params.reasoning.summary = compat.reasoningSummary;
5094
+ }
5077
5095
  if (compat.supportsEncryptedReasoning && model.reasoning) {
5078
5096
  params.include = ["reasoning.encrypted_content"];
5079
5097
  }
@@ -5606,6 +5624,8 @@ function monotonicNow() {
5606
5624
  // ../../packages/ai/src/providers/responses/responses-sse.ts
5607
5625
  var DEFAULT_RESPONSES_STREAM_IDLE_TIMEOUT_MS = 2 * 60 * 1e3;
5608
5626
  var DEFAULT_RESPONSES_FIRST_BYTE_TIMEOUT_MS = 3 * 60 * 1e3;
5627
+ var REASONING_STREAM_IDLE_TIMEOUT_MS = 5 * 60 * 1e3;
5628
+ var REASONING_FIRST_BYTE_TIMEOUT_MS = 5 * 60 * 1e3;
5609
5629
  function parseSSEDataLine2(line) {
5610
5630
  const trimmed = line.trim();
5611
5631
  if (!trimmed || trimmed.startsWith(":")) return null;
@@ -5635,16 +5655,19 @@ function explicitBudget(value, field) {
5635
5655
  }
5636
5656
  return value;
5637
5657
  }
5638
- function resolveSSEBudgets(options) {
5658
+ function resolveSSEBudgets(options, model) {
5639
5659
  const firstResponse = explicitBudget(options?.firstResponseTimeoutMs, "firstResponseTimeoutMs");
5640
5660
  const streamIdle = explicitBudget(options?.streamIdleTimeoutMs, "streamIdleTimeoutMs");
5641
5661
  const requestTimeoutMs = explicitBudget(options?.requestTimeoutMs, "requestTimeoutMs");
5642
5662
  explicitBudget(options?.connectionIdleTimeoutMs, "connectionIdleTimeoutMs");
5663
+ const reasoning = model.reasoning === true;
5664
+ const defaultFirstByte = reasoning ? REASONING_FIRST_BYTE_TIMEOUT_MS : DEFAULT_RESPONSES_FIRST_BYTE_TIMEOUT_MS;
5665
+ const defaultIdle = reasoning ? REASONING_STREAM_IDLE_TIMEOUT_MS : DEFAULT_RESPONSES_STREAM_IDLE_TIMEOUT_MS;
5643
5666
  if (firstResponse !== void 0 || streamIdle !== void 0) {
5644
5667
  return {
5645
5668
  http: {
5646
- firstByteTimeoutMs: firstResponse ?? DEFAULT_RESPONSES_FIRST_BYTE_TIMEOUT_MS,
5647
- streamIdleTimeoutMs: streamIdle ?? DEFAULT_RESPONSES_STREAM_IDLE_TIMEOUT_MS
5669
+ firstByteTimeoutMs: firstResponse ?? defaultFirstByte,
5670
+ streamIdleTimeoutMs: streamIdle ?? defaultIdle
5648
5671
  },
5649
5672
  requestTimeoutMs
5650
5673
  };
@@ -5652,8 +5675,8 @@ function resolveSSEBudgets(options) {
5652
5675
  if (options?.timeoutMs !== void 0) return { http: { timeoutMs: options.timeoutMs }, requestTimeoutMs };
5653
5676
  return {
5654
5677
  http: {
5655
- firstByteTimeoutMs: DEFAULT_RESPONSES_FIRST_BYTE_TIMEOUT_MS,
5656
- streamIdleTimeoutMs: DEFAULT_RESPONSES_STREAM_IDLE_TIMEOUT_MS
5678
+ firstByteTimeoutMs: defaultFirstByte,
5679
+ streamIdleTimeoutMs: defaultIdle
5657
5680
  },
5658
5681
  requestTimeoutMs
5659
5682
  };
@@ -5674,6 +5697,7 @@ function streamResponsesSSE(model, context, options) {
5674
5697
  let totalTimer;
5675
5698
  let internalTimeout;
5676
5699
  let localFailure = false;
5700
+ let providerRejected = false;
5677
5701
  const requestAbort = new AbortController();
5678
5702
  const onUserAbort = () => requestAbort.abort();
5679
5703
  const clearTotalTimer = () => {
@@ -5701,7 +5725,7 @@ function streamResponsesSSE(model, context, options) {
5701
5725
  try {
5702
5726
  let resolved;
5703
5727
  try {
5704
- resolved = resolveSSEBudgets(options);
5728
+ resolved = resolveSSEBudgets(options, model);
5705
5729
  } catch (error) {
5706
5730
  localFailure = true;
5707
5731
  throw error;
@@ -5767,6 +5791,7 @@ function streamResponsesSSE(model, context, options) {
5767
5791
  });
5768
5792
  if (!response.ok) {
5769
5793
  const errorBody = await response.text().catch(() => "");
5794
+ providerRejected = true;
5770
5795
  throw new Error(`API error ${response.status}: ${errorBody}`);
5771
5796
  }
5772
5797
  if (!response.readSSELines) {
@@ -5824,13 +5849,26 @@ function streamResponsesSSE(model, context, options) {
5824
5849
  const message = reducer.message;
5825
5850
  const userAborted = options?.signal?.aborted === true;
5826
5851
  message.stopReason = userAborted ? "aborted" : "error";
5852
+ const adapterTimeoutKind = error instanceof Error ? error.timeoutKind : void 0;
5853
+ if (!internalTimeout && (adapterTimeoutKind === "first_byte" || adapterTimeoutKind === "stream_idle")) {
5854
+ internalTimeout = adapterTimeoutKind === "first_byte" ? "first_response" : "stream_idle";
5855
+ }
5827
5856
  message.errorMessage = internalTimeout ? `Responses request timeout (${internalTimeout}) after ${Math.round(monotonicNow() - startedAt)}ms` : error instanceof Error ? error.message : JSON.stringify(error);
5828
- if (submitted || localFailure) message.retryable = false;
5857
+ const compat = getResponsesCompat(model);
5858
+ const streamLost = !internalTimeout && submitted && !localFailure && !providerRejected && message.stopReason === "error";
5859
+ if (internalTimeout && compat.timeoutReplay) {
5860
+ message.replayEligible = true;
5861
+ message.replayClass = internalTimeout;
5862
+ } else if (streamLost && compat.timeoutReplay) {
5863
+ message.replayEligible = true;
5864
+ message.replayClass = receivedMessageCount === 0 ? "stream_lost" : "stream_lost_partial";
5865
+ }
5866
+ if ((submitted || localFailure) && !(streamLost && receivedMessageCount === 0)) message.retryable = false;
5829
5867
  phase = "cleanup";
5830
5868
  lifecycle({
5831
5869
  timeoutKind: internalTimeout,
5832
- retryAllowed: !submitted && !userAborted && !localFailure,
5833
- retryDecision: submitted ? "not_retryable_after_submission" : localFailure ? "local_configuration_error" : "not_submitted",
5870
+ retryAllowed: !userAborted && !localFailure && message.retryable !== false,
5871
+ retryDecision: streamLost ? receivedMessageCount === 0 ? message.replayEligible ? "replay_exempt_stream_lost" : "stream_lost_no_evidence" : message.replayEligible ? "replay_exempt_after_submission" : "not_retryable_after_submission" : submitted ? "not_retryable_after_submission" : localFailure ? "local_configuration_error" : "not_submitted",
5834
5872
  cancelSource: userAborted ? "user" : internalTimeout ? "internal_timeout" : "none",
5835
5873
  cleanupOutcome: "request_abandoned"
5836
5874
  });
@@ -5851,6 +5889,8 @@ var DEFAULT_CONNECT_TIMEOUT_MS = 3e4;
5851
5889
  var DEFAULT_FIRST_RESPONSE_TIMEOUT_MS = 2 * 60 * 1e3;
5852
5890
  var DEFAULT_STREAM_IDLE_TIMEOUT_MS = 2 * 60 * 1e3;
5853
5891
  var DEFAULT_CONNECTION_IDLE_TIMEOUT_MS = 2 * 60 * 1e3;
5892
+ var REASONING_FIRST_RESPONSE_TIMEOUT_MS = 5 * 60 * 1e3;
5893
+ var REASONING_STREAM_IDLE_TIMEOUT_MS2 = 5 * 60 * 1e3;
5854
5894
  var ITERATOR_CLEANUP_TIMEOUT_MS = 1e3;
5855
5895
  function explicitBudget2(value, field) {
5856
5896
  if (value === void 0) return void 0;
@@ -5859,16 +5899,17 @@ function explicitBudget2(value, field) {
5859
5899
  }
5860
5900
  return value;
5861
5901
  }
5862
- function resolveBudgets(options) {
5902
+ function resolveBudgets(options, model) {
5863
5903
  const firstResponse = explicitBudget2(options?.firstResponseTimeoutMs, "firstResponseTimeoutMs");
5864
5904
  const streamIdle = explicitBudget2(options?.streamIdleTimeoutMs, "streamIdleTimeoutMs");
5865
5905
  const requestTimeout = explicitBudget2(options?.requestTimeoutMs, "requestTimeoutMs");
5866
5906
  const connectionIdle = explicitBudget2(options?.connectionIdleTimeoutMs, "connectionIdleTimeoutMs");
5867
5907
  const legacy = options?.timeoutMs !== void 0 && Number.isFinite(options.timeoutMs) && options.timeoutMs > 0 ? options.timeoutMs : void 0;
5908
+ const reasoning = model.reasoning === true;
5868
5909
  return {
5869
5910
  connectTimeoutMs: legacy ?? DEFAULT_CONNECT_TIMEOUT_MS,
5870
- firstResponseTimeoutMs: firstResponse ?? legacy ?? DEFAULT_FIRST_RESPONSE_TIMEOUT_MS,
5871
- streamIdleTimeoutMs: streamIdle ?? legacy ?? DEFAULT_STREAM_IDLE_TIMEOUT_MS,
5911
+ firstResponseTimeoutMs: firstResponse ?? legacy ?? (reasoning ? REASONING_FIRST_RESPONSE_TIMEOUT_MS : DEFAULT_FIRST_RESPONSE_TIMEOUT_MS),
5912
+ streamIdleTimeoutMs: streamIdle ?? legacy ?? (reasoning ? REASONING_STREAM_IDLE_TIMEOUT_MS2 : DEFAULT_STREAM_IDLE_TIMEOUT_MS),
5872
5913
  requestTimeoutMs: requestTimeout,
5873
5914
  connectionIdleTimeoutMs: connectionIdle ?? DEFAULT_CONNECTION_IDLE_TIMEOUT_MS
5874
5915
  };
@@ -5937,7 +5978,7 @@ function streamResponsesWS(model, context, options) {
5937
5978
  }
5938
5979
  let budgets;
5939
5980
  try {
5940
- budgets = resolveBudgets(options);
5981
+ budgets = resolveBudgets(options, model);
5941
5982
  } catch (error) {
5942
5983
  reducer.message.stopReason = "error";
5943
5984
  reducer.message.errorMessage = error instanceof Error ? error.message : String(error);
@@ -5966,6 +6007,7 @@ function streamResponsesWS(model, context, options) {
5966
6007
  let requestTimer;
5967
6008
  let totalTimer;
5968
6009
  let receiveCleanupFailed = false;
6010
+ const compat = getResponsesCompat(model);
5969
6011
  let cleanupCancelSource;
5970
6012
  const requestAbort = new AbortController();
5971
6013
  const publish = (event) => {
@@ -6081,7 +6123,9 @@ function streamResponsesWS(model, context, options) {
6081
6123
  cancelSource: "internal_timeout",
6082
6124
  retryAllowed: !sent,
6083
6125
  retryDecision,
6084
- submissionAttempted: sent
6126
+ submissionAttempted: sent,
6127
+ // L2 diagnostic surface: this timeout qualifies for bounded replay.
6128
+ ...compat.timeoutReplay && sent ? { replayExempt: true } : {}
6085
6129
  });
6086
6130
  requestAbort.abort();
6087
6131
  }, timeoutMs);
@@ -6273,9 +6317,21 @@ function streamResponsesWS(model, context, options) {
6273
6317
  message.stopReason = userAborted || ownerDisposed ? "aborted" : "error";
6274
6318
  const cause = timedOut ? `Responses request timeout (${timedOut}) after ${ageMs()}ms` : error instanceof Error ? error.message : String(error);
6275
6319
  message.errorMessage = cause;
6320
+ const streamLost = !timedOut && message.stopReason === "error";
6321
+ if (timedOut && compat.timeoutReplay) {
6322
+ message.replayEligible = true;
6323
+ message.replayClass = timedOut;
6324
+ } else if (streamLost && compat.timeoutReplay) {
6325
+ message.replayEligible = true;
6326
+ message.replayClass = receivedMessageCount === 0 ? "stream_lost" : "stream_lost_partial";
6327
+ }
6276
6328
  if (sent) {
6277
- message.retryable = false;
6278
- retryDecision = "not_retryable_after_submission";
6329
+ if (streamLost && receivedMessageCount === 0) {
6330
+ retryDecision = message.replayEligible ? "replay_exempt_stream_lost" : "stream_lost_no_evidence";
6331
+ } else {
6332
+ message.retryable = false;
6333
+ if (!timedOut) retryDecision = message.replayEligible ? "replay_exempt_after_submission" : "not_retryable_after_submission";
6334
+ }
6279
6335
  }
6280
6336
  cleanupCancelSource = userAborted ? "user" : timedOut ? "internal_timeout" : ownerDisposed ? "owner_disposal" : "none";
6281
6337
  stream.push({ type: "error", reason: message.stopReason, error: message });
@@ -6297,7 +6353,7 @@ function streamResponsesWS(model, context, options) {
6297
6353
  terminalAccepted: finished,
6298
6354
  timeoutKind: timedOut,
6299
6355
  submissionAttempted: sent,
6300
- retryAllowed: !finished && !sent && reducer.message.stopReason !== "aborted" && reducer.message.retryable !== false,
6356
+ retryAllowed: !finished && reducer.message.stopReason !== "aborted" && reducer.message.retryable !== false,
6301
6357
  cancelSource,
6302
6358
  retryDecision,
6303
6359
  cleanupOutcome