alink-cli 0.11.8 → 0.11.10

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/dist/bin.mjs CHANGED
@@ -11747,6 +11747,7 @@ const AuthAccessReadScope = "access:read";
11747
11747
  const AuthAccessWriteScope = "access:write";
11748
11748
  const AuthRelayReadScope = "relay:read";
11749
11749
  const AuthRelayWriteScope = "relay:write";
11750
+ const AuthPortProxyOperateScope = "port-proxy:operate";
11750
11751
  const AuthEnvironmentScope = Literals([
11751
11752
  AuthOrchestrationReadScope,
11752
11753
  AuthOrchestrationOperateScope,
@@ -11755,7 +11756,8 @@ const AuthEnvironmentScope = Literals([
11755
11756
  AuthAccessReadScope,
11756
11757
  AuthAccessWriteScope,
11757
11758
  AuthRelayReadScope,
11758
- AuthRelayWriteScope
11759
+ AuthRelayWriteScope,
11760
+ AuthPortProxyOperateScope
11759
11761
  ]);
11760
11762
  const AuthEnvironmentScopes = ArraySchema(AuthEnvironmentScope);
11761
11763
  const AuthStandardClientScopes = [
@@ -11763,7 +11765,8 @@ const AuthStandardClientScopes = [
11763
11765
  AuthOrchestrationOperateScope,
11764
11766
  AuthTerminalOperateScope,
11765
11767
  AuthReviewWriteScope,
11766
- AuthRelayReadScope
11768
+ AuthRelayReadScope,
11769
+ AuthPortProxyOperateScope
11767
11770
  ];
11768
11771
  const AuthAdministrativeScopes = [
11769
11772
  ...AuthStandardClientScopes,
@@ -22506,6 +22509,11 @@ const ReviewDiffPreviewResult = Struct({
22506
22509
  sources: ArraySchema(ReviewDiffPreviewSource)
22507
22510
  });
22508
22511
  const ReviewDiffPreviewError = Union([VcsError, GitCommandError]);
22512
+ //#endregion
22513
+ //#region ../t3-contracts/src/portProxy.ts
22514
+ const PortProxyPort = PortSchema.pipe(brand("PortProxyPort"));
22515
+ const PortProxyListResult = Struct({ ports: ArraySchema(PortProxyPort) });
22516
+ const PortProxyPortInput = Struct({ port: PortProxyPort });
22509
22517
  const ResourceTelemetryIoSemantics = Literals([
22510
22518
  "storage",
22511
22519
  "logical",
@@ -23272,6 +23280,9 @@ const WS_METHODS = {
23272
23280
  serverReportClientActivity: "server.reportClientActivity",
23273
23281
  serverReportHostPowerState: "server.reportHostPowerState",
23274
23282
  serverGetBackgroundPolicy: "server.getBackgroundPolicy",
23283
+ portProxyList: "portProxy.list",
23284
+ portProxyAuthorize: "portProxy.authorize",
23285
+ portProxyRevoke: "portProxy.revoke",
23275
23286
  cloudGetRelayClientStatus: "cloud.getRelayClientStatus",
23276
23287
  cloudInstallRelayClient: "cloud.installRelayClient",
23277
23288
  sourceControlLookupRepository: "sourceControl.lookupRepository",
@@ -23345,6 +23356,21 @@ const WsServerGetSettingsRpc = make$52(WS_METHODS.serverGetSettings, {
23345
23356
  success: ServerSettings,
23346
23357
  error: Union([ServerSettingsError, EnvironmentAuthorizationError])
23347
23358
  });
23359
+ const WsPortProxyListRpc = make$52(WS_METHODS.portProxyList, {
23360
+ payload: Struct({}),
23361
+ success: PortProxyListResult,
23362
+ error: EnvironmentAuthorizationError
23363
+ });
23364
+ const WsPortProxyAuthorizeRpc = make$52(WS_METHODS.portProxyAuthorize, {
23365
+ payload: PortProxyPortInput,
23366
+ success: PortProxyListResult,
23367
+ error: EnvironmentAuthorizationError
23368
+ });
23369
+ const WsPortProxyRevokeRpc = make$52(WS_METHODS.portProxyRevoke, {
23370
+ payload: PortProxyPortInput,
23371
+ success: PortProxyListResult,
23372
+ error: EnvironmentAuthorizationError
23373
+ });
23348
23374
  const WsServerUpdateSettingsRpc = make$52(WS_METHODS.serverUpdateSettings, {
23349
23375
  payload: Struct({ patch: ServerSettingsPatch }),
23350
23376
  success: ServerSettings,
@@ -23670,7 +23696,7 @@ const WsOrchestrationSubscribeThreadRpc = make$52(ORCHESTRATION_WS_METHODS.subsc
23670
23696
  error: Union([OrchestrationGetSnapshotError, EnvironmentAuthorizationError]),
23671
23697
  stream: true
23672
23698
  });
23673
- const WsRpcGroup = make$51(WsServerProbeRpc, WsServerGetConfigRpc, WsServerRefreshProvidersRpc, WsServerUpdateProviderRpc, WsServerUpdateServerRpc, WsServerUpdateServerWithProgressRpc, WsServerUpsertKeybindingRpc, WsServerRemoveKeybindingRpc, WsServerGetSettingsRpc, WsServerUpdateSettingsRpc, WsServerDiscoverSourceControlRpc, WsServerGetTraceDiagnosticsRpc, WsServerGetProcessDiagnosticsRpc, WsServerGetProcessResourceHistoryRpc, WsServerGetResourceTelemetryHistoryRpc, WsServerRetryResourceTelemetryRpc, WsServerSignalProcessRpc, WsServerReportClientActivityRpc, WsServerReportHostPowerStateRpc, WsServerGetBackgroundPolicyRpc, WsCloudGetRelayClientStatusRpc, WsCloudInstallRelayClientRpc, WsSourceControlLookupRepositoryRpc, WsSourceControlCloneRepositoryRpc, WsSourceControlPublishRepositoryRpc, WsProjectsListEntriesRpc, WsProjectsReadFileRpc, WsProjectsSearchContentsRpc, WsProjectsSearchEntriesRpc, WsProjectsWriteFileRpc, WsShellOpenInEditorRpc, WsFilesystemBrowseRpc, WsAssetsCreateUrlRpc, WsSubscribeVcsStatusRpc, WsVcsPullRpc, WsVcsRefreshStatusRpc, WsGitRunStackedActionRpc, WsGitResolvePullRequestRpc, WsGitPreparePullRequestThreadRpc, WsVcsListRefsRpc, WsVcsCreateWorktreeRpc, WsVcsRemoveWorktreeRpc, WsVcsCreateRefRpc, WsVcsSwitchRefRpc, WsVcsInitRpc, WsReviewGetDiffPreviewRpc, WsReviewGetDiffFileContentsRpc, WsTerminalOpenRpc, WsTerminalAttachRpc, WsTerminalWriteRpc, WsTerminalResizeRpc, WsTerminalClearRpc, WsTerminalRestartRpc, WsTerminalCloseRpc, make$52(WS_METHODS.subscribeTerminalEvents, {
23699
+ const WsRpcGroup = make$51(WsServerProbeRpc, WsServerGetConfigRpc, WsServerRefreshProvidersRpc, WsServerUpdateProviderRpc, WsServerUpdateServerRpc, WsServerUpdateServerWithProgressRpc, WsServerUpsertKeybindingRpc, WsServerRemoveKeybindingRpc, WsServerGetSettingsRpc, WsServerUpdateSettingsRpc, WsServerDiscoverSourceControlRpc, WsServerGetTraceDiagnosticsRpc, WsServerGetProcessDiagnosticsRpc, WsServerGetProcessResourceHistoryRpc, WsServerGetResourceTelemetryHistoryRpc, WsServerRetryResourceTelemetryRpc, WsServerSignalProcessRpc, WsServerReportClientActivityRpc, WsServerReportHostPowerStateRpc, WsServerGetBackgroundPolicyRpc, WsPortProxyListRpc, WsPortProxyAuthorizeRpc, WsPortProxyRevokeRpc, WsCloudGetRelayClientStatusRpc, WsCloudInstallRelayClientRpc, WsSourceControlLookupRepositoryRpc, WsSourceControlCloneRepositoryRpc, WsSourceControlPublishRepositoryRpc, WsProjectsListEntriesRpc, WsProjectsReadFileRpc, WsProjectsSearchContentsRpc, WsProjectsSearchEntriesRpc, WsProjectsWriteFileRpc, WsShellOpenInEditorRpc, WsFilesystemBrowseRpc, WsAssetsCreateUrlRpc, WsSubscribeVcsStatusRpc, WsVcsPullRpc, WsVcsRefreshStatusRpc, WsGitRunStackedActionRpc, WsGitResolvePullRequestRpc, WsGitPreparePullRequestThreadRpc, WsVcsListRefsRpc, WsVcsCreateWorktreeRpc, WsVcsRemoveWorktreeRpc, WsVcsCreateRefRpc, WsVcsSwitchRefRpc, WsVcsInitRpc, WsReviewGetDiffPreviewRpc, WsReviewGetDiffFileContentsRpc, WsTerminalOpenRpc, WsTerminalAttachRpc, WsTerminalWriteRpc, WsTerminalResizeRpc, WsTerminalClearRpc, WsTerminalRestartRpc, WsTerminalCloseRpc, make$52(WS_METHODS.subscribeTerminalEvents, {
23674
23700
  payload: Struct({}),
23675
23701
  success: TerminalEvent,
23676
23702
  error: EnvironmentAuthorizationError,
@@ -50725,7 +50751,7 @@ const layer$12 = effect(ProviderMaintenanceRunner, fn("ProviderMaintenanceRunner
50725
50751
  })());
50726
50752
  //#endregion
50727
50753
  //#region src/orchestration/ActivityPayloadProjection.ts
50728
- function asRecord$1(value) {
50754
+ function asRecord$2(value) {
50729
50755
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
50730
50756
  }
50731
50757
  function asTrimmedString$1(value) {
@@ -50748,7 +50774,7 @@ function collectChangedFiles(value, target, seen, depth) {
50748
50774
  }
50749
50775
  return;
50750
50776
  }
50751
- const record = asRecord$1(value);
50777
+ const record = asRecord$2(value);
50752
50778
  if (!record) return;
50753
50779
  pushChangedFile(target, seen, record.path);
50754
50780
  pushChangedFile(target, seen, record.filePath);
@@ -50774,13 +50800,13 @@ function collectChangedFiles(value, target, seen, depth) {
50774
50800
  }
50775
50801
  }
50776
50802
  function projectCommandData(data) {
50777
- const item = asRecord$1(data.item);
50803
+ const item = asRecord$2(data.item);
50778
50804
  if (!item) return;
50779
50805
  const projectedItem = {};
50780
50806
  if ("command" in item) projectedItem.command = item.command;
50781
- const input = asRecord$1(item.input);
50807
+ const input = asRecord$2(item.input);
50782
50808
  if (input && "command" in input) projectedItem.input = { command: input.command };
50783
- const result = asRecord$1(item.result);
50809
+ const result = asRecord$2(item.result);
50784
50810
  if (result && "command" in result) projectedItem.result = { command: result.command };
50785
50811
  return Object.keys(projectedItem).length > 0 ? projectedItem : void 0;
50786
50812
  }
@@ -50796,7 +50822,7 @@ function summarizeToolTextOutput(value) {
50796
50822
  return null;
50797
50823
  }
50798
50824
  function projectRawOutput(value) {
50799
- const rawOutput = asRecord$1(value);
50825
+ const rawOutput = asRecord$2(value);
50800
50826
  if (!rawOutput) return;
50801
50827
  if (typeof rawOutput.totalFiles === "number" && Number.isFinite(rawOutput.totalFiles)) return {
50802
50828
  totalFiles: rawOutput.totalFiles,
@@ -50818,8 +50844,8 @@ function projectRawOutput(value) {
50818
50844
  * the full payload in persistence and the event store.
50819
50845
  */
50820
50846
  function projectActivityPayload(activity) {
50821
- const payload = asRecord$1(activity.payload);
50822
- const data = asRecord$1(payload?.data);
50847
+ const payload = asRecord$2(activity.payload);
50848
+ const data = asRecord$2(payload?.data);
50823
50849
  if (!payload || !data || payload.itemType === "mcp_tool_call") return activity;
50824
50850
  const projectedData = {};
50825
50851
  const item = projectCommandData(data);
@@ -50848,7 +50874,7 @@ function projectActivityPayload(activity) {
50848
50874
  */
50849
50875
  function isResolvableContextWindowActivity(activity) {
50850
50876
  if (activity.kind !== "context-window.updated") return false;
50851
- const usedTokens = asRecord$1(activity.payload)?.usedTokens;
50877
+ const usedTokens = asRecord$2(activity.payload)?.usedTokens;
50852
50878
  return typeof usedTokens === "number" && Number.isFinite(usedTokens) && usedTokens >= 0;
50853
50879
  }
50854
50880
  /**
@@ -51040,6 +51066,60 @@ const observeRpcStreamEffect = (method, effect, traceAttributes) => {
51040
51066
  return withRpcStreamTracing(method, instrumented, traceAttributes);
51041
51067
  };
51042
51068
  //#endregion
51069
+ //#region src/portProxy.ts
51070
+ const ports = /* @__PURE__ */ new Set();
51071
+ const methods = /* @__PURE__ */ new Set([
51072
+ "GET",
51073
+ "HEAD",
51074
+ "POST",
51075
+ "PUT",
51076
+ "PATCH",
51077
+ "DELETE",
51078
+ "OPTIONS"
51079
+ ]);
51080
+ const requestHeaders = /* @__PURE__ */ new Set([
51081
+ "authorization",
51082
+ "cookie",
51083
+ "host",
51084
+ "connection",
51085
+ "upgrade",
51086
+ "proxy-authorization",
51087
+ "proxy-connection"
51088
+ ]);
51089
+ const responseHeaders = /* @__PURE__ */ new Set([
51090
+ "set-cookie",
51091
+ "connection",
51092
+ "upgrade",
51093
+ "proxy-authenticate",
51094
+ "transfer-encoding"
51095
+ ]);
51096
+ function listAuthorizedPorts() {
51097
+ return [...ports].sort((a, b) => a - b);
51098
+ }
51099
+ function authorizePort(port) {
51100
+ ports.add(port);
51101
+ return listAuthorizedPorts();
51102
+ }
51103
+ function revokePort(port) {
51104
+ ports.delete(port);
51105
+ return listAuthorizedPorts();
51106
+ }
51107
+ function isPortAuthorized(port) {
51108
+ return ports.has(port);
51109
+ }
51110
+ function authorizedPortBaseUrl(port) {
51111
+ return isPortAuthorized(port) ? `http://127.0.0.1:${port}` : null;
51112
+ }
51113
+ function isPortProxyMethodAllowed(method) {
51114
+ return methods.has(method.toUpperCase());
51115
+ }
51116
+ function isPortProxyRequestHeaderAllowed(header) {
51117
+ return !requestHeaders.has(header.toLowerCase());
51118
+ }
51119
+ function isPortProxyResponseHeaderAllowed(header) {
51120
+ return !responseHeaders.has(header.toLowerCase());
51121
+ }
51122
+ //#endregion
51043
51123
  //#region ../t3-shared/src/searchRanking.ts
51044
51124
  function normalizeSearchQuery(input, options) {
51045
51125
  const trimmed = input.trim();
@@ -52379,6 +52459,9 @@ const RPC_REQUIRED_SCOPES = {
52379
52459
  [WS_METHODS.serverReportClientActivity]: AuthOrchestrationReadScope,
52380
52460
  [WS_METHODS.serverReportHostPowerState]: AuthOrchestrationOperateScope,
52381
52461
  [WS_METHODS.serverGetBackgroundPolicy]: AuthOrchestrationReadScope,
52462
+ [WS_METHODS.portProxyList]: AuthPortProxyOperateScope,
52463
+ [WS_METHODS.portProxyAuthorize]: AuthPortProxyOperateScope,
52464
+ [WS_METHODS.portProxyRevoke]: AuthPortProxyOperateScope,
52382
52465
  [WS_METHODS.cloudGetRelayClientStatus]: AuthRelayReadScope,
52383
52466
  [WS_METHODS.cloudInstallRelayClient]: AuthRelayWriteScope,
52384
52467
  [WS_METHODS.sourceControlLookupRepository]: AuthOrchestrationReadScope,
@@ -52885,6 +52968,9 @@ const makeWsRpcLayer = (currentSession) => WsRpcGroup.toLayer(gen(function* () {
52885
52968
  }), { "rpc.aggregate": "orchestration" }),
52886
52969
  [WS_METHODS.serverProbe]: (_input) => observeRpcEffect$1(WS_METHODS.serverProbe, succeed$1({}), { "rpc.aggregate": "server" }),
52887
52970
  [WS_METHODS.serverGetConfig]: (_input) => observeRpcEffect$1(WS_METHODS.serverGetConfig, loadServerConfig, { "rpc.aggregate": "server" }),
52971
+ [WS_METHODS.portProxyList]: (_input) => observeRpcEffect$1(WS_METHODS.portProxyList, sync(() => ({ ports: listAuthorizedPorts() })), { "rpc.aggregate": "port-proxy" }),
52972
+ [WS_METHODS.portProxyAuthorize]: ({ port }) => observeRpcEffect$1(WS_METHODS.portProxyAuthorize, sync(() => ({ ports: authorizePort(port) })), { "rpc.aggregate": "port-proxy" }),
52973
+ [WS_METHODS.portProxyRevoke]: ({ port }) => observeRpcEffect$1(WS_METHODS.portProxyRevoke, sync(() => ({ ports: revokePort(port) })), { "rpc.aggregate": "port-proxy" }),
52888
52974
  [WS_METHODS.serverRefreshProviders]: (input) => observeRpcEffect$1(WS_METHODS.serverRefreshProviders, (input.instanceId !== void 0 ? providerRegistry.refreshInstance(input.instanceId) : providerRegistry.refresh()).pipe(map$4((providers) => ({ providers }))), { "rpc.aggregate": "server" }),
52889
52975
  [WS_METHODS.serverUpdateProvider]: (input) => observeRpcEffect$1(WS_METHODS.serverUpdateProvider, providerMaintenanceRunner.updateProvider(input), { "rpc.aggregate": "server" }),
52890
52976
  [WS_METHODS.serverUpdateSettings]: ({ patch }) => observeRpcEffect$1(WS_METHODS.serverUpdateSettings, serverSettings.updateSettings(patch).pipe(map$4(redactServerSettingsForClient)), { "rpc.aggregate": "server" }),
@@ -53185,7 +53271,8 @@ function makeAgentLinkFrameAssembler() {
53185
53271
  const TUNNEL_SCOPES = [
53186
53272
  AuthOrchestrationReadScope,
53187
53273
  AuthOrchestrationOperateScope,
53188
- AuthTerminalOperateScope
53274
+ AuthTerminalOperateScope,
53275
+ AuthPortProxyOperateScope
53189
53276
  ];
53190
53277
  function machineIdFromToken(token) {
53191
53278
  const parts = token.split(".");
@@ -53322,7 +53409,7 @@ const splitHubFrame = (text) => {
53322
53409
  };
53323
53410
  };
53324
53411
  function isHttpTunnelRequestFrame(value) {
53325
- return typeof value === "object" && value !== null && value._tag === "HttpRequest" && typeof value.id === "string" && typeof value.method === "string" && typeof value.path === "string" && Array.isArray(value.headers) && (value.body === null || typeof value.body === "string");
53412
+ return typeof value === "object" && value !== null && value._tag === "HttpRequest" && typeof value.id === "string" && typeof value.method === "string" && typeof value.path === "string" && Array.isArray(value.headers) && (value.body === null || typeof value.body === "string") && (value.targetPort === void 0 || Number.isInteger(value.targetPort) && Number(value.targetPort) >= 1 && Number(value.targetPort) <= 65535);
53326
53413
  }
53327
53414
  function encodeHttpTunnelResponseFrame(frame) {
53328
53415
  return JSON.stringify(frame);
@@ -53455,7 +53542,7 @@ const runHubTunnel = (config) => gen(function* () {
53455
53542
  });
53456
53543
  yield* addFinalizer(() => sessionsStore.markDisconnected(issued.sessionId).pipe(andThen(serverAuth.revokeSession(issued.sessionId)), ignore$1));
53457
53544
  yield* sessionsStore.markConnected(issued.sessionId);
53458
- const localBaseUrl = `http://127.0.0.1:${serverConfig.port}`;
53545
+ const daemonBaseUrl = `http://127.0.0.1:${serverConfig.port}`;
53459
53546
  const sendEncrypted = (frame) => {
53460
53547
  try {
53461
53548
  for (const part of chunkAgentLinkFrame(encodeHttpTunnelResponseFrame(frame))) {
@@ -53496,12 +53583,35 @@ const runHubTunnel = (config) => gen(function* () {
53496
53583
  });
53497
53584
  return;
53498
53585
  }
53586
+ const portProxyBaseUrl = requestFrame.targetPort === void 0 ? void 0 : authorizedPortBaseUrl(requestFrame.targetPort);
53587
+ if (portProxyBaseUrl === null) {
53588
+ sendEncrypted({
53589
+ _tag: "HttpResponse",
53590
+ id: requestFrame.id,
53591
+ status: 403,
53592
+ statusText: "Forbidden",
53593
+ headers: [["content-type", "text/plain; charset=utf-8"]],
53594
+ body: Buffer.from("This port has not been authorized in AgentLink settings.").toString("base64")
53595
+ });
53596
+ return;
53597
+ }
53598
+ if (portProxyBaseUrl !== void 0 && !isPortProxyMethodAllowed(requestFrame.method)) {
53599
+ sendEncrypted({
53600
+ _tag: "HttpResponse",
53601
+ id: requestFrame.id,
53602
+ status: 405,
53603
+ statusText: "Method Not Allowed",
53604
+ headers: [["content-type", "text/plain; charset=utf-8"]],
53605
+ body: Buffer.from("Unsupported port proxy method.").toString("base64")
53606
+ });
53607
+ return;
53608
+ }
53499
53609
  runFork(gen(function* () {
53500
- const targetUrl = `${localBaseUrl}${requestFrame.path}`;
53501
- const headers = { authorization: `Bearer ${issued.token}` };
53610
+ const targetUrl = `${portProxyBaseUrl ?? daemonBaseUrl}${requestFrame.path}`;
53611
+ const headers = requestFrame.targetPort === void 0 ? { authorization: `Bearer ${issued.token}` } : {};
53502
53612
  for (const [key, value] of requestFrame.headers) {
53503
53613
  const lower = key.toLowerCase();
53504
- if (lower === "authorization" || lower === "cookie") continue;
53614
+ if (requestFrame.targetPort === void 0 ? lower === "authorization" || lower === "cookie" : !isPortProxyRequestHeaderAllowed(lower)) continue;
53505
53615
  headers[lower] = value;
53506
53616
  }
53507
53617
  let request = make$65(requestFrame.method)(targetUrl).pipe(setHeaders(headers));
@@ -53509,7 +53619,7 @@ const runHubTunnel = (config) => gen(function* () {
53509
53619
  const response = yield* httpClient.execute(request);
53510
53620
  const responseBody = yield* response.arrayBuffer;
53511
53621
  const responseHeaders = [];
53512
- for (const [key, value] of Object.entries(response.headers)) if (typeof value === "string") responseHeaders.push([key, value]);
53622
+ for (const [key, value] of Object.entries(response.headers)) if (typeof value === "string" && (requestFrame.targetPort === void 0 || isPortProxyResponseHeaderAllowed(key))) responseHeaders.push([key, value]);
53513
53623
  return {
53514
53624
  _tag: "HttpResponse",
53515
53625
  id: requestFrame.id,
@@ -60178,7 +60288,7 @@ const CodexAppServerSchemaIssueKind = Literals([
60178
60288
  "Forbidden",
60179
60289
  "OneOf"
60180
60290
  ]);
60181
- const schemaIssueDiagnostics$1 = (root) => {
60291
+ const schemaIssueDiagnostics$2 = (root) => {
60182
60292
  let issueCount = 0;
60183
60293
  let maximumPathDepth = 0;
60184
60294
  const issueKinds = /* @__PURE__ */ new Set();
@@ -60283,7 +60393,7 @@ var CodexAppServerProtocolParseError = class CodexAppServerProtocolParseError ex
60283
60393
  return new CodexAppServerProtocolParseError({
60284
60394
  operation,
60285
60395
  ...context,
60286
- ...schemaIssueDiagnostics$1(cause.issue),
60396
+ ...schemaIssueDiagnostics$2(cause.issue),
60287
60397
  cause
60288
60398
  });
60289
60399
  }
@@ -60401,7 +60511,7 @@ var CodexAppServerRequestError = class CodexAppServerRequestError extends Tagged
60401
60511
  });
60402
60512
  }
60403
60513
  static invalidPayload(method, operation, cause) {
60404
- const diagnostics = schemaIssueDiagnostics$1(cause.issue);
60514
+ const diagnostics = schemaIssueDiagnostics$2(cause.issue);
60405
60515
  return new CodexAppServerRequestError({
60406
60516
  code: -32602,
60407
60517
  errorMessage: `Invalid payload for method '${method}' during '${operation}'`,
@@ -84374,7 +84484,7 @@ const AcpSchemaIssueKind = Literals([
84374
84484
  "Forbidden",
84375
84485
  "OneOf"
84376
84486
  ]);
84377
- const schemaIssueDiagnostics = (root) => {
84487
+ const schemaIssueDiagnostics$1 = (root) => {
84378
84488
  let issueCount = 0;
84379
84489
  let maximumPathDepth = 0;
84380
84490
  const issueKinds = /* @__PURE__ */ new Set();
@@ -84423,7 +84533,8 @@ var AcpProcessExitedError = class extends TaggedErrorClass()("AcpProcessExitedEr
84423
84533
  const AcpProtocolParseOperation = Literals([
84424
84534
  "encode-message",
84425
84535
  "decode-wire-message",
84426
- "decode-notification-payload"
84536
+ "decode-notification-payload",
84537
+ "decode-rpc-result"
84427
84538
  ]);
84428
84539
  var AcpProtocolParseError = class AcpProtocolParseError extends TaggedErrorClass()("AcpProtocolParseError", {
84429
84540
  operation: AcpProtocolParseOperation,
@@ -84442,7 +84553,7 @@ var AcpProtocolParseError = class AcpProtocolParseError extends TaggedErrorClass
84442
84553
  return new AcpProtocolParseError({
84443
84554
  operation,
84444
84555
  method,
84445
- ...schemaIssueDiagnostics(cause.issue),
84556
+ ...schemaIssueDiagnostics$1(cause.issue),
84446
84557
  cause
84447
84558
  });
84448
84559
  }
@@ -84569,7 +84680,7 @@ var AcpRequestError = class AcpRequestError extends TaggedErrorClass()("AcpReque
84569
84680
  });
84570
84681
  }
84571
84682
  static invalidExtensionPayload(method, cause) {
84572
- const diagnostics = schemaIssueDiagnostics(cause.issue);
84683
+ const diagnostics = schemaIssueDiagnostics$1(cause.issue);
84573
84684
  return new AcpRequestError({
84574
84685
  code: -32602,
84575
84686
  errorMessage: `Invalid payload for ACP extension method '${method}'.`,
@@ -84655,6 +84766,65 @@ const isAcpError = is(AcpError);
84655
84766
  const decodeSessionUpdate = decodeUnknownEffect(SessionNotification);
84656
84767
  const decodeElicitationComplete = decodeUnknownEffect(ElicitationCompleteNotification);
84657
84768
  const parserFactory = ndJsonRpc();
84769
+ const canonicalStopReasons$1 = /* @__PURE__ */ new Set([
84770
+ "end_turn",
84771
+ "max_tokens",
84772
+ "max_turn_requests",
84773
+ "refusal",
84774
+ "cancelled"
84775
+ ]);
84776
+ const structuralName = (value) => value.length <= 128 && /^[A-Za-z][A-Za-z0-9._:/-]*$/.test(value) ? value : "unknown";
84777
+ const valueType = (value) => value === null ? "null" : Array.isArray(value) ? "array" : typeof value;
84778
+ const boundedFieldNames = (value) => Object.keys(value).slice(0, 16).map(structuralName);
84779
+ const safeWireDiagnostics = (data) => {
84780
+ const lines = (typeof data === "string" ? data : new TextDecoder().decode(data)).split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
84781
+ if (lines.length === 0 || lines.length > 16) return { jsonSyntaxValid: false };
84782
+ let decoded;
84783
+ try {
84784
+ decoded = lines.map((line) => JSON.parse(line));
84785
+ } catch {
84786
+ return { jsonSyntaxValid: false };
84787
+ }
84788
+ const candidate = decoded.at(-1);
84789
+ if (candidate === null || typeof candidate !== "object" || Array.isArray(candidate)) return {
84790
+ jsonSyntaxValid: true,
84791
+ frameCount: decoded.length,
84792
+ topLevelType: valueType(candidate)
84793
+ };
84794
+ const frame = candidate;
84795
+ const result = frame.result !== null && typeof frame.result === "object" && !Array.isArray(frame.result) ? frame.result : void 0;
84796
+ const stopReason = result?.stopReason;
84797
+ return {
84798
+ jsonSyntaxValid: true,
84799
+ frameCount: decoded.length,
84800
+ topLevelFields: boundedFieldNames(frame),
84801
+ ...Object.hasOwn(frame, "jsonrpc") ? { jsonrpcType: valueType(frame.jsonrpc) } : {},
84802
+ ...Object.hasOwn(frame, "id") ? { idType: valueType(frame.id) } : {},
84803
+ ...typeof frame.method === "string" ? { method: structuralName(frame.method) } : {},
84804
+ ...result ? { resultFields: boundedFieldNames(result) } : {},
84805
+ ...result && Object.hasOwn(result, "stopReason") ? {
84806
+ stopReasonType: valueType(stopReason),
84807
+ ...typeof stopReason === "string" && canonicalStopReasons$1.has(stopReason) ? { canonicalStopReason: stopReason } : {}
84808
+ } : {}
84809
+ };
84810
+ };
84811
+ const safeTerminationDiagnostics = (error) => {
84812
+ const record = error;
84813
+ return {
84814
+ errorTag: error._tag,
84815
+ ...typeof record.operation === "string" ? { operation: structuralName(record.operation) } : {},
84816
+ ...typeof record.method === "string" ? { method: structuralName(record.method) } : {},
84817
+ ...Object.hasOwn(record, "requestId") ? {
84818
+ requestIdType: valueType(record.requestId),
84819
+ requestId: "redacted"
84820
+ } : {},
84821
+ ...typeof record.issueCount === "number" ? { issueCount: Math.min(Math.max(0, record.issueCount), 1e4) } : {},
84822
+ ...Array.isArray(record.issueKinds) ? { issueKinds: record.issueKinds.slice(0, 16).map((kind) => structuralName(String(kind))) } : {},
84823
+ ...typeof record.maximumPathDepth === "number" ? { maximumPathDepth: Math.min(Math.max(0, record.maximumPathDepth), 1e3) } : {},
84824
+ ...typeof record.pid === "number" ? { pid: record.pid } : {},
84825
+ ...typeof record.code === "number" ? { exitCode: record.code } : {}
84826
+ };
84827
+ };
84658
84828
  const makeAcpPatchedProtocol = fn("makeAcpPatchedProtocol")(function* (options) {
84659
84829
  const parser = parserFactory.makeUnsafe();
84660
84830
  const serverQueue = yield* unbounded$2();
@@ -84724,6 +84894,11 @@ const makeAcpPatchedProtocol = fn("makeAcpPatchedProtocol")(function* (options)
84724
84894
  yield* offer$1(disconnects, 0);
84725
84895
  const error = yield* classify();
84726
84896
  if (!error) return;
84897
+ yield* logProtocol({
84898
+ direction: "incoming",
84899
+ stage: "terminated",
84900
+ payload: safeTerminationDiagnostics(error)
84901
+ });
84727
84902
  yield* failAllExtPending(error);
84728
84903
  yield* emitClientProtocolError(error);
84729
84904
  if (options.onTermination) yield* options.onTermination(error);
@@ -84823,18 +84998,22 @@ const makeAcpPatchedProtocol = fn("makeAcpPatchedProtocol")(function* (options)
84823
84998
  direction: "incoming",
84824
84999
  stage: "decoded",
84825
85000
  payload: messages
84826
- })), tapErrorTag("AcpProtocolParseError", (error) => logProtocol({
85001
+ })), flatMap$1((messages) => forEach(messages, routeDecodedMessage, { discard: true })), tapErrorTag("AcpProtocolParseError", (error) => logProtocol({
84827
85002
  direction: "incoming",
84828
85003
  stage: "decode_failed",
84829
85004
  payload: {
84830
85005
  operation: error.operation,
85006
+ ...error.operation === "decode-wire-message" ? safeWireDiagnostics(data) : {},
84831
85007
  ...error.method === void 0 ? {} : { method: error.method },
84832
- ...error.requestId === void 0 ? {} : { requestId: error.requestId },
85008
+ ...error.requestId === void 0 ? {} : {
85009
+ requestIdType: valueType(error.requestId),
85010
+ requestId: "redacted"
85011
+ },
84833
85012
  ...error.issueCount === void 0 ? {} : { issueCount: error.issueCount },
84834
85013
  ...error.issueKinds === void 0 ? {} : { issueKinds: error.issueKinds },
84835
85014
  ...error.maximumPathDepth === void 0 ? {} : { maximumPathDepth: error.maximumPathDepth }
84836
85015
  }
84837
- })), flatMap$1((messages) => forEach(messages, routeDecodedMessage, { discard: true })))), matchEffect({
85016
+ })))), matchEffect({
84838
85017
  onFailure: (error) => {
84839
85018
  const normalized = isAcpError(error) ? error : new AcpTransportError({
84840
85019
  operation: "read-input-stream",
@@ -85028,7 +85207,7 @@ const ClientRpcs = make$51(ReadTextFileRpc, WriteTextFileRpc, RequestPermissionR
85028
85207
  //#endregion
85029
85208
  //#region ../effect-acp/src/_internal/shared.ts
85030
85209
  const isError = is(Error$1);
85031
- const callRpc = (method, effect) => effect.pipe(catchIf(isError, (error) => fail(AcpRequestError.fromProtocolError(error, { method }))), catchTags({ RpcClientError: (cause) => fail(new AcpTransportError({
85210
+ const callRpc = (method, effect) => effect.pipe(catchDefect((defect) => isSchemaError(defect) ? fail(AcpProtocolParseError.fromSchemaError("decode-rpc-result", method, defect)) : die(defect)), catchIf(isError, (error) => fail(AcpRequestError.fromProtocolError(error, { method }))), catchTags({ RpcClientError: (cause) => fail(new AcpTransportError({
85032
85211
  operation: "call-rpc",
85033
85212
  method,
85034
85213
  cause
@@ -85388,7 +85567,7 @@ const registerLocalToolHandlers = (input) => gen(function* () {
85388
85567
  });
85389
85568
  //#endregion
85390
85569
  //#region ../t3-shared/src/toolActivity.ts
85391
- function asRecord(value) {
85570
+ function asRecord$1(value) {
85392
85571
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
85393
85572
  }
85394
85573
  function asTrimmedString(value) {
@@ -85418,10 +85597,10 @@ function extractCommandFromTitle$1(title) {
85418
85597
  return /`([^`]+)`/u.exec(title)?.[1]?.trim() || void 0;
85419
85598
  }
85420
85599
  function extractToolCommand(data, title) {
85421
- const item = asRecord(data?.item);
85422
- const itemInput = asRecord(item?.input);
85423
- const itemResult = asRecord(item?.result);
85424
- const rawInput = asRecord(data?.rawInput);
85600
+ const item = asRecord$1(data?.item);
85601
+ const itemInput = asRecord$1(item?.input);
85602
+ const itemResult = asRecord$1(item?.result);
85603
+ const rawInput = asRecord$1(data?.rawInput);
85425
85604
  const direct = [
85426
85605
  normalizeCommandValue$1(item?.command),
85427
85606
  normalizeCommandValue$1(itemInput?.command),
@@ -85449,7 +85628,7 @@ function collectPaths(value, paths, seen, depth) {
85449
85628
  }
85450
85629
  return;
85451
85630
  }
85452
- const record = asRecord(value);
85631
+ const record = asRecord$1(value);
85453
85632
  if (!record) return;
85454
85633
  for (const key of [
85455
85634
  "path",
@@ -85508,7 +85687,7 @@ function deriveToolActivityPresentation(input) {
85508
85687
  const title = asTrimmedString(input.title);
85509
85688
  const detail = stripTrailingExitCode(asTrimmedString(input.detail));
85510
85689
  const fallbackSummary = asTrimmedString(input.fallbackSummary) ?? "Tool";
85511
- const data = asRecord(input.data);
85690
+ const data = asRecord$1(input.data);
85512
85691
  const command = extractToolCommand(data, title);
85513
85692
  const primaryPath = extractPrimaryPath(data);
85514
85693
  const action = classifyToolAction({
@@ -85532,7 +85711,7 @@ function deriveToolActivityPresentation(input) {
85532
85711
  ...primaryPath ? { detail: primaryPath } : {}
85533
85712
  };
85534
85713
  if (action === "search") {
85535
- const query = asTrimmedString(asRecord(data?.rawInput)?.query) ?? asTrimmedString(asRecord(data?.rawInput)?.pattern) ?? asTrimmedString(asRecord(data?.rawInput)?.searchTerm);
85714
+ const query = asTrimmedString(asRecord$1(data?.rawInput)?.query) ?? asTrimmedString(asRecord$1(data?.rawInput)?.pattern) ?? asTrimmedString(asRecord$1(data?.rawInput)?.searchTerm);
85536
85715
  return {
85537
85716
  summary: "Searched files",
85538
85717
  ...query ? { detail: query } : {}
@@ -85841,6 +86020,20 @@ function parseSessionUpdateEvent(params) {
85841
86020
  function formatConfigOptionValue(value) {
85842
86021
  return JSON.stringify(value);
85843
86022
  }
86023
+ function safeProcessCommand(command) {
86024
+ const basename = command.split(/[\\/]/).at(-1) ?? "unknown";
86025
+ return basename.length <= 128 && /^[A-Za-z0-9._-]+$/.test(basename) ? basename : "unknown";
86026
+ }
86027
+ function safeArgumentKind(argument) {
86028
+ return argument.startsWith("-") ? "flag" : "positional";
86029
+ }
86030
+ function safeErrorTag(error) {
86031
+ if (error !== null && typeof error === "object" && "_tag" in error) {
86032
+ const tag = error._tag;
86033
+ if (typeof tag === "string" && /^[A-Za-z][A-Za-z0-9._-]*$/.test(tag)) return tag;
86034
+ }
86035
+ return "unknown";
86036
+ }
85844
86037
  const defaultSessionLoadTimeout = seconds(90);
85845
86038
  const defaultSessionLoadReplayIdleGap = seconds(2);
85846
86039
  var AcpSessionRuntime = class extends Service$2()("t3/provider/acp/AcpSessionRuntime") {};
@@ -85892,6 +86085,38 @@ const make$4 = (options) => gen(function* () {
85892
86085
  command: options.spawn.command,
85893
86086
  cause
85894
86087
  })));
86088
+ const logProcessEvent = (stage, payload) => options.protocolLogging?.logger?.({
86089
+ direction: "incoming",
86090
+ stage,
86091
+ payload
86092
+ }) ?? void_$1;
86093
+ yield* logProcessEvent("process_spawned", {
86094
+ command: safeProcessCommand(spawnCommand.command),
86095
+ argumentCount: Math.min(spawnCommand.args.length, 1e3),
86096
+ argumentKinds: spawnCommand.args.slice(0, 32).map(safeArgumentKind),
86097
+ pid: child.pid
86098
+ });
86099
+ yield* child.stderr.pipe(runForEach((chunk) => {
86100
+ const text = new TextDecoder().decode(chunk);
86101
+ return logProcessEvent("process_stderr", {
86102
+ pid: child.pid,
86103
+ byteLength: chunk.byteLength,
86104
+ lineBreakCount: Math.min(text.match(/\n/g)?.length ?? 0, 1e4)
86105
+ });
86106
+ }), catch_((error) => logProcessEvent("process_stderr", {
86107
+ pid: child.pid,
86108
+ errorTag: safeErrorTag(error)
86109
+ })), forkIn(runtimeScope));
86110
+ yield* child.exitCode.pipe(matchEffect({
86111
+ onFailure: (error) => logProcessEvent("process_exited", {
86112
+ pid: child.pid,
86113
+ errorTag: safeErrorTag(error)
86114
+ }),
86115
+ onSuccess: (exitCode) => logProcessEvent("process_exited", {
86116
+ pid: child.pid,
86117
+ exitCode
86118
+ })
86119
+ }), forkIn(runtimeScope));
85895
86120
  const acpContext = yield* build(layerChildProcess(child, {
85896
86121
  ...options.protocolLogging?.logIncoming !== void 0 ? { logIncoming: options.protocolLogging.logIncoming } : {},
85897
86122
  ...options.protocolLogging?.logOutgoing !== void 0 ? { logOutgoing: options.protocolLogging.logOutgoing } : {},
@@ -86642,6 +86867,13 @@ function makeAcpContentDeltaEvent(input) {
86642
86867
  }
86643
86868
  //#endregion
86644
86869
  //#region src/provider/acp/AcpNativeLogging.ts
86870
+ const canonicalStopReasons = /* @__PURE__ */ new Set([
86871
+ "end_turn",
86872
+ "max_tokens",
86873
+ "max_turn_requests",
86874
+ "refusal",
86875
+ "cancelled"
86876
+ ]);
86645
86877
  function structuralMethod(value) {
86646
86878
  return value.length <= 128 && /^[A-Za-z][A-Za-z0-9._:/-]*$/.test(value) ? value : "unknown";
86647
86879
  }
@@ -86672,7 +86904,127 @@ function summarizePayload(payload) {
86672
86904
  return { valueType: "object" };
86673
86905
  }
86674
86906
  }
86907
+ function boundedNumber(value, maximum) {
86908
+ return typeof value === "number" && Number.isFinite(value) ? Math.min(Math.max(0, value), maximum) : void 0;
86909
+ }
86910
+ function structuralNames(value) {
86911
+ return Array.isArray(value) ? value.slice(0, 16).map((item) => typeof item === "string" ? structuralMethod(item) : "unknown") : void 0;
86912
+ }
86913
+ function schemaIssueDiagnostics(root) {
86914
+ let issueCount = 0;
86915
+ let maximumPathDepth = 0;
86916
+ const issueKinds = /* @__PURE__ */ new Set();
86917
+ const visit = (issue, pathDepth) => {
86918
+ if (issueCount >= 1e4) return;
86919
+ issueCount += 1;
86920
+ issueKinds.add(structuralMethod(issue._tag));
86921
+ maximumPathDepth = Math.max(maximumPathDepth, pathDepth);
86922
+ switch (issue._tag) {
86923
+ case "Filter":
86924
+ case "Encoding":
86925
+ visit(issue.issue, pathDepth);
86926
+ break;
86927
+ case "Pointer":
86928
+ visit(issue.issue, Math.min(pathDepth + issue.path.length, 1e3));
86929
+ break;
86930
+ case "Composite":
86931
+ case "AnyOf":
86932
+ for (const child of issue.issues.slice(0, 1e3)) visit(child, pathDepth);
86933
+ break;
86934
+ }
86935
+ };
86936
+ visit(root, 0);
86937
+ return {
86938
+ issueCount,
86939
+ issueKinds: [...issueKinds].slice(0, 16),
86940
+ maximumPathDepth
86941
+ };
86942
+ }
86943
+ function asRecord(value) {
86944
+ return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
86945
+ }
86946
+ function summarizeRequestCause(cause) {
86947
+ for (const reason of cause.reasons) {
86948
+ if (reason._tag !== "Fail") continue;
86949
+ const failure = asRecord(reason.error);
86950
+ if (failure?._tag === "AcpProtocolParseError" && failure.operation === "decode-rpc-result") {
86951
+ const issueCount = boundedNumber(failure.issueCount, 1e4);
86952
+ const issueKinds = structuralNames(failure.issueKinds);
86953
+ const maximumPathDepth = boundedNumber(failure.maximumPathDepth, 1e3);
86954
+ return {
86955
+ failureKind: "rpc-result-decode",
86956
+ causeTags: ["AcpProtocolParseError", "SchemaError"],
86957
+ ...issueCount === void 0 ? {} : { issueCount },
86958
+ ...issueKinds ? { issueKinds } : {},
86959
+ ...maximumPathDepth === void 0 ? {} : { maximumPathDepth }
86960
+ };
86961
+ }
86962
+ const transport = failure;
86963
+ if (transport?._tag !== "AcpTransportError" || transport.operation !== "call-rpc") continue;
86964
+ const rpcClient = asRecord(transport.cause);
86965
+ if (rpcClient?._tag !== "RpcClientError") continue;
86966
+ const rpcDefect = asRecord(rpcClient.reason);
86967
+ if (rpcDefect?._tag !== "RpcClientDefect" || !isSchemaError(rpcDefect.cause)) continue;
86968
+ return {
86969
+ failureKind: "rpc-result-decode",
86970
+ causeTags: [
86971
+ "AcpTransportError",
86972
+ "RpcClientError",
86973
+ "RpcClientDefect",
86974
+ "SchemaError"
86975
+ ],
86976
+ ...schemaIssueDiagnostics(rpcDefect.cause.issue)
86977
+ };
86978
+ }
86979
+ }
86980
+ function summarizeProtocolDiagnostics(payload) {
86981
+ if (payload === null || typeof payload !== "object" || Array.isArray(payload)) return summarizePayload(payload);
86982
+ const record = payload;
86983
+ const requestIdType = typeof record.requestIdType === "string" ? structuralMethod(record.requestIdType) : Object.hasOwn(record, "requestId") ? record.requestId === null ? "null" : Array.isArray(record.requestId) ? "array" : typeof record.requestId : void 0;
86984
+ const issueCount = boundedNumber(record.issueCount, 1e4);
86985
+ const maximumPathDepth = boundedNumber(record.maximumPathDepth, 1e3);
86986
+ const frameCount = boundedNumber(record.frameCount, 16);
86987
+ const pid = boundedNumber(record.pid, Number.MAX_SAFE_INTEGER);
86988
+ const exitCode = boundedNumber(record.exitCode, 255);
86989
+ const byteLength = boundedNumber(record.byteLength, Number.MAX_SAFE_INTEGER);
86990
+ const lineBreakCount = boundedNumber(record.lineBreakCount, 1e4);
86991
+ const argumentCount = boundedNumber(record.argumentCount, 1e3);
86992
+ const argumentKinds = structuralNames(record.argumentKinds);
86993
+ const issueKinds = structuralNames(record.issueKinds);
86994
+ const topLevelFields = structuralNames(record.topLevelFields);
86995
+ const resultFields = structuralNames(record.resultFields);
86996
+ return {
86997
+ valueType: "object",
86998
+ ...typeof record.errorTag === "string" ? { errorTag: structuralMethod(record.errorTag) } : {},
86999
+ ...typeof record.command === "string" ? { command: structuralMethod(record.command) } : {},
87000
+ ...argumentCount === void 0 ? {} : { argumentCount },
87001
+ ...argumentKinds ? { argumentKinds } : {},
87002
+ ...typeof record.operation === "string" ? { operation: structuralMethod(record.operation) } : {},
87003
+ ...typeof record.method === "string" ? { method: structuralMethod(record.method) } : {},
87004
+ ...requestIdType ? {
87005
+ requestIdType,
87006
+ requestId: "redacted"
87007
+ } : {},
87008
+ ...issueCount === void 0 ? {} : { issueCount },
87009
+ ...issueKinds ? { issueKinds } : {},
87010
+ ...maximumPathDepth === void 0 ? {} : { maximumPathDepth },
87011
+ ...typeof record.jsonSyntaxValid === "boolean" ? { jsonSyntaxValid: record.jsonSyntaxValid } : {},
87012
+ ...frameCount === void 0 ? {} : { frameCount },
87013
+ ...typeof record.topLevelType === "string" ? { topLevelType: structuralMethod(record.topLevelType) } : {},
87014
+ ...topLevelFields ? { topLevelFields } : {},
87015
+ ...typeof record.jsonrpcType === "string" ? { jsonrpcType: structuralMethod(record.jsonrpcType) } : {},
87016
+ ...typeof record.idType === "string" ? { idType: structuralMethod(record.idType) } : {},
87017
+ ...resultFields ? { resultFields } : {},
87018
+ ...typeof record.stopReasonType === "string" ? { stopReasonType: structuralMethod(record.stopReasonType) } : {},
87019
+ ...typeof record.canonicalStopReason === "string" && canonicalStopReasons.has(record.canonicalStopReason) ? { canonicalStopReason: record.canonicalStopReason } : {},
87020
+ ...pid === void 0 ? {} : { pid },
87021
+ ...exitCode === void 0 ? {} : { exitCode },
87022
+ ...byteLength === void 0 ? {} : { byteLength },
87023
+ ...lineBreakCount === void 0 ? {} : { lineBreakCount }
87024
+ };
87025
+ }
86675
87026
  function formatRequestLogPayload(event) {
87027
+ const causeDiagnostics = event.cause ? summarizeRequestCause(event.cause) : void 0;
86676
87028
  return {
86677
87029
  method: structuralMethod(event.method),
86678
87030
  status: event.status,
@@ -86680,7 +87032,8 @@ function formatRequestLogPayload(event) {
86680
87032
  ...event.result !== void 0 ? { result: summarizePayload(event.result) } : {},
86681
87033
  ...event.cause !== void 0 ? {
86682
87034
  errorTag: causeErrorTag(event.cause),
86683
- reasonCount: event.cause.reasons.length
87035
+ reasonCount: event.cause.reasons.length,
87036
+ ...causeDiagnostics ?? {}
86684
87037
  } : {}
86685
87038
  };
86686
87039
  }
@@ -86688,7 +87041,7 @@ function formatProtocolLogPayload(event) {
86688
87041
  return {
86689
87042
  direction: event.direction,
86690
87043
  stage: event.stage,
86691
- payload: summarizePayload(event.payload)
87044
+ payload: event.stage === "decode_failed" || event.stage === "terminated" || event.stage === "process_spawned" || event.stage === "process_stderr" || event.stage === "process_exited" ? summarizeProtocolDiagnostics(event.payload) : summarizePayload(event.payload)
86692
87045
  };
86693
87046
  }
86694
87047
  const makeAcpNativeLoggerFactory = fn("makeAcpNativeLoggerFactory")(function* () {